Skip to content

Commit

Permalink
Merge pull request #60 from pkestene/cmake-minor-changes
Browse files Browse the repository at this point in the history
Cmake minor changes
  • Loading branch information
dalg24 authored Oct 31, 2022
2 parents 23d6aff + e202c83 commit d383789
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -17,7 +27,9 @@ include(CheckCCompilerFlag)

include(GNUInstallDirs)

include(CTest)
if (FLCL_BUILD_TESTS)
include(CTest)
endif()

add_link_options(LINKER:--disable-new-dtags)

Expand Down Expand Up @@ -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()
17 changes: 8 additions & 9 deletions src/flcl-cxx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <iostream>
#include <type_traits>
#include <Kokkos_Core.hpp>
#include <Kokkos_View.hpp>
#include <Kokkos_DualView.hpp>
#include "flcl-types-cxx.hpp"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -114,7 +113,7 @@ namespace flcl {
typedef Kokkos::View<flcl_view_i64_c_t*****,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_i64_5d_t;
typedef Kokkos::View<flcl_view_r32_c_t*****,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_r32_5d_t;
typedef Kokkos::View<flcl_view_r64_c_t*****,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_r64_5d_t;

// 6D fortran-compatible view types
typedef Kokkos::View<flcl_view_l_c_t******,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_l_6d_t;
typedef Kokkos::View<flcl_view_i32_c_t******,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_i32_6d_t;
Expand All @@ -128,7 +127,7 @@ namespace flcl {
typedef Kokkos::View<flcl_view_i64_c_t*******,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_i64_7d_t;
typedef Kokkos::View<flcl_view_r32_c_t*******,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_r32_7d_t;
typedef Kokkos::View<flcl_view_r64_c_t*******,Kokkos::LayoutLeft,flcl::HostMemorySpace> view_r64_7d_t;

// 1D fortran-compatible dualview types
typedef Kokkos::DualView<flcl_dualview_l_c_t*,Kokkos::LayoutLeft> dualview_l_1d_t;
typedef Kokkos::DualView<flcl_dualview_i32_c_t*,Kokkos::LayoutLeft> dualview_i32_1d_t;
Expand Down Expand Up @@ -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<DataType>;
using value_type = typename traits::value_type;
constexpr auto rank = Kokkos::ViewTraits<DataType>::rank;
Expand All @@ -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);

Expand All @@ -209,7 +208,7 @@ namespace flcl {
dimensions[7], strides[7]
};
// clang-format on

return Kokkos::View<DataType, Kokkos::LayoutStride, flcl::HostMemorySpace, Kokkos::MemoryUnmanaged>(
reinterpret_cast<value_type *>(ndarray.data), layout);
}
Expand All @@ -232,7 +231,7 @@ namespace flcl {

return ndarray;
}

} // namespace flcl

#endif // FLCL_CXX_HPP
#endif // FLCL_CXX_HPP

0 comments on commit d383789

Please sign in to comment.