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

Generated on Sat Sep 23 01:17:11 2017 for NAMD by  doxygen 1.4.7