My Project  debian-1:4.1.1-p2+ds-4build1
Macros | Functions | Variables
omTables.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "omConfig.h"
#include "omDerivedConfig.h"
#include "omStructs.h"
#include "omAllocPrivate.h"

Go to the source code of this file.

Macros

#define MH_TABLES_C
 
#define _POSIX_SOURCE   1
 
#define MIN_BIN_BLOCKS   4
 
#define INCR_FACTOR   1
 
#define OM_MAX_BLOCK_SIZE   ((SIZEOF_OM_BIN_PAGE / MIN_BIN_BLOCKS) & ~(SIZEOF_STRICT_ALIGNMENT - 1))
 

Functions

void OutputSize2Bin (size_t *binSize, size_t max_block_size, int track)
 
void OutputSize2AlignedBin (size_t *binSize, size_t max_block_size, int track)
 
void OutputStaticBin (size_t *binSize, int max_bin_index, int track)
 
int GetMaxBlockThreshold ()
 
void CreateDenseBins ()
 
int main (int argc, char *argv[])
 

Variables

size_t om_BinSize [SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
 

Macro Definition Documentation

◆ _POSIX_SOURCE

#define _POSIX_SOURCE   1

Definition at line 10 of file omTables.c.

◆ INCR_FACTOR

#define INCR_FACTOR   1

Definition at line 26 of file omTables.c.

◆ MH_TABLES_C

#define MH_TABLES_C

Definition at line 8 of file omTables.c.

◆ MIN_BIN_BLOCKS

#define MIN_BIN_BLOCKS   4

Definition at line 25 of file omTables.c.

◆ OM_MAX_BLOCK_SIZE

#define OM_MAX_BLOCK_SIZE   ((SIZEOF_OM_BIN_PAGE / MIN_BIN_BLOCKS) & ~(SIZEOF_STRICT_ALIGNMENT - 1))

Definition at line 30 of file omTables.c.

Function Documentation

◆ CreateDenseBins()

void CreateDenseBins ( )

Definition at line 135 of file omTables.c.

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  }

◆ GetMaxBlockThreshold()

int GetMaxBlockThreshold ( )

Definition at line 122 of file omTables.c.

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);

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 164 of file omTables.c.

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  if (argc > 1)
178  {
179  /* output what goes into omTables.h */
180  printf(
181 "#ifndef OM_TABLES_H\n"
182 "#define OM_TABLES_H\n"
183 "#define OM_MAX_BLOCK_SIZE %d\n"
184 "#define OM_MAX_BIN_INDEX %d\n"
185 "#define OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD %d\n"
186 "#endif /* OM_TABLES_H */\n"
187 , OM_MAX_BLOCK_SIZE, max_bin_index, GetMaxBlockThreshold());
188  return 0;
189  }
190 
191  printf(
192 "#ifndef OM_TABLES_INC\n"
193 "#define OM_TABLES_INC\n"
194 );
195 
196  /* Output om_StaticBin */
197  OutputStaticBin(om_BinSize, max_bin_index, 0);
198  /* Output om_Size2Bin */
200 
201 #ifdef OM_ALIGNMENT_NEEDS_WORK
203 #endif
204 
205  printf("\n#ifdef OM_HAVE_TRACK\n");
206  /* Output om_StaticBin */
207  OutputStaticBin(om_BinSize, max_bin_index, 1);
208  /* Output om_Size2Bin */
209 #ifdef OM_ALIGNMENT_NEEDS_WORK
211 #else
213 #endif
214  printf("\n#endif /* OM_HAVE_TRACK */\n");
215 
216  printf("\n#endif /* OM_TABLES_INC */\n");
217  return 0;

◆ OutputSize2AlignedBin()

void OutputSize2AlignedBin ( size_t *  binSize,
size_t  max_block_size,
int  track 
)

Definition at line 80 of file omTables.c.

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);

◆ OutputSize2Bin()

void OutputSize2Bin ( size_t *  binSize,
size_t  max_block_size,
int  track 
)

Definition at line 64 of file omTables.c.

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);

◆ OutputStaticBin()

void OutputStaticBin ( size_t *  binSize,
int  max_bin_index,
int  track 
)

Definition at line 106 of file omTables.c.

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]));

Variable Documentation

◆ om_BinSize

size_t om_BinSize[SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
Initial value:
=
{ 8, 12, 16, 20,
24, 28, 32,
40, 48, 56, 64,
80, 96, 112, 128,
160, 192, 224,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*9)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*6)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*4)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*2)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,

Definition at line 49 of file omTables.c.

OutputSize2Bin
void OutputSize2Bin(size_t *binSize, size_t max_block_size, int track)
Definition: omTables.c:64
j
int j
Definition: facHensel.cc:105
INCR_FACTOR
#define INCR_FACTOR
Definition: omTables.c:26
OutputStaticBin
void OutputStaticBin(size_t *binSize, int max_bin_index, int track)
Definition: omTables.c:106
GetMaxBlockThreshold
int GetMaxBlockThreshold()
Definition: omTables.c:122
i
int i
Definition: cfEzgcd.cc:125
OM_MAX_BLOCK_SIZE
#define OM_MAX_BLOCK_SIZE
Definition: omTables.c:30
CreateDenseBins
void CreateDenseBins()
Definition: omTables.c:135
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
MIN_BIN_BLOCKS
#define MIN_BIN_BLOCKS
Definition: omTables.c:25
SIZEOF_OM_BIN_PAGE
#define SIZEOF_OM_BIN_PAGE
Definition: omAllocPrivate.h:30
OutputSize2AlignedBin
void OutputSize2AlignedBin(size_t *binSize, size_t max_block_size, int track)
Definition: omTables.c:80
om_BinSize
size_t om_BinSize[SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
Definition: omTables.c:49