Skip to content

Commit

Permalink
Combine sum_<y|z>intox into a single test
Browse files Browse the repository at this point in the history
  • Loading branch information
pbartholomew08 committed Jun 28, 2024
1 parent c076b39 commit 3a75900
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 115 deletions.
3 changes: 1 addition & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ define_test(omp/test_omp_transeq.f90 ${CMAKE_CTEST_NPROCS} omp)
define_test(omp/test_omp_dist_transeq.f90 ${CMAKE_CTEST_NPROCS} omp)

define_test(test_scalar_product.f90 ${CMAKE_CTEST_NPROCS} omp)
define_test(test_sum_yintox.f90 ${CMAKE_CTEST_NPROCS} omp)
define_test(test_sum_zintox.f90 ${CMAKE_CTEST_NPROCS} omp)
define_test(test_sum_intox.f90 ${CMAKE_CTEST_NPROCS} omp)

if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI" OR
${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVHPC")
Expand Down
48 changes: 38 additions & 10 deletions tests/test_sum_yintox.f90 → tests/test_sum_intox.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
program test_sum_yintox
program test_sum_intox
!! Tests the implementation of summing a Y-oriented field into an X-oriented
!! one.

use m_common, only: DIR_X, DIR_Y
use m_common, only: DIR_X, DIR_Y, DIR_Z

use m_allocator
use m_base_backend
Expand Down Expand Up @@ -48,7 +48,8 @@ program test_sum_yintox
backend => omp_backend
#endif

call runtest()
call runtest("YintoX", DIR_Y)
call runtest("ZintoX", DIR_Z)

if (nrank == 0) then
if (.not. test_pass) then
Expand All @@ -60,19 +61,27 @@ program test_sum_yintox

contains

subroutine runtest()
subroutine runtest(test, dir_from)

use m_ordering, only: get_index_dir

character(len=*), intent(in) :: test
integer, intent(in) :: dir_from

class(field_t), pointer :: a, b
integer :: ctr
integer :: i, j, k
integer :: ii, jj, kk

integer, dimension(3) :: dims
logical :: check_pass

if (nrank == 0) then
print *, "Test ", test
end if

a => backend%allocator%get_block(DIR_X)
b => backend%allocator%get_block(DIR_Y)
b => backend%allocator%get_block(dir_from)

dims = mesh%get_padded_dims(DIR_C)

Expand All @@ -84,20 +93,39 @@ subroutine runtest()
call get_index_dir(ii, jj, kk, i, j, k, DIR_X, SZ, &
dims(1), dims(2), dims(3))
a%data(ii, jj, kk) = ctr
call get_index_dir(ii, jj, kk, i, j, k, DIR_Y, SZ, &
call get_index_dir(ii, jj, kk, i, j, k, dir_from, SZ, &
dims(1), dims(2), dims(3))
b%data(ii, jj, kk) = -ctr
ctr = ctr + 1
end do
end do
end do

call backend%sum_yintox(a, b)

if (dir_from == DIR_Y) then
call backend%sum_yintox(a, b)
else
call backend%sum_zintox(a, b)
end if

if ((minval(a%data) /= 0) .or. (maxval(a%data) /= 0)) then
test_pass = .false.
check_pass = .false.
end if
call MPI_Allreduce(MPI_IN_PLACE, check_pass, 1, &
MPI_LOGICAL, MPI_LAND, MPI_COMM_WORLD, &
ierr)
test_pass = test_pass .and. check_pass

if (nrank == 0) then
if (check_pass) then
print *, "- PASS"
else
print *, "- FAIL"
end if
end if

call backend%allocator%release_block(a)
call backend%allocator%release_block(b)

end subroutine runtest

end program test_sum_yintox
end program test_sum_intox
103 changes: 0 additions & 103 deletions tests/test_sum_zintox.f90

This file was deleted.

0 comments on commit 3a75900

Please sign in to comment.