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];
87 typedef struct BinElement_t {
92 typedef struct WriteBinItem_t {
97 typedef struct ReadBinItem_t {
99 REntry * array[NUMREAD];
103 typedef struct Vector_t {
104 MemoryQueueItem item;
105 REntry * array[NUMITEMS];
109 typedef struct SCC_t {
110 MemoryQueueItem item;
114 int ADDRENTRY(MemoryQueue* q, REntry * r);
115 void RETIRERENTRY(MemoryQueue* Q, REntry * r);
118 // forward declaration of pointer type
119 typedef struct SESEcommon_t* SESEcommon_p;
121 // these fields are common to any SESE, and casting the
122 // generated SESE record to this can be used, because
123 // the common structure is always the first item in a
124 // customized SESE record
125 typedef struct SESEcommon_t {
127 // the identifier for the class of sese's that
128 // are instances of one particular static code block
131 // a parent waits on this semaphore when stalling on
132 // this child, the child gives it at its SESE exit
136 // the lock guards the following data SESE's
137 // use to coordinate with one another
138 pthread_mutex_t lock;
140 struct Queue* forwardList;
141 volatile int unresolvedDependencies;
143 pthread_cond_t doneCond;
146 pthread_cond_t runningChildrenCond;
147 int numRunningChildren;
151 psemaphore parentStallSem;
152 pthread_cond_t stallDone;
156 struct MemoryQueue_t** memoryQueueArray;
157 struct REntry_t* rentryArray[NUMRENTRY];
161 // a thread-local stack of SESEs and function to
162 // ensure it is initialized once per thread
164 extern __thread struct Queue* seseCallStack;
165 extern __thread pthread_once_t mlpOnceObj;
166 void mlpInitOncePerThread();
168 extern __thread SESEcommon_p seseCaller;
171 // simple mechanical allocation and
172 // deallocation of SESE records
173 void* mlpCreateSESErecord( int size );
174 void mlpDestroySESErecord( void* seseRecord );
175 void* mlpAllocSESErecord( int size );
177 MemoryQueue** mlpCreateMemoryQueueArray(int numMemoryQueue);
178 REntry* mlpCreateFineREntry(int type, void* seseToIssue, void* dynID);
179 REntry* mlpCreateREntry(int type, void* seseToIssue);
180 MemoryQueue* createMemoryQueue();
182 #endif /* __MLP_RUNTIME__ */