1#ifndef PSCF_HOST_D_ARRAY_H
2#define PSCF_HOST_D_ARRAY_H
11#include <util/containers/DArray.h>
39 template <
typename Data>
123#include "DeviceArray.h"
124#include "cudaErrorCheck.h"
126#include <cuda_runtime.h>
133 template <
typename Data>
141 template <
typename Data>
149 template <
typename Data>
155 UTIL_THROW(
"RHS DeviceArray<Data> must be allocated.");
161 cudaMemcpyDeviceToHost) );
167 template <
typename Data>
174 template <
typename Data>
180 UTIL_THROW(
"RHS DeviceArray<Data> must be allocated.");
190 UTIL_THROW(
"Cannot assign arrays of unequal capacity");
196 cudaMemcpyDeviceToHost) );
204 template <
typename Data>
210 UTIL_THROW(
"RHS DeviceArray<Data> must be allocated.");
215 UTIL_THROW(
"LHS HostDArray<Data> must be allocated.");
220 UTIL_THROW(
"Slice must not exceed the capacity of device array.");
227 cudaMemcpyDeviceToHost) );
Dynamic array on the GPU device with aligned data.
bool isAllocated() const
Return true if the array has allocated data, false otherwise.
int capacity() const
Return array capacity.
Data * cArray()
Return pointer to underlying C array.
Template for dynamic array stored in host CPU memory.
void copySlice(DeviceArray< Data > const &other, int beginId)
Copy a slice of the data from a larger DeviceArray into this array.
HostDArray()
Default constructor.
Data ValueType
Data type of each element.
HostDArray(int capacity)
Allocating constructor.
HostDArray(DeviceArray< Data > const &other)
Copy constructor (copies from device to host).
virtual ~HostDArray()
Destructor.
int capacity() const
Return allocated size.
void allocate(int capacity)
Allocate the underlying C array.
DArray()
Default constructor.
bool isAllocated() const
Return true if this DArray has been allocated, false otherwise.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
PSCF package top-level namespace.