38#include <initializer_list>
44#if defined(OpenPFC_ENABLE_CUDA)
45#include <cuda_runtime.h>
63template <
typename BackendTag,
typename T>
70 if constexpr (std::is_same_v<BackendTag, backend::CpuTag>) {
75 size_t idx = indices.data()[
i];
77 throw std::runtime_error(
"gather: index out of bounds");
82#if defined(OpenPFC_ENABLE_CUDA)
83 else if constexpr (std::is_same_v<BackendTag, backend::CudaTag>) {
86 throw std::runtime_error(
"CUDA gather not yet implemented");
96 const std::vector<T> &
source) {
105 std::initializer_list<T>
source) {
122template <
typename BackendTag,
typename T>
129 if constexpr (std::is_same_v<BackendTag, backend::CpuTag>) {
134 size_t idx = indices.data()[
i];
136 throw std::runtime_error(
"scatter: index out of bounds");
141#if defined(OpenPFC_ENABLE_CUDA)
142 else if constexpr (std::is_same_v<BackendTag, backend::CudaTag>) {
145 throw std::runtime_error(
"CUDA scatter not yet implemented");
155 std::vector<T> &
dest) {
Sparse vector for indexed data views.
Definition sparse_vector.hpp:66
Sparse vector for halo exchange and indexed data views.
void gather(SparseVector< BackendTag, T > &sparse_vector, const T *source, size_t source_size)
Gather: Collect values from dense array into SparseVector.
Definition sparse_vector_ops.hpp:64
void scatter(const SparseVector< BackendTag, T > &sparse_vector, T *dest, size_t dest_size)
Scatter: Write values from SparseVector into dense array.
Definition sparse_vector_ops.hpp:123
Represents the global simulation domain (the "world").
Definition world.hpp:91