1#ifndef PSCF_HOST_RECV_ARRAY_CU_H
2#define PSCF_HOST_RECV_ARRAY_CU_H
11#include <pscf/backend/cuda/CUT.h>
12#include <util/containers/ConstArray.h>
16 template <
typename Data>
class Array;
94 template <
typename Data>
254 template <
class Archive>
255 void serialize(Archive& ar,
const unsigned int version);
273 extern template class HostRecvArray<cudaReal,CUT>;
274 extern template class HostRecvArray<cudaComplex,CUT>;
278#include "BackendArray.h"
279#include "cudaErrorCheck.h"
280#include <util/containers/Array.h>
281#include <util/misc/Memory.h>
283#include <cuda_runtime.h>
290 template <
typename Data>
300 template <
typename Data>
309 template <
typename Data>
317 std::cout <<
"Exception in HostRecvArray destructor";
326 template <
typename Data>
331 if (
dynamic_cast< Array<Data>*
>(
this) == &other)
return *
this;
358 template <
typename Data>
365 const int n = other.capacity();
381 cudaMemcpyDeviceToHost)
390 template <
typename Data>
404 other.cArray() + beginId,
406 cudaMemcpyDeviceToHost)
414 template <
typename Data>
418 UTIL_THROW(
"Attempt to allocate with capacity <= 0");
421 UTIL_THROW(
"Attempt to re-allocate a HostRecvArray");
430 template <
typename Data>
444 template <
typename Data>
448 if (capacity == capacity_)
return;
456 capacity_ = capacity;
463 template <
typename Data>
464 template <
class Archive>
466 const unsigned int version)
469 if (Archive::is_saving()) {
473 if (Archive::is_loading()) {
480 UTIL_THROW(
"Inconsistent HostRecvArray capacities");
Backend identifier class for the GPU-enabled CUDA backend.
HostRecvArray()=default
Default constructor.
CUT BackendIdClass
Alias for backend identifier class.
Data ValueType
Alias for data type of each array element.
void dissociate()
Release this array after finishing all reading.
void copySlice(BackendArray< Data, CUT > const &other, int beginId)
Copy a slice of data from a larger BackendArray into this array.
void allocate(int capacity)
Allocate the underlying C array.
void deallocate()
Deallocate the underlying C array.
Array container class template.
int capacity() const
Return allocated size.
bool isAllocated() const
Does this array have associated data?
Read-only array container class template.
bool isAllocated() const
Does this array have associated data?
int capacity_
Allocated size of the data_ array.
int capacity() const
Return allocated size of this array.
Data * data_
Pointer to an array of Data elements.
static void deallocate(Data *&ptr, size_t size)
Deallocate a C++ array.
static void reallocate(Data *&ptr, size_t oldSize, size_t newSize)
Reallocate a C++ array.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
PSCF package top-level namespace.
Utility classes for scientific computation.