simple MPI test for testing the autocmake
- code reviewer's comments included
This commit is contained in:
parent
baa9fe5555
commit
f8905fed65
@ -1,6 +1,6 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
install:
|
install:
|
||||||
- sudo apt-get install g++ cmake gfortran libblas-dev liblapack-dev
|
- sudo apt-get install g++ cmake gfortran libblas-dev liblapack-dev openmpi-bin libopenmpi-dev
|
||||||
- sudo pip install pytest pep8
|
- sudo pip install pytest pep8
|
||||||
script:
|
script:
|
||||||
- pep8 --ignore=E501 update.py
|
- pep8 --ignore=E501 update.py
|
||||||
|
17
test/fc_mpi/cmake/autocmake.cfg
Normal file
17
test/fc_mpi/cmake/autocmake.cfg
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[project]
|
||||||
|
name: example
|
||||||
|
|
||||||
|
[fc]
|
||||||
|
source: ../../../modules/fc.cmake
|
||||||
|
|
||||||
|
[mpi]
|
||||||
|
source: ../../../modules/mpi.cmake
|
||||||
|
|
||||||
|
[int64]
|
||||||
|
source: ../../../modules/int64.cmake
|
||||||
|
|
||||||
|
[default_build_paths]
|
||||||
|
source: ../../../modules/default_build_paths.cmake
|
||||||
|
|
||||||
|
[src]
|
||||||
|
source: ../../../modules/src.cmake
|
6
test/fc_mpi/src/CMakeLists.txt
Normal file
6
test/fc_mpi/src/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
if (MPI_FOUND)
|
||||||
|
add_executable(example example.f90)
|
||||||
|
else()
|
||||||
|
message(FATAL "MPI not found!")
|
||||||
|
endif()
|
||||||
|
|
16
test/fc_mpi/src/example.f90
Normal file
16
test/fc_mpi/src/example.f90
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
program example
|
||||||
|
use mpi
|
||||||
|
implicit none
|
||||||
|
integer :: ierr, rank, size
|
||||||
|
logical :: test_ok
|
||||||
|
call MPI_INIT(ierr)
|
||||||
|
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
|
||||||
|
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
|
||||||
|
call MPI_FINALIZE(ierr)
|
||||||
|
test_ok=(size==2.and.(rank==0.or.rank==1))
|
||||||
|
if (test_ok) then
|
||||||
|
if (rank == 0) print *,'Test OK!'
|
||||||
|
else
|
||||||
|
stop "test fc_mpi failed!"
|
||||||
|
endif
|
||||||
|
end program
|
16
test/test.py
16
test/test.py
@ -72,7 +72,7 @@ def exe(command):
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def configure_build_and_exe(name, setup_command):
|
def configure_build_and_exe(name, setup_command, launcher=None):
|
||||||
|
|
||||||
stamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S')
|
stamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S')
|
||||||
|
|
||||||
@ -97,9 +97,15 @@ def configure_build_and_exe(name, setup_command):
|
|||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
stdout, stderr = exe('mingw32-make')
|
stdout, stderr = exe('mingw32-make')
|
||||||
|
if (launcher):
|
||||||
|
stdout, stderr = exe(launcher + ' bin\\\example.exe')
|
||||||
|
else:
|
||||||
stdout, stderr = exe('bin\\\example.exe')
|
stdout, stderr = exe('bin\\\example.exe')
|
||||||
else:
|
else:
|
||||||
stdout, stderr = exe('make')
|
stdout, stderr = exe('make')
|
||||||
|
if (launcher):
|
||||||
|
stdout, stderr = exe(launcher + ' ./bin/example')
|
||||||
|
else:
|
||||||
stdout, stderr = exe('./bin/example')
|
stdout, stderr = exe('./bin/example')
|
||||||
|
|
||||||
return stdout, stderr
|
return stdout, stderr
|
||||||
@ -142,6 +148,14 @@ def test_fc_int64():
|
|||||||
stdout, stderr = configure_build_and_exe('fc_int64', 'python setup.py --fc=gfortran --int64')
|
stdout, stderr = configure_build_and_exe('fc_int64', 'python setup.py --fc=gfortran --int64')
|
||||||
assert 'test_int64 ok' in stdout
|
assert 'test_int64 ok' in stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_fc_mpi():
|
||||||
|
if sys.platform != 'win32':
|
||||||
|
stdout, stderr = configure_build_and_exe('fc_mpi', 'python setup.py --mpi --fc=mpif90', 'mpirun -np 2')
|
||||||
|
assert 'Test OK!' in stdout
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user