MulticoreBSP for C
Version 1.1
Main Page
Namespaces
Data Structures
Files
File List
Globals
mcutil.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 by Albert-Jan N. Yzelman
3
*
4
* This file is part of MulticoreBSP in C --
5
* a port of the original Java-based MulticoreBSP.
6
*
7
* MulticoreBSP for C is distributed as part of the original
8
* MulticoreBSP and is free software: you can redistribute
9
* it and/or modify it under the terms of the GNU Lesser
10
* General Public License as published by the Free Software
11
* Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
* MulticoreBSP is distributed in the hope that it will be
14
* useful, but WITHOUT ANY WARRANTY; without even the
15
* implied warranty of MERCHANTABILITY or FITNESS FOR A
16
* PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
18
*
19
* You should have received a copy of the GNU Lesser General
20
* Public License along with MulticoreBSP. If not, see
21
* <http://www.gnu.org/licenses/>.
22
*/
23
24
#ifndef _H_MCUTIL
25
#define _H_MCUTIL
26
27
#include <stdio.h>
28
#include <stdlib.h>
29
#include <assert.h>
30
#include <limits.h>
31
#include <string.h>
32
#include <unistd.h>
33
#include <stdlib.h>
34
#include <pthread.h>
35
#include <stdbool.h>
36
37
#ifdef _WIN32
38
#include <windows.h>
39
#endif
40
41
#include "
mcbsp.h
"
42
#include "
mcbsp-affinity.h
"
43
47
struct
mcbsp_util_machine_info
{
48
50
bool
Tset
;
51
53
bool
Aset
;
54
56
bool
Cset
;
57
59
bool
TpCset
;
60
62
bool
TNset
;
63
65
bool
Pset
;
66
68
bool
Rset
;
69
71
size_t
threads
;
72
74
enum
mcbsp_affinity_mode
affinity
;
75
84
size_t
cores
;
85
90
size_t
threads_per_core
;
91
93
enum
mcbsp_thread_numbering
thread_numbering
;
94
105
size_t
*
manual_affinity
;
106
110
size_t
num_reserved_cores
;
111
121
size_t
*
reserved_cores
;
122
123
};
124
126
struct
mcbsp_util_address_map
{
127
129
unsigned
long
int
cap
;
130
132
unsigned
long
int
size
;
133
135
void
* *
keys
;
136
138
unsigned
long
int
*
values
;
139
140
};
141
143
struct
mcbsp_util_address_table_entry
{
144
146
void
*
address
;
147
149
size_t
size
;
150
151
};
152
154
struct
mcbsp_util_stack
{
155
157
size_t
cap
;
158
160
size_t
top
;
161
163
size_t
size
;
164
166
void
*
array
;
167
168
};
169
171
struct
mcbsp_util_address_table
{
172
174
pthread_mutex_t
mutex
;
175
177
unsigned
long
int
cap
;
178
180
unsigned
long
int
P
;
181
183
#ifdef MCBSP_ALLOW_MULTIPLE_REGS
184
struct
mcbsp_util_stack
**
table
;
185
#else
186
struct
mcbsp_util_address_table_entry
**
table
;
187
#endif
188
};
189
196
void
mcbsp_util_stack_initialise
(
struct
mcbsp_util_stack
*
const
stack,
const
size_t
elementSize );
197
199
void
mcbsp_util_stack_grow
(
struct
mcbsp_util_stack
*
const
stack );
200
202
bool
mcbsp_util_stack_empty
(
const
struct
mcbsp_util_stack
*
const
stack );
203
214
void
*
mcbsp_util_stack_pop
(
struct
mcbsp_util_stack
*
const
stack );
215
224
void
*
mcbsp_util_stack_peek
(
const
struct
mcbsp_util_stack
*
const
stack );
225
227
void
mcbsp_util_stack_push
(
struct
mcbsp_util_stack
*
const
stack,
const
void
*
const
item );
228
230
void
mcbsp_util_stack_destroy
(
struct
mcbsp_util_stack
*
const
stack );
231
233
void
mcbsp_util_varstack_grow
(
struct
mcbsp_util_stack
*
const
stack );
234
236
void
*
mcbsp_util_varstack_pop
(
struct
mcbsp_util_stack
*
const
stack,
const
size_t
size
);
237
239
void
*
mcbsp_util_varstack_regpop
(
struct
mcbsp_util_stack
*
const
stack );
240
242
void
*
mcbsp_util_varstack_peek
(
const
struct
mcbsp_util_stack
*
const
stack,
const
size_t
size
);
243
245
void
mcbsp_util_varstack_push
(
struct
mcbsp_util_stack
*
const
stack,
const
void
*
const
item,
const
size_t
size
);
246
248
void
mcbsp_util_varstack_regpush
(
struct
mcbsp_util_stack
*
const
stack,
const
void
*
const
item );
249
257
void
mcbsp_util_address_table_initialise
(
struct
mcbsp_util_address_table
*
const
table,
const
unsigned
long
int
P );
258
265
void
mcbsp_util_address_table_grow
(
struct
mcbsp_util_address_table
*
const
table );
266
274
void
mcbsp_util_address_setsize
(
struct
mcbsp_util_address_table
*
const
table,
const
unsigned
long
int
target_size );
275
281
void
mcbsp_util_address_table_destroy
(
struct
mcbsp_util_address_table
*
const
table );
282
293
void
mcbsp_util_address_table_set
(
struct
mcbsp_util_address_table
*
const
table,
const
unsigned
long
int
key,
const
unsigned
long
int
version,
void
*
const
value,
const
size_t
size
);
294
304
const
struct
mcbsp_util_address_table_entry
*
mcbsp_util_address_table_get
(
const
struct
mcbsp_util_address_table
*
const
table,
const
unsigned
long
int
key,
const
unsigned
long
int
version );
305
315
bool
mcbsp_util_address_table_delete
(
struct
mcbsp_util_address_table
*
const
table,
const
unsigned
long
int
key,
const
unsigned
long
int
version );
316
322
void
mcbsp_util_address_map_initialise
(
struct
mcbsp_util_address_map
*
const
address_map );
323
329
void
mcbsp_util_address_map_grow
(
struct
mcbsp_util_address_map
*
const
address_map );
330
336
void
mcbsp_util_address_map_destroy
(
struct
mcbsp_util_address_map
*
const
address_map );
337
345
unsigned
long
int
mcbsp_util_address_map_get
(
const
struct
mcbsp_util_address_map
*
const
address_map,
const
void
*
const
key );
346
354
void
mcbsp_util_address_map_insert
(
struct
mcbsp_util_address_map
*
const
address_map,
void
*
const
key,
unsigned
long
int
value );
355
363
void
mcbsp_util_address_map_remove
(
struct
mcbsp_util_address_map
*
const
address_map,
void
*
const
key );
364
378
size_t
mcbsp_util_address_map_binsearch
(
const
struct
mcbsp_util_address_map
*
const
address_map,
const
void
*
const
key,
size_t
lo,
size_t
hi );
379
386
size_t
mcbsp_util_detect_hardware_threads
();
387
393
struct
mcbsp_util_machine_info
*
mcbsp_util_createMachineInfo
();
394
403
void
mcbsp_util_destroyMachineInfo
(
void
* machine_info );
404
409
int
mcbsp_util_int_compare
(
const
void
* a,
const
void
* b );
410
416
size_t
mcbsp_util_log2
(
size_t
x );
417
431
size_t
mcbsp_util_sort_unique_integers
(
size_t
*
const
array,
const
size_t
length,
const
size_t
lower_bound,
const
size_t
upper_bound );
432
443
bool
mcbsp_util_contains
(
const
size_t
*
const
array,
const
size_t
value,
const
size_t
lo,
const
size_t
hi );
444
454
int
*
mcbsp_util_pinning
(
const
MCBSP_PROCESSOR_INDEX_DATATYPE
P,
struct
mcbsp_util_machine_info
*
const
machine );
455
463
void
mcbsp_util_fatal
();
464
465
#endif
466
Generated by
1.8.1.1