Compute.h

Go to the documentation of this file.
00001 
00007 /*
00008    Base class for all Compute objects. Almost an abstract
00009    class except that it does do the basic patchReady()
00010    countdown.
00011 */
00012 
00013 #ifndef COMPUTE_H
00014 #define COMPUTE_H
00015 
00016 #include "main.h"
00017 #include "charm++.h"
00018 
00019 #include "NamdTypes.h"
00020 
00021 class Node;
00022 class PatchMap;
00023 class LocalWorkMsg;
00024 
00025 // Base class for various forms of Compute objects
00026 // for example: <linkto class=ComputeAngles>ComputeAngles</linkto> 
00027 // and <linkto class=ComputeNonbondedExcl>ComputeNonbondedExcl</linkto>
00028 class Compute {
00029 private:
00030   int patchReadyCounter;
00031   int numPatches;
00032   int doAtomUpdate;
00033   int sequenceNumber;
00034 
00035 protected:
00036   int computeType;
00037   int basePriority;
00038   void enqueueWork();
00039   int gbisPhase;//earlier phases have higher priority
00040   int gbisPhasePriority[3];//earlier phases have higher priority
00041 
00042 public:
00043   const ComputeID cid;
00044   LDObjHandle ldObjHandle;
00045 
00046   LocalWorkMsg *const localWorkMsg;
00047   Compute(ComputeID);
00048   int type() { return computeType; };
00049 
00050   virtual ~Compute();
00051 
00052   void setNumPatches(int n) { patchReadyCounter = numPatches = n; }
00053   int getNumPatches() { return (numPatches); };
00054 
00055   // registers for boxes
00056   virtual void initialize() {};
00057   // destructor better unregister for boxes!
00058 
00059   virtual void atomUpdate() {};
00060   virtual void patchReady(PatchID, int doneMigration, int seq);
00061   virtual int noWork(); // cleans up and returns 1 if no work to do
00062   virtual void doWork(); // actually does the work if noWork() returns 0
00063   virtual void finishPatch(int);
00064   int sequence(void) { return sequenceNumber; }
00065   int priority(void) { return basePriority+gbisPhasePriority[gbisPhase-1]; }
00066   int getGBISPhase(void) {return gbisPhase;}
00067 
00068   virtual void gbisP2PatchReady(PatchID, int seq);
00069   virtual void gbisP3PatchReady(PatchID, int seq);
00070 
00071 };
00072 
00073 /* For projection's usage: each compute object's work is associated 
00074  * with a user event in projections. This macro indicates the offset 
00075  * of the event ID that those compute objects' user events begin with.
00076  */ 
00077 #define TRACE_COMPOBJ_IDOFFSET 10000
00078 
00079 #endif
00080 

Generated on Thu Nov 23 01:17:10 2017 for NAMD by  doxygen 1.4.7