Skip to content

Commit 6b3fe8e

Browse files
wilfonbaAnandAnand Radhakrishnansbryngelson
authored
Frontier UVM and other preparations to reproduce 100T (#967)
Co-authored-by: Anand <[email protected]> Co-authored-by: Anand Radhakrishnan <[email protected]> Co-authored-by: Spencer Bryngelson <[email protected]>
1 parent 52c0aac commit 6b3fe8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1243
-971
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Gam = "Gam"
1818
strang = "strang"
1919
Strang = "Strang"
2020
TKE = "TKE"
21+
HSA = "HSA"
2122

2223
[files]
2324
extend-exclude = ["docs/documentation/references*", "tests/", "toolchain/cce_simulation_workgroup_256.sh"]

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ function(MFC_SETUP_TARGET)
506506
)
507507
endif()
508508
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
509+
# Frontier Unified Memory Support
510+
if (MFC_Unified)
511+
target_compile_options(${ARGS_TARGET}
512+
PRIVATE -DFRONTIER_UNIFIED)
513+
endif()
514+
509515
find_package(hipfort COMPONENTS hip CONFIG REQUIRED)
510516
target_link_libraries(${a_target} PRIVATE hipfort::hip hipfort::hipfort-amdgcn)
511517
endif()

src/common/m_boundary_common.fpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ contains
16261626

16271627
impure subroutine s_create_mpi_types(bc_type)
16281628

1629-
type(integer_field), dimension(1:num_dims, -1:1) :: bc_type
1629+
type(integer_field), dimension(1:num_dims, -1:1), intent(in) :: bc_type
16301630

16311631
#ifdef MFC_MPI
16321632
integer :: dir, loc
@@ -1659,9 +1659,9 @@ contains
16591659

16601660
subroutine s_write_serial_boundary_condition_files(q_prim_vf, bc_type, step_dirpath, old_grid_in)
16611661

1662-
type(scalar_field), dimension(sys_size) :: q_prim_vf
1663-
type(integer_field), dimension(1:num_dims, -1:1) :: bc_type
1664-
logical :: old_grid_in
1662+
type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf
1663+
type(integer_field), dimension(1:num_dims, -1:1), intent(in) :: bc_type
1664+
logical, intent(in) :: old_grid_in
16651665

16661666
character(LEN=*), intent(in) :: step_dirpath
16671667

@@ -1700,8 +1700,8 @@ contains
17001700

17011701
subroutine s_write_parallel_boundary_condition_files(q_prim_vf, bc_type)
17021702

1703-
type(scalar_field), dimension(sys_size) :: q_prim_vf
1704-
type(integer_field), dimension(1:num_dims, -1:1) :: bc_type
1703+
type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf
1704+
type(integer_field), dimension(1:num_dims, -1:1), intent(in) :: bc_type
17051705

17061706
integer :: dir, loc
17071707
character(len=path_len) :: file_loc, file_path
@@ -1870,7 +1870,7 @@ contains
18701870

18711871
subroutine s_pack_boundary_condition_buffers(q_prim_vf)
18721872

1873-
type(scalar_field), dimension(sys_size) :: q_prim_vf
1873+
type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf
18741874
integer :: i, j, k
18751875

18761876
do k = 0, p

src/common/m_helper.fpp

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ module m_helper
3737
double_factorial, &
3838
factorial, &
3939
f_cut_on, &
40-
f_cut_off
40+
f_cut_off, &
41+
s_downsample_data, &
42+
s_upsample_data
4143

4244
contains
4345

