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