NAMD
Public Member Functions | List of all members
PmeYPencil Class Reference
Inheritance diagram for PmeYPencil:
PmePencil< CBase_PmeYPencil >

Public Member Functions

PmeYPencil_SDAG_CODE PmeYPencil ()
 
 PmeYPencil (CkMigrateMessage *)
 
void fft_init ()
 
void recv_trans (const PmeTransMsg *)
 
void forward_fft ()
 
void forward_subset_fft (int fromIdx, int toIdx)
 
void send_trans ()
 
void send_subset_trans (int fromIdx, int toIdx)
 
void recv_untrans (const PmeUntransMsg *)
 
void node_process_trans (PmeTransMsg *)
 
void recvNodeAck (PmeAckMsg *)
 
void node_process_untrans (PmeUntransMsg *)
 
void backward_fft ()
 
void backward_subset_fft (int fromIdx, int toIdx)
 
void send_untrans ()
 
void send_subset_untrans (int fromIdx, int toIdx)
 
- Public Member Functions inherited from PmePencil< CBase_PmeYPencil >
 PmePencil ()
 
 ~PmePencil ()
 
void base_init (PmePencilInitMsg *msg)
 
void order_init (int nBlocks)
 

Additional Inherited Members

- Public Types inherited from PmePencil< CBase_PmeYPencil >
typedef int AtomicInt
 
- Public Attributes inherited from PmePencil< CBase_PmeYPencil >
PmePencilInitMsgData initdata
 
Lattice lattice
 
PmeReduction evir
 
int sequence
 
AtomicInt imsg
 
AtomicInt imsgb
 
int hasData
 
int offload
 
float * data
 
float * work
 
int * send_order
 
int * needs_reply
 

Detailed Description

Definition at line 4635 of file ComputePme.C.

Constructor & Destructor Documentation

PmeYPencil_SDAG_CODE PmeYPencil::PmeYPencil ( )
inline

Definition at line 4638 of file ComputePme.C.

References PmePencil< CBase_PmeYPencil >::imsg, and PmePencil< CBase_PmeYPencil >::imsgb.

4638 { __sdag_init(); setMigratable(false); imsg=imsgb=0;}
PmeYPencil::PmeYPencil ( CkMigrateMessage *  )
inline

Definition at line 4639 of file ComputePme.C.

4639 { __sdag_init(); }

Member Function Documentation

void PmeYPencil::backward_fft ( )

Definition at line 5932 of file ComputePme.C.

References CKLOOP_CTRL_PME_BACKWARDFFT, PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, Node::Object(), PmeYPencilBackwardFFT(), Node::simParameters, SimParameters::useCkLoop, PmePencil< CBase_PmeYPencil >::work, PmePencilInitMsgData::xBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_untrans().

