Skip to content

Commit

Permalink
CMake: AMReX_TEST_TYPE
Browse files Browse the repository at this point in the history
Add a new option, AMReX_TEST_TYPE=[All|Small]. Be default, all tests are
built when AMReX_ENABLE_TEST is on. When the type is small, only four tests
are enabled. If a CI job takes too long to compile and run all the tests, we
could switch to the small test type.

Re-enable tests and change the test type to Small for the nvhpc CI. We had
to disable it due to space limit in. It should no longer be a problem for
the small set of tests.
  • Loading branch information
WeiqunZhang committed Jun 7, 2023
1 parent 1f3afaa commit fc0c293
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ jobs:
nvfortran --version
cmake --version
# Disable Fortran and Tests due to space limit
cmake -S . -B build \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DAMReX_ENABLE_TESTS=OFF \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_ENABLE_TYPE=Small \
-DAMReX_PARTICLES=ON \
-DAMReX_FORTRAN=OFF \
-DAMReX_FORTRAN=ON \
-DAMReX_GPU_BACKEND=CUDA \
-DCMAKE_C_COMPILER=$(which nvc) \
-DCMAKE_CXX_COMPILER=$(which nvc++) \
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ endif()
#
# Enable CTests
#
option(AMReX_ENABLE_TESTS "Enable CTest suite for AMReX" NO)
if (AMReX_ENABLE_TESTS)
enable_testing()
add_subdirectory(Tests)
Expand Down
2 changes: 2 additions & 0 deletions Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ The list of available options is reported in the :ref:`table <tab:cmakevar>` bel
+------------------------------+-------------------------------------------------+-------------------------+-----------------------+
| AMReX_ENABLE_TESTS | Enable CTest suite | NO | YES, NO |
+------------------------------+-------------------------------------------------+-------------------------+-----------------------+
| AMReX_TEST_TYPE | Test type -- affects the number of tests | All | All, Small |
+------------------------------+-------------------------------------------------+-------------------------+-----------------------+
| AMReX_DIFFERENT_COMPILER | Allow an app to use a different compiler | NO | YES, NO |
+------------------------------+-------------------------------------------------+-------------------------+-----------------------+
| AMReX_INSTALL | Generate Install Targets | YES | YES, NO |
Expand Down
99 changes: 58 additions & 41 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
#
# List of subdirectories to search for CMakeLists.
#
set( AMREX_TESTS_SUBDIRS AsyncOut MultiBlock Reinit Amr CLZ Parser Parser2 CTOParFor RoundoffDomain)

if (AMReX_PARTICLES)
list(APPEND AMREX_TESTS_SUBDIRS Particles)
endif ()

if (AMReX_EB)
list(APPEND AMREX_TESTS_SUBDIRS EB)
endif ()

if (AMReX_LINEAR_SOLVERS)
list(APPEND AMREX_TESTS_SUBDIRS LinearSolvers)
endif ()

if (AMReX_HDF5)
list(APPEND AMREX_TESTS_SUBDIRS HDF5Benchmark)
endif ()

if (AMReX_FORTRAN_INTERFACES)
list(APPEND AMREX_TESTS_SUBDIRS FortranInterface)
endif ()

if (AMReX_CUDA)
list(APPEND AMREX_TESTS_SUBDIRS GPU)
endif ()

list(TRANSFORM AMREX_TESTS_SUBDIRS PREPEND "${CMAKE_CURRENT_LIST_DIR}/")

#
# Function to setup the tutorials
#
Expand Down Expand Up @@ -128,17 +97,65 @@ function (setup_test _dim _srcs _inputs)

endfunction ()

if (AMReX_TEST_TYPE STREQUAL "Small")

#
# Loop over subdirs and add to the build those containing CMakeLists.txt
#
foreach (_subdir IN LISTS AMREX_TESTS_SUBDIRS)
add_subdirectory("Amr/Advection_AmrCore")

file( GLOB_RECURSE _tests "${_subdir}/*CMakeLists.txt" )
if (AMReX_PARTICLES)
add_subdirectory("Particles/Redistribute")
endif ()

foreach ( _item IN LISTS _tests)
get_filename_component(_dir ${_item} DIRECTORY )
add_subdirectory(${_dir})
endforeach ()
if (AMReX_EB)
add_subdirectory("EB/CNS")
endif()

if (AMReX_LINEAR_SOLVERS)
add_subdirectory("LinearSolvers/ABecLaplacian_C")
endif()

else()
#
# List of subdirectories to search for CMakeLists.
#
set( AMREX_TESTS_SUBDIRS AsyncOut MultiBlock Reinit Amr CLZ Parser Parser2 CTOParFor RoundoffDomain)

endforeach ()
if (AMReX_PARTICLES)
list(APPEND AMREX_TESTS_SUBDIRS Particles)
endif ()

if (AMReX_EB)
list(APPEND AMREX_TESTS_SUBDIRS EB)
endif ()

if (AMReX_LINEAR_SOLVERS)
list(APPEND AMREX_TESTS_SUBDIRS LinearSolvers)
endif ()

if (AMReX_HDF5)
list(APPEND AMREX_TESTS_SUBDIRS HDF5Benchmark)
endif ()

if (AMReX_FORTRAN_INTERFACES)
list(APPEND AMREX_TESTS_SUBDIRS FortranInterface)
endif ()

if (AMReX_CUDA)
list(APPEND AMREX_TESTS_SUBDIRS GPU)
endif ()

list(TRANSFORM AMREX_TESTS_SUBDIRS PREPEND "${CMAKE_CURRENT_LIST_DIR}/")

#
# 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 ()
endif()
17 changes: 17 additions & 0 deletions Tools/CMake/AMReXOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,20 @@ print_option(AMReX_CLANG_TIDY)
cmake_dependent_option(AMReX_CLANG_TIDY_WERROR "Treat clang-tidy warnings as errors" OFF
"AMReX_CLANG_TIDY" OFF)
print_option(AMReX_CLANG_TIDY_WERROR)

#
# Tests =============================================================
#
option(AMReX_ENABLE_TESTS "Enable CTest suite for AMReX" NO)
print_option(AMReX_ENABLE_TESTS)
set(AMReX_TEST_TYPE_VALUES "All;Small")
set(AMReX_TEST_TYPE All CACHE STRING "Type of AMReX Tests: <All,Small>")
set_property(CACHE AMReX_TEST_TYPE PROPERTY STRINGS ${AMReX_TEST_TYPE_VALUES})
if (NOT AMReX_TEST_TYPE IN_LIST AMReX_TEST_TYPE_VALUES)
message(FATAL_ERROR "AMReX_TEST_TYPE=${AMReX_TEST_TYPE} is not allowed."
" Must be one of ${AMReX_TEST_TYPE_VALUES}.")
endif()
if (AMReX_ENABLE_TESTS)
message(STATUS " AMReX_TEST_TYPE = ${AMReX_TEST_TYPE}")
endif()

0 comments on commit fc0c293

Please sign in to comment.