BIE |
/home/weinberg/src/BIE/include/TileRequestHandlerThread.h00001 #ifndef TileRequestHandlerThread_h 00002 #define TileRequestHandlerThread_h 00003 00004 #include "EvaluationRequest.h" 00005 00006 #include <BIEmpi.h> 00007 #include <vector> 00008 #include <list> 00009 #include <cc++/thread.h> 00010 #include "ElapsedTime.h" 00011 00012 using namespace ost; 00013 00014 namespace BIE { 00015 00016 00017 class TileMasterWorkerThread; // forward declaration 00018 00019 00026 class TileRequestHandlerThread : public Thread { 00027 00028 public: 00033 TileRequestHandlerThread(int numWorkersInTileGroup, 00034 vector<int> *p_GroupIdToSystemId, 00035 vector<int> *p_SystemIdToGroupId, 00036 vector<MPI_Comm> *p_comms, 00037 Semaphore *numberSlavesReady); 00038 00039 void reInitialize(int tileGroupSize, 00040 vector<int> *groupIdToSystemId, 00041 vector<int> *systemIdToGroupId, 00042 vector<MPI_Comm> *comms, 00043 Semaphore *numberSlavesReady); 00044 00046 void setTileMasterWorkerThread(TileMasterWorkerThread* tileMasterWorkerThread); 00047 00049 void masterWorkerRegister(); 00050 00053 void masterWorkerAvailable(); 00054 00055 00056 00058 void resetPause(); 00059 00061 void unPause(); 00062 00064 void stopPausedThread(); 00065 virtual ~TileRequestHandlerThread(){}; 00066 00067 00069 virtual void run (); 00070 00074 virtual void enqueueRequest(EvaluationRequest *request); 00075 00078 virtual void readAndProcessMessage(MPI_Status *status); 00079 00081 bool allWorking(); 00082 00084 bool noneWorking(); 00085 00087 bool noMPISlaves(); 00088 00090 bool workAvailable(); 00091 00093 virtual void final(); 00094 00095 00096 // Event that signifies some work just went out. 00097 Event MPIThreadLoopEvent; 00098 00099 //aah todo Why doesn't volatile work here? 00100 /*volatile*/ vector<double> startTime; 00101 /*volatile*/ vector<double> endTime; 00102 vector< vector<int> > histo; 00103 00104 ElapsedTime workerWaitTime; 00105 ElapsedTime workWaitTime; 00106 ElapsedTime mutexWaitTime; 00107 ElapsedTime probeTime; 00108 ElapsedTime IprobeTime; 00109 ElapsedTime loopEventWaitTime; 00110 ElapsedTime thrqMutexHoldTime; 00111 ElapsedTime recvTime; 00112 00113 private: 00114 00115 // helper function for constructors and reInitialize methods. 00116 void commonInitialize(int tileGroupSize, 00117 vector<int> *groupIdToSystemId, 00118 vector<int> *systemIdToGroupId, 00119 vector<MPI_Comm> *p_comms, 00120 Semaphore *numberSlavesReady); 00121 volatile bool stopRequested; 00122 volatile bool resetRequested; 00123 00124 Semaphore workerAvailableSemaphore; // initializes to zero 00125 Semaphore requestAvailableSemaphore; // initializes to zero 00126 00127 int workerAvailableSemaphoreCount; 00128 int requestAvailableSemaphoreCount; 00129 00130 // Semaphores to control resetting and stopping 00131 Semaphore exitedMainLoop; 00132 Semaphore resumeMainLoop; 00133 00134 // this object also owns the request queue. 00135 list<EvaluationRequest*> requestQueue; 00136 00138 Mutex requestQueueMutex; 00139 00140 /*volatile*/ vector<EvaluationRequest*> pendingRequest; 00141 00142 vector<int> *groupIdToSystemId; 00143 vector<int> *systemIdToGroupId; 00144 vector<MPI_Comm> *comms; 00145 int numWorkersInTileGroup; 00146 00147 TileMasterWorkerThread *tileMasterWorkerThread; 00148 }; 00149 00150 } 00151 00152 00153 #endif // TileRequestHandlerThread_h 00154 Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU. Documentation generated at Fri Mar 26 00:35:11 2010 by
|