1from itertools
import combinations
3from pathlib
import Path
8machine =
"sapphire_rapid"
10patch_sizes = [3, 6, 16]
11numbers_of_threads = [1, 2, 4, 8, 16, 32, 64]
15 3: [
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128",
"256",
"512",
"1024",
"2048",
"4096",
"8192"],
16 6: [
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128",
"256",
"512",
"1024",
"2048",
"4096",
"8192"],
17 16: [
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128",
"256",
"512",
"1024",
"2048",
"4096",
"8192"]
22set_environment = f
"source {Path.home()}/set_env_x86_cpu_only.sh"
36 "taskloop_single-region_memref-flattening":
"--enable-memref-flattening --enable-omp-tasks --omp-task-version=taskloop --omp-single-region",
37 "taskloop_single-region_function-inlining":
"--enable-function-inlining --enable-omp-tasks --omp-task-version=taskloop --omp-single-region",
38 "taskloop_single-region_memory-fusion":
"--enable-memory-fusion --enable-omp-tasks --omp-task-version=taskloop --omp-single-region",
39 "taskloop_single-region_loop-fusion":
"--enable-loop-fusion --enable-omp-tasks --omp-task-version=taskloop --omp-single-region",
40 "taskloop_single-region_perfect-loop-nesting":
"--enable-imperfect-nested-loops-to-perfect --enable-omp-tasks --omp-task-version=taskloop --omp-single-region"
43output_name = f
"{application}_kernel_benchmark"
44job_name = f
"{application}_kernel_benchmark"
45output_root = f
"{Path.home()}/Peano/benchmarks/exahype2/kernel-benchmarks/"
46script_name = f
"submit_kernel_benchmark-cpu-parallel-{application}-{solver}.sh"
49 benchmark_script_name =
"kernel-benchmarks-fd4-dsl.py"
50 benchmark_app_name =
"KernelBenchmarksFD4DSL.Release"
51if solver ==
"rusanov":
52 benchmark_script_name =
"kernel-benchmarks-fv-rusanov-dsl.py"
53 benchmark_app_name =
"KernelBenchmarksFVRusanovDSL.Release"
57 print_statement = f
"""echo "Patch Size: {patch_size}, C++" """
59 print_statement = f
"""echo "Patch Size: {patch_size}, MLIR, {", ".join(passes)}" """
60 pass_flags = [optional_passes[enabled_pass]
for enabled_pass
in passes]
61 return f
"""{print_statement}
62python {benchmark_script_name} -d 3 -cpu {"--enable-cpp" if use_cpp else "--enable-mlir"} -parallel -ps {patch_size} -p {" ".join(number_of_patches)} -samples {number_of_samples} {" ".join(pass_flags)}
63for number_of_threads in "${{numbers_of_threads[@]}}"; do
64 echo "Number of threads: ${{number_of_threads}}"
65 export OMP_NUM_THREADS=${{number_of_threads}}
66 ./{benchmark_app_name} > {output_directory}/patch_size_{patch_size}_threads_${{number_of_threads}}.txt
71submission_scripts = []
73for patch_size
in patch_sizes:
74 number_of_patches = numbers_of_patches[patch_size]
77 for i
in range(0, len(optional_passes) + 1):
78 for combination
in list(combinations(optional_passes, i)):
79 pass_list.append(combination)
94 for optional_pass
in optional_passes.keys():
95 output_directory = output_root + f
"results/{application}/{solver}/cpu_parallel/{machine}/{optional_pass}"
96 if not os.path.exists(output_directory):
97 os.makedirs(output_directory)
100with open(script_name,
"w")
as file:
101 file.write(f
"""#!/bin/bash -l
103#SBATCH -o {output_name}.out
104#SBATCH -e {output_name}.err
105#SBATCH -t {runtime_hours}:00:00
109#SBATCH -p {partition}
111#SBATCH --mem={memory}
113export PATH=~/Peano/src/exahype2/mlir/build/bin/:$PATH
114export PYTHONPATH=~/Peano/python/:~/Peano/applications/exahype2/ccz4/:~/Peano/src/
117numbers_of_threads=({" ".join([str(number_of_threads) for number_of_threads in numbers_of_threads])})
119 for script
in submission_scripts:
120 file.write(script +
"\n")
generate_submission_script_fragment(bool use_cpp, int patch_size, list[str] number_of_patches, list[str] passes, str output_directory)