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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 745536af..d9c519ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,12 @@ 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) -find_package(spdlog QUIET) +option(PCMS_ENABLE_PRINT "PCMS print statements enabled" ON) +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 @@ -58,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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b43a0e47..fb7024e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,46 +1,53 @@ # 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) +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) @@ -55,40 +62,36 @@ 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) - 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) - target_compile_options(pcms_core PRIVATE -fsanitize=address - -fno-omit-frame-pointer) -endif() - -if(PCMS_PRINT_ENABLED) - add_definitions(-DPCMS_PRINT_ENABLED) - target_compile_definitions(pcms_core INTERFACE -DPCMS_PRINT_ENABLED) + target_compile_options( + pcms_core PRIVATE -fsanitize=address + -fno-omit-frame-pointer + ) endif() -if(spdlog_FOUND) - add_definitions(-DPCMS_SPDLOG_ENABLED) - target_compile_definitions(pcms_core INTERFACE -DPCMS_SPDLOG_ENABLED) +if(PCMS_ENABLE_SPDLOG) target_link_libraries(pcms_core PUBLIC spdlog::spdlog) endif() @@ -97,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 @@ -107,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) @@ -147,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 +) 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