1#ifndef __CORE__PROBE_HPP__
2#define __CORE__PROBE_HPP__
4#include "Kokkos_Core_fwd.hpp"
5#include <Kokkos_Core.hpp>
6#include <biocma_cst_config.hpp>
9#include <unordered_map>
33 template <std::
size_t buffer_size>
class Probes
36 template <
typename Space>
37 using buffer_type = Kokkos::View<double[buffer_size], Kokkos::LayoutRight, Space>;
40 [[nodiscard]] KOKKOS_INLINE_FUNCTION
bool set(
double val)
const;
46 [[nodiscard]] std::span<const
double>
get() const;
61 using MapProbes = std::unordered_map<ProbeType, ProbeAutogeneratedBuffer>;
69 if (AutoGenerated::FlagCompileTime::use_probe)
73 internal_counter = Kokkos::View<uint64_t, Kokkos::SharedSpace>(
"i_c");
79 template <std::
size_t buffer_size>
82 const auto i = (active)?Kokkos::atomic_fetch_inc(&internal_counter()):0;
85 if ((i < buffer_size) && active)
90 this->buffer(i) = val;
107 return (internal_counter() >= buffer_size) && active;
111 Kokkos::deep_copy(buffer, 0.);
112 Kokkos::deep_copy(internal_counter, 0);
115 template <std::
size_t buffer_size>
118 Kokkos::deep_copy(host_buffer, buffer);
119 return {host_buffer.data(), std::min(buffer_size, internal_counter())};
Class to store time event as bulk storage
Definition probe.hpp:34
Kokkos::View< uint64_t, Kokkos::SharedSpace > internal_counter
Definition probe.hpp:54
Probes()
Definition probe.hpp:67
buffer_type< Kokkos::DefaultHostExecutionSpace > host_buffer
Definition probe.hpp:55
bool need_export() const noexcept
Definition probe.hpp:105
std::span< const double > get() const
Definition probe.hpp:116
void clear()
Definition probe.hpp:109
buffer_type< Kokkos::DefaultExecutionSpace > buffer
Definition probe.hpp:53
Kokkos::View< double[buffer_size], Kokkos::LayoutRight, Space > buffer_type
Definition probe.hpp:37
KOKKOS_INLINE_FUNCTION bool set(double val) const
Definition probe.hpp:80
bool active
Definition probe.hpp:51
Namespace that contains classes and structures related to simulation handling.
Definition host_specific.hpp:12
ProbeType
Definition probe.hpp:23
std::unordered_map< ProbeType, ProbeAutogeneratedBuffer > MapProbes
Definition probe.hpp:61