Skip to content

Commit

Permalink
Fix lint formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Riyaz Haque committed Oct 22, 2024
1 parent d1e0913 commit 11aa249
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 44 deletions.
12 changes: 8 additions & 4 deletions lib/benchpark/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class CudaExperiment:
variant(
"cuda",
default="non",
values=("oui", "non"),
description="Build and run with CUDA",
default="non",
values=("oui", "non"),
description="Build and run with CUDA",
)

class Helper(ExperimentHelperBase):
Expand Down Expand Up @@ -43,4 +43,8 @@ def compute_spack_section(self):
}

def generate_spack_specs(self):
return "+cuda cuda_arch={cuda_arch}" if self.spec.satisfies("cuda=oui") else "~cuda"
return (
"+cuda cuda_arch={cuda_arch}"
if self.spec.satisfies("cuda=oui")
else "~cuda"
)
25 changes: 16 additions & 9 deletions lib/benchpark/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ramble.language.language_base # noqa
import ramble.language.language_helpers # noqa


class ExperimentHelperBase:
def __init__(self, exp):
self.spec = exp.spec
Expand All @@ -39,9 +40,7 @@ def compute_spack_section(self):
return {}

def generate_spack_specs(self):
raise NotImplementedError(
"Each experiment must implement generate_spack_specs"
)
raise NotImplementedError("Each experiment must implement generate_spack_specs")

