diff --git a/CMakeLists.txt b/CMakeLists.txt index 3577b30..b53337e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,18 @@ cmake_minimum_required(VERSION 3.19) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) project(flcl VERSION 0.5.0 LANGUAGES Fortran C CXX) -set(default_build_type "RelWithDebInfo") +if (NOT CMAKE_BUILD_TYPE) + set(DEFAULT_BUILD_TYPE "RelWithDebInfo") + message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") + set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING + "Choose the type of build, options are: Debug, Release, RelWithDebInfo and MinSizeRel." + FORCE) +endif() + + set(BUILD_SHARED_LIBS OFF) +option(FLCL_BUILD_EXAMPLES "Build examples" ON) +option(FLCL_BUILD_TESTS "Build tests" ON) include(CMakeDetermineFortranCompiler) include(CMakeDetermineCCompiler) @@ -17,7 +27,9 @@ include(CheckCCompilerFlag) include(GNUInstallDirs) -include(CTest) +if (FLCL_BUILD_TESTS) + include(CTest) +endif() add_link_options(LINKER:--disable-new-dtags) @@ -141,14 +153,14 @@ install( PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) -# install flcl module files in include directory +# install flcl module files in include directory install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mod/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") #unit testing section and toggle -if(BUILD_TESTING) +if(FLCL_BUILD_TESTS) add_subdirectory(test) endif() -if(BUILD_EXAMPLES) +if(FLCL_BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/src/flcl-cxx.hpp b/src/flcl-cxx.hpp index 2449a8a..ae97758 100644 --- a/src/flcl-cxx.hpp +++ b/src/flcl-cxx.hpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "flcl-types-cxx.hpp" @@ -73,7 +72,7 @@ using HostMemorySpace = Kokkos::HostSpace; // an optimization, one could switch to using dualview types and manage the // necessary memory transfer explicitly over larger compute regions. namespace flcl { - + #ifdef KOKKOS_ENABLE_CUDA using HostMemorySpace = Kokkos::CudaUVMSpace; #else @@ -114,7 +113,7 @@ namespace flcl { typedef Kokkos::View view_i64_5d_t; typedef Kokkos::View view_r32_5d_t; typedef Kokkos::View view_r64_5d_t; - + // 6D fortran-compatible view types typedef Kokkos::View view_l_6d_t; typedef Kokkos::View view_i32_6d_t; @@ -128,7 +127,7 @@ namespace flcl { typedef Kokkos::View view_i64_7d_t; typedef Kokkos::View view_r32_7d_t; typedef Kokkos::View view_r64_7d_t; - + // 1D fortran-compatible dualview types typedef Kokkos::DualView dualview_l_1d_t; typedef Kokkos::DualView dualview_i32_1d_t; @@ -183,7 +182,7 @@ namespace flcl { view_from_ndarray(flcl_ndarray_t const &ndarray) { size_t dimensions[Kokkos::ARRAY_LAYOUT_MAX_RANK] = {}; size_t strides[Kokkos::ARRAY_LAYOUT_MAX_RANK] = {}; - + using traits = Kokkos::ViewTraits; using value_type = typename traits::value_type; constexpr auto rank = Kokkos::ViewTraits::rank; @@ -193,7 +192,7 @@ namespace flcl { << ndarray.rank << "." << std::endl; std::exit(EXIT_FAILURE); } - + std::copy(ndarray.dims, ndarray.dims + ndarray.rank, dimensions); std::copy(ndarray.strides, ndarray.strides + ndarray.rank, strides); @@ -209,7 +208,7 @@ namespace flcl { dimensions[7], strides[7] }; // clang-format on - + return Kokkos::View( reinterpret_cast(ndarray.data), layout); } @@ -232,7 +231,7 @@ namespace flcl { return ndarray; } - + } // namespace flcl -#endif // FLCL_CXX_HPP \ No newline at end of file +#endif // FLCL_CXX_HPP