1 #ifndef BAMBOO_MULTICORE_MEM_H
2 #define BAMBOO_MULTICORE_MEM_H
5 #include "SimpleHash.h"
7 // data structures for shared memory allocation
10 #define BAMBOO_BASE_VA 0x1000000
12 #define BAMBOO_BASE_VA 0xd000000
14 #elif defined TILERA_ZLINUX
17 #define BAMBOO_BASE_VA 0x1000000
19 #define BAMBOO_BASE_VA 0xd000000
21 #endif // MULTICORE_GC
25 #define GC_BAMBOO_NUMCORES 56
28 #define GC_BAMBOO_NUMCORES (NUMCORES)
30 #define GC_BAMBOO_NUMCORES 62
34 #define BAMBOO_SHARED_RUNTIME_PAGE_SIZE (1<<24) //16M
36 #define BAMBOO_PAGE_SIZE ((unsigned int)(64 * 1024)) // 64K
37 #define BAMBOO_PAGE_SIZE_BITS (16)
38 #ifdef GC_LARGEPAGESIZE
39 #define BAMBOO_PAGE_SIZE ((unsigned int)(4 * 64 * 1024))
40 #define BAMBOO_PAGE_SIZE_BITS (18)
41 #elif defined GC_LARGEPAGESIZE2
42 #define BAMBOO_PAGE_SIZE ((unsigned int)(4 * 64 * 1024)) // 64K
43 #define BAMBOO_PAGE_SIZE_BITS (18)
47 #include "structdefs.h"
48 #define BAMBOO_NUM_BLOCKS (NUMCORES4GC*(2+3))
49 #define BAMBOO_PAGE_SIZE (64 * 64)
50 #define BAMBOO_PAGE_SIZE_BITS (12)
51 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE))
52 #define BAMBOO_SHARED_MEM_SIZE ((unsigned int)((BAMBOO_SMEM_SIZE) *(BAMBOO_NUM_BLOCKS)))
54 #elif defined GC_CACHE_ADAPT
55 #ifdef GC_LARGESHAREDHEAP
56 #define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(2+24)))
58 #define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*72)) // 72M per core
60 #define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(2+14)))
62 #ifdef GC_LARGEPAGESIZE
63 #define BAMBOO_SMEM_SIZE ((unsigned int)(4 * (BAMBOO_PAGE_SIZE)))
64 #elif defined GC_SMALLPAGESIZE
65 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE))
66 #elif defined GC_SMALLPAGESIZE2
67 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE))
68 #elif defined GC_LARGEPAGESIZE2
69 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE))
71 #define BAMBOO_SMEM_SIZE ((unsigned int)(16*(BAMBOO_PAGE_SIZE))) // 1M
73 #define BAMBOO_SMEM_SIZE ((unsigned int)(4 * (BAMBOO_PAGE_SIZE)))
74 #endif // GC_LARGEPAGESIZE
75 #define BAMBOO_SHARED_MEM_SIZE ((unsigned int)((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS)))
78 #ifdef GC_LARGESHAREDHEAP
79 #define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(2+5)))
81 #define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*72)) // 72M per core
83 #define BAMBOO_NUM_BLOCKS ((unsigned int)((GC_BAMBOO_NUMCORES)*(2+2))) //(15 * 1024) //(64 * 4 * 0.75) //(1024 * 1024 * 3.5) 3G
85 #ifdef GC_LARGEPAGESIZE
86 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE*16))
87 #elif defined GC_SMALLPAGESIZE
88 #define BAMBOO_PAGE_SIZE ((unsigned int)(256 * 1024)) // (4096)
89 #define BAMBOO_PAGE_SIZE_BITS (18)
90 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE))
91 #elif defined GC_SMALLPAGESIZE2
92 #define BAMBOO_PAGE_SIZE ((unsigned int)(256 * 1024)) // (4096) 64
93 #define BAMBOO_PAGE_SIZE_BITS (18)
94 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE))
96 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE*16))
97 #endif // GC_LARGEPAGESIZE
98 #define BAMBOO_SHARED_MEM_SIZE ((unsigned int)((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS))) //(1024 * 1024 * 240) //((unsigned long long int)(3.0 * 1024 * 1024 * 1024)) // 3G
101 #if defined(MULTICORE_GC)||defined(PMC_GC)
102 #if defined(GC_SMALLPAGESIZE)||defined(PMC_GC)
103 // memory for globals
104 #define BAMBOO_GLOBAL_DEFS_SIZE (1024 * 1024)
105 #define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (1024 * 512)
106 // memory for thread queue
107 #define BAMBOO_THREAD_QUEUE_SIZE (1024 * 1024)
109 // memory for globals
110 #define BAMBOO_GLOBAL_DEFS_SIZE (BAMBOO_SMEM_SIZE)
111 #define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (BAMBOO_SMEM_SIZE/2)
112 // memory for thread queue
113 #define BAMBOO_THREAD_QUEUE_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024)
114 #endif // GC_SMALLPAGESIZE
116 //keeps track of the top address that has been zero'd by the allocator
117 volatile void * bamboo_smem_zero_top;
118 volatile unsigned int totalbytestozero;
120 //BAMBOO_SMEM_ZERO_UNIT_SIZE must evenly divide the page size and be a
121 //power of two(we rely on both in the allocation function)
122 #define BAMBOO_SMEM_ZERO_UNIT_SIZE 4096
124 //This is for memory allocation with no garbage collection
125 unsigned int bamboo_free_smemp;
126 int bamboo_free_smem_size;
127 #endif // MULTICORE_GC
128 //This flag indicates that a memory request was services
129 volatile bool smemflag;
130 //Pointer to new block of memory after request
131 volatile void * bamboo_cur_msp;
132 //Number of bytes in new block of memory
133 volatile unsigned INTPTR bamboo_smem_size;
135 void * localmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
136 void * fixedmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
137 void * mixedmalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
138 void * globalmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
139 void * smemalloc(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
140 void * smemalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
143 #endif // BAMBOO_MULTICORE_MEM_H