Skip to content

Commit

Permalink
#49: Merged #56 into constant output branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco-Cos committed Jul 8, 2024
2 parents 5b9ec94 + a9b358d commit 366a468
Show file tree
Hide file tree
Showing 14 changed files with 2,522 additions and 513 deletions.
20 changes: 12 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ def main():
if args.plot:
pprint.info2('Plotting...')

specs_obj = TemplateSpecs(name='Sop1' if not args.shared else 'SharedLogic', exact=args.benchmark_name, literals_per_product=args.lpp,
products_per_output=args.ppo,
benchmark_name=args.approximate_benchmark, num_of_models=args.num_models, subxpat=args.subxpat,
et=args.et,
specs_obj = TemplateSpecs(name='Sop1' if not args.shared else 'SharedLogic', exact=args.benchmark_name,
literals_per_product=args.lpp, products_per_output=args.ppo,
benchmark_name=args.approximate_benchmark, num_of_models=args.num_models,
subxpat=args.subxpat, subxpat_v2=args.subxpat_v2,
full_error_function=args.full_error_function,
sub_error_function=args.sub_error_function,
et=args.et, et_partitioning=args.et_partitioning,
partitioning_percentage=args.partitioning_percentage, iterations=args.iterations,
grid=args.grid, imax=args.imax, omax=args.omax, sensitivity=args.sensitivity,
timeout=args.timeout, subgraph_size=args.subgraph_size, mode=args.mode, population=args.population,
min_labeling=args.min_labeling,
timeout=args.timeout, subgraph_size=args.subgraph_size, mode=args.mode,
population=args.population,
min_labeling=args.min_labeling, manual_nodes=args.manual_nodes,
shared=args.shared, products_in_total=args.pit, parallel=args.parallel,
encoding=args.encoding,
partial_labeling=args.partial_labeling, num_subgraphs=args.num_subgraphs)
stats_obj = Stats(specs_obj)
stats_obj.gather_results()
Expand All @@ -53,7 +58,7 @@ def main():
grid=args.grid, imax=args.imax, omax=args.omax, sensitivity=args.sensitivity,
timeout=args.timeout, subgraph_size=args.subgraph_size, mode=args.mode, population=args.population,
min_labeling=args.min_labeling, manual_nodes=args.manual_nodes,
shared=args.shared, products_in_total=args.pit, parallel=args.parallel,
shared=args.shared, products_in_total=args.pit, parallel=args.parallel, encoding=args.encoding,
partial_labeling=args.partial_labeling, num_subgraphs=args.num_subgraphs)

if specs_obj.grid:
Expand All @@ -71,7 +76,6 @@ def clean_all():
z3logpath.OUTPUT_PATH['z3'],
z3logpath.OUTPUT_PATH['report'],
z3logpath.OUTPUT_PATH['figure'],
# z3logpath.LOG_PATH['yosys'],
z3logpath.TEST_PATH['tb'],
sxpatpaths.OUTPUT_PATH['area'],
sxpatpaths.OUTPUT_PATH['power'],
Expand Down
455 changes: 449 additions & 6 deletions sxpat/annotatedGraph.py

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions sxpat/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ def __init__(self, tmp_args: argparse):
self.__full_error_function: int = tmp_args.full_error_function
self.__sub_error_function: int = tmp_args.sub_error_function
self.__et_partitioning: int = tmp_args.et_partitioning
self.__encoding: int = tmp_args.encoding

self.__partial_labeling: bool = tmp_args.partial_labeling
self.__num_subgraphs: int = tmp_args.num_subgraphs



@property
def parallel(self):
return self.__parallel
Expand Down Expand Up @@ -233,6 +233,10 @@ def sub_error_function(self):
def et_partitioning(self):
return self.__et_partitioning

@property
def encoding(self):
return self.__encoding

@property
def partial_labeling(self):
return self.__partial_labeling
Expand Down Expand Up @@ -416,6 +420,10 @@ def parse(cls) -> Arguments:
choices=['asc', 'desc', 'smart_asc', 'smart_desc'],
default='asc')

my_parser.add_argument('-encoding',
type=int,
default=1)

my_parser.add_argument('--partial-labeling',
action="store_true",
default=False)
Expand Down Expand Up @@ -460,4 +468,5 @@ def __repr__(self):
f'{self.et_partitioning = }\n' \
f'{self.partial_labeling = }\n' \
f'{self.num_subgraphs = }\n' \
f'{self.clean = }'
f'{self.clean = }\n' \
f'{self.encoding = }'
2 changes: 2 additions & 0 deletions sxpat/config/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
from Z3Log.config.config import *

# OpenSTA for power and delay analysis
OPENSTA = 'sta'
Expand Down Expand Up @@ -31,6 +32,7 @@
POPULATION = 'population'
MIN_LABELING = 'min_labeling'
PARALLEL = 'parallel'
ENCODING = 'encoding'

FULL_ERROR_FUNCTION = 'full_error_function'
SUB_ERROR_FUNCTION = 'sub_error_function'
Expand Down
1 change: 1 addition & 0 deletions sxpat/config/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from Z3Log.config.path import *

OUTPUT_PATH: Dict[str, Tuple[str, str]] = {
**OUTPUT_PATH,
'json': ('output/json', 'json'),
'html': ('output/html', 'html'),
'figure': ('output/figure', 'pdf'),
Expand Down
8 changes: 4 additions & 4 deletions sxpat/labeling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import csv
import re
import os
import shutil

Expand All @@ -8,7 +8,6 @@
from Z3Log.graph import Graph
from Z3Log.utils import *
from Z3Log.z3solver import Z3solver
from Z3Log.config import path as z3logpath


def labeling(exact_benchmark_name: str,
Expand Down Expand Up @@ -77,21 +76,22 @@ def labeling_explicit(exact_benchmark_name: str, approximate_benchmark: str, con
else:
z3py_obj = Z3solver(exact_benchmark_name, approximate_benchmark, experiment=SINGLE, optimization=MAXIMIZE, parallel=parallel)


if constant_value == 0:
labels_false = z3py_obj.label_circuit(False, partial=partial, et=et)

# cleanup (folder report/)
report_folder, _ = OUTPUT_PATH['report']
all_files = [f for f in os.listdir(report_folder)]
print(f'{all_files= }')

for dir in all_files:
if re.search('labeling', dir) and os.path.isdir(f'{report_folder}/{dir}'):
shutil.rmtree(f'{report_folder}/{dir}')

# cleanup (folder z3/)
z3_folder, _ = OUTPUT_PATH['z3']
all_files = [f for f in os.listdir(z3_folder)]
print(f'{all_files= }')

for dir in all_files:
if re.search('labeling', dir) and os.path.isdir(f'{z3_folder}/{dir}'):
shutil.rmtree(f'{z3_folder}/{dir}')
Expand Down
Loading

0 comments on commit 366a468

Please sign in to comment.