17#ifndef dealii_memory_space_data_h
18#define dealii_memory_space_data_h
37 template <
typename Number,
typename MemorySpace>
42 static_assert(std::is_same<MemorySpace, Host>::value ||
43 std::is_same<MemorySpace, CUDA>::value,
44 "MemorySpace should be Host or CUDA");
72 std::unique_ptr<Number[], std::function<void(Number *)>>
values;
90 template <
typename Number,
typename MemorySpace>
95 static_assert(std::is_same<MemorySpace, Host>::value ||
96 std::is_same<MemorySpace, CUDA>::value,
97 "MemorySpace should be Host or CUDA");
102 template <
typename Number>
103 struct MemorySpaceData<Number, Host>
121 std::unique_ptr<Number[], std::function<void(Number *)>>
values;
127 std::vector<ArrayView<const Number>>
values_sm;
132 template <
typename Number>
134 swap(MemorySpaceData<Number, Host> &u, MemorySpaceData<Number, Host> &v)
141# ifdef DEAL_II_COMPILER_CUDA_AWARE
143 template <
typename Number>
144 struct MemorySpaceData<Number, CUDA>
154 const cudaError_t cuda_error_code =
157 n_elements *
sizeof(Number),
158 cudaMemcpyDeviceToHost);
165 const cudaError_t cuda_error_code =
168 n_elements *
sizeof(Number),
169 cudaMemcpyHostToDevice);
173 std::unique_ptr<Number[], std::function<void(Number *)>>
values;
174 std::unique_ptr<Number[], void (*)(Number *)>
values_dev;
179 std::vector<ArrayView<const Number>>
values_sm;
184 template <
typename Number>
186 swap(MemorySpaceData<Number, CUDA> &u, MemorySpaceData<Number, CUDA> &v)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define AssertCuda(error_code)
void swap(MemorySpaceData< Number, MemorySpace > &, MemorySpaceData< Number, MemorySpace > &)
VectorType::value_type * begin(VectorType &V)
void delete_device_data(Number *device_ptr) noexcept
void copy(const T *begin, const T *end, U *dest)
std::unique_ptr< Number[]> values_dev
std::unique_ptr< Number[], std::function< void(Number *)> > values
void copy_from(Number *begin, std::size_t n_elements)
void copy_to(Number *begin, std::size_t n_elements)
std::vector< ArrayView< const Number > > values_sm