1 #ifndef MULTICORE_RUNTIME
2 #define MULTICORE_RUNTIME
4 ////////////////////////////////////////////////////////////////
6 ///////////////////////////////////////////////////////////////
8 // data structures for msgs
18 volatile bool isMsgSending;
20 // data structures of status for termination
21 int corestatus[NUMCORES]; // records status of each core
24 int numsendobjs[NUMCORES]; // records how many objects a core has sent out
25 int numreceiveobjs[NUMCORES]; // records how many objects a core has received
30 int self_numreceiveobjs;
32 // data structures for locking
33 struct RuntimeHash locktable;
34 static struct RuntimeHash* locktbl = &locktable;
39 struct RuntimeHash * objRedirectLockTbl;
45 // data structures for waiting objs
46 struct Queue objqueue;
48 // data structures for shared memory allocation
50 struct bamboo_shared_mem {
52 struct bamboo_shared_mem * next;
54 struct bamboo_smem_list {
55 struct bamboo_shared_mem * head;
56 struct bamboo_shared_mem * tail;
58 struct bamboo_smem_list * bamboo_free_msps;
59 mspace bamboo_cur_msp;
62 // data structures for profile mode
65 #define TASKINFOLENGTH 10000
66 //#define INTERRUPTINFOLENGTH 500
72 typedef struct task_info {
74 unsigned long long startTime;
75 unsigned long long endTime;
76 unsigned long long exitIndex;
77 struct Queue * newObjs;
80 /*typedef struct interrupt_info {
85 TaskInfo * taskInfoArray[TASKINFOLENGTH];
87 bool taskInfoOverflow;
88 /*InterruptInfo * interruptInfoArray[INTERRUPTINFOLENGTH];
89 int interruptInfoIndex;
90 bool interruptInfoOverflow;*/
91 int profilestatus[NUMCORES]; // records status of each core
94 #endif // #ifdef PROFILE
99 /////////////////////////////////////////////////////////////
101 ////////////////////////////////////////////////////////////
102 // these are functions should be implemented in //
103 // multicore runtime for any multicore processors //
104 ////////////////////////////////////////////////////////////
107 inline void initialization(void) __attribute__((always_inline));
108 inline void initCommunication(void) __attribute__((always_inline));
109 inline void fakeExecution(void) __attribute__((always_inline));
110 inline void terminate(void) __attribute__((always_inline));
112 inline void send_msg_1(int targetcore, unsigned long n0) __attribute__((always_inline));
113 inline void send_msg_2(int targetcore, unsigned long n0, unsigned long n1) __attribute__((always_inline));
114 inline void send_msg_3(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2) __attribute__((always_inline));
115 inline void send_msg_4(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3) __attribute__((always_inline));
116 inline void send_msg_5(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3, unsigned long n4) __attribute__((always_inline));
117 inline void send_msg_6(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3, unsigned long n4, unsigned long n5) __attribute__((always_inline));
118 inline void cache_msg_2(int targetcore, unsigned long n0, unsigned long n1) __attribute__((always_inline));
119 inline void cache_msg_3(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2) __attribute__((always_inline));
120 inline void cache_msg_4(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3) __attribute__((always_inline));
121 inline void cache_msg_6(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3, unsigned long n4, unsigned long n5) __attribute__((always_inline));
122 inline void transferObject(struct transObjInfo * transObj);
123 inline int receiveMsg(void) __attribute__((always_inline));
126 inline void profileTaskStart(char * taskname) __attribute__((always_inline));
127 inline void profileTaskEnd(void) __attribute__((always_inline));
128 void outputProfileData();
129 #endif // #ifdef PROFILE
130 ///////////////////////////////////////////////////////////
132 //////////////////////////////////////////////////////////////////////////////////////
133 // For each version of BAMBOO runtime, there should be a header file named //
134 // runtim_arch.h defining following MARCOS: //
135 // BAMBOO_TOTALCORE: the total # of cores available in the processor //
136 // BAMBOO_NUM_OF_CORE: the # of current residing core //
137 // BAMBOO_GET_NUM_OF_CORE(): compute the # of current residing core //
138 // BAMBOO_DEBUGPRINT(x): print out integer x //
139 // BAMBOO_DEBUGPRINT_REG(x): print out value of variable x //
140 // BAMBOO_LOCAL_MEM_CALLOC(x, y): allocate an array of x elements each of whose //
141 // size in bytes is y on local memory //
142 // BAMBOO_SHARE_MEM_CALLOC(x, y): allocate an array of x elements each of whose //
143 // size in bytes is y on shared memory //
144 // BAMBOO_START_CRITICAL_SECTION_OBJ_QUEUE() //
145 // BAMBOO_CLOSE_CRITICAL_SECTION_OBJ_QUEUE(): locks for global data structures //
146 // related to obj queue //
147 // BAMBOO_START_CRITICAL_SECTION_STATUS() //
148 // BAMBOO_CLOSE_CRITICAL_SECTION_STATUS(): locks for global data structures //
149 // related to status data //
150 // BAMBOO_START_CRITICAL_SECTION_MSG() //
151 // BAMBOO_CLOSE_CRITICAL_SECTION_MSG(): locks for global data structures related //
153 // BAMBOO_START_CRITICAL_SECTION_LOCK() //
154 // BAMBOO_CLOSE_CRITICAL_SECTION_LOCK(): locks for global data structures related //
156 // BAMBOO_START_CRITICAL_SECTION_MEM() //
157 // BAMBOO_CLOSE_CRITICAL_SECTION_MEM(): locks for allocating memory //
158 // BAMBOO_START_CRITICAL_SECTION() //
159 // BAMBOO_CLOSE_CRITICAL_SECTION(): locks for all global data structures //
160 // BAMBOO_WAITING_FOR_LOCK(): routine executed while waiting for lock request //
162 // BAMBOO_CACHE_LINE_SIZE: the cache line size //
163 // BAMBOO_CACHE_LINE_MASK: mask for a cache line //
164 // BAMBOO_CACHE_FLUSH_RANGE(x, y): flush cache lines started at x with length y //
165 // BAMBOO_CACHE_FLUSH_ALL(): flush the whole cache of a core if necessary //
166 // BAMBOO_EXIT(x): exit routine //
167 // BAMBOO_MSG_AVAIL(): checking if there are msgs coming in //
168 // BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number //
169 /////////////////////////////////////////////////////////////////////////////////////
171 #endif // #ifdef MULTICORE
172 #endif // #ifdef TASK
173 #endif // #ifndef MULTICORE_RUNTIME