Skip to content
Open
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
43 changes: 43 additions & 0 deletions thicket/compiler_static_info_reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2022 Lawrence Livermore National Security, LLC and other
# Thicket Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: MIT
import json


class CompilerStaticInfoReader:
def __init__(self, preprocessed_file):
self.preprocessed_file = preprocessed_file

def build_path_to_node(self, graph):
path_to_node = {}

def dfs(node, path_parts, visited):
if node in visited:
return
visited.add(node)
name = node.frame["name"]
curr_path = path_parts + [name]
path_to_node["/".join(curr_path)] = node
for child in node.children:
dfs(child, curr_path, visited)

visited = set()
for root in graph.roots:
dfs(root, [], visited)
return path_to_node

def add_to_thicket(self, thicket):
# Expects flattened preprocessor output (run preprocessor.py with --flat):
with open(self.preprocessed_file) as f:
data = json.load(f)

region_index = self.build_path_to_node(thicket.graph)

for region_path, metrics in data.items():
th_node = region_index.get(region_path)
if th_node is None:
continue

for metric, value in metrics.items():
thicket.dataframe.loc[th_node, metric] = value
31 changes: 31 additions & 0 deletions thicket/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ def rajaperf_unique_tunings(data_dir, tmpdir):
return [os.path.join(str(tmpdir), f) for f in cali_files]


@pytest.fixture
def rajaperf_hip_O2_32M_cali(data_dir, tmpdir):
"""All trials of for RAJA HIP optimization level O2 and total node problem size 536870912."""
cali_files = sorted(
glob(
f"{data_dir}/rajaperf-comp-static-data/tuolumne/runtime/O2/**/RAJA_HIP-block_256.cali",
recursive=True,
)
)
for cf in cali_files:
shutil.copy(cf, str(tmpdir))
return [os.path.join(str(tmpdir), f) for f in cali_files]


@pytest.fixture
def rajaperf_hip_O2_32M_compiler_static_info(data_dir, tmpdir):
"""Trace log and extraction plugin output for RAJA HIP at optimization level O2 and problem size 512M"""
postprocessed_file = os.path.join(
data_dir,
"rajaperf-comp-static-data/tuolumne/llvm_pass_plugins/data.json",
)

dest_postprocessed_file = os.path.join(
str(tmpdir), os.path.basename(postprocessed_file)
)

shutil.copy(postprocessed_file, dest_postprocessed_file)

return dest_postprocessed_file


@pytest.fixture
def caliper_ordered(data_dir, tmpdir):
"""Builds a temporary directory containing the lulesh cali file."""
Expand Down
Loading
Loading