OptPme.C File Reference

#include <sfftw.h>
#include <srfftw.h>
#include <assert.h>
#include "InfoStream.h"
#include "Node.h"
#include "PatchMap.h"
#include "PatchMap.inl"
#include "AtomMap.h"
#include "OptPme.h"
#include "OptPmeMgr.decl.h"
#include "OptPmeRealSpace.h"
#include "PmeKSpace.h"
#include "ComputeNonbondedUtil.h"
#include "PatchMgr.h"
#include "Molecule.h"
#include "ReductionMgr.h"
#include "ComputeMgr.decl.h"
#include "Debug.h"
#include "SimParameters.h"
#include "WorkDistrib.h"
#include "varsizemsg.h"
#include "Random.h"
#include "Priorities.h"
#include "PmeBase.inl"
#include "fftlib.h"
#include "fftmap.h"
#include "fftlib.C"
#include "OptPmeMgr.def.h"

Go to the source code of this file.

Classes

class  OptPmeMgr

Defines

#define MIN_DEBUG_LEVEL   3

Functions

void pme_f2d (double *dst, float *src, int N)
void pme_d2f (float *dst, double *src, int N)
static void initializePmeGrid (SimParameters *simParams, PmeGrid &grid)
static void scale_n_copy_coordinates (CompAtom *x, PmeParticle p[], int &N, Lattice &lattice, PmeGrid grid, double xmin, double xlen, double ymin, double ylen, double zmin, double zlen, int &scg)
void recv_ungrid_done (void *m)

Variables

char * pencilPMEProcessors
int many_to_many_start = 0x7fffffff
static CmiNodeLock fftw_plan_lock


Define Documentation

#define MIN_DEBUG_LEVEL   3

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 39 of file OptPme.C.


Function Documentation

static void initializePmeGrid ( SimParameters simParams,
PmeGrid grid 
) [inline, static]

Definition at line 103 of file OptPme.C.

References PmeGrid::block1, PmeGrid::block2, PmeGrid::block3, PmeGrid::dim2, PmeGrid::dim3, if(), PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, PmeGrid::order, simParams, PmeGrid::xBlocks, PmeGrid::yBlocks, and PmeGrid::zBlocks.

Referenced by OptPmeMgr::initialize().

00103                                                                                {
00104     int xBlocks = 0, yBlocks = 0, zBlocks= 0;
00105 
00106     if ( simParams->PMEPencils > 1 ) {
00107       xBlocks = yBlocks = zBlocks = simParams->PMEPencils;
00108     } else {
00109       int nb2 = ( simParams->PMEGridSizeX * simParams->PMEGridSizeY
00110                   * simParams->PMEGridSizeZ ) / simParams->PMEMinPoints;
00111       if ( nb2 > CkNumPes() ) nb2 = CkNumPes();
00112       if ( nb2 < 1 ) nb2 = 1;
00113       int nb = (int) sqrt((float)nb2);
00114       if ( nb < 1 ) nb = 1;
00115       xBlocks = zBlocks = nb;
00116       yBlocks = nb2 / nb;
00117     }
00118     
00119     int dimx = simParams->PMEGridSizeX;
00120     int bx = 1 + ( dimx - 1 ) / xBlocks;
00121     xBlocks = 1 + ( dimx - 1 ) / bx;
00122     
00123     int dimy = simParams->PMEGridSizeY;
00124     int by = 1 + ( dimy - 1 ) / yBlocks;
00125     yBlocks = 1 + ( dimy - 1 ) / by;
00126     
00127     int dimz = simParams->PMEGridSizeZ / 2 + 1;  // complex
00128     int bz = 1 + ( dimz - 1 ) / zBlocks;
00129     zBlocks = 1 + ( dimz - 1 ) / bz;
00130 
00131     grid.xBlocks = xBlocks;
00132     grid.yBlocks = yBlocks;
00133     grid.zBlocks = zBlocks;
00134 
00135     grid.K1 = simParams->PMEGridSizeX;
00136     grid.K2 = simParams->PMEGridSizeY;
00137     grid.K3 = simParams->PMEGridSizeZ;
00138     grid.order = simParams->PMEInterpOrder;
00139     grid.dim2 = grid.K2;
00140     grid.dim3 = 2 * (grid.K3/2 + 1);
00141 
00142     grid.block1 = ( grid.K1 + xBlocks - 1 ) / xBlocks;
00143     grid.block2 = ( grid.K2 + yBlocks - 1 ) / yBlocks;
00144     grid.block3 = ( grid.K3/2 + 1 + zBlocks - 1 ) / zBlocks;  // complex
00145 }

void pme_d2f ( float *  dst,
double *  src,
int  N 
)

Definition at line 1087 of file OptPme.C.

Referenced by OptPmeCompute::doWorkOnPeer().

01087                                               {
01088 #pragma disjoint (*src, *dst)  
01089 #pragma unroll (8)
01090   for (int i = 0; i < N; i++) 
01091     dst[i] = src[i];
01092 }

void pme_f2d ( double *  dst,
float *  src,
int  N 
)

Definition at line 1080 of file OptPme.C.

Referenced by OptPmeCompute::ungridForces_init().

01080                                               {
01081 #pragma disjoint (*src, *dst)  
01082 #pragma unroll (8)
01083   for (int i = 0; i < N; i++) 
01084     dst[i] = src[i];
01085 }

