Skip to content

Commit

Permalink
Fix memory bugs in offload
Browse files Browse the repository at this point in the history
Add is_device_pointer in omp target clauses
  • Loading branch information
williamfgc committed Oct 24, 2023
1 parent a724445 commit 8b3a8fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Particle/RealSpacePositionsTOMPTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class RealSpacePositionsTOMPTarget : public DynamicCoordinatesT<T>

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;
Expand Down
7 changes: 4 additions & 3 deletions src/Particle/SoaDistanceTableAATOMPTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,21 +413,22 @@ 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();

{
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);
Expand Down

0 comments on commit 8b3a8fd

Please sign in to comment.