Route ampif77 and ampif90 through ampiCC, factoring out duplicated code
[charm.git] / src / conv-core / mem-arena.h
blob4b9ac700a23e2e75f27348af692f97efa2d6266d
1 #ifndef _MEM_ARENA_H_
2 #define _MEM_ARENA_H_
4 #define USE_BTREE 1
6 #if USE_BTREE
8 /* b-tree definitions */
9 #define TREE_NODE_SIZE 128 /* a power of 2 is probably best */
10 #define TREE_NODE_MID 63 /* must be ceiling(TREE_NODE_SIZE / 2) - 1 */
12 /* linked list definitions */
13 #define LIST_ARRAY_SIZE 64
15 /* doubly-linked list node */
16 struct _dllnode {
17 struct _dllnode *previous;
18 struct _slotblock *sb;
19 struct _dllnode *next;
22 /* slotblock */
23 struct _slotblock {
24 CmiInt8 startslot;
25 CmiInt8 nslots;
26 struct _dllnode *listblock;
29 typedef struct _dllnode dllnode;
30 typedef struct _slotblock slotblock;
32 /* b-tree node */
33 struct _btreenode {
34 int num_blocks;
35 slotblock blocks[TREE_NODE_SIZE];
36 struct _btreenode *child[TREE_NODE_SIZE + 1];
38 typedef struct _btreenode btreenode;
40 /* slotset */
41 typedef struct _slotset {
42 btreenode *btree_root;
43 dllnode *list_array[LIST_ARRAY_SIZE];
44 } slotset;
46 #else
48 typedef struct _slotblock
50 CmiInt8 startslot;
51 CmiInt8 nslots;
52 } slotblock;
54 typedef struct _slotset
56 int maxbuf;
57 slotblock *buf;
58 CmiInt8 emptyslots;
59 } slotset;
61 #endif
63 slotset *new_slotset(CmiInt8 startslot, CmiInt8 nslots);
64 CmiInt8 get_slots(slotset *ss, CmiInt8 nslots);
65 void grab_slots(slotset *ss, CmiInt8 sslot, CmiInt8 nslots);
66 void free_slots(slotset *ss, CmiInt8 sslot, CmiInt8 nslots);
68 #endif