Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] Feature: Forward Benchpark Metadata to Caliper #478

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
13 changes: 13 additions & 0 deletions experiments/caliper/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,16 @@ def get_helper_name_prefix(self):

def get_spack_variants(self):
return "~caliper" if self.spec.satisfies("caliper=none") else "+caliper"

def compute_variables_section(self):
""" Add Caliper metadata variables for the ramble.yaml """
if not self.spec.satisfies("caliper=none"):
return {
"caliper_metadata": {
"application_name": "{application_name}",
"experiment_name": "{experiment_name}",
"workload_name": "{workload_name}"
}
}
else:
return {}
14 changes: 13 additions & 1 deletion lib/benchpark/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def get_helper_name_prefix(self):
def get_spack_variants(self):
return None

def compute_variables_section(self):
return {}

class SingleNode:
variant(
Expand Down Expand Up @@ -240,10 +242,13 @@ def compute_spack_section_wrapper(self):
"packages": {k: v for k, v in self.package_specs.items() if v},
"environments": {self.name: {"packages": list(self.package_specs.keys())}},
}

def compute_variables_section(self):
return {}

def compute_ramble_dict(self):
# This can be overridden by any subclass that needs more flexibility
return {
ramble_dict = {
"ramble": {
"include": self.compute_include_section(),
"config": self.compute_config_section(),
Expand All @@ -252,6 +257,13 @@ def compute_ramble_dict(self):
"software": self.compute_spack_section_wrapper(),
}
}
# Add any variables from helper classes
for cls in self.helpers:
additional_vars = cls.compute_variables_section()
if additional_vars:
ramble_dict["ramble"].update({"variables": additional_vars})

return ramble_dict

def write_ramble_dict(self, filepath):
ramble_dict = self.compute_ramble_dict()
Expand Down
30 changes: 27 additions & 3 deletions modifiers/caliper/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

from ramble.modkit import *

import json

def add_mode(mode_name, mode_option, description):
mode(
Expand All @@ -30,10 +30,17 @@ class Caliper(SpackModifier):

maintainers("pearce8")

# The filename for Caliper output data
_cali_datafile = "{experiment_run_dir}/{experiment_name}.cali"

# The filename for metadata forwarded from Benchpark to Caliper
_caliper_metadata_file = "{experiment_run_dir}/{experiment_name}_metadata.json"

_default_mode = "time"

# Write out the metadata file once all variables are resolved
register_phase('build_metadata', pipeline='setup', run_after=['make_experiments'])

add_mode(
mode_name=_default_mode,
mode_option="time.exclusive",
Expand All @@ -42,7 +49,7 @@ class Caliper(SpackModifier):

env_var_modification(
"CALI_CONFIG",
"spot(output={}{})".format(_cali_datafile, "${CALI_CONFIG_MODE}"),
dyokelson marked this conversation as resolved.
Show resolved Hide resolved
"spot(output={}{}),metadata(file={}),metadata(file=/etc/node_info.json,keys=\"host.name,host.cluster,host.os\")".format(_cali_datafile, "${CALI_CONFIG_MODE}", _caliper_metadata_file),
method="set",
modes=[_default_mode],
)
Expand Down Expand Up @@ -83,8 +90,25 @@ class Caliper(SpackModifier):
description="Top-down analysis for Intel CPUs (top level)",
)

def _build_metadata(self, workspace, app_inst):
''' Write the caliper metadata to json '''
# Load the Caliper metadata variable from ramble.yaml
# experiment_metadata = self.expander.expand_var('caliper_metadata', typed=True, merge_used_stage=False)
# Error: expand_var() got an unexpected keyword argument 'merge_used_stage'
# TODO: How to get this from the ramble.yaml?
experiment_metadata = self.expander.expand_var('caliper_metadata', typed=True)
#self.expander.flush_used_variables()
# Error: 'Expander' object has no attribute 'flush_used_variables'

# Write to the Caliper metadata file
cali_metadata_file = self.expander.expand_var(self._caliper_metadata_file)
# print(json.dumps(experiment_metadata))
with open(cali_metadata_file, "w") as f:
f.write(json.dumps(experiment_metadata))


archive_pattern(_cali_datafile)

software_spec("caliper", pkg_spec="caliper")

required_package("caliper")
required_package("caliper")
Loading