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)
|
if(PKG_KOKKOS)
|
||||||
# TODO: this option needs to be documented when this works with a
|
find_package(Kokkos 3 QUIET)
|
||||||
# regular release version of KOKKOS, and a version compatibility check
|
if(Kokkos_FOUND)
|
||||||
# of external KOKKOS lib versus what the KOKKOS package needs is required.
|
set(DOWNLOAD_KOKKOS_DEFAULT OFF)
|
||||||
option(EXTERNAL_KOKKOS "Build against external kokkos library")
|
|
||||||
if(EXTERNAL_KOKKOS)
|
|
||||||
find_package(Kokkos REQUIRED)
|
|
||||||
list(APPEND LAMMPS_LINK_LIBS Kokkos::kokkos)
|
|
||||||
else()
|
else()
|
||||||
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
|
set(DOWNLOAD_KOKKOS_DEFAULT ON)
|
||||||
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
|
endif()
|
||||||
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
option(DOWNLOAD_KOKKOS "Download the KOKKOS library instead of using an already installed one" ${DOWNLOAD_KOKKOS_DEFAULT})
|
||||||
|
if(DOWNLOAD_KOKKOS)
|
||||||
set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
|
message(STATUS "KOKKOS download requested - we will build our own")
|
||||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
|
# Workaround for cross compilation with MinGW where ${CMAKE_INSTALL_LIBDIR}
|
||||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
|
# is a full path, so we need to remove the prefix
|
||||||
${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
string(REPLACE ${CMAKE_INSTALL_PREFIX} "" _KOKKOS_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||||
include_directories(${Kokkos_INCLUDE_DIRS})
|
include(ExternalProject)
|
||||||
list(APPEND LAMMPS_LINK_LIBS kokkos)
|
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()
|
endif()
|
||||||
add_definitions(-DLMP_KOKKOS)
|
add_definitions(-DLMP_KOKKOS)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue