#include <ManagedMemory.h>
Public Member Functions | |
void | init (size_t size, bool onGpu=false) |
calls memInit with category "misc" | |
void | free () |
ManagedArray (const T *ptr=0, size_t N=0) | |
optionally initialize N elements from a pointer | |
ManagedArray (const std::vector< T > &) | |
initialize from an std::vector | |
ManagedArray (const ManagedArray &) | |
copy-constructor | |
ManagedArray (ManagedArray &&) | |
move-constructor | |
ManagedArray & | operator= (const ManagedArray &) |
copy-assignment | |
ManagedArray & | operator= (ManagedArray &&) |
move-assignment | |
Public Member Functions inherited from ManagedMemory< T > | |
T * | data () |
Return a pointer to the actual data Return a CPU pointer to the actual data, will move data from GPU to CPU if necessary In GPU mode, care must be taken when calling this from multiple cpu threads Only the "GPU Owner" thread may call this when the data is actually on the GPU. Ideally call once from main thread to get data onto the cpu before launching other cpu threads. | |
const T * | data () const |
Return a const pointer to the actual data Return a CPU pointer to the actual data, will move data from GPU to CPU if necessary In GPU mode, care must be taken when calling this from multiple cpu threads Only the "GPU Owner" thread may call this when the data is actually on the GPU. Ideally call once from main thread to get data onto the cpu before launching other cpu threads. | |
T * | dataGpu () |
Get a GPU data pointer (must be called from GPU owner thread) | |
const T * | dataGpu () const |
Get a const GPU data pointer (must be called from GPU owner thread) | |
size_t | nData () const |
number of data points | |
bool | isOnGpu () const |
Check where the data is (for #ifdef simplicity exposed even when no GPU_ENABLED) | |
T * | begin () |
pointer to start of array | |
const T * | begin () const |
const pointer to start of array | |
const T * | cbegin () const |
const pointer to start of array | |
T * | end () |
pointer just past end of array | |
const T * | end () const |
const pointer just past end of array | |
const T * | cend () const |
const pointer just past end of array | |
T * | dataPref () |
const T * | dataPref () const |
void | read (const char *fname) |
binary read from a file | |
void | read (FILE *filep) |
binary read from a stream | |
void | write (const char *fname) const |
binary-write to a file | |
void | write (FILE *filep) const |
binary-write toa stream | |
void | read_real (const char *fname) |
binary read real-part from file, setting imaginary parts to 0 | |
void | read_real (FILE *filep) |
binary read real-part from stream, setting imaginary parts to 0 | |
void | write_real (const char *fname) const |
binary write real-parts to file | |
void | write_real (FILE *filep) const |
binary write real-parts to stream | |
void | dump (const char *fname, bool realPartOnly) const |
write as complex or real-part alone and report discarded imaginary part, if any | |
void | zero () |
set all elements to zero | |
Additional Inherited Members | |
Protected Member Functions inherited from ManagedMemory< T > | |
ManagedMemory () | |
Initialize a valid state, but don't allocate anything. | |
void | memFree () |
Free memory. | |
void | memInit (string category, size_t nElem, bool onGpu=false) |
Allocate memory. | |
void | memMove (ManagedMemory< T > &&) |
Steal the other object's data (used for move constructors/assignment) | |
General ManagedMemory class for one-off use as a CPU <-> GPU array. For each commonly-used physical object, derive directly from ManagedMemory and implement operators; do not use this wrapper.