MulticoreBSP for C
Version 1.1
Main Page
Namespaces
Data Structures
Files
File List
Globals
mcinternal.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_MCINTERNAL
25
#define _H_MCINTERNAL
26
27
#include "
mcbsp-internal.h
"
28
#include "
mcutil.h
"
29
30
#include <stdio.h>
31
#include <errno.h>
32
#include <stdlib.h>
33
#include <assert.h>
34
#include <pthread.h>
35
#include <stdbool.h>
36
37
#ifdef __MACH__
38
#include <mach/mach.h>
39
#include <mach/clock.h>
40
#include <mach/mach_error.h>
41
#endif
42
43
#ifdef _WIN32
44
#include <windows.h>
45
#endif
46
50
struct
mcbsp_init_data
{
51
53
void (*
spmd
)(void);
54
58
void
*
bsp_program
;
59
61
int
argc
;
62
64
char
**
argv
;
65
67
pthread_t *
threads
;
68
70
MCBSP_PROCESSOR_INDEX_DATATYPE
P
;
71
73
volatile
bool
abort
;
74
76
bool
ended
;
77
82
MCBSP_PROCESSOR_INDEX_DATATYPE
sync_entry_counter
;
83
88
MCBSP_PROCESSOR_INDEX_DATATYPE
sync_exit_counter
;
89
91
pthread_mutex_t
mutex
;
92
93
#ifdef MCBSP_USE_SPINLOCK
94
95
unsigned
char
*
condition
;
96
98
unsigned
char
*
mid_condition
;
99
#else
100
101
pthread_cond_t
condition
;
102
104
pthread_cond_t
mid_condition
;
105
#endif
106
108
struct
mcbsp_util_address_table
global2local
;
109
111
struct
mcbsp_thread_data
**
threadData
;
112
114
struct
mcbsp_thread_data
*
prev_data
;
115
117
size_t
tagSize
;
118
119
};
120
124
struct
mcbsp_thread_data
{
125
127
struct
mcbsp_init_data
*
init
;
128
130
MCBSP_PROCESSOR_INDEX_DATATYPE
bsp_id
;
131
132
#ifdef __MACH__
133
134
clock_serv_t clock;
135
140
mach_timespec_t
start
;
141
#elif _WIN32
142
146
LARGE_INTEGER
start
;
147
152
LARGE_INTEGER frequency;
153
#else
154
155
struct
timespec
start
;
156
#endif
157
159
struct
mcbsp_util_address_map
local2global
;
160
165
unsigned
long
int
localC
;
166
171
struct
mcbsp_util_stack
removedGlobals
;
172
177
struct
mcbsp_util_stack
localsToRemove
;
178
183
struct
mcbsp_util_stack
*
request_queues
;
184
189
struct
mcbsp_util_stack
*
queues
;
190
197
struct
mcbsp_util_stack
*
hpsend_queues
;
198
203
size_t
newTagSize
;
204
206
struct
mcbsp_util_stack
bsmp
;
207
209
struct
mcbsp_util_stack
localsToPush
;
210
214
struct
mcbsp_util_stack
globalsToPush
;
215
216
};
217
222
struct
mcbsp_get_request
{
223
225
void
*
source
;
226
228
void
*
destination
;
229
231
size_t
length
;
232
233
};
234
243
struct
mcbsp_message
{
244
246
void
*
destination
;
247
249
size_t
length
;
250
251
};
252
257
struct
mcbsp_hpsend_request
{
258
260
const
void
*
payload
;
261
263
const
void
*
tag
;
264
266
size_t
payload_size
;
267
268
};
269
271
struct
mcbsp_push_request
{
272
274
void
*
address
;
275
277
MCBSP_BYTESIZE_TYPE
size
;
278
279
};
280
282
extern
pthread_key_t
mcbsp_internal_init_data
;
283
285
extern
pthread_key_t
mcbsp_internal_thread_data
;
286
290
extern
pthread_key_t
mcbsp_internal_init_data
;
291
293
extern
bool
mcbsp_internal_keys_allocated
;
294
299
extern
pthread_mutex_t
mcbsp_internal_key_mutex
;
300
306
void
bsp_init_internal
(
struct
mcbsp_init_data
*
const
initialisationData );
307
317
struct
mcbsp_init_data
*
bsp_begin_check
();
318
325
struct
mcbsp_util_machine_info
*
mcbsp_internal_getMachineInfo
();
326
330
void
mcbsp_internal_check_keys_allocated
();
331
336
void
*
mcbsp_internal_spmd
();
337
342
void
mcbsp_internal_check_aborted
();
343
344
#ifdef MCBSP_USE_SPINLOCK
345
354
void
mcbsp_internal_sync
(
struct
mcbsp_init_data
*
const
init,
const
size_t
bsp_id );
355
#else
356
363
void
mcbsp_internal_sync
(
struct
mcbsp_init_data
*
const
init );
364
#endif
365
366
#ifdef MCBSP_USE_SPINLOCK
367
383
void
mcbsp_internal_syncWithCondition
(
struct
mcbsp_init_data
*
const
init,
384
volatile
unsigned
char
*
const
condition,
const
size_t
bsp_id );
385
#else
386
399
void
mcbsp_internal_syncWithCondition
(
struct
mcbsp_init_data
*
const
init,
400
pthread_cond_t *
const
condition );
401
#endif
402
408
const
struct
mcbsp_thread_data
*
mcbsp_internal_const_prefunction
();
409
414
struct
mcbsp_thread_data
*
mcbsp_internal_prefunction
();
415
417
extern
int
main
(
int
argc,
char
** argv );
418
419
#endif
420
Generated by
1.8.1.1