diff --git a/src/core/astaroth.cu b/src/core/astaroth.cu index ff655c0..a141295 100644 --- a/src/core/astaroth.cu +++ b/src/core/astaroth.cu @@ -260,8 +260,8 @@ acSwapBuffers(void) return AC_SUCCESS; } -AcResult -acExchangeHalos(void) +static AcResult +acSynchronizeHalos(void) { // Exchanges the halos of subgrids // After this step, the data within the main grid ranging from @@ -290,6 +290,26 @@ acExchangeHalos(void) return AC_SUCCESS; } +static AcResult +acSynchronizeStream(const StreamType stream) +{ + for (int i = 0; i < num_devices; ++i) { + synchronize(devices[i], stream); + } + + return AC_SUCCESS; +} + +AcResult +acSynchronize(void) +{ + acSynchronizeStream(STREAM_ALL); + acSynchronizeHalos(); + acSynchronizeStream(STREAM_ALL); + + return AC_SUCCESS; +} + AcResult acBoundcondStep(void) { @@ -397,10 +417,7 @@ acBoundcondStep(void) periodic_boundconds(0, tpb, start, end, d_buffer.in[i]); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ - // Exchange halos - acExchangeHalos(); - - // With periodic boundary conditions we also exchange the front and back plates of the + // With periodic boundary conditions we exchange the front and back plates of the // grid. The exchange is done between the first and last device (0 and num_devices - 1). const int num_vertices = subgrid.m.x * subgrid.m.y * NGHOST; // ...|ooooxxx|... -> xxx|ooooooo|... @@ -514,16 +531,6 @@ acReduceVec(const ReductionType& rtype, const VertexBufferHandle& a, const Verte return simple_final_reduce_scal(rtype, results, num_devices); } -AcResult -acSynchronize(void) -{ - for (int i = 0; i < num_devices; ++i) { - synchronize(devices[i], STREAM_ALL); - } - - return AC_SUCCESS; -} - AcResult acLoadDeviceConstant(const AcRealParam param, const AcReal value) {