ComputePatch.C

Go to the documentation of this file.
00001 
00007 /*
00008    Compute object which deals with a single patch.
00009 */
00010 
00011 #include "WorkDistrib.decl.h"
00012 #include "Node.h"
00013 #include "ComputePatch.h"
00014 #include "Priorities.h"
00015 #include "PatchMap.inl"
00016 #include "Patch.h"
00017 #include "ComputeMap.h" //needed for checking GBIS type
00018 #include "LdbCoordinator.h"
00019 
00020 #define MIN_DEBUG_LEVEL 4
00021 //#define DEBUGM
00022 #include "Debug.h"
00023 
00024 ComputePatch::ComputePatch(ComputeID c, PatchID p) : Compute(c) {
00025     setNumPatches(1);
00026     patchID = p;
00027     patch = NULL;
00028     positionBox = NULL;
00029     forceBox = NULL;
00030     gbisPhase = 3;
00031 }
00032 
00033 ComputePatch::~ComputePatch() {
00034   DebugM(4, "~ComputePatch("<<cid<<") numAtoms("<<patchID<<") = " 
00035     << numAtoms << "\n");
00036     if (positionBox != NULL) {
00037       PatchMap::Object()->patch(patchID)->unregisterPositionPickup(this,
00038          &positionBox);
00039     }
00040     if (forceBox != NULL) {
00041       PatchMap::Object()->patch(patchID)->unregisterForceDeposit(this,
00042                 &forceBox);
00043     }
00044 }
00045 
00046 void ComputePatch::initialize() {
00047     // How can we tell if BoxOwner has packed up and left?  Need a mechanism
00048     // to handle this or do we assume the Boxes have been dumped?
00049 
00050         if (positionBox == NULL) { // We have yet to get boxes
00051             if (!(patch = PatchMap::Object()->patch(patchID))) {
00052               NAMD_bug("ComputePatch used with unknown patch.");
00053             }
00054             DebugM(3, "initialize(" << cid <<")  patchid = "<<patch->getPatchID()<<"\n");
00055             positionBox = patch->registerPositionPickup(this);
00056             forceBox = patch->registerForceDeposit(this);
00057         }
00058         numAtoms = patch->getNumAtoms();
00059 
00060   DebugM(3, "initialize("<<cid<<") numAtoms("<<patchID<<") = " 
00061     << numAtoms  << " patchAddr=" << patch << "\n");
00062     Compute::initialize();
00063 
00064     int myNode = CkMyPe();
00065     if ( PatchMap::Object()->node(patchID) != myNode ) {
00066       basePriority = GB1_COMPUTE_PROXY_PRIORITY + PATCH_PRIORITY(patchID);
00067       gbisPhasePriority[0] = 0;
00068       gbisPhasePriority[1] = GB2_COMPUTE_PROXY_PRIORITY-GB1_COMPUTE_PROXY_PRIORITY;//sub GB1_PRIOR
00069       gbisPhasePriority[2] = COMPUTE_PROXY_PRIORITY-GB1_COMPUTE_PROXY_PRIORITY;
00070     } else {
00071       basePriority = GB1_COMPUTE_HOME_PRIORITY + PATCH_PRIORITY(patchID);
00072       gbisPhasePriority[0] = 0;
00073       gbisPhasePriority[1] = GB2_COMPUTE_HOME_PRIORITY-GB1_COMPUTE_HOME_PRIORITY;
00074       gbisPhasePriority[2] = COMPUTE_HOME_PRIORITY-GB1_COMPUTE_HOME_PRIORITY;
00075     }
00076 }
00077 
00078 void ComputePatch::atomUpdate() {
00079     // How can we tell if BoxOwner has packed up and left?  Need a mechanism
00080     // to handle this or do we assume the Boxes have been dumped?
00081     numAtoms = patch->getNumAtoms();
00082 
00083     // DMK - Atom Separation (water vs. non-water)
00084     #if NAMD_SeparateWaters != 0
00085       numWaterAtoms = patch->getNumWaterAtoms();
00086     #endif
00087 }
00088 
00089 void ComputePatch::doWork() {
00090   DebugM(3,patchID << ": doWork() called.\n");
00091 
00092 #ifndef NAMD_CUDA
00093   // Inform load balancer. 
00094   // I assume no threads will suspend until endWork is called
00095   LdbCoordinator::Object()->startWork(ldObjHandle);
00096 #endif
00097   if ( (computeType != computeNonbondedSelfType ) ||
00098        (!patch->flags.doGBIS || gbisPhase == 1) ) {
00099     // Open up positionBox, forceBox
00100     p = positionBox->open();
00101     r = forceBox->open();
00102     pExt = patch->getCompAtomExtInfo();
00103   }
00104 
00105   // Pass pointers to doForce
00106   doForce(p, pExt, r);
00107 // Inform load balancer
00108 #ifndef NAMD_CUDA
00109   if (patch->flags.doGBIS && (gbisPhase == 1 || gbisPhase == 2)) {
00110     LdbCoordinator::Object()->pauseWork(ldObjHandle);
00111   } else {
00112     LdbCoordinator::Object()->endWork(ldObjHandle);
00113   }
00114 #endif
00115   // Close up boxes
00116   if ( (computeType != computeNonbondedSelfType   ) ||
00117        (!patch->flags.doGBIS || gbisPhase == 3) ) {
00118     positionBox->close(&p);
00119     forceBox->close(&r);
00120   }
00121   DebugM(2,patchID << ": doWork() completed.\n");
00122 }
00123 

Generated on Sat Nov 18 01:17:13 2017 for NAMD by  doxygen 1.4.7