Loading...
Searching...
No Matches
EnvironmentKokkosAssembly.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3#pragma once
4
24
25#ifndef GPR_LINALG_KOKKOS
26#error "EnvironmentKokkosAssembly.h needs -Dlinalg_backend=kokkos"
27#endif
28
29#include <Eigen/Core>
30#include <cstddef>
31#include <memory>
32
34
36
37namespace detail {
38struct EnvironmentStorage;
39}
40
43public:
44 DeviceEnvironments() = default;
46 std::shared_ptr<const detail::EnvironmentStorage> storage)
47 : storage_(std::move(storage))
48 {
49 }
50
51 [[nodiscard]] bool empty() const noexcept
52 {
53 return !storage_;
54 }
55 [[nodiscard]] const detail::EnvironmentStorage* storage() const noexcept
56 {
57 return storage_.get();
58 }
59
60private:
61 std::shared_ptr<const detail::EnvironmentStorage> storage_;
62};
63
65[[nodiscard]] DeviceEnvironments upload(
66 const gpr::detail::EnvironmentBatchView& source);
67
70inline constexpr std::size_t default_scratch_bytes = std::size_t(256) << 20;
71
75[[nodiscard]] std::size_t pairsPerChunk(const DeviceEnvironments& left,
76 const DeviceEnvironments& right,
77 int channel_count,
78 std::size_t scratch_bytes);
79
87[[nodiscard]] Eigen::VectorXd assemble(
88 const DeviceEnvironments& left, const DeviceEnvironments& right,
89 const gpr::detail::EnvironmentPairBatch& batch,
90 std::size_t scratch_bytes = default_scratch_bytes);
91
92} // namespace gpr::kokkos_environment
Environment data of one configuration set, in execution memory.
DeviceEnvironments(std::shared_ptr< const detail::EnvironmentStorage > storage)
const detail::EnvironmentStorage * storage() const noexcept
DeviceEnvironments upload(const gpr::detail::EnvironmentBatchView &source)
Copy the environments of source to execution memory.
constexpr std::size_t default_scratch_bytes
std::size_t pairsPerChunk(const DeviceEnvironments &left_environments, const DeviceEnvironments &right_environments, int channel_count, std::size_t scratch_bytes)
Eigen::VectorXd assemble(const DeviceEnvironments &left_environments, const DeviceEnvironments &right_environments, const gpr::detail::EnvironmentPairBatch &batch, std::size_t scratch_bytes)
STL namespace.