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

Add a macro to wrap add_executable #651

Merged
merged 7 commits into from
Jan 23, 2025
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
2 changes: 1 addition & 1 deletion benchmarks/advection_reaction_3D/kokkos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(BUILD_ARKODE
set(benchmark_target "advection_reaction_3D_kokkos.${backend}")

# benchmark source files
add_executable(
sundials_add_executable(
${benchmark_target}
advection_reaction_3D.cpp
arkode_driver.cpp
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/advection_reaction_3D/raja/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(BUILD_ARKODE
# MPI only
# ----------------------------------------------------------------------------

add_executable(
sundials_add_executable(
advection_reaction_3D_raja
advection_reaction_3D.cpp
arkode_driver.cpp
Expand Down Expand Up @@ -94,7 +94,7 @@ if(BUILD_ARKODE
set_source_files_properties(cvode_driver.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(ida_driver.cpp PROPERTIES LANGUAGE CUDA)

add_executable(
sundials_add_executable(
advection_reaction_3D_raja_mpicuda
advection_reaction_3D.cpp
arkode_driver.cpp
Expand Down Expand Up @@ -149,7 +149,7 @@ if(BUILD_ARKODE

if(BUILD_NVECTOR_HIP)

add_executable(
sundials_add_executable(
advection_reaction_3D_raja_mpihip
advection_reaction_3D.cpp
advection_reaction_3D.hpp
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/diffusion_2D/mpi_gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ foreach(test_tuple ${tests})

endif()

add_executable(${target} ${sources})
sundials_add_executable(${target} ${sources})

# if("${backend}" STREQUAL "USE_CUDA") sundials_add_benchmark(${target}
# ${target} diffusion_2D ENABLE_GPU NUM_CORES ${SUNDIALS_BENCHMARK_NUM_GPUS} )
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/diffusion_2D/mpi_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ foreach(test_tuple ${tests})
set(target ${package}_diffusion_2D_mpi)

# create executable
add_executable(${target} ${sources})
sundials_add_executable(${target} ${sources})

add_dependencies(benchmark ${target})

Expand Down
7 changes: 3 additions & 4 deletions benchmarks/nvector/openmpdev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")

add_executable(
test_nvector_performance_openmpdev
test_nvector_performance_openmpdev.c ../test_nvector_performance.c
../../../src/sundials/sundials_nvector.c)
sundials_add_executable(
test_nvector_performance_openmpdev test_nvector_performance_openmpdev.c
../test_nvector_performance.c ../../../src/sundials/sundials_nvector.c)

# folder to organize targets in an IDE
set_target_properties(test_nvector_performance_openmp PROPERTIES FOLDER
Expand Down
32 changes: 13 additions & 19 deletions cmake/macros/SundialsAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,25 @@
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ---------------------------------------------------------------
# CMake macro for adding executables.
# CMake function that wraps the add_executable command.
#
# It adds one extra single-value argument, SCALAR_TYPE. Otherwise
# this function behaves exactly as add_executable does.
#
# ---------------------------------------------------------------

macro(sundials_add_nvector_benchmark NAME)
function(sundials_add_executable NAME)

set(options)
set(singleValueArgs)
set(multiValueArgs SOURCES SUNDIALS_TARGETS LINK_LIBRARIES INSTALL_SUBDIR)
set(singleValueArgs SCALAR_TYPE)
set(multiValueArgs)

cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
"${multiValueArgs}" ${ARGN})

set(BENCHMARKS_DIR ${PROJECT_SOURCE_DIR}/benchmarks)

add_executable(${NAME} ${BENCHMARKS_DIR}/nvector/test_nvector_performance.c
${arg_SOURCES})

set_target_properties(${NAME} PROPERTIES FOLDER "Benchmarks")

target_include_directories(${NAME} PRIVATE ${BENCHMARKS_DIR}/nvector)

target_link_libraries(${NAME} PRIVATE ${arg_SUNDIALS_TARGETS}
${arg_LINK_LIBRARIES} -lm)

install(TARGETS ${NAME}
DESTINATION "${BENCHMARKS_INSTALL_PATH}/${arg_INSTALL_SUBDIR}")
string(TOUPPER "${arg_SCALAR_TYPE}" _scalarUpper)
if(NOT _scalarUpper OR _scalarUpper STREQUAL SUNDIALS_SCALAR_TYPE)
add_executable(${NAME} ${arg_UNPARSED_ARGUMENTS})
endif()

endmacro(sundials_add_nvector_benchmark)
endfunction()
41 changes: 41 additions & 0 deletions cmake/macros/SundialsAddNvectorBenchmark.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ---------------------------------------------------------------
# Programmer(s): Cody J. Balos @ LLNL
# ---------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2025, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ---------------------------------------------------------------
# CMake macro for adding nvector benchmark executables.
# ---------------------------------------------------------------

function(sundials_add_nvector_benchmark NAME)

set(options)
set(singleValueArgs)
set(multiValueArgs SOURCES SUNDIALS_TARGETS LINK_LIBRARIES INSTALL_SUBDIR)

cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
balos1 marked this conversation as resolved.
Show resolved Hide resolved
"${multiValueArgs}" ${ARGN})

set(BENCHMARKS_DIR ${PROJECT_SOURCE_DIR}/benchmarks)

add_executable(${NAME} ${BENCHMARKS_DIR}/nvector/test_nvector_performance.c
${arg_SOURCES})

set_target_properties(${NAME} PROPERTIES FOLDER "Benchmarks")

target_include_directories(${NAME} PRIVATE ${BENCHMARKS_DIR}/nvector)

target_link_libraries(${NAME} PRIVATE ${arg_SUNDIALS_TARGETS}
${arg_LINK_LIBRARIES} -lm)

install(TARGETS ${NAME}
DESTINATION "${BENCHMARKS_INSTALL_PATH}/${arg_INSTALL_SUBDIR}")

endfunction(sundials_add_nvector_benchmark)
1 change: 1 addition & 0 deletions cmake/macros/SundialsCMakeMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ include(SundialsInstallExamples)
include(SundialsInstallExamplesGinkgo)
include(SundialsOption)
include(SundialsAddBenchmark)
include(SundialsAddNvectorBenchmark)
2 changes: 1 addition & 1 deletion examples/arkode/CXX_manyvector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ foreach(example_tuple ${ARKODE_examples})

# add example executable
if(NOT TARGET ${example_target})
add_executable(${example_target} ${example})
sundials_add_executable(${example_target} ${example})

set_target_properties(${example_target} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ macro(build_examples examples_to_build lang)
set_source_files_properties(${example} PROPERTIES LANGUAGE ${lang})

# example source files
add_executable(${example_target} ${example})
sundials_add_executable(${example_target} ${example})

# folder to organize targets in an IDE
set_target_properties(${example_target} PROPERTIES FOLDER "Examples")
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_parhyp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ foreach(example_tuple ${ARKODE_examples})
# source files once for testing with different inputs
if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.cpp)
sundials_add_executable(${example} ${example}.cpp)

# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ foreach(example_tuple ${ARKODE_examples})

# add example executable
if(NOT TARGET ${example_target})
add_executable(${example_target} ${example})
sundials_add_executable(${example_target} ${example})

set_target_properties(${example_target} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_superludist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ foreach(example_tuple ${ARKODE_examples})
get_filename_component(example_target ${example} NAME_WE)

# example source files
add_executable(${example_target} ${example})
sundials_add_executable(${example_target} ${example})

set_target_properties(${example_target} PROPERTIES FOLDER "Examples")

Expand Down
4 changes: 2 additions & 2 deletions examples/arkode/CXX_xbraid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ foreach(example_tuple ${ARKODE_examples})
if(NOT TARGET ${example})

# example source files
add_executable(${example} ${example}.cpp)
sundials_add_executable(${example} ${example}.cpp)

# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down Expand Up @@ -109,7 +109,7 @@ if(ENABLE_HYPRE AND HYPRE_FOUND)
if(NOT TARGET ${example})

# example source files
add_executable(${example} ${example}.cpp)
sundials_add_executable(${example} ${example}.cpp)

# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_manyvector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ foreach(example_tuple ${ARKODE_examples})
list(GET example_tuple 1 example_type)

# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ foreach(example_tuple ${ARKODE_examples})
list(GET example_tuple 4 example_int_precision)

# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_openmpdev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ foreach(example_tuple ${ARKODE_examples})
list(GET example_tuple 2 example_type)

# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ foreach(example_tuple ${ARKODE_examples})

if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

# libraries to link against
target_link_libraries(${example} ${SUNDIALS_LIBS})
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_parhyp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ foreach(example_tuple ${ARKODE_examples})
get_filename_component(example_target ${example} NAME_WE)

# create target
add_executable(${example_target} ${example})
sundials_add_executable(${example_target} ${example})

set_target_properties(${example_target} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_petsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ foreach(example_tuple ${ARKODE_examples})
list(GET example_tuple 3 example_type)

# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
6 changes: 3 additions & 3 deletions examples/arkode/C_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ foreach(example_tuple ${ARKODE_examples})

if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

# folder for IDEs
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down Expand Up @@ -173,7 +173,7 @@ if(BUILD_SUNLINSOL_KLU)
list(GET example_tuple 1 example_type)

# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down Expand Up @@ -208,7 +208,7 @@ if(BUILD_SUNLINSOL_SUPERLUMT)
list(GET example_tuple 1 example_type)

# example source files
add_executable(${example} ${example}.c)
sundials_add_executable(${example} ${example}.c)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
4 changes: 2 additions & 2 deletions examples/arkode/F2003_custom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ foreach(example_tuple ${FARKODE_examples})
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# example source files
add_executable(${example} ${example}.f90 ${FARKODEsources})
sundials_add_executable(${example} ${example}.f90 ${FARKODEsources})

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down Expand Up @@ -87,7 +87,7 @@ foreach(example_tuple ${FARKODE_tests})
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# example source files
add_executable(${example} ${example}.f90 ${FARKODEsources})
sundials_add_executable(${example} ${example}.f90 ${FARKODEsources})

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/F2003_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ foreach(example_tuple ${FARKODE_examples})
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# example source files
add_executable(${example} ${example}.f90)
sundials_add_executable(${example} ${example}.f90)

# libraries to link against
target_link_libraries(${example} MPI::MPI_Fortran ${SUNDIALS_LIBS})
Expand Down
8 changes: 4 additions & 4 deletions examples/arkode/F2003_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ foreach(example_tuple ${FARKODE_examples})
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# example source files
add_executable(${example} ${example}.f90)
sundials_add_executable(${example} ${example}.f90)

# folder for IDEs
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down Expand Up @@ -122,7 +122,7 @@ if(BUILD_SUNLINSOL_KLU)
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# create the cmake executable target
add_executable(${example} ${example}.f90)
sundials_add_executable(${example} ${example}.f90)
set_target_properties(${example} PROPERTIES FOLDER "Examples")

# add example to regression tests
Expand Down Expand Up @@ -163,7 +163,7 @@ if(BUILD_SUNLINSOL_LAPACKDENSE)
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# example source files
add_executable(${example} ${example}.f90)
sundials_add_executable(${example} ${example}.f90)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down Expand Up @@ -199,7 +199,7 @@ foreach(example_tuple ${FARKODE_tests})
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir)

# example source files
add_executable(${example} ${example}.f90)
sundials_add_executable(${example} ${example}.f90)

set_target_properties(${example} PROPERTIES FOLDER "Examples")

Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_onemkl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ foreach(example_tuple ${CVODE_examples})
if(NOT TARGET ${example_target})

# example source files
add_executable(${example_target} ${example})
sundials_add_executable(${example_target} ${example})

# folder for IDEs
set_target_properties(${example_target} PROPERTIES FOLDER "Examples")
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ foreach(example_tuple ${CVODE_examples})
# source files once for testing with different inputs
if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.cpp)
sundials_add_executable(${example} ${example}.cpp)

# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_parhyp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ foreach(example_tuple ${CVODE_examples})
# source files once for testing with different inputs
if(NOT TARGET ${example})
# example source files
add_executable(${example} ${example}.cpp)
sundials_add_executable(${example} ${example}.cpp)

# folder to organize targets in an IDE
set_target_properties(${example} PROPERTIES FOLDER "Examples")
Expand Down
Loading
Loading