17 #ifndef vtkPPixelTransfer_h
18 #define vtkPPixelTransfer_h
25 #include "vtkRenderingParallelLICModule.h"
26 #include "vtkSetGet.h"
35 VTK_ABI_NAMESPACE_BEGIN
55 , SrcWholeExt(srcWholeExt)
58 , DestWholeExt(destWholeExt)
73 , SrcWholeExt(srcWholeExt)
76 , DestWholeExt(destWholeExt)
91 , SrcWholeExt(wholeExt)
94 , DestWholeExt(wholeExt)
126 , SrcWholeExt(srcWholeExt)
127 , SrcExt(srcWholeExt)
129 , DestWholeExt(destWholeExt)
130 , DestExt(destWholeExt)
145 , SrcWholeExt(srcWholeExt)
148 , DestWholeExt(destWholeExt)
174 bool Sender(
int rank)
const {
return (this->SrcRank == rank); }
175 bool Receiver(
int rank)
const {
return (this->DestRank == rank); }
176 bool Local(
int rank)
const {
return (this->Sender(rank) && this->Receiver(rank)); }
239 template <
typename SOURCE_TYPE,
typename DEST_TYPE>
240 int Execute(MPI_Comm comm,
int rank,
int nComps, SOURCE_TYPE* srcData, DEST_TYPE* destData,
241 std::vector<MPI_Request>& reqs, std::deque<MPI_Datatype>& types,
int tag);
247 int Execute(MPI_Comm comm,
int rank,
int nComps,
int srcType,
void* srcData,
int destType,
248 void* destData, std::vector<MPI_Request>& reqs, std::deque<MPI_Datatype>& types,
int tag);
253 int Blit(
int nComps,
int srcType,
void* srcData,
int destType,
void* destData);
257 template <
typename SOURCE_TYPE>
258 int Execute(MPI_Comm comm,
int rank,
int nComps, SOURCE_TYPE* srcData,
int destType,
259 void* destData, std::vector<MPI_Request>& reqs, std::deque<MPI_Datatype>& types,
int tag);
273 template <
typename SOURCE_TYPE>
275 int destType,
void* destData, std::vector<MPI_Request>& reqs, std::deque<MPI_Datatype>& types,
282 return this->
Execute(comm, rank, nComps, srcData, (VTK_TT*)destData, reqs, types, tag));
288 template <
typename SOURCE_TYPE,
typename DEST_TYPE>
290 DEST_TYPE* destData, std::vector<MPI_Request>& reqs, std::deque<MPI_Datatype>& types,
int tag)
293 if ((comm == MPI_COMM_NULL) || (this->
Local(rank)))
297 this->DestExt, nComps, srcData, nComps, destData);
300 if (rank == this->DestRank)
303 if (destData ==
nullptr)
308 MPI_Datatype subarray;
309 iErr = vtkMPIPixelViewNew<DEST_TYPE>(this->DestWholeExt, this->DestExt, nComps, subarray);
315 if (this->UseBlockingRecv)
318 iErr = MPI_Recv(destData, 1, subarray, this->SrcRank, tag, comm, &stat);
322 reqs.push_back(MPI_REQUEST_NULL);
323 iErr = MPI_Irecv(destData, 1, subarray, this->SrcRank, tag, comm, &reqs.back());
326 #define HOLD_RECV_TYPES
327 #ifdef HOLD_RECV_YPES
328 types.push_back(subarray);
330 MPI_Type_free(&subarray);
339 if (rank == this->SrcRank)
342 if (srcData ==
nullptr)
347 MPI_Datatype subarray;
348 iErr = vtkMPIPixelViewNew<SOURCE_TYPE>(this->SrcWholeExt, this->SrcExt, nComps, subarray);
354 if (this->UseBlockingSend)
356 iErr = MPI_Ssend(srcData, 1, subarray, this->DestRank, tag, comm);
361 iErr = MPI_Isend(srcData, 1, subarray, this->DestRank, tag, comm, &req);
362 #define SAVE_SEND_REQS
363 #ifdef SAVE_SEND_REQS
366 MPI_Request_free(&req);
370 #define HOLD_SEND_TYPES
371 #ifdef HOLD_SEND_TYPES
372 types.push_back(subarray);
374 MPI_Type_free(&subarray);
386 VTKRENDERINGPARALLELLIC_EXPORT
389 VTK_ABI_NAMESPACE_END
vtkPixelExtent & GetSourceExtent()
void SetUseBlockingSend(int val)
Enable/diasable non-blocking communication.
vtkPPixelTransfer(int srcRank, int destRank, const vtkPixelExtent &ext, int id=0)
Initialize a transaction from sub extent of source to sub extent of dest, both the whole and the subs...
const vtkPixelExtent & GetDestinationExtent() const
void SetDestinationRank(int rank)
int GetSourceRank() const
void SetSourceWholeExtent(vtkPixelExtent &srcExt)
Set/Get the source extent.
vtkPixelExtent & GetDestinationWholeExtent()
vtkPPixelTransfer(int srcRank, const vtkPixelExtent &srcWholeExt, const vtkPixelExtent &srcExt, int destRank, const vtkPixelExtent &destWholeExt, const vtkPixelExtent &destExt, int id=0)
Initialize a transaction from sub extent of source to sub extent of dest, where the subsets are diffe...
int GetDestinationRank() const
int GetUseBlockingRecv() const
class to handle inter-process communication of pixel data from non-contiguous regions of a shared ind...
vtkPixelExtent & GetSourceWholeExtent()
void SetUseBlockingRecv(int val)
void SetSourceExtent(vtkPixelExtent &srcExt)
Set/Get the source extent.
vtkPPixelTransfer(int srcRank, int destRank, const vtkPixelExtent &wholeExt, const vtkPixelExtent &targetExt, int id=0)
Initialize a transaction from sub extent of source to sub extent of dest, both the whole and the subs...
int GetTransactionId() const
const vtkPixelExtent & GetSourceExtent() const
static int Blit(const vtkPixelExtent &ext, int nComps, int srcType, void *srcData, int destType, void *destData)
for memory to memory transfers.
const vtkPixelExtent & GetSourceWholeExtent() const
VTKRENDERINGPARALLELLIC_EXPORT ostream & operator<<(std::ostream &os, const vtkPPixelTransfer >)
vtkPPixelTransfer(int srcRank, const vtkPixelExtent &srcWholeExt, const vtkPixelExtent &targetExt, int destRank, const vtkPixelExtent &destWholeExt, int id)
Initialize a transaction from sub extent of source to sub extent of dest, where the subsets are the s...
vtkPPixelTransfer(int srcRank, const vtkPixelExtent &srcWholeExt, int destRank, const vtkPixelExtent &destWholeExt, int id=0)
Initialize a transaction from whole extent of source to whole extent of dest, where source and destin...
bool Sender(int rank) const
Tests to determine a given rank's role in this transaction.
int Execute(MPI_Comm comm, int rank, int nComps, SOURCE_TYPE *srcData, DEST_TYPE *destData, std::vector< MPI_Request > &reqs, std::deque< MPI_Datatype > &types, int tag)
Transfer data from source to destination.
void SetDestinationWholeExtent(vtkPixelExtent &destExt)
Set/get the destination extent.
vtkPPixelTransfer(const vtkPixelExtent &srcWholeExt, const vtkPixelExtent &srcExt, const vtkPixelExtent &destWholeExt, const vtkPixelExtent &destExt)
Initialize a transaction from sub extent of source to sub extent of dest, where the subsets are diffe...
Representation of a cartesian pixel plane and common operations on it.
void SetSourceRank(int rank)
Set/Get the MPI rank of source and destination processes.
bool Local(int rank) const
int GetUseBlockingSend() const
void SetTransactionId(int id)
Set/get the transaction id.
bool Receiver(int rank) const
void SetDestinationExtent(vtkPixelExtent &destExt)
Set/get the destination extent.
const vtkPixelExtent & GetDestinationWholeExtent() const
vtkPixelExtent & GetDestinationExtent()