From 6bfc5f04f73534aec1b5582a8a45573e3fa074f9 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 26 Jun 2019 13:33:03 +0300 Subject: [PATCH 01/12] Added tighter bounds for gcc and nvcc versions. There was a bit of an chicken-and-egg issue: we need gcc 6.0 in order to get bug 48891 (see gcc bugzilla) fixed, but cuda < 9 supports gcc only up to 5.3. This is not a perfect solution, f.ex. ubuntu 16.04 ships with gcc 5.4 but with the fix backported from later versions so in practice that would also work but is not accepted anymore. --- CMakeLists.txt | 4 ++-- src/core/CMakeLists.txt | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15a48d9..349201e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,8 @@ message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER}) message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER_ID}) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4) - message(FATAL_ERROR "GCC version 5.4 or higher required") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) # Because of GCC bug 48891 + message(FATAL_ERROR "GCC version 6.0 or higher required") endif() endif() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e875faa..9b67f11 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -4,13 +4,7 @@ #----------------------Find CUDA-----------------------------------------------# -find_package(CUDA) -if (NOT CUDA_FOUND) - # find_package(CUDA REQUIRED) gives a confusing error message if it fails, - # therefore we print the reason here explicitly - message(FATAL_ERROR "CUDA not found") -endif() - +find_package(CUDA 9 REQUIRED) #----------------------CUDA settings-------------------------------------------# From ffe9df1bb0938ba3c4dc798382191647c6298c66 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 26 Jun 2019 14:08:56 +0300 Subject: [PATCH 02/12] LFORCING was turned off in stencil_process and the autotests failed, re-enabled --- acc/mhd_solver/stencil_process.sps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acc/mhd_solver/stencil_process.sps b/acc/mhd_solver/stencil_process.sps index 40b28ed..a52f6ac 100644 --- a/acc/mhd_solver/stencil_process.sps +++ b/acc/mhd_solver/stencil_process.sps @@ -2,7 +2,7 @@ #define LENTROPY (1) #define LTEMPERATURE (0) #define LGRAVITY (0) -#define LFORCING (0) +#define LFORCING (1) #define LUPWD (0) From 174e29add68791a1bd2341dcf083c9b8651f1d17 Mon Sep 17 00:00:00 2001 From: Matthias Rheinhardt Date: Wed, 26 Jun 2019 15:11:32 +0300 Subject: [PATCH 03/12] MR: added PENCIL_ASTAROTH --- src/standalone/config_loader.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/standalone/config_loader.cc b/src/standalone/config_loader.cc index 637bcd4..1717cea 100644 --- a/src/standalone/config_loader.cc +++ b/src/standalone/config_loader.cc @@ -153,6 +153,7 @@ update_config(AcMeshInfo* config) config->real_params[AC_sq2GM_star] = AcReal(sqrt(AcReal(2) * config->real_params[AC_GM_star])); const bool print_config = true; +#ifndef PENCIL_ASTAROTH if (print_config) { printf("###############################################################" "\n"); @@ -161,6 +162,7 @@ update_config(AcMeshInfo* config) printf("###############################################################" "\n"); } +#endif } /** From 25f1ec795980fa9f64d6395b10a90ecc9a5fe30e Mon Sep 17 00:00:00 2001 From: Matthias Rheinhardt Date: Wed, 26 Jun 2019 15:13:56 +0300 Subject: [PATCH 04/12] MR: intro'd VERBOSE_PRINT switch --- src/standalone/config_loader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/standalone/config_loader.cc b/src/standalone/config_loader.cc index 1717cea..a3a9abe 100644 --- a/src/standalone/config_loader.cc +++ b/src/standalone/config_loader.cc @@ -153,7 +153,7 @@ update_config(AcMeshInfo* config) config->real_params[AC_sq2GM_star] = AcReal(sqrt(AcReal(2) * config->real_params[AC_GM_star])); const bool print_config = true; -#ifndef PENCIL_ASTAROTH +#ifdef VERBOSE_PRINT if (print_config) { printf("###############################################################" "\n"); From 522da0041f6567f1192b2f4a25b99b53ac51b5b1 Mon Sep 17 00:00:00 2001 From: Matthias Rheinhardt Date: Wed, 26 Jun 2019 16:53:56 +0300 Subject: [PATCH 05/12] MR: new name for GetDevice --- src/core/astaroth.cu | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index 956a24f..fecfdcb 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -74,6 +74,14 @@ printInt3(const int3 vec) AcResult acInit(const AcMeshInfo& config) +{ + Acresult res=acGetDevice(); + res=acInitialize(config); + return AC_SUCCESS; +} + +AcResult +acCheckDeviceAvail() { // Check devices cudaGetDeviceCount(&num_devices); @@ -89,6 +97,11 @@ acInit(const AcMeshInfo& config) WARNING("MULTIGPU_ENABLED was false. Using only one device"); num_devices = 1; // Use only one device if multi-GPU is not enabled } + return AC_SUCCESS; +} +AcResult +acInitialize(const AcMeshInfo& config) +{ // Check that num_devices is divisible with AC_nz. This makes decomposing the // problem domain to multiple GPUs much easier since we do not have to worry // about remainders @@ -108,14 +121,14 @@ acInit(const AcMeshInfo& config) ERRCHK_ALWAYS(subgrid.n.x >= STENCIL_ORDER); ERRCHK_ALWAYS(subgrid.n.y >= STENCIL_ORDER); ERRCHK_ALWAYS(subgrid.n.z >= STENCIL_ORDER); - +#ifndef PENCIL_ASTAROTH // clang-format off printf("Grid m "); printInt3(grid.m); printf("\n"); printf("Grid n "); printInt3(grid.n); printf("\n"); printf("Subrid m "); printInt3(subgrid.m); printf("\n"); printf("Subrid n "); printInt3(subgrid.n); printf("\n"); // clang-format on - +#endif // Initialize the devices for (int i = 0; i < num_devices; ++i) { createDevice(i, subgrid_config, &devices[i]); @@ -259,9 +272,9 @@ acStore(AcMesh* host_mesh) AcResult acIntegrateStep(const int& isubstep, const AcReal& dt) { - const int3 start = (int3){STENCIL_ORDER / 2, STENCIL_ORDER / 2, STENCIL_ORDER / 2}; - const int3 end = (int3){STENCIL_ORDER / 2 + subgrid.n.x, STENCIL_ORDER / 2 + subgrid.n.y, - STENCIL_ORDER / 2 + subgrid.n.z}; + const int3 start = (int3){NGHOST, NGHOST, NGHOST}; + const int3 end = (int3){NGHOST + subgrid.n.x, NGHOST + subgrid.n.y, + NGHOST + subgrid.n.z}; for (int i = 0; i < num_devices; ++i) { rkStep(devices[i], STREAM_PRIMARY, isubstep, start, end, dt); } @@ -294,7 +307,7 @@ acBoundcondStep(void) else { // Local boundary conditions for (int i = 0; i < num_devices; ++i) { - const int3 d0 = (int3){0, 0, STENCIL_ORDER / 2}; // DECOMPOSITION OFFSET HERE + const int3 d0 = (int3){0, 0, NGHOST}; // DECOMPOSITION OFFSET HERE const int3 d1 = (int3){subgrid.m.x, subgrid.m.y, d0.z + subgrid.n.z}; boundcondStep(devices[i], STREAM_PRIMARY, d0, d1); } @@ -393,7 +406,7 @@ acBoundcondStep(void) */ // Exchange halos for (int i = 0; i < num_devices; ++i) { - const int num_vertices = subgrid.m.x * subgrid.m.y * STENCIL_ORDER / 2; + const int num_vertices = subgrid.m.x * subgrid.m.y * NGHOST; // ...|ooooxxx|... -> xxx|ooooooo|... { const int3 src = (int3){0, 0, subgrid.n.z}; @@ -403,8 +416,8 @@ acBoundcondStep(void) } // ...|ooooooo|xxx <- ...|xxxoooo|... { - const int3 src = (int3){0, 0, STENCIL_ORDER / 2}; - const int3 dst = (int3){0, 0, STENCIL_ORDER / 2 + subgrid.n.z}; + const int3 src = (int3){0, 0, NGHOST}; + const int3 dst = (int3){0, 0, NGHOST + subgrid.n.z}; copyMeshDeviceToDevice(devices[(i + 1) % num_devices], STREAM_PRIMARY, src, devices[i], dst, num_vertices); } From daddde15b8ba8cb4b9343bb35a6a8e49dc7006c9 Mon Sep 17 00:00:00 2001 From: Matthias Rheinhardt Date: Wed, 26 Jun 2019 17:06:46 +0300 Subject: [PATCH 06/12] MR: encapsulated user stuff --- include/user.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 include/user.h diff --git a/include/user.h b/include/user.h new file mode 100644 index 0000000..72e2268 --- /dev/null +++ b/include/user.h @@ -0,0 +1,16 @@ +#ifdef PENCIL_ASTAROTH + + #include "../cparam.inc_c.h" + #define NGHOST nghost + #define STENCIL_ORDER (2*nghost) + #include "PC_moduleflags.h" + #define CONFIG_PATH + #define AC_MULTIGPU_ENABLED (false) + #ifdef DOUBLE_PRECISION + #define AC_DOUBLE_PRECISION 1 + #else + #define AC_DOUBLE_PRECISION 0 + #endif + #define USER_PROVIDED +#endif + From 57a39fd8489c315cb58a33cc1ad2726dcea9a631 Mon Sep 17 00:00:00 2001 From: Matthias Rheinhardt Date: Wed, 26 Jun 2019 17:10:51 +0300 Subject: [PATCH 07/12] MR: USER_PROVIDED --- include/astaroth.h | 85 ++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index e6114c7..8666f8f 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -57,13 +57,11 @@ extern "C" { #define MAX_TB_DIM (MAX_THREADS_PER_BLOCK) #define NUM_ITERATIONS (10) #define WARP_SIZE (32) - /* * ============================================================================= * Compile-time constants used during simulation (user definable) * ============================================================================= */ -#define STENCIL_ORDER (6) ///////////// PAD TEST // NOTE: works only with nx is divisible by 32 @@ -74,10 +72,22 @@ extern "C" { // L-prefix inherited from the old Astaroth, no idea what it means // MV: L means a Logical switch variale, something having true of false value. // Note: forcing is disabled currently in the files generated by acc (compiler of our DSL) -#define LFORCING (1) -#define LINDUCTION (1) -#define LENTROPY (1) -#define LTEMPERATURE (0) +// +#include "user.h" + +#ifndef USER_PROVIDED + + #define STENCIL_ORDER (6) + #define NGHOST (STENCIL_ORDER/2) + #define LHYDRO (1) + #define LDENSITY (1) + #define LFORCING (1) + #define LINDUCTION (1) + #define LENTROPY (1) + #define LTEMPERATURE (0) + #define LMAGNETIC LINDUCTION + +#endif #define AC_THERMAL_CONDUCTIVITY (AcReal(0.001)) // TODO: make an actual config parameter @@ -177,15 +187,31 @@ extern "C" { * ============================================================================= */ // clang-format off -#define AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC)\ - FUNC(VTXBUF_LNRHO), \ +#ifdef LHYDRO +#define AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC) \ FUNC(VTXBUF_UUX), \ FUNC(VTXBUF_UUY), \ - FUNC(VTXBUF_UUZ), \ - // FUNC(VTXBUF_DYE), + FUNC(VTXBUF_UUZ), +#else +#define AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC) +#endif -#if LINDUCTION -#define AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC)\ +#ifdef LDENSITY +#define AC_FOR_DENSITY_VTXBUF_HANDLES(FUNC) \ + FUNC(VTXBUF_DENSITY), +#else +#define AC_FOR_DENSITY_VTXBUF_HANDLES(FUNC) +#endif + +#ifdef LENTROPY +#define AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC) \ + FUNC(VTXBUF_ENTROPY), +#else +#define AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC) +#endif + +#ifdef LMAGNETIC +#define AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC) \ FUNC(VTXBUF_AX), \ FUNC(VTXBUF_AY), \ FUNC(VTXBUF_AZ), @@ -193,25 +219,22 @@ extern "C" { #define AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC) #endif -#if LENTROPY -#define AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC)\ - FUNC(VTXBUF_ENTROPY), -#else -#define AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC) +#define AC_FOR_VTXBUF_HANDLES(FUNC) AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC) \ + AC_FOR_DENSITY_VTXBUF_HANDLES(FUNC) \ + AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC) \ + AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC) \ + +//MR: Temperature must not have an additional variable slot, but should sit on the +// same as entropy. +#ifndef USER_PROVIDED + #if LTEMPERATURE + #define AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC)\ + FUNC(VTXBUF_TEMPERATURE), + #else + #define AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC) + #endif #endif -#if LTEMPERATURE -#define AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC)\ - FUNC(VTXBUF_TEMPERATURE), -#else -#define AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC) -#endif - -#define AC_FOR_VTXBUF_HANDLES(FUNC)\ - AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC)\ - AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC)\ - AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC)\ - AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC) // clang-format on /* @@ -267,6 +290,7 @@ typedef enum { RTYPE_MAX, RTYPE_MIN, RTYPE_RMS, RTYPE_RMS_EXP, NUM_REDUCTION_TYP typedef enum { AC_FOR_INT_PARAM_TYPES(AC_GEN_ID), NUM_INT_PARAM_TYPES } AcIntParam; typedef enum { AC_FOR_REAL_PARAM_TYPES(AC_GEN_ID), NUM_REAL_PARAM_TYPES } AcRealParam; +//typedef enum { AC_FOR_VEC_PARAM_TYPES(AC_GEN_ID), NUM_VEC_PARAM_TYPES } AcVecParam; extern const char* intparam_names[]; // Defined in astaroth.cu extern const char* realparam_names[]; // Defined in astaroth.cu @@ -274,6 +298,7 @@ extern const char* realparam_names[]; // Defined in astaroth.cu typedef struct { int int_params[NUM_INT_PARAM_TYPES]; AcReal real_params[NUM_REAL_PARAM_TYPES]; + //AcReal* vec_params[NUM_VEC_PARAM_TYPES]; } AcMeshInfo; /* @@ -327,6 +352,8 @@ initialization of *all memory needed on all GPUs in the node*. In other words, setups everything GPU-side so that calling any other GPU interface function afterwards does not result in illegal memory accesses. */ AcResult acInit(const AcMeshInfo& mesh_info); +AcResult acCheckDeviceAvail(); +AcResult acInitialize(const AcMeshInfo& mesh_info); /** Splits the host_mesh and distributes it among the GPUs in the node */ AcResult acLoad(const AcMesh& host_mesh); From 0bc8b7e827cc3ec8ab00f61738e271a945ab62c0 Mon Sep 17 00:00:00 2001 From: Matthias Rheinhardt Date: Tue, 25 Jun 2019 23:50:57 +0300 Subject: [PATCH 08/12] MR: VTXBUF_DENSITY -> VTXBUF_LNRHO, minor --- include/astaroth.h | 2 +- src/core/astaroth.cu | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index 8666f8f..1220ef0 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -198,7 +198,7 @@ extern "C" { #ifdef LDENSITY #define AC_FOR_DENSITY_VTXBUF_HANDLES(FUNC) \ - FUNC(VTXBUF_DENSITY), + FUNC(VTXBUF_LNRHO), #else #define AC_FOR_DENSITY_VTXBUF_HANDLES(FUNC) #endif diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index fecfdcb..dd6e410 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -75,7 +75,7 @@ printInt3(const int3 vec) AcResult acInit(const AcMeshInfo& config) { - Acresult res=acGetDevice(); + AcResult res=acGetDevice(); res=acInitialize(config); return AC_SUCCESS; } @@ -288,12 +288,12 @@ acIntegrateStepWithOffset(const int& isubstep, const AcReal& dt, const int3& sta /* // A skeleton function for computing integrations with arbitrary subblocks // Uncommenting the following should work with a single GPU. - const int3 start = (int3){STENCIL_ORDER / 2, STENCIL_ORDER / 2, STENCIL_ORDER / 2}; - const int3 end = (int3){STENCIL_ORDER / 2 + subgrid.n.x, STENCIL_ORDER / 2 + subgrid.n.y, - STENCIL_ORDER / 2 + subgrid.n.z}; - rkStep(devices[0], STREAM_PRIMARY, isubstep, start, end, dt); + const int3 start = (int3){NGHOST, NGHOST, NGHOST}; + const int3 end = (int3){NGHOST + subgrid.n.x, NGHOST + subgrid.n.y, + NGHOST + subgrid.n.z}; */ - return AC_FAILURE; + rkStep(devices[0], STREAM_PRIMARY, isubstep, start, end, dt); + return AC_SUCCESS; } AcResult From cda17c9b085b3198b42b9edd6f184ad5d24ec912 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 26 Jun 2019 18:50:15 +0300 Subject: [PATCH 09/12] VERBOSE_PRINTING flag is now globally used in the whole program and should be used to suppress development/debugging-related printing. Also added comments to the new interface function acCheckDeviceAvailability and made it free from side effects. --- include/astaroth.h | 8 ++++++-- src/core/astaroth.cu | 26 ++++++++++++-------------- src/standalone/config_loader.cc | 15 +++++---------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index 1220ef0..483f9ba 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -49,6 +49,7 @@ extern "C" { #define AUTO_OPTIMIZE (0) // DEPRECATED TODO remove #define BOUNDCONDS_OPTIMIZE (0) #define GENERATE_BENCHMARK_DATA (0) +#define VERBOSE_PRINTING (1) // Device info #define REGISTERS_PER_THREAD (255) @@ -347,13 +348,16 @@ typedef struct { * Astaroth interface * ============================================================================= */ + +/** Checks whether there are any CUDA devices available. Returns AC_SUCCESS if there is 1 or more, + AC_FAILURE otherwise. */ +AcResult acCheckDeviceAvailability(void); + /** Starting point of all GPU computation. Handles the allocation and initialization of *all memory needed on all GPUs in the node*. In other words, setups everything GPU-side so that calling any other GPU interface function afterwards does not result in illegal memory accesses. */ AcResult acInit(const AcMeshInfo& mesh_info); -AcResult acCheckDeviceAvail(); -AcResult acInitialize(const AcMeshInfo& mesh_info); /** Splits the host_mesh and distributes it among the GPUs in the node */ AcResult acLoad(const AcMesh& host_mesh); diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index dd6e410..74dd55a 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -73,18 +73,21 @@ printInt3(const int3 vec) } AcResult -acInit(const AcMeshInfo& config) +acCheckDeviceAvailability(void) { - AcResult res=acGetDevice(); - res=acInitialize(config); - return AC_SUCCESS; + int device_count; // Separate from num_devices to avoid side effects + ERRCHK_CUDA_ALWAYS(cudaGetDeviceCount(&device_count)); + if (device_count > 0) + return AC_SUCCESS; + else + return AC_FAILURE; } AcResult -acCheckDeviceAvail() +acInit(const AcMeshInfo& config) { - // Check devices - cudaGetDeviceCount(&num_devices); + // Get num_devices + ERRCHK_CUDA_ALWAYS(cudaGetDeviceCount(&num_devices)); if (num_devices < 1) { ERROR("No CUDA devices found!"); return AC_FAILURE; @@ -97,11 +100,6 @@ acCheckDeviceAvail() WARNING("MULTIGPU_ENABLED was false. Using only one device"); num_devices = 1; // Use only one device if multi-GPU is not enabled } - return AC_SUCCESS; -} -AcResult -acInitialize(const AcMeshInfo& config) -{ // Check that num_devices is divisible with AC_nz. This makes decomposing the // problem domain to multiple GPUs much easier since we do not have to worry // about remainders @@ -121,14 +119,14 @@ acInitialize(const AcMeshInfo& config) ERRCHK_ALWAYS(subgrid.n.x >= STENCIL_ORDER); ERRCHK_ALWAYS(subgrid.n.y >= STENCIL_ORDER); ERRCHK_ALWAYS(subgrid.n.z >= STENCIL_ORDER); -#ifndef PENCIL_ASTAROTH + // clang-format off printf("Grid m "); printInt3(grid.m); printf("\n"); printf("Grid n "); printInt3(grid.n); printf("\n"); printf("Subrid m "); printInt3(subgrid.m); printf("\n"); printf("Subrid n "); printInt3(subgrid.n); printf("\n"); // clang-format on -#endif + // Initialize the devices for (int i = 0; i < num_devices; ++i) { createDevice(i, subgrid_config, &devices[i]); diff --git a/src/standalone/config_loader.cc b/src/standalone/config_loader.cc index a3a9abe..36e33e3 100644 --- a/src/standalone/config_loader.cc +++ b/src/standalone/config_loader.cc @@ -152,16 +152,11 @@ update_config(AcMeshInfo* config) config->real_params[AC_G_CONST]; config->real_params[AC_sq2GM_star] = AcReal(sqrt(AcReal(2) * config->real_params[AC_GM_star])); - const bool print_config = true; -#ifdef VERBOSE_PRINT - if (print_config) { - printf("###############################################################" - "\n"); - printf("Config dimensions recalculated:\n"); - print(*config); - printf("###############################################################" - "\n"); - } +#if VERBOSE_PRINTING + printf("###############################################################\n"); + printf("Config dimensions recalculated:\n"); + print(*config); + printf("###############################################################\n"); #endif } From 65c8a39cb9156ad938b2fa0e14bdbcbbde3bfd15 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 26 Jun 2019 18:56:40 +0300 Subject: [PATCH 10/12] Removed old comments and renamed USER_PROVIDED to USER_PROVIDED_DEFINES to be more explicit --- include/astaroth.h | 17 +++-------------- include/user.h | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index 483f9ba..42197bc 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -63,21 +63,11 @@ extern "C" { * Compile-time constants used during simulation (user definable) * ============================================================================= */ - -///////////// PAD TEST -// NOTE: works only with nx is divisible by 32 -//#define PAD_LEAD (32 - STENCIL_ORDER/2) -//#define PAD_SIZE (32 - STENCIL_ORDER) -///////////// PAD TEST - -// L-prefix inherited from the old Astaroth, no idea what it means -// MV: L means a Logical switch variale, something having true of false value. -// Note: forcing is disabled currently in the files generated by acc (compiler of our DSL) -// +// USER_PROVIDED_DEFINES must be defined in user.h if the user wants to override the following +// logical switches #include "user.h" -#ifndef USER_PROVIDED - +#ifndef USER_PROVIDED_DEFINES #define STENCIL_ORDER (6) #define NGHOST (STENCIL_ORDER/2) #define LHYDRO (1) @@ -87,7 +77,6 @@ extern "C" { #define LENTROPY (1) #define LTEMPERATURE (0) #define LMAGNETIC LINDUCTION - #endif #define AC_THERMAL_CONDUCTIVITY (AcReal(0.001)) // TODO: make an actual config parameter diff --git a/include/user.h b/include/user.h index 72e2268..c2075b4 100644 --- a/include/user.h +++ b/include/user.h @@ -11,6 +11,6 @@ #else #define AC_DOUBLE_PRECISION 0 #endif - #define USER_PROVIDED + #define USER_PROVIDED_DEFINES #endif From ee075e6741e39131ad88799500be1793b8d6f039 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 26 Jun 2019 19:42:49 +0300 Subject: [PATCH 11/12] Set the default number of devices to 0 (this is updated at acInit() --- src/core/astaroth.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index 74dd55a..cd6865b 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -36,7 +36,7 @@ const char* realparam_names[] = {AC_FOR_REAL_PARAM_TYPES(AC_GEN_STR)}; const char* vtxbuf_names[] = {AC_FOR_VTXBUF_HANDLES(AC_GEN_STR)}; static const int MAX_NUM_DEVICES = 32; -static int num_devices = 1; +static int num_devices = 0; static Device devices[MAX_NUM_DEVICES] = {}; static Grid From 401172bb74c9645d65f31adcd0c29d2b933bbb19 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 26 Jun 2019 19:43:37 +0300 Subject: [PATCH 12/12] Formatting --- src/core/astaroth.cu | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index cd6865b..635bd58 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -39,17 +39,6 @@ static const int MAX_NUM_DEVICES = 32; static int num_devices = 0; static Device devices[MAX_NUM_DEVICES] = {}; -static Grid -createGrid(const AcMeshInfo& config) -{ - Grid grid; - - grid.m = (int3){config.int_params[AC_mx], config.int_params[AC_my], config.int_params[AC_mz]}; - grid.n = (int3){config.int_params[AC_nx], config.int_params[AC_ny], config.int_params[AC_nz]}; - - return grid; -} - static Grid grid; // A grid consists of num_devices subgrids static Grid subgrid; @@ -72,6 +61,17 @@ printInt3(const int3 vec) printf("(%d, %d, %d)", vec.x, vec.y, vec.z); } +static Grid +createGrid(const AcMeshInfo& config) +{ + Grid grid; + + grid.m = (int3){config.int_params[AC_mx], config.int_params[AC_my], config.int_params[AC_mz]}; + grid.n = (int3){config.int_params[AC_nx], config.int_params[AC_ny], config.int_params[AC_nz]}; + + return grid; +} + AcResult acCheckDeviceAvailability(void) {