gets rid of crashes...
[IRC.git] / Robust / src / Runtime / bamboo / multicoremem.h
1 #ifndef BAMBOO_MULTICORE_MEM_H
2 #define BAMBOO_MULTICORE_MEM_H
3 #include "multicore.h"
4 #include "Queue.h"
5 #include "SimpleHash.h"
6
7 // data structures for shared memory allocation
8 #ifdef TILERA_BME
9 #ifdef MGC
10 #define BAMBOO_BASE_VA 0x1000000  
11 #else 
12 #define BAMBOO_BASE_VA 0xd000000
13 #endif
14 #elif defined TILERA_ZLINUX
15 #ifdef MULTICORE_GC
16 #ifdef MGC
17 #define BAMBOO_BASE_VA 0x1000000 
18 #else 
19 #define BAMBOO_BASE_VA 0xd000000
20 #endif
21 #endif // MULTICORE_GC
22 #endif // TILERA_BME
23
24 #define BAMBOO_SHARED_RUNTIME_PAGE_SIZE ((unsigned int)(1<<24))  //16M
25
26 // include the header file that defines the BAMBOO_NUM_BLOCKS, BAMBOO_PAGE_SIZE, BAMBOO_PAGE_SIZE_BITS and BAMBOO_SMEM_SIZE
27 #include "multicorememsize.h"
28 #define BAMBOO_SHARED_MEM_SIZE ((unsigned int)((BAMBOO_SMEM_SIZE) * (BAMBOO_NUM_BLOCKS)))
29
30 #if defined(MULTICORE_GC)||defined(PMC_GC)
31 #if defined(GC_SMALLPAGESIZE)||defined(PMC_GC)
32 // memory for globals
33 #define BAMBOO_GLOBAL_DEFS_SIZE (1024 * 1024)
34 #define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (1024 * 512)
35 // memory for thread queue
36 #define BAMBOO_THREAD_QUEUE_SIZE (1024 * 1024)
37 #else
38 // memory for globals
39 #define BAMBOO_GLOBAL_DEFS_SIZE (BAMBOO_SMEM_SIZE)
40 #define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (BAMBOO_SMEM_SIZE/2)
41 // memory for thread queue
42 #define BAMBOO_THREAD_QUEUE_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024)
43 #endif // GC_SMALLPAGESIZE
44
45 //keeps track of the top address that has been zero'd by the allocator
46 volatile void * bamboo_smem_zero_top;
47 volatile unsigned int totalbytestozero;
48
49 //BAMBOO_SMEM_ZERO_UNIT_SIZE must evenly divide the page size and be a
50 //power of two(we rely on both in the allocation function)
51 #define BAMBOO_SMEM_ZERO_UNIT_SIZE 4096
52 #else
53 //This is for memory allocation with no garbage collection
54 unsigned int bamboo_free_smemp;
55 int bamboo_free_smem_size;
56 #endif // MULTICORE_GC
57 //This flag indicates that a memory request was services
58 volatile bool smemflag;
59 //Pointer to new block of memory after request
60 volatile void * bamboo_cur_msp;
61 //Number of bytes in new block of memory
62 volatile unsigned INTPTR bamboo_smem_size;
63
64 void * localmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
65 void * fixedmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
66 void * mixedmalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
67 void * globalmalloc_I(int coren, unsigned INTPTR memcheck, unsigned INTPTR * allocsize);
68 void * smemalloc(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
69 void * smemalloc_I(int coren, unsigned INTPTR isize, unsigned INTPTR * allocsize);
70
71 #warning Block size is BAMBOO_SMEM_SIZE
72 #warning Numblocks is BAMBOO_NUM_BLOCKS
73
74 #endif // BAMBOO_MULTICORE_MEM_H