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