/usr/include/vtk-6.2/vtkPPixelTransfer.h is in libvtk6-dev 6.2.0+dfsg1-10build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkPPixelTransfer.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPPixelTransfer -- For movement of pixel data described by extents
// .SECTION Description
// class to handle inter-process communication of pixel data from
// non-contiguous regions of a shared index space. For example copying
// a subset of one image to a subset of another. The class can be used
// for purely local(no MPI) non-contigious data transfers by setting
// the source and destination ranks to the same id. In that case
// memcpy is used.
//
// .SECTION See also
// vtkPixelExtent
#ifndef vtkPPixelTransfer_h
#define vtkPPixelTransfer_h
#include "vtkPixelTransfer.h"
#include "vtkRenderingParallelLICModule.h" // for export
#include "vtkSetGet.h" // for macros
#include "vtkPixelExtent.h" // for pixel extent
#include "vtkMPI.h" // for mpi
#include "vtkMPIPixelTT.h" // for type traits
#include "vtkMPIPixelView.h" // for mpi subarrays
// included vtkSystemIncludes.h in the base class.
#include <iostream> // for ostream
#include <vector> // for vector
#include <cstring> // for memcpy
// #define vtkPPixelTransferDEBUG
class VTKRENDERINGPARALLELLIC_EXPORT vtkPPixelTransfer : public vtkPixelTransfer
{
public:
vtkPPixelTransfer()
:
SrcRank(0),
DestRank(0),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
// Description:
// Initialize a transaction from sub extent of source to sub extent
// of dest, where the subsets are different.
vtkPPixelTransfer(
int srcRank,
const vtkPixelExtent &srcWholeExt,
const vtkPixelExtent &srcExt,
int destRank,
const vtkPixelExtent &destWholeExt,
const vtkPixelExtent &destExt,
int id=0)
:
Id(id),
SrcRank(srcRank),
SrcWholeExt(srcWholeExt),
SrcExt(srcExt),
DestRank(destRank),
DestWholeExt(destWholeExt),
DestExt(destExt),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
// Description:
// Initialize a transaction from sub extent of source to sub extent
// of dest, where the subsets are the same.
vtkPPixelTransfer(
int srcRank,
const vtkPixelExtent &srcWholeExt,
const vtkPixelExtent &targetExt,
int destRank,
const vtkPixelExtent &destWholeExt,
int id)
:
Id(id),
SrcRank(srcRank),
SrcWholeExt(srcWholeExt),
SrcExt(targetExt),
DestRank(destRank),
DestWholeExt(destWholeExt),
DestExt(targetExt),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
// Description:
// Initialize a transaction from sub extent of source to sub extent
// of dest, both the whole and the subsets are the same.
vtkPPixelTransfer(
int srcRank,
int destRank,
const vtkPixelExtent &wholeExt,
const vtkPixelExtent &targetExt,
int id=0)
:
Id(id),
SrcRank(srcRank),
SrcWholeExt(wholeExt),
SrcExt(targetExt),
DestRank(destRank),
DestWholeExt(wholeExt),
DestExt(targetExt),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
// Description:
// Initialize a transaction from sub extent of source to sub extent
// of dest, both the whole and the subsets are the same.
vtkPPixelTransfer(
int srcRank,
int destRank,
const vtkPixelExtent &ext,
int id=0)
:
Id(id),
SrcRank(srcRank),
SrcWholeExt(ext),
SrcExt(ext),
DestRank(destRank),
DestWholeExt(ext),
DestExt(ext),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
// Description:
// Initialize a transaction from whole extent of source to whole extent
// of dest, where source and destination have different whole extents.
vtkPPixelTransfer(
int srcRank,
const vtkPixelExtent &srcWholeExt,
int destRank,
const vtkPixelExtent &destWholeExt,
int id=0)
:
Id(id),
SrcRank(srcRank),
SrcWholeExt(srcWholeExt),
SrcExt(srcWholeExt),
DestRank(destRank),
DestWholeExt(destWholeExt),
DestExt(destWholeExt),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
// Description:
// Initialize a transaction from sub extent of source to sub extent
// of dest, where the subsets are different. This is a local
// operation there will be no communication.
vtkPPixelTransfer(
const vtkPixelExtent &srcWholeExt,
const vtkPixelExtent &srcExt,
const vtkPixelExtent &destWholeExt,
const vtkPixelExtent &destExt)
:
Id(0),
SrcRank(0),
SrcWholeExt(srcWholeExt),
SrcExt(srcExt),
DestRank(0),
DestWholeExt(destWholeExt),
DestExt(destExt),
UseBlockingSend(0),
UseBlockingRecv(0)
{}
~vtkPPixelTransfer(){}
// Description:
// Set/Get the MPI rank of source and destination
// processes.
void SetSourceRank(int rank)
{ this->SrcRank=rank; }
int GetSourceRank() const
{ return this->SrcRank; }
void SetDestinationRank(int rank)
{ this->DestRank=rank; }
int GetDestinationRank() const
{ return this->DestRank; }
// Description:
// Tests to determine a given rank's role in this transaction.
// If both Sender and Receiver are true then the operation
// is local and no mpi calls are made.
bool Sender(int rank) const { return (this->SrcRank == rank); }
bool Receiver(int rank) const { return (this->DestRank == rank); }
bool Local(int rank) const
{ return (this->Sender(rank) && this->Receiver(rank)); }
// Description:
// Set/Get the source extent. This is the extent of the
// array that data will be coppied from.
void SetSourceWholeExtent(vtkPixelExtent &srcExt)
{ this->SrcWholeExt=srcExt; }
vtkPixelExtent &GetSourceWholeExtent()
{ return this->SrcWholeExt; }
const vtkPixelExtent &GetSourceWholeExtent() const
{ return this->SrcWholeExt; }
// Description:
// Set/Get the source extent. This is the subset extent in the
// array that data will be coppied from.
void SetSourceExtent(vtkPixelExtent &srcExt)
{ this->SrcExt=srcExt; }
vtkPixelExtent &GetSourceExtent()
{ return this->SrcExt; }
const vtkPixelExtent &GetSourceExtent() const
{ return this->SrcExt; }
// Description:
// Set/get the destination extent. This is the extent
// of array that will recveive the data.
void SetDestinationWholeExtent(vtkPixelExtent &destExt)
{ this->DestWholeExt=destExt; }
vtkPixelExtent &GetDestinationWholeExtent()
{ return this->DestWholeExt; }
const vtkPixelExtent &GetDestinationWholeExtent() const
{ return this->DestWholeExt; }
// Description:
// Set/get the destination extent. This is the subset extent
// in the array that will recveive the data.
void SetDestinationExtent(vtkPixelExtent &destExt)
{ this->DestExt=destExt; }
vtkPixelExtent &GetDestinationExtent()
{ return this->DestExt; }
const vtkPixelExtent &GetDestinationExtent() const
{ return this->DestExt; }
// Description:
// Set/get the transaction id.
void SetTransactionId(int id)
{ this->Id=id; }
int GetTransactionId() const
{ return this->Id; }
// Description:
// Enable/diasable non-blocking communication
void SetUseBlockingSend(int val)
{ this->UseBlockingSend=val; }
int GetUseBlockingSend() const
{ return this->UseBlockingSend; }
void SetUseBlockingRecv(int val)
{ this->UseBlockingRecv=val; }
int GetUseBlockingRecv() const
{ return this->UseBlockingRecv; }
// Description:
// Transfer data from source to destination.
template<typename SOURCE_TYPE, typename DEST_TYPE>
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);
// Description:
// Transfer data from source to destination. convenience for working
// with vtk data type enum rather than c types.
int Execute(
MPI_Comm comm,
int rank,
int nComps,
int srcType,
void *srcData,
int destType,
void *destData,
std::vector<MPI_Request> &reqs,
std::deque<MPI_Datatype> &types,
int tag);
// Description:
// Block transfer for local memory to memory transfers, without using mpi.
int Blit(
int nComps,
int srcType,
void *srcData,
int destType,
void *destData);
private:
// distpatch helper for vtk data type enum
template<typename SOURCE_TYPE>
int Execute(
MPI_Comm comm,
int rank,
int nComps,
SOURCE_TYPE *srcData,
int destType,
void *destData,
std::vector<MPI_Request> &reqs,
std::deque<MPI_Datatype> &types,
int tag);
private:
int Id; // transaction id
int SrcRank; // rank who owns source memory
vtkPixelExtent SrcWholeExt; // source extent
vtkPixelExtent SrcExt; // source subset to transfer
int DestRank; // rank who owns destination memory
vtkPixelExtent DestWholeExt; // destination extent
vtkPixelExtent DestExt; // destination subset
int UseBlockingSend; // controls for non-blocking comm
int UseBlockingRecv;
};
//-----------------------------------------------------------------------------
template<typename SOURCE_TYPE>
int vtkPPixelTransfer::Execute(
MPI_Comm comm,
int rank,
int nComps,
SOURCE_TYPE *srcData,
int destType,
void *destData,
std::vector<MPI_Request> &reqs,
std::deque<MPI_Datatype> &types,
int tag)
{
// second layer of dispatch
switch(destType)
{
vtkTemplateMacro(
return this->Execute(
comm,
rank,
nComps,
srcData,
(VTK_TT*)destData,
reqs,
types,
tag));
}
return 0;
}
//-----------------------------------------------------------------------------
template<typename SOURCE_TYPE, typename DEST_TYPE>
int vtkPPixelTransfer::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)
{
int iErr = 0;
if ((comm == MPI_COMM_NULL) || (this->Local(rank)))
{
// transaction is local, bypass mpi in favor of memcpy
return vtkPixelTransfer::Blit(
this->SrcWholeExt,
this->SrcExt,
this->DestWholeExt,
this->DestExt,
nComps,
srcData,
nComps,
destData);
}
if (rank == this->DestRank)
{
// use mpi to receive the data
if (destData == NULL)
{
return -1;
}
MPI_Datatype subarray;
iErr = vtkMPIPixelViewNew<DEST_TYPE>(
this->DestWholeExt,
this->DestExt,
nComps,
subarray);
if (iErr)
{
return -4;
}
if (this->UseBlockingRecv)
{
MPI_Status stat;
iErr = MPI_Recv(
destData,
1,
subarray,
this->SrcRank,
tag,
comm,
&stat);
}
else
{
reqs.push_back(MPI_REQUEST_NULL);
iErr = MPI_Irecv(
destData,
1,
subarray,
this->SrcRank,
tag,
comm,
&reqs.back());
}
#define HOLD_RECV_TYPES
#ifdef HOLD_RECV_YPES
types.push_back(subarray);
#else
MPI_Type_free(&subarray);
#endif
if (iErr)
{
return -5;
}
}
if (rank == this->SrcRank)
{
// use mpi to send the data
if (srcData == NULL)
{
return -1;
}
MPI_Datatype subarray;
iErr = vtkMPIPixelViewNew<SOURCE_TYPE>(
this->SrcWholeExt,
this->SrcExt,
nComps,
subarray);
if (iErr)
{
return -2;
}
if (this->UseBlockingSend)
{
iErr = MPI_Ssend(
srcData,
1,
subarray,
this->DestRank,
tag,
comm);
}
else
{
MPI_Request req;
iErr = MPI_Isend(
srcData,
1,
subarray,
this->DestRank,
tag,
comm,
&req);
#define SAVE_SEND_REQS
#ifdef SAVE_SEND_REQS
reqs.push_back(req);
#else
MPI_Request_free(&req);
#endif
}
#define HOLD_SEND_TYPES
#ifdef HOLD_SEND_TYPES
types.push_back(subarray);
#else
MPI_Type_free(&subarray);
#endif
if (iErr)
{
return -3;
}
}
return iErr;
}
ostream &operator<<(std::ostream &os, const vtkPPixelTransfer >);
#endif
// VTK-HeaderTest-Exclude: vtkPPixelTransfer.h
|