Skip to content

Commit

Permalink
Add missing-only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
berkayurun committed Sep 28, 2023
1 parent e206bf1 commit 42e5ab9
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 2 deletions.
88 changes: 86 additions & 2 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,60 @@ def read_backup(hdf5_file):
return [backup_expanded_faults, backup_config, backup_goldenrun]


def read_simulated_faults(hdf5_file):
with tables.open_file(hdf5_file, "r") as f_in:
# Process simulated faults
simulated_faults_hash = {}
exp_n = 0

for exp in tqdm(
f_in.root.fault,
total=f_in.root.fault._v_nchildren,
desc="Reading simulated faults",
):
simulated_exp = {
"index": exp_n,
"faultlist": [
Fault(
fault["fault_address"],
[],
fault["fault_type"],
fault["fault_model"],
fault["fault_lifespan"],
fault["fault_mask"],
fault["trigger_address"],
fault["trigger_hitcounter"],
fault["fault_num_bytes"],
fault["fault_wildcard"],
)
for fault in exp.faults.iterrows()
],
}

config_hash = hashlib.sha256()
for fault in simulated_exp["faultlist"]:
config_hash.update(str(fault).encode())
simulated_faults_hash[config_hash.digest()] = simulated_exp

exp_n = exp_n + 1

return simulated_faults_hash


def get_not_simulated_faults(faultlist, simulated_faults):
missing_faultlist = []

for faultconfig in faultlist:
config_hash = hashlib.sha256()
for fault in faultconfig["faultlist"]:
config_hash.update(str(fault).encode())

if not config_hash.digest() in simulated_faults:
missing_faultlist.append(faultconfig)

return missing_faultlist


def controller(
args,
hdf5mode,
Expand All @@ -495,6 +549,7 @@ def controller(
num_workers,
queuedepth,
compressionlevel,
missing_only,
goldenrun_only,
goldenrun=True,
logger=hdf5collector,
Expand Down Expand Up @@ -592,6 +647,20 @@ def controller(
log_config = True
log_goldenrun = True

if missing_only:
simulated_faults = read_simulated_faults(hdf5_file)
faultlist = get_not_simulated_faults(faultlist, simulated_faults)

log_config = False
log_goldenrun = False

overwrite_faults = False

if faultlist:
clogger.info(f"{len(faultlist)} faults are missing and will be simulated")
else:
clogger.info("All faults are already simulated")

p_logger = Process(
target=logger,
args=(
Expand Down Expand Up @@ -750,7 +819,7 @@ def controller(
if faultlist:
tperindex = (t1 - t0) / len(faultlist)
else:
tperindex = (t1 - t0)
tperindex = t1 - t0

tperworker = tperindex / num_workers
clogger.debug(
Expand Down Expand Up @@ -847,6 +916,13 @@ def get_argument_parser():
action="store_true",
required=False,
)
parser.add_argument(
"--missing-only",
"-m",
help="Only run missing experiments",
action="store_true",
required=False,
)
return parser


Expand Down Expand Up @@ -889,6 +965,13 @@ def process_arguments(args):
else:
parguments["goldenrun_only"] = False

if args.missing_only and hdf5file.is_file():
parguments["missing_only"] = True
parguments["hdf5mode"] = "a"
parguments["goldenrun"] = False
else:
parguments["missing_only"] = False

qemu_conf = json.load(args.qemu)
args.qemu.close()
print(qemu_conf)
Expand Down Expand Up @@ -996,7 +1079,8 @@ def init_logging():
parguments["num_workers"], # num_workers
parguments["queuedepth"], # queuedepth
parguments["compressionlevel"], # compressionlevel
parguments["goldenrun_only"],
parguments["missing_only"], # missing_only flag
parguments["goldenrun_only"], # goldenrun_only flag
parguments["goldenrun"], # goldenrun
hdf5collector, # logger
None, # qemu_pre
Expand Down
13 changes: 13 additions & 0 deletions faultclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ def __init__(
self.num_bytes = num_bytes
self.wildcard = wildcard

def __str__(self):
return (
f"{self.trigger.address}"
f"{self.trigger.hitcounter}"
f"{self.address}"
f"{self.type}"
f"{self.model}"
f"{self.lifespan}"
f"{self.mask}"
f"{self.num_bytes}"
f"{self.wildcard}"
)


def write_fault_list_to_pipe(fault_list, fifo):
fault_pack = fault_pb2.FaultPack()
Expand Down

0 comments on commit 42e5ab9

Please sign in to comment.