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

Commit

Permalink
Rearranged subroutines for better parallel/simd performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 6, 2021
1 parent 06af75d commit 4219f95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 2 additions & 3 deletions Makefile.Defines
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ GMEM = -fsanitize-address-use-after-scope -fstack-check -fsanitize=bounds-stri
GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries
GPRODUCTION = -O2 -ffree-line-length-none $(GPAR)


#FFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
#FFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
#FFASTFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
FFSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) $(OPTREPORT) #$(ADVIXE_FLAGS)
FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) $(OPTREPORT) #$(ADVIXE_FLAGS)
FFLAGS = $(IPRODUCTION) -fp-model=fast $(OPTREPORT) #$(ADVIXE_FLAGS)
FORTRAN = ifort
AR = xiar
Expand Down
24 changes: 14 additions & 10 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ subroutine encounter_check_all_triangular_plpl(npl, x, v, renc, dt, lvdotr, inde
type(encounter_list), dimension(npl) :: lenc

call util_index_array(ind_arr, npl)

!$omp parallel do default(private) schedule(static)&
!$omp shared(x, v, renc, lenc, ind_arr) &
!$omp firstprivate(npl, dt)
Expand Down Expand Up @@ -800,21 +800,25 @@ module pure subroutine encounter_check_one(xr, yr, zr, vxr, vyr, vzr, renc, dt,

if (r2 > r2crit) then
vdotr = vxr * xr + vyr * yr + vzr * zr
v2 = vxr**2 + vyr**2 + vzr**2
tmin = -vdotr / v2

if (tmin < dt) then
r2min = r2 - vdotr**2 / v2
if (vdotr > 0.0_DP) then
r2min = r2
else
r2min = r2 + 2 * vdotr * dt + v2 * dt**2
v2 = vxr**2 + vyr**2 + vzr**2
tmin = -vdotr / v2

if (tmin < dt) then
r2min = r2 - vdotr**2 / v2
else
r2min = r2 + 2 * vdotr * dt + v2 * dt**2
end if
end if
else
vdotr = 0.0_DP
vdotr = -1.0_DP
r2min = r2
end if

lencounter = (r2min <= r2crit)
lvdotr = (vdotr < 0.0_DP)
lencounter = lvdotr .and. (r2min <= r2crit)

return
end subroutine encounter_check_one
Expand Down Expand Up @@ -904,8 +908,8 @@ module subroutine encounter_check_sweep_aabb_double_list(self, n1, n2, nenc, ind
!Internals
integer(I4B) :: i, k, ntot
type(encounter_list), dimension(n1+n2) :: lenc !! Array of encounter lists (one encounter list per body)
type(walltimer) :: timer
integer(I4B), dimension(:), allocatable, save :: ind_arr
type(walltimer) :: timer

ntot = n1 + n2
call util_index_array(ind_arr, ntot)
Expand Down
2 changes: 1 addition & 1 deletion src/kick/kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module subroutine kick_getacch_int_all_triangular_pl(npl, nplm, x, Gmass, radius
end do
end do
!$omp end parallel do

do concurrent(i = 1:npl)
acc(:,i) = acc(:,i) + ahi(:,i) + ahj(:,i)
end do
Expand Down

0 comments on commit 4219f95

Please sign in to comment.