Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: AMReX_TEST_TYPE #3357

Merged
merged 3 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ 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_FORTRAN=OFF \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_TEST_TYPE=Small \
-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()

Loading