Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

template<class ArrayT>
void Impala::Core::Array::Pattern::PxBorderExchange ( ArrayT *  a,
int  divide,
int  extent 
) [inline]

Definition at line 1445 of file PxDistribution.h.

References ArrayBD(), ArrayBH(), ArrayBW(), ArrayCD(), ArrayCH(), ArrayCW(), ArrayD(), ArrayH(), ArrayPB(), ArrayW(), BOR_TAG, PxMyBackCPU(), PxMyDownCPU(), PxMyFrontCPU(), PxMyLeftCPU(), PxMyRightCPU(), PxMyUpCPU(), XY_PLANE, XZ_PLANE, and YZ_PLANE.

Referenced by PxFuncBorderConstant2d(), PxFuncBorderMirror2d(), and PxFuncBorderPropagateNormalized2d().

01446 {
01447     int tw = ArrayW(a),  th = ArrayH(a),  td = ArrayD(a);
01448     int bw = ArrayBW(a), bh = ArrayBH(a), bd = ArrayBD(a);
01449     int cw = ArrayCW(a), ch = ArrayCH(a), cd = ArrayCD(a);
01450 
01451     typedef typename ArrayT::StorType storT;
01452     storT *ptr1, *ptr2, *ptr3, *ptr4;
01453     int part1, part2, xSize, ySize, zSize;
01454     int eSize = ArrayT::ElemSize();
01455 
01456     /*** Determine send/recv partners and buffer pointers & sizes ***/
01457 
01458     switch (divide) {
01459         case YZ_PLANE:                              // left <--> right
01460             part1 = PxMyLeftCPU();
01461             part2 = PxMyRightCPU();
01462             xSize = extent;
01463             ySize = ch;
01464             zSize = cd;
01465             ptr1 = ArrayPB(a) + (bd*tw*th+bh*tw+bw) * eSize;
01466             ptr2 = ArrayPB(a) + (bd*tw*th+bh*tw+bw+cw) * eSize;
01467             ptr3 = ArrayPB(a) + (bd*tw*th+bh*tw+bw+cw-xSize) * eSize;
01468             ptr4 = ArrayPB(a) + (bd*tw*th+bh*tw+bw-xSize) * eSize;
01469             break;
01470 
01471         case XZ_PLANE:                              // top <--> bottom
01472             part1 = PxMyUpCPU();
01473             part2 = PxMyDownCPU();
01474             xSize = tw;
01475             ySize = extent;
01476             zSize = cd;
01477             ptr1 = ArrayPB(a) + (bd*tw*th + bh*tw) * eSize;
01478             ptr2 = ArrayPB(a) + (bd*tw*th + (bh+ch)*tw) * eSize;
01479             ptr3 = ArrayPB(a) + (bd*tw*th + (bh+ch-ySize)*tw) * eSize;
01480             ptr4 = ArrayPB(a) + (bd*tw*th + (bh-ySize)*tw) * eSize;
01481             break;
01482 
01483         case XY_PLANE:                              // front <--> back
01484             part1 = PxMyFrontCPU();
01485             part2 = PxMyBackCPU();
01486             xSize = tw;
01487             ySize = th;
01488             zSize = extent;
01489             ptr1 = ArrayPB(a) + (bd*tw*th) * eSize;
01490             ptr2 = ArrayPB(a) + ((bd+cd)*tw*th) * eSize;
01491             ptr3 = ArrayPB(a) + ((bd+cd-zSize)*tw*th) * eSize;
01492             ptr4 = ArrayPB(a) + ((bd-zSize)*tw*th) * eSize;
01493             break;
01494 
01495         default:
01496             return;
01497     }
01498 
01499     if ((xSize == 0) || (ySize == 0) || (zSize == 0)) {
01500         return;
01501     }
01502 
01503     MPI_Datatype elem, blk2d, blk3d;
01504     MPI_Status stat;
01505     int sSize = eSize*sizeof(typename ArrayT::StorType);
01506     MPI_Type_contiguous(sSize, MPI_BYTE, &elem);
01507     MPI_Type_vector(ySize, xSize, tw, elem, &blk2d);
01508     MPI_Type_hvector(zSize, 1, tw*th*sSize, blk2d, &blk3d);
01509     MPI_Type_commit(&blk3d);
01510 
01511     /*** Send to first partner and receive from second partner ***/
01512 
01513     if (part1 != -1) {
01514         MPI_Send(ptr1, 1, blk3d, part1, BOR_TAG, MPI_COMM_WORLD);
01515     }
01516     if (part2 != -1) {
01517         MPI_Recv(ptr2, 1, blk3d, part2, BOR_TAG, MPI_COMM_WORLD, &stat);
01518 
01519     /*** Send to second partner and receive from first partner ***/
01520 
01521         MPI_Send(ptr3, 1, blk3d, part2, BOR_TAG, MPI_COMM_WORLD);
01522     }
01523     if (part1 != -1) {
01524         MPI_Recv(ptr4, 1, blk3d, part1, BOR_TAG, MPI_COMM_WORLD, &stat);
01525     }
01526 
01527     MPI_Type_free(&blk3d);
01528     MPI_Type_free(&blk2d);
01529     MPI_Type_free(&elem);
01530 }

Here is the call graph for this function:


Generated on Fri Mar 19 11:02:50 2010 for ImpalaSrc by  doxygen 1.5.1