forked from espressif/arduino-esp32
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathxmp-library.h
executable file
·789 lines (565 loc) · 20.3 KB
/
xmp-library.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
/* Customer ID=11656; Build=0x5f626; Copyright (c) 2008-2009 by Tensilica Inc. ALL RIGHTS RESERVED.
These coded instructions, statements, and computer programs are the
copyrighted works and confidential proprietary information of Tensilica Inc.
They may not be modified, copied, reproduced, distributed, or disclosed to
third parties in any manner, medium, or form, in whole or in part, without
the prior written consent of Tensilica Inc. */
#ifndef _XMP_LIBRARY_H
#define _XMP_LIBRARY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <xtensa/config/core-isa.h>
#include <xtensa/config/core.h>
#include <xtensa/tie/xt_core.h>
#if XCHAL_HAVE_RELEASE_SYNC
#include <xtensa/tie/xt_sync.h>
#endif
#if XCHAL_HAVE_EXTERN_REGS
#include <xtensa/xtensa-xer.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "xtensa/system/mpsystem.h"
/*
W A R N I N G:
xmp library clients should treat all data structures in this file
as opaque. They are only public to enable users to declare them
statically.
*/
/* -------------------------------------------------------------------------
When using XMP on cache-incoherent systems, these macros are helpful
to ensure that you are not reading stale data, and to ensure that
the data you write makes it all the way back to main memory.
*/
#if !XCHAL_DCACHE_IS_COHERENT
#define XMP_WRITE_BACK_ELEMENT(x) xthal_dcache_region_writeback((void *)x, sizeof(*x))
#define XMP_INVALIDATE_ELEMENT(x) xthal_dcache_region_invalidate((void *)x, sizeof(*x))
#define XMP_WRITE_BACK_INVALIDATE_ELEMENT(x) xthal_dcache_region_writeback_inv((void *)x, sizeof(*x))
#define XMP_WRITE_BACK_ARRAY(x) xthal_dcache_region_writeback((void *)x, sizeof(x))
#define XMP_INVALIDATE_ARRAY(x) xthal_dcache_region_invalidate((void *)x, sizeof(x))
#define XMP_WRITE_BACK_INVALIDATE_ARRAY(x) xthal_dcache_region_writeback_inv((void *)x, sizeof(x))
#define XMP_WRITE_BACK_ARRAY_ELEMENTS(x, num_elements) xthal_dcache_region_writeback((void *)x, sizeof(*x) * num_elements)
#define XMP_INVALIDATE_ARRAY_ELEMENTS(x, num_elements) xthal_dcache_region_invalidate((void *)x, sizeof(*x) * num_elements)
#define XMP_WRITE_BACK_INVALIDATE_ARRAY_ELEMENTS(x, num_elements) xthal_dcache_region_writeback_inv((void *)x, sizeof(*x) * num_elements)
#else
#define XMP_WRITE_BACK_ELEMENT(x)
#define XMP_INVALIDATE_ELEMENT(x)
#define XMP_WRITE_BACK_INVALIDATE_ELEMENT(x)
#define XMP_WRITE_BACK_ARRAY(x)
#define XMP_INVALIDATE_ARRAY(x)
#define XMP_WRITE_BACK_INVALIDATE_ARRAY(x)
#define XMP_WRITE_BACK_ARRAY_ELEMENTS(x, num_elements)
#define XMP_INVALIDATE_ARRAY_ELEMENTS(x, num_elements)
#define XMP_WRITE_BACK_INVALIDATE_ARRAY_ELEMENTS(x, num_elements)
#endif
/* -------------------------------------------------------------------------
Initialization, error codes, constants and house-keeping
Every core should call xmp_init with the number of cores in the
system.
xmp_init should be called before you use any global synchronization
primitive or shared data.
Further, before you use a dynamically allocated synchronization
primitives, you need to both initialize it by calling the
xmp_*_init function, and you need to have called xmp_init, which
sets up interrupt handlers and interrupt routing.
The second parameter sets the interprocessor interrupt
routing. Passing zero instructs the library to use the default
routing, which will be suitable for most users.
*/
extern void xmp_init (int num_cores, unsigned int interrupt_routing);
/* If you want finer-grained control than that provided by xmp_init,
you can the functions below individually--however, this is more
inconvenient and requires greater understanding of the library's
internals. Don't use them directly unless you have a good reason.
*/
extern void xmp_unpack_shared (void);
extern void xmp_route_interrupts (unsigned int routing);
#if XCHAL_HAVE_MP_INTERRUPTS
extern void xmp_enable_ipi_interrupts (void);
/* Turn off certain things enabled by xmp_init */
extern void xmp_disable_ipi_interrupts (void);
#endif
extern void xmp_end (void);
/* Only valid after xmp_init. */
extern int xmp_num_cores (void);
/* How many cycles should a core wait before rechecking a
synchronization variable? Higher values will reduce memory
transactions, but will also result in higher latency in returning
from synchronization.
*/
extern void xmp_spin_wait_set_cycles (unsigned int limit);
/* If you would prefer to provide your own spin wait function,
to go to sleep, etc. Declare a function of this type, then call
this function. */
typedef void (*xmp_spin_wait_function_t)(void);
extern void xmp_spin_wait_set_function (xmp_spin_wait_function_t func);
extern void xmp_spin(void);
#define XMP_NO_OWNER 0x07
#define XMP_MUTEX_DESTROYED 0xFE
#define XMP_ERROR_FATAL 0xFD
#define XMP_MAX_CORES 0x4
static inline unsigned int xmp_prid (void)
{
#if XCHAL_HAVE_PRID
return XT_RSR_PRID() & 0xFF;
#else
return 0;
#endif
}
/* -------------------------------------------------------------------------
Tracing
A core must set a trace_file if it wants any synchronization
tracing to occur. Sharing file descriptors among cores is very
messy, so don't do it. This, unfortunately, means that two cores
contending for a mutex are not able to trace to the same file.
Any object (except the atomic integer) can have tracing off or on.
*/
extern void xmp_set_trace_file (FILE * file);
extern void xmp_trace (const char * fmt, ...);
/* -------------------------------------------------------------------------
Memory Allocation Functions.
These do what you would expect, only from shared memory instead of
private memory.
*/
#if XCHAL_DCACHE_IS_COHERENT
extern void * xmp_malloc (size_t size);
extern void * xmp_calloc (size_t nmemb, size_t size);
extern void xmp_free (void * ptr);
#endif
extern void * xmp_sbrk(int size);
/* -------------------------------------------------------------------------
xmp_atomic_int_t
The most basic synchronization primitive in the xmp library.
Atomic ints are sharable among processors, and even interrupt
levels on the same processor. However, their semantics are fairly
rudimentary. All other primitives are based on these, therefore,
changing this implementation affects all other primitives.
*/
typedef unsigned int xmp_atomic_int_t;
static inline xmp_atomic_int_t
xmp_coherent_l32ai(xmp_atomic_int_t * address)
{
XMP_INVALIDATE_ELEMENT (address);
return XT_L32AI(address, 0);
}
static inline void
xmp_coherent_s32ri(xmp_atomic_int_t value, xmp_atomic_int_t * address)
{
XT_S32RI (value, address, 0);
XMP_WRITE_BACK_ELEMENT (address);
}
#define XMP_ATOMIC_INT_INITIALIZER(value) (value)
/* xmp_atomic_int_init - Initialize an int prior to use
Nonsynchronizing, Nonblocking
Usage:
value - initial value
integer - points to an uninitialized integer
On exit:
initialized to given value
Errors: none
*/
static inline void
xmp_atomic_int_init (xmp_atomic_int_t * integer, int value)
{
xmp_coherent_s32ri (value, integer);
}
/* xmp_atomic_int_value - Read the value
Nonsynchronizing, Nonblocking
Usage:
integer - points to an int
Returns:
the value
*/
static inline int
xmp_atomic_int_value (xmp_atomic_int_t * integer)
{
return xmp_coherent_l32ai (integer);
}
/* xmp_atomic_int_conditional_increment - Conditionally increment integer
Synchronizing, nonblocking
Usage:
integer - points to an initialized integer
amount - how much to increment
prev - believed value of the integer
eg: prev = xmp_atomic_int_value (integer);
success = xmp_atomic_int_increment (integer, 1, prev);
Returns: current value of integer - user should check if it matches
the previous value of the integer. If it does, then the update
was successful.
*/
#define USE_ASSEMBLY_IMPLEMENTATION 0
static inline int
xmp_atomic_int_conditional_increment (xmp_atomic_int_t * integer, int amount, int prev)
{
int val;
int saved;
#if USE_ASSEMBLY_IMPLEMENTATION
/* %0 = prev
%1 = saved
%2 = atomic integer pointer
%3 = amount
*/
asm volatile ("wsr.scompare1 %0\n"
"mov %1, %0\n"
"add %0, %0, %3\n"
"s32c1i %0, %2, 0\n"
: "+&a" (prev), "+&a"(saved) : "a" (integer), "a" (amount));
return prev;
#else
XT_WSR_SCOMPARE1 (prev);
val = prev + amount;
saved = val;
XT_S32C1I (val, integer, 0);
return val;
#endif
}
/* xmp_atomic_int_increment - Increment integer
Synchronizing, blocking
Usage:
integer - points to an initialized integer
amount - how much to increment
Returns: new value of integer
*/
static inline int
xmp_atomic_int_increment (xmp_atomic_int_t * integer, int amount)
{
int val;
int saved;
#if USE_ASSEMBLY_IMPLEMENTATION
/* %0 = val
%1 = saved
%2 = atomic integer pointer
%3 = amount
*/
asm volatile ("l32ai %0, %2, 0\n"
"1:\n"
"wsr.scompare1 %0\n"
"mov %1, %0\n"
"add %0, %0, %3\n"
"s32c1i %0, %2, 0\n"
"bne %0, %1, 1b\n"
: "+&a" (val), "+&a"(saved) : "a" (integer), "a" (amount));
#else
/* Accurately naming "val" is tricky. Sometimes it will be what we
want to be the new value, but sometimes it contains the value
that is currently at the location. */
/* Load location's current value */
val = xmp_coherent_l32ai (integer);
do {
XT_WSR_SCOMPARE1 (val);
saved = val;
/* Change it to what we would like to store there--"new_val" */
val = val + amount;
/* Possibly store new_val, but reload location's current value no
matter what. */
XT_S32C1I (val, integer, 0);
if (val != saved)
xmp_spin();
} while (val != saved);
#endif
return val + amount;
}
/* xmp_atomic_int_conditional_set - Set the value of an atomic integer
Synchronizing, nonblocking
Usage:
integer - points to an initialized integer
from - believed value of the integer
eg: prev = xmp_atomic_int_value (integer);
success = xmp_atomic_int_conditional_set (integer, 1, prev);
to - new value
Returns: current value of integer - user should check if it matches
the previous value of the integer. If it does, then the update
was successful.
*/
static inline int
xmp_atomic_int_conditional_set (xmp_atomic_int_t * integer, int from, int to)
{
int val;
/* Don't even try to update if the integer's value isn't what we
think it should be. This prevents acquiring this cache-line for
writing and therefore prevents bus transactions when various
cores contend. */
val = xmp_coherent_l32ai(integer);
if (val == from) {
XT_WSR_SCOMPARE1 (from);
val = to;
/* Possibly store to, but reload location's current value no
matter what. */
XT_S32C1I (val, integer, 0);
}
return val;
}
/* Macros to implement trivial spin locks. These are very primitive, but
can be useful when you don't need the higher-overhead synchronization.
To use an xmp_atomic_int_t as a trivial spin lock, you should
initialize it to zero first.
*/
#define XMP_SIMPLE_SPINLOCK_ACQUIRE(atomic_int_ptr) \
{ while (xmp_atomic_int_conditional_set (atomic_int_ptr, 0, xmp_prid() + 1) != 0) \
xmp_spin(); }
#define XMP_SIMPLE_SPINLOCK_RELEASE(atomic_int_ptr) \
{ while (xmp_atomic_int_conditional_set (atomic_int_ptr, xmp_prid() + 1, 0) != xmp_prid() + 1) \
xmp_spin(); }
#define XMP_SIMPLE_SPINLOCK_OWNER(atomic_int_ptr) (xmp_atomic_int_value(atomic_int_ptr) - 1)
/* -------------------------------------------------------------------------
xmp_mutex_t - An even higher-level data structure to enforce
mutual exclusion between cores. A core which waits on a mutex might
sleep with a waiti and be interrupted by an interrupt.
Mutexes can be normal or recursive. For a normal mutex, a core
attempting to acquire a mutex it already holds will result in
deadlock. For a recursive mutex, a core will succeed in acquiring a
mutex it already holds, and must release it as many times as it
acquired it.
Mutexes are not sharable between interrupt levels--because
ownership is tracked by core, not thread.
Like all xmp data structures, an object of type xmp_mutex_t
should be treated by the programmer as opaque. They are only
public in this header file to allow them to be declared statically.
For configurations with 16-byte cache lines, this has the most
frequently used and changed data in the first line.
*/
#if XCHAL_DCACHE_IS_COHERENT
typedef struct xmp_mutex_t {
xmp_atomic_int_t qlock;
unsigned int qhead;
unsigned int qtail;
unsigned char queue[XMP_MAX_CORES];
unsigned short held;
unsigned char owner;
unsigned char recursive : 1;
unsigned char trace : 1;
unsigned char system : 1;
unsigned char unused : 5;
const char * name;
} xmp_mutex_t __attribute__ ((aligned (XMP_MAX_DCACHE_LINESIZE)));
#define XMP_MUTEX_INITIALIZER(name) \
{ 0, 0, -1, {XMP_NO_OWNER, XMP_NO_OWNER, XMP_NO_OWNER, XMP_NO_OWNER}, \
0, XMP_NO_OWNER, XMP_MUTEX_FLAG_NORMAL, 0, 0, 0, name }
#define XMP_RECURSIVE_MUTEX_INITIALIZER(name) \
{ 0, 0, -1, {XMP_NO_OWNER, XMP_NO_OWNER, XMP_NO_OWNER, XMP_NO_OWNER}, \
0, XMP_NO_OWNER, XMP_MUTEX_FLAG_RECURSIVE, 0, 0, 0, name }
#define XMP_MUTEX_FLAG_NORMAL 0
#define XMP_MUTEX_FLAG_RECURSIVE 1
#define XMP_MUTEX_ACQUIRE_FAILED -1
#define XMP_MUTEX_ERROR_DESTROY_OWNED -2
#define XMP_MUTEX_ERROR_NOT_OWNED -3
#define XMP_MUTEX_ERROR_ALREADY_OWNED -4
/*
xmp_mutex_init
Nonsynchronizing
Nonblocking
Usage:
mutex - points to an uninitialized mutex
name - name if you want one, NULL if not.
recursive - use recursive semantices
Returns
zero on success (always succeeds)
*/
extern int xmp_mutex_init (xmp_mutex_t * mutex,
const char * name,
unsigned int recursive);
/*
int xmp_mutex_destroy (xmp_mutex_t * mutex);
Synchronizing - will fail if mutex is held by anyone -- including
current processor
Nonblocking
Usage:
mutex - points to a mutex
Returns
zero on success
non-zero if mutex is held
*/
extern int xmp_mutex_destroy (xmp_mutex_t * mutex);
/*
xmp_mutex_lock -- Synchronizing
xmp_mutex_trylock
Usage:
mutex - points to a mutex
Returns
zero on success
*/
extern int xmp_mutex_lock (xmp_mutex_t * mutex);
extern int xmp_mutex_trylock (xmp_mutex_t * mutex);
/*
xmp_mutex_unlock
Synchronizing
Nonblocking
Usage:
mutex - points to a mutex
Returns
zero on success - mutex is released
non-zero on failure - mutex is owned by another core
- prid of processor that does own it
note that by the time this function
returns, the owner of the core may
have changed.
*/
extern int xmp_mutex_unlock (xmp_mutex_t * mutex);
/*
xmp_mutex_name
Nonsynchronizing
Nonblocking
Usage:
mutex - points to a mutex
Returns the name of the given mutex, which may be NULL.
*/
const char * xmp_mutex_name (const xmp_mutex_t * mutex);
/*
xmp_mutex_trace_on
xmp_mutex_trace_off
Nonsynchronizing
Nonblocking
Turn off and on tracing for the mutex.
These functions are only present in the debug version of the library.
*/
extern void xmp_mutex_trace_on (xmp_mutex_t * mutex);
extern void xmp_mutex_trace_off (xmp_mutex_t * mutex);
/* -------------------------------------------------------------------------
xmp_condition_t
Condition Variables following Mesa semantics.
Condition variables are not sharable among interrupt levels.
*/
typedef struct xmp_condition_t {
unsigned int qhead;
unsigned int qtail;
unsigned char queue[XMP_MAX_CORES];
unsigned int waiting[XMP_MAX_CORES];
unsigned char trace : 1;
unsigned char unused : 7;
const char * name;
} xmp_condition_t __attribute__ ((aligned (XMP_MAX_DCACHE_LINESIZE)));
#define XMP_CONDITION_INITIALIZER(name) \
{ 0, -1, {XMP_NO_OWNER, XMP_NO_OWNER, XMP_NO_OWNER, XMP_NO_OWNER}, \
{0, 0, 0, 0}, 0, 0, name}
/* xmp_condition_init - Initialize a condition variable
Nonsynchronizing, Nonblocking
Usage:
condition - pointer to an xmp_condition_t
On exit:
condition initialized
Errors: none
*/
extern int xmp_condition_init (xmp_condition_t * condition,
const char * name);
extern int xmp_condition_destroy (xmp_condition_t * condition);
/* xmp_condition_wait - Wait for a condition variable
Synchronizing, blocking
Usage:
condition - pointer to an xmp_condition_t
mutex - pointer to an xmp_mutex_t already acquired by the calling
process
Errors: if the mutex isn't held by this core
*/
extern int xmp_condition_wait (xmp_condition_t * condition,
xmp_mutex_t * mutex);
/* xmp_condition_signal
- Signal the first (if any) core waiting on a condition variable
You must hold the mutex you passed to xmp_condition_wait before
calling this function.
Synchronizing, nonblocking
Usage:
condition - pointer to an xmp_condition_t
Errors: none
*/
extern int xmp_condition_signal (xmp_condition_t * condition);
/* xmp_condition_broadcast
- Signal all cores waiting on a condition variable
Synchronizing, nonblocking
You must hold the mutex you passed to xmp_condition_wait before
calling this function.
Usage:
condition - pointer to an xmp_condition_t
Errors: none
*/
extern int xmp_condition_broadcast (xmp_condition_t * condition);
static inline const char * xmp_condition_name (const xmp_condition_t * condition)
{
return condition->name;
}
/*
xmp_condition_trace_on
xmp_condition_trace_off
Nonsynchronizing
Nonblocking
Turn off and on statistics and tracing for the condition. For
tracing you must also set a trace file for the core.
These functions are only present in the debug-version of the library.
*/
extern void xmp_condition_trace_on (xmp_condition_t * condition);
extern void xmp_condition_trace_off (xmp_condition_t * condition);
#endif /* XCHAL_DCACHE_IS_COHERENT */
/* -------------------------------------------------------------------------
xmp_barrier_t
Classic barriers that stop any core from continuing until a
specified number of cores reach that point. Once the barrier allows
cores through, the barrier is reset and will stop cores from
progressing again.
Barriers are not sharable among interrupt levels.
*/
typedef struct xmp_barrier_t
{
xmp_atomic_int_t count;
xmp_atomic_int_t state;
xmp_atomic_int_t sleeping;
unsigned short num_cores;
unsigned short trace : 1;
unsigned short system : 1;
const char * name;
} xmp_barrier_t __attribute__ ((aligned (XMP_MAX_DCACHE_LINESIZE)));
#define XMP_BARRIER_INITIALIZER(number, name) \
{ 0, 0, 0, number, 0, 0, name }
/* xmp_barrier_init - Initialize a barrier
Nonsynchronizing, Nonblocking
Usage:
barrier - pointer to an xmp_barrier_t
num_cores - number of cores needed to arrive at the
barrier before any are allowed through
On exit:
barrier initialized
Always returns zero.
Errors: none
*/
extern int xmp_barrier_init (xmp_barrier_t * barrier, int num_cores,
const char * name);
/* xmp_barrier_wait - Wait on a barrier
Nonsynchronizing, Nonblocking
Usage:
barrier - pointer to an xmp_barrier_t
On exit:
Enough cores (as determined at the barrier's initialization)
have reached the barrier.
Errors: none
*/
extern int xmp_barrier_wait (xmp_barrier_t * barrier);
static inline const char * xmp_barrier_name (const xmp_barrier_t * barrier)
{
return barrier->name;
}
/*
xmp_barrier_trace_on
xmp_barrier_trace_off
Nonsynchronizing
Nonblocking
Turn on and off tracing for the barrier. For
tracing you must also set a trace file for the core.
These functions are only present in the debug-version of the library.
*/
extern void xmp_barrier_trace_on (xmp_barrier_t * barrier);
extern void xmp_barrier_trace_off (xmp_barrier_t * barrier);
/* -------------------------------------------------------------------------
Portions of the library that are internal, but belong here for
convenience.
*/
extern xmp_atomic_int_t _ResetSync;
static inline void
xmp_initial_sync (int num_cores)
{
xmp_atomic_int_increment (&_ResetSync, 1);
while (xmp_coherent_l32ai (&_ResetSync) != num_cores)
xmp_spin ();
}
#ifdef __cplusplus
}
#endif
#endif /* _XMP_LIBRARY_H */