1from itertools
import combinations
3from pathlib
import Path
8machine =
"grace_hopper"
10patch_sizes = [3, 6, 16]
14 3: [
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128",
"256",
"512",
"1024",
"2048",
"4096",
"8192"],
15 6: [
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128",
"256",
"512",
"1024",
"2048",
"4096",
"8192"],
16 16: [
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128",
"256",
"512",
"1024",
"2048",
"4096",
"8192"]
19if machine ==
"grace_hopper":
20 partition =
"gracehopper"
22 set_environment = f
"source {Path.home()}/set_env_arm.sh"
24 partition =
"cosma8-shm"
26 set_environment = f
"source {Path.home()}/set_env_x86_nvidia.sh"
30 "memory-reuse":
"--enable-memory-reuse",
31 "perfect-loop-nesting":
"--enable-imperfect-nested-loops-to-perfect",
32 "memory-fusion":
"--enable-memory-fusion",
33 "loop-fusion":
"--enable-loop-fusion"
36output_name = f
"{application}_kernel_benchmark"
37job_name = f
"{application}_kernel_benchmark"
38output_root = f
"{Path.home()}/Peano/benchmarks/exahype2/kernel-benchmarks/"
39script_name = f
"submit_kernel_benchmark-gpu-parallel-{application}-{solver}.sh"
40compile_script_name = f
"compile_kernel_benchmark-gpu-parallel-{application}-{solver}.sh"
41run_script_name = f
"run_kernel_benchmark-gpu-parallel-{application}-{solver}.sh"
44 benchmark_script_name =
"kernel-benchmarks-fd4-dsl.py"
45 benchmark_app_name =
"KernelBenchmarksFD4DSL.Release"
46if solver ==
"rusanov":
47 benchmark_script_name =
"kernel-benchmarks-fv-rusanov-dsl.py"
48 benchmark_app_name =
"KernelBenchmarksFVRusanovDSL.Release"
52 print_statement = f
"""echo "Patch Size: {patch_size}, C++" """
54 print_statement = f
"""echo "Patch Size: {patch_size}, MLIR, {", ".join(passes)}" """
55 pass_flags = [optional_passes[enabled_pass]
for enabled_pass
in passes]
56 return f
"""{print_statement}
57python {benchmark_script_name} -d 3 -gpu {"--enable-cpp" if use_cpp else "--enable-mlir"} -ps {patch_size} -p {" ".join(number_of_patches)} -samples {number_of_samples} {" ".join(pass_flags)}
58./{benchmark_app_name} > {output_directory}/patch_size_{patch_size}.txt
63 print_statement = f
"""echo "Patch Size: {patch_size}, C++" """
64 benchmark_executable_name = f
"cpp_{patch_size}"
66 print_statement = f
"""echo "Patch Size: {patch_size}, MLIR, {", ".join(passes)}" """
68 benchmark_executable_name = f
"no-passes_{patch_size}"
70 benchmark_executable_name = f
"{'_'.join(passes)}_{patch_size}"
71 pass_flags = [optional_passes[enabled_pass]
for enabled_pass
in passes]
72 return f
"""{print_statement}
73python {benchmark_script_name} -d 3 -gpu {"--enable-cpp" if use_cpp else "--enable-mlir"} -ps {patch_size} -p {" ".join(number_of_patches)} -samples {number_of_samples} {" ".join(pass_flags)} -o {benchmark_executable_name}
78 print_statement = f
"""echo "Patch Size: {patch_size}, C++" """
79 benchmark_executable_name = f
"cpp_{patch_size}"
81 print_statement = f
"""echo "Patch Size: {patch_size}, MLIR, {", ".join(passes)}" """
83 benchmark_executable_name = f
"no-passes_{patch_size}"
85 benchmark_executable_name = f
"{'_'.join(passes)}_{patch_size}"
86 return f
"""{print_statement}
87./{benchmark_executable_name}.Release > {output_directory}/patch_size_{patch_size}.txt
92submission_scripts = []
94for patch_size
in patch_sizes:
95 number_of_patches = numbers_of_patches[patch_size]
98 for i
in range(0, len(optional_passes) + 1):
99 for combination
in list(combinations(optional_passes, i)):
100 pass_list.append(combination)
103 output_directory = output_root + f
"results/{application}/{solver}/gpu_parallel/{machine}/cpp"
104 if not os.path.exists(output_directory):
105 os.makedirs(output_directory)
111 output_directory = output_root + f
"results/{application}/{solver}/gpu_parallel/{machine}/no-passes"
112 if not os.path.exists(output_directory):
113 os.makedirs(output_directory)
119 for optional_pass
in optional_passes.keys():
120 output_directory = output_root + f
"results/{application}/{solver}/gpu_parallel/{machine}/{optional_pass}"
121 if not os.path.exists(output_directory):
122 os.makedirs(output_directory)
127with open(compile_script_name,
"w")
as file:
128 file.write(f
"""#!/bin/bash -l
130#SBATCH -o {output_name}.out
131#SBATCH -e {output_name}.err
132#SBATCH -t {runtime_hours}:00:00
135#SBATCH -p {partition}
138export PATH=~/Peano/src/exahype2/mlir/build/bin/:$PATH
139export PYTHONPATH=~/Peano/python/:~/Peano/applications/exahype2/ccz4/:~/Peano/src/
142 for script
in compile_scripts:
143 file.write(script +
"\n")
145with open(run_script_name,
"w")
as file:
146 file.write(f
"""#!/bin/bash -l
148#SBATCH -o {output_name}.out
149#SBATCH -e {output_name}.err
150#SBATCH -t {runtime_hours}:00:00
153#SBATCH -p {partition}
156export PATH=~/Peano/src/exahype2/mlir/build/bin/:$PATH
157export PYTHONPATH=~/Peano/python/:~/Peano/applications/exahype2/ccz4/:~/Peano/src/
160 for script
in run_scripts:
161 file.write(script +
"\n")
163with open(script_name,
"w")
as file:
164 file.write(f
"""#!/bin/bash -l
166#SBATCH -o {output_name}.out
167#SBATCH -e {output_name}.err
168#SBATCH -t {runtime_hours}:00:00
171#SBATCH -p {partition}
174export PATH=~/Peano/src/exahype2/mlir/build/bin/:$PATH
175export PYTHONPATH=~/Peano/python/:~/Peano/applications/exahype2/ccz4/:~/Peano/src/
179 for script
in submission_scripts:
180 file.write(script +
"\n")
generate_compilation_script_fragment(bool use_cpp, int patch_size, list[int] number_of_patches, list[str] passes, str output_directory)
generate_running_script_fragment(bool use_cpp, int patch_size, list[int] number_of_patches, list[str] passes, str output_directory)
generate_submission_script_fragment(bool use_cpp, int patch_size, list[str] number_of_patches, list[str] passes, str output_directory)