quantum-espresso/UtilXlib/tests/test_mp_bcast_r4d_gpu.f90

54 lines
1.2 KiB
Fortran
Raw Normal View History

#if defined(__CUDA)
PROGRAM test_mp_bcast_r4d_gpu
!
! Simple program to check the functionalities of test_mp_bcast_r4d.
!
USE cudafor
2020-10-01 12:22:37 +08:00
USE parallel_include
2018-02-28 18:21:12 +08:00
USE util_param, ONLY : DP
USE mp, ONLY : mp_bcast
USE mp_world, ONLY : mp_world_start, mp_world_end, mpime, &
root, nproc, world_comm
USE tester
IMPLICIT NONE
!
TYPE(tester_t) :: test
INTEGER :: world_group = 0
! test variable
2018-02-28 18:21:12 +08:00
REAL(DP), DEVICE :: im_d(10, 10, 10, 10)
REAL(DP) :: im_h(10, 10, 10, 10)
!
CALL test%init()
#if defined(__MPI)
world_group = MPI_COMM_WORLD
#endif
CALL mp_world_start(world_group)
im_h(:, :, :, :) = mpime
im_d = im_h
CALL mp_bcast(im_d, root, world_comm)
im_h = im_d
!
CALL test%assert_equal(ALL(im_h .eq. 0) , .true. )
!
im_h(:, :, :, :) = mpime
im_d = im_h
CALL mp_bcast(im_d, nproc-1, world_comm)
im_h = im_d
!
CALL test%assert_equal(ALL(im_h .eq. nproc-1) , .true. )
!
CALL collect_results(test)
!
CALL mp_world_end()
!
IF (mpime .eq. 0) CALL test%print()
!
END PROGRAM test_mp_bcast_r4d_gpu
#else
PROGRAM test_mp_bcast_r4d_gpu
CALL no_test()
END PROGRAM test_mp_bcast_r4d_gpu
#endif