Config the size of the shared heap for TSP benchmark
[IRC.git] / Robust / src / Runtime / bamboo / multicoreruntime.h
1 #ifndef MULTICORE_RUNTIME
2 #define MULTICORE_RUNTIME
3
4 #ifndef INLINE
5 #define INLINE    inline __attribute__((always_inline))
6 #endif
7
8 #ifndef bool
9 #define bool int
10 #define true 1
11 #define false 0
12 #endif
13
14 ////////////////////////////////////////////////////////////////
15 // global variables                                          //
16 ///////////////////////////////////////////////////////////////
17
18 // record the starting time
19 unsigned long long bamboo_start_time;
20
21 // data structures for msgs
22 #define BAMBOO_OUT_BUF_LENGTH 2048
23 #define BAMBOO_OUT_BUF_MASK (0x7FF)
24 #define BAMBOO_MSG_BUF_LENGTH 2048
25 #define BAMBOO_MSG_BUF_MASK (0x7FF)
26 int msgdata[BAMBOO_MSG_BUF_LENGTH];
27 volatile int msgdataindex;
28 volatile int msgdatalast;
29 int msglength;
30 volatile bool msgdatafull;
31 int outmsgdata[BAMBOO_OUT_BUF_LENGTH];
32 int outmsgindex;
33 int outmsglast;
34 int outmsgleft;
35 volatile bool isMsgHanging;
36
37 #define MSG_INDEXINC_I() \
38   msgdataindex = (msgdataindex + 1) & (BAMBOO_MSG_BUF_MASK) 
39
40 #define MSG_LASTINDEXINC_I() \
41   msgdatalast = (msgdatalast + 1) & (BAMBOO_MSG_BUF_MASK)
42
43 #define MSG_CACHE_I(n) \
44   msgdata[msgdatalast] = (n); \
45   MSG_LASTINDEXINC_I()
46
47 // NOTE: if msgdataindex == msgdatalast, it always means that the buffer if
48 //       full. In the case that the buffer is empty, should never call this
49 //       MACRO
50 #define MSG_REMAINSIZE_I(s) \
51   if(msgdataindex < msgdatalast) { \
52     (*(int*)s) = msgdatalast - msgdataindex; \
53   } else if((msgdataindex == msgdatalast) && (!msgdatafull)) { \
54     (*(int*)s) = 0; \
55   } else { \
56     (*(int*)s) = (BAMBOO_MSG_BUF_LENGTH) - msgdataindex + msgdatalast; \
57   }
58
59 #define OUTMSG_INDEXINC() \
60   outmsgindex = (outmsgindex + 1) & (BAMBOO_OUT_BUF_MASK)
61
62 #define OUTMSG_LASTINDEXINC() \
63   outmsglast = (outmsglast + 1) & (BAMBOO_OUT_BUF_MASK); \
64   if(outmsglast == outmsgindex) { \
65     BAMBOO_EXIT(0xd101); \
66   }
67
68 #define OUTMSG_CACHE(n) \
69   outmsgdata[outmsglast] = (n); \
70   OUTMSG_LASTINDEXINC();
71
72 #define MAX_PACKET_WORDS 5
73
74 /* Message format:
75  *      type + Msgbody
76  * type: 1 -- transfer object
77  *       2 -- transfer stall msg
78  *       3 -- lock request
79  *       4 -- lock grount
80  *       5 -- lock deny
81  *       6 -- lock release
82  *       // add for profile info
83  *       7 -- transfer profile output msg
84  *       8 -- transfer profile output finish msg
85  *       // add for alias lock strategy
86  *       9 -- redirect lock request
87  *       a -- lock grant with redirect info
88  *       b -- lock deny with redirect info
89  *       c -- lock release with redirect info
90  *       d -- status confirm request
91  *       e -- status report msg
92  *       f -- terminate
93  *      10 -- requiring for new memory
94  *      11 -- response for new memory request
95  *      12 -- GC init phase start
96  *      13 -- GC start
97  *      14 -- compact phase start
98  *      15 -- flush phase start
99  *      16 -- init phase finish
100  *      17 -- mark phase finish
101  *      18 -- compact phase finish
102  *      19 -- flush phase finish
103  *      1a -- GC finish
104  *      1b -- marked phase finish confirm request
105  *      1c -- marked phase finish confirm response
106  *      1d -- markedObj msg
107  *      1e -- start moving objs msg
108  *      1f -- ask for mapping info of a markedObj
109  *      20 -- mapping info of a markedObj
110  *      21 -- large objs info request
111  *      22 -- large objs info response
112  *      23 -- large objs mapping info
113  *
114  * ObjMsg: 1 + size of msg + obj's address + (task index + param index)+
115  * StallMsg: 2 + corenum + sendobjs + receiveobjs
116  *             (size is always 4 * sizeof(int))
117  * LockMsg: 3 + lock type + obj pointer + lock + request core
118  *            (size is always 5 * sizeof(int))
119  *          4/5/6 + lock type + obj pointer + lock
120  *            (size is always 4 * sizeof(int))
121  *          9 + lock type + obj pointer +  redirect lock + root request core
122  *            + request core
123  *            (size is always 6 * sizeof(int))
124  *          a/b + lock type + obj pointer + redirect lock
125  *              (size is always 4 * sizeof(int))
126  *          c + lock type + lock + redirect lock
127  *            (size is always 4 * sizeof(int))
128  *          lock type: 0 -- read; 1 -- write
129  * ProfileMsg: 7 + totalexetime
130  *               (size is always 2 * sizeof(int))
131  *             8 + corenum
132  *               (size is always 2 * sizeof(int))
133  * StatusMsg: d (size is always 1 * sizeof(int))
134  *            e + status + corenum + sendobjs + receiveobjs
135  *              (size is always 5 * sizeof(int))
136  *            status: 0 -- stall; 1 -- busy
137  * TerminateMsg: f (size is always 1 * sizeof(int)
138  * MemoryMsg: 10 + size + corenum
139  *              (size is always 3 * sizeof(int))
140  *           11 + base_va + size
141  *              (size is always 3 * sizeof(int))
142  * GCMsg: 12/13 (size is always 1 * sizeof(int))
143  *        14 + size of msg + (num of objs to move + (start address
144  *           + end address + dst core + start dst)+)?
145  *           + (num of incoming objs + (start dst + orig core)+)?
146  *           + (num of large obj lists + (start address + lenght
147  *           + start dst)+)?
148  *        15 (size is always 1 * sizeof(int))
149  *        16 + corenum
150  *           (size is always 2 * sizeof(int))
151  *        17 + corenum + gcsendobjs + gcreceiveobjs
152  *           (size if always 4 * sizeof(int))
153  *        18 + corenum + fulfilled blocks num + (finish compact(1) + current
154  *           heap top)/(need mem(0) + mem need)
155  *           size is always 5 * sizeof(int))
156  *        19 + corenum
157  *              (size is always 2 * sizeof(int))
158  *        1a (size is always 1 * sizeof(int))
159  *        1b (size if always 1 * sizeof(int))
160  *        1c + size of msg + corenum + gcsendobjs + gcreceiveobjs
161  *           (size is always 5 * sizeof(int))
162  *        1d + obj's address + request core
163  *           (size is always 3 * sizeof(int))
164  *        1e + corenum + start addr + end addr
165  *           (size if always 4 * sizeof(int))
166  *        1f + obj's address + corenum
167  *           (size is always 3 * sizeof(int))
168  *        20 + obj's address + dst address
169  *           (size if always 3 * sizeof(int))
170  *        21 (size is always 1 * sizeof(int))
171  *        22 + size of msg + corenum + current heap size
172  *           + (num of large obj lists + (start address + length)+)?
173  *        23 + orig large obj ptr + new large obj ptr
174  *            (size is always 3 * sizeof(int))
175  */
176 typedef enum {
177   MSGSTART = 0xD0,       // 0xD0
178   TRANSOBJ,              // 0xD1
179   TRANSTALL,             // 0xD2
180   LOCKREQUEST,           // 0xD3
181   LOCKGROUNT,            // 0xD4
182   LOCKDENY,              // 0xD5
183   LOCKRELEASE,           // 0xD6
184   PROFILEOUTPUT,         // 0xD7
185   PROFILEFINISH,         // 0xD8
186   REDIRECTLOCK,          // 0xD9
187   REDIRECTGROUNT,        // 0xDa
188   REDIRECTDENY,          // 0xDb
189   REDIRECTRELEASE,       // 0xDc
190   STATUSCONFIRM,         // 0xDd
191   STATUSREPORT,          // 0xDe
192   TERMINATE,             // 0xDf
193   MEMREQUEST,            // 0xE0
194   MEMRESPONSE,           // 0xE1
195 #ifdef MULTICORE_GC
196   GCSTARTPRE,            // 0xE2
197   GCSTARTINIT,           // 0xE3
198   GCSTART,               // 0xE4
199   GCSTARTCOMPACT,        // 0xE5
200   GCSTARTMAPINFO,        // 0xE6
201   GCSTARTFLUSH,          // 0xE7
202   GCFINISHPRE,           // 0xE8
203   GCFINISHINIT,          // 0xE9
204   GCFINISHMARK,          // 0xEa
205   GCFINISHCOMPACT,       // 0xEb
206   GCFINISHMAPINFO,       // 0xEc
207   GCFINISHFLUSH,         // 0xEd
208   GCFINISH,              // 0xEe
209   GCMARKCONFIRM,         // 0xEf
210   GCMARKREPORT,          // 0xF0
211   GCMARKEDOBJ,           // 0xF1
212   GCMOVESTART,           // 0xF2
213   GCMAPREQUEST,          // 0xF3
214   GCMAPINFO,             // 0xF4
215   GCMAPTBL,              // 0xF5
216   GCLOBJREQUEST,         // 0xF6
217   GCLOBJINFO,            // 0xF7
218   GCLOBJMAPPING,         // 0xF8
219 #ifdef GC_PROFILE
220   GCPROFILES,            // 0xF9
221 #endif
222 #ifdef GC_CACHE_ADAPT
223   GCSTARTPOSTINIT,       // 0xFa
224   GCSTARTPREF,           // 0xFb
225   GCFINISHPOSTINIT,      // 0xFc
226   GCFINISHPREF,          // 0xFd
227 #endif // GC_CACHE_ADAPT
228 #endif
229   MSGEND
230 } MSGTYPE;
231
232 /////////////////////////////////////////////////////////////////////////////////
233 // NOTE: BAMBOO_TOTALCORE -- number of the available cores in the processor.
234 //                           No greater than the number of all the cores in
235 //                           the processor
236 //       NUMCORES -- number of cores chosen to deploy the application. It can
237 //                   be greater than that required to fully parallelize the
238 //                   application. The same as NUMCORES.
239 //       NUMCORESACTIVE -- number of cores that really execute the
240 //                         application. No greater than NUMCORES
241 //       NUMCORES4GC -- number of cores for gc. No greater than NUMCORES.
242 //                      NOTE: currently only support ontinuous cores as gc
243 //                            cores, i.e. 0~NUMCORES4GC-1
244 ////////////////////////////////////////////////////////////////////////////////
245 // data structures of status for termination
246 // only check working cores
247 volatile int corestatus[NUMCORESACTIVE]; // records status of each core
248                                          // 1: running tasks
249                                          // 0: stall
250 volatile int numsendobjs[NUMCORESACTIVE]; // records how many objects a core
251                                           // has sent out
252 volatile int numreceiveobjs[NUMCORESACTIVE]; // records how many objects a
253                                              // core has received
254 volatile int numconfirm;
255 volatile bool waitconfirm;
256 bool busystatus;
257 int self_numsendobjs;
258 int self_numreceiveobjs;
259
260 // get rid of lock msgs for GC version
261 #ifndef MULTICORE_GC
262 // data structures for locking
263 struct RuntimeHash locktable;
264 static struct RuntimeHash* locktbl = &locktable;
265 struct RuntimeHash * lockRedirectTbl;
266 struct RuntimeHash * objRedirectLockTbl;
267 #endif
268 struct LockValue {
269   int redirectlock;
270   int value;
271 };
272 int lockobj;
273 int lock2require;
274 int lockresult;
275 bool lockflag;
276
277 // data structures for waiting objs
278 struct Queue objqueue;
279 struct Queue * totransobjqueue; // queue to hold objs to be transferred
280                                 // should be cleared whenever enter a task
281
282 // data structures for shared memory allocation
283 #ifdef TILERA_BME
284 #define BAMBOO_BASE_VA 0xd000000
285 #elif defined TILERA_ZLINUX
286 #ifdef MULTICORE_GC
287 #define BAMBOO_BASE_VA 0xd000000
288 #endif // MULTICORE_GC
289 #endif // TILERA_BME
290
291 #ifdef BAMBOO_MEMPROF
292 #define GC_BAMBOO_NUMCORES 56
293 #else
294 #define GC_BAMBOO_NUMCORES 62
295 #endif
296
297 #ifdef GC_DEBUG
298 #include "structdefs.h"
299 #define BAMBOO_NUM_BLOCKS (NUMCORES4GC*(2+1)+3)
300 #define BAMBOO_PAGE_SIZE (64 * 64)
301 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
302 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_SMEM_SIZE) *(BAMBOO_NUM_BLOCKS))
303
304 #elif defined GC_CACHE_ADAPT
305 #ifdef GC_LARGESHAREDHEAP
306 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+24))
307 #else
308 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+14))
309 #endif
310 #define BAMBOO_PAGE_SIZE (64 * 1024) // 64K
311 #ifdef GC_LARGEPAGESIZE
312 #define BAMBOO_PAGE_SIZE (4 * 64 * 1024)
313 #define BAMBOO_SMEM_SIZE (4 * (BAMBOO_PAGE_SIZE))
314 #elif defined GC_SMALLPAGESIZE
315 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
316 #elif defined GC_SMALLPAGESIZE2
317 #define BAMBOO_PAGE_SIZE (16 * 1024)  // (4096)
318 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
319 #elif defined GC_LARGEPAGESIZE2
320 #define BAMBOO_PAGE_SIZE (4 * 64 * 1024) // 64K
321 #define BAMBOO_SMEM_SIZE ((BAMBOO_PAGE_SIZE))
322 #else
323 #define BAMBOO_SMEM_SIZE (4 * (BAMBOO_PAGE_SIZE))
324 #endif // GC_LARGEPAGESIZE
325 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS))
326
327 #else // GC_DEBUG
328 #ifdef GC_LARGESHAREDHEAP
329 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+2))
330 #elif defined GC_LARGESHAREDHEAP2
331 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+2))
332 #else
333 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+3)) //(15 * 1024) //(64 * 4 * 0.75) //(1024 * 1024 * 3.5)  3G
334 #endif
335 #ifdef GC_LARGEPAGESIZE
336 #define BAMBOO_PAGE_SIZE (4 * 1024 * 1024)  // (4096)
337 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
338 #elif defined GC_SMALLPAGESIZE
339 #define BAMBOO_PAGE_SIZE (256 * 1024)  // (4096)
340 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
341 #elif defined GC_SMALLPAGESIZE2
342 #define BAMBOO_PAGE_SIZE (64 * 1024)  // (4096)
343 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
344 #else
345 #define BAMBOO_PAGE_SIZE (1024 * 1024)  // (4096)
346 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
347 #endif // GC_LARGEPAGESIZE
348 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS)) //(1024 * 1024 * 240) //((unsigned long long int)(3.0 * 1024 * 1024 * 1024)) // 3G 
349 #endif // GC_DEBUG
350
351 #ifdef MULTICORE_GC
352 volatile bool gc_localheap_s;
353 #endif
354
355 #ifdef MULTICORE_GC
356 #include "multicoregarbage.h"
357
358 typedef enum {
359   SMEMLOCAL = 0x0,// 0x0, using local mem only
360   SMEMFIXED,      // 0x1, use local mem in lower address space(1 block only)
361                   //      and global mem in higher address space
362   SMEMMIXED,      // 0x2, like FIXED mode but use a threshold to control
363   SMEMGLOBAL,     // 0x3, using global mem only
364   SMEMEND
365 } SMEMSTRATEGY;
366
367 SMEMSTRATEGY bamboo_smem_mode; //-DSMEML: LOCAL; -DSMEMF: FIXED;
368                                //-DSMEMM: MIXED; -DSMEMG: GLOBAL;
369
370 struct freeMemItem {
371   INTPTR ptr;
372   int size;
373   int startblock;
374   int endblock;
375   struct freeMemItem * next;
376 };
377
378 struct freeMemList {
379   struct freeMemItem * head;
380   struct freeMemItem * backuplist; // hold removed freeMemItem for reuse;
381                                    // only maintain 1 freemMemItem
382 };
383
384 // table recording the number of allocated bytes on each block
385 // Note: this table resides on the bottom of the shared heap for all cores
386 //       to access
387 volatile int * bamboo_smemtbl;
388 volatile int bamboo_free_block;
389 int bamboo_reserved_smem; // reserved blocks on the top of the shared heap
390                           // e.g. 20% of the heap and should not be allocated
391                           // otherwise gc is invoked
392 volatile INTPTR bamboo_smem_zero_top;
393 #define BAMBOO_SMEM_ZERO_UNIT_SIZE (4 * 1024) // 4KB
394 #else
395 //volatile mspace bamboo_free_msp;
396 INTPTR bamboo_free_smemp;
397 int bamboo_free_smem_size;
398 #endif
399 volatile bool smemflag;
400 volatile INTPTR bamboo_cur_msp;
401 volatile int bamboo_smem_size;
402
403 // for test TODO
404 int total_num_t6;
405
406 // data structures for profile mode
407 #ifdef PROFILE
408
409 #define TASKINFOLENGTH 3000 // 0
410 #ifdef PROFILE_INTERRUPT
411 #define INTERRUPTINFOLENGTH 50 //0
412 #endif // PROFILE_INTERRUPT
413
414 bool stall;
415 int totalexetime;
416
417 typedef struct task_info {
418   char* taskName;
419   unsigned long long startTime;
420   unsigned long long endTime;
421   unsigned long long exitIndex;
422   struct Queue * newObjs;
423 } TaskInfo;
424
425 TaskInfo * taskInfoArray[TASKINFOLENGTH];
426 int taskInfoIndex;
427 bool taskInfoOverflow;
428 #ifdef PROFILE_INTERRUPT
429 typedef struct interrupt_info {
430   unsigned long long startTime;
431   unsigned long long endTime;
432 } InterruptInfo;
433
434 InterruptInfo * interruptInfoArray[INTERRUPTINFOLENGTH];
435 int interruptInfoIndex;
436 bool interruptInfoOverflow;
437 #endif // PROFILE_INTERUPT
438 volatile int profilestatus[NUMCORESACTIVE]; // records status of each core
439                                             // 1: running tasks
440                                             // 0: stall
441 #endif // #ifdef PROFILE
442
443 #ifndef INTERRUPT
444 bool reside;
445 #endif
446 /////////////////////////////////////////////////////////////
447
448 ////////////////////////////////////////////////////////////
449 // these are functions should be implemented in           //
450 // multicore runtime for any multicore processors         //
451 ////////////////////////////////////////////////////////////
452 #ifdef TASK
453 #ifdef MULTICORE
454 INLINE void initialization(void);
455 INLINE void initCommunication(void);
456 INLINE void fakeExecution(void);
457 INLINE void terminate(void);
458 INLINE void initlock(struct ___Object___ * v);
459 #ifdef BAMBOO_MEMPROF
460 INLINE void terminatememprof(void);
461 #endif
462
463 // lock related functions
464 bool getreadlock(void* ptr);
465 void releasereadlock(void* ptr);
466 bool getwritelock(void* ptr);
467 void releasewritelock(void* ptr);
468 bool getwritelock_I(void* ptr);
469 void releasewritelock_I(void * ptr);
470 #ifndef MULTICORE_GC
471 void releasewritelock_r(void * lock, void * redirectlock);
472 #endif
473 /* this function is to process lock requests.
474  * can only be invoked in receiveObject() */
475 // if return -1: the lock request is redirected
476 //            0: the lock request is approved
477 //            1: the lock request is denied
478 INLINE int processlockrequest(int locktype,
479                               int lock,
480                               int obj,
481                               int requestcore,
482                               int rootrequestcore,
483                               bool cache);
484 INLINE void processlockrelease(int locktype,
485                                int lock,
486                                int redirectlock,
487                                bool redirect);
488
489 // msg related functions
490 INLINE void send_hanging_msg(bool isInterrupt);
491 INLINE void send_msg_1(int targetcore,
492                        unsigned long n0,
493                                            bool isInterrupt);
494 INLINE void send_msg_2(int targetcore,
495                        unsigned long n0,
496                        unsigned long n1,
497                                            bool isInterrupt);
498 INLINE void send_msg_3(int targetcore,
499                        unsigned long n0,
500                        unsigned long n1,
501                        unsigned long n2,
502                                            bool isInterrupt);
503 INLINE void send_msg_4(int targetcore,
504                        unsigned long n0,
505                        unsigned long n1,
506                        unsigned long n2,
507                        unsigned long n3,
508                                            bool isInterrupt);
509 INLINE void send_msg_5(int targetcore,
510                        unsigned long n0,
511                        unsigned long n1,
512                        unsigned long n2,
513                        unsigned long n3,
514                        unsigned long n4,
515                                            bool isInterrupt);
516 INLINE void send_msg_6(int targetcore,
517                        unsigned long n0,
518                        unsigned long n1,
519                        unsigned long n2,
520                        unsigned long n3,
521                        unsigned long n4,
522                        unsigned long n5,
523                                            bool isInterrupt);
524 INLINE void cache_msg_1(int targetcore,
525                         unsigned long n0);
526 INLINE void cache_msg_2(int targetcore,
527                         unsigned long n0,
528                         unsigned long n1);
529 INLINE void cache_msg_3(int targetcore,
530                         unsigned long n0,
531                         unsigned long n1,
532                         unsigned long n2);
533 INLINE void cache_msg_4(int targetcore,
534                         unsigned long n0,
535                         unsigned long n1,
536                         unsigned long n2,
537                         unsigned long n3);
538 INLINE void cache_msg_5(int targetcore,
539                         unsigned long n0,
540                         unsigned long n1,
541                         unsigned long n2,
542                         unsigned long n3,
543                         unsigned long n4);
544 INLINE void cache_msg_6(int targetcore,
545                         unsigned long n0,
546                         unsigned long n1,
547                         unsigned long n2,
548                         unsigned long n3,
549                         unsigned long n4,
550                         unsigned long n5);
551 INLINE void transferObject(struct transObjInfo * transObj);
552 INLINE int receiveMsg(uint32_t send_port_pending);
553
554 #ifdef MULTICORE_GC
555 INLINE void transferMarkResults();
556 #endif
557
558 #ifdef PROFILE
559 INLINE void profileTaskStart(char * taskname);
560 INLINE void profileTaskEnd(void);
561 void outputProfileData();
562 #endif  // #ifdef PROFILE
563 ///////////////////////////////////////////////////////////
564
565 /////////////////////////////////////////////////////////////////////////////
566 // For each version of BAMBOO runtime, there should be a header file named //
567 // runtim_arch.h defining following MARCOS:                                //
568 // BAMBOO_NUM_OF_CORE: the # of current residing core                      //
569 // BAMBOO_GET_NUM_OF_CORE(): compute the # of current residing core        //
570 // BAMBOO_COORDS(c, x, y): convert the cpu # to coords (*x, *y)            //
571 // BAMBOO_DEBUGPRINT(x): print out integer x                               //
572 // BAMBOO_DEBUGPRINT_REG(x): print out value of variable x                 //
573 // BAMBOO_EXIT_APP(x): exit the whole application                          //
574 // BAMBOO_EXIT(x): error exit routine with error #                         //
575 // BAMBOO_DIE(x): error exit routine with error msg                        //
576 // BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number       //
577 // BAMBOO_MSG_AVAIL(): checking if there are msgs coming in                //
578 // BAMBOO_GCMSG_AVAIL(): checking if there are gcmsgs coming in            //
579 // BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(): change to runtime mode from    //
580 //                                          client mode                    //
581 // BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(): change to client mode from     //
582 //                                          runtime mode                   //
583 // BAMBOO_ENTER_SEND_MODE_FROM_CLIENT(): change to send mode from          //
584 //                                       client mode                       //
585 // BAMBOO_ENTER_CLIENT_MODE_FROM_SEND(): change to client mode from        //
586 //                                       send mode                         //
587 // BAMBOO_ENTER_RUNTIME_MODE_FROM_SEND(): change to runtime mode from      //
588 //                                        send mode                        //
589 // BAMBOO_ENTER_SEND_MODE_FROM_RUNTIME(): change to send mode from         //
590 //                                        runtime mode                     //
591 // BAMBOO_WAITING_FOR_LOCK(): routine executed while waiting for lock      //
592 //                            request response                             //
593 // BAMBOO_LOCAL_MEM_CALLOC(x, y): allocate an array of x elements each of  //
594 //                                whose size in bytes is y on local memory //
595 //                                which is given by the hypervisor         //
596 // BAMBOO_LOCAL_MEM_FREE(x): free space with ptr x on local memory         //
597 // BAMBOO_LOCAL_MEM_CLOSE(): close the local heap                          //
598 // BAMBOO_LOCAL_MEM_CALLOC_S(x, y): allocate an array of x elements each of//
599 //                                  whose size in bytes is y on local      //
600 //                                  memory which is not from the hypervisor//
601 //                                  but is allocated from the free memory  //
602 // BAMBOO_LOCAL_MEM_FREE_S(x): free space with ptr x on self-allocated     //
603 //                             local memory                                //
604 // BAMBOO_LOCAL_MEM_CLOSE_S(): close the self-allocated local heap        //
605 // BAMBOO_SHARE_MEM_CALLOC_I(x, y): allocate an array of x elements each of//
606 //                                whose size in bytes is y on shared memory//
607 // BAMBOO_SHARE_MEM_CLOSE(): close the shared heap                         //
608 // BAMBOO_CACHE_LINE_SIZE: the cache line size                             //
609 // BAMBOO_CACHE_LINE_MASK: mask for a cache line                           //
610 // BAMBOO_CACHE_FLUSH_RANGE(x, y): flush cache lines started at x with     //
611 //                                 length y                                //
612 // BAMBOO_CACHE_FLUSH_ALL(): flush the whole cache of a core if necessary  //
613 // BAMBOO_MEMSET_WH(x, y, z): memset the specified region of memory (start //
614 //                            address x, size z) to value y with write     //
615 //                            hint, the processor will not fetch the       //
616 //                            current content of the memory and directly   //
617 //                            write                                        //
618 // BAMBOO_CLEAN_DTLB(): zero-out all the dtlb entries                      //
619 // BAMBOO_CACHE_FLUSH_L2(): Flush the contents of this tile's L2 back to   //
620 //                          main memory                                    //
621 // BAMBOO_CACHE_FLUSH_RANGE_NO_FENCE(x, y): flush a range of mem without   //
622 //                                          mem fence                      //
623 // BAMBOO_CACHE_MEM_FENCE_INCOHERENT(): fence to guarantee visibility of   //
624 //                                      stores to incoherent memory        //
625 /////////////////////////////////////////////////////////////////////////////
626
627 #endif  // #ifdef MULTICORE
628 #endif  // #ifdef TASK
629 #endif  // #ifndef MULTICORE_RUNTIME