From d4d2680f4058566e8235795262944530f612108b Mon Sep 17 00:00:00 2001 From: jpekkila Date: Wed, 3 Jul 2019 16:19:25 +0300 Subject: [PATCH] Added a new generic function to the interface (astaroth.h) for loading arbitrary device constants. Also (unintended) autoformatting. --- include/astaroth.h | 10 +++++++--- src/core/astaroth.cu | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index 504f768..5d0e404 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -409,11 +409,15 @@ AcResult acQuit(void); unless otherwise stated. */ AcResult acSynchronize(void); +/** */ +AcResult acloadDeviceConstant(const AcRealParam param, const AcReal value); + /** Tool for loading forcing vector information into the device memory */ -AcResult acForcingVec(const AcReal forcing_magnitude, const AcReal3 k_force, const AcReal3 ff_hel_re, - const AcReal3 ff_hel_im, const AcReal forcing_phase, const AcReal kaver); - +AcResult acForcingVec(const AcReal forcing_magnitude, const AcReal3 k_force, + const AcReal3 ff_hel_re, const AcReal3 ff_hel_im, const AcReal forcing_phase, + const AcReal kaver); + /* End extern "C" */ #ifdef __cplusplus } diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index a0cf7ae..a912e90 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -506,15 +506,24 @@ acSynchronize(void) return AC_SUCCESS; } -//Tool for loading forcing vector information into the device memory AcResult -acForcingVec(const AcReal forcing_magnitude, const AcReal3 k_force, const AcReal3 ff_hel_re, +acloadDeviceConstant(const AcRealParam param, const AcReal value) +{ + for (int i = 0; i < num_devices; ++i) { + loadDeviceConstant(devices[i], param, value); + } + return AC_SUCCESS; +} + +// Tool for loading forcing vector information into the device memory +AcResult +acForcingVec(const AcReal forcing_magnitude, const AcReal3 k_force, const AcReal3 ff_hel_re, const AcReal3 ff_hel_im, const AcReal forcing_phase, const AcReal kaver) { for (int i = 0; i < num_devices; ++i) { loadDeviceConstant(devices[i], AC_forcing_magnitude, forcing_magnitude); - loadDeviceConstant(devices[i], AC_forcing_phase, forcing_phase ); + loadDeviceConstant(devices[i], AC_forcing_phase, forcing_phase); loadDeviceConstant(devices[i], AC_k_forcex, k_force.x); loadDeviceConstant(devices[i], AC_k_forcey, k_force.y); @@ -529,10 +538,7 @@ acForcingVec(const AcReal forcing_magnitude, const AcReal3 k_force, const AcReal loadDeviceConstant(devices[i], AC_ff_hel_imz, ff_hel_im.z); loadDeviceConstant(devices[i], AC_kaver, kaver); - } - + return AC_SUCCESS; } - -