Added more control for synchronizing streams and halos among the GPUs

This commit is contained in:
jpekkila
2019-07-05 15:17:20 +03:00
parent 332f1a4f40
commit 224b91b83a

View File

@@ -260,8 +260,8 @@ acSwapBuffers(void)
return AC_SUCCESS; return AC_SUCCESS;
} }
AcResult static AcResult
acExchangeHalos(void) acSynchronizeHalos(void)
{ {
// Exchanges the halos of subgrids // Exchanges the halos of subgrids
// After this step, the data within the main grid ranging from // After this step, the data within the main grid ranging from
@@ -290,6 +290,26 @@ acExchangeHalos(void)
return AC_SUCCESS; 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 AcResult
acBoundcondStep(void) acBoundcondStep(void)
{ {
@@ -397,10 +417,7 @@ acBoundcondStep(void)
periodic_boundconds(0, tpb, start, end, d_buffer.in[i]); periodic_boundconds(0, tpb, start, end, d_buffer.in[i]);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*/ */
// Exchange halos // With periodic boundary conditions we exchange the front and back plates of the
acExchangeHalos();
// With periodic boundary conditions we also exchange the front and back plates of the
// grid. The exchange is done between the first and last device (0 and num_devices - 1). // 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; const int num_vertices = subgrid.m.x * subgrid.m.y * NGHOST;
// ...|ooooxxx|... -> xxx|ooooooo|... // ...|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); 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 AcResult
acLoadDeviceConstant(const AcRealParam param, const AcReal value) acLoadDeviceConstant(const AcRealParam param, const AcReal value)
{ {