From 8b3a8fd9841a1e3ab48e95f443c90641b832f057 Mon Sep 17 00:00:00 2001 From: William F Godoy Date: Mon, 23 Oct 2023 22:56:03 -0400 Subject: [PATCH] Fix memory bugs in offload Add is_device_pointer in omp target clauses --- src/Particle/RealSpacePositionsTOMPTarget.h | 1 + src/Particle/SoaDistanceTableAATOMPTarget.h | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Particle/RealSpacePositionsTOMPTarget.h b/src/Particle/RealSpacePositionsTOMPTarget.h index 57a81f6c85..9e2b2965d7 100644 --- a/src/Particle/RealSpacePositionsTOMPTarget.h +++ b/src/Particle/RealSpacePositionsTOMPTarget.h @@ -121,6 +121,7 @@ class RealSpacePositionsTOMPTarget : public DynamicCoordinatesT auto* mw_pos_ptr = mw_new_pos.data(); PRAGMA_OFFLOAD("omp target update to(\ + is_device_ptr(mw_pos_ptr, mw_rosa_ptr) \ mw_pos_ptr[DIM * mw_new_pos.capacity()])") coords_leader.is_nw_new_pos_prepared = true; diff --git a/src/Particle/SoaDistanceTableAATOMPTarget.h b/src/Particle/SoaDistanceTableAATOMPTarget.h index 4d89033ed2..85afcfa5c7 100644 --- a/src/Particle/SoaDistanceTableAATOMPTarget.h +++ b/src/Particle/SoaDistanceTableAATOMPTarget.h @@ -413,9 +413,10 @@ struct SoaDistanceTableAATOMPTarget : const auto num_sources_local = this->num_targets_; const auto num_padded = num_targets_padded_; - auto* rsoa_dev_list_ptr = + const auto* rsoa_dev_list_ptr = coordinates_leader.getMultiWalkerRSoADevicePtrs().data(); auto* r_dr_ptr = mw_new_old_dist_displ.data(); + const auto* new_pos_ptr = coordinates_leader.getFusedNewPosBuffer().data(); const size_t new_pos_stride = coordinates_leader.getFusedNewPosBuffer().capacity(); @@ -423,11 +424,11 @@ struct SoaDistanceTableAATOMPTarget : ScopedTimer offload(offload_timer_); PRAGMA_OFFLOAD("omp target teams distribute collapse(2) \ num_teams(nw * num_teams) nowait \ + is_device_ptr(new_pos_ptr,rsoa_dev_list_ptr) \ depend(out: r_dr_ptr[:mw_new_old_dist_displ.size()])") for (int iw = 0; iw < nw; ++iw) for (int team_id = 0; team_id < num_teams; team_id++) { - auto* source_pos_ptr = rsoa_dev_list_ptr[iw]; - auto* new_pos_ptr = coordinates_leader.getFusedNewPosBuffer().data(); + const auto* source_pos_ptr = rsoa_dev_list_ptr[iw]; const size_t first = ChunkSizePerTeam * team_id; const size_t last = omptarget::min( first + ChunkSizePerTeam, num_sources_local);