Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def create_dag(self):
return

num_edges_reduced = len(self.dag.edges_reduced)
# Checking num_basis_paths = num_edges - num_nodes + 2
self.path_dimension = self.dag.num_edges - self.dag.num_nodes + 2
if num_edges_reduced != self.path_dimension:
err_msg = ("The number of non-special edges is different from the dimension of the path.")
Expand Down Expand Up @@ -631,7 +632,9 @@ def on_exit(start_time, infeasible):
logger.info("Candidate path found.")

candidate_path_edges = Dag.get_edges(candidate_path_nodes)
print("candidate_path_edges: ", candidate_path_edges)
compressed_path = self._compress_path(candidate_path_edges)
print("compressed_path: ", compressed_path)

# Temporarily replace the row in the basis matrix to calculate the new determinant.
prev_matrix_row = self.basis_matrix[current_row].copy()
Expand Down
58 changes: 56 additions & 2 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from analyzer import Analyzer
from defaults import logger
from gametime_error import GameTimeError
from nx_helper import write_dag_to_dot_file


def find_config_file(path: str) -> Optional[str]:
Expand Down Expand Up @@ -51,7 +52,7 @@ def find_config_file(path: str) -> Optional[str]:
return None


def run_gametime(config_path: str, clean_temp: bool = True, backend: str = None) -> int:
def run_gametime(config_path: str, clean_temp: bool = True, backend: str = None, visualize_weights: bool = False) -> int:
"""
Run GameTime analysis on the specified configuration.

Expand Down Expand Up @@ -151,6 +152,49 @@ def run_gametime(config_path: str, clean_temp: bool = True, backend: str = None)
logger.info(f"WCET Path: {max_path}")

logger.info("="*60)

# Visualize weighted graph if requested
if visualize_weights:
logger.info("\n" + "="*60)
logger.info("GENERATING WEIGHTED GRAPH DOT FILE")
logger.info("="*60)

# Estimate edge weights
logger.info("Estimating edge weights...")
analyzer.estimate_edge_weights()

# Create output directory for visualizations
# Use the project root's visualizations directory (similar to test file)
config_dir = os.path.dirname(os.path.abspath(config_path))
# Go up to project root and use visualizations directory there
# This matches the test file's approach: ../../visualizations from test location
output_dir = os.path.join(config_dir, '..', '..', 'visualizations')
output_dir = os.path.abspath(output_dir)
os.makedirs(output_dir, exist_ok=True)

# Generate filename based on function name and backend
func_name = project_config.func.replace(' ', '_').lower()
backend_name = project_config.backend if project_config.backend else 'default'
dot_filename = f'{func_name}_{backend_name}_weighted_graph.dot'
dot_path = os.path.join(output_dir, dot_filename)

# Create edge labels with weights
edge_labels = {}
edge_list = list(analyzer.dag.all_edges)
for i in range(len(analyzer.dag.edge_weights)):
if i < len(edge_list):
edge = edge_list[i]
weight = analyzer.dag.edge_weights[i]
if abs(weight) > 0.01: # Only label non-zero weights
edge_labels[edge] = f'{weight:.2f}'
else: # Add zero weights too to avoid KeyError
edge_labels[edge] = '0.00'

logger.info(f"Creating weighted graph DOT file...")
write_dag_to_dot_file(analyzer.dag, dot_path, edges_to_labels=edge_labels)
logger.info(f"DOT file saved to: {dot_path}")
logger.info("="*60)

logger.info("\nAnalysis completed successfully!")

return 0
Expand Down Expand Up @@ -183,6 +227,9 @@ def main():

# Run analysis without cleaning temporary files
gametime /path/to/test/folder --no-clean

# Run analysis and generate weighted graph visualization
gametime /path/to/test/folder --visualize-weights
"""
)

Expand All @@ -209,6 +256,12 @@ def main():
version='GameTime 0.1.0'
)

parser.add_argument(
'--visualize-weights',
action='store_true',
help='Generate a DOT file visualizing the weighted graph with estimated edge weights'
)

args = parser.parse_args()

# Validate the path
Expand All @@ -227,7 +280,8 @@ def main():
exit_code = run_gametime(
config_path,
clean_temp=not args.no_clean,
backend=args.backend
backend=args.backend,
visualize_weights=args.visualize_weights
)

return exit_code
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 0 additions & 39 deletions test/flexpret_test/flexpret_test.py

This file was deleted.

Loading
Loading