Skip to content

Commit

Permalink
Project name KokkosRemote -> KokkosRemoteSpaces, adds sample project …
Browse files Browse the repository at this point in the history
…with external KRS dep
  • Loading branch information
janciesko committed Sep 11, 2023
1 parent 3e9100d commit 1b3903b
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 42 deletions.
48 changes: 24 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.12)

project(KokkosRemote
project(KokkosRemoteSpaces
LANGUAGES CXX
VERSION 0.1.0)

Expand Down Expand Up @@ -108,76 +108,76 @@ if (KRS_ENABLE_RACERLIB)
list(APPEND HEADERS ${DIR_HDRS})
endif()

add_library(kokkosremote ${SOURCES} ${HEADERS})
add_library(Kokkos::kokkosremote ALIAS kokkosremote)
target_link_libraries(kokkosremote PUBLIC Kokkos::kokkos)
add_library(kokkosremotespaces ${SOURCES} ${HEADERS})
add_library(Kokkos::kokkosremotespaces ALIAS kokkosremotespaces)
target_link_libraries(kokkosremotespaces PUBLIC Kokkos::kokkos)

foreach(DIR ${SOURCE_DIRS})
target_include_directories(kokkosremote PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${DIR}>)
target_include_directories(kokkosremotespaces PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${DIR}>)
foreach(BACKEND_NAME ${PUBLIC_DEPS})
target_compile_definitions(kokkosremote PUBLIC KRS_ENABLE_${BACKEND_NAME})
target_compile_definitions(kokkosremotespaces PUBLIC KRS_ENABLE_${BACKEND_NAME})
endforeach()
endforeach()

if (KRS_ENABLE_RACERLIB)
target_include_directories(kokkosremote PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/features/racerlib>)
target_compile_definitions(kokkosremote PUBLIC KRS_ENABLE_RACERLIB)
target_include_directories(kokkosremotespaces PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/features/racerlib>)
target_compile_definitions(kokkosremotespaces PUBLIC KRS_ENABLE_RACERLIB)
endif()

target_include_directories(kokkosremote PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/core>)
target_include_directories(kokkosremote PUBLIC $<INSTALL_INTERFACE:include>)
target_include_directories(kokkosremotespaces PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/core>)
target_include_directories(kokkosremotespaces PUBLIC $<INSTALL_INTERFACE:include>)

if(KRS_ENABLE_DEBUG OR CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(kokkosremote PUBLIC KOKKOS_REMOTE_SPACES_ENABLE_DEBUG)
target_compile_definitions(kokkosremotespaces PUBLIC KOKKOS_REMOTE_SPACES_ENABLE_DEBUG)
message(STATUS "Enabled build mode: debug")
endif()

if (PRIVATE_DEPS)
target_link_libraries(kokkosremote PRIVATE ${PRIVATE_DEPS})
target_link_libraries(kokkosremotespaces PRIVATE ${PRIVATE_DEPS})
endif()
if (PUBLIC_DEPS)
target_link_libraries(kokkosremote PUBLIC ${PUBLIC_DEPS})
target_link_libraries(kokkosremotespaces PUBLIC ${PUBLIC_DEPS})
endif()

if (KRS_ENABLE_NVSHMEMSPACE)
target_link_libraries(kokkosremote PRIVATE "-lnvidia-ml")
target_link_libraries(kokkosremotespaces PRIVATE "-lnvidia-ml")
endif()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
KokkosRemoteConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteConfig.cmake"
KokkosRemoteSpacesConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteSpacesConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteSpacesConfigVersion.cmake"
VERSION "${KokkosRemote_VERSION}"
COMPATIBILITY AnyNewerVersion
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/KokkosRemote)
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteSpacesConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KokkosRemoteSpacesConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/KokkosRemoteSpaces)

