Compute.C

Go to the documentation of this file.
00001 
00007 /*
00008    Top of Compute hierarchy.  
00009    enqueueWork() - delivers Compute object itself to queue up for doWork()
00010    doWork() - called by work queue
00011 */
00012 
00013 #include "main.h"
00014 #include "charm++.h"
00015 
00016 #include "WorkDistrib.decl.h"
00017 #include "WorkDistrib.h"
00018 
00019 #include "NamdTypes.h"
00020 #include "Box.h"
00021 #include "OwnerBox.h"
00022 
00023 #include "Node.h"
00024 #include "Compute.h"
00025 #include "Priorities.h"
00026 
00027 #include "LdbCoordinator.h"
00028 
00029 #define MIN_DEBUG_LEVEL 4
00030 // #define DEBUGM
00031 #include "Debug.h"
00032 
00033 Compute::Compute(ComputeID c) : gbisPhase(1),basePriority(0), cid(c),
00034         localWorkMsg(new (PRIORITY_SIZE) LocalWorkMsg) { 
00035   gbisPhasePriority[0] = 0;
00036   gbisPhasePriority[1] = 0;
00037   gbisPhasePriority[2] = 0;
00038   doAtomUpdate = false;
00039   computeType = ComputeMap::Object()->type(c);
00040   LdbIdField(ldObjHandle.id, 0) = 0;
00041 }
00042 
00043 Compute::~Compute() {
00044   delete localWorkMsg;
00045 }
00046 
00047 void Compute::enqueueWork() {
00048   if (!this) { DebugM(4,"This Compute is NULL!!!\n"); }
00049   if ( ! noWork() ) {
00050     //gbisPhase = 1; //first phase - this should already be 1
00051     WorkDistrib::messageEnqueueWork(this);  // should be in ComputeMgr?
00052   } else {
00053     //don't enqueue work
00054   }
00055 }
00056 
00057 
00058 //---------------------------------------------------------------------
00059 // Signal from patch or proxy that data is ready.
00060 // When all Patches and Proxies needed by this Compute object
00061 // have checked-in, we are ready to enqueueWork()
00062 //---------------------------------------------------------------------
00063 void Compute::patchReady(PatchID patchID, int doneMigration, int seq) { 
00064   if (doneMigration) { // If any patch has done migration - we must remap
00065     doAtomUpdate = true; 
00066   }
00067 
00068   if (numPatches <= 0) {
00069       DebugM(5,"Compute::patchReady("<<patchID<<")-call not valid!\n");
00070   } else {
00071     if (! --patchReadyCounter) {
00072       patchReadyCounter = numPatches;
00073       //gbisPhase = 1;
00074       sequenceNumber = seq;  // breaks CUDA priority if done earlier
00075       if (doAtomUpdate) {
00076         atomUpdate();
00077         doAtomUpdate = false;
00078       }
00079       enqueueWork();
00080     }
00081   }
00082 }
00083 
00084 void Compute::gbisP2PatchReady(PatchID pid, int seq) {
00085 
00086   if (! --patchReadyCounter) {
00087     patchReadyCounter = numPatches;
00088     //gbisPhase = 2;
00089     sequenceNumber = seq;
00090     enqueueWork();
00091   }
00092 }
00093 
00094 void Compute::gbisP3PatchReady(PatchID pid, int seq) {
00095   if (! --patchReadyCounter) {
00096     patchReadyCounter = numPatches;
00097     //gbisPhase = 3;
00098     sequenceNumber = seq;
00099     enqueueWork();
00100   }
00101 }
00102 
00103 
00104 int Compute::noWork() {
00105   return 0;
00106 }
00107 
00108 void Compute::doWork() {
00109     DebugM(5,"Default Compute::doWork() called.\n");
00110 }
00111 
00112 void Compute::finishPatch(int) {
00113     DebugM(5,"Default Compute::finishPatch() called.\n");
00114 }
00115 

Generated on Sat Jul 21 01:17:11 2018 for NAMD by  doxygen 1.4.7