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 profile mode
51 #define TASKINFOLENGTH 10000
52 //#define INTERRUPTINFOLENGTH 500
58 typedef struct task_info {
63 struct Queue * newObjs;
66 /*typedef struct interrupt_info {
71 TaskInfo * taskInfoArray[TASKINFOLENGTH];
73 bool taskInfoOverflow;
74 /*InterruptInfo * interruptInfoArray[INTERRUPTINFOLENGTH];
75 int interruptInfoIndex;
76 bool interruptInfoOverflow;*/
77 int profilestatus[NUMCORES]; // records status of each core
80 #endif // #ifdef PROFILE
85 /////////////////////////////////////////////////////////////
87 ////////////////////////////////////////////////////////////
88 // these are functions should be implemented in //
89 // multicore runtime for any multicore processors //
90 ////////////////////////////////////////////////////////////
93 inline void initialization(void) __attribute__((always_inline));
94 inline void initCommunication(void) __attribute__((always_inline));
95 inline void fakeExecution(void) __attribute__((always_inline));
96 inline void terminate(void) __attribute__((always_inline));
98 inline void send_msg_1(int targetcore, unsigned long n0) __attribute__((always_inline));
99 inline void send_msg_2(int targetcore, unsigned long n0, unsigned long n1) __attribute__((always_inline));
100 inline void send_msg_3(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2) __attribute__((always_inline));
101 inline void send_msg_4(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3) __attribute__((always_inline));
102 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));
103 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));
104 inline void cache_msg_2(int targetcore, unsigned long n0, unsigned long n1) __attribute__((always_inline));
105 inline void cache_msg_3(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2) __attribute__((always_inline));
106 inline void cache_msg_4(int targetcore, unsigned long n0, unsigned long n1, unsigned long n2, unsigned long n3) __attribute__((always_inline));
107 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));
108 inline void transferObject(struct transObjInfo * transObj);
109 inline int receiveMsg(void) __attribute__((always_inline));
112 inline void profileTaskStart(char * taskname) __attribute__((always_inline));
113 inline void profileTaskEnd(void) __attribute__((always_inline));
114 #endif // #ifdef PROFILE
115 ///////////////////////////////////////////////////////////
117 //////////////////////////////////////////////////////////////////////////////////////
118 // For each version of BAMBOO runtime, there should be a header file named //
119 // runtim_arch.h defining following MARCOS: //
120 // BAMBOO_TOTALCORE: the total # of cores available in the processor //
121 // BAMBOO_NUM_OF_CORE: the # of current residing core //
122 // BAMBOO_GET_NUM_OF_CORE(): compute the # of current residing core //
123 // BAMBOO_DEBUGPRINT(x): print out integer x //
124 // BAMBOO_DEBUGPRINT_REG(x): print out value of variable x //
125 // BAMBOO_LOCAL_MEM_CALLOC(x, y): allocate an array of x elements each of whose //
126 // size in bytes is y on local memory //
127 // BAMBOO_SHARE_MEM_CALLOC(x, y): allocate an array of x elements each of whose //
128 // size in bytes is y on shared memory //
129 // BAMBOO_START_CRITICAL_SECTION_OBJ_QUEUE() //
130 // BAMBOO_CLOSE_CRITICAL_SECTION_OBJ_QUEUE(): locks for global data structures //
131 // related to obj queue //
132 // BAMBOO_START_CRITICAL_SECTION_STATUS() //
133 // BAMBOO_CLOSE_CRITICAL_SECTION_STATUS(): locks for global data structures //
134 // related to status data //
135 // BAMBOO_START_CRITICAL_SECTION_MSG() //
136 // BAMBOO_CLOSE_CRITICAL_SECTION_MSG(): locks for global data structures related //
138 // BAMBOO_START_CRITICAL_SECTION_LOCK() //
139 // BAMBOO_CLOSE_CRITICAL_SECTION_LOCK(): locks for global data structures related //
141 // BAMBOO_START_CRITICAL_SECTION_MEM() //
142 // BAMBOO_CLOSE_CRITICAL_SECTION_MEM(): locks for allocating memory //
143 // BAMBOO_START_CRITICAL_SECTION() //
144 // BAMBOO_CLOSE_CRITICAL_SECTION(): locks for all global data structures //
145 // BAMBOO_WAITING_FOR_LOCK(): routine executed while waiting for lock request //
147 // BAMBOO_CACHE_LINE_SIZE: the cache line size //
148 // BAMBOO_CACHE_LINE_MASK: mask for a cache line //
149 // BAMBOO_CACHE_FLUSH_RANGE(x, y): flush cache lines started at x with length y //
150 // BAMBOO_CACHE_FLUSH_ALL(): flush the whole cache of a core if necessary //
151 // BAMBOO_EXIT(x): exit routine //
152 // BAMBOO_MSG_AVAIL(): checking if there are msgs coming in //
153 // BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number //
154 /////////////////////////////////////////////////////////////////////////////////////
156 #endif // #ifdef MULTICORE
157 #endif // #ifdef TASK
158 #endif // #ifndef MULTICORE_RUNTIME