Deprecated the old style of selecting a config file (was a compile-time parameter). The config file is now a runtime parameter and can be changed without recompilation. Usage: ./ac_run -s <path/to/config/file/relative/to/ac_run/path>. config/astaroth.conf is selected by default if the custom path is not supplied to ac_run.
This commit is contained in:
@@ -27,7 +27,6 @@ option(BUILD_C_API_TEST "Builds a C program to test whether the API is c
|
||||
option(BUILD_MPI_TEST "Builds a C program to test whether MPI works" OFF)
|
||||
option(DOUBLE_PRECISION "Generates double precision code" OFF)
|
||||
option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON)
|
||||
option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF)
|
||||
|
||||
## Compile the Astaroth Code compiler
|
||||
find_package(FLEX)
|
||||
|
@@ -30,11 +30,4 @@ target_link_libraries(astaroth_standalone PRIVATE astaroth_core "${OpenMP_CXX_FL
|
||||
|
||||
add_executable(ac_run main.cc)
|
||||
target_link_libraries(ac_run PRIVATE astaroth_standalone)
|
||||
|
||||
# Define the config directory
|
||||
if (ALTER_CONF)
|
||||
# ASTAROTH_CONF_PATH supplied by ac_mkbuilddir.sh
|
||||
target_compile_definitions(astaroth_standalone PRIVATE CONFIG_PATH="${ASTAROTH_CONF_PATH}/")
|
||||
else()
|
||||
target_compile_definitions(astaroth_standalone PRIVATE CONFIG_PATH="${CMAKE_SOURCE_DIR}/config/")
|
||||
endif()
|
||||
add_definitions(-DAC_DEFAULT_CONFIG="${CMAKE_SOURCE_DIR}/config/astaroth.conf")
|
||||
|
@@ -456,7 +456,7 @@ check_rk3(const AcMeshInfo& mesh_info)
|
||||
}
|
||||
|
||||
int
|
||||
run_autotest(void)
|
||||
run_autotest(const char* config_path)
|
||||
{
|
||||
#if GEN_TEST_RESULT == 1
|
||||
char testresult_path[256];
|
||||
@@ -471,7 +471,7 @@ run_autotest(void)
|
||||
|
||||
/* Parse configs */
|
||||
AcMeshInfo config;
|
||||
load_config(&config);
|
||||
load_config(config_path, &config);
|
||||
|
||||
if (STENCIL_ORDER > 6)
|
||||
printf("WARNING!!! If the stencil order is larger than the computational domain some "
|
||||
|
@@ -41,13 +41,13 @@
|
||||
#include <vector>
|
||||
|
||||
int
|
||||
run_benchmark(void)
|
||||
run_benchmark(const char* config_path)
|
||||
{
|
||||
const int nn = 256;
|
||||
const int num_iters = 100;
|
||||
|
||||
AcMeshInfo mesh_info;
|
||||
load_config(&mesh_info);
|
||||
load_config(config_path, &mesh_info);
|
||||
mesh_info.int_params[AC_nx] = nn;
|
||||
mesh_info.int_params[AC_ny] = mesh_info.int_params[AC_nx];
|
||||
mesh_info.int_params[AC_nz] = mesh_info.int_params[AC_nx];
|
||||
|
@@ -159,14 +159,16 @@ update_config(AcMeshInfo* config)
|
||||
\return 0 on success, -1 if there are potentially uninitialized values.
|
||||
*/
|
||||
int
|
||||
load_config(AcMeshInfo* config)
|
||||
load_config(const char* config_path, AcMeshInfo* config)
|
||||
{
|
||||
int retval = 0;
|
||||
ERRCHK(config_path);
|
||||
|
||||
// memset reads the second parameter as a byte even though it says int in
|
||||
// the function declaration
|
||||
memset(config, (uint8_t)0xFF, sizeof(*config));
|
||||
|
||||
parse_config(CONFIG_PATH "astaroth.conf", config);
|
||||
parse_config(config_path, config);
|
||||
update_config(config);
|
||||
|
||||
// sizeof(config) must be a multiple of 4 bytes for this to work
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "astaroth.h"
|
||||
|
||||
/** Loads data from the config file */
|
||||
int load_config(AcMeshInfo* config);
|
||||
int load_config(const char* config_path, AcMeshInfo* config);
|
||||
|
||||
/** Recalculates the portion of int parameters which get their values from nx,
|
||||
* ny and nz. Must be called after modifying the config struct or otherwise
|
||||
|
@@ -73,16 +73,24 @@ main(int argc, char* argv[])
|
||||
for (int i = 0; i < argc; ++i)
|
||||
printf("%d: %s\n", i, argv[i]);
|
||||
|
||||
const size_t buf_size = 256;
|
||||
char config_path[buf_size];
|
||||
(argc == 3) ? strncpy(config_path, argv[2], buf_size)
|
||||
: strncpy(config_path, AC_DEFAULT_CONFIG, buf_size);
|
||||
|
||||
printf("Config path: %s\n", config_path);
|
||||
if (argc == 1) {
|
||||
return run_renderer();
|
||||
return run_renderer(config_path);
|
||||
}
|
||||
else if (argc == 2) {
|
||||
else if (argc == 2 || argc == 3) {
|
||||
if (strcmp(argv[1], "-t") == 0)
|
||||
return run_autotest();
|
||||
return run_autotest(config_path);
|
||||
else if (strcmp(argv[1], "-b") == 0)
|
||||
return run_benchmark();
|
||||
return run_benchmark(config_path);
|
||||
else if (strcmp(argv[1], "-s") == 0)
|
||||
return run_simulation();
|
||||
return run_simulation(config_path);
|
||||
else if (strcmp(argv[1], "-r") == 0)
|
||||
return run_renderer(config_path);
|
||||
else
|
||||
WARNING("Unrecognized option");
|
||||
}
|
||||
|
@@ -354,11 +354,11 @@ check_input(const float& dt)
|
||||
}
|
||||
|
||||
int
|
||||
run_renderer(void)
|
||||
run_renderer(const char* config_path)
|
||||
{
|
||||
/* Parse configs */
|
||||
AcMeshInfo mesh_info;
|
||||
load_config(&mesh_info);
|
||||
load_config(config_path, &mesh_info);
|
||||
renderer_init(mesh_info.int_params[AC_mx], mesh_info.int_params[AC_my]);
|
||||
|
||||
AcMesh* mesh = acmesh_create(mesh_info);
|
||||
@@ -455,7 +455,7 @@ run_renderer(void)
|
||||
#else // BUILD_RT_VISUALIZATION == 0
|
||||
#include "src/core/errchk.h"
|
||||
int
|
||||
run_renderer(void)
|
||||
run_renderer(const char* /*config_path*/)
|
||||
{
|
||||
WARNING("Real-time visualization module not built. Set BUILD_RT_VISUALIZATION=ON with cmake.");
|
||||
return 1;
|
||||
|
@@ -26,10 +26,10 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
int run_autotest(void);
|
||||
int run_autotest(const char* config_path);
|
||||
|
||||
int run_simulation(void);
|
||||
int run_simulation(const char* config_path);
|
||||
|
||||
int run_benchmark(void);
|
||||
int run_benchmark(const char* config_path);
|
||||
|
||||
int run_renderer(void);
|
||||
int run_renderer(const char* config_path);
|
||||
|
@@ -223,11 +223,11 @@ print_diagnostics(const int step, const AcReal dt, const AcReal t_step, FILE* di
|
||||
*/
|
||||
|
||||
int
|
||||
run_simulation(void)
|
||||
run_simulation(const char* config_path)
|
||||
{
|
||||
/* Parse configs */
|
||||
AcMeshInfo mesh_info;
|
||||
load_config(&mesh_info);
|
||||
load_config(config_path, &mesh_info);
|
||||
|
||||
AcMesh* mesh = acmesh_create(mesh_info);
|
||||
// TODO: This need to be possible to define in astaroth.conf
|
||||
|
Reference in New Issue
Block a user