Merged in config_selection_as_runtime_option_20190918 (pull request #9)
Config selection as runtime option 20190918 (includes branch acc_cmake_integration_20190918)
This commit is contained in:
@@ -27,7 +27,35 @@ 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(BUILD_MPI_TEST "Builds a C program to test whether MPI works" OFF)
|
||||||
option(DOUBLE_PRECISION "Generates double precision code" OFF)
|
option(DOUBLE_PRECISION "Generates double precision code" OFF)
|
||||||
option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON)
|
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)
|
||||||
|
find_package(BISON)
|
||||||
|
execute_process (
|
||||||
|
COMMAND ./build_acc.sh
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/acc
|
||||||
|
)
|
||||||
|
# NOTE: Manually defined DSL_MODULE_DIR must be set relative to the project root, not the actual
|
||||||
|
# build directory!
|
||||||
|
# NO! ../acc/mhd_solver
|
||||||
|
# YES! acc/mhd_solver
|
||||||
|
|
||||||
|
if (NOT DEFINED DSL_MODULE_DIR)
|
||||||
|
set(DSL_MODULE_DIR ${CMAKE_SOURCE_DIR}/acc/mhd_solver)
|
||||||
|
endif ()
|
||||||
|
get_filename_component(DSL_MODULE_DIR ${DSL_MODULE_DIR} REALPATH)
|
||||||
|
message(STATUS "DSL module dir: ${DSL_MODULE_DIR}")
|
||||||
|
set(DSL_SOURCES ${DSL_MODULE_DIR}/*)
|
||||||
|
set(DSL_HEADERS "${PROJECT_BINARY_DIR}/stencil_assembly.cuh"
|
||||||
|
"${PROJECT_BINARY_DIR}/stencil_process.cuh"
|
||||||
|
"${PROJECT_BINARY_DIR}/stencil_defines.h")
|
||||||
|
add_custom_command (
|
||||||
|
COMMENT "Building AC objects ${DSL_MODULE_DIR}"
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR}/scripts/compile_acc_module.sh ${DSL_MODULE_DIR}
|
||||||
|
DEPENDS ${DSL_SOURCES}
|
||||||
|
OUTPUT ${DSL_HEADERS}
|
||||||
|
)
|
||||||
|
add_custom_target(dsl_headers ALL DEPENDS ${DSL_HEADERS})
|
||||||
|
|
||||||
## Build types
|
## Build types
|
||||||
# Available types (case-sensitive):
|
# Available types (case-sensitive):
|
||||||
|
@@ -6,14 +6,14 @@ COMPILER_NAME="acc"
|
|||||||
SRC_DIR=${PWD}/src
|
SRC_DIR=${PWD}/src
|
||||||
BUILD_DIR=${PWD}/build
|
BUILD_DIR=${PWD}/build
|
||||||
|
|
||||||
echo "Created" ${BUILD_DIR}
|
echo "-- Compiling acc:" ${BUILD_DIR}
|
||||||
|
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
echo ${BASE_DIR}
|
#echo ${BASE_DIR}
|
||||||
echo ${SRC_DIR}
|
#echo ${SRC_DIR}
|
||||||
echo ${BUILD_DIR}
|
#echo ${BUILD_DIR}
|
||||||
|
|
||||||
# Generate Bison headers
|
# Generate Bison headers
|
||||||
bison --verbose -d ${SRC_DIR}/${COMPILER_NAME}.y
|
bison --verbose -d ${SRC_DIR}/${COMPILER_NAME}.y
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Usage ./compile <source file>
|
# Usage ./compile <source file> <gcc preprocessor flags, f.ex. -I some/path>
|
||||||
|
|
||||||
ACC_DIR=`dirname $0`
|
ACC_DIR=`dirname $0`
|
||||||
|
|
||||||
@@ -10,19 +10,19 @@ EXTENSION="${FULL_NAME##*.}"
|
|||||||
if [ "${EXTENSION}" = "sas" ]; then
|
if [ "${EXTENSION}" = "sas" ]; then
|
||||||
COMPILE_FLAGS="-sas" # Generate stencil assembly stage
|
COMPILE_FLAGS="-sas" # Generate stencil assembly stage
|
||||||
CUH_FILENAME="stencil_assembly.cuh"
|
CUH_FILENAME="stencil_assembly.cuh"
|
||||||
echo "Generating stencil assembly stage ${FILENAME}.sas -> ${CUH_FILENAME}"
|
echo "-- Generating stencil assembly stage: ${FILENAME}.sas -> ${CUH_FILENAME}"
|
||||||
elif [ "${EXTENSION}" = "sps" ]; then
|
elif [ "${EXTENSION}" = "sps" ]; then
|
||||||
COMPILE_FLAGS="-sps" # Generate stencil processing stage
|
COMPILE_FLAGS="-sps" # Generate stencil processing stage
|
||||||
CUH_FILENAME="stencil_process.cuh"
|
CUH_FILENAME="stencil_process.cuh"
|
||||||
echo "Generating stencil processing stage: ${FILENAME}.sps -> ${CUH_FILENAME}"
|
echo "-- Generating stencil processing stage: ${FILENAME}.sps -> ${CUH_FILENAME}"
|
||||||
elif [ "${EXTENSION}" = "sdh" ]; then
|
elif [ "${EXTENSION}" = "sdh" ]; then
|
||||||
COMPILE_FLAGS="-sdh" # Generate stencil definition header
|
COMPILE_FLAGS="-sdh" # Generate stencil definition header
|
||||||
CUH_FILENAME="stencil_defines.h"
|
CUH_FILENAME="stencil_defines.h"
|
||||||
echo "Generating stencil definition header: ${FILENAME}.sdh -> ${CUH_FILENAME}"
|
echo "-- Generating stencil definition header: ${FILENAME}.sdh -> ${CUH_FILENAME}"
|
||||||
else
|
else
|
||||||
echo "Error: unknown extension" ${EXTENSION} "of file" ${FULL_NAME}
|
echo "-- Error: unknown extension" ${EXTENSION} "of file" ${FULL_NAME}
|
||||||
echo "Extension should be either .sas, .sps or .sdh"
|
echo "-- Extension should be either .sas, .sps or .sdh"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${ACC_DIR}/preprocess.sh $1 | ${ACC_DIR}/build/acc ${COMPILE_FLAGS} > ${CUH_FILENAME}
|
${ACC_DIR}/preprocess.sh $@ | ${ACC_DIR}/build/acc ${COMPILE_FLAGS} > ${CUH_FILENAME}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Preprocesses the give file using GCC. This script is usually automatically called in
|
# Preprocesses the give file using GCC. This script is usually automatically called in
|
||||||
# ./compile.sh, but may be called also individually for debugging purposes.
|
# ./compile.sh, but may be called also individually for debugging purposes.
|
||||||
cat ${@} | gcc -x c -E - | sed "s/#.*//g"
|
cat $1 | gcc ${@:2} -x c -E - | sed "s/#.*//g"
|
||||||
|
@@ -650,8 +650,10 @@ main(int argc, char** argv)
|
|||||||
compilation_type = STENCIL_PROCESS;
|
compilation_type = STENCIL_PROCESS;
|
||||||
else if (!strcmp(argv[1], "-sdh"))
|
else if (!strcmp(argv[1], "-sdh"))
|
||||||
compilation_type = STENCIL_HEADER;
|
compilation_type = STENCIL_HEADER;
|
||||||
else
|
else {
|
||||||
printf("Unknown flag %s. Generating stencil assembly.\n", argv[1]);
|
printf("Unknown flag %s. Generating stencil assembly.\n", argv[1]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Usage: ./acc [flags]\n"
|
printf("Usage: ./acc [flags]\n"
|
||||||
@@ -685,4 +687,5 @@ main(int argc, char** argv)
|
|||||||
// Cleanup
|
// Cleanup
|
||||||
astnode_destroy(root);
|
astnode_destroy(root);
|
||||||
// printf("COMPILATION SUCCESS\n");
|
// printf("COMPILATION SUCCESS\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -18,11 +18,9 @@ pipelines:
|
|||||||
scheduled:
|
scheduled:
|
||||||
- step:
|
- step:
|
||||||
script: # Modify the commands below to build your repository.
|
script: # Modify the commands below to build your repository.
|
||||||
- source ./sourceme.sh
|
|
||||||
- mkdir -p build && cd build
|
- mkdir -p build && cd build
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y cmake flex bison
|
- apt-get install -y cmake flex bison
|
||||||
- ../scripts/compile_acc.sh
|
- cmake -DDSL_MODULE_DIR="acc/mhd_solver" ..
|
||||||
- cmake ..
|
|
||||||
- make -j
|
- make -j
|
||||||
# - ./ac_run -t
|
# - ./ac_run -t
|
||||||
|
9
scripts/compile_acc_module.sh
Executable file
9
scripts/compile_acc_module.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
ACC_DIR=$(readlink -f $(dirname $0)/../acc)
|
||||||
|
MODULE_DIR=$(readlink -f $1)
|
||||||
|
|
||||||
|
echo "-- Compiling project in "${MODULE_DIR}
|
||||||
|
for source in ${MODULE_DIR}/*.sas ${MODULE_DIR}/*.sps ${MODULE_DIR}/*.sdh
|
||||||
|
do
|
||||||
|
${ACC_DIR}/compile.sh $source -I ${MODULE_DIR}
|
||||||
|
done
|
@@ -37,3 +37,4 @@ endif ()
|
|||||||
cuda_add_library(astaroth_core STATIC astaroth.cu device.cu node.cu)
|
cuda_add_library(astaroth_core STATIC astaroth.cu device.cu node.cu)
|
||||||
target_include_directories(astaroth_core PRIVATE .)
|
target_include_directories(astaroth_core PRIVATE .)
|
||||||
target_link_libraries(astaroth_core m)
|
target_link_libraries(astaroth_core m)
|
||||||
|
add_dependencies(astaroth_core dsl_headers)
|
||||||
|
@@ -30,11 +30,4 @@ target_link_libraries(astaroth_standalone PRIVATE astaroth_core "${OpenMP_CXX_FL
|
|||||||
|
|
||||||
add_executable(ac_run main.cc)
|
add_executable(ac_run main.cc)
|
||||||
target_link_libraries(ac_run PRIVATE astaroth_standalone)
|
target_link_libraries(ac_run PRIVATE astaroth_standalone)
|
||||||
|
add_definitions(-DAC_DEFAULT_CONFIG="${CMAKE_SOURCE_DIR}/config/astaroth.conf")
|
||||||
# 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()
|
|
||||||
|
@@ -456,7 +456,7 @@ check_rk3(const AcMeshInfo& mesh_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
run_autotest(void)
|
run_autotest(const char* config_path)
|
||||||
{
|
{
|
||||||
#if GEN_TEST_RESULT == 1
|
#if GEN_TEST_RESULT == 1
|
||||||
char testresult_path[256];
|
char testresult_path[256];
|
||||||
@@ -471,7 +471,7 @@ run_autotest(void)
|
|||||||
|
|
||||||
/* Parse configs */
|
/* Parse configs */
|
||||||
AcMeshInfo config;
|
AcMeshInfo config;
|
||||||
load_config(&config);
|
load_config(config_path, &config);
|
||||||
|
|
||||||
if (STENCIL_ORDER > 6)
|
if (STENCIL_ORDER > 6)
|
||||||
printf("WARNING!!! If the stencil order is larger than the computational domain some "
|
printf("WARNING!!! If the stencil order is larger than the computational domain some "
|
||||||
|
@@ -41,13 +41,13 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
int
|
int
|
||||||
run_benchmark(void)
|
run_benchmark(const char* config_path)
|
||||||
{
|
{
|
||||||
const int nn = 256;
|
const int nn = 256;
|
||||||
const int num_iters = 100;
|
const int num_iters = 100;
|
||||||
|
|
||||||
AcMeshInfo mesh_info;
|
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_nx] = nn;
|
||||||
mesh_info.int_params[AC_ny] = mesh_info.int_params[AC_nx];
|
mesh_info.int_params[AC_ny] = mesh_info.int_params[AC_nx];
|
||||||
mesh_info.int_params[AC_nz] = 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.
|
\return 0 on success, -1 if there are potentially uninitialized values.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
load_config(AcMeshInfo* config)
|
load_config(const char* config_path, AcMeshInfo* config)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
ERRCHK(config_path);
|
||||||
|
|
||||||
// memset reads the second parameter as a byte even though it says int in
|
// memset reads the second parameter as a byte even though it says int in
|
||||||
// the function declaration
|
// the function declaration
|
||||||
memset(config, (uint8_t)0xFF, sizeof(*config));
|
memset(config, (uint8_t)0xFF, sizeof(*config));
|
||||||
|
|
||||||
parse_config(CONFIG_PATH "astaroth.conf", config);
|
parse_config(config_path, config);
|
||||||
update_config(config);
|
update_config(config);
|
||||||
|
|
||||||
// sizeof(config) must be a multiple of 4 bytes for this to work
|
// sizeof(config) must be a multiple of 4 bytes for this to work
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include "astaroth.h"
|
#include "astaroth.h"
|
||||||
|
|
||||||
/** Loads data from the config file */
|
/** 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,
|
/** 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
|
* ny and nz. Must be called after modifying the config struct or otherwise
|
||||||
|
@@ -73,16 +73,25 @@ main(int argc, char* argv[])
|
|||||||
for (int i = 0; i < argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
printf("%d: %s\n", i, argv[i]);
|
printf("%d: %s\n", i, argv[i]);
|
||||||
|
|
||||||
|
char* config_path;
|
||||||
|
(argc == 3) ? config_path = strdup(argv[2])
|
||||||
|
: config_path = strdup(AC_DEFAULT_CONFIG);
|
||||||
|
|
||||||
|
printf("Config path: %s\n", config_path);
|
||||||
|
ERRCHK(config_path);
|
||||||
|
|
||||||
if (argc == 1) {
|
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)
|
if (strcmp(argv[1], "-t") == 0)
|
||||||
return run_autotest();
|
return run_autotest(config_path);
|
||||||
else if (strcmp(argv[1], "-b") == 0)
|
else if (strcmp(argv[1], "-b") == 0)
|
||||||
return run_benchmark();
|
return run_benchmark(config_path);
|
||||||
else if (strcmp(argv[1], "-s") == 0)
|
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
|
else
|
||||||
WARNING("Unrecognized option");
|
WARNING("Unrecognized option");
|
||||||
}
|
}
|
||||||
@@ -90,5 +99,6 @@ main(int argc, char* argv[])
|
|||||||
WARNING("Too many options given");
|
WARNING("Too many options given");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(config_path);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@@ -354,11 +354,11 @@ check_input(const float& dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
run_renderer(void)
|
run_renderer(const char* config_path)
|
||||||
{
|
{
|
||||||
/* Parse configs */
|
/* Parse configs */
|
||||||
AcMeshInfo mesh_info;
|
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]);
|
renderer_init(mesh_info.int_params[AC_mx], mesh_info.int_params[AC_my]);
|
||||||
|
|
||||||
AcMesh* mesh = acmesh_create(mesh_info);
|
AcMesh* mesh = acmesh_create(mesh_info);
|
||||||
@@ -455,7 +455,7 @@ run_renderer(void)
|
|||||||
#else // BUILD_RT_VISUALIZATION == 0
|
#else // BUILD_RT_VISUALIZATION == 0
|
||||||
#include "src/core/errchk.h"
|
#include "src/core/errchk.h"
|
||||||
int
|
int
|
||||||
run_renderer(void)
|
run_renderer(const char* /*config_path*/)
|
||||||
{
|
{
|
||||||
WARNING("Real-time visualization module not built. Set BUILD_RT_VISUALIZATION=ON with cmake.");
|
WARNING("Real-time visualization module not built. Set BUILD_RT_VISUALIZATION=ON with cmake.");
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -26,10 +26,10 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#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);
|
||||||
|
@@ -175,11 +175,11 @@ print_diagnostics(const int step, const AcReal dt, const AcReal t_step, FILE* di
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
run_simulation(void)
|
run_simulation(const char* config_path)
|
||||||
{
|
{
|
||||||
/* Parse configs */
|
/* Parse configs */
|
||||||
AcMeshInfo mesh_info;
|
AcMeshInfo mesh_info;
|
||||||
load_config(&mesh_info);
|
load_config(config_path, &mesh_info);
|
||||||
|
|
||||||
AcMesh* mesh = acmesh_create(mesh_info);
|
AcMesh* mesh = acmesh_create(mesh_info);
|
||||||
// TODO: This need to be possible to define in astaroth.conf
|
// TODO: This need to be possible to define in astaroth.conf
|
||||||
|
Reference in New Issue
Block a user