1 #ifndef __MLP_RUNTIME__
2 #define __MLP_RUNTIME__
7 #include "psemaphore.h"
31 #define PARENTCOARSE 5
41 #define H_MASK (NUMBINS<<4)-1
51 typedef struct REntry_t{
52 struct Hashtable_t* hashtable;
53 struct BinItem_t* binitem;
54 struct Vector_t* vector;
56 struct MemoryQueue_t* queue;
59 psemaphore parentStallSem;
60 int type; // fine read:0, fine write:1, parent read:2, parent write:3 coarse: 4, parent coarse:5, scc: 6
65 typedef struct MemoryQueueItem_t {
66 int type; // hashtable:0, vector:1, singleitem:2
67 int total; //total non-retired
68 int status; //NOTREADY, READY
69 struct MemoryQueueItem_t *next;
72 typedef struct MemoryQueue_t {
73 MemoryQueueItem * head;
74 MemoryQueueItem * tail;
75 REntry * binbuf[NUMBINS];
76 REntry * buf[NUMRENTRY];
80 typedef struct BinItem_t {
82 int status; //NOTREADY, READY
83 int type; //READBIN:0, WRITEBIN:1
84 struct BinItem_t * next;
87 typedef struct Hashtable_t {
89 struct BinElement_t* array[NUMBINS];
90 struct Queue* unresolvedQueue;
93 typedef struct BinElement_t {
98 typedef struct WriteBinItem_t {
103 typedef struct ReadBinItem_t {
105 REntry * array[NUMREAD];
109 typedef struct Vector_t {
110 MemoryQueueItem item;
111 REntry * array[NUMITEMS];
115 typedef struct SCC_t {
116 MemoryQueueItem item;
120 int ADDRENTRY(MemoryQueue* q, REntry * r);
121 void RETIRERENTRY(MemoryQueue* Q, REntry * r);
124 // forward declaration of pointer type
125 typedef struct SESEcommon_t* SESEcommon_p;
127 // these fields are common to any SESE, and casting the
128 // generated SESE record to this can be used, because
129 // the common structure is always the first item in a
130 // customized SESE record
131 typedef struct SESEcommon_t {
133 // the identifier for the class of sese's that
134 // are instances of one particular static code block
137 // a parent waits on this semaphore when stalling on
138 // this child, the child gives it at its SESE exit
142 // the lock guards the following data SESE's
143 // use to coordinate with one another
144 pthread_mutex_t lock;
146 struct Queue* forwardList;
147 volatile int unresolvedDependencies;
149 pthread_cond_t doneCond;
152 pthread_cond_t runningChildrenCond;
153 int numRunningChildren;
157 psemaphore parentStallSem;
158 pthread_cond_t stallDone;
162 int unresolvedRentryIdx;
163 struct MemoryQueue_t** memoryQueueArray;
164 struct REntry_t* rentryArray[NUMRENTRY];
165 struct REntry_t* unresolvedRentryArray[NUMRENTRY];
169 // a thread-local stack of SESEs and function to
170 // ensure it is initialized once per thread
172 extern __thread struct Queue* seseCallStack;
173 extern __thread pthread_once_t mlpOnceObj;
174 void mlpInitOncePerThread();
176 extern __thread SESEcommon_p seseCaller;
179 // simple mechanical allocation and
180 // deallocation of SESE records
181 void* mlpCreateSESErecord( int size );
182 void mlpDestroySESErecord( void* seseRecord );
183 void* mlpAllocSESErecord( int size );
185 MemoryQueue** mlpCreateMemoryQueueArray(int numMemoryQueue);
186 REntry* mlpCreateFineREntry(int type, void* seseToIssue, void* dynID);
187 REntry* mlpCreateREntry(int type, void* seseToIssue);
188 MemoryQueue* createMemoryQueue();
189 void rehashMemoryQueue(SESEcommon_p seseParent);
191 #endif /* __MLP_RUNTIME__ */