class Experiment(ExperimentSystemBase):
"""This is the superclass for all benchpark experiments.
Expand Down Expand Up @@ -78,7 +77,7 @@ def __init__(self, spec):

for cls in self.__class__.mro()[1:]:
if cls is not Experiment and cls is not object:
if hasattr(cls, 'Helper'):
if hasattr(cls, "Helper"):
helper_instance = cls.Helper(self)
self.helpers.append(helper_instance)

Expand All @@ -104,8 +103,8 @@ def compute_modifiers_section(self):
def compute_applications_section(self):
# Require that the experiment defines num_procs
variables = {}
variables["n_ranks"] = self.num_procs
variables["n_ranks"] = self.num_procs

raise NotImplementedError(
"Each experiment must implement compute_applications_section"
)
Expand All @@ -118,13 +117,21 @@ def compute_spack_section(self):
package_specs_dict = {}
for cls in self.helpers:
cls_package_specs_dict = cls.compute_spack_section()
if cls_package_specs_dict and "packages" in cls_package_specs_dict and "environments" in cls_package_specs_dict:
if (
cls_package_specs_dict
and "packages" in cls_package_specs_dict
and "environments" in cls_package_specs_dict
):
if not package_specs_dict:
package_specs_dict["packages"] = cls_package_specs_dict["packages"]
package_specs_dict["environment"] = cls_package_specs_dict["environments"]
package_specs_dict["environment"] = cls_package_specs_dict[
"environments"
]
else:
package_specs_dict["packages"] |= cls_package_specs_dict["packages"]
package_specs_dict["environment"] |= cls_package_specs_dict["environments"]
package_specs_dict["environment"] |= cls_package_specs_dict[
"environments"
]
return package_specs_dict

def generate_spack_specs(self):
Expand Down
6 changes: 3 additions & 3 deletions lib/benchpark/openmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class OpenMPExperiment(Experiment):
variant(
"openmp",
default="non",
values=("oui", "non"),
description="Build and run with OpenMP",
default="non",
values=("oui", "non"),
description="Build and run with OpenMP",
)

class Helper(ExperimentHelperBase):
Expand Down
12 changes: 8 additions & 4 deletions lib/benchpark/rocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
class ROCmExperiment:
variant(
"rocm",
default="non",
values=("oui", "non"),
description="Build and run with ROCm",
default="non",
values=("oui", "non"),
description="Build and run with ROCm",
)

class Helper(ExperimentHelperBase):
def generate_spack_specs(self):
return "+rocm amdgpu_target={rocm_arch}" if self.spec.satisfies("rocm=oui") else "~rocm"
return (
"+rocm amdgpu_target={rocm_arch}"
if self.spec.satisfies("rocm=oui")
else "~rocm"
)
26 changes: 11 additions & 15 deletions var/exp_repo/experiments/amg2023/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Amg2023(OpenMPExperiment, CudaExperiment, ROCmExperiment, Caliper, Experim
description="custom spack specs",
)

#requires("system+papi", when(caliper=topdown*))
# requires("system+papi", when(caliper=topdown*))

# TODO: Support list of 3-tuples
# variant(
Expand Down Expand Up @@ -87,16 +87,12 @@ def make_experiment_example(self):
variables["nz"] = n
zips["size"] = ["nx", "ny", "nz"]

m_tag = (
"matrices" if self.spec.satisfies("openmp=oui") else "matrix"
)
m_tag = "matrices" if self.spec.satisfies("openmp=oui") else "matrix"
if self.spec.satisfies("openmp=oui"):
matrices.append(
{"size_nodes_threads": ["size", "n_nodes", "n_threads_per_proc"]}
)
elif self.spec.satisfies("cuda=oui") or self.spec.satisfies(
"rocm=oui"
):
elif self.spec.satisfies("cuda=oui") or self.spec.satisfies("rocm=oui"):
matrices.append("size")
else:
pass
Expand Down Expand Up @@ -148,7 +144,7 @@ def compute_spack_section(self):
app_name = self.spec.name

# set package versions
app_version = self.spec.variants['version'][0]
app_version = self.spec.variants["version"][0]

# get system config options
# TODO: Get compiler/mpi/package handles directly from system.py
Expand Down Expand Up @@ -185,14 +181,14 @@ def compute_spack_section(self):
}

package_specs[app_name]["pkg_spec"] += super().generate_spack_specs()
package_specs[app_name]["pkg_spec"] += " " + self.spec.variants['extra_specs'][0]
package_specs[app_name]["pkg_spec"] = package_specs[app_name]["pkg_spec"].strip()
package_specs[app_name]["pkg_spec"] += (
" " + self.spec.variants["extra_specs"][0]
)
package_specs[app_name]["pkg_spec"] = package_specs[app_name][
"pkg_spec"
].strip()

return {
"packages": {k: v for k, v in package_specs.items() if v},
"environments": {
app_name: {
"packages": list(package_specs.keys())
}
},
"environments": {app_name: {"packages": list(package_specs.keys())}},
}
20 changes: 11 additions & 9 deletions var/exp_repo/experiments/kripke/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def compute_applications_section(self):
elif self.spec.satisfies("rocm=oui"):
variables["arch"] = "HIP"

experiment_name_template = f"kripke_{variables['arch']}_{self.spec.variants['scaling'][0]}"
experiment_name_template = (
f"kripke_{variables['arch']}_{self.spec.variants['scaling'][0]}"
)
experiment_name_template += "_{n_nodes}_{n_ranks}_{n_threads_per_proc}_{ngroups}_{gs}_{nquad}_{ds}_{lorder}_{nzx}_{nzy}_{nzz}_{npx}_{npy}_{npz}"

return {
Expand All @@ -135,7 +137,7 @@ def compute_spack_section(self):
app_name = self.spec.name

# set package versions
app_version = self.spec.variants['version'][0]
app_version = self.spec.variants["version"][0]

# get system config options
# TODO: Get compiler/mpi/package handles directly from system.py
Expand All @@ -158,14 +160,14 @@ def compute_spack_section(self):
}

package_specs[app_name]["pkg_spec"] += super().generate_spack_specs()
package_specs[app_name]["pkg_spec"] += " " + self.spec.variants['extra_specs'][0]
package_specs[app_name]["pkg_spec"] = package_specs[app_name]["pkg_spec"].strip()
package_specs[app_name]["pkg_spec"] += (
" " + self.spec.variants["extra_specs"][0]
)
package_specs[app_name]["pkg_spec"] = package_specs[app_name][
"pkg_spec"
].strip()

return {
"packages": {k: v for k, v in package_specs.items() if v},
"environments": {
app_name: {
"packages": list(package_specs.keys())
}
},
"environments": {app_name: {"packages": list(package_specs.keys())}},
}

0 comments on commit 11aa249

Please sign in to comment.