1 #ifndef BAMBOO_MULTICORE_RUNTIME_H
2 #define BAMBOO_MULTICORE_RUNTIME_H
4 #include "structdefs.h"
6 #include "multicoremsg.h"
7 #include "multicoremem.h"
8 #include "multicoretask.h"
9 #include "multicoremgc.h"
10 #include "multicorecache.h"
12 //Define the following line if the base object type has pointers
13 //#define OBJECTHASPOINTERS
16 extern volatile bool gcflag;
21 #endif // MULTICORE_GC
23 ////////////////////////////////////////////////////////////////
24 // global variables //
25 ///////////////////////////////////////////////////////////////
26 // record the starting time
27 unsigned long long bamboo_start_time;
34 /////////////////////////////////////////////////////////////////////////////////
35 // NOTE: BAMBOO_TOTALCORE -- number of the available cores in the processor.
36 // No greater than the number of all the cores in
38 // NUMCORES -- number of cores chosen to deploy the application. It can
39 // be greater than that required to fully parallelize the
40 // application. The same as NUMCORES.
41 // NUMCORESACTIVE -- number of cores that really execute the
42 // application. No greater than NUMCORES
43 // NUMCORES4GC -- number of cores for gc. No greater than NUMCORES.
44 // NOTE: currently only support ontinuous cores as gc
45 // cores, i.e. 0~NUMCORES4GC-1
46 ////////////////////////////////////////////////////////////////////////////////
47 // data structures of status for termination
48 // only check working cores
49 volatile int corestatus[NUMCORESACTIVE]; // records status of each core
52 volatile int numsendobjs[NUMCORESACTIVE]; // records how many objects a core
54 volatile int numreceiveobjs[NUMCORESACTIVE]; // records how many objects a
56 volatile int numconfirm;
57 volatile bool waitconfirm;
60 int self_numreceiveobjs;
62 /////////////////////////////////////////////////////////////
64 ////////////////////////////////////////////////////////////
65 // these are functions should be implemented in //
66 // multicore runtime for any multicore processors //
67 ////////////////////////////////////////////////////////////
68 INLINE void initialization(void);
69 INLINE void initCommunication(void);
70 INLINE void fakeExecution(void);
71 INLINE void terminate(void);
72 INLINE void initlock(struct ___Object___ * v);
74 INLINE void terminatememprof(void);
75 #endif // BAMBOO_MEMPROF
77 ///////////////////////////////////////////////////////////
79 /////////////////////////////////////////////////////////////////////////////
80 // For each version of BAMBOO runtime, there should be a header file named //
81 // runtim_arch.h defining following MARCOS: //
82 // BAMBOO_NUM_OF_CORE: the # of current residing core //
83 // BAMBOO_GET_NUM_OF_CORE(): compute the # of current residing core //
84 // BAMBOO_COORDS(c, x, y): convert the cpu # to coords (*x, *y) //
85 // BAMBOO_COORDS_X(c): convert the cpu # to coords x //
86 // BAMBOO_COORDS_Y(c): convert the cpu # to coordsy //
87 // BAMBOO_DEBUGPRINT(x): print out integer x //
88 // BAMBOO_DEBUGPRINT_REG(x): print out value of variable x //
89 // BAMBOO_EXIT_APP(x): exit the whole application //
90 // BAMBOO_EXIT(x): error exit routine with file name and line # //
91 // BAMBOO_DIE(x): error exit routine with error msg //
92 // BAMBOO_ASSERT(x) : check if condition x is met //
93 // BAMBOO_ASSERTMSG(x.y): check if condition x is met or not, if not, print//
95 // BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number //
96 // BAMBOO_MSG_AVAIL(): checking if there are msgs coming in //
97 // BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(): change to runtime mode from //
99 // BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(): change to client mode from //
101 // BAMBOO_ENTER_SEND_MODE_FROM_CLIENT(): change to send mode from //
103 // BAMBOO_ENTER_CLIENT_MODE_FROM_SEND(): change to client mode from //
105 // BAMBOO_ENTER_RUNTIME_MODE_FROM_SEND(): change to runtime mode from //
107 // BAMBOO_ENTER_SEND_MODE_FROM_RUNTIME(): change to send mode from //
109 // BAMBOO_WAITING_FOR_LOCK_I(): routine executed while waiting for lock //
110 // request response //
111 // BAMBOO_LOCAL_MEM_CALLOC(x, y): allocate an array of x elements each of //
112 // whose size in bytes is y on local memory //
113 // which is given by the hypervisor //
114 // BAMBOO_LOCAL_MEM_FREE(x): free space with ptr x on local memory //
115 // BAMBOO_LOCAL_MEM_CLOSE(): close the local heap //
116 // BAMBOO_LOCAL_MEM_CALLOC_S(x, y): allocate an array of x elements each of//
117 // whose size in bytes is y on local //
118 // memory which is not from the hypervisor//
119 // but is allocated from the free memory //
120 // BAMBOO_LOCAL_MEM_FREE_S(x): free space with ptr x on self-allocated //
122 // BAMBOO_LOCAL_MEM_CLOSE_S(): close the self-allocated local heap //
123 // BAMBOO_SHARE_MEM_CALLOC_I(x, y): allocate an array of x elements each of//
124 // whose size in bytes is y on shared memory//
125 // BAMBOO_SHARE_MEM_CLOSE(): close the shared heap //
126 // BAMBOO_CACHE_LINE_SIZE: the cache line size //
127 // BAMBOO_CACHE_LINE_MASK: mask for a cache line //
128 // BAMBOO_CACHE_FLUSH_RANGE(x, y): flush cache lines started at x with //
130 // BAMBOO_CACHE_FLUSH_ALL(): flush the whole cache of a core if necessary //
131 // BAMBOO_MEMSET_WH(x, y, z): memset the specified region of memory (start //
132 // address x, size z) to value y with write //
133 // hint, the processor will not fetch the //
134 // current content of the memory and directly //
136 // BAMBOO_CLEAN_DTLB(): zero-out all the dtlb entries //
137 // BAMBOO_CACHE_FLUSH_L2(): Flush the contents of this tile's L2 back to //
139 // BAMBOO_CACHE_FLUSH_RANGE_NO_FENCE(x, y): flush a range of mem without //
141 // BAMBOO_CACHE_MEM_FENCE_INCOHERENT(): fence to guarantee visibility of //
142 // stores to incoherent memory //
143 /////////////////////////////////////////////////////////////////////////////
145 #endif // #ifdef MULTICORE
146 #endif // BAMBOO_MULTICORE_RUNTIME_H