Skip to content

Commit c8379a0

Browse files
author
Daniel Vickers
committed
Lookup table for improved perofrmance
1 parent f6155f3 commit c8379a0

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/simulation/m_ibm.fpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ module m_ibm
2525

2626
private :: s_compute_image_points, s_compute_interpolation_coeffs, s_interpolate_image_point, s_find_ghost_points, &
2727
& s_find_num_ghost_points
28-
; public :: s_initialize_ibm_module, s_ibm_setup, s_ibm_correct_state, s_finalize_ibm_module
28+
; public :: ib_gbl_idx_lookup, s_initialize_ibm_module, s_ibm_setup, s_ibm_correct_state, s_finalize_ibm_module
2929

3030
type(integer_field), public :: ib_markers
3131
$:GPU_DECLARE(create='[ib_markers]')
3232

3333
type(ghost_point), dimension(:), allocatable :: ghost_points
3434
$:GPU_DECLARE(create='[ghost_points]')
3535

36+
integer, dimension(:), allocatable :: ib_gbl_idx_lookup
37+
$:GPU_DECLARE(create='[ib_gbl_idx_lookup]')
38+
3639
integer :: num_gps !< Number of ghost points
3740
#if defined(MFC_OpenACC)
3841
$:GPU_DECLARE(create='[gp_layers, num_gps]')
@@ -84,6 +87,9 @@ contains
8487
if (p /= 0) then
8588
$:GPU_UPDATE(device='[z_cc, dz, z_domain, ib_bc_z%beg]')
8689
end if
90+
ib_gbl_idx_lookup = -1
91+
$:GPU_UPDATE(device='[ib_gbl_idx_lookup]')
92+
call s_update_ib_lookup()
8793

8894
! recompute the new ib_patch locations and broadcast them.
8995
ib_markers%sf = 0._wp
@@ -118,8 +124,6 @@ contains
118124

119125
call nvtxEndRange
120126

121-
! print *, proc_rank, num_local_ibs, num_ibs, num_gbl_ibs
122-
123127
end subroutine s_ibm_setup
124128

125129
!> Update the conservative variables at the ghost points
@@ -248,8 +252,6 @@ contains
248252
q_prim_vf(eqn_idx%E)%sf(j, k, l) = q_prim_vf(eqn_idx%E)%sf(j, k, &
249253
& l) + pres_IP/(1._wp - 2._wp*abs(gp%levelset*alpha_rho_IP(q)/pres_IP) &
250254
& *dot_product(patch_ib(patch_id) %force/patch_ib(patch_id)%mass, gp%levelset_norm))
251-
! q_prim_vf(eqn_idx%E)%sf(j, k, l) = q_prim_vf(eqn_idx%E)%sf(j, k, & & l) + pres_IP/(1._wp -
252-
! 2._wp*abs(gp%levelset*alpha_rho_IP(q)/pres_IP)) ! TODO :: REMOVE ME
253255
end do
254256
end if
255257

@@ -1052,6 +1054,7 @@ contains
10521054
impure subroutine s_finalize_ibm_module()
10531055

10541056
@:DEALLOCATE(ib_markers%sf)
1057+
@:DEALLOCATE(ib_gbl_idx_lookup)
10551058
if (allocated(airfoil_grid_u)) then
10561059
@:DEALLOCATE(airfoil_grid_u)
10571060
@:DEALLOCATE(airfoil_grid_l)
@@ -1282,6 +1285,7 @@ contains
12821285
end do
12831286
call MPI_SENDRECV(send_buf, pack_pos, MPI_PACKED, send_neighbor, tag, recv_buf, buf_size, MPI_PACKED, &
12841287
& recv_neighbor, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr)
1288+
12851289
if (recv_neighbor /= MPI_PROC_NULL) then
12861290
unpack_pos = 0
12871291
call MPI_UNPACK(recv_buf, buf_size, unpack_pos, recv_count, 1, MPI_INTEGER, MPI_COMM_WORLD, ierr)
@@ -1479,6 +1483,7 @@ contains
14791483
end do
14801484

14811485
deallocate (send_buf, recv_bufs)
1486+
call s_update_ib_lookup()
14821487
end if
14831488
#endif
14841489

@@ -1492,15 +1497,21 @@ contains
14921497
integer, intent(out) :: neighborhood_idx
14931498
integer :: i
14941499

1495-
neighborhood_idx = -1
1500+
neighborhood_idx = ib_gbl_idx_lookup(gbl_idx)
1501+
1502+
end subroutine s_get_neighborhood_idx
1503+
1504+
subroutine s_update_ib_lookup()
1505+
1506+
integer :: i
14961507

1508+
$:GPU_PARALLEL_LOOP(private='[i]')
14971509
do i = 1, num_ibs
1498-
if (patch_ib(i)%gbl_patch_id == gbl_idx) then
1499-
neighborhood_idx = i
1500-
exit
1501-
end if
1510+
ib_gbl_idx_lookup(patch_ib(i)%gbl_patch_id) = i
15021511
end do
1512+
$:END_GPU_PARALLEL_LOOP()
1513+
$:GPU_UPDATE(host='[ib_gbl_idx_lookup]')
15031514

1504-
end subroutine s_get_neighborhood_idx
1515+
end subroutine s_update_ib_lookup
15051516

15061517
end module m_ibm

src/simulation/m_start_up.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,8 @@ contains
12681268
patch_ib(:) = patch_ib_gbl(1:num_aware_ibs)
12691269
#endif
12701270

1271+
@:ALLOCATE(ib_gbl_idx_lookup(1:num_gbl_ibs))
1272+
12711273
end subroutine s_reduce_ib_patch_array
12721274

12731275
!> Build ib_neighbor_ranks(-1:1,-1:1,-1:1): MPI ranks of all neighbor domains. Uses two rounds of MPI_SENDRECV cascades - face

0 commit comments

Comments
 (0)