e4d75541d554335292abfd40ce2e90af4f99c0c4
[IRC.git] / Robust / src / Runtime / RAW / runtime_arch.h
1 #ifndef RUNTIME_ARCH
2 #define RUNTIME_ARCH
3
4 #ifdef PROFILE
5 #ifdef RAWUSEIO
6 #include "stdio.h"
7 #include "string.h"
8 #endif
9 #endif
10 #include <raw.h>
11 #include <raw_compiler_defs.h>
12
13 #define BAMBOO_TOTALCORE (raw_get_num_tiles())  // the total # of cores available in the processor
14 #define BAMBOO_NUM_OF_CORE corenum   // the # of current residing core
15 #define BAMBOO_GET_NUM_OF_CORE() (raw_get_abs_pos_x() + raw_get_array_size_x() * raw_get_abs_pos_y())  // compute the # of current residing core
16 #define BAMBOO_DEBUGPRINT(x) (raw_test_pass((x)))
17 #define BAMBOO_DEBUGPRINT_REG(x) (raw_test_pass_reg((x)))
18
19 #define BAMBOO_SHARE_MEM_CALLOC(x, y) (calloc((x), (y)))  // allocate an array of x elements each of whose size in bytes is y on shared memory 
20
21 #ifdef INTERRUPT
22 // locks for global data structures related to obj queue
23 #define BAMBOO_START_CRITICAL_SECTION_OBJ_QUEUE() raw_user_interrupts_off()
24 #define BAMBOO_CLOSE_CRITICAL_SECTION_OBJ_QUEUE() raw_user_interrupts_on()
25 // locks for global data structures related to status data
26 #define BAMBOO_START_CRITICAL_SECTION_STATUS() raw_user_interrupts_off()
27 #define BAMBOO_CLOSE_CRITICAL_SECTION_STATUS() raw_user_interrupts_on()
28 // locks for global data structures related to msg data
29 #define BAMBOO_START_CRITICAL_SECTION_MSG() raw_user_interrupts_off()
30 #define BAMBOO_CLOSE_CRITICAL_SECTION_MSG() raw_user_interrupts_on()
31 // locks for global data structures related to lock table
32 #define BAMBOO_START_CRITICAL_SECTION_LOCK() raw_user_interrupts_off()
33 #define BAMBOO_CLOSE_CRITICAL_SECTION_LOCK() raw_user_interrupts_on()
34 // locks for allocating memory
35 #define BAMBOO_START_CRITICAL_SECTION_MEM() raw_user_interrupts_off()
36 #define BAMBOO_CLOSE_CRITICAL_SECTION_MEM() raw_user_interrupts_on()
37 // locks for all global data structures
38 #define BAMBOO_START_CRITICAL_SECTION() raw_user_interrupts_off()
39 #define BAMBOO_CLOSE_CRITICAL_SECTION() raw_user_interrupts_on()
40 #else
41 // locks for global data structures related to obj queue
42 #define BAMBOO_START_CRITICAL_SECTION_OBJ_QUEUE()  
43 #define BAMBOO_CLOSE_CRITICAL_SECTION_OBJ_QUEUE()  
44 // locks for global data structures related to status data
45 #define BAMBOO_START_CRITICAL_SECTION_STATUS()  
46 #define BAMBOO_CLOSE_CRITICAL_SECTION_STATUS()  
47 // locks for global data structures related to msg data
48 #define BAMBOO_START_CRITICAL_SECTION_MSG()  
49 #define BAMBOO_CLOSE_CRITICAL_SECTION_MSG()  
50 // locks for global data structures related to lock table
51 #define BAMBOO_START_CRITICAL_SECTION_LOCK()  
52 #define BAMBOO_CLOSE_CRITICAL_SECTION_LOCK()  
53 // locks for allocating memory
54 #define BAMBOO_START_CRITICAL_SECTION_MEM()  
55 #define BAMBOO_CLOSE_CRITICAL_SECTION_MEM()  
56 // locks for all global data structures
57 #define BAMBOO_START_CRITICAL_SECTION()  
58 #define BAMBOO_CLOSE_CRITICAL_SECTION()  
59 #endif
60
61 #define BAMBOO_WAITING_FOR_LOCK() (receiveObject())
62 #define BAMBOO_CACHE_FLUSH_RANGE(x, y)  (raw_invalidate_cache_range((x), (y)))
63 #define BAMBOO_CACHE_FLUSH_ALL() (raw_flush_entire_cache())
64 #define BAMBOO_EXIT(x) (raw_test_done((x)))
65 #define BAMBOO_MSG_AVAIL() (gdn_input_avail())
66 #define BAMBOO_GET_EXE_TIME() (raw_get_cycle())
67
68 #endif // #ifndef RUNTIME_ARCH