Skip to content

Commit

Permalink
Merge branch 'main' into 94-using-constants-for-left-shift
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco-Cos committed Oct 21, 2024
2 parents bb473bc + c19c209 commit fdfe590
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
18 changes: 17 additions & 1 deletion sxpat/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,25 @@ def get_num_models_from_json(self, json_obj: List[Dict]):

def set_path(self, this_path: Tuple[str, str], this_name: Optional[str] = None, id: int = 0):
if this_name is None:
# get data from name
data = NameData.from_filename(self.benchmark_name)

# updte root if origin
if data.is_origin:
data.root = f'{data.root}_{self.template_name}_enc{self.specs.encoding.value}'
data.root = '_'.join((
data.root,
self.template_name,
f'et{self.specs.et}',
f'enc{self.specs.encoding.value}',
f'imax{self.specs.imax}',
f'omax{self.specs.omax}',
))

# update et
ET_PATTERN = re.compile(r'_et\d+')
data.root = ET_PATTERN.sub(f'_et{self.specs.et}', data.root)

# generate successor path
this_name = str(data.get_successor(self.specs.iteration, id))

folder, extenstion = this_path
Expand Down
8 changes: 5 additions & 3 deletions sxpat/utils/name.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations
from typing import Any, Mapping, Optional
from typing import Optional
from os import PathLike
import dataclasses as dc

import re
from time import time_ns

from Z3Log.config import path as z3logpath
from sxpat.config.config import NameParameters
Expand Down Expand Up @@ -52,7 +53,7 @@ class NameData(PathLike):
source_id: Optional[str] = None
curr_id: Optional[str] = None

NAME_PATTERN = re.compile(r'(.+)_s(E|i\d+m\d+)_(i\d+m\d+)')
NAME_PATTERN = re.compile(r'(.+)_s(E|i\d+m\d+t\d+)_(i\d+m\d+t\d+)')

def __post_init__(self):
self.curr_id = self.curr_id or 'E'
Expand All @@ -65,7 +66,8 @@ def from_filename(cls, filename: str) -> NameData:

@staticmethod
def gen_id(iteration_number: int, model_number: int) -> str:
return f'i{iteration_number}m{model_number}'
timestamp = str(time_ns())[-15:]
return f'i{iteration_number}m{model_number}t{timestamp}'

@property
def is_origin(self) -> bool:
Expand Down
2 changes: 0 additions & 2 deletions sxpat/xplore.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ def explore_grid(specs_obj: Specifications):
stats_obj.grid.cells[lpp][ppo].store_model_info(best_model_info)
pprint.success(f'ErrorEval PASS! with total wce = {best_data[4]}')

synth_obj.set_path(z3logpath.OUTPUT_PATH['ver'], list(cur_model_results.keys())[0])

exact_stats = [synth_obj.estimate_area(exact_file_path),
synth_obj.estimate_power(exact_file_path),
synth_obj.estimate_delay(exact_file_path)]
Expand Down

0 comments on commit fdfe590

Please sign in to comment.