forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: enable testing via CTest. (AMReX-Codes#1362)
- Loading branch information
Showing
16 changed files
with
277 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
if (NOT ENABLE_EB) | ||
return() | ||
endif () | ||
|
||
set(_sources main.cpp) | ||
set(_input_files ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files inputs ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources BBIOTest.cpp BBIOTestDriver.cpp ) | ||
set(_input_files ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files inputs ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# | ||
# List of subdirectories to search for CMakeLists. | ||
# | ||
set( AMREX_TESTS_SUBDIRS AsyncOut ) | ||
|
||
if (ENABLE_PARTICLES) | ||
list(APPEND AMREX_TESTS_SUBDIRS Particles) | ||
endif () | ||
|
||
list(TRANSFORM AMREX_TESTS_SUBDIRS PREPEND "${CMAKE_CURRENT_LIST_DIR}/") | ||
|
||
# | ||
# Function to setup the tutorials | ||
# | ||
function (setup_test _srcs _inputs) | ||
|
||
cmake_parse_arguments( "" "HAS_FORTRAN_MODULES" | ||
"BASE_NAME;RUNTIME_SUBDIR;EXTRA_DEFINITIONS;CMDLINE_PARAMS;NTASKS;NTHREADS" "" ${ARGN} ) | ||
|
||
if (_BASE_NAME) | ||
set(_base_name ${_BASE_NAME}) | ||
else () | ||
string(REGEX REPLACE ".*Tests/" "" _base_name ${CMAKE_CURRENT_LIST_DIR}) | ||
string(REPLACE "/" "_" _base_name ${_base_name}) | ||
endif() | ||
|
||
if (_RUNTIME_SUBDIR) | ||
set(_exe_dir ${CMAKE_CURRENT_BINARY_DIR}/${_RUNTIME_SUBDIR}) | ||
else () | ||
set(_exe_dir ${CMAKE_CURRENT_BINARY_DIR}) | ||
endif () | ||
|
||
set( _exe_name Test_${_base_name} ) | ||
set( _test_name ${_base_name} ) | ||
|
||
add_executable( ${_exe_name} ) | ||
target_sources( ${_exe_name} PRIVATE ${${_srcs}} ) | ||
set_target_properties( ${_exe_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${_exe_dir} ) | ||
|
||
if (_EXTRA_DEFINITIONS) | ||
target_compile_definitions(${_exe_name} PRIVATE ${_EXTRA_DEFINITIONS}) | ||
endif () | ||
|
||
# Find out which include directory is needed | ||
set(_includes ${${_srcs}}) | ||
list(FILTER _includes INCLUDE REGEX "\\.H") | ||
foreach(_item IN LISTS _includes) | ||
get_filename_component( _include_dir ${_item} DIRECTORY ) | ||
target_include_directories( ${_exe_name} PRIVATE ${_include_dir} ) | ||
endforeach() | ||
|
||
if (_HAS_FORTRAN_MODULES) | ||
target_include_directories(${_exe_name} | ||
PRIVATE | ||
${CMAKE_CURRENT_BINARY_DIR}/mod_files) | ||
set_target_properties( ${_exe_name} | ||
PROPERTIES | ||
Fortran_MODULE_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR}/mod_files ) | ||
endif () | ||
|
||
target_link_libraries( ${_exe_name} amrex ) | ||
|
||
if (ENABLE_CUDA) | ||
setup_target_for_cuda_compilation( ${_exe_name} ) | ||
endif () | ||
|
||
# | ||
# Assemble the commands sequence to launch the test | ||
# | ||
set(_cmd ${_exe_dir}/${_exe_name}) | ||
|
||
if (_CMDLINE_PARAMS) | ||
list(APPEND _cmd ${_CMDLINE_PARAMS}) | ||
endif () | ||
|
||
if (${_inputs}) | ||
file( COPY ${${_inputs}} DESTINATION ${_exe_dir} ) | ||
list(APPEND _cmd ${${_inputs}}) | ||
endif () | ||
|
||
# | ||
# Add the test | ||
# | ||
add_test( | ||
NAME ${_test_name} | ||
COMMAND ${_cmd} | ||
WORKING_DIRECTORY ${_exe_dir} | ||
) | ||
|
||
# | ||
# Add MPI test | ||
# | ||
if (ENABLE_MPI AND _NTASKS) | ||
if (_NTASKS GREATER 2) | ||
message(FATAL_ERROR "\nsetup_tests(): number of MPI tasks exceeds CI limit of 2") | ||
endif () | ||
|
||
add_test( | ||
NAME ${_test_name}_MPI | ||
COMMAND mpiexec -n ${_NTASKS} ${_cmd} | ||
WORKING_DIRECTORY ${_exe_dir} | ||
) | ||
|
||
set_tests_properties(${_test_name}_MPI PROPERTIES ENVIRONMENT OMP_NUM_THREADS=1 ) | ||
endif () | ||
|
||
if (ENABLE_OMP AND _NTHREADS) | ||
if (_NTHREADS GREATER 2) | ||
message(FATAL_ERROR "\nsetup_tests(): number of OpenMP threads exceeds CI limit of 2") | ||
endif () | ||
|
||
add_test( | ||
NAME ${_test_name}_OpenMP | ||
COMMAND ${_cmd} | ||
WORKING_DIRECTORY ${_exe_dir} | ||
) | ||
|
||
set_tests_properties(${_test_name}_OpenMP PROPERTIES ENVIRONMENT OMP_NUM_THREADS=${_NTHREADS} ) | ||
endif () | ||
|
||
endfunction () | ||
|
||
|
||
# | ||
# Loop over subdirs and add to the build those containing CMakeLists.txt | ||
# | ||
foreach (_subdir IN LISTS AMREX_TESTS_SUBDIRS) | ||
|
||
file( GLOB_RECURSE _tests "${_subdir}/*CMakeLists.txt" ) | ||
|
||
foreach ( _item IN LISTS _tests) | ||
get_filename_component(_dir ${_item} DIRECTORY ) | ||
add_subdirectory(${_dir}) | ||
endforeach () | ||
|
||
endforeach () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
# | ||
# Disabled for NOW | ||
# | ||
return() | ||
|
||
|
||
if (NOT CMAKE_Fortran_COMPILER_LOADED) | ||
return() | ||
endif () | ||
|
||
set(_sources AMRProfTestBL.cpp tBA.cpp tDM.cpp tFillFab.cpp tParmParse.cpp TPROFILER_F.H tread.cpp tVisMF.cpp ) | ||
list(APPEND _sources AMRPROFTEST_F.H tCArena.cpp tFAC.cpp tMFcopy.cpp tProfiler.cpp tRABcast.cpp tUMap.cpp ) | ||
list(APPEND _sources fillfab.f t8BIT.cpp tDir.cpp tFB.cpp tMF.cpp TPROFILER.F tRan.cpp tVisMF2.cpp ) | ||
|
||
set(_input_files ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources DataServicesTest0.cpp) | ||
set(_input_files ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files ba.max) | ||
|
||
setup_test(_sources _input_files CMDLINE_PARAMS nrounds=1) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,8 @@ | ||
# | ||
# This test requires CUDA and Particles to be enabled | ||
# | ||
if (NOT ENABLE_CUDA OR NOT ENABLE_PARTICLES) | ||
return () | ||
endif () | ||
set(_sources CheckPair.H Constants.H main.cpp MDParticleContainer.cpp MDParticleContainer.H ) | ||
|
||
set( SRC_DIR ${CMAKE_CURRENT_LIST_DIR} ) | ||
set( EXENAME "gpu_nblist.exe" ) | ||
set(_input_files inputs ) | ||
|
||
add_executable( ${EXENAME} EXCLUDE_FROM_ALL "") | ||
setup_test(_sources _input_files NTASKS 2) | ||
|
||
target_sources( ${EXENAME} | ||
PRIVATE | ||
${SRC_DIR}/Constants.H | ||
${SRC_DIR}/MDParticleContainer.H | ||
${SRC_DIR}/MDParticleContainer.cpp | ||
${SRC_DIR}/CheckPair.H | ||
${SRC_DIR}/main.cpp) | ||
|
||
target_include_directories(${EXENAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ) | ||
set_source_files_properties(${SRC_DIR}/main.cpp ${SRC_DIR}/MDParticleContainer.cpp PROPERTIES LANGUAGE CUDA) | ||
|
||
# Since we are forcing the use of fortran compiler to link | ||
# we need to specify the flags to add at link phase since | ||
# it won't propagate amrex ones | ||
set_target_properties( ${EXENAME} | ||
PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
CUDA_SEPARABLE_COMPILATION ON # This add -dc flag | ||
) | ||
|
||
target_link_libraries(${EXENAME} amrex) | ||
|
||
file( COPY inputs DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) | ||
|
||
add_tutorial(${EXENAME}) | ||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files inputs ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files inputs ) | ||
|
||
setup_test(_sources _input_files NTHREADS 2) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files inputs ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files inputs.rt ) # There are others but we use only this one for now | ||
|
||
setup_test(_sources _input_files NTASKS 2) | ||
|
||
unset(_sources) | ||
unset(_input_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(_sources main.cpp) | ||
set(_input_files ) | ||
|
||
setup_test(_sources _input_files) | ||
|
||
unset(_sources) | ||
unset(_input_files) |