Skip to content

Commit

Permalink
Minor tweaks to get things working
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmundGoodman committed Feb 13, 2024
1 parent e868432 commit ce7ab12
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Project specific ignores
results/

### Python ignores
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
10 changes: 8 additions & 2 deletions src/hpc_multibench/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

BASH_SHEBANG = "#!/bin/sh\n"
JOB_ID_REGEX = r"Submitted batch job (\d+)"

OUTPUT_DIRECTORY = Path("results_example/")

class RunConfiguration:
"""A builder/runner for a run configuration."""
Expand All @@ -33,6 +33,9 @@ def sbatch_contents(self) -> str:

for key, value in self.sbatch_config.items():
sbatch_file += f"#SBATCH --{key}={value}\n"
if "output" not in self.sbatch_config:
name = f"{self.name}_" if self.name != "" else slurm
sbatch_file += f"#SBATCH --output={OUTPUT_DIRECTORY}/{name}_%j.out\n"

if len(self.module_loads) > 0:
sbatch_file += "module purge\n"
Expand All @@ -54,7 +57,7 @@ def sbatch_contents(self) -> str:
if self.name != "":
sbatch_file += f" '{self.name}' "
sbatch_file += " ====='\n"
sbatch_file += f"time srun {self.run_command} {self.args}\n"
sbatch_file += f"time {self.run_command} {self.args}\n"

return sbatch_file

Expand All @@ -64,6 +67,9 @@ def __repr__(self) -> str:

def run(self) -> int | None:
"""Run the specified run configuration."""
if "output" not in self.sbatch_config:
# Ensure the output directory exists if it is being used
OUTPUT_DIRECTORY.mkdir(exist_ok=True)
with NamedTemporaryFile(
suffix=".sbatch", dir=Path("./"), mode="w+"
) as sbatch_tmp:
Expand Down
6 changes: 5 additions & 1 deletion src/hpc_multibench/yaml_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def get_matrix_iterator(matrix: list[dict[str, list[Any]]]) -> Iterator[dict[str
yield {item[0]: value}


def get_matrix_variables_suffix(variables: dict[str, Any]) -> str:
"""."""
return ",".join(f"{name}={value.replace('/','').replace(' ','_')}" for name, value in variables.items())

def get_bench(
bench_name: str, bench: Bench, executables: dict[str, Executable]
) -> list[RunConfiguration]:
Expand All @@ -107,7 +111,7 @@ def get_bench(
)
executable = executables[executable_name]
run_configuration = get_run_configuration(
f"{bench_name}/{executable_name}/", executable
f"{bench_name}__{executable_name}__{get_matrix_variables_suffix(matrix_variables)}", executable
)

for key, value in matrix_variables.items():
Expand Down
39 changes: 20 additions & 19 deletions yaml_examples/kudu_plan.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#defaults:
# "default name":
executables:
"cpp_reference":
"cpp-reference":
sbatch_config:
"nodes": 1
"ntasks-per-node": 1
Expand All @@ -14,7 +14,7 @@ executables:
- "make -j 8"
run_command: "./test_HPCCG"

"cpp_openmp":
"cpp-openmp":
sbatch_config:
"nodes": 1
"ntasks-per-node": 1
Expand All @@ -28,7 +28,7 @@ executables:
- "make -j 8"
run_command: "./test_HPCCG"

"cpp_mpi":
"cpp-mpi":
sbatch_config:
"nodes": 2
"ntasks-per-node": 8
Expand All @@ -42,7 +42,7 @@ executables:
- "make -j 8"
run_command: "mpirun -n 2 ./test_HPCCG"

"cpp_hybrid":
"cpp-hybrid":
sbatch_config:
"nodes": 2
"ntasks-per-node": 4
Expand All @@ -57,7 +57,7 @@ executables:
- "make -j 8"
run_command: "mpirun -n 2 ./test_HPCCG"

"rust_reference":
"rust-reference":
sbatch_config:
"nodes": 1
"ntasks-per-node": 1
Expand All @@ -70,7 +70,7 @@ executables:
- "cargo build --release"
run_command: "cargo run --release"

"rust_rayon":
"rust-rayon":
sbatch_config:
"nodes": 1
"ntasks-per-node": 1
Expand All @@ -84,7 +84,7 @@ executables:
- "cargo build --release"
run_command: "cargo run --release"

"rust_mpi":
"rust-mpi":
sbatch_config:
"nodes": 2
"ntasks-per-node": 8
Expand All @@ -93,23 +93,24 @@ executables:
module_loads:
- "cs402-mpi"
environment_variables: {}
directory: "../6_mpi"
directory: "../7_mpi"
build_commands:
- "cargo build --release"
run_command: "mpirun -n 2 cargo run --release"
run_command: "mpirun -n 2 ./target/release/hpccg-rs"

benches:
"cpp_rust_comp":
"cpp-rust-comp":
executables:
# - "cpp_reference"
# - "cpp_openmp"
- "cpp_mpi"
# - "cpp_hybrid"
#- "rust_reference"
# - "rust_rayon"
- "rust_mpi"
- "cpp-reference"
- "cpp-openmp"
- "cpp-mpi"
- "cpp-hybrid"
- "rust-reference"
- "rust-rayon"
- "rust-mpi"
matrix:
- args:
#- "50 50 50"
#- "100 100 100"
- "100 100 100"
- "200 200 200"
- "300 300 300"
- "400 400 400"

0 comments on commit ce7ab12

Please sign in to comment.