From ee84cccfd993e8781d7a61881645517945da67e1 Mon Sep 17 00:00:00 2001 From: Jacob Merson Date: Sun, 16 Nov 2025 11:34:15 -0800 Subject: [PATCH 1/5] add ENABLE varibles to make spdlog usage explicit --- CMakeLists.txt | 6 +++++- src/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 745536af..94ddc70c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,11 @@ option(PCMS_ENABLE_OMEGA_H "enable Omega_h field adapter" OFF) option(PCMS_ENABLE_C "Enable pcms C api" ON) option(PCMS_PRINT_ENABLED "PCMS print statements enabled" ON) -find_package(spdlog QUIET) +option(PCMS_ENABLE_SPDLOG "use spdlog for logging" ON) + +if(PCMS_ENABLE_SPDLOG) + find_package(spdlog REQUIRED) +endif() # find package before fortran enabled, so we don't require the adios2 fortran # interfaces this is important because adios2 build with clang/gfortran is diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b43a0e47..307be324 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,7 +86,7 @@ if(PCMS_PRINT_ENABLED) target_compile_definitions(pcms_core INTERFACE -DPCMS_PRINT_ENABLED) endif() -if(spdlog_FOUND) +if(PCMS_ENABLE_SPDLOG) add_definitions(-DPCMS_SPDLOG_ENABLED) target_compile_definitions(pcms_core INTERFACE -DPCMS_SPDLOG_ENABLED) target_link_libraries(pcms_core PUBLIC spdlog::spdlog) From 2db6d5e8c4174b9c1a402a28e42782546a5fcf75 Mon Sep 17 00:00:00 2001 From: Jacob Merson Date: Sun, 16 Nov 2025 11:40:19 -0800 Subject: [PATCH 2/5] update the minimum version of adios2 in cmake Errors were reported with older adios2 versions. closes #218 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94ddc70c..fb2e83e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ if(PCMS_ENABLE_OMEGA_H) endif() endif() # adios2 adds C and Fortran depending on how it was built -find_package(ADIOS2 CONFIG 2.5 REQUIRED) +find_package(ADIOS2 CONFIG 2.10.2 REQUIRED) find_package(Kokkos CONFIG 4.5 REQUIRED) find_package(meshfields REQUIRED) From b7e9029aef378393490d57e9f5759807c58d4367 Mon Sep 17 00:00:00 2001 From: Jacob Merson Date: Sun, 16 Nov 2025 11:47:30 -0800 Subject: [PATCH 3/5] make use of spdlog explicit in github action workflows --- .github/workflows/clang-tidy.yml | 3 ++- .github/workflows/cmake-test.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 77758a3d..3051a024 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -200,6 +200,7 @@ jobs: -DPETSC_DIR=${{ runner.temp }}/petsc-openmpi \ -DPETSC_ARCH=ubuntu-kokkos \ -DPCMS_TIMEOUT=10 \ + -DPCMS_ENABLE_SPDLOG=OFF \ -DCatch2_DIR=${{ runner.temp }}/build-Catch2-openmpi/install/lib/cmake/Catch2 \ -DOmega_h_DIR=${{ runner.temp }}/build-omega_h-openmpi/install/lib/cmake/Omega_h \ -Dmeshfields_DIR=${{ runner.temp }}/build-meshFields-openmpi/install/lib/cmake/meshfields \ @@ -235,4 +236,4 @@ jobs: echo "Some C/C++ files have clang-tidy issues. Please fix them with clang-tidy-18." exit 1 fi - echo "All C/C++ files pass clang-tidy checks" \ No newline at end of file + echo "All C/C++ files pass clang-tidy checks" diff --git a/.github/workflows/cmake-test.yml b/.github/workflows/cmake-test.yml index a0151aea..45dbe50c 100644 --- a/.github/workflows/cmake-test.yml +++ b/.github/workflows/cmake-test.yml @@ -201,6 +201,7 @@ jobs: -DPETSC_DIR=${{ runner.temp }}/petsc -DPETSC_ARCH=ubuntu-kokkos -DPCMS_TIMEOUT=10 + -DPCMS_ENABLE_SPDLOG=OFF -DCatch2_DIR=${{ runner.temp }}/build-Catch2/install/lib/cmake/Catch2 -DOmega_h_DIR=${{ runner.temp }}/build-omega_h/install/lib/cmake/Omega_h -Dmeshfields_DIR=${{ runner.temp }}/build-meshFields/install/lib/cmake/meshfields From fe8dcdac17e01fcc996e96a9fca153c3ea79671f Mon Sep 17 00:00:00 2001 From: Jacob Merson Date: Fri, 21 Nov 2025 15:10:05 -0800 Subject: [PATCH 4/5] use config file instead of target compile definitions This commit updates PCMS configuration options to use a configuration file. This should do a better job of ensuring that downstream applications are setting up the correct configuration options if they do not build with CMake. It also has the benefit of making it easier to identify what options PCMS was configured with without parsing the CMake package files. --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 14 +++----------- src/pcms.cpp | 2 +- src/pcms.h | 1 + src/pcms/adapter/xgc/xgc_reverse_classification.h | 5 +++-- src/pcms/capi/client.cpp | 8 +------- src/pcms/configuration.h.in | 8 ++++++++ src/pcms/print.h | 12 ++++++------ 8 files changed, 24 insertions(+), 28 deletions(-) create mode 100644 src/pcms/configuration.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index fb2e83e7..d9c519ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ option(PCMS_ENABLE_XGC "enable xgc field adapter" ON) option(PCMS_ENABLE_OMEGA_H "enable Omega_h field adapter" OFF) option(PCMS_ENABLE_C "Enable pcms C api" ON) -option(PCMS_PRINT_ENABLED "PCMS print statements enabled" ON) +option(PCMS_ENABLE_PRINT "PCMS print statements enabled" ON) option(PCMS_ENABLE_SPDLOG "use spdlog for logging" ON) if(PCMS_ENABLE_SPDLOG) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 307be324..6b97b18f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,6 +41,9 @@ set(PCMS_SOURCES pcms/adapter/xgc/xgc_field_adapter.h) configure_file(pcms/version.h.in pcms/version.h) +configure_file(pcms/configuration.h.in pcms/configuration.h) +list(APPEND PCMS_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/pcms/version.h ${CMAKE_CURRENT_BINARY_DIR}/pcms/configuration.h) + if(PCMS_ENABLE_XGC) list(APPEND PCMS_SOURCES pcms/adapter/xgc/xgc_reverse_classification.cpp) @@ -70,10 +73,6 @@ target_link_libraries(pcms_core PUBLIC meshfields::meshfields redev::redev MPI::MPI_CXX Kokkos::kokkos perfstubs) if(PCMS_ENABLE_OMEGA_H) target_link_libraries(pcms_core PUBLIC Omega_h::omega_h) - target_compile_definitions(pcms_core PUBLIC -DPCMS_HAS_OMEGA_H) -endif() -if(PCMS_ENABLE_SERVER) - target_compile_definitions(pcms_core PUBLIC -DPCMS_HAS_SERVER) endif() if(PCMS_HAS_ASAN) @@ -81,14 +80,7 @@ if(PCMS_HAS_ASAN) -fno-omit-frame-pointer) endif() -if(PCMS_PRINT_ENABLED) - add_definitions(-DPCMS_PRINT_ENABLED) - target_compile_definitions(pcms_core INTERFACE -DPCMS_PRINT_ENABLED) -endif() - if(PCMS_ENABLE_SPDLOG) - add_definitions(-DPCMS_SPDLOG_ENABLED) - target_compile_definitions(pcms_core INTERFACE -DPCMS_SPDLOG_ENABLED) target_link_libraries(pcms_core PUBLIC spdlog::spdlog) endif() diff --git a/src/pcms.cpp b/src/pcms.cpp index 3d33691b..664bd710 100644 --- a/src/pcms.cpp +++ b/src/pcms.cpp @@ -9,7 +9,7 @@ static_assert(std::is_same_v, "pcms and redev LO types must match"); static_assert(std::is_same_v, "pcms and redev GO types must match"); -#ifdef PCMS_HAS_OMEGA_H +#ifdef PCMS_ENABLE_OMEGA_H static_assert(std::is_same_v, "pcms and Omega_h real types must match"); static_assert(std::is_same_v, diff --git a/src/pcms.h b/src/pcms.h index b9ec6ad1..7b8591f4 100644 --- a/src/pcms.h +++ b/src/pcms.h @@ -1,6 +1,7 @@ #ifndef PCMS_H_ #define PCMS_H_ +#include "pcms/configuration.h" #include "pcms/common.h" #include "pcms/field_communicator.h" #include "pcms/adapter/omega_h/omega_h_field.h" diff --git a/src/pcms/adapter/xgc/xgc_reverse_classification.h b/src/pcms/adapter/xgc/xgc_reverse_classification.h index cc5bcb29..b163c707 100644 --- a/src/pcms/adapter/xgc/xgc_reverse_classification.h +++ b/src/pcms/adapter/xgc/xgc_reverse_classification.h @@ -8,8 +8,9 @@ #include "mdspan/mdspan.hpp" #include "pcms/arrays.h" #include "pcms/memory_spaces.h" +#include "pcms/configuration.h" // #include -#ifdef PCMS_HAS_OMEGA_H +#ifdef PCMS_ENABLE_OMEGA_H #include #include "pcms/assert.h" #endif @@ -86,7 +87,7 @@ ReverseClassificationVertex ReadReverseClassificationVertex(std::string, MPI_Comm, int root = 0); -#ifdef PCMS_HAS_OMEGA_H +#ifdef PCMS_ENABLE_OMEGA_H enum class IndexBase { Zero = 0, diff --git a/src/pcms/capi/client.cpp b/src/pcms/capi/client.cpp index a208fca4..2cc4ee96 100644 --- a/src/pcms/capi/client.cpp +++ b/src/pcms/capi/client.cpp @@ -13,13 +13,7 @@ namespace pcms using FieldAdapterVariant = std::variant, pcms::XGCFieldAdapter, pcms::XGCFieldAdapter, - pcms::XGCFieldAdapter, pcms::DummyFieldAdapter - // #ifdef PCMS_HAS_OMEGA_H - // , - // pcms::OmegaHFieldAdapter, - // pcms::OmegaHFieldAdapter - // #endif - >; + pcms::XGCFieldAdapter, pcms::DummyFieldAdapter>; } // namespace pcms diff --git a/src/pcms/configuration.h.in b/src/pcms/configuration.h.in new file mode 100644 index 00000000..f52825b6 --- /dev/null +++ b/src/pcms/configuration.h.in @@ -0,0 +1,8 @@ +#cmakedefine PCMS_ENABLE_SERVER +#cmakedefine PCMS_ENABLE_CLIENT +#cmakedefine PCMS_ENABLE_XGC +#cmakedefine PCMS_ENABLE_OMEGA_H +#cmakedefine PCMS_ENABLE_C +#cmakedefine PCMS_ENABLE_PRINT +#cmakedefine PCMS_ENABLE_SPDLOG +#cmakedefine PCMS_ENABLE_Fortran diff --git a/src/pcms/print.h b/src/pcms/print.h index 9354946b..d8290748 100644 --- a/src/pcms/print.h +++ b/src/pcms/print.h @@ -1,7 +1,7 @@ #ifndef PCMS_PRINT_H #define PCMS_PRINT_H -#ifdef PCMS_SPDLOG_ENABLED +#ifdef PCMS_ENABLE_SPDLOG #include "spdlog/spdlog.h" #include #endif @@ -25,9 +25,9 @@ void setStderr(FILE* err); template void printError(const char* fmt, const Args&... args) { -#if defined(PCMS_SPDLOG_ENABLED) && defined(PCMS_PRINT_ENABLED) +#if defined(PCMS_ENABLE_SPDLOG) && defined(PCMS_ENABLE_PRINT) spdlog::error("{}", fmt::sprintf(fmt, args...)); -#elif defined(PCMS_PRINT_ENABLED) +#elif defined(PCMS_ENABLE_PRINT) fprintf(getStdout(), fmt, args...); #endif } @@ -35,14 +35,14 @@ void printError(const char* fmt, const Args&... args) template KOKKOS_INLINE_FUNCTION void printInfo(const char* fmt, const Args&... args) { -#if defined(PCMS_SPDLOG_ENABLED) && defined(PCMS_PRINT_ENABLED) && \ +#if defined(PCMS_ENABLE_SPDLOG) && defined(PCMS_ENABLE_PRINT) && \ !defined(ACTIVE_GPU_EXECUTION) spdlog::info("{}", fmt::sprintf(fmt, args...)); -#elif defined(PCMS_PRINT_ENABLED) && !defined(ACTIVE_GPU_EXECUTION) +#elif defined(PCMS_ENABLE_PRINT) && !defined(ACTIVE_GPU_EXECUTION) fprintf(getStdout(), fmt, args...); #endif } } // namespace pcms -#endif // PCMS_PRINT_H \ No newline at end of file +#endif // PCMS_PRINT_H From 1b0addf25258111f20314b80957e7a001ffcbbaa Mon Sep 17 00:00:00 2001 From: Jacob Merson Date: Tue, 9 Dec 2025 16:35:08 -0500 Subject: [PATCH 5/5] format CMakeLists.txt --- src/CMakeLists.txt | 140 ++++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 59 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b97b18f..fb7024e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,44 +1,48 @@ # TODO split out the field transfer library -set(PCMS_HEADERS - pcms.h - pcms/arrays.h - pcms/assert.h - pcms/bounding_box.h - pcms/common.h - pcms/coordinate.h - pcms/coordinate_systems.h - pcms/coordinate_transform.h - pcms/field.h - pcms/create_field.h - pcms/field_communicator.h - pcms/field_communicator2.h - pcms/field_evaluation_methods.h - pcms/memory_spaces.h - pcms/types.h - pcms/array_mask.h - pcms/inclusive_scan.h - pcms/profile.h - pcms/print.h - pcms/partition.h - pcms/coupler.h - pcms/coordinate_system.h - pcms/field_layout.h - pcms/adapter/point_cloud/point_cloud_layout.h - pcms/adapter/point_cloud/point_cloud.h - pcms/adapter/omega_h/omega_h_field_layout.h - pcms/adapter/omega_h/omega_h_field2.h) +set( + PCMS_HEADERS + pcms.h + pcms/arrays.h + pcms/assert.h + pcms/bounding_box.h + pcms/common.h + pcms/coordinate.h + pcms/coordinate_systems.h + pcms/coordinate_transform.h + pcms/field.h + pcms/create_field.h + pcms/field_communicator.h + pcms/field_communicator2.h + pcms/field_evaluation_methods.h + pcms/memory_spaces.h + pcms/types.h + pcms/array_mask.h + pcms/inclusive_scan.h + pcms/profile.h + pcms/print.h + pcms/partition.h + pcms/coupler.h + pcms/coordinate_system.h + pcms/field_layout.h + pcms/adapter/point_cloud/point_cloud_layout.h + pcms/adapter/point_cloud/point_cloud.h + pcms/adapter/omega_h/omega_h_field_layout.h + pcms/adapter/omega_h/omega_h_field2.h +) -set(PCMS_SOURCES - pcms.cpp - pcms/assert.cpp - pcms/print.cpp - pcms/create_field.cpp - pcms/adapter/xgc/xgc_field_adapter.h - pcms/adapter/point_cloud/point_cloud_layout.cpp - pcms/adapter/point_cloud/point_cloud.cpp - pcms/adapter/omega_h/omega_h_field_layout.cpp - pcms/adapter/omega_h/omega_h_field2.cpp - pcms/adapter/xgc/xgc_field_adapter.h) +set( + PCMS_SOURCES + pcms.cpp + pcms/assert.cpp + pcms/print.cpp + pcms/create_field.cpp + pcms/adapter/xgc/xgc_field_adapter.h + pcms/adapter/point_cloud/point_cloud_layout.cpp + pcms/adapter/point_cloud/point_cloud.cpp + pcms/adapter/omega_h/omega_h_field_layout.cpp + pcms/adapter/omega_h/omega_h_field2.cpp + pcms/adapter/xgc/xgc_field_adapter.h +) configure_file(pcms/version.h.in pcms/version.h) configure_file(pcms/configuration.h.in pcms/configuration.h) @@ -58,26 +62,33 @@ if(PCMS_ENABLE_OMEGA_H) pcms/transfer_field.h pcms/transfer_field2.h pcms/uniform_grid.h - pcms/point_search.h) + pcms/point_search.h + ) endif() find_package(Kokkos REQUIRED) find_package(perfstubs REQUIRED) add_library(pcms_core ${PCMS_SOURCES}) -set_target_properties(pcms_core PROPERTIES OUTPUT_NAME pcmscore EXPORT_NAME - core) +set_target_properties( + pcms_core PROPERTIES OUTPUT_NAME pcmscore EXPORT_NAME + core +) add_library(pcms::core ALIAS pcms_core) target_compile_features(pcms_core PUBLIC cxx_std_17) -target_link_libraries(pcms_core PUBLIC meshfields::meshfields redev::redev - MPI::MPI_CXX Kokkos::kokkos perfstubs) +target_link_libraries( + pcms_core PUBLIC meshfields::meshfields redev::redev + MPI::MPI_CXX Kokkos::kokkos perfstubs +) if(PCMS_ENABLE_OMEGA_H) target_link_libraries(pcms_core PUBLIC Omega_h::omega_h) endif() if(PCMS_HAS_ASAN) - target_compile_options(pcms_core PRIVATE -fsanitize=address - -fno-omit-frame-pointer) + target_compile_options( + pcms_core PRIVATE -fsanitize=address + -fno-omit-frame-pointer + ) endif() if(PCMS_ENABLE_SPDLOG) @@ -89,8 +100,9 @@ set_target_properties(pcms_core PROPERTIES PUBLIC_HEADER "${PCMS_HEADERS}") target_include_directories( pcms_core PUBLIC "$" - "$" - "$") + "$" + "$" +) install( TARGETS pcms_core EXPORT pcms_core-targets @@ -99,23 +111,29 @@ install( RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms) + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms +) configure_package_config_file( "${CMAKE_SOURCE_DIR}/config.cmake.in" "${CMAKE_BINARY_DIR}/pcms-config.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms) + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms +) write_basic_package_version_file( "${PROJECT_BINARY_DIR}/pcms-config-version.cmake" - COMPATIBILITY AnyNewerVersion) + COMPATIBILITY AnyNewerVersion +) -install(FILES "${PROJECT_BINARY_DIR}/pcms-config.cmake" - "${PROJECT_BINARY_DIR}/pcms-config-version.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms) +install( + FILES "${PROJECT_BINARY_DIR}/pcms-config.cmake" + "${PROJECT_BINARY_DIR}/pcms-config-version.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms +) install( EXPORT pcms_core-targets NAMESPACE pcms:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms +) add_library(pcms_pcms INTERFACE) target_link_libraries(pcms_pcms INTERFACE pcms::core) @@ -139,11 +157,15 @@ install( RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms) + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms +) # install external headers -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcms/external/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms/external) +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcms/external/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcms/external +) install( EXPORT pcms-targets NAMESPACE pcms:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcms +)