ComputeHomeTuples< T, S, P > Class Template Reference

#include <ComputeHomeTuples.h>

Inheritance diagram for ComputeHomeTuples< T, S, P >:
Compute ComputeSelfTuples< T, S, P > ComputeSelfTuples< AngleElem, Angle, AngleValue > ComputeSelfTuples< AnisoElem, Aniso, AnisoValue > ComputeSelfTuples< BondElem, Bond, BondValue > ComputeSelfTuples< CrosstermElem, Crossterm, CrosstermValue > ComputeSelfTuples< DihedralElem, Dihedral, DihedralValue > ComputeSelfTuples< ExclElem, Exclusion, int > ComputeSelfTuples< GromacsPairElem, GromacsPair, GromacsPairValue > ComputeSelfTuples< ImproperElem, Improper, ImproperValue > ComputeSelfTuples< TholeElem, Thole, TholeValue >

List of all members.

Public Member Functions

virtual ~ComputeHomeTuples ()
virtual void initialize (void)
void atomUpdate (void)
virtual void doWork (void)

Protected Member Functions

virtual void loadTuples (void)
 ComputeHomeTuples (ComputeID c)
 ComputeHomeTuples (ComputeID c, PatchIDList &pids)

Protected Attributes

int doLoadTuples
ResizeArray< T > tupleList
TuplePatchList tuplePatchList
PatchMappatchMap
AtomMapatomMap
SubmitReductionreduction
int accelMDdoDihe
SubmitReductionpressureProfileReduction
BigRealpressureProfileData
int pressureProfileSlabs
char * isBasePatch

Detailed Description

template<class T, class S, class P>
class ComputeHomeTuples< T, S, P >

Definition at line 314 of file ComputeHomeTuples.h.


Constructor & Destructor Documentation

template<class T, class S, class P>
ComputeHomeTuples< T, S, P >::ComputeHomeTuples ( ComputeID  c  )  [inline, protected]

Definition at line 462 of file ComputeHomeTuples.h.

00462                                    : Compute(c) {
00463       patchMap = PatchMap::Object();
00464       atomMap = AtomMap::Object();
00465       reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00466       
00467       SimParameters *params = Node::Object()->simParameters;
00468       accelMDdoDihe=false;
00469       if (params->accelMDOn) {
00470          if (params->accelMDdihe || params->accelMDdual) accelMDdoDihe=true;
00471       }
00472       if (params->pressureProfileOn) {
00473         pressureProfileSlabs = T::pressureProfileSlabs = 
00474           params->pressureProfileSlabs;
00475         int n = T::pressureProfileAtomTypes = params->pressureProfileAtomTypes;
00476         pressureProfileReduction = ReductionMgr::Object()->willSubmit(
00477           REDUCTIONS_PPROF_BONDED, 3*pressureProfileSlabs*((n*(n+1))/2));
00478         int numAtomTypePairs = n*n;
00479         pressureProfileData = new BigReal[3*pressureProfileSlabs*numAtomTypePairs];
00480       } else {
00481         pressureProfileReduction = NULL;
00482         pressureProfileData = NULL;
00483       }
00484       doLoadTuples = false;
00485       isBasePatch = 0;
00486 #ifdef USE_HOMETUPLES
00487       tuples = NULL;
00488 #endif
00489     }

template<class T, class S, class P>
ComputeHomeTuples< T, S, P >::ComputeHomeTuples ( ComputeID  c,
PatchIDList pids 
) [inline, protected]

Definition at line 491 of file ComputeHomeTuples.h.

00491                                                       : Compute(c) {
00492       patchMap = PatchMap::Object();
00493       atomMap = AtomMap::Object();
00494       reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00495       SimParameters *params = Node::Object()->simParameters;
00496       accelMDdoDihe=false;
00497       if (params->accelMDOn) {
00498          if (params->accelMDdihe || params->accelMDdual) accelMDdoDihe=true;
00499       }
00500       if (params->pressureProfileOn) {
00501         pressureProfileSlabs = T::pressureProfileSlabs = 
00502           params->pressureProfileSlabs;
00503         int n = T::pressureProfileAtomTypes = params->pressureProfileAtomTypes;
00504         pressureProfileReduction = ReductionMgr::Object()->willSubmit(
00505           REDUCTIONS_PPROF_BONDED, 3*pressureProfileSlabs*((n*(n+1))/2));
00506         int numAtomTypePairs = n*n;
00507         pressureProfileData = new BigReal[3*pressureProfileSlabs*numAtomTypePairs];
00508       } else {
00509         pressureProfileReduction = NULL;
00510         pressureProfileData = NULL;
00511       }
00512       doLoadTuples = false;
00513       int nPatches = patchMap->numPatches();
00514       isBasePatch = new char[nPatches];
00515       int i;
00516       for (i=0; i<nPatches; ++i) { isBasePatch[i] = 0; }
00517       for (i=0; i<pids.size(); ++i) { isBasePatch[pids[i]] = 1; }
00518 #ifdef USE_HOMETUPLES
00519       tuples = NULL;
00520 #endif
00521     }