5932  {
5933 #ifdef NAMD_FFTW
5934 #ifdef MANUAL_DEBUG_FFTW3
5935  dumpMatrixFloat3("bw_y_b", data, nx, initdata.grid.K2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
5936 #endif
5937 
5938 #ifdef NAMD_FFTW_3
5939 #if CMK_SMP && USE_CKLOOP
5940  int useCkLoop = Node::Object()->simParameters->useCkLoop;
5941  if(useCkLoop>=CKLOOP_CTRL_PME_BACKWARDFFT
5942  && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
5943  CkLoop_Parallelize(PmeYPencilBackwardFFT, 1, (void *)this, CkMyNodeSize(), 0, nx-1); //sync
5944  return;
5945  }
5946 #endif
5947  //the above is a transformation of the following loop using CkLoop
5948  for ( int i=0; i<nx; ++i ) {
5949 #if CMK_BLUEGENEL
5950  CmiNetworkProgress();
5951 #endif
5952  fftwf_execute_dft(backward_plan,
5953  ((fftwf_complex *) data) + i * nz * initdata.grid.K2,
5954  ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
5955  }
5956 #else
5957  for ( int i=0; i<nx; ++i ) {
5958 #if CMK_BLUEGENEL
5959  CmiNetworkProgress();
5960 #endif
5961  fftw(backward_plan, nz,
5962  ((fftw_complex *) data) + i * nz * initdata.grid.K2,
5963  nz, 1, (fftw_complex *) work, 1, 0);
5964  }
5965 #endif
5966 
5967 #ifdef MANUAL_DEBUG_FFTW3
5968  dumpMatrixFloat3("bw_y_a", data, nx, initdata.grid.K2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
5969 #endif
5970 
5971 #endif
5972 }
static Node * Object()
Definition: Node.h:86
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
SimParameters * simParameters
Definition: Node.h:178
static void PmeYPencilBackwardFFT(int first, int last, void *result, int paraNum, void *param)
Definition: ComputePme.C:5915
#define CKLOOP_CTRL_PME_BACKWARDFFT
Definition: SimParameters.h:97
void PmeYPencil::backward_subset_fft ( int  fromIdx,
int  toIdx 
)

Definition at line 5920 of file ComputePme.C.

References PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, and PmeGrid::K2.

Referenced by PmeYPencilBackwardFFT().

5920  {
5921 #ifdef NAMD_FFTW
5922 #ifdef NAMD_FFTW_3
5923  for(int i=fromIdx; i<=toIdx; i++){
5924  fftwf_execute_dft(backward_plan,
5925  ((fftwf_complex *) data) + i * nz * initdata.grid.K2,
5926  ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
5927  }
5928 #endif
5929 #endif
5930 }
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
void PmeYPencil::fft_init ( )

Definition at line 4865 of file ComputePme.C.

References PmeGrid::block1, PmeGrid::block3, PmePencil< CBase_PmeYPencil >::data, PmeGrid::dim2, PmeGrid::dim3, PmePencil< CBase_PmeYPencil >::evir, ComputePmeMgr::fftw_plan_lock, SimParameters::FFTWEstimate, fftwf_malloc, SimParameters::FFTWPatient, PmePencilInitMsgData::grid, if(), PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K1, PmeGrid::K2, NAMD_die(), PmePencil< CBase_PmeYPencil >::order_init(), PmePencilInitMsgData::pmeNodeProxy, Node::simParameters, PmePencil< CBase_PmeYPencil >::work, and PmePencilInitMsgData::yBlocks.

4865  {
4866  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
4867  Node *node = nd.ckLocalBranch();
4869 
4870 #if USE_NODE_PAR_RECEIVE
4871  ((NodePmeMgr *)CkLocalNodeBranch(initdata.pmeNodeProxy))->registerYPencil(thisIndex,this);
4872 #endif
4873 
4874  int K1 = initdata.grid.K1;
4875  int K2 = initdata.grid.K2;
4876  int dim2 = initdata.grid.dim2;
4877  int dim3 = initdata.grid.dim3;
4878  int block1 = initdata.grid.block1;
4879  int block3 = initdata.grid.block3;
4880 
4881  nx = block1;
4882  if ( (thisIndex.x + 1) * block1 > K1 ) nx = K1 - thisIndex.x * block1;
4883  nz = block3;
4884  if ( (thisIndex.z+1)*block3 > dim3/2 ) nz = dim3/2 - thisIndex.z*block3;
4885 
4886 #ifdef NAMD_FFTW
4888 
4889  data = (float *) fftwf_malloc( sizeof(float) * nx*dim2*nz*2);
4890  work = new float[2*K2];
4891 
4893 
4894 #ifdef NAMD_FFTW_3
4895  /* need array of sizes for the dimensions */
4896  /* ideally this should be implementable as a single multidimensional
4897  * plan, but that has proven tricky to implement, so we maintain the
4898  * loop of 1d plan executions. */
4899  int sizeLines=nz;
4900  int planLineSizes[1];
4901  planLineSizes[0]=K2;
4902  int fftwFlags = simParams->FFTWPatient ? FFTW_PATIENT : simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE ;
4903  forward_plan = fftwf_plan_many_dft(1, planLineSizes, sizeLines,
4904  (fftwf_complex *) data, NULL, sizeLines, 1,
4905  (fftwf_complex *) data, NULL, sizeLines, 1,
4906  FFTW_FORWARD,
4907  fftwFlags);
4908  backward_plan = fftwf_plan_many_dft(1, planLineSizes, sizeLines,
4909  (fftwf_complex *) data, NULL, sizeLines, 1,
4910  (fftwf_complex *) data, NULL, sizeLines, 1,
4911  FFTW_BACKWARD,
4912  fftwFlags);
4913  CkAssert(forward_plan != NULL);
4914  CkAssert(backward_plan != NULL);
4915 #else
4916  forward_plan = fftw_create_plan_specific(K2, FFTW_FORWARD,
4917  ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
4918  | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
4919  nz, (fftw_complex *) work, 1);
4920  backward_plan = fftw_create_plan_specific(K2, FFTW_BACKWARD,
4921  ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
4922  | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
4923  nz, (fftw_complex *) work, 1);
4924 #endif
4925  CmiUnlock(ComputePmeMgr::fftw_plan_lock);
4926 #else
4927  NAMD_die("Sorry, FFTW must be compiled in to use PME.");
4928 #endif
4929 
4930 #if USE_NODE_PAR_RECEIVE
4931  evir = 0;
4932  CmiMemoryWriteFence();
4933 #endif
4934 }
int dim2
Definition: PmeBase.h:19
static CmiNodeLock fftw_plan_lock
Definition: ComputePme.C:414
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int dim3
Definition: PmeBase.h:19
Definition: Node.h:78
void order_init(int nBlocks)
Definition: ComputePme.C:4523
int K2
Definition: PmeBase.h:18
SimParameters * simParameters
Definition: Node.h:178
int K1
Definition: PmeBase.h:18
int block1
Definition: PmeBase.h:21
if(ComputeNonbondedUtil::goMethod==2)
CProxy_NodePmeMgr pmeNodeProxy
Definition: ComputePme.C:218
int block3
Definition: PmeBase.h:21
void NAMD_die(const char *err_msg)
Definition: common.C:83
#define simParams
Definition: Output.C:127
#define fftwf_malloc
Definition: ComputePme.C:13
void PmeYPencil::forward_fft ( )

Definition at line 5422 of file ComputePme.C.

References CKLOOP_CTRL_PME_FORWARDFFT, PmePencil< CBase_PmeYPencil >::data, PmeGrid::dim2, PmePencil< CBase_PmeYPencil >::evir, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, Node::Object(), PmeYPencilForwardFFT(), Node::simParameters, SimParameters::useCkLoop, PmePencil< CBase_PmeYPencil >::work, PmePencilInitMsgData::xBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

5422  {
5423  evir = 0.;
5424 #ifdef NAMD_FFTW
5425 #ifdef MANUAL_DEBUG_FFTW3
5426  dumpMatrixFloat3("fw_y_b", data, nx, initdata.grid.K2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
5427 #endif
5428 
5429 #ifdef NAMD_FFTW_3
5430 #if CMK_SMP && USE_CKLOOP
5431  int useCkLoop = Node::Object()->simParameters->useCkLoop;
5432  if(useCkLoop>=CKLOOP_CTRL_PME_FORWARDFFT
5433  && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
5434  CkLoop_Parallelize(PmeYPencilForwardFFT, 1, (void *)this, CkMyNodeSize(), 0, nx-1); //sync
5435  return;
5436  }
5437 #endif
5438  //the above is a transformation of the following loop using CkLoop
5439  for ( int i=0; i<nx; ++i ) {
5440  fftwf_execute_dft(forward_plan, ((fftwf_complex *) data) + i
5441  * nz * initdata.grid.K2,
5442  ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
5443  }
5444 #else
5445  for ( int i=0; i<nx; ++i ) {
5446  fftw(forward_plan, nz,
5447  ((fftw_complex *) data) + i * nz * initdata.grid.K2,
5448  nz, 1, (fftw_complex *) work, 1, 0);
5449  }
5450 #endif
5451 #ifdef MANUAL_DEBUG_FFTW3
5452  dumpMatrixFloat3("fw_y_a", data, nx, initdata.grid.dim2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
5453 #endif
5454 
5455 #endif
5456 }
static Node * Object()
Definition: Node.h:86
int dim2
Definition: PmeBase.h:19
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
SimParameters * simParameters
Definition: Node.h:178
#define CKLOOP_CTRL_PME_FORWARDFFT
Definition: SimParameters.h:94
static void PmeYPencilForwardFFT(int first, int last, void *result, int paraNum, void *param)
Definition: ComputePme.C:5406
void PmeYPencil::forward_subset_fft ( int  fromIdx,
int  toIdx 
)

Definition at line 5410 of file ComputePme.C.

References PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, and PmeGrid::K2.

Referenced by PmeYPencilForwardFFT().

5410  {
5411 #ifdef NAMD_FFTW
5412 #ifdef NAMD_FFTW_3
5413  for(int i=fromIdx; i<=toIdx; i++){
5414  fftwf_execute_dft(forward_plan, ((fftwf_complex *) data) + i
5415  * nz * initdata.grid.K2,
5416  ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
5417  }
5418 #endif
5419 #endif
5420 }
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
void PmeYPencil::node_process_trans ( PmeTransMsg msg)

Definition at line 4936 of file ComputePme.C.

References forward_fft(), PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::hasData, PmePencil< CBase_PmeYPencil >::imsg, PmePencil< CBase_PmeYPencil >::initdata, PmePencil< CBase_PmeYPencil >::needs_reply, recv_trans(), send_trans(), PmeTransMsg::sourceNode, and PmePencilInitMsgData::yBlocks.

Referenced by NodePmeMgr::recvYTrans().

4937 {
4938  if ( msg->hasData ) hasData = 1;
4939  needs_reply[msg->sourceNode] = msg->hasData;
4940  recv_trans(msg);
4941  int limsg;
4942  CmiMemoryAtomicFetchAndInc(imsg,limsg);
4943  if(limsg+1 == initdata.yBlocks)
4944  {
4945  if ( hasData ) {
4946  forward_fft();
4947  }
4948  send_trans();
4949  imsg=0;
4950  CmiMemoryWriteFence();
4951  }
4952 }
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
void recv_trans(const PmeTransMsg *)
Definition: ComputePme.C:5369
void send_trans()
Definition: ComputePme.C:5520
int sourceNode
Definition: ComputePme.C:131
void forward_fft()
Definition: ComputePme.C:5422
void PmeYPencil::node_process_untrans ( PmeUntransMsg msg)

Definition at line 4959 of file ComputePme.C.

References backward_fft(), PmePencil< CBase_PmeYPencil >::hasData, PmePencil< CBase_PmeYPencil >::imsgb, PmePencil< CBase_PmeYPencil >::initdata, NAMD_bug(), recv_untrans(), send_untrans(), and PmePencilInitMsgData::yBlocks.

Referenced by recvNodeAck(), and NodePmeMgr::recvYUntrans().

4960 {
4961  if ( msg ) {
4962  if ( ! hasData ) NAMD_bug("PmeYPencil::node_process_untrans non-null msg but not hasData");
4963  recv_untrans(msg);
4964  } else if ( hasData ) NAMD_bug("PmeYPencil::node_process_untrans hasData but null msg");
4965  int limsg;
4966  CmiMemoryAtomicFetchAndInc(imsgb,limsg);
4967  if(limsg+1 == initdata.yBlocks)
4968  {
4969  if ( hasData ) {
4970  backward_fft();
4971  }
4972  hasData=0;
4973  imsgb=0;
4974  CmiMemoryWriteFence();
4975  send_untrans();
4976  }
4977 }
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
void NAMD_bug(const char *err_msg)
Definition: common.C:123
void recv_untrans(const PmeUntransMsg *)
Definition: ComputePme.C:5891
void backward_fft()
Definition: ComputePme.C:5932
void send_untrans()
Definition: ComputePme.C:6038
void PmeYPencil::recv_trans ( const PmeTransMsg msg)

Definition at line 5369 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::imsg, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, PmeTransMsg::lattice, PmePencil< CBase_PmeYPencil >::lattice, PmeTransMsg::nx, PmeTransMsg::qgrid, PmeTransMsg::sequence, PmePencil< CBase_PmeYPencil >::sequence, and PmeTransMsg::sourceNode.

Referenced by node_process_trans().

5369  {
5370  if ( imsg == 0 ) {
5371  lattice = msg->lattice;
5372  sequence = msg->sequence;
5373  }
5374  int block2 = initdata.grid.block2;
5375  int K2 = initdata.grid.K2;
5376  int jb = msg->sourceNode;
5377  int ny = msg->nx;
5378  if ( msg->hasData ) {
5379  const float *md = msg->qgrid;
5380  float *d = data;
5381  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
5382  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
5383  for ( int k=0; k<nz; ++k ) {
5384 #ifdef ZEROCHECK
5385  if ( (*md) == 0. ) CkPrintf("0 in ZY at %d %d %d %d %d %d %d %d %d\n",
5386  thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
5387 #endif
5388  d[2*(j*nz+k)] = *(md++);
5389  d[2*(j*nz+k)+1] = *(md++);
5390  }
5391  }
5392  }
5393  } else {
5394  float *d = data;
5395  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
5396  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
5397  for ( int k=0; k<nz; ++k ) {
5398  d[2*(j*nz+k)] = 0;
5399  d[2*(j*nz+k)+1] = 0;
5400  }
5401  }
5402  }
5403  }
5404 }
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
float * qgrid
Definition: ComputePme.C:137
int block2
Definition: PmeBase.h:21
int sourceNode
Definition: ComputePme.C:131
Lattice lattice
Definition: ComputePme.C:134
void PmeYPencil::recv_untrans ( const PmeUntransMsg msg)

Definition at line 5891 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, PmeUntransMsg::ny, PmeUntransMsg::qgrid, and PmeUntransMsg::sourceNode.

Referenced by node_process_untrans().

5891  {
5892  int block2 = initdata.grid.block2;
5893  int K2 = initdata.grid.K2;
5894  int jb = msg->sourceNode;
5895  int ny = msg->ny;
5896  const float *md = msg->qgrid;
5897  float *d = data;
5898  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
5899 #if CMK_BLUEGENEL
5900  CmiNetworkProgress();
5901 #endif
5902  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
5903  for ( int k=0; k<nz; ++k ) {
5904 #ifdef ZEROCHECK
5905  if ( (*md) == 0. ) CkPrintf("0 in XY at %d %d %d %d %d %d %d %d %d\n",
5906  thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
5907 #endif
5908  d[2*(j*nz+k)] = *(md++);
5909  d[2*(j*nz+k)+1] = *(md++);
5910  }
5911  }
5912  }
5913 }
float * qgrid
Definition: ComputePme.C:154
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
int block2
Definition: PmeBase.h:21
void PmeYPencil::recvNodeAck ( PmeAckMsg msg)

Definition at line 4954 of file ComputePme.C.

References node_process_untrans().

4954  {
4955  delete msg;
4957 }
void node_process_untrans(PmeUntransMsg *)
Definition: ComputePme.C:4959
void PmeYPencil::send_subset_trans ( int  fromIdx,
int  toIdx 
)

Definition at line 5463 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmeTransMsg::destElem, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::hasData, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, PmeTransMsg::lattice, PmePencil< CBase_PmeYPencil >::lattice, PmeTransMsg::nx, PME_TRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PRIORITY_SIZE, PmeTransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmeTransMsg::sequence, PmePencil< CBase_PmeYPencil >::sequence, SET_PRIORITY, PmeTransMsg::sourceNode, PmePencilInitMsgData::xm, PmePencilInitMsgData::xPencil, and PmePencilInitMsgData::yBlocks.

Referenced by PmeYPencilSendTrans().

5463  {
5464  int yBlocks = initdata.yBlocks;
5465  int block2 = initdata.grid.block2;
5466  int K2 = initdata.grid.K2;
5467  for ( int isend=fromIdx; isend<=toIdx; ++isend ) {
5468  int jb = send_order[isend];
5469  int ny = block2;
5470  if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
5471  int hd = ( hasData ? 1 : 0 );
5472  PmeTransMsg *msg = new (hd*nx*ny*nz*2,PRIORITY_SIZE) PmeTransMsg;
5473  msg->lattice = lattice;
5474  msg->sourceNode = thisIndex.x;
5475  msg->hasData = hasData;
5476  msg->nx = nx;
5477  if ( hasData ) {
5478  float *md = msg->qgrid;
5479  const float *d = data;
5480  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
5481  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
5482  for ( int k=0; k<nz; ++k ) {
5483  *(md++) = d[2*(j*nz+k)];
5484  *(md++) = d[2*(j*nz+k)+1];
5485  #ifdef ZEROCHECK
5486  if ( *(md-2) == 0. ) CkPrintf("send 0 in YX at %d %d %d %d %d %d %d %d %d\n",
5487  thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
5488  #endif
5489  }
5490  }
5491  }
5492  if ( md != msg->qgrid + nx*ny*nz*2 ) CkPrintf("error in YX at %d %d %d\n",
5493  thisIndex.x, jb, thisIndex.z);
5494  }
5495  msg->sequence = sequence;
5497  CmiEnableUrgentSend(1);
5498 #if USE_NODE_PAR_RECEIVE
5499  msg->destElem=CkArrayIndex3D(0,jb,thisIndex.z);
5500 #if X_PERSIST
5501  CmiUsePersistentHandle(&trans_handle[isend], 1);
5502 #endif
5503  initdata.pmeNodeProxy[CmiNodeOf(initdata.xm.ckLocalBranch()->procNum(0,msg->destElem))].recvXTrans(msg);
5504 #if X_PERSIST
5505  CmiUsePersistentHandle(NULL, 0);
5506 #endif
5507 #else
5508 #if X_PERSIST
5509  CmiUsePersistentHandle(&trans_handle[isend], 1);
5510 #endif
5511  initdata.xPencil(0,jb,thisIndex.z).recvTrans(msg);
5512 #if X_PERSIST
5513  CmiUsePersistentHandle(NULL, 0);
5514 #endif
5515 #endif
5516  CmiEnableUrgentSend(0);
5517  }
5518 }
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
#define PME_TRANS2_PRIORITY
Definition: Priorities.h:32
int K2
Definition: PmeBase.h:18
CProxy_PmePencilMap xm
Definition: ComputePme.C:219
CProxy_NodePmeMgr pmeNodeProxy
Definition: ComputePme.C:218
float * qgrid
Definition: ComputePme.C:137
int block2
Definition: PmeBase.h:21
#define PRIORITY_SIZE
Definition: Priorities.h:13
int sourceNode
Definition: ComputePme.C:131
CkArrayIndex3D destElem
Definition: ComputePme.C:138
Lattice lattice
Definition: ComputePme.C:134
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
CProxy_PmeXPencil xPencil
Definition: ComputePme.C:214
void PmeYPencil::send_subset_untrans ( int  fromIdx,
int  toIdx 
)

Definition at line 5979 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmeUntransMsg::destElem, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, PmePencil< CBase_PmeYPencil >::needs_reply, PmeUntransMsg::ny, PME_UNTRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PRIORITY_SIZE, PmeUntransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmePencil< CBase_PmeYPencil >::sequence, SET_PRIORITY, PmeUntransMsg::sourceNode, PmePencilInitMsgData::yBlocks, PmePencilInitMsgData::zm, and PmePencilInitMsgData::zPencil.

Referenced by PmeYPencilSendUntrans().

5979  {
5980  int yBlocks = initdata.yBlocks;
5981  int block2 = initdata.grid.block2;
5982  int K2 = initdata.grid.K2;
5983 
5984  for(int isend=fromIdx; isend<=toIdx; isend++) {
5985  int jb = send_order[isend];
5986  if ( ! needs_reply[jb] ) {
5987  PmeAckMsg *msg = new (PRIORITY_SIZE) PmeAckMsg;
5988  CmiEnableUrgentSend(1);
5990 #if USE_NODE_PAR_RECEIVE
5991  initdata.zPencil(thisIndex.x,jb,0).recvNodeAck(msg);
5992 #else
5993  initdata.zPencil(thisIndex.x,jb,0).recvAck(msg);
5994 #endif
5995  CmiEnableUrgentSend(0);
5996  continue;
5997  }
5998  int ny = block2;
5999  if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
6000  PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;
6001  msg->sourceNode = thisIndex.z;
6002  msg->ny = nz;
6003  float *md = msg->qgrid;
6004  const float *d = data;
6005  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
6006  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
6007  for ( int k=0; k<nz; ++k ) {
6008  *(md++) = d[2*(j*nz+k)];
6009  *(md++) = d[2*(j*nz+k)+1];
6010  }
6011  }
6012  }
6014  CmiEnableUrgentSend(1);
6015 #if USE_NODE_PAR_RECEIVE
6016  msg->destElem=CkArrayIndex3D( thisIndex.x, jb, 0);
6017  // CkPrintf("[%d] sending to %d %d %d recvZUntrans on node %d\n", CkMyPe(), thisIndex.x, jb, 0, CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem)));
6018 #if Z_PERSIST
6019  CmiUsePersistentHandle(&untrans_handle[isend], 1);
6020 #endif
6021  initdata.pmeNodeProxy[CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem))].recvZUntrans(msg);
6022 #if Z_PERSIST
6023  CmiUsePersistentHandle(NULL, 0);
6024 #endif
6025 #else
6026 #if Z_PERSIST
6027  CmiUsePersistentHandle(&untrans_handle[isend], 1);
6028 #endif
6029  initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
6030 #if Z_PERSIST
6031  CmiUsePersistentHandle(NULL, 0);
6032 #endif
6033 #endif
6034  CmiEnableUrgentSend(0);
6035  }
6036 }
float * qgrid
Definition: ComputePme.C:154
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
CProxy_PmeZPencil zPencil
Definition: ComputePme.C:216
CProxy_PmePencilMap zm
Definition: ComputePme.C:221
CProxy_NodePmeMgr pmeNodeProxy
Definition: ComputePme.C:218
int block2
Definition: PmeBase.h:21
#define PRIORITY_SIZE
Definition: Priorities.h:13
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
CkArrayIndex3D destElem
Definition: ComputePme.C:155
#define PME_UNTRANS2_PRIORITY
Definition: Priorities.h:34
void PmeYPencil::send_trans ( )