@@ -625,4 +627,87 @@ contains
625627
626628
end function f_gx
627629
630+
subroutine s_downsample_data(q_cons_vf, q_cons_temp, m_ds, n_ds, p_ds, m_glb_ds, n_glb_ds, p_glb_ds)
631+
632+
type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf, q_cons_temp
633+
634+
! Down sampling variables
635+
integer :: i, j, k, l
636+
integer :: ix, iy, iz, x_id, y_id, z_id
637+
integer, intent(inout) :: m_ds, n_ds, p_ds, m_glb_ds, n_glb_ds, p_glb_ds
638+
639+
m_ds = int((m + 1)/3) - 1
640+
n_ds = int((n + 1)/3) - 1
641+
p_ds = int((p + 1)/3) - 1
642+
643+
m_glb_ds = int((m_glb + 1)/3) - 1
644+
n_glb_ds = int((n_glb + 1)/3) - 1
645+
p_glb_ds = int((p_glb + 1)/3) - 1
646+
647+
do i = 1, sys_size
648+
$:GPU_UPDATE(host='[q_cons_vf(i)%sf]')
649+
end do
650+
651+
do l = -1, p_ds + 1
652+
do k = -1, n_ds + 1
653+
do j = -1, m_ds + 1
654+
x_id = 3*j + 1
655+
y_id = 3*k + 1
656+
z_id = 3*l + 1
657+
do i = 1, sys_size
658+
q_cons_temp(i)%sf(j, k, l) = 0
659+
660+
do iz = -1, 1
661+
do iy = -1, 1
662+
do ix = -1, 1
663+
q_cons_temp(i)%sf(j, k, l) = q_cons_temp(i)%sf(j, k, l) &
664+
+ (1._wp/27._wp)*q_cons_vf(i)%sf(x_id + ix, y_id + iy, z_id + iz)
665+
end do
666+
end do
667+
end do
668+
end do
669+
end do
670+
end do
671+
end do
672+
673+
end subroutine s_downsample_data
674+
675+
subroutine s_upsample_data(q_cons_vf, q_cons_temp)
676+
677+
type(scalar_field), intent(inout), dimension(sys_size) :: q_cons_vf, q_cons_temp
678+
integer :: i, j, k, l
679+
integer :: ix, iy, iz
680+
integer :: x_id, y_id, z_id
681+
real(wp), dimension(4) :: temp
682+
683+
do l = 0, p
684+
do k = 0, n
685+
do j = 0, m
686+
do i = 1, sys_size
687+
688+
ix = int(j/3._wp)
689+
iy = int(k/3._wp)
690+
iz = int(l/3._wp)
691+
692+
x_id = j - int(3*ix) - 1
693+
y_id = k - int(3*iy) - 1
694+
z_id = l - int(3*iz) - 1
695+
696+
temp(1) = (2._wp/3._wp)*q_cons_temp(i)%sf(ix, iy, iz) + (1._wp/3._wp)*q_cons_temp(i)%sf(ix + x_id, iy, iz)
697+
temp(2) = (2._wp/3._wp)*q_cons_temp(i)%sf(ix, iy + y_id, iz) + (1._wp/3._wp)*q_cons_temp(i)%sf(ix + x_id, iy + y_id, iz)
698+
temp(3) = (2._wp/3._wp)*temp(1) + (1._wp/3._wp)*temp(2)
699+
700+
temp(1) = (2._wp/3._wp)*q_cons_temp(i)%sf(ix, iy, iz + z_id) + (1._wp/3._wp)*q_cons_temp(i)%sf(ix + x_id, iy, iz + z_id)
701+
temp(2) = (2._wp/3._wp)*q_cons_temp(i)%sf(ix, iy + y_id, iz + z_id) + (1._wp/3._wp)*q_cons_temp(i)%sf(ix + x_id, iy + y_id, iz + z_id)
702+
temp(4) = (2._wp/3._wp)*temp(1) + (1._wp/3._wp)*temp(2)
703+
704+
q_cons_vf(i)%sf(j, k, l) = (2._wp/3._wp)*temp(3) + (1._wp/3._wp)*temp(4)
705+
706+
end do
707+
end do
708+
end do
709+
end do
710+
711+
end subroutine s_upsample_data
712+
628713
end module m_helper

src/common/m_helper_basic.fpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ contains
110110
res = f_approx_equal(var, real(nint(var), wp))
111111
end function f_is_integer
112112

