diff --git a/include/astaroth.h b/include/astaroth.h index 43438f7..b071c81 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -66,8 +66,8 @@ AcResult acStore(AcMesh* host_mesh); * substep and the user is responsible for calling acBoundcondStep before reading the data. */ AcResult acIntegrate(const AcReal dt); -/** Applies periodic boundary conditions for the Mesh distributed among the devices visible to the - * caller*/ +/** Applies periodic boundary conditions for the Mesh distributed among the devices visible to + * the caller*/ AcResult acBoundcondStep(void); /** Does a scalar reduction with the data stored in some vertex buffer */ @@ -81,6 +81,13 @@ AcReal acReduceVec(const ReductionType rtype, const VertexBufferHandle a, */ AcResult acStoreWithOffset(const int3 dst, const size_t num_vertices, AcMesh* host_mesh); +/** Will potentially be deprecated in later versions. Added only to fix backwards compatibility with + * PC for now.*/ +AcResult acIntegrateStep(const int isubstep, const AcReal& dt); +AcResult acIntegrateStepWithOffset(const int isubstep, const AcReal dt, const int3 start, + const int3 end); +AcResult acSynchronize(void); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index 7393fea..1bd0c42 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -19,6 +19,8 @@ // #include "astaroth_defines.h" #include "astaroth.h" +#include "math_utils.h" // int3 + int3 + #define AC_GEN_STR(X) #X const char* intparam_names[] = {AC_FOR_BUILTIN_INT_PARAM_TYPES(AC_GEN_STR) // AC_FOR_USER_INT_PARAM_TYPES(AC_GEN_STR)}; @@ -33,10 +35,13 @@ const char* vtxbuf_names[] = {AC_FOR_VTXBUF_HANDLES(AC_GEN_STR)}; static const int num_nodes = 1; static Node nodes[num_nodes]; +static int3 grid_n; AcResult acInit(const AcMeshInfo mesh_info) { + grid_n = (int3){mesh_info.int_params[AC_nx], mesh_info.int_params[AC_ny], + mesh_info.int_params[AC_nz]}; return acNodeCreate(0, mesh_info, &nodes[0]); } @@ -46,6 +51,12 @@ acQuit(void) return acNodeDestroy(nodes[0]); } +AcResult +acSynchronize(void) +{ + return acNodeSynchronizeStream(nodes[0], STREAM_ALL); +} + AcResult acSynchronizeStream(const Stream stream) { @@ -80,6 +91,20 @@ acIntegrate(const AcReal dt) return acNodeIntegrate(nodes[0], dt); } +AcResult +acIntegrateStep(const int& isubstep, const AcReal dt) +{ + const int3 start = (int3){NGHOST, NGHOST, NGHOST}; + const int3 end = start + grid_n; + return acNodeIntegrateSubstep(nodes[0], STREAM_DEFAULT, isubstep, start, end, dt); +} + +AcResult +acIntegrateStepWithOffset(const int isubstep, const AcReal dt, const int3 start, const int3 end) +{ + return acNodeIntegrateSubstep(nodes[0], STREAM_DEFAULT, isubstep, start, end, dt); +} + AcResult acBoundcondStep(void) {