Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
rearranged some of the openmp loops to extract more performance
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 1, 2021
1 parent fb6aeaa commit 2006e7e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/encounter/encounter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, nplm, x, v, renc, dt, lv
end do

! Sweep the intervals for each of the massive bodies along one dimension
!$omp parallel do simd default(firstprivate) schedule(static)&
!$omp parallel do default(private) schedule(static)&
!$omp shared(aabb, lenc, ind_arr)
do i = 1, npl
ibox = aabb(1)%ibeg(i)
Expand All @@ -204,7 +204,7 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, nplm, x, v, renc, dt, lv
lenc(i)%index2(:) = pack(ind_arr(:), lencounteri(:))
end if
end do
!$omp end parallel do simd
!$omp end parallel do

associate(nenc_arr => lenc(:)%nenc)
nenc = sum(nenc_arr(1:npl))
Expand All @@ -227,10 +227,11 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, nplm, x, v, renc, dt, lv
end do
! Now that we have identified potential pairs, use the narrow-phase process to get the final values
lenc_final(:) = .true.


!$omp parallel do simd default(firstprivate) schedule(static)&
!$omp shared(index1, index2, renc, lenc_final, lvdotr_final) &
!$omp lastprivate(xr, yr, zr, vxr, vyr, vzr, renc12)
!$omp parallel do default(private) schedule(static)&
!$omp shared(lenc_final, lvdotr_final) &
!$omp firstprivate(nenc, nplm, dt, index1, index2, renc, x, v)
do k = 1, nenc
i = index1(k)
j = index2(k)
Expand All @@ -247,7 +248,7 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, nplm, x, v, renc, dt, lv
call encounter_check_one(xr, yr, zr, vxr, vyr, vzr, renc12, dt, lenc_final(k), lvdotr_final(k))
end if
end do
!$omp end parallel do simd
!$omp end parallel do

nenc = count(lenc_final(:)) ! Count the true number of encounters
allocate(tmp(nenc))
Expand Down

0 comments on commit 2006e7e

Please sign in to comment.