Skip to content

Commit

Permalink
tests: increase fidelity of MPI, scalapack and MUMPS unit tests
Browse files Browse the repository at this point in the history
also give hard Meson build error if Intel compiler used without MKL.
Yes Intel can be used without MKL, but normally our users woudl use MKL.
  • Loading branch information
scivision committed Nov 25, 2019
1 parent 5306d62 commit a60e56a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 11 deletions.
10 changes: 8 additions & 2 deletions meson/meson.build
Expand Up @@ -45,6 +45,9 @@ endif

# -- MKL (in general, MKL can be used with intel, intel-cl, gcc or PGI)
mklroot = get_option('mklroot')
if ['intel', 'intel-cl'].contains(fc.get_id()) and mklroot == ''
error('Normally Intel compiler uses MKL--please be sure to do like "meson build -Dmklroot=$MKLROOT"')
endif
mkllib_root = mklroot/'lib/intel64'
# os == 'windows' ? mklroot/'lib/intel64_win' : mklroot/'lib/intel64'

Expand Down Expand Up @@ -143,8 +146,11 @@ if not scalapack.found()
scalapack = fc.find_library('scalapack', dirs: scalapack_root / 'lib', required: false, disabler: true)
endif
endif
if scalapack.found() and not fc.links('L = numroc(1,1,1,1,1); end', dependencies: scalapack, name: 'SCALAPACK')
scalapack = disabler()
if scalapack.found()
if (fc.run(files('../tests/test_scalapack.f90'), dependencies: [scalapack, mpi], name: 'SCALAPACK').returncode() != 0)
# .links() is NOT an adequate test
scalapack = disabler()
endif
endif
endif

Expand Down
20 changes: 15 additions & 5 deletions tests/CMakeLists.txt
Expand Up @@ -3,25 +3,35 @@ find_package(MPI REQUIRED COMPONENTS Fortran)
add_executable(testmpi test_mpi.f90)
target_link_libraries(testmpi PRIVATE MPI::MPI_Fortran)
target_compile_options(testmpi PRIVATE ${FFLAGS})
add_test(NAME MPIexist COMMAND testmpi)
add_test(NAME MPIbasic COMMAND testmpi)

set_tests_properties(MPIexist PROPERTIES
set_tests_properties(MPIbasic PROPERTIES
TIMEOUT 15
FIXTURES_SETUP MPIMUMPS)
#---------------
# ---

add_executable(test_scalapack test_scalapack.f90)
target_link_libraries(test_scalapack PRIVATE ${SCALAPACK_LIBRARIES} MPI::MPI_Fortran)
target_include_directories(test_scalapack PRIVATE ${SCALAPACK_INCLUDE_DIRS})
target_compile_options(test_scalapack PRIVATE ${FFLAGS})
add_test(NAME ScalapackBasic COMMAND testmpi)

set_tests_properties(ScalapackBasic PROPERTIES
TIMEOUT 15
FIXTURES_SETUP MPIMUMPS)

# ---
add_executable(testmumps test_mumps.F90)
target_include_directories(testmumps PRIVATE ${MUMPS_INCLUDE_DIRS})
target_compile_options(testmumps PRIVATE ${FFLAGS})
target_compile_definitions(testmumps PRIVATE REALBITS=${realbits})
target_link_libraries(testmumps PRIVATE ${MUMPS_LIBRARIES} MPI::MPI_Fortran)

add_test(NAME MUMPS
add_test(NAME MUMPSbasic
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:testmumps>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

set_tests_properties(MUMPS PROPERTIES
set_tests_properties(MUMPSbasic PROPERTIES
TIMEOUT 15
DEPENDS MPIexist
RUN_SERIAL true
Expand Down
14 changes: 11 additions & 3 deletions tests/meson.build
@@ -1,16 +1,24 @@
test_mpi_exe = executable('test_mpi', 'test_mpi.f90',
dependencies: mpi,
link_language: 'fortran')
test('MPI_OK', test_mpi_exe,
test('MPI basic', test_mpi_exe,
timeout: 10,
suite: 'unit')

test_scalapack_exe = executable('test_scalapack', 'test_scalapack.f90',
dependencies: [scalapack, blacs, mpi],
link_language: 'fortran')
test('Scalapack basic', test_scalapack_exe,
timeout: 10,
suite: 'unit')



test_mumps_exe = executable('test_mumps', 'test_mumps.F90',
dependencies: [mumps, blacs, mpi],
dependencies: [mumps, scalapack, blacs, mpi],
fortran_args: real_bits,
link_language: 'fortran')
test('MUMPS', mpiexec,
test('MUMPS basic', mpiexec,
args: ['-np', '2', test_mumps_exe],
workdir: meson.current_source_dir(),
timeout: 15,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_mpi.f90
Expand Up @@ -12,13 +12,16 @@
if (ierr /= 0) error stop 'mpi init error'

call MPI_COMM_RANK(MPI_COMM_WORLD, mrank, ierr)
if (ierr /= 0) error stop 'mpi comm_rank error'
call MPI_COMM_SIZE(MPI_COMM_WORLD, msize, ierr)
if (ierr /= 0) error stop 'mpi comm_size error'
call MPI_GET_LIBRARY_VERSION(version, vlen, ierr)
if (ierr /= 0) error stop 'mpi get_library_version error'

call MPI_FINALIZE(ierr)
if (ierr /= 0) error stop 'mpi finalize error'

print '(A,I3,A,I3,A)', 'Image ', mrank, ' / ', msize, ':', trim(version)
print '(A,I3,A,I3,A)', 'Image ', mrank, ' / ', msize, ': MPI library version:', trim(version)

print '(A12,A15)','type','value'
print '(A12,I15)','mpi_real',mpi_real
Expand Down
2 changes: 2 additions & 0 deletions tests/test_mumps.F90
Expand Up @@ -17,6 +17,7 @@
print *,compiler_version(), compiler_options()

call mpi_init(ierr)
if (ierr /= 0) error stop 'mpi init error'
! Define a communicator for the package.
mumps_par%COMM = MPI_COMM_WORLD
! Initialize an instance of the package
Expand All @@ -28,6 +29,7 @@
call simple_test(mumps_par)

call mpi_finalize(ierr)
if (ierr /= 0) error stop 'mpi finalize error'

contains

Expand Down
25 changes: 25 additions & 0 deletions tests/test_scalapack.f90
@@ -0,0 +1,25 @@
! minimal Scalapack demo
implicit none

integer :: ictxt, myid, nprocs, mycol, myrow, npcol, nprow
real :: eps
real, external :: pslamch

! arbitrary test parameters
npcol = 2
nprow = 2

call blacs_pinfo(myid, nprocs)
call blacs_get(-1, 0, ictxt)
call blacs_gridinit(ictxt, "C", nprocs, 1)

call blacs_gridinfo(ictxt, nprow, npcol, myrow, mycol)

eps = pslamch(ictxt, 'E')

if(myrow == mycol) print '(A, F10.6)', "OK: Scalapack Fortran eps=", eps

call blacs_gridexit(ictxt)
call blacs_exit(0)

end program

0 comments on commit a60e56a

Please sign in to comment.