mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Add OpenMP tests (also fix PEP8 compliance in test_compile.py).
This commit is contained in:
parent
7e5e146f4e
commit
d44dfd20d9
2 changed files with 66 additions and 22 deletions
|
|
@ -55,7 +55,7 @@ def run_suite(name=None, mpi=False):
|
|||
results.append((name, result))
|
||||
|
||||
# set mpiexec path
|
||||
if os.environ.has_key('COMPILER'):
|
||||
if 'COMPILER' in os.environ:
|
||||
compiler = os.environ['COMPILER']
|
||||
else:
|
||||
compiler = 'gnu'
|
||||
|
|
@ -67,8 +67,9 @@ sys.path.append(pwd)
|
|||
|
||||
# Set list of tests, either default or from command line
|
||||
flags = []
|
||||
tests = ['compile', 'normal', 'debug', 'optimize', 'hdf5', 'mpi', 'phdf5',
|
||||
'petsc', 'phdf5-petsc', 'phdf5-petsc-optimize']
|
||||
tests = ['compile', 'normal', 'debug', 'optimize', 'mpi', 'omp', 'hdf5',
|
||||
'petsc', 'mpi-omp', 'omp-hdf5', 'phdf5', 'phdf5-petsc',
|
||||
'phdf5-petsc-optimize', 'omp-phdf5-petsc-optimize']
|
||||
if len(sys.argv) > 1:
|
||||
flags = [i for i in sys.argv[1:] if i.startswith('-')]
|
||||
tests_ = [i for i in sys.argv[1:] if not i.startswith('-')]
|
||||
|
|
@ -79,10 +80,10 @@ results = []
|
|||
for name in tests:
|
||||
if name == 'compile':
|
||||
run_compile()
|
||||
elif name in ['normal', 'debug', 'optimize', 'hdf5']:
|
||||
elif name in ['normal', 'debug', 'optimize', 'omp', 'hdf5', 'omp-hdf5']:
|
||||
run_suite(name=name)
|
||||
elif name in ['mpi', 'phdf5', 'petsc', 'phdf5-petsc',
|
||||
'phdf5-petsc-optimize']:
|
||||
elif name in ['mpi', 'mpi-omp' 'phdf5', 'petsc', 'phdf5-petsc',
|
||||
'phdf5-petsc-optimize', 'omp-phdf5-petsc-optimize']:
|
||||
run_suite(name=name, mpi=True)
|
||||
|
||||
# print out summary of results
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
"""Compilation tests
|
||||
|
||||
This set of tests makes sure that OpenMC can compile for many different
|
||||
combinations of compilation flags and options. By default, only the gfortran and
|
||||
ifort compilers are tested. This requires that the MPI, HDF5, and PETSC
|
||||
combinations of compilation flags and options. By default, only the gfortran
|
||||
and ifort compilers are tested. This requires that the MPI, HDF5, and PETSC
|
||||
libraries are already set up appropriately in the Makefile.
|
||||
|
||||
"""
|
||||
|
|
@ -15,80 +15,123 @@ import shutil
|
|||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
if os.environ.has_key('COMPILER'):
|
||||
if 'COMPILER' in os.environ:
|
||||
compiler = 'COMPILER=' + os.environ['COMPILER']
|
||||
else:
|
||||
compiler = 'COMPILER=gnu'
|
||||
|
||||
|
||||
def setup():
|
||||
# Change to source directory
|
||||
os.chdir(pwd + '/../../src')
|
||||
|
||||
|
||||
def test_normal():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-normal')
|
||||
|
||||
|
||||
def test_debug():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'DEBUG=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-debug')
|
||||
|
||||
|
||||
def test_profile():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'PROFILE=yes'])
|
||||
assert returncode == 0
|
||||
|
||||
|
||||
def test_optimize():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'OPTIMIZE=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-optimize')
|
||||
|
||||
|
||||
def test_mpi():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-mpi')
|
||||
|
||||
|
||||
def test_omp():
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'OPENMP=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-omp')
|
||||
|
||||
|
||||
def test_hdf5():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'HDF5=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-hdf5')
|
||||
|
||||
|
||||
def test_petsc():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'PETSC=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-petsc')
|
||||
|
||||
|
||||
def test_mpi_omp():
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'OPENMP=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-mpi-omp')
|
||||
|
||||
|
||||
def test_omp_hdf5():
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'OPENMP=yes', 'HDF5=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-omp-hdf5')
|
||||
|
||||
|
||||
def test_mpi_hdf5():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-phdf5')
|
||||
|
||||
|
||||
def test_mpi_hdf5_petsc():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes', 'PETSC=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-phdf5-petsc')
|
||||
|
||||
|
||||
def test_mpi_hdf5_petsc_optimize():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes', 'PETSC=yes', 'OPTIMIZE=yes'])
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes', 'PETSC=yes',
|
||||
'OPTIMIZE=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-phdf5-petsc-optimize')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5_petsc_optimize():
|
||||
returncode = run(['make', 'distclean'])
|
||||
returncode = run(['make', compiler, 'MPI=yes', 'OMP=yes', 'HDF5=yes',
|
||||
'PETSC=yes', 'OPTIMIZE=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-omp-phdf5-petsc-optimize')
|
||||
|
||||
|
||||
def run(commands):
|
||||
proc = Popen(commands, stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
print(proc.communicate()[0])
|
||||
return returncode
|
||||
|
||||
|
||||
def teardown(commands):
|
||||
returncode = run(['make','distclean'])
|
||||
shutil.copy('openmc-normal','openmc')
|
||||
returncode = run(['make', 'distclean'])
|
||||
shutil.copy('openmc-normal', 'openmc')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue