1#ifndef __CONTRIBUTION_KERNEL_HPP__
2#define __CONTRIBUTION_KERNEL_HPP__
3#include "Kokkos_Assert.hpp"
4#include <Kokkos_Core.hpp>
5#include <mc/particles_container.hpp>
6#include <mc/traits.hpp>
22 TeamPolicy::execution_space::scratch_memory_space>;
48 KOKKOS_INLINE_FUNCTION
54 const std::size_t n_particle =
m_particles.n_particles();
57 static const auto n_c = M::n_c;
61 Kokkos::parallel_for(Kokkos::TeamVectorRange(team, n_c),
62 [&](
const std::size_t j)
70 && (p0 + upper_bound) <= n_particle);
75 Kokkos::TeamThreadRange(team, 0, upper_bound),
76 [&](
const std::size_t relative_index)
78 const std::size_t flatten_index = p0 + relative_index;
83 const auto weight =
m_particles.get_weight(flatten_index);
84 for (std::size_t j = 0; j < n_c; ++j)
86 Kokkos::atomic_add(&scratch(j),
87 weight * contribs(flatten_index, j));
93 Kokkos::single(Kokkos::PerTeam(team),
96 auto access = cs.access();
97 for (std::size_t j = 0; j < M::n_c; ++j)
99 access(j, 0) += scratch(j);
144 KOKKOS_INLINE_FUNCTION
155 constexpr std::size_t work_per_thread = 32;
161 KOKKOS_ASSERT(upper_bound < n_particle);
163 const auto range = (upper_bound + work_per_thread - 1) / work_per_thread;
167 Kokkos::parallel_for(
168 Kokkos::TeamThreadRange(team, 0, range),
169 [&](
const std::size_t i)
172 for (std::size_t k = 0; k < work_per_thread; ++k)
174 const std::size_t p = p0 + i * work_per_thread + k;
180 const auto pos = positions(p);
181 Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, 0, M::n_c),
183 { access(j, pos) += weight * c(p, j); });
Main owning object for Monte-Carlo particles.
Definition particles_container.hpp:57
decltype(Kokkos::Experimental::create_scatter_view( kernelContribution())) ContributionView
Definition alias.hpp:162
@ Idle
Definition alias.hpp:126
Definition contribution_kernel.hpp:11
Definition contribution_kernel.hpp:14
Kokkos::View< float_type *, TeamPolicy::execution_space::scratch_memory_space > ScratchView
Definition contribution_kernel.hpp:20
TeamPolicy::member_type TeamMember
Definition contribution_kernel.hpp:18
KOKKOS_INLINE_FUNCTION void operator()(Tag0D _tag, const TeamMember &team) const
Definition contribution_kernel.hpp:49
ContributionFunctor(std::size_t particle_per_team, MC::ContributionView contribution_scatter, MC::ParticlesContainer< M > particles)
Definition contribution_kernel.hpp:23
Kokkos::TeamPolicy< ComputeSpace > TeamPolicy
Definition contribution_kernel.hpp:17
void update(MC::ParticlesContainer< M > _particles)
Definition contribution_kernel.hpp:35
size_t np
Definition contribution_kernel.hpp:32
MC::ParticlesContainer< M > m_particles
Definition contribution_kernel.hpp:45
float float_type
Definition contribution_kernel.hpp:19
MC::ContributionView m_contribution_scatter
Definition contribution_kernel.hpp:44
std::size_t m_particle_per_team
Definition contribution_kernel.hpp:42