From b8869bb8481972d62bf13c9c320cab66f4175f2c Mon Sep 17 00:00:00 2001 From: jpekkila Date: Mon, 1 Jul 2019 18:37:56 +0300 Subject: [PATCH] Linked the defines used by the DSL and astaroth.h. Now f.ex. LENTROPY has to be set only once in acc/mhd_solver/stencil_defines.h and it is propagated throughout the whole project. The name for stencil_defines.h is not final and may change if I come up with a better name. In any case, there is now a standard header associated with each DSL solver where the user can set defines, and declare arrays (VTXBUF_LNRHO) and device constants (uniforms). --- acc/compile.sh | 2 +- acc/mhd_solver/stencil_defines.h | 9 +++++++++ acc/preprocess.sh | 2 +- include/astaroth.h | 9 +-------- scripts/compile_acc.sh | 9 ++++++--- 5 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 acc/mhd_solver/stencil_defines.h diff --git a/acc/compile.sh b/acc/compile.sh index 55831cd..7f7c143 100755 --- a/acc/compile.sh +++ b/acc/compile.sh @@ -21,4 +21,4 @@ else exit fi -${ACC_DIR}/preprocess.sh $1 | ${ACC_DIR}/build/acc ${COMPILE_FLAGS} > ${CUH_FILENAME} +${ACC_DIR}/preprocess.sh $2 $1 | ${ACC_DIR}/build/acc ${COMPILE_FLAGS} > ${CUH_FILENAME} diff --git a/acc/mhd_solver/stencil_defines.h b/acc/mhd_solver/stencil_defines.h new file mode 100644 index 0000000..880b5f9 --- /dev/null +++ b/acc/mhd_solver/stencil_defines.h @@ -0,0 +1,9 @@ +#define STENCIL_ORDER (6) +#define NGHOST (STENCIL_ORDER / 2) +#define LDENSITY (1) +#define LHYDRO (1) +#define LMAGNETIC (0) +#define LENTROPY (0) +#define LTEMPERATURE (0) +#define LFORCING (0) +#define LUPWD (0) diff --git a/acc/preprocess.sh b/acc/preprocess.sh index 0ce6fbc..ededfdc 100755 --- a/acc/preprocess.sh +++ b/acc/preprocess.sh @@ -1,4 +1,4 @@ #!/bin/bash # Preprocesses the give file using GCC. This script is usually automatically called in # ./compile.sh, but may be called also individually for debugging purposes. -gcc -E -x c ${@} | sed "s/#.*//g" +cat ${@} | gcc -x c -E - | sed "s/#.*//g" diff --git a/include/astaroth.h b/include/astaroth.h index c3d8f82..9fff494 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -69,14 +69,7 @@ extern "C" { // clang-format off #ifndef USER_PROVIDED_DEFINES - #define STENCIL_ORDER (6) - #define NGHOST (STENCIL_ORDER / 2) - #define LDENSITY (1) - #define LHYDRO (1) - #define LMAGNETIC (1) - #define LENTROPY (1) - #define LTEMPERATURE (0) - #define LFORCING (1) + #include "acc/mhd_solver/stencil_defines.h" // TODO: this should be in a standard location #endif // clang-format on diff --git a/scripts/compile_acc.sh b/scripts/compile_acc.sh index d051c7b..0debccf 100755 --- a/scripts/compile_acc.sh +++ b/scripts/compile_acc.sh @@ -8,6 +8,7 @@ fi KERNEL_DIR=${AC_HOME}"/src/core/kernels" ACC_DIR=${AC_HOME}"/acc" +ACC_DEFAULT_HEADER="mhd_solver/stencil_defines.h" ACC_DEFAULT_SAS="mhd_solver/stencil_assembly.sas" ACC_DEFAULT_SPS="mhd_solver/stencil_process.sps" @@ -15,12 +16,13 @@ ${ACC_DIR}/clean.sh ${ACC_DIR}/build_acc.sh +ACC_HEADER=${ACC_DEFAULT_HEADER} ACC_SAS=${ACC_DEFAULT_SAS} ACC_SPS=${ACC_DEFAULT_SPS} while [ "$#" -gt 0 ] do - case $1 in + case $1 in -h|--help) echo "You can set a custom files for DSL under the path $AC_HOME/" echo "Example:" @@ -44,9 +46,10 @@ do esac done +echo "Header file:" ${ACC_DIR}/${ACC_HEADER} echo "Assembly file: ${ACC_DIR}/${ACC_SAS}" echo "Process file: ${ACC_DIR}/${ACC_SPS}" cd ${KERNEL_DIR} -${ACC_DIR}/compile.sh ${ACC_DIR}/${ACC_SAS} -${ACC_DIR}/compile.sh ${ACC_DIR}/${ACC_SPS} +${ACC_DIR}/compile.sh ${ACC_DIR}/${ACC_SAS} ${ACC_DIR}/${ACC_HEADER} +${ACC_DIR}/compile.sh ${ACC_DIR}/${ACC_SPS} ${ACC_DIR}/${ACC_HEADER}