template<class T, class S, class P>
virtual ComputeHomeTuples< T, S, P >::~ComputeHomeTuples (  )  [inline, virtual]

Definition at line 525 of file ComputeHomeTuples.h.

00525                                  {
00526       delete reduction;
00527       delete [] isBasePatch;
00528       delete pressureProfileReduction;
00529       delete pressureProfileData;
00530 #ifdef USE_HOMETUPLES
00531       if (tuples != NULL) delete tuples;
00532 #endif
00533     }


Member Function Documentation

template<class T, class S, class P>
void ComputeHomeTuples< T, S, P >::atomUpdate ( void   )  [inline, virtual]

Reimplemented from Compute.

Definition at line 589 of file ComputeHomeTuples.h.

00589                           {
00590       doLoadTuples = true;
00591     }

template<class T, class S, class P>
virtual void ComputeHomeTuples< T, S, P >::doWork ( void   )  [inline, virtual]

Reimplemented from Compute.

Reimplemented in ComputeSelfTuples< T, S, P >, ComputeSelfTuples< AnisoElem, Aniso, AnisoValue >, ComputeSelfTuples< AngleElem, Angle, AngleValue >, ComputeSelfTuples< GromacsPairElem, GromacsPair, GromacsPairValue >, ComputeSelfTuples< ExclElem, Exclusion, int >, ComputeSelfTuples< DihedralElem, Dihedral, DihedralValue >, ComputeSelfTuples< ImproperElem, Improper, ImproperValue >, ComputeSelfTuples< BondElem, Bond, BondValue >, ComputeSelfTuples< CrosstermElem, Crossterm, CrosstermValue >, and ComputeSelfTuples< TholeElem, Thole, TholeValue >.

Definition at line 598 of file ComputeHomeTuples.h.