113-
pure subroutine s_configure_coordinate_bounds(recon_type, weno_polyn, muscl_polyn, buff_size, idwint, idwbuff, &
113+
pure subroutine s_configure_coordinate_bounds(recon_type, weno_polyn, muscl_polyn, &
114+
igr_order, buff_size, idwint, idwbuff, &
114115
viscous, bubbles_lagrange, m, n, p, num_dims, igr)
115-
integer, intent(in) :: recon_type, weno_polyn, muscl_polyn, m, n, p, num_dims
116+
117+
integer, intent(in) :: recon_type, weno_polyn, muscl_polyn
118+
integer, intent(in) :: m, n, p, num_dims, igr_order
116119
integer, intent(inout) :: buff_size
117120
type(int_bounds_info), dimension(3), intent(inout) :: idwint, idwbuff
118121
logical, intent(in) :: viscous, bubbles_lagrange
@@ -123,11 +126,7 @@ contains
123126
! the physical computational domain from one time-step iteration to
124127
! the next one
125128
if (igr) then
126-
if (viscous) then
127-
buff_size = 6
128-
else
129-
buff_size = 4
130-
end if
129+
buff_size = (igr_order - 1)/2 + 2
131130
elseif (recon_type == WENO_TYPE) then
132131
if (viscous) then
133132
buff_size = 2*weno_polyn + 2

src/common/m_mpi_common.fpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,57 @@ contains
282282
283283
end subroutine s_initialize_mpi_data
284284
285+
!! @param q_cons_vf Conservative variables
286+
subroutine s_initialize_mpi_data_ds(q_cons_vf)
287+
288+
type(scalar_field), &
289+
dimension(sys_size), &
290+
intent(in) :: q_cons_vf
291+
292+
integer, dimension(num_dims) :: sizes_glb, sizes_loc
293+
integer, dimension(3) :: sf_start_idx
294+
295+
#ifdef MFC_MPI
296+
297+
! Generic loop iterator
298+
integer :: i, j, q, k, l, m_ds, n_ds, p_ds, ierr
299+
300+
sf_start_idx = (/0, 0, 0/)
301+
302+
#ifndef MFC_POST_PROCESS
303+
m_ds = int((m + 1)/3) - 1
304+
n_ds = int((n + 1)/3) - 1
305+
p_ds = int((p + 1)/3) - 1
306+
#else
307+
m_ds = m
308+
n_ds = n
309+
p_ds = p
310+
#endif
311+
312+
#ifdef MFC_POST_PROCESS
313+
do i = 1, sys_size
314+
MPI_IO_DATA%var(i)%sf => q_cons_vf(i)%sf(-1:m_ds + 1, -1:n_ds + 1, -1:p_ds + 1)
315+
end do
316+
#endif
317+
! Define global(g) and local(l) sizes for flow variables
318+
sizes_loc(1) = m_ds + 3
319+
if (n > 0) then
320+
sizes_loc(2) = n_ds + 3
321+
if (p > 0) then
322+
sizes_loc(3) = p_ds + 3
323+
end if
324+
end if
325+
326+
! Define the view for each variable
327+
do i = 1, sys_size
328+
call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_loc, sizes_loc, sf_start_idx, &
329+
MPI_ORDER_FORTRAN, mpi_p, MPI_IO_DATA%view(i), ierr)
330+
call MPI_TYPE_COMMIT(MPI_IO_DATA%view(i), ierr)
331+
end do
332+
#endif
333+
334+
end subroutine s_initialize_mpi_data_ds
335+
285336
impure subroutine s_mpi_gather_data(my_vector, counts, gathered_vector, root)
286337
287338
integer, intent(in) :: counts ! Array of vector lengths for each process

src/common/m_variables_conversion.fpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ contains
392392
if (igr) then
393393
if (num_fluids == 1) then
394394
alpha_rho_K(1) = q_vf(contxb)%sf(k, l, r)
395-
alpha_K(1) = q_vf(advxb)%sf(k, l, r)
395+
alpha_K(1) = 1._wp
396396
else
397397
do i = 1, num_fluids - 1
398398
alpha_rho_K(i) = q_vf(i)%sf(k, l, r)
@@ -884,7 +884,7 @@ contains
884884
if (igr) then
885885
if (num_fluids == 1) then
886886
alpha_rho_K(1) = qK_cons_vf(contxb)%sf(j, k, l)
887-
alpha_K(1) = qK_cons_vf(advxb)%sf(j, k, l)
887+
alpha_K(1) = 1._wp
888888
else
889889
$:GPU_LOOP(parallelism='[seq]')
890890
do i = 1, num_fluids - 1
@@ -1147,10 +1147,12 @@ contains
11471147
end do
11481148
end if
11491149

1150-
$:GPU_LOOP(parallelism='[seq]')
1151-
do i = advxb, advxe
1152-
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l)
1153-
end do
1150+
if (.not. igr .or. num_fluids > 1) then
1151+
$:GPU_LOOP(parallelism='[seq]')
1152+
do i = advxb, advxe
1153+
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l)
1154+
end do
1155+
end if
11541156

11551157
if (surface_tension) then
11561158
qK_prim_vf(c_idx)%sf(j, k, l) = qK_cons_vf(c_idx)%sf(j, k, l)
@@ -1223,10 +1225,12 @@ contains
12231225
call s_convert_to_mixture_variables(q_prim_vf, j, k, l, &
12241226
rho, gamma, pi_inf, qv, Re_K, G, fluid_pp(:)%G)
12251227

1226-
! Transferring the advection equation(s) variable(s)
1227-
do i = adv_idx%beg, adv_idx%end
1228-
q_cons_vf(i)%sf(j, k, l) = q_prim_vf(i)%sf(j, k, l)
1229-
end do
1228+
if (.not. igr .or. num_fluids > 1) then
1229+
! Transferring the advection equation(s) variable(s)
1230+
do i = adv_idx%beg, adv_idx%end
1231+
q_cons_vf(i)%sf(j, k, l) = q_prim_vf(i)%sf(j, k, l)
1232+
end do
1233+
end if
12301234

12311235
if (relativity) then
12321236

0 commit comments

Comments
 (0)