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