1 #ifndef MULTICORE_MEM_H
2 #define MULTICORE_MEM_H
4 #include "SimpleHash.h"
22 // data structures for shared memory allocation
24 #define BAMBOO_BASE_VA 0xd000000
25 #elif defined TILERA_ZLINUX
27 #define BAMBOO_BASE_VA 0xd000000
28 #endif // MULTICORE_GC
32 #define GC_BAMBOO_NUMCORES 56
34 #define GC_BAMBOO_NUMCORES 62
38 #include "structdefs.h"
39 #define BAMBOO_NUM_BLOCKS (NUMCORES4GC*(2+1)+3)
40 #define BAMBOO_PAGE_SIZE (64 * 64)
41 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
42 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_SMEM_SIZE) *(BAMBOO_NUM_BLOCKS))
44 #elif defined GC_CACHE_ADAPT
45 #ifdef GC_LARGESHAREDHEAP
46 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+24))
48 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+14))
50 #define BAMBOO_PAGE_SIZE (64 * 1024) // 64K
51 #ifdef GC_LARGEPAGESIZE
52 #define BAMBOO_PAGE_SIZE (4 * 64 * 1024)
53 #define BAMBOO_SMEM_SIZE (4 * (BAMBOO_PAGE_SIZE))
54 #elif defined GC_SMALLPAGESIZE
55 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
56 #elif defined GC_SMALLPAGESIZE2
57 #define BAMBOO_PAGE_SIZE (16 * 1024) // (4096)
58 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
59 #elif defined GC_LARGEPAGESIZE2
60 #define BAMBOO_PAGE_SIZE (4 * 64 * 1024) // 64K
61 #define BAMBOO_SMEM_SIZE ((BAMBOO_PAGE_SIZE))
63 #define BAMBOO_SMEM_SIZE (4 * (BAMBOO_PAGE_SIZE))
64 #endif // GC_LARGEPAGESIZE
65 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS))
68 #ifdef GC_LARGESHAREDHEAP
69 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+2))
70 #elif defined GC_LARGESHAREDHEAP2
71 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+2))
73 #define BAMBOO_NUM_BLOCKS ((GC_BAMBOO_NUMCORES)*(2+3)) //(15 * 1024) //(64 * 4 * 0.75) //(1024 * 1024 * 3.5) 3G
75 #ifdef GC_LARGEPAGESIZE
76 #define BAMBOO_PAGE_SIZE (4 * 1024 * 1024) // (4096)
77 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
78 #elif defined GC_SMALLPAGESIZE
79 #define BAMBOO_PAGE_SIZE (256 * 1024) // (4096)
80 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
81 #elif defined GC_SMALLPAGESIZE2
82 #define BAMBOO_PAGE_SIZE (64 * 1024) // (4096)
83 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
85 #define BAMBOO_PAGE_SIZE (1024 * 1024) // (4096)
86 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
87 #endif // GC_LARGEPAGESIZE
88 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS)) //(1024 * 1024 * 240) //((unsigned long long int)(3.0 * 1024 * 1024 * 1024)) // 3G
92 volatile bool gc_localheap_s;
93 #include "multicoregarbage.h"
96 SMEMLOCAL = 0x0,// 0x0, using local mem only
97 SMEMFIXED, // 0x1, use local mem in lower address space(1 block only)
98 // and global mem in higher address space
99 SMEMMIXED, // 0x2, like FIXED mode but use a threshold to control
100 SMEMGLOBAL, // 0x3, using global mem only
104 SMEMSTRATEGY bamboo_smem_mode; //-DSMEML: LOCAL; -DSMEMF: FIXED;
105 //-DSMEMM: MIXED; -DSMEMG: GLOBAL;
112 struct freeMemItem * next;
116 struct freeMemItem * head;
117 struct freeMemItem * backuplist; // hold removed freeMemItem for reuse;
118 // only maintain 1 freemMemItem
121 // table recording the number of allocated bytes on each block
122 // Note: this table resides on the bottom of the shared heap for all cores
124 volatile int * bamboo_smemtbl;
125 volatile int bamboo_free_block;
126 unsigned int bamboo_reserved_smem; // reserved blocks on the top of the shared
127 // heap e.g. 20% of the heap and should not
128 // be allocated otherwise gc is invoked
129 volatile INTPTR bamboo_smem_zero_top;
130 #define BAMBOO_SMEM_ZERO_UNIT_SIZE (4 * 1024) // 4KB
132 //volatile mspace bamboo_free_msp;
133 INTPTR bamboo_free_smemp;
134 int bamboo_free_smem_size;
135 #endif // MULTICORE_GC
136 volatile bool smemflag;
137 volatile INTPTR bamboo_cur_msp;
138 volatile int bamboo_smem_size;