My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
omalloc
omTables.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
"
19
#include "
omalloc/omAllocPrivate.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
36
size_t
om_BinSize
[
SIZEOF_OM_BIN_PAGE
/
MIN_BIN_BLOCKS
] =
37
{ 8, 16, 24, 32,
38
40, 48, 56, 64, 72,
39
80, 96, 112, 128, 144,
40
160, 192, 224,
41
((
SIZEOF_OM_BIN_PAGE
/ (
MIN_BIN_BLOCKS
+
INCR_FACTOR
*9)) / 8)*8,
42
((
SIZEOF_OM_BIN_PAGE
/ (
MIN_BIN_BLOCKS
+
INCR_FACTOR
*6)) / 8)*8,
43
((
SIZEOF_OM_BIN_PAGE
/ (
MIN_BIN_BLOCKS
+
INCR_FACTOR
*4)) / 8)*8,
44
((
SIZEOF_OM_BIN_PAGE
/ (
MIN_BIN_BLOCKS
+
INCR_FACTOR
*2)) / 8)*8,
45
((
SIZEOF_OM_BIN_PAGE
/ (
MIN_BIN_BLOCKS
+
INCR_FACTOR
)) / 8)*8,
46
OM_MAX_BLOCK_SIZE
};
47
48
#else
/* ! OM_ALIGN_8 */
49
50
size_t
om_BinSize
[
SIZEOF_OM_BIN_PAGE
/
MIN_BIN_BLOCKS
] =
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,
61
OM_MAX_BLOCK_SIZE
};
62
63
#endif
/* OM_ALIGN_8 */
64
65
void
OutputSize2Bin
(
size_t
*binSize,
size_t
max_block_size,
int
track)
66
{
67
long
i
,
j
;
68
printf(
"omBin om_Size2%sBin[/*%ld*/] = {\n"
,
69
(track?
"Track"
:
""
), (
long
)(max_block_size / SIZEOF_OM_ALIGNMENT));
70
i
=0;
71
j
=SIZEOF_OM_ALIGNMENT;
72
while
(
j
< max_block_size)
73
{
74
printf(
"&om_Static%sBin[%ld], /* %ld */ \n"
, (track?
"Track"
:
""
),
i
,
j
);
75
if
(binSize[
i
] ==
j
)
i
++;
76
j
+= SIZEOF_OM_ALIGNMENT;
77
}
78
printf(
"&om_Static%sBin[%ld] /* %ld */};\n\n"
, (track?
"Track"
:
""
),
i
,
j
);
79
}
80
81
void
OutputSize2AlignedBin
(
size_t
*binSize,
size_t
max_block_size,
int
track)
82
{
83
long
i
,
j
;
84
if
(
OM_MAX_BLOCK_SIZE
% 8 != 0)
85
{
86
fprintf(stderr,
"OM_MAX_BLOCK_SIZE == %d not divisible by 8\n"
,
OM_MAX_BLOCK_SIZE
);fflush(stdout);
87
_exit(1);
88
}
89
printf(
"omBin om_Size2%sBin[/*%ld*/] = {\n"
,
90
(track ?
"Track"
:
"Aligned"
), (
long
)(max_block_size / SIZEOF_OM_ALIGNMENT));
91
i
=0;
92
while
(binSize[
i
] % SIZEOF_STRICT_ALIGNMENT != 0)
i
++;
93
j
=SIZEOF_OM_ALIGNMENT;
94
while
(
j
< max_block_size)
95
{
96
printf(
"&om_Static%sBin[%ld], /* %ld */ \n"
, (track ?
"Track"
:
""
),
i
,
j
);
97
if
(binSize[
i
] ==
j
)
98
{
99
i
++;
100
while
(binSize[
i
] % SIZEOF_STRICT_ALIGNMENT != 0)
i
++;
101
}
102
j
+= SIZEOF_OM_ALIGNMENT;
103
}
104
printf(
"&om_Static%sBin[%ld] /* %ld */};\n\n"
, (track ?
"Track"
:
""
),
i
,
j
);
105
}
106
107
void
OutputStaticBin
(
size_t
*binSize,
int
max_bin_index,
int
track)
108
{
109
long
i
;
110
printf(
"omBin_t om_Static%sBin[/*%d*/] = {\n"
, (track ?
"Track"
:
""
), max_bin_index+1);
111
112
for
(
i
=0;
i
< max_bin_index;
i
++)
113
{
114
printf(
"{om_ZeroPage, NULL, NULL, %ld, %ld, 0},\n"
,
115
(
long
)(binSize[
i
] / SIZEOF_LONG),
116
(
long
)(
SIZEOF_OM_BIN_PAGE
/binSize[
i
]));
117
}
118
printf(
"{om_ZeroPage, NULL, NULL, %ld, %ld, 0}\n};\n\n"
,
119
(
long
)(binSize[
i
] / SIZEOF_LONG),
120
(
long
)(
SIZEOF_OM_BIN_PAGE
/binSize[
i
]));
121
}
122
123
int
GetMaxBlockThreshold
()
124
{
125
int
i
;
126
for
(
i
=SIZEOF_OM_ALIGNMENT;
i
<
OM_MAX_BLOCK_SIZE
;
i
+= SIZEOF_OM_ALIGNMENT)
127
{
128
if
((
SIZEOF_OM_BIN_PAGE
/
i
) ==
SIZEOF_OM_BIN_PAGE
/(
i
+ SIZEOF_OM_ALIGNMENT))
129
return
i
;
130
}
131
/* should never get here */
132
printf(
"error"
);fflush(stdout);
133
_exit(1);
134
}
135
136
void
CreateDenseBins
()
137
{
138
size_t
size
, align_size = SIZEOF_OM_ALIGNMENT;
139
int
i
= 1;
140
#ifdef OM_ALIGNMENT_NEEDS_WORK
141
int
n =
GetMaxBlockThreshold
();
142
#endif
143
144
size
= align_size;
145
om_BinSize
[0] = align_size;
146
i
= 1;
147
while
(
size
<
OM_MAX_BLOCK_SIZE
)
148
{
149
size
+= align_size;
150
#ifdef OM_ALIGNMENT_NEEDS_WORK
151
if
(
size
>= n && align_size != SIZEOF_STRICT_ALIGNMENT)
152
{
153
align_size = SIZEOF_STRICT_ALIGNMENT;
154
size
= OM_STRICT_ALIGN_SIZE(
size
);
155
}
156
#endif
157
om_BinSize
[
i
] =
size
;
158
if
((
SIZEOF_OM_BIN_PAGE
/ (
size
+ align_size)) < (
SIZEOF_OM_BIN_PAGE
/
size
))
159
{
160
i
++;
161
}
162
}
163
}
164
165
int
main
(
int
argc,
char
* argv[])
166
{
167
int
max_bin_index = 0;
168
/* determine max_bin_index */
169
#ifdef OM_HAVE_DENSE_BIN_DISTRIBUTION
170
CreateDenseBins
();
171
#endif
172
for
(;;)
173
{
174
max_bin_index++;
175
if
(
om_BinSize
[max_bin_index] ==
OM_MAX_BLOCK_SIZE
)
break
;
176
}
177
178
printf(
179
"#ifndef OM_TABLES_INC\n"
180
"#define OM_TABLES_INC\n"
181
);
182
183
/* Output om_StaticBin */
184
OutputStaticBin
(
om_BinSize
, max_bin_index, 0);
185
/* Output om_Size2Bin */
186
OutputSize2Bin
(
om_BinSize
,
OM_MAX_BLOCK_SIZE
, 0);
187
188
#ifdef OM_ALIGNMENT_NEEDS_WORK
189
OutputSize2AlignedBin
(
om_BinSize
,
OM_MAX_BLOCK_SIZE
, 0);
190
#endif
191
192
printf(
"\n#ifdef OM_HAVE_TRACK\n"
);
193
/* Output om_StaticBin */
194
OutputStaticBin
(
om_BinSize
, max_bin_index, 1);
195
/* Output om_Size2Bin */
196
#ifdef OM_ALIGNMENT_NEEDS_WORK
197
OutputSize2AlignedBin
(
om_BinSize
,
OM_MAX_BLOCK_SIZE
, 1);
198
#else
199
OutputSize2Bin
(
om_BinSize
,
OM_MAX_BLOCK_SIZE
, 1);
200
#endif
201
printf(
"\n#endif /* OM_HAVE_TRACK */\n"
);
202
203
printf(
"\n#endif /* OM_TABLES_INC */\n"
);
204
return
0;
205
}
206
#endif
/* MH_TABLES_C */
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition
cf_ops.cc:600
i
int i
Definition
cfEzgcd.cc:132
j
int j
Definition
facHensel.cc:110
omAllocPrivate.h
SIZEOF_OM_BIN_PAGE
#define SIZEOF_OM_BIN_PAGE
Definition
omAllocPrivate.h:32
omStructs.h
MIN_BIN_BLOCKS
#define MIN_BIN_BLOCKS
Definition
omTables.c:26
INCR_FACTOR
#define INCR_FACTOR
Definition
omTables.c:27
OutputSize2Bin
void OutputSize2Bin(size_t *binSize, size_t max_block_size, int track)
Definition
omTables.c:65
CreateDenseBins
void CreateDenseBins()
Definition
omTables.c:136
GetMaxBlockThreshold
int GetMaxBlockThreshold()
Definition
omTables.c:123
OutputStaticBin
void OutputStaticBin(size_t *binSize, int max_bin_index, int track)
Definition
omTables.c:107
om_BinSize
size_t om_BinSize[SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
Definition
omTables.c:50
OutputSize2AlignedBin
void OutputSize2AlignedBin(size_t *binSize, size_t max_block_size, int track)
Definition
omTables.c:81
OM_MAX_BLOCK_SIZE
#define OM_MAX_BLOCK_SIZE
Definition
omTables.c:31
main
int main()
Definition
p_Procs_Generate.cc:219
Generated on
for My Project by
doxygen 1.17.0
for
Singular