Skip to content

Commit

Permalink
Merge branch 'main' into multi_gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
NaderAlAwar committed Oct 23, 2023
2 parents 1539ae1 + b8694f5 commit aed4237
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, 'pypy-3.6', 'pypy-3.7']
python-version: [3.7, 3.8, 3.9, 'pypy-3.6', 'pypy-3.7']
kokkos-branch: ['master', 'develop']

steps:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, 'pypy-3.6', 'pypy-3.7']
python-version: [3.7, 3.8, 3.9, 'pypy-3.6', 'pypy-3.7']
kokkos-branch: ['master']

steps:
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11.0-rc.1"]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
kokkos-branch: ['develop']

steps:
Expand All @@ -163,7 +163,7 @@ jobs:
python -m pip install 'cmake==3.20.2'

- name: Install Kokkos
if: ${{ matrix.python-version != '3.6' && matrix.python-version != '3.7' }}
if: ${{ matrix.python-version != '3.7' }}
run:
git clone -b ${{ matrix.kokkos-branch }} https://github.com/kokkos/kokkos.git /tmp/kokkos-source &&
cmake -B /tmp/kokkos-build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ SET(libpykokkos_SOURCES
${CMAKE_CURRENT_LIST_DIR}/src/enumeration.cpp
${CMAKE_CURRENT_LIST_DIR}/src/available.cpp
${CMAKE_CURRENT_LIST_DIR}/src/common.cpp
${CMAKE_CURRENT_LIST_DIR}/src/tools.cpp)
${CMAKE_CURRENT_LIST_DIR}/src/tools.cpp
${CMAKE_CURRENT_LIST_DIR}/src/execution_spaces.cpp)

SET(libpykokkos_HEADERS
${CMAKE_CURRENT_LIST_DIR}/include/libpykokkos.hpp
Expand All @@ -66,7 +67,8 @@ SET(libpykokkos_HEADERS
${CMAKE_CURRENT_LIST_DIR}/include/common.hpp
${CMAKE_CURRENT_LIST_DIR}/include/traits.hpp
${CMAKE_CURRENT_LIST_DIR}/include/views.hpp
${CMAKE_CURRENT_LIST_DIR}/include/fwd.hpp)
${CMAKE_CURRENT_LIST_DIR}/include/fwd.hpp
${CMAKE_CURRENT_LIST_DIR}/include/execution_spaces.hpp)

