Skip to content

Commit

Permalink
Remove 3 out of 4 compile definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Oct 31, 2024
1 parent 7b26395 commit f14218d
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ target_compile_features(DDC INTERFACE cxx_std_17)
target_include_directories(
DDC
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(DDC INTERFACE Kokkos::kokkos)
target_compile_definitions(DDC INTERFACE MDSPAN_USE_PAREN_OPERATOR=1)
if("${DDC_BUILD_DOUBLE_PRECISION}")
target_compile_definitions(DDC INTERFACE DDC_BUILD_DOUBLE_PRECISION)
endif()
add_library(DDC::DDC ALIAS DDC)
install(TARGETS DDC EXPORT DDCTargets)
configure_file(cmake/config.hpp.in generated/ddc/config.hpp NO_SOURCE_PERMISSIONS @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/ddc/config.hpp DESTINATION include/ddc)

# Link library to DDC

Expand Down Expand Up @@ -166,7 +166,6 @@ if("${DDC_BUILD_KERNELS_FFT}")
endif()

target_link_libraries(DDC INTERFACE KokkosFFT::fft)
target_compile_definitions(DDC INTERFACE "DDC_BUILD_KERNELS_FFT")
endif()

if("${DDC_BUILD_KERNELS_SPLINES}")
Expand Down Expand Up @@ -204,7 +203,6 @@ if("${DDC_BUILD_KERNELS_SPLINES}")
endif()

target_link_libraries(DDC INTERFACE Kokkos::kokkoskernels)
target_compile_definitions(DDC INTERFACE "DDC_BUILD_KERNELS_SPLINES")
endif()

## The PDI wrapper
Expand All @@ -219,7 +217,6 @@ if("${DDC_BUILD_PDI_WRAPPER}")
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(PDI_Wrapper INTERFACE DDC::DDC PDI::PDI_C)
target_compile_definitions(PDI_Wrapper INTERFACE "DDC_BUILD_PDI_WRAPPER")
add_library(DDC::PDI_Wrapper ALIAS PDI_Wrapper)
install(TARGETS PDI_Wrapper EXPORT DDCTargets)
endif()
Expand Down
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ target_link_libraries(non_uniform_heat_equation PUBLIC DDC::DDC)
target_link_libraries(uniform_heat_equation PUBLIC DDC::DDC)

if("${DDC_BUILD_PDI_WRAPPER}")
target_include_directories(heat_equation PUBLIC "DDC_EXAMPLE_WITH_PDI")
target_include_directories(uniform_heat_equation PUBLIC "DDC_EXAMPLE_WITH_PDI")
target_include_directories(non_uniform_heat_equation PUBLIC "DDC_EXAMPLE_WITH_PDI")
target_link_libraries(heat_equation PUBLIC DDC::PDI_Wrapper)
target_link_libraries(uniform_heat_equation PUBLIC DDC::PDI_Wrapper)
target_link_libraries(non_uniform_heat_equation PUBLIC DDC::PDI_Wrapper)
Expand Down
4 changes: 3 additions & 1 deletion examples/heat_equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <ddc/ddc.hpp>

#include <Kokkos_Core.hpp>
#ifdef DDC_BUILD_PDI_WRAPPER
#ifdef DDC_EXAMPLE_WITH_PDI
#include <ddc/pdi.hpp>

#include <paraconf.h>
#include <pdi.h>
#endif
Expand Down
4 changes: 3 additions & 1 deletion examples/non_uniform_heat_equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include <ddc/ddc.hpp>

#include <Kokkos_Core.hpp>
#ifdef DDC_BUILD_PDI_WRAPPER
#ifdef DDC_EXAMPLE_WITH_PDI
#include <ddc/pdi.hpp>

#include <paraconf.h>
#include <pdi.h>
#endif
Expand Down
4 changes: 3 additions & 1 deletion examples/uniform_heat_equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <ddc/ddc.hpp>

#include <Kokkos_Core.hpp>
#ifdef DDC_BUILD_PDI_WRAPPER
#ifdef DDC_EXAMPLE_WITH_PDI
#include <ddc/pdi.hpp>

#include <paraconf.h>
#include <pdi.h>
#endif
Expand Down
6 changes: 1 addition & 5 deletions include/ddc/ddc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace ddc {
}

// Misc
#include "ddc/config.hpp"
#include "ddc/detail/macros.hpp"
#include "ddc/detail/tagged_vector.hpp"
#include "ddc/detail/type_seq.hpp"
Expand Down Expand Up @@ -41,8 +42,3 @@ namespace ddc {
#include "ddc/parallel_transform_reduce.hpp"
#include "ddc/reducer.hpp"
#include "ddc/transform_reduce.hpp"

// PDI wrapper
#if defined(DDC_BUILD_PDI_WRAPPER)
#include "ddc/pdi.hpp"
#endif
2 changes: 2 additions & 0 deletions include/ddc/real_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#pragma once

#include "ddc/config.hpp"

namespace ddc {

#ifdef DDC_BUILD_DOUBLE_PRECISION
Expand Down
12 changes: 11 additions & 1 deletion install_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ message("DDC_BUILD_KERNELS_SPLINES=${DDC_BUILD_KERNELS_SPLINES}")
message("DDC_BUILD_PDI_WRAPPER=${DDC_BUILD_PDI_WRAPPER}")

add_executable(main main.cpp)
target_link_libraries(main PRIVATE DDC::DDC DDC::PDI_Wrapper)
target_link_libraries(main PRIVATE DDC::DDC)
if("${DDC_BUILD_KERNELS_FFT}")
target_compile_definitions(main PRIVATE "DDC_TEST_WITH_KERNELS_FFT")
endif()
if("${DDC_BUILD_KERNELS_SPLINES}")
target_compile_definitions(main PRIVATE "DDC_TEST_WITH_KERNELS_SPLINES")
endif()
if("${DDC_BUILD_PDI_WRAPPER}")
target_compile_definitions(main PRIVATE "DDC_TEST_WITH_PDI_WRAPPER")
target_link_libraries(main PRIVATE DDC::PDI_Wrapper)
endif()
12 changes: 9 additions & 3 deletions install_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@

#include <ddc/ddc.hpp>

#if defined(DDC_BUILD_KERNELS_FFT)
#if defined(DDC_TEST_WITH_KERNELS_FFT)
#include <ddc/kernels/fft.hpp>
#else
#error
#endif

#if defined(DDC_BUILD_KERNELS_SPLINES)
#if defined(DDC_TEST_WITH_KERNELS_SPLINES)
#include <ddc/kernels/splines.hpp>
#else
#error
#endif

#if defined(DDC_BUILD_PDI_WRAPPER)
#if defined(DDC_TEST_WITH_PDI_WRAPPER)
#include <ddc/pdi.hpp>
#else
#error
#endif

#if defined(DDC_BUILD_DOUBLE_PRECISION)
static_assert(std::is_same_v<ddc::Real, double>);
#else
static_assert(std::is_same_v<ddc::Real, float>);
#endif

int main()
{
return 0;
Expand Down

0 comments on commit f14218d

Please sign in to comment.