00598                               {
00599 
00600       LdbCoordinator::Object()->startWork(ldObjHandle);
00601 
00602       // Open Boxes - register that we are using Positions
00603       // and will be depositing Forces.
00604       UniqueSetIter<TuplePatchElem> ap(tuplePatchList);
00605       for (ap = ap.begin(); ap != ap.end(); ap++) {
00606         ap->x = ap->positionBox->open();
00607         ap->xExt = ap->p->getCompAtomExtInfo();
00608         if ( ap->p->flags.doMolly ) ap->x_avg = ap->avgPositionBox->open();
00609         ap->r = ap->forceBox->open();
00610         ap->f = ap->r->f[Results::normal];
00611         if (accelMDdoDihe) ap->af = ap->r->f[Results::amdf]; // for dihedral-only or dual-boost accelMD
00612       } 
00613     
00614       BigReal reductionData[T::reductionDataSize];
00615       int tupleCount = 0;
00616       int numAtomTypes = T::pressureProfileAtomTypes;
00617       int numAtomTypePairs = numAtomTypes*numAtomTypes;
00618     
00619       for ( int i = 0; i < T::reductionDataSize; ++i ) reductionData[i] = 0;
00620       if (pressureProfileData) {
00621         memset(pressureProfileData, 0, 3*pressureProfileSlabs*numAtomTypePairs*sizeof(BigReal));
00622         // Silly variable hiding of the previous iterator
00623         UniqueSetIter<TuplePatchElem> newap(tuplePatchList);
00624         newap = newap.begin();
00625         const Lattice &lattice = newap->p->lattice;
00626         T::pressureProfileThickness = lattice.c().z / pressureProfileSlabs;
00627         T::pressureProfileMin = lattice.origin().z - 0.5*lattice.c().z;
00628       }
00629 
00630       if ( ! Node::Object()->simParameters->commOnly ) {
00631       if ( doLoadTuples ) {
00632 #ifdef USE_HOMETUPLES
00633         tuples->loadTuples(tuplePatchList, isBasePatch, AtomMap::Object());
00634 #else
00635         loadTuples();
00636 #endif
00637         doLoadTuples = false;
00638       }
00639       // take triplet and pass with tuple info to force eval
00640 #ifdef USE_HOMETUPLES
00641       T *al = (T *)tuples->getTupleList();
00642       const int ntuple = tuples->getNumTuples();
00643 #else
00644       T *al = tupleList.begin();
00645       const int ntuple = tupleList.size();
00646 #endif
00647       if ( ntuple ) T::computeForce(al, ntuple, reductionData, pressureProfileData);
00648       tupleCount += ntuple;
00649       }
00650  
00651     LdbCoordinator::Object()->endWork(ldObjHandle);
00652 
00653       T::submitReductionData(reductionData,reduction);
00654       reduction->item(T::reductionChecksumLabel) += (BigReal)tupleCount;
00655       reduction->submit();
00656 
00657       if (pressureProfileReduction) {
00658         // For ease of calculation we stored interactions between types
00659         // i and j in (ni+j).  For efficiency now we coalesce the
00660         // cross interactions so that just i<=j are stored.
00661         const int arraysize = 3*pressureProfileSlabs;
00662         const BigReal *data = pressureProfileData;
00663         for (int i=0; i<numAtomTypes; i++) {
00664           for (int j=0; j<numAtomTypes; j++) {
00665             int ii=i;
00666             int jj=j;
00667             if (ii > jj) { int tmp=ii; ii=jj; jj=tmp; }
00668             const int reductionOffset = 
00669               (ii*numAtomTypes - (ii*(ii+1))/2 + jj)*arraysize;
00670             for (int k=0; k<arraysize; k++) {
00671               pressureProfileReduction->item(reductionOffset+k) += data[k];
00672             }
00673             data += arraysize;
00674           }
00675         }
00676         pressureProfileReduction->submit();
00677       }
00678     
00679       // Close boxes - i.e. signal we are done with Positions and
00680       // AtomProperties and that we are depositing Forces
00681       for (ap = ap.begin(); ap != ap.end(); ap++) {
00682         ap->positionBox->close(&(ap->x));
00683         if ( ap->p->flags.doMolly ) ap->avgPositionBox->close(&(ap->x_avg));
00684         ap->forceBox->close(&(ap->r));
00685       }
00686     }

template<class T, class S, class P>
virtual void ComputeHomeTuples< T, S, P >::initialize ( void   )  [inline, virtual]

Reimplemented from Compute.

Reimplemented in ComputeSelfTuples< T, S, P >, ComputeSelfTuples< AnisoElem, Aniso, AnisoValue >, ComputeSelfTuples< AngleElem, Angle, AngleValue >, ComputeSelfTuples< GromacsPairElem, GromacsPair, GromacsPairValue >, ComputeSelfTuples< ExclElem, Exclusion, int >, ComputeSelfTuples< DihedralElem, Dihedral, DihedralValue >, ComputeSelfTuples< ImproperElem, Improper, ImproperValue >, ComputeSelfTuples< BondElem, Bond, BondValue >, ComputeSelfTuples< CrosstermElem, Crossterm, CrosstermValue >, and ComputeSelfTuples< TholeElem, Thole, TholeValue >.

Definition at line 539 of file ComputeHomeTuples.h.

00539                                   {
00540 
00541 #ifdef NAMD_CUDA
00542       ProxyMgr *proxyMgr = ProxyMgr::Object();
00543 #endif
00544 
00545 #ifdef USE_HOMETUPLES
00546       tuples = new HomeTuples<T, S, P>();
00547 #endif
00548 
00549       // Start with empty list
00550       tuplePatchList.clear();
00551     
00552       int nPatches = patchMap->numPatches();
00553       int pid;
00554       for (pid=0; pid<nPatches; ++pid) {
00555         if ( isBasePatch[pid] ) {
00556 #ifdef NAMD_CUDA
00557           proxyMgr->createProxy(pid);
00558 #endif
00559           Patch *patch = patchMap->patch(pid);
00560           tuplePatchList.add(TuplePatchElem(patch, this));
00561         }
00562       }
00563     
00564       // Gather all proxy patches (neighbors, that is)
00565       PatchID neighbors[PatchMap::MaxOneOrTwoAway];
00566     
00567       for (pid=0; pid<nPatches; ++pid) if ( isBasePatch[pid] ) {
00568         int numNeighbors = patchMap->upstreamNeighbors(pid,neighbors);
00569         for ( int i = 0; i < numNeighbors; ++i ) {
00570           if ( ! tuplePatchList.find(TuplePatchElem(neighbors[i])) ) {
00571 #ifdef NAMD_CUDA
00572             proxyMgr->createProxy(neighbors[i]);
00573 #endif
00574             Patch *patch = patchMap->patch(neighbors[i]);
00575             tuplePatchList.add(TuplePatchElem(patch, this));
00576           }
00577         }
00578       }
00579       setNumPatches(tuplePatchList.size());
00580       doLoadTuples = true;
00581 
00582       basePriority = COMPUTE_PROXY_PRIORITY;  // no patch dependence
00583     }

