chore: Extract benchmark data during CMake configuration

This commit is contained in:
Max Lübke 2025-03-19 09:39:45 +01:00
parent 5141d0901a
commit d77956996c
3 changed files with 65 additions and 69 deletions

View File

@ -6,11 +6,11 @@ This repository contains input data from POET simulations used in the
NAAICE project and is simulated with the latest version of tug with
heterogeneous alphas.
Benchmarks (grids, timestep, file paths, etc) are defined in the
header file `eval/bench_defs.hpp.in`. The data used by the three
benchmarks `barite_200`, `barite_large` and `surfex` are in the
corresponding subdirectories of `eval`, as `tar.gz`. Remember to
unpack them before running the executable!
Benchmarks (grids, timestep, file paths, etc) are defined in the header file
`eval/bench_defs.hpp.in`. The data used by the three benchmarks `barite_200`,
`barite_large` and `surfex` are in the corresponding subdirectories of `eval`,
as `tar.gz`. Remember to unpack them before running the executable into the
same directory of the executable. Or just let CMake do it for you.
To write the results to file, set the `BENCH_OUTPUT` environmental
variable, e.g. `BENCH_OUTPUT=1 ./bench`. The resulting fields are

View File

@ -1,5 +1,31 @@
set(BARITE_200_BENCH "${CMAKE_CURRENT_SOURCE_DIR}/barite_200")
set(BARITE_LARGE_BENCH "${CMAKE_CURRENT_SOURCE_DIR}/barite_large")
set(SURFEX_BENCH "${CMAKE_CURRENT_SOURCE_DIR}/surfex")
set(benchmarks
"${CMAKE_CURRENT_SOURCE_DIR}/barite_200"
"${CMAKE_CURRENT_SOURCE_DIR}/barite_large"
"${CMAKE_CURRENT_SOURCE_DIR}/surfex"
)
foreach(benchmark ${benchmarks})
# find tar.gz files
file(GLOB_RECURSE tar_files "${benchmark}/*.tar.gz")
foreach(tar_file ${tar_files})
# get the name of the tar file
get_filename_component(tar_name ${tar_file} NAME_WE)
# get the name of the directory
get_filename_component(dir_name ${tar_file} DIRECTORY)
get_filename_component(dir_name ${dir_name} NAME)
# create the directory
message("Extracting ${tar_name} to ${dir_name}")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${dir_name}")
# extract the tar file
execute_process(
COMMAND tar -xzf ${tar_file}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${dir_name}"
)
endforeach()
endforeach()
set(BARITE_200_BENCH "${CMAKE_BINARY_DIR}/barite_200")
set(BARITE_LARGE_BENCH "${CMAKE_BINARY_DIR}/barite_large")
set(SURFEX_BENCH "${CMAKE_BINARY_DIR}/surfex")
configure_file(bench_defs.hpp.in bench_defs.hpp)

View File

@ -1,9 +1,9 @@
#ifndef _BENCH_DEFS_HPP
#define _BENCH_DEFS_HPP
#include <iostream>
#include <string>
#include <vector>
#include <iostream>
struct init_boundary {
const std::vector<int> north_const;
@ -31,7 +31,6 @@ struct bench_input {
const int iterations;
};
static const std::vector<int> gen_vec(int elems) {
std::vector<int> vec(elems);
for (int i = 0; i < elems; i++) {
@ -42,7 +41,7 @@ static const std::vector<int> gen_vec(int elems) {
}
static const std::vector<int> gen_vec_rev(int from, int to) {
int size = to - from+1;
int size = to - from + 1;
std::vector<int> vec(size);
for (int i = from; i < to; i++) {
vec[i] = i;
@ -66,9 +65,8 @@ static bench_input barite_200_input = {
.west_const = {0, 1, 2, 3, 4},
.values = {111.0124, 55.50622, -3.336970273297e-08, 0.1, 0.2,
.0, .0}},
.timestep = 1000,
.iterations = 50
};
.timestep = 500,
.iterations = 100};
static bench_input barite_large_input = {
.csv_file_init = "@BARITE_LARGE_BENCH@/barite_large_init.csv",
@ -83,9 +81,8 @@ static bench_input barite_large_input = {
.east_const = {},
.west_const = {},
.values = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
.timestep = 100,
.iterations = 5
};
.timestep = 50,
.iterations = 10};
static bench_input surfex_input = {
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
@ -120,34 +117,7 @@ static bench_input surfex_input = {
2.5e-08, // U4
1.6e-10, // U5
1.0e-05}}, // U6
.timestep = 3600,
.iterations = 20
};
.timestep = 1800,
.iterations = 40};
#endif // _BENCH_DEFS_HPP