1#ifndef __MC_FIRST_TOUCH_HPP__
2#define __MC_FIRST_TOUCH_HPP__
4#include <Kokkos_Core.hpp>
6#include <biocma_cst_config.hpp>
7#include <common/common.hpp>
8#include <common/execinfo.hpp>
9#include <common/kokkos_getpolicy.hpp>
30 using TeamMember =
typename Kokkos::TeamPolicy<ComputeSpace>::member_type;
31 using value_type =
typename ViewType::non_const_value_type;
38 KOKKOS_INLINE_FUNCTION
void
41 const std::size_t p0 =
begin + (team.league_rank() *
per_team);
44 Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, upper),
45 [&](
const std::size_t idx)
47 const std::size_t i = p0 + idx;
48 if constexpr (ViewType::rank == 1)
54 for (std::size_t j = 0; j <
view.extent(1);
66 template <
typename ViewType>
73 end = std::min(end,
static_cast<std::size_t
>(view.extent(0)));
74 if (begin >= end || npt == 0)
83 Kokkos::TeamPolicy<ComputeSpace>(
84 static_cast<int>(league), Kokkos::AUTO(), Kokkos::AUTO()),
104 template <
typename ViewType,
typename... Extents>
112 if (view.extent(0) == n_alloc)
117 ViewType next(Kokkos::view_alloc(Kokkos::WithoutInitializing, view.label()),
121 const std::size_t live = std::min(n_live, n_alloc);
126 const std::size_t n_copy
127 = std::min(
static_cast<std::size_t
>(view.extent(0)), n_alloc);
130 const auto range = Kokkos::make_pair(std::size_t{ 0 }, n_copy);
131 if constexpr (ViewType::rank == 1)
133 Kokkos::deep_copy(Kokkos::subview(next, range),
134 Kokkos::subview(view, range));
138 Kokkos::deep_copy(Kokkos::subview(next, range, Kokkos::ALL),
139 Kokkos::subview(view, range, Kokkos::ALL));
std::size_t c_league_size(std::size_t n_tot, std::size_t n_per_team) noexcept
Definition common.cpp:17
Definition first_touch.hpp:27
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:16
void resize_first_touch(ViewType &view, std::size_t n_alloc, std::size_t n_live, std::size_t npt, Extents... rest)
Kokkos::resize, but with the first touch placed by us.
Definition first_touch.hpp:106
void first_touch(const ViewType &view, std::size_t begin, std::size_t end, std::size_t npt)
Write-touch [begin, end) with the move kernel's team decomposition.
Definition first_touch.hpp:68
Definition first_touch.hpp:29
std::size_t per_team
Definition first_touch.hpp:36
ViewType view
Definition first_touch.hpp:33
std::size_t begin
Definition first_touch.hpp:34
KOKKOS_INLINE_FUNCTION void operator()(const TeamMember &team) const
Definition first_touch.hpp:39
typename Kokkos::TeamPolicy< ComputeSpace >::member_type TeamMember
Definition first_touch.hpp:30
std::size_t end
Definition first_touch.hpp:35
typename ViewType::non_const_value_type value_type
Definition first_touch.hpp:31