ADD_LIBRARY(libpykokkos-core OBJECT
${libpykokkos_SOURCES}
Expand Down
1 change: 1 addition & 0 deletions examples/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Kokkos_Core.hpp"

#include <cstdint>
#include <iostream>

struct InitView {
explicit InitView(view_type _v) : m_view(_v) {}
Expand Down
2 changes: 1 addition & 1 deletion external/kokkos
Submodule kokkos updated 70 files
+1 −1 .github/workflows/continuous-integration-workflow.yml
+1 −1 .jenkins
+44 −2 CHANGELOG.md
+5 −1 CMakeLists.txt
+11 −7 Makefile.kokkos
+1 −1 algorithms/cmake/Dependencies.cmake
+1 −1 algorithms/src/CMakeLists.txt
+16 −4 algorithms/src/Kokkos_Sort.hpp
+5 −3 bin/nvcc_wrapper
+3 −0 cmake/KokkosCore_config.h.in
+1 −0 cmake/compile_tests/cuda_compute_capability.cc
+12 −1 cmake/kokkos_arch.cmake
+0 −7 cmake/kokkos_tribits.cmake
+1 −1 containers/cmake/Dependencies.cmake
+44 −27 containers/src/Kokkos_DynRankView.hpp
+51 −30 containers/src/Kokkos_DynamicView.hpp
+62 −49 containers/src/Kokkos_OffsetView.hpp
+10 −0 containers/unit_tests/CMakeLists.txt
+1 −0 containers/unit_tests/TestCompileMain.cpp
+179 −0 containers/unit_tests/TestCreateMirror.cpp
+77 −0 containers/unit_tests/TestDynamicView.hpp
+1 −1 core/cmake/Dependencies.cmake
+1 −1 core/perf_test/test_atomic.cpp
+2 −1 core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp
+3 −2 core/src/Cuda/Kokkos_Cuda_Half_Conversion.hpp
+1 −1 core/src/Cuda/Kokkos_Cuda_Locks.hpp
+72 −35 core/src/Cuda/Kokkos_Cuda_Parallel_Range.hpp
+1 −0 core/src/Cuda/Kokkos_Cuda_ReduceScan.hpp
+2 −0 core/src/HIP/Kokkos_HIP_Instance.cpp
+39 −21 core/src/HIP/Kokkos_HIP_Parallel_Range.hpp
+7 −10 core/src/HIP/Kokkos_HIP_ReduceScan.hpp
+1 −0 core/src/HIP/Kokkos_HIP_Shuffle_Reduce.hpp
+38 −27 core/src/Kokkos_CopyViews.hpp
+3 −5 core/src/Kokkos_Macros.hpp
+39 −19 core/src/Kokkos_ScratchSpace.hpp
+0 −8 core/src/Kokkos_Serial.hpp
+25 −12 core/src/Kokkos_View.hpp
+8 −8 core/src/Kokkos_WorkGraphPolicy.hpp
+1 −1 core/src/OpenACC/Kokkos_OpenACC_Traits.hpp
+9 −3 core/src/OpenMPTarget/Kokkos_OpenMPTarget_Instance.cpp
+1 −1 core/src/SYCL/Kokkos_SYCL.cpp
+8 −6 core/src/SYCL/Kokkos_SYCL_Parallel_Team.hpp
+1 −7 core/src/Serial/Kokkos_Serial.cpp
+7 −12 core/src/Serial/Kokkos_Serial_Parallel_MDRange.hpp
+2 −3 core/src/impl/Kokkos_ClockTic.hpp
+15 −8 core/src/impl/Kokkos_Core.cpp
+3 −1 core/src/impl/Kokkos_InitializationSettings.hpp
+1 −0 core/src/impl/Kokkos_MemoryPool.cpp
+3 −3 core/src/impl/Kokkos_Profiling.cpp
+5 −9 core/src/impl/Kokkos_ViewMapping.hpp
+2 −0 core/unit_test/CMakeLists.txt
+1 −0 core/unit_test/TestCompileMain.cpp
+126 −0 core/unit_test/TestCreateMirror.cpp
+14 −10 core/unit_test/TestDefaultDeviceTypeInit.hpp
+0 −2 core/unit_test/TestDetectionIdiom.cpp
+31 −11 core/unit_test/TestScan.hpp
+2 −2 core/unit_test/TestSharedAlloc.hpp
+129 −4 core/unit_test/TestTeam.hpp
+10 −0 core/unit_test/TestTeamReductionScan.hpp
+10 −0 core/unit_test/TestViewIsAssignable.hpp
+3 −1 core/unit_test/cuda/TestCuda_InterOp_Init.cpp
+3 −1 core/unit_test/cuda/TestCuda_InterOp_Streams.cpp
+3 −1 core/unit_test/hip/TestHIP_InterOp_Init.cpp
+3 −1 core/unit_test/hip/TestHIP_InterOp_Streams.cpp
+1 −1 core/unit_test/sycl/TestSYCL_InterOp_Init.cpp
+1 −0 core/unit_test/sycl/TestSYCL_InterOp_Init_Context.cpp
+6 −2 core/unit_test/sycl/TestSYCL_InterOp_Streams.cpp
+1 −0 master_history.txt
+1 −1 simd/cmake/Dependencies.cmake
+1 −1 tpls/desul/include/desul/atomics/Lock_Array_Cuda.hpp
137 changes: 137 additions & 0 deletions include/execution_spaces.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) 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.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott ([email protected])
//
// ************************************************************************
//@HEADER
*/

#pragma once

#include "common.hpp"
#include "concepts.hpp"
#include "pools.hpp"
#include "traits.hpp"

#include <Kokkos_Core.hpp>

namespace Common {
template <typename Sp, size_t SpaceIdx>
void generate_execution_space_init(py::class_<Sp> &,
enable_if_t<SpaceIdx == Serial_Backend, int> = 0) {}

template <typename Sp, size_t SpaceIdx>
void generate_execution_space_init(py::class_<Sp> &,
enable_if_t<SpaceIdx == Threads_Backend, int> = 0) {}

template <typename Sp, size_t SpaceIdx>
void generate_execution_space_init(py::class_<Sp> &,
enable_if_t<SpaceIdx == OpenMP_Backend, int> = 0) {}

template <typename Sp, size_t SpaceIdx>
void generate_execution_space_init(py::class_<Sp> &_space,
enable_if_t<SpaceIdx == Cuda_Backend, int> = 0) {
#if defined(KOKKOS_ENABLE_CUDA) && defined(__CUDACC__)
_space.def(py::init([](uint64_t stream_ptr, bool manage_stream) {
cudaStream_t s = reinterpret_cast<cudaStream_t>(stream_ptr);
return new Sp{s, manage_stream};
}));
#endif
}

template <typename Sp, size_t SpaceIdx>
void generate_execution_space_init(py::class_<Sp> &_space,
enable_if_t<SpaceIdx == HIP_Backend, int> = 0) {
#if defined(KOKKOS_ENABLE_HIP) && defined(__HIPCC__)
_space.def(py::init([](uint64_t stream_ptr, bool manage_stream) {
hipStream_t s = reinterpret_cast<hipStream_t>(stream_ptr);
return new Sp{s, manage_stream};
}));
#endif
}

template <typename Sp, size_t SpaceIdx>
void generate_execution_space(py::module &_mod, const std::string &_name,
const std::string &_msg) {
if (debug_output())
std::cerr << "Registering " << _msg << " as python class '" << _name
<< "'..." << std::endl;

py::class_<Sp> _space(_mod, _name.c_str());
_space.def(py::init([]() { return new Sp{}; }));

// Add other constructors with arguments if they exist
generate_execution_space_init<Sp, SpaceIdx>(_space);
}
} // namespace Common

namespace Space {
namespace SpaceDim {

template <size_t SpaceIdx>
void generate_execution_space(py::module &_mod) {
using space_spec_t = ExecutionSpaceSpecialization<SpaceIdx>;
using Sp = typename space_spec_t::type;

auto name = join("_", "KokkosExecutionSpace", space_spec_t::label());

Common::generate_execution_space<Sp, SpaceIdx>(_mod, name, demangle<Sp>());
}
} // namespace SpaceDim

template <size_t SpaceIdx>
void generate_execution_space(
py::module &,
std::enable_if_t<!is_available<execution_space_t<SpaceIdx>>::value, int> =
0) {}

template <size_t SpaceIdx>
void generate_execution_space(
py::module &_mod,
std::enable_if_t<is_available<execution_space_t<SpaceIdx>>::value, int> =
0) {
SpaceDim::generate_execution_space<SpaceIdx>(_mod);
}
} // namespace Space

template <size_t... SpaceIdx>
void generate_execution_spaces(py::module &_mod,
std::index_sequence<SpaceIdx...>) {
FOLD_EXPRESSION(Space::generate_execution_space<SpaceIdx>(_mod));
}
1 change: 1 addition & 0 deletions include/libpykokkos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ void generate_view_variants(py::module& kokkos);
void generate_atomic_variants(py::module& kokkos);
void generate_backend_versions(py::module& kokkos);
void generate_pool_variants(py::module& kokkos);
void generate_execution_spaces(py::module& kokkos);
void destroy_callbacks();
4 changes: 4 additions & 0 deletions include/views.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ void generate_view(py::module &_mod, const std::string &_name,
"dynamic", [](ViewT &) { return Kokkos::is_dyn_rank_view<ViewT>::value; },
"Whether the rank is dynamic");

_view.def_property_readonly(
"cpp_type", [=](ViewT &) { return _msg; },
"Underlying C++ type as string");

// support []
generate_view_access<Tp>(_view, std::index_sequence<Idx...>{});
}
Expand Down
55 changes: 55 additions & 0 deletions src/execution_spaces.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) 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.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott ([email protected])
//
// ************************************************************************
//@HEADER
*/

#include "execution_spaces.hpp"

#include "common.hpp"
#include "defines.hpp"
#include "fwd.hpp"
#include "traits.hpp"

void generate_execution_spaces(py::module &kokkos) {
generate_execution_spaces(kokkos,
std::make_index_sequence<ExecutionSpacesEnd>{});
}
1 change: 1 addition & 0 deletions src/libpykokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@ PYBIND11_MODULE(libpykokkos, kokkos) {
generate_atomic_variants(kokkos);
generate_backend_versions(kokkos);
generate_pool_variants(kokkos);
generate_execution_spaces(kokkos);
}

0 comments on commit aed4237

Please sign in to comment.