template<class T, class S, class P>
virtual void ComputeHomeTuples< T, S, P >::loadTuples ( void   )  [inline, protected, virtual]

Definition at line 319 of file ComputeHomeTuples.h.

00319                                   {
00320       int numTuples;
00321 
00322       #ifdef MEM_OPT_VERSION
00323       typename ElemTraits<T>::signature *allSigs;      
00324       #else
00325       int32 **tuplesByAtom;
00326       /* const (need to propagate const) */ S *tupleStructs;
00327       #endif
00328       
00329       const P *tupleValues;
00330       Node *node = Node::Object();
00331 
00332       #ifdef MEM_OPT_VERSION
00333       allSigs = ElemTraits<T>::get_sig_pointer(node->molecule);
00334       #else      
00335       T::getMoleculePointers(node->molecule,
00336                     &numTuples, &tuplesByAtom, &tupleStructs);      
00337       #endif
00338       
00339       T::getParameterPointers(node->parameters, &tupleValues);
00340 
00341       tupleList.resize(0);
00342 
00343       LocalID aid[T::size];
00344 
00345       const int lesOn = node->simParameters->lesOn;
00346       const int soluteScalingOn = node->simParameters->soluteScalingOn;
00347       Real invLesFactor = lesOn ? 
00348                           1.0/node->simParameters->lesFactor :
00349                           1.0;
00350       const Real soluteScalingFactor = node->simParameters->soluteScalingFactor;
00351       const Bool soluteScalingAll = node->simParameters->soluteScalingAll;
00352 
00353       // cycle through each patch and gather all tuples
00354       TuplePatchListIter ai(tuplePatchList);
00355     
00356       for ( ai = ai.begin(); ai != ai.end(); ai++ )
00357       {
00358         // CompAtom *atom = (*ai).x;
00359         Patch *patch = (*ai).p;
00360         int numAtoms = patch->getNumAtoms();
00361         CompAtomExt *atomExt = (*ai).xExt; //patch->getCompAtomExtInfo();
00362     
00363         // cycle through each atom in the patch and load up tuples
00364         for (int j=0; j < numAtoms; j++)
00365         {              
00366            /* cycle through each tuple */
00367            #ifdef MEM_OPT_VERSION
00368            typename ElemTraits<T>::signature *thisAtomSig =
00369                    &allSigs[ElemTraits<T>::get_sig_id(atomExt[j])];
00370            TupleSignature *allTuples;
00371            T::getTupleInfo(thisAtomSig, &numTuples, &allTuples);
00372            for(int k=0; k<numTuples; k++) {
00373                T t(atomExt[j].id, &allTuples[k], tupleValues);
00374            #else
00375            /* get list of all tuples for the atom */
00376            int32 *curTuple = tuplesByAtom[atomExt[j].id];
00377            for( ; *curTuple != -1; ++curTuple) {             
00378              T t(&tupleStructs[*curTuple],tupleValues);
00379            #endif            
00380              register int i;
00381              aid[0] = atomMap->localID(t.atomID[0]);
00382              int homepatch = aid[0].pid;
00383              int samepatch = 1;
00384              int has_les = lesOn && node->molecule->get_fep_type(t.atomID[0]);
00385              int has_ss = soluteScalingOn && node->molecule->get_ss_type(t.atomID[0]);
00386              for (i=1; i < T::size; i++) {
00387                  aid[i] = atomMap->localID(t.atomID[i]);
00388                  samepatch = samepatch && ( homepatch == aid[i].pid );
00389                  has_les |= lesOn && node->molecule->get_fep_type(t.atomID[i]);
00390                  has_ss |= soluteScalingOn && node->molecule->get_ss_type(t.atomID[i]);
00391              }
00392              if (T::size < 4 && !soluteScalingAll) has_ss = false;
00393              if ( samepatch ) continue;
00394              t.scale = (!has_les && !has_ss) ? 1.0 : ( has_les ? invLesFactor : soluteScalingFactor );
00395              for (i=1; i < T::size; i++) {
00396                  homepatch = patchMap->downstream(homepatch,aid[i].pid);
00397              }
00398              if ( homepatch != notUsed && isBasePatch[homepatch] ) {
00399                TuplePatchElem *p;
00400                for (i=0; i < T::size; i++) {
00401                  t.p[i] = p = tuplePatchList.find(TuplePatchElem(aid[i].pid));
00402                  if ( ! p ) {
00403                      #ifdef MEM_OPT_VERSION
00404                      iout << iWARN << "Tuple with atoms ";
00405                      #else
00406                    iout << iWARN << "Tuple " << *curTuple << " with atoms ";
00407                      #endif
00408                    int erri;
00409                    for( erri = 0; erri < T::size; erri++ ) {
00410                      iout << t.atomID[erri] << "(" <<  aid[erri].pid << ") ";
00411                    }
00412                    iout << "missing patch " << aid[i].pid << "\n" << endi;
00413                    break;
00414                  }
00415                  t.localIndex[i] = aid[i].index;
00416                }
00417                if ( ! p ) continue;
00418              #ifdef MEM_OPT_VERSION
00419                //avoid adding Tuples whose atoms are all fixed
00420                if(node->simParameters->fixedAtomsOn &&
00421                   !node->simParameters->fixedAtomsForces) {
00422                  int allfixed = 1;
00423                  for(i=0; i<T::size; i++){
00424                    CompAtomExt *one = &(t.p[i]->xExt[aid[i].index]);
00425                    allfixed = allfixed & one->atomFixed;
00426                  }
00427                  if(!allfixed) tupleList.add(t);
00428                }else{
00429                  tupleList.add(t);
00430                }
00431              #else
00432                tupleList.add(t);
00433              #endif               
00434              }
00435            }
00436         }
00437       }
00438     }


Member Data Documentation

template<class T, class S, class P>
int ComputeHomeTuples< T, S, P >::accelMDdoDihe [protected]

Definition at line 456 of file ComputeHomeTuples.h.

template<class T, class S, class P>
AtomMap* ComputeHomeTuples< T, S, P >::atomMap [protected]

Definition at line 454 of file ComputeHomeTuples.h.

template<class T, class S, class P>
int ComputeHomeTuples< T, S, P >::doLoadTuples [protected]

Definition at line 441 of file ComputeHomeTuples.h.

template<class T, class S, class P>
char* ComputeHomeTuples< T, S, P >::isBasePatch [protected]

Definition at line 460 of file ComputeHomeTuples.h.

template<class T, class S, class P>
PatchMap* ComputeHomeTuples< T, S, P >::patchMap [protected]

Definition at line 453 of file ComputeHomeTuples.h.

template<class T, class S, class P>
BigReal* ComputeHomeTuples< T, S, P >::pressureProfileData [protected]

Definition at line 458 of file ComputeHomeTuples.h.

template<class T, class S, class P>
SubmitReduction* ComputeHomeTuples< T, S, P >::pressureProfileReduction [protected]

Definition at line 457 of file ComputeHomeTuples.h.

template<class T, class S, class P>
int ComputeHomeTuples< T, S, P >::pressureProfileSlabs [protected]

Definition at line 459 of file ComputeHomeTuples.h.

template<class T, class S, class P>
SubmitReduction* ComputeHomeTuples< T, S, P >::reduction [protected]

Definition at line 455 of file ComputeHomeTuples.h.

template<class T, class S, class P>
ResizeArray<T> ComputeHomeTuples< T, S, P >::tupleList [protected]

Definition at line 449 of file ComputeHomeTuples.h.

template<class T, class S, class P>
TuplePatchList ComputeHomeTuples< T, S, P >::tuplePatchList [protected]

Definition at line 450 of file ComputeHomeTuples.h.


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

Generated on 11 Nov 2019 for NAMD by  doxygen 1.6.1