Skip to content

Commit f729d69

Browse files
Initial pass through of removing copies
1 parent b53fbe8 commit f729d69

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/simulation/m_data_output.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ contains
889889

890890
integer, intent(in) :: time_step
891891

892+
$:GPU_UPDATE(host='[patch_ib(1:num_ibs)]')
893+
892894
if (parallel_io) then
893895
call s_write_parallel_ib_data(time_step)
894896
else

src/simulation/m_ib_patches.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,8 @@ contains
895895
!> Compute a rotation matrix for converting to the rotating frame of the boundary
896896
subroutine s_update_ib_rotation_matrix(patch_id)
897897
898+
$:GPU_ROUTINE(parallelism='[seq]')
899+
898900
integer, intent(in) :: patch_id
899901
real(wp), dimension(3, 3, 3) :: rotation
900902
real(wp) :: angle

src/simulation/m_ibm.fpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,17 @@ contains
7676

7777
call nvtxStartRange("SETUP-IBM-MODULE")
7878

79+
$:GPU_UPDATE(device='[patch_ib(1:num_ibs)]')
80+
7981
! do all set up for moving immersed boundaries
82+
$:GPU_PARALLEL_LOOP(private='[i]')
8083
do i = 1, num_ibs
8184
if (patch_ib(i)%moving_ibm /= 0) then
8285
call s_compute_moment_of_inertia(i, patch_ib(i)%angular_vel)
8386
end if
8487
call s_update_ib_rotation_matrix(i)
8588
end do
86-
$:GPU_UPDATE(device='[patch_ib(1:num_ibs)]')
89+
$:END_GPU_PARALLEL_LOOP()
8790

8891
! allocate some arrays for MPI communication, if required by this simulation
8992
#ifdef MFC_MPI
@@ -868,13 +871,13 @@ contains
868871
$:END_GPU_PARALLEL_LOOP()
869872

870873
! recalulcate the rotation matrix based upon the new angles
874+
$:GPU_PARALLEL_LOOP(private='[i]')
871875
do i = 1, num_ibs
872876
if (patch_ib(i)%moving_ibm /= 0) then
873877
call s_update_ib_rotation_matrix(i)
874878
end if
875879
end do
876-
877-
$:GPU_UPDATE(device='[patch_ib]')
880+
$:END_GPU_PARALLEL_LOOP()
878881

879882
! recompute the new ib_patch locations and broadcast them.
880883
call nvtxStartRange("APPLY-IB-PATCHES")
@@ -933,7 +936,7 @@ contains
933936
$:GPU_PARALLEL_LOOP(private='[ib_idx, ib_idx_temp, encoded_ib_idx, fluid_idx, radial_vector, local_force_contribution, &
934937
& cell_volume, local_torque_contribution, dynamic_viscosity, viscous_stress_div, &
935938
& viscous_stress_div_1, viscous_stress_div_2, dx, dy, dz]', copy='[forces, torques]', &
936-
& copyin='[patch_ib, dynamic_viscosities]', collapse=3)
939+
& copyin='[dynamic_viscosities]', collapse=3)
937940
do i = 0, m
938941
do j = 0, n
939942
do k = 0, p
@@ -1122,6 +1125,8 @@ contains
11221125
!> Computes the moment of inertia for an immersed boundary
11231126
subroutine s_compute_moment_of_inertia(ib_idx, axis)
11241127

1128+
$:GPU_ROUTINE(parallelism='[seq]')
1129+
11251130
real(wp), dimension(3), intent(in) :: axis !< the axis about which we compute the moment. Only required in 3D.
11261131
integer, intent(in) :: ib_idx
11271132
real(wp) :: moment, distance_to_axis, cell_volume
@@ -1158,13 +1163,10 @@ contains
11581163

11591164
ib_marker = patch_ib(ib_idx)%gbl_patch_id
11601165

1161-
$:GPU_PARALLEL_LOOP(private='[position, closest_point_along_axis, vector_to_axis, distance_to_axis]', copy='[moment, &
1162-
& count]', copyin='[ib_marker, cell_volume, normal_axis]', collapse=3)
11631166
do i = 0, m
11641167
do j = 0, n
11651168
do k = 0, p
11661169
if (ib_markers%sf(i, j, k) == ib_marker) then
1167-
$:GPU_ATOMIC(atomic='update')
11681170
count = count + 1 ! increment the count of total cells in the boundary
11691171

11701172
! get the position in local coordinates so that the axis passes through 0, 0, 0
@@ -1182,7 +1184,6 @@ contains
11821184
distance_to_axis = dot_product(vector_to_axis, vector_to_axis) ! saves the distance to the axis squared
11831185

11841186
! compute the position component of the moment
1185-
$:GPU_ATOMIC(atomic='update')
11861187
moment = moment + distance_to_axis
11871188
end if
11881189
end do

src/simulation/m_time_steppers.fpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ contains
714714

715715
if (moving_immersed_boundary_flag) call s_compute_ib_forces(q_prim_vf, fluid_pp)
716716

717+
$:GPU_PARALLEL_LOOP(private='[i, gbl_id]', copyin='[s]')
717718
do i = 1, num_ibs
718719
if (s == 1) then
719720
patch_ib(i)%step_vel = patch_ib(i)%vel
@@ -759,8 +760,8 @@ contains
759760
& 2)*patch_ib(i)%z_centroid + rk_coef(s, 3)*patch_ib(i)%vel(3)*dt)/rk_coef(s, 4)
760761
end if
761762
end do
763+
$:END_GPU_PARALLEL_LOOP()
762764

763-
$:GPU_UPDATE(device='[patch_ib]')
764765
call s_update_mib(num_ibs)
765766

766767
call nvtxEndRange

0 commit comments

Comments
 (0)