BioCMAMC-ST
move_info.hpp
1#ifndef __SIMULATION__MOVE_INFO_HPP__
2#define __SIMULATION__MOVE_INFO_HPP__
3
4#include <Kokkos_Core_fwd.hpp>
5#include <common/common.hpp>
6#include <mc/alias.hpp>
7#include <simulation/alias.hpp>
8
10{
11
13 {
14 std::size_t index;
15 double flow;
16 };
17
18 template <typename ExecSpace> struct MoveInfo
19 {
20 ConstNeighborsView<ExecSpace> neighbors;
23 // LeavingFlowType leaving_flow;
24 // LeavingFlowIndexType index_leaving_flow;
25 Kokkos::View<LeavingFlow*,
26 Kokkos::SharedHostPinnedSpace,
27 Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Aligned |
28 Kokkos::MemoryTraitsFlags::Restrict>>
30 Kokkos::View<double*, ExecSpace> liquid_volume;
31
33 {
34 }
35
36 MoveInfo(const std::size_t n_compartments, const std::size_t n_flows)
37 : diag_transition("diag_transition", n_compartments),
38 leaving_flow("leaving_flow", n_flows),
39 liquid_volume("liquid_volume", n_compartments)
40
41 {
42 }
43
44 void update(std::span<const double> newliquid_volume,
45 std::span<const double> diag,
46 std::span<const double> proba)
47 {
48 KOKKOS_ASSERT(newliquid_volume.size() == this->liquid_volume.extent(0));
49 const auto n_c = diag.size();
50 const auto n_neighbors = proba.size() / n_c;
51 KOKKOS_ASSERT(proba.size() % n_c == 0);
52
53 Kokkos::View<const double*, HostSpace> hostli(newliquid_volume.data(),
54 newliquid_volume.size());
55 Kokkos::deep_copy(this->liquid_volume, hostli);
56
57 Kokkos::View<const double*,
58 Kokkos::LayoutLeft,
59 HostSpace,
60 Kokkos::MemoryTraits<Kokkos::RandomAccess>>
61 _diag_transition(diag.data(), n_c);
62
63 Kokkos::deep_copy(diag_transition, _diag_transition);
64
65 const auto* chunk_proba = proba.data();
67 chunk_proba, n_c, n_neighbors);
69 Kokkos::create_mirror_view_and_copy(ComputeSpace(), cumproba_host);
70 }
71
72 void
73 set_flow(const std::size_t i, const std::size_t i_flow, const double flow)
74 {
75 leaving_flow(i) = {i_flow, flow};
76 // Kokkos::deep_copy(leaving_flow(i), LeavingFlow{i_flow, flow});
77 }
78 };
79} // namespace Simulation::KernelInline
80#endif
Definition kernels.hpp:11
Kokkos::View< double *, Kokkos::LayoutLeft, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > > DiagonalView
Definition alias.hpp:14
Kokkos::View< const double **, Kokkos::LayoutRight, Space, Kokkos::MemoryTraits< Kokkos::RandomAccess > > CumulativeProbabilityView
Definition alias.hpp:20
Definition move_info.hpp:13
double flow
Definition move_info.hpp:15
std::size_t index
Definition move_info.hpp:14
void set_flow(const std::size_t i, const std::size_t i_flow, const double flow)
Definition move_info.hpp:73
MoveInfo()
Definition move_info.hpp:32
Kokkos::View< LeavingFlow *, Kokkos::SharedHostPinnedSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Aligned|Kokkos::MemoryTraitsFlags::Restrict > > leaving_flow
Definition move_info.hpp:29
DiagonalView< ExecSpace > diag_transition
Definition move_info.hpp:21
MoveInfo(const std::size_t n_compartments, const std::size_t n_flows)
Definition move_info.hpp:36
CumulativeProbabilityView< ExecSpace > cumulative_probability
Definition move_info.hpp:22
void update(std::span< const double > newliquid_volume, std::span< const double > diag, std::span< const double > proba)
Definition move_info.hpp:44
ConstNeighborsView< ExecSpace > neighbors
Definition move_info.hpp:20
Kokkos::View< double *, ExecSpace > liquid_volume
Definition move_info.hpp:30