install(FILES
${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
TARGETS kokkosremote ${PUBLIC_DEPS}
EXPORT KokkosRemoteTargets
TARGETS kokkosremotespaces ${PUBLIC_DEPS}
EXPORT KokkosRemoteSpacesTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(EXPORT
KokkosRemoteTargets
KokkosRemoteSpacesTargets
NAMESPACE Kokkos::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/KokkosRemote
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/KokkosRemoteSpaces
)

IF (KRS_ENABLE_EXAMPLES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ set(Kokkos_DIR "@Kokkos_DIR@")
find_dependency(Kokkos REQUIRED)

GET_FILENAME_COMPONENT(Kokkos_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
INCLUDE("${Kokkos_CMAKE_DIR}/KokkosRemoteTargets.cmake")
INCLUDE("${Kokkos_CMAKE_DIR}/KokkosRemoteSpacesTargets.cmake")
UNSET(Kokkos_CMAKE_DIR)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ find_package(KokkosRemote REQUIRED)
add_executable(MatVec matvec.cpp)
target_link_libraries(MatVec PRIVATE \
Kokkos::kokkoskernels Kokkos::kokkosremote)
Kokkos::kokkoskernels Kokkos::kokkosremotespaces)
```

This cmake build fike can be used as
Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/access_overhead/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ FILE(GLOB SRCS *.cpp)
foreach(file ${SRCS})
get_filename_component(test_name ${file} NAME_WE)
add_executable(${test_name} ${file})
target_link_libraries(${test_name} PRIVATE Kokkos::kokkosremote)
target_link_libraries(${test_name} PRIVATE Kokkos::kokkosremotespaces)
endforeach()
4 changes: 2 additions & 2 deletions examples/benchmarks/misslatency/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(misslatency misslatency.cpp)
add_executable(misslatency_partitioned misslatency_partitioned.cpp)
target_link_libraries(misslatency PRIVATE Kokkos::kokkosremote)
target_link_libraries(misslatency_partitioned PRIVATE Kokkos::kokkosremote)
target_link_libraries(misslatency PRIVATE Kokkos::kokkosremotespaces)
target_link_libraries(misslatency_partitioned PRIVATE Kokkos::kokkosremotespaces)
2 changes: 1 addition & 1 deletion examples/benchmarks/poissonaccess/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(poissonaccess poissonaccess.cpp)
target_link_libraries(poissonaccess PRIVATE Kokkos::kokkosremote)
target_link_libraries(poissonaccess PRIVATE Kokkos::kokkosremotespaces)
2 changes: 1 addition & 1 deletion examples/benchmarks/randomaccess/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(randomaccess randomaccess.cpp)
target_link_libraries(randomaccess PRIVATE Kokkos::kokkosremote)
target_link_libraries(randomaccess PRIVATE Kokkos::kokkosremotespaces)
2 changes: 1 addition & 1 deletion examples/cgsolve/rma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(cgsolve cgsolve.cpp)
target_link_libraries(cgsolve PRIVATE Kokkos::kokkosremote)
target_link_libraries(cgsolve PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(cgsolve PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(cgsolve PRIVATE KRS_ENABLE_NVSHMEM_PTR)
8 changes: 8 additions & 0 deletions examples/empty_project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.25)
project(MyProject)

find_package(KokkosRemoteSpaces REQUIRED)

add_executable(project project.cpp)
target_link_libraries(project PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(project PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
30 changes: 30 additions & 0 deletions examples/empty_project/project.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Contact: Jan Ciesko (jciesko@sandia.gov)
//
//@HEADER

#include <Kokkos_RemoteSpaces.hpp>
#include <project.hpp>

int main(int argc, char *argv[]) {
comm_init(argc, argv);
Kokkos::initialize(argc, argv);
{
// Your application code here
}
Kokkos::finalize();
comm_fini();
}
53 changes: 53 additions & 0 deletions examples/empty_project/project.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Contact: Jan Ciesko (jciesko@sandia.gov)
//
//@HEADER

void comm_init(int argc, char* argv[]) {
int mpi_thread_level_available;
int mpi_thread_level_required = MPI_THREAD_MULTIPLE;

#ifdef KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SERIAL
mpi_thread_level_required = MPI_THREAD_SINGLE;
#endif

MPI_Init_thread(&argc, &argv, mpi_thread_level_required,
&mpi_thread_level_available);
assert(mpi_thread_level_available >= mpi_thread_level_required);

#ifdef KRS_ENABLE_SHMEMSPACE
shmem_init_thread(mpi_thread_level_required, &mpi_thread_level_available);
assert(mpi_thread_level_available >= mpi_thread_level_required);
#endif

#ifdef KRS_ENABLE_NVSHMEMSPACE
MPI_Comm mpi_comm;
nvshmemx_init_attr_t attr;
mpi_comm = MPI_COMM_WORLD;
attr.mpi_comm = &mpi_comm;
nvshmemx_init_attr(NVSHMEMX_INIT_WITH_MPI_COMM, &attr);
#endif
}

void comm_fini() {
#ifdef KRS_ENABLE_SHMEMSPACE
shmem_finalize();
#endif
#ifdef KRS_ENABLE_NVSHMEMSPACE
nvshmem_finalize();
#endif
MPI_Finalize();
}
2 changes: 1 addition & 1 deletion examples/heat3d/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_executable(mpi_heat3d heat3d.cpp)
target_link_libraries(mpi_heat3d PRIVATE Kokkos::kokkosremote)
target_link_libraries(mpi_heat3d PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(mpi_heat3d PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
2 changes: 1 addition & 1 deletion examples/heat3d/opt_rma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(opt_rma_heat3d heat3d.cpp)
target_link_libraries(opt_rma_heat3d PRIVATE Kokkos::kokkosremote)
target_link_libraries(opt_rma_heat3d PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(opt_rma_heat3d PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(opt_rma_heat3d PRIVATE KRS_ENABLE_NVSHMEM_PTR)
2 changes: 1 addition & 1 deletion examples/heat3d/partitioned_rma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(partitioned_heat3d heat3d.cpp)
target_link_libraries(partitioned_heat3d PRIVATE Kokkos::kokkosremote)
target_link_libraries(partitioned_heat3d PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(partitioned_heat3d PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(partitioned_heat3d PRIVATE KRS_ENABLE_NVSHMEM_PTR)
2 changes: 1 addition & 1 deletion examples/heat3d/rma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(rma_heat3d heat3d.cpp)
target_link_libraries(rma_heat3d PRIVATE Kokkos::kokkosremote)
target_link_libraries(rma_heat3d PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(rma_heat3d PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(rma_heat3d PRIVATE KRS_ENABLE_NVSHMEM_PTR)
2 changes: 1 addition & 1 deletion examples/matvec/multi-node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(matvec_multi matvec.cpp)
target_link_libraries(matvec_multi PRIVATE Kokkos::kokkosremote)
target_link_libraries(matvec_multi PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(matvec_multi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})


2 changes: 1 addition & 1 deletion examples/matvec/single-node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(matvec_single matvec.cpp)
target_link_libraries(matvec_single PRIVATE Kokkos::kokkosremote)
target_link_libraries(matvec_single PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(matvec_single PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})


2 changes: 1 addition & 1 deletion examples/vectorshift/multi-node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_executable(shift_multi vectorshift.cpp)
target_link_libraries(shift_multi PRIVATE Kokkos::kokkosremote)
target_link_libraries(shift_multi PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(shift_multi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
2 changes: 1 addition & 1 deletion examples/vectorshift/single-node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(shift_single vectorshift.cpp)
target_link_libraries(shift_single PRIVATE Kokkos::kokkosremote)
target_link_libraries(shift_single PRIVATE Kokkos::kokkosremotespaces)
target_include_directories(shift_single PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})


4 changes: 2 additions & 2 deletions unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(NOT googletest_POPULATED)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif()

SET(NAME KokkosRemote_TestAll)
SET(NAME KokkosRemoteSpaces_TestAll)

if (KRS_ENABLE_MPISPACE)
FILE(GLOB TEST_SRCS *.cpp)
Expand All @@ -22,5 +22,5 @@ endif()

add_executable(${NAME} ${TEST_SRCS})

target_link_libraries(${NAME} PRIVATE Kokkos::kokkosremote)
target_link_libraries(${NAME} PRIVATE Kokkos::kokkosremotespaces)
target_link_libraries(${NAME} PRIVATE gtest_main)

0 comments on commit 1b3903b

Please sign in to comment.