forked from lijiext/lammps
cmake: move kokkos to external project (part I)
This commit is contained in:
parent
36b826348b
commit
01a51d655c
|
@ -0,0 +1,13 @@
|
|||
diff --git a/lib/kokkos/containers/src/Kokkos_ScatterView.hpp b/lib/kokkos/containers/src/Kokkos_ScatterView.hpp
|
||||
index a8c05e3..1d83aed 100644
|
||||
--- a/lib/kokkos/containers/src/Kokkos_ScatterView.hpp
|
||||
+++ b/lib/kokkos/containers/src/Kokkos_ScatterView.hpp
|
||||
@@ -681,7 +681,7 @@ class ScatterView<DataType
|
||||
,contribution>
|
||||
{
|
||||
public:
|
||||
- typedef Kokkos::View<DataType, Layout, ExecSpace> original_view_type;
|
||||
+ typedef Kokkos::View<DataType, Layout, Kokkos::Device<ExecSpace, Kokkos::Cuda::memory_space> > original_view_type;
|
||||
typedef typename original_view_type::value_type original_value_type;
|
||||
typedef typename original_view_type::reference_type original_reference_type;
|
||||
friend class ScatterAccess<DataType, Op, ExecSpace, Layout, ScatterNonDuplicated, contribution, ScatterNonAtomic>;
|
|
@ -1,22 +1,38 @@
|
|||
if(PKG_KOKKOS)
|
||||
# TODO: this option needs to be documented when this works with a
|
||||
# regular release version of KOKKOS, and a version compatibility check
|
||||
# of external KOKKOS lib versus what the KOKKOS package needs is required.
|
||||
option(EXTERNAL_KOKKOS "Build against external kokkos library")
|
||||
if(EXTERNAL_KOKKOS)
|
||||
find_package(Kokkos REQUIRED)
|
||||
list(APPEND LAMMPS_LINK_LIBS Kokkos::kokkos)
|
||||
find_package(Kokkos 3 QUIET)
|
||||
if(Kokkos_FOUND)
|
||||
set(DOWNLOAD_KOKKOS_DEFAULT OFF)
|
||||
else()
|
||||
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
|
||||
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
|
||||
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
|
||||
set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
|
||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
|
||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
|
||||
${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
include_directories(${Kokkos_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS kokkos)
|
||||
set(DOWNLOAD_KOKKOS_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_KOKKOS "Download the KOKKOS library instead of using an already installed one" ${DOWNLOAD_KOKKOS_DEFAULT})
|
||||
if(DOWNLOAD_KOKKOS)
|
||||
message(STATUS "KOKKOS download requested - we will build our own")
|
||||
# Workaround for cross compilation with MinGW where ${CMAKE_INSTALL_LIBDIR}
|
||||
# is a full path, so we need to remove the prefix
|
||||
string(REPLACE ${CMAKE_INSTALL_PREFIX} "" _KOKKOS_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(kokkos_build
|
||||
URL https://github.com/kokkos/kokkos/archive/3.0.00.tar.gz
|
||||
URL_MD5 281c7093aa3a603276e93abdf4be23b9
|
||||
PATCH_COMMAND patch -p3 < ${CMAKE_CURRENT_SOURCE_DIR}/2826.patch
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/${_KOKKOS_LIBDIR}/libkokkoscore.a
|
||||
)
|
||||
list(APPEND LAMMPS_DEPS kokkos_build)
|
||||
ExternalProject_get_property(kokkos_build INSTALL_DIR)
|
||||
set(KOKKOS_LIBRARIES ${INSTALL_DIR}/${_KOKKOS_LIBDIR}/libkokkoscore.a)
|
||||
set(KOKKOS_INCLUDE_DIRS ${INSTALL_DIR}/include)
|
||||
include_directories(${KOKKOS_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${KOKKOS_LIBRARIES})
|
||||
else()
|
||||
find_package(Kokkos 3)
|
||||
if(NOT Kokkos_FOUND)
|
||||
message(FATAL_ERROR "KOKKOS library not found, help CMake to find it by setting KOKKOS_LIBRARY, or set DOWNLOAD_KOKKOS=ON to download it")
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS Kokkos::kokkos)
|
||||
endif()
|
||||
add_definitions(-DLMP_KOKKOS)
|
||||
|
||||
|
|
Loading…
Reference in New Issue