My Project
Loading...
Searching...
No Matches
omTables1.c
Go to the documentation of this file.
1/*******************************************************************
2 * File: omTables.c
3 * Purpose: program which generates omTables.inc
4 * Author: obachman (Olaf Bachmann)
5 * Created: 11/99
6 *******************************************************************/
7
8#ifndef MH_TABLES_C
9#define MH_TABLES_C
10
11#define _POSIX_SOURCE 1
12
13#include <stdio.h>
14#include <unistd.h>
15#include <string.h>
16#include "omalloc/omConfig.h"
17#include "omalloc/omDerivedConfig.h"
18#include "omalloc/omStructs.h"
20
21/* Specify the minimal number of blocks which should go into a bin */
22#if SIZEOF_SYSTEM_PAGE > 4096
23#define MIN_BIN_BLOCKS 8
24#define INCR_FACTOR 2
25#else
26#define MIN_BIN_BLOCKS 4
27#define INCR_FACTOR 1
28#endif
29
30
31#define OM_MAX_BLOCK_SIZE ((SIZEOF_OM_BIN_PAGE / MIN_BIN_BLOCKS) & ~(SIZEOF_STRICT_ALIGNMENT - 1))
32
33/* Specify sizes of static bins */
34#ifdef OM_ALIGN_8
35
37{ 8, 16, 24, 32,
38 40, 48, 56, 64, 72,
39 80, 96, 112, 128, 144,
40 160, 192, 224,
47
48#else /* ! OM_ALIGN_8 */
49
51{ 8, 12, 16, 20,
52 24, 28, 32,
53 40, 48, 56, 64,
54 80, 96, 112, 128,
55 160, 192, 224,
56 ((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*9)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
57 ((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*6)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
58 ((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*4)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
59 ((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*2)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
60 ((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
62
63#endif /* OM_ALIGN_8 */
64
66{
67 int i;
68 for (i=SIZEOF_OM_ALIGNMENT; i < OM_MAX_BLOCK_SIZE; i += SIZEOF_OM_ALIGNMENT)
69 {
70 if ((SIZEOF_OM_BIN_PAGE/i) == SIZEOF_OM_BIN_PAGE/(i + SIZEOF_OM_ALIGNMENT))
71 return i;
72 }
73 /* should never get here */
74 printf("error");fflush(stdout);
75 _exit(1);
76}
77
79{
80 size_t size, align_size = SIZEOF_OM_ALIGNMENT;
81 int i = 1;
82#ifdef OM_ALIGNMENT_NEEDS_WORK
83 int n = GetMaxBlockThreshold();
84#endif
85
86 size = align_size;
87 om_BinSize[0] = align_size;
88 i = 1;
89 while (size < OM_MAX_BLOCK_SIZE)
90 {
91 size += align_size;
92#ifdef OM_ALIGNMENT_NEEDS_WORK
93 if (size >= n && align_size != SIZEOF_STRICT_ALIGNMENT)
94 {
95 align_size = SIZEOF_STRICT_ALIGNMENT;
96 size= OM_STRICT_ALIGN_SIZE(size);
97 }
98#endif
99 om_BinSize[i] = size;
100 if ((SIZEOF_OM_BIN_PAGE / (size + align_size)) < (SIZEOF_OM_BIN_PAGE /size))
101 {
102 i++;
103 }
104 }
105}
106
107int main(int argc, char* argv[])
108{
109 int max_bin_index = 0;
110 /* determine max_bin_index */
111#ifdef OM_HAVE_DENSE_BIN_DISTRIBUTION
113#endif
114 for(;;)
115 {
116 max_bin_index++;
117 if (om_BinSize[max_bin_index] == OM_MAX_BLOCK_SIZE) break;
118 }
119 {
120 /* output what goes into omTables.h */
121 printf(
122"#ifndef OM_TABLES_H\n"
123"#define OM_TABLES_H\n"
124"#define OM_MAX_BLOCK_SIZE %d\n"
125"#define OM_MAX_BIN_INDEX %d\n"
126"#define OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD %d\n"
127"#endif /* OM_TABLES_H */\n"
128, OM_MAX_BLOCK_SIZE, max_bin_index, GetMaxBlockThreshold());
129 return 0;
130 }
131}
132#endif /* MH_TABLES_C */
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
int i
Definition: cfEzgcd.cc:132
#define SIZEOF_OM_BIN_PAGE
#define MIN_BIN_BLOCKS
Definition: omTables1.c:26
#define INCR_FACTOR
Definition: omTables1.c:27
void CreateDenseBins()
Definition: omTables1.c:78
int GetMaxBlockThreshold()
Definition: omTables1.c:65
size_t om_BinSize[SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
Definition: omTables1.c:50
#define OM_MAX_BLOCK_SIZE
Definition: omTables1.c:31
int main()