From 616b601672555d060074f71fb66d66f9e2493c08 Mon Sep 17 00:00:00 2001 From: Pratik Nayak Date: Fri, 15 Nov 2024 22:22:52 +0100 Subject: [PATCH 1/3] Enable file-config conditionally + It depends on nlohmann-json --- examples/CMakeLists.txt | 44 +++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 90c1f8e2632..1da769fdf3f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,7 +20,6 @@ set(EXAMPLES_EXEC_LIST set(EXAMPLES_LIST ${EXAMPLES_EXEC_LIST} custom-stopping-criterion - file-config-solver ginkgo-overhead minimal-cuda-solver mixed-spmv @@ -64,6 +63,15 @@ else() message(STATUS "No Kokkos found, disabling examples with Kokkos assembly.") endif() +set(GKO_FILE_CONFIG_ENABLED 0) +find_package(nlohmann_json 3.9.1 QUIET) +if(nlohmann_json_FOUND) + set(GKO_FILE_CONFIG_ENABLED 1) + list(APPEND EXAMPLES_LIST file-config-solver) +else() + message(STATUS "No nlohmann-json found, disabling file-config example") +endif() + foreach(example ${EXAMPLES_LIST}) add_subdirectory(${example}) endforeach() @@ -106,20 +114,22 @@ if(GINKGO_BUILD_TESTS) endforeach() endforeach() - file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file-config-solver/config/*.json) - foreach(config IN LISTS config_list) - get_filename_component(config_name "${config}" NAME_WE) - foreach(executor IN LISTS executors) - add_test(NAME example_file-config-solver_${config_name}_${executor} - COMMAND - "$" - "${executor}" "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/config/${config_name}.json" - "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/data/A.mtx" - WORKING_DIRECTORY - "$") - # Prevent performance issues with high core counts - set_property(TEST example_file-config-solver_${config_name}_${executor} PROPERTY ENVIRONMENT OMP_NUM_THREADS=4) - endforeach() - endforeach() - + if(GKO_FILE_CONFIG_ENABLED) + file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file-config-solver/config/*.json) + foreach(config IN LISTS config_list) + get_filename_component(config_name "${config}" NAME_WE) + foreach(executor IN LISTS executors) + add_test(NAME example_file-config-solver_${config_name}_${executor} + COMMAND + "$" + "${executor}" "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/config/${config_name}.json" + "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/data/A.mtx" + WORKING_DIRECTORY + "$") + # Prevent performance issues with high core counts + set_property(TEST example_file-config-solver_${config_name}_${executor} PROPERTY ENVIRONMENT OMP_NUM_THREADS=4) + endforeach() + endforeach() + endif() + endif() From 600417bc848dbe35d14874b07d732d7d492bc9b5 Mon Sep 17 00:00:00 2001 From: Pratik Nayak Date: Fri, 22 Nov 2024 15:12:51 +0100 Subject: [PATCH 2/3] move find_package to root CMakeLists.txt --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d13a5c0f3..b789c634d93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,7 +246,7 @@ endif() if(GINKGO_BUILD_BENCHMARKS) find_package(gflags 2.2.2 QUIET) endif() -if(GINKGO_BUILD_TESTS OR GINKGO_BUILD_BENCHMARKS) +if(GINKGO_BUILD_TESTS OR GINKGO_BUILD_BENCHMARKS OR GINKGO_BUILD_EXAMPLES) find_package(nlohmann_json 3.9.1 QUIET) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1da769fdf3f..d08f88a40cb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -64,7 +64,6 @@ else() endif() set(GKO_FILE_CONFIG_ENABLED 0) -find_package(nlohmann_json 3.9.1 QUIET) if(nlohmann_json_FOUND) set(GKO_FILE_CONFIG_ENABLED 1) list(APPEND EXAMPLES_LIST file-config-solver) From 5a8b5907abadcdc48859558ed601b52ff3417319 Mon Sep 17 00:00:00 2001 From: Pratik Nayak Date: Fri, 22 Nov 2024 15:27:32 +0100 Subject: [PATCH 3/3] always pull in json support with examples enabled --- examples/CMakeLists.txt | 40 ++++++++++++++------------------------ third_party/CMakeLists.txt | 2 +- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d08f88a40cb..5d8b9d9aa22 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,6 +20,7 @@ set(EXAMPLES_EXEC_LIST set(EXAMPLES_LIST ${EXAMPLES_EXEC_LIST} custom-stopping-criterion + file-config-solver ginkgo-overhead minimal-cuda-solver mixed-spmv @@ -63,14 +64,6 @@ else() message(STATUS "No Kokkos found, disabling examples with Kokkos assembly.") endif() -set(GKO_FILE_CONFIG_ENABLED 0) -if(nlohmann_json_FOUND) - set(GKO_FILE_CONFIG_ENABLED 1) - list(APPEND EXAMPLES_LIST file-config-solver) -else() - message(STATUS "No nlohmann-json found, disabling file-config example") -endif() - foreach(example ${EXAMPLES_LIST}) add_subdirectory(${example}) endforeach() @@ -113,22 +106,19 @@ if(GINKGO_BUILD_TESTS) endforeach() endforeach() - if(GKO_FILE_CONFIG_ENABLED) - file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file-config-solver/config/*.json) - foreach(config IN LISTS config_list) - get_filename_component(config_name "${config}" NAME_WE) - foreach(executor IN LISTS executors) - add_test(NAME example_file-config-solver_${config_name}_${executor} - COMMAND - "$" - "${executor}" "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/config/${config_name}.json" - "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/data/A.mtx" - WORKING_DIRECTORY - "$") - # Prevent performance issues with high core counts - set_property(TEST example_file-config-solver_${config_name}_${executor} PROPERTY ENVIRONMENT OMP_NUM_THREADS=4) - endforeach() + file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file-config-solver/config/*.json) + foreach(config IN LISTS config_list) + get_filename_component(config_name "${config}" NAME_WE) + foreach(executor IN LISTS executors) + add_test(NAME example_file-config-solver_${config_name}_${executor} + COMMAND + "$" + "${executor}" "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/config/${config_name}.json" + "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/data/A.mtx" + WORKING_DIRECTORY + "$") + # Prevent performance issues with high core counts + set_property(TEST example_file-config-solver_${config_name}_${executor} PROPERTY ENVIRONMENT OMP_NUM_THREADS=4) endforeach() - endif() - + endforeach() endif() diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index cfba7759170..1977d8e7f68 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -13,7 +13,7 @@ if(GINKGO_BUILD_BENCHMARKS) endif() endif() -if(GINKGO_BUILD_TESTS OR GINKGO_BUILD_BENCHMARKS) +if(GINKGO_BUILD_TESTS OR GINKGO_BUILD_BENCHMARKS OR GINKGO_BUILD_EXAMPLES) if (NOT nlohmann_json_FOUND) add_subdirectory(nlohmann_json) endif()