#include <OptPme.h>
Inheritance diagram for OptPmeCompute:

Public Member Functions | |
| OptPmeCompute (ComputeID c) | |
| virtual | ~OptPmeCompute () |
| void | doWork () |
| void | sendPencils () |
| void | copyPencils (OptPmeGridMsg *) |
| void | ungridForces () |
| void | setMgr (OptPmeMgr *mgr) |
Public Attributes | |
| double * | zline_storage |
| float * | sp_zstorage |
|
|
Definition at line 478 of file OptPme.C. References DebugM, ReductionMgr::Object(), REDUCTIONS_BASIC, and ReductionMgr::willSubmit(). 00478 : 00479 ComputeHomePatches(c) 00480 { 00481 DebugM(4,"OptPmeCompute created.\n"); 00482 00483 CProxy_OptPmeMgr::ckLocalBranch( 00484 CkpvAccess(BOCclass_group).computePmeMgr)->setCompute(this); 00485 00486 _initialized = false; 00487 00488 useAvgPositions = 1; 00489 00490 reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC); 00491 }
|
|
|
Definition at line 692 of file OptPme.C. 00693 {
00694 delete [] zline_storage;
00695 delete [] q_arr;
00696 }
|
|
|
Definition at line 860 of file OptPme.C. References PmeGrid::dim2, OptPmeGridMsg::qgrid, OptPmeGridMsg::xlen, OptPmeGridMsg::xstart, OptPmeGridMsg::ylen, and OptPmeGridMsg::ystart. Referenced by OptPmeMgr::recvUngrid(). 00860 {
00861
00862 if (!_initialized) initializeOptPmeCompute();
00863
00864 int ibegin = msg->xstart;
00865 int iend = msg->xstart + msg->xlen;
00866 int jbegin = msg->ystart;
00867 int jend = msg->ylen;
00868 int fcount = zlen * msg->xlen * msg->ylen;
00869
00870 float *qmsg = msg->qgrid;
00871 double *data = q_arr[ibegin * myGrid.dim2 + jbegin];
00872
00873 #pragma disjoint (*qmsg, *data)
00874 #pragma unroll(8)
00875 for ( int k=0; k<fcount; ++k )
00876 data[k] = *(qmsg++);
00877 }
|
|
|
Reimplemented from Compute. Definition at line 699 of file OptPme.C. References OptPmeMgr::_iter, ResizeArrayIter< T >::begin(), BigReal, PmeParticle::cg, OptPmeMgr::constant_pressure, DebugM, ResizeArrayIter< T >::end(), OptPmeRealSpace::fill_charges(), OptPmeMgr::handle, PmeGrid::order, PHASE_GR, pme_d2f(), scale_n_copy_coordinates(), sendPencils(), sp_zstorage, SubmitReduction::submit(), TRACE_COMPOBJ_IDOFFSET, OptPmeMgr::xPencil, and zline_storage. 00700 {
00701 DebugM(4,"Entering OptPmeCompute::doWork().\n");
00702
00703 #ifdef TRACE_COMPUTE_OBJECTS
00704 double traceObjStartTime = CmiWallTimer();
00705 #endif
00706
00707 if (!_initialized) initializeOptPmeCompute();
00708
00709 ResizeArrayIter<PatchElem> ap(patchList);
00710
00711 // Skip computations if nothing to do.
00712 if ( ! patchList[0].p->flags.doFullElectrostatics )
00713 {
00714 for (ap = ap.begin(); ap != ap.end(); ap++) {
00715 CompAtom *x = (*ap).positionBox->open();
00716 Results *r = (*ap).forceBox->open();
00717 (*ap).positionBox->close(&x);
00718 (*ap).forceBox->close(&r);
00719 }
00720 reduction->submit();
00721 return;
00722 }
00723
00724 myMgr->_iter ++; //this is a pme step
00725
00726 // allocate storage
00727 numLocalAtoms = 0;
00728 for (ap = ap.begin(); ap != ap.end(); ap++) {
00729 numLocalAtoms += (*ap).p->getNumAtoms();
00730 }
00731
00732 Lattice &lattice = patchList[0].p->flags.lattice;
00733
00734 localData = new PmeParticle[numLocalAtoms];
00735 // get positions and charges
00736 PmeParticle * data_ptr = localData;
00737
00738 int natoms = 0;
00739 if (myMgr->constant_pressure)
00740 resetPatchCoordinates(lattice); //Update patch coordinates with new lattice
00741
00742 for (ap = ap.begin(); ap != ap.end(); ap++) {
00743 #ifdef NETWORK_PROGRESS
00744 CmiNetworkProgress();
00745 #endif
00746
00747 CompAtom *x = (*ap).positionBox->open();
00748 if ( patchList[0].p->flags.doMolly ) {
00749 (*ap).positionBox->close(&x);
00750 x = (*ap).avgPositionBox->open();
00751 }
00752 int numAtoms = (*ap).p->getNumAtoms();
00753 int order_1 = myGrid.order - 1;
00754 scale_n_copy_coordinates(x, localData, numAtoms,
00755 lattice, myGrid,
00756 xstart + order_1, xlen - order_1,
00757 ystart + order_1, ylen - order_1,
00758 zstart + order_1, zlen - order_1,
00759 strayChargeErrors);
00760 natoms += numAtoms;
00761
00762 if ( patchList[0].p->flags.doMolly ) { (*ap).avgPositionBox->close(&x); }
00763 else { (*ap).positionBox->close(&x); }
00764 }
00765
00766 numLocalAtoms = natoms; //Exclude all atoms out of range
00767
00768 // calculate self energy
00769 BigReal ewaldcof = ComputeNonbondedUtil::ewaldcof;
00770 evir[0] = 0;
00771 BigReal selfEnergy = 0;
00772 data_ptr = localData;
00773 int i;
00774 for(i=0; i<numLocalAtoms; ++i)
00775 {
00776 selfEnergy += data_ptr->cg * data_ptr->cg;
00777 ++data_ptr;
00778 }
00779 selfEnergy *= -1. * ewaldcof / SQRT_PI;
00780 evir[0][0] += selfEnergy;
00781
00782 double **q = q_arr;
00783 memset( (void*) zline_storage, 0, zlen * nzlines * sizeof(double) );
00784
00785 myRealSpace[0] = new OptPmeRealSpace(myGrid,numLocalAtoms);
00786 //scale_coordinates(localData, numLocalAtoms, lattice, myGrid);
00787 if (!strayChargeErrors)
00788 myRealSpace[0]->fill_charges(q, localData, zstart, zlen);
00789
00790 #ifdef TRACE_COMPUTE_OBJECTS
00791 traceUserBracketEvent(TRACE_COMPOBJ_IDOFFSET+this->cid, traceObjStartTime, CmiWallTimer());
00792 #endif
00793
00794 if (myMgr->constant_pressure && patchList[0].patchID == 0)
00795 myMgr->xPencil.recvLattice (lattice);
00796
00797 if (myMgr->_iter <= many_to_many_start)
00798 sendPencils();
00799 #if CHARM_VERSION > 60000
00800 else {
00801 pme_d2f (sp_zstorage, zline_storage, nzlines * zlen);
00802 CmiDirect_manytomany_start (myMgr->handle, PHASE_GR);
00803 }
00804 #endif
00805 }
|
|
|
Definition at line 809 of file OptPme.C. References PmeGrid::block1, PmeGrid::block2, PmeGrid::dim2, PmeGrid::dim3, PmeGrid::K1, PmeGrid::K2, OptPmeGridMsg::patchID, OptPmeGridMsg::qgrid, ResizeArray< Elem >::size(), OptPmeGridMsg::sourceNode, OptPmeMgr::usePencils, PmeGrid::xBlocks, OptPmeGridMsg::xlen, OptPmeGridMsg::xstart, PmeGrid::yBlocks, OptPmeGridMsg::ylen, OptPmeGridMsg::ystart, PmeGrid::zBlocks, OptPmeGridMsg::zlen, OptPmeMgr::zPencil, and OptPmeGridMsg::zstart. Referenced by doWork(). 00809 {
00810
00811 assert ( myMgr->usePencils );
00812
00813 //iout << iPE << " Sending charge grid for " << numLocalAtoms << " atoms to FFT with " << myMgr->numPencilsActive << " messages" <<".\n" << endi;
00814
00815 int xBlocks = myGrid.xBlocks;
00816 int yBlocks = myGrid.yBlocks;
00817 int zBlocks = myGrid.zBlocks;
00818
00819 int K1 = myGrid.K1;
00820 int K2 = myGrid.K2;
00821 int dim2 = myGrid.dim2;
00822 int dim3 = myGrid.dim3;
00823 int block1 = myGrid.block1;
00824 int block2 = myGrid.block2;
00825
00826 //Lattice lattice = patchList[0].p->flags.lattice;
00827
00828 int nactive = 0;
00829 for (int idx = 0; idx < pencilVec.size(); idx++) {
00830 int xstart = pencilVec[idx].xmin;
00831 int ystart = pencilVec[idx].ymin;
00832 int xlen = pencilVec[idx].xmax - pencilVec[idx].xmin + 1;
00833 int ylen = pencilVec[idx].ymax - pencilVec[idx].ymin + 1;
00834 int ib = pencilVec[idx].ib;
00835 int jb = pencilVec[idx].jb;
00836 double *data = pencilVec[idx].data;
00837
00838 int fcount = xlen * ylen * zlen;
00839 OptPmeGridMsg *msg = new (fcount, PRIORITY_SIZE) OptPmeGridMsg;
00840 msg->zstart = zstart;
00841 msg->zlen = zlen;
00842 msg->xstart = xstart;
00843 msg->xlen = xlen;
00844 msg->ystart = ystart;
00845 msg->ylen = ylen;
00846 msg->sourceNode = CkMyPe();
00847 msg->patchID = patchList[0].patchID;
00848
00849 float *qmsg = msg->qgrid;
00850 #pragma disjoint (*data, *qmsg)
00851 #pragma unroll(8)
00852 for ( int k=0; k< fcount; ++k )
00853 *(qmsg++) = data[k];
00854
00855 myMgr->zPencil(ib,jb,0).recvGrid(msg);
00856 }
00857 }
|
|
|
Definition at line 50 of file OptPme.h. Referenced by OptPmeMgr::setCompute(). 00050 { myMgr = mgr; }
|
|
|
Definition at line 879 of file OptPme.C. References OptPmeMgr::_iter, ResizeArrayIter< T >::begin(), SimParameters::commOnly, OptPmeRealSpace::compute_forces(), ResizeArrayIter< T >::end(), Results::f, Force, SubmitReduction::item(), Node::Object(), pme_f2d(), REDUCTION_ELECT_ENERGY_SLOW, REDUCTION_STRAY_CHARGE_ERRORS, scale_forces(), Node::simParameters, simParams, sp_zstorage, SubmitReduction::submit(), Vector::x, Vector::y, Vector::z, and zline_storage. Referenced by OptPmeMgr::ungridCalc(). 00879 {
00880
00881 //printf ("%d: In OptPMECompute::ungridforces\n", CkMyPe());
00882
00883 if (myMgr->_iter > many_to_many_start)
00884 pme_f2d (zline_storage, sp_zstorage, nzlines * zlen);
00885
00886 SimParameters *simParams = Node::Object()->simParameters;
00887 Vector *localResults = new Vector[numLocalAtoms];
00888 //memset (localResults, 0, sizeof (Vector) * numLocalAtoms);
00889
00890 Vector *gridResults;
00891 gridResults = localResults;
00892
00893 Vector pairForce = 0.;
00894 Lattice lattice = patchList[0].p->flags.lattice;
00895 if(!simParams->commOnly) {
00896 #ifdef NETWORK_PROGRESS
00897 CmiNetworkProgress();
00898 #endif
00899
00900 if (!strayChargeErrors) {
00901 myRealSpace[0]->compute_forces(q_arr, localData, gridResults, zstart, zlen);
00902 scale_forces(gridResults, numLocalAtoms, lattice);
00903 }
00904 delete myRealSpace[0];
00905 }
00906 delete [] localData;
00907 // delete [] localPartition;
00908
00909 Vector *results_ptr = localResults;
00910 ResizeArrayIter<PatchElem> ap(patchList);
00911
00912 // add in forces
00913 for (ap = ap.begin(); ap != ap.end(); ap++) {
00914 Results *r = (*ap).forceBox->open();
00915 Force *f = r->f[Results::slow];
00916 int numAtoms = (*ap).p->getNumAtoms();
00917
00918 if ( ! strayChargeErrors && ! simParams->commOnly ) {
00919 for(int i=0; i<numAtoms; ++i) {
00920 f[i].x += results_ptr->x;
00921 f[i].y += results_ptr->y;
00922 f[i].z += results_ptr->z;
00923 ++results_ptr;
00924 }
00925 }
00926
00927 (*ap).forceBox->close(&r);
00928 }
00929
00930 delete [] localResults;
00931
00932 double scale = 1.;
00933
00934 reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += evir[0][0] * scale;
00935 reduction->item(REDUCTION_STRAY_CHARGE_ERRORS) += strayChargeErrors;
00936 strayChargeErrors = 0;
00937 reduction->submit();
00938 }
|
|
|
Definition at line 53 of file OptPme.h. Referenced by doWork(), and ungridForces(). |
|
|
Definition at line 52 of file OptPme.h. Referenced by doWork(), and ungridForces(). |
1.3.9.1