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 int type; // fine read:0, fine write:1, parent read:2, parent write:3 coarse: 4, parent coarse:5, scc: 6
53 struct Hashtable_t* hashtable;
54 struct BinItem_t* binitem;
55 struct Vector_t* vector;
57 struct MemoryQueue_t* queue;
58 psemaphore parentStallSem;
63 typedef struct MemoryQueueItem_t {
64 int type; // hashtable:0, vector:1, singleitem:2
65 int total; //total non-retired
66 int status; //NOTREADY, READY
67 struct MemoryQueueItem_t *next;
70 typedef struct MemoryQueue_t {
71 MemoryQueueItem * head;
72 MemoryQueueItem * tail;
75 typedef struct BinItem_t {
77 int status; //NOTREADY, READY
78 int type; //READBIN:0, WRITEBIN:1
79 struct BinItem_t * next;
82 typedef struct Hashtable_t {
84 struct BinElement_t* array[NUMBINS];
85 struct Queue* unresolvedQueue;
88 typedef struct BinElement_t {
93 typedef struct WriteBinItem_t {
98 typedef struct ReadBinItem_t {
100 REntry * array[NUMREAD];
104 typedef struct Vector_t {
105 MemoryQueueItem item;
106 REntry * array[NUMITEMS];
110 typedef struct SCC_t {
111 MemoryQueueItem item;
115 int ADDRENTRY(MemoryQueue* q, REntry * r);
116 void RETIRERENTRY(MemoryQueue* Q, REntry * r);
119 // forward declaration of pointer type
120 typedef struct SESEcommon_t* SESEcommon_p;
122 // these fields are common to any SESE, and casting the
123 // generated SESE record to this can be used, because
124 // the common structure is always the first item in a
125 // customized SESE record
126 typedef struct SESEcommon_t {
128 // the identifier for the class of sese's that
129 // are instances of one particular static code block
132 // a parent waits on this semaphore when stalling on
133 // this child, the child gives it at its SESE exit
137 // the lock guards the following data SESE's
138 // use to coordinate with one another
139 pthread_mutex_t lock;
141 struct Queue* forwardList;
142 volatile int unresolvedDependencies;
144 pthread_cond_t doneCond;
147 pthread_cond_t runningChildrenCond;
148 int numRunningChildren;
152 psemaphore parentStallSem;
153 pthread_cond_t stallDone;
157 int unresolvedRentryIdx;
158 struct MemoryQueue_t** memoryQueueArray;
159 struct REntry_t* rentryArray[NUMRENTRY];
160 struct REntry_t* unresolvedRentryArray[NUMRENTRY];
164 // a thread-local stack of SESEs and function to
165 // ensure it is initialized once per thread
167 extern __thread struct Queue* seseCallStack;
168 extern __thread pthread_once_t mlpOnceObj;
169 void mlpInitOncePerThread();
171 extern __thread SESEcommon_p seseCaller;
174 // simple mechanical allocation and
175 // deallocation of SESE records
176 void* mlpCreateSESErecord( int size );
177 void mlpDestroySESErecord( void* seseRecord );
178 void* mlpAllocSESErecord( int size );
180 MemoryQueue** mlpCreateMemoryQueueArray(int numMemoryQueue);
181 REntry* mlpCreateFineREntry(int type, void* seseToIssue, void* dynID);
182 REntry* mlpCreateREntry(int type, void* seseToIssue);
183 MemoryQueue* createMemoryQueue();
185 #endif /* __MLP_RUNTIME__ */