void recv_ungrid_done ( void *  m  ) 

Definition at line 606 of file OptPme.C.

References OptPmeDummyMsg::to_pe.

00606                                 {
00607   OptPmeDummyMsg *msg =  (OptPmeDummyMsg *) m;  
00608   CProxy_OptPmeMgr pmeProxy (CkpvAccess(BOCclass_group).computePmeMgr);
00609   pmeProxy[msg->to_pe].ungridCalc (msg);
00610 }  

static void scale_n_copy_coordinates ( CompAtom x,
PmeParticle  p[],
int &  N,
Lattice lattice,
PmeGrid  grid,
double  xmin,
double  xlen,
double  ymin,
double  ylen,
double  zmin,
double  zlen,
int &  scg 
) [inline, static]

Definition at line 152 of file OptPme.C.

References Lattice::a_r(), Lattice::b_r(), Lattice::c_r(), PmeParticle::cg, COULOMB, ComputeNonbondedUtil::dielectric_1, PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, Lattice::origin(), ComputeNonbondedUtil::scaling, PmeParticle::x, x, Vector::x, y, PmeParticle::y, Vector::y, z, PmeParticle::z, and Vector::z.

Referenced by OptPmeCompute::doWork().

00159                                                       {
00160   Vector origin = lattice.origin();
00161   Vector recip1 = lattice.a_r();
00162   Vector recip2 = lattice.b_r();
00163   Vector recip3 = lattice.c_r();
00164   double ox = origin.x;
00165   double oy = origin.y;
00166   double oz = origin.z;
00167   double r1x = recip1.x;
00168   double r1y = recip1.y;
00169   double r1z = recip1.z;
00170   double r2x = recip2.x;
00171   double r2y = recip2.y;
00172   double r2z = recip2.z;
00173   double r3x = recip3.x;
00174   double r3y = recip3.y;
00175   double r3z = recip3.z;
00176   int K1 = grid.K1;
00177   int K2 = grid.K2;
00178   int K3 = grid.K3;
00179 
00180   const BigReal coulomb_sqrt = sqrt( COULOMB * ComputeNonbondedUtil::scaling
00181                                      * ComputeNonbondedUtil::dielectric_1 );
00182 
00183 
00184   int natoms = 0;
00185   for (int i=0; i<N; i++) {
00186     double px = x[i].position.x - ox;
00187     double py = x[i].position.y - oy;
00188     double pz = x[i].position.z - oz;
00189     double sx = px*r1x + py*r1y + pz*r1z;
00190     double sy = px*r2x + py*r2y + pz*r2z;
00191     double sz = px*r3x + py*r3y + pz*r3z;
00192     p[natoms].x = K1 * ( sx - floor(sx) );
00193     p[natoms].y = K2 * ( sy - floor(sy) );
00194     p[natoms].z = K3 * ( sz - floor(sz) );
00195 #ifndef ARCH_POWERPC
00196     //  Check for rare rounding condition where K * ( 1 - epsilon ) == K      
00197     //  which was observed with g++ on Intel x86 architecture. 
00198     if ( p[natoms].x == K1 ) p[natoms].x = 0;
00199     if ( p[natoms].y == K2 ) p[natoms].y = 0;
00200     if ( p[natoms].z == K3 ) p[natoms].z = 0;
00201 #endif
00202 
00203 #if 1 //stray charge detection
00204     BigReal u1,u2,u3;
00205     u1 = (int) (p[natoms].x - xmin);
00206     if (u1 >= grid.K1) u1 -= grid.K1;    
00207     u2 = (int) (p[natoms].y - ymin);
00208     if (u2 >= grid.K2) u2 -= grid.K2;    
00209     u3 = (int) (p[natoms].z - zmin);
00210     if (u3 >= grid.K3) u3 -= grid.K3;
00211     
00212     if ( (u1 < 0.0) || (u1 >= xlen) || 
00213          (u2 < 0.0) || (u2 >= ylen) || 
00214          (u3 < 0.0) || (u3 >= zlen) ) {
00215       scg ++;
00216       continue;
00217     }
00218 #endif
00219     
00220     p[natoms].cg = coulomb_sqrt * x[i].charge;
00221     natoms ++;
00222   }
00223   N = natoms;
00224 }


Variable Documentation

CmiNodeLock fftw_plan_lock [static]

Definition at line 148 of file OptPme.C.

Referenced by OptPmeXPencil::fft_init(), OptPmeYPencil::fft_init(), OptPmeZPencil::fft_init(), and OptPmeMgr::OptPmeMgr().

int many_to_many_start = 0x7fffffff

Definition at line 54 of file OptPme.C.

Referenced by OptPmeCompute::doWork(), OptPmeCompute::doWorkOnPeer(), OptPmeMgr::initialize(), and OptPmeCompute::ungridForces_init().

char* pencilPMEProcessors

Definition at line 96 of file ComputePme.C.

Referenced by ComputePmeMgr::initialize(), OptPmePencilMapX::initialize(), OptPmePencilMapY::initialize(), OptPmePencilMapZ::initialize(), OptPmeMgr::initialize(), and isPmeProcessor().


Generated on Tue Sep 19 01:17:15 2017 for NAMD by  doxygen 1.4.7