diff --git a/.gitignore b/.gitignore index fac449a..cd435dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +### Project specific ignores +results/ + +### Python ignores # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/src/hpc_multibench/configuration.py b/src/hpc_multibench/configuration.py index 34c9914..e84372c 100755 --- a/src/hpc_multibench/configuration.py +++ b/src/hpc_multibench/configuration.py @@ -10,7 +10,7 @@ BASH_SHEBANG = "#!/bin/sh\n" JOB_ID_REGEX = r"Submitted batch job (\d+)" - +OUTPUT_DIRECTORY = Path("results/") class RunConfiguration: """A builder/runner for a run configuration.""" @@ -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" @@ -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 @@ -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: diff --git a/src/hpc_multibench/yaml_ingest.py b/src/hpc_multibench/yaml_ingest.py index f71e203..b88ba35 100755 --- a/src/hpc_multibench/yaml_ingest.py +++ b/src/hpc_multibench/yaml_ingest.py @@ -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]: @@ -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(): diff --git a/yaml_examples/avon_plan.yaml b/yaml_examples/avon_plan.yaml index fc13e94..dde1b90 100644 --- a/yaml_examples/avon_plan.yaml +++ b/yaml_examples/avon_plan.yaml @@ -1,7 +1,7 @@ #defaults: # "default name": executables: - "cpp_reference": + "cpp-reference": sbatch_config: "nodes": 1 "ntasks-per-node": 1 @@ -15,7 +15,7 @@ executables: - "make -j 8" run_command: "./test_HPCCG" - "cpp_openmp": + "cpp-openmp": sbatch_config: "nodes": 1 "ntasks-per-node": 1 @@ -30,7 +30,7 @@ executables: - "make -j 8" run_command: "./test_HPCCG" - "cpp_mpi": + "cpp-mpi": sbatch_config: "nodes": 2 "ntasks-per-node": 8 @@ -45,7 +45,7 @@ executables: - "make -j 8" run_command: "mpirun -n 2 ./test_HPCCG" - "cpp_hybrid": + "cpp-hybrid": sbatch_config: "nodes": 2 "ntasks-per-node": 4 @@ -61,7 +61,7 @@ executables: - "make -j 8" run_command: "mpirun -n 2 ./test_HPCCG" - "rust_reference": + "rust-reference": sbatch_config: "nodes": 1 "ntasks-per-node": 1 @@ -76,7 +76,7 @@ executables: - "cargo build --release" run_command: "cargo run --release" - "rust_rayon": + "rust-rayon": sbatch_config: "nodes": 1 "ntasks-per-node": 1 @@ -92,7 +92,7 @@ executables: - "cargo build --release" run_command: "cargo run --release" - "rust_mpi": + "rust-mpi": sbatch_config: "nodes": 2 "ntasks-per-node": 8 @@ -103,23 +103,24 @@ executables: - "Clang/13.0.1" - "OpenMPI/4.1.4" 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" diff --git a/yaml_examples/kudu_plan.yaml b/yaml_examples/kudu_plan.yaml index 2a76d33..4ee4f50 100644 --- a/yaml_examples/kudu_plan.yaml +++ b/yaml_examples/kudu_plan.yaml @@ -1,7 +1,7 @@ #defaults: # "default name": executables: - "cpp_reference": + "cpp-reference": sbatch_config: "nodes": 1 "ntasks-per-node": 1 @@ -14,7 +14,7 @@ executables: - "make -j 8" run_command: "./test_HPCCG" - "cpp_openmp": + "cpp-openmp": sbatch_config: "nodes": 1 "ntasks-per-node": 1 @@ -28,7 +28,7 @@ executables: - "make -j 8" run_command: "./test_HPCCG" - "cpp_mpi": + "cpp-mpi": sbatch_config: "nodes": 2 "ntasks-per-node": 8 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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"