Definition at line 5520 of file ComputePme.C.

References PmeGrid::block2, CKLOOP_CTRL_PME_SENDTRANS, PmePencil< CBase_PmeYPencil >::data, PmeTransMsg::destElem, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::hasData, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, PmeTransMsg::lattice, PmePencil< CBase_PmeYPencil >::lattice, PmeTransMsg::nx, Node::Object(), PME_TRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PmeYPencilSendTrans(), PRIORITY_SIZE, PmeTransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmeTransMsg::sequence, PmePencil< CBase_PmeYPencil >::sequence, SET_PRIORITY, Node::simParameters, PmeTransMsg::sourceNode, SimParameters::useCkLoop, PmePencilInitMsgData::xBlocks, PmePencilInitMsgData::xm, PmePencilInitMsgData::xPencil, PmePencilInitMsgData::yBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

5520  {
5521 #if USE_PERSISTENT
5522  if (trans_handle == NULL) setup_persistent();
5523 #endif
5524 #if CMK_SMP && USE_CKLOOP
5525  int useCkLoop = Node::Object()->simParameters->useCkLoop;
5526  if(useCkLoop>=CKLOOP_CTRL_PME_SENDTRANS
5527  && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
5534  //send_subset_trans(0, initdata.yBlocks-1);
5535  CkLoop_Parallelize(PmeYPencilSendTrans, 1, (void *)this, CkMyNodeSize(), 0, initdata.yBlocks-1, 1); //not sync
5536  return;
5537  }
5538 #endif
5539  int yBlocks = initdata.yBlocks;
5540  int block2 = initdata.grid.block2;
5541  int K2 = initdata.grid.K2;
5542  for ( int isend=0; isend<yBlocks; ++isend ) {
5543  int jb = send_order[isend];
5544  int ny = block2;
5545  if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
5546  int hd = ( hasData ? 1 : 0 );
5547  PmeTransMsg *msg = new (hd*nx*ny*nz*2,PRIORITY_SIZE) PmeTransMsg;
5548  msg->lattice = lattice;
5549  msg->sourceNode = thisIndex.x;
5550  msg->hasData = hasData;
5551  msg->nx = nx;
5552  if ( hasData ) {
5553  float *md = msg->qgrid;
5554  const float *d = data;
5555  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
5556  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
5557  for ( int k=0; k<nz; ++k ) {
5558  *(md++) = d[2*(j*nz+k)];
5559  *(md++) = d[2*(j*nz+k)+1];
5560 #ifdef ZEROCHECK
5561  if ( *(md-2) == 0. ) CkPrintf("send 0 in YX at %d %d %d %d %d %d %d %d %d\n",
5562  thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
5563 #endif
5564  }
5565  }
5566  }
5567  if ( md != msg->qgrid + nx*ny*nz*2 ) CkPrintf("error in YX at %d %d %d\n",
5568  thisIndex.x, jb, thisIndex.z);
5569  }
5570  msg->sequence = sequence;
5572  CmiEnableUrgentSend(1);
5573 #if USE_NODE_PAR_RECEIVE
5574  msg->destElem=CkArrayIndex3D(0,jb,thisIndex.z);
5575 #if X_PERSIST
5576  CmiUsePersistentHandle(&trans_handle[isend], 1);
5577 #endif
5578  initdata.pmeNodeProxy[CmiNodeOf(initdata.xm.ckLocalBranch()->procNum(0,msg->destElem))].recvXTrans(msg);
5579 #if X_PERSIST
5580  CmiUsePersistentHandle(NULL, 0);
5581 #endif
5582 #else
5583 #if X_PERSIST
5584  CmiUsePersistentHandle(&trans_handle[isend], 1);
5585 #endif
5586  initdata.xPencil(0,jb,thisIndex.z).recvTrans(msg);
5587 #if X_PERSIST
5588  CmiUsePersistentHandle(NULL, 0);
5589 #endif
5590 
5591 #endif
5592  CmiEnableUrgentSend(0);
5593  }
5594 }
static Node * Object()
Definition: Node.h:86
static void PmeYPencilSendTrans(int first, int last, void *result, int paraNum, void *param)
Definition: ComputePme.C:5458
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
#define PME_TRANS2_PRIORITY
Definition: Priorities.h:32
int K2
Definition: PmeBase.h:18
SimParameters * simParameters
Definition: Node.h:178
CProxy_PmePencilMap xm
Definition: ComputePme.C:219
CProxy_NodePmeMgr pmeNodeProxy
Definition: ComputePme.C:218
float * qgrid
Definition: ComputePme.C:137
int block2
Definition: PmeBase.h:21
#define PRIORITY_SIZE
Definition: Priorities.h:13
int sourceNode
Definition: ComputePme.C:131
#define CKLOOP_CTRL_PME_SENDTRANS
Definition: SimParameters.h:95
CkArrayIndex3D destElem
Definition: ComputePme.C:138
Lattice lattice
Definition: ComputePme.C:134
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
CProxy_PmeXPencil xPencil
Definition: ComputePme.C:214
void PmeYPencil::send_untrans ( )

Definition at line 6038 of file ComputePme.C.

References PmeGrid::block2, CKLOOP_CTRL_PME_SENDUNTRANS, PmePencil< CBase_PmeYPencil >::data, PmeUntransMsg::destElem, PmePencil< CBase_PmeYPencil >::evir, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, PmePencil< CBase_PmeYPencil >::needs_reply, PmeUntransMsg::ny, Node::Object(), PME_UNTRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PmeYPencilSendUntrans(), PRIORITY_SIZE, PmeUntransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmePencil< CBase_PmeYPencil >::sequence, SET_PRIORITY, Node::simParameters, PmeUntransMsg::sourceNode, SimParameters::useCkLoop, PmePencilInitMsgData::xBlocks, PmePencilInitMsgData::yBlocks, PmePencilInitMsgData::zBlocks, PmePencilInitMsgData::zm, and PmePencilInitMsgData::zPencil.

Referenced by node_process_untrans().

6038  {
6039 #if USE_PERSISTENT
6040  if (untrans_handle == NULL) setup_persistent();
6041 #endif
6042 #if CMK_SMP && USE_CKLOOP
6043  int useCkLoop = Node::Object()->simParameters->useCkLoop;
6044  if(useCkLoop>=CKLOOP_CTRL_PME_SENDUNTRANS
6045  && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
6046  int yBlocks = initdata.yBlocks;
6047 
6048 #if USE_NODE_PAR_RECEIVE
6049  //CkLoop_Parallelize(PmeYPencilSendUntrans, 1, (void *)this, CkMyNodeSize(), 0, yBlocks-1, 1); //sync
6050  CkLoop_Parallelize(PmeYPencilSendUntrans, 1, (void *)this, yBlocks, 0, yBlocks-1, 1);
6051 #else
6052  //CkLoop_Parallelize(PmeYPencilSendUntrans, 1, (void *)this, CkMyNodeSize(), 0, yBlocks-1, 0); //not sync
6053  CkLoop_Parallelize(PmeYPencilSendUntrans, 1, (void *)this, yBlocks, 0, yBlocks-1, 0); //not sync
6054 #endif
6055  return;
6056  }
6057 #endif
6058  int yBlocks = initdata.yBlocks;
6059  int block2 = initdata.grid.block2;
6060  int K2 = initdata.grid.K2;
6061  for ( int isend=0; isend<yBlocks; ++isend ) {
6062  int jb = send_order[isend];
6063  if ( ! needs_reply[jb] ) {
6064  PmeAckMsg *msg = new (PRIORITY_SIZE) PmeAckMsg;
6065  CmiEnableUrgentSend(1);
6067 #if USE_NODE_PAR_RECEIVE
6068  initdata.zPencil(thisIndex.x,jb,0).recvNodeAck(msg);
6069 #else
6070  initdata.zPencil(thisIndex.x,jb,0).recvAck(msg);
6071 #endif
6072  CmiEnableUrgentSend(0);
6073  continue;
6074  }
6075  int ny = block2;
6076  if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
6077  PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;
6078  msg->sourceNode = thisIndex.z;
6079  msg->ny = nz;
6080  float *md = msg->qgrid;
6081  const float *d = data;
6082  for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
6083  for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
6084  for ( int k=0; k<nz; ++k ) {
6085  *(md++) = d[2*(j*nz+k)];
6086  *(md++) = d[2*(j*nz+k)+1];
6087  }
6088  }
6089  }
6091 
6092  CmiEnableUrgentSend(1);
6093 #if USE_NODE_PAR_RECEIVE
6094  msg->destElem=CkArrayIndex3D( thisIndex.x, jb, 0);
6095  // CkPrintf("[%d] sending to %d %d %d recvZUntrans on node %d\n", CkMyPe(), thisIndex.x, jb, 0, CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem)));
6096 #if Z_PERSIST
6097  CmiUsePersistentHandle(&untrans_handle[isend], 1);
6098 #endif
6099  initdata.pmeNodeProxy[CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem))].recvZUntrans(msg);
6100 #if Z_PERSIST
6101  CmiUsePersistentHandle(NULL, 0);
6102 #endif
6103 #else
6104 #if Z_PERSIST
6105  CmiUsePersistentHandle(&untrans_handle[isend], 1);
6106 #endif
6107  initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
6108 #if Z_PERSIST
6109  CmiUsePersistentHandle(NULL, 0);
6110 #endif
6111 #endif
6112  CmiEnableUrgentSend(0);
6113  }
6114 
6115 #if USE_NODE_PAR_RECEIVE
6116  evir = 0.;
6117  CmiMemoryWriteFence();
6118 #endif
6119 }
static Node * Object()
Definition: Node.h:86
float * qgrid
Definition: ComputePme.C:154
PmePencilInitMsgData initdata
Definition: ComputePme.C:4535
int K2
Definition: PmeBase.h:18
CProxy_PmeZPencil zPencil
Definition: ComputePme.C:216
SimParameters * simParameters
Definition: Node.h:178
CProxy_PmePencilMap zm
Definition: ComputePme.C:221
CProxy_NodePmeMgr pmeNodeProxy
Definition: ComputePme.C:218
int block2
Definition: PmeBase.h:21
#define CKLOOP_CTRL_PME_SENDUNTRANS
Definition: SimParameters.h:98
#define PRIORITY_SIZE
Definition: Priorities.h:13
static void PmeYPencilSendUntrans(int first, int last, void *result, int paraNum, void *param)
Definition: ComputePme.C:5974
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
CkArrayIndex3D destElem
Definition: ComputePme.C:155
#define PME_UNTRANS2_PRIORITY
Definition: Priorities.h:34

The documentation for this class was generated from the following file: