8#include "MemoryOArchive.h"
9#include <util/misc/Memory.h>
35 if (buffer_ && ownsData_) {
37 Memory::deallocate<Byte>(buffer_, capacity_ +
sizeof(
size_t));
50 Memory::allocate<Byte>(buffer_,
capacity +
sizeof(
size_t));
51 begin_ = buffer_ +
sizeof(size_t);
76 int comm_size = comm.Get_size();
77 int myRank = comm.Get_rank();
80 if (dest > comm_size - 1 || dest < 0) {
87 size_t sendBytes = cursor_ - buffer_;
88 size_t* sizePtr = (
size_t*)buffer_;
90 comm.Send(buffer_, sendBytes, MPI::UNSIGNED_CHAR, dest, 5);
99 int comm_size = comm.Get_size();
100 int myRank = comm.Get_rank();
103 if (dest > comm_size - 1 || dest < 0) {
106 if (dest == myRank) {
107 UTIL_THROW(
"Source and desination identical");
110 size_t sendBytes = cursor_ - buffer_;
111 size_t* sizePtr = (
size_t*)buffer_;
112 *sizePtr = sendBytes;
113 req = comm.Isend(buffer_, sendBytes, MPI::UNSIGNED_CHAR, dest, 5);
virtual ~MemoryOArchive()
Destructor.
void iSend(MPI::Intracomm &comm, MPI::Request &req, int dest)
Send packed data via MPI (non-blocking)
virtual void allocate(size_t capacity)
Allocate memory.
bool isAllocated() const
Has memory been allocated?
Byte * begin() const
Return pointer to beginning of block.
size_t capacity() const
Return capacity in Bytes.
MemoryOArchive()
Constructor.
void send(MPI::Intracomm &comm, int dest)
Send packed data via MPI.
void clear()
Resets the cursor to the beginning.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.