Skip to content

Commit fc65f7e

Browse files
committed
CI probe: multi-lane device-versus-host check of every EOS helper
1 parent 2829c41 commit fc65f7e

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

src/simulation/m_start_up.fpp

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,13 @@ contains
10341034
!> Transfer initial conservative variable and model parameter data to the GPU device
10351035
subroutine s_initialize_gpu_vars
10361036

1037-
integer :: i
1037+
integer :: i, n, kk
1038+
integer, parameter :: np = 100000
1039+
real(wp), allocatable, dimension(:) :: pin
1040+
real(wp), allocatable, dimension(:,:) :: pout
1041+
real(wp), dimension(6) :: href
1042+
integer, dimension(6) :: nbad, nfirst
1043+
real(wp) :: rho, gamma, pi_inf, dpi, dgamma, tmp
10381044

10391045
if (.not. down_sample) then
10401046
do i = 1, sys_size
@@ -1101,6 +1107,54 @@ contains
11011107
$:GPU_UPDATE(device='[igr, nb, igr_order]')
11021108
#:endif
11031109

1110+
! CI probe: every EOS helper over many lanes with per-lane inputs, device against host.
1111+
@:ALLOCATE(pin(1:np), pout(1:np, 1:6))
1112+
do n = 1, np
1113+
pin(n) = 1._wp + 1.e-3_wp*n
1114+
end do
1115+
$:GPU_UPDATE(device='[pin]')
1116+
$:GPU_PARALLEL_LOOP(private='[n, rho, gamma, pi_inf, dpi, dgamma, tmp]')
1117+
do n = 1, np
1118+
pout(n, 1) = f_bulk_modulus(pin(n), gammas(1), pi_infs(1))
1119+
call s_phase_coefficients(0.5_wp*pin(n), 0.5_wp, 1, rho, gamma, pi_inf, dpi, dgamma)
1120+
pout(n, 2) = gamma*pin(n) + pi_inf + rho
1121+
call s_phase_bulk_modulus(pin(n), 0.5_wp, 0.5_wp*pin(n), 1, pout(n, 3))
1122+
call s_phase_bulk_modulus(pin(n), 0.5_wp, 0.5_wp*pin(n), 1, tmp)
1123+
pout(n, 4) = tmp
1124+
call s_phase_internal_energy(pin(n), 0.5_wp, 0.5_wp*pin(n), 1, tmp)
1125+
pout(n, 5) = tmp
1126+
call s_eos_coefficients(pin(n), 1, gamma, pi_inf, dpi, dgamma)
1127+
pout(n, 6) = gamma*pin(n) + pi_inf + dpi + dgamma
1128+
end do
1129+
$:END_GPU_PARALLEL_LOOP()
1130+
$:GPU_UPDATE(host='[pout]')
1131+
nbad = 0
1132+
nfirst = 0
1133+
do n = 1, np
1134+
href(1) = f_bulk_modulus(pin(n), gammas(1), pi_infs(1))
1135+
call s_phase_coefficients(0.5_wp*pin(n), 0.5_wp, 1, rho, gamma, pi_inf, dpi, dgamma)
1136+
href(2) = gamma*pin(n) + pi_inf + rho
1137+
call s_phase_bulk_modulus(pin(n), 0.5_wp, 0.5_wp*pin(n), 1, href(3))
1138+
href(4) = href(3)
1139+
call s_phase_internal_energy(pin(n), 0.5_wp, 0.5_wp*pin(n), 1, href(5))
1140+
call s_eos_coefficients(pin(n), 1, gamma, pi_inf, dpi, dgamma)
1141+
href(6) = gamma*pin(n) + pi_inf + dpi + dgamma
1142+
do kk = 1, 6
1143+
if (.not. abs(pout(n, kk) - href(kk)) <= 1.e-12_wp*abs(href(kk))) then
1144+
nbad(kk) = nbad(kk) + 1
1145+
if (nfirst(kk) == 0) nfirst(kk) = n
1146+
end if
1147+
end do
1148+
end do
1149+
if (proc_rank == 0) then
1150+
print '(A, 6I8)', ' eos probe mismatches per kernel (of 100000): ', nbad
1151+
do kk = 1, 6
1152+
if (nfirst(kk) > 0) print '(A, I2, A, I7, 2ES24.15)', ' eos probe kernel ', kk, ' first bad lane ', nfirst(kk), &
1153+
& pout(nfirst(kk), kk), href(kk)
1154+
end do
1155+
end if
1156+
@:DEALLOCATE(pin, pout)
1157+
11041158
end subroutine s_initialize_gpu_vars
11051159

11061160
!> Finalize and deallocate all simulation sub-modules in reverse initialization order

0 commit comments

Comments
 (0)