From 0884c4bf38b2e5f21ba5d2bb1ea53657b9ade4b4 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Thu, 4 Jul 2019 15:28:18 +0300 Subject: [PATCH] Moved the definition of acForcingVec to host_forcing.cc since it depends on user parameters that may not be defined in all projects --- include/astaroth.h | 8 +------ src/core/astaroth.cu | 32 ---------------------------- src/standalone/model/host_forcing.cc | 29 +++++++++++++++++++++++++ src/standalone/model/host_forcing.h | 8 ++++++- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index 62fe967..01d7558 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -272,15 +272,9 @@ AcResult acQuit(void); unless otherwise stated. */ AcResult acSynchronize(void); -/** */ +/** Loads a parameter to the constant memory of all devices */ 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); - /* End extern "C" */ #ifdef __cplusplus } diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index d9e0b1a..43e4403 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -515,35 +515,3 @@ acLoadDeviceConstant(const AcRealParam param, const AcReal value) } return AC_SUCCESS; } - -// Tool for loading forcing vector information into the device memory -// %JP: Added a generic function for loading device constants (acLoadDeviceConstant). -// This acForcingVec should go outside the core library since it references user-defined -// parameters such as AC_forcing_magnitude which may not be defined in all projects. -// host_forcing.cc is probably a good place for this. -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_k_forcex, k_force.x); - loadDeviceConstant(devices[i], AC_k_forcey, k_force.y); - loadDeviceConstant(devices[i], AC_k_forcez, k_force.z); - - loadDeviceConstant(devices[i], AC_ff_hel_rex, ff_hel_re.x); - loadDeviceConstant(devices[i], AC_ff_hel_rey, ff_hel_re.y); - loadDeviceConstant(devices[i], AC_ff_hel_rez, ff_hel_re.z); - - loadDeviceConstant(devices[i], AC_ff_hel_imx, ff_hel_im.x); - loadDeviceConstant(devices[i], AC_ff_hel_imy, ff_hel_im.y); - loadDeviceConstant(devices[i], AC_ff_hel_imz, ff_hel_im.z); - - loadDeviceConstant(devices[i], AC_kaver, kaver); - } - - return AC_SUCCESS; -} diff --git a/src/standalone/model/host_forcing.cc b/src/standalone/model/host_forcing.cc index 4ce7892..05a0ec5 100644 --- a/src/standalone/model/host_forcing.cc +++ b/src/standalone/model/host_forcing.cc @@ -175,3 +175,32 @@ helical_forcing_special_vector(AcReal3* ff_hel_re, AcReal3* ff_hel_im, const AcR *ff_hel_im = (AcReal3){relhel * k_cross_k_cross_e.x / denominator, relhel * k_cross_k_cross_e.y, relhel * k_cross_k_cross_e.z}; } + +// Tool for loading forcing vector information into the device memory +// %JP: Added a generic function for loading device constants (acLoadDeviceConstant). +// This acForcingVec should go outside the core library since it references user-defined +// parameters such as AC_forcing_magnitude which may not be defined in all projects. +// host_forcing.cc is probably a good place for this. +// %JP update: moved this here out of astaroth.cu. Should be renamed such that it cannot be +// confused with actual interface functions. +void +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) +{ + acLoadDeviceConstant(AC_forcing_magnitude, forcing_magnitude); + acLoadDeviceConstant(AC_forcing_phase, forcing_phase); + + acLoadDeviceConstant(AC_k_forcex, k_force.x); + acLoadDeviceConstant(AC_k_forcey, k_force.y); + acLoadDeviceConstant(AC_k_forcez, k_force.z); + + acLoadDeviceConstant(AC_ff_hel_rex, ff_hel_re.x); + acLoadDeviceConstant(AC_ff_hel_rey, ff_hel_re.y); + acLoadDeviceConstant(AC_ff_hel_rez, ff_hel_re.z); + + acLoadDeviceConstant(AC_ff_hel_imx, ff_hel_im.x); + acLoadDeviceConstant(AC_ff_hel_imy, ff_hel_im.y); + acLoadDeviceConstant(AC_ff_hel_imz, ff_hel_im.z); + + acLoadDeviceConstant(AC_kaver, kaver); +} diff --git a/src/standalone/model/host_forcing.h b/src/standalone/model/host_forcing.h index 569485e..602cbd7 100644 --- a/src/standalone/model/host_forcing.h +++ b/src/standalone/model/host_forcing.h @@ -42,4 +42,10 @@ AcReal3 helical_forcing_k_generator(const AcReal kmax, const AcReal kmin); void helical_forcing_e_generator(AcReal3* e_force, const AcReal3 k_force); -void helical_forcing_special_vector(AcReal3* ff_hel_re, AcReal3* ff_hel_im, const AcReal3 k_force, const AcReal3 e_force, const AcReal relhel); +void helical_forcing_special_vector(AcReal3* ff_hel_re, AcReal3* ff_hel_im, const AcReal3 k_force, + const AcReal3 e_force, const AcReal relhel); + +/** Tool for loading forcing vector information into the device memory + */ +void 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);