20 #ifndef JDFTX_ELECTRONIC_MANAGEDMEMORY_H 21 #define JDFTX_ELECTRONIC_MANAGEDMEMORY_H 23 #include <electronic/common.h> 44 size_t nData()
const {
return nElements; }
60 inline const complex* dataPref()
const {
return data(); }
64 void send(
int dest,
int tag=0)
const;
65 void recv(
int src,
int tag=0);
66 void bcast(
int root=0);
67 void allReduce(MPIUtil::ReduceOp op,
bool safeMode=
false,
bool ignoreComplexCheck=
false);
69 void write(
const char *fname)
const;
70 void writea(
const char *fname)
const;
71 void write(FILE *filep)
const;
72 void read(
const char *fname);
73 void read(FILE *filep);
78 void dump(
const char* fname,
bool realPartOnly)
const;
84 void memInit(
string category,
size_t nElem,
bool onGpu=
false);
109 #endif // JDFTX_ELECTRONIC_MANAGEDMEMORY_H void memFree()
Free memory.
size_t nData() const
number of data points
Definition: ManagedMemory.h:44
void allReduce(MPIUtil::ReduceOp op, bool safeMode=false, bool ignoreComplexCheck=false)
apply all-to-all reduction (see MPIUtil::allReduce). Optionally ignore unsupported operations for com...
void memInit(string category, size_t nElem, bool onGpu=false)
Allocate memory.
void write_real(const char *fname) const
binary write real-parts to file
void send(int dest, int tag=0) const
send to another process
void read(const char *fname)
binary read from a file
Base class for managed-memory objects (that could potentially live on GPUs as well) ...
Definition: ManagedMemory.h:26
void dump(const char *fname, bool realPartOnly) const
write as complex or real-part alone and report discarded imaginary part, if any
complex * dataGpu()
Get a gpu data pointer (must be called from GPU owner thread)
bool isOnGpu() const
Check where the data is (for #ifdef simplicity exposed even when no GPU_ENABLED)
Definition: ManagedMemory.h:46
static void reportUsage()
print memory usage report
ManagedMemory()
Initialize a valid state, but don't allocate anything.
void memMove(ManagedMemory &&)
Steal the other object's data (used for move constructors/assignment)
void zero()
set all elements to zero
void read_real(const char *fname)
binary read real-part from file, setting imaginary parts to 0
void writea(const char *fname) const
binary-append to a file
complex * data()
Return a pointer to the actual data Return a CPU pointer to the actual data, will move data from GPU ...
void write(const char *fname) const
binary-write to a file
void bcast(int root=0)
synchronize across processes (using value on specified root process)
Complex number (need to define our own because we need operators for gpu code as well) ...
Definition: scalar.h:49
void axpy(double alpha, const Tptr &X, Tptr &Y)
Generic axpy for complex data types (Note: null pointers are treated as zero)
Definition: Operators.h:158
void recv(int src, int tag=0)
receive from another process
double nrm2(const Tptr &X)
Definition: Operators.h:199