1 |
cnh |
1.7 |
C $Header: /u/gcmpack/MITgcm/eesupp/inc/BARRIER.h,v 1.6 2005/11/07 18:16:07 cnh Exp $ |
2 |
cnh |
1.4 |
C $Name: $ |
3 |
|
|
CBOP |
4 |
|
|
C !ROUTINE: BARRIER.h |
5 |
|
|
C !INTERFACE: |
6 |
|
|
C include "BARRIER.h" |
7 |
|
|
C !DESCRIPTION: |
8 |
|
|
C *==========================================================* |
9 |
|
|
C | BARRIER.h |
10 |
|
|
C | o Globals used by Fortran barrier routine. |
11 |
|
|
C *==========================================================* |
12 |
|
|
C | These variables support a simple Fortran shared memory |
13 |
|
|
C | barrier routine. They do busy waiting, that is the |
14 |
|
|
C | thread that is waiting sits in a tight loop reading |
15 |
|
|
C | some memory location and waiting for all other threads. |
16 |
|
|
C | On some systems this is sometimes a good method to use. |
17 |
|
|
C | On the T3E memory is not shared so the routine should |
18 |
|
|
C | use the T3E "eureka" barriers. On CRAY and NEC there are |
19 |
|
|
C | hardware barriers that are accessed through a compiler |
20 |
|
|
C | directives. Finally proper multi-threading compilers |
21 |
|
|
C | support barrier compile directives - sometimes these |
22 |
|
|
C | are good, sometimes they are lousy. |
23 |
|
|
C | The barrier mechanism is used as follows |
24 |
|
|
C | 1. In the single-threaded part of the code |
25 |
edhill |
1.5 |
C | CALL FBAR\_INIT |
26 |
cnh |
1.4 |
C | on CRAY, NEC this routine does nothing |
27 |
|
|
C | on T3E there is no single-threaded code |
28 |
|
|
C | but there may be barrier initialisation - |
29 |
|
|
C | need to check. |
30 |
|
|
C | 2. When we need to synchronize everybody just |
31 |
|
|
C | CALL FBAR( myThid ) |
32 |
|
|
C | where myThid is myThreadId |
33 |
edhill |
1.5 |
C | on CRAY, NEC FBAR will just do C\$DIR BARRIER |
34 |
cnh |
1.4 |
C | or the like. |
35 |
|
|
C | on T3E FBAR does CALL BARRIER(...) or something |
36 |
|
|
C | need to check this. |
37 |
|
|
C *==========================================================* |
38 |
|
|
CEOP |
39 |
cnh |
1.1 |
COMMON / BARRIER_COMMON / key1, key2, key3, |
40 |
cnh |
1.6 |
& door1, door2, door3, |
41 |
cnh |
1.7 |
& bCount, masterSet |
42 |
cnh |
1.1 |
INTEGER key1(lShare4,MAX_NO_THREADS) |
43 |
|
|
INTEGER key2(lShare4,MAX_NO_THREADS) |
44 |
|
|
INTEGER key3(lShare4,MAX_NO_THREADS) |
45 |
|
|
INTEGER door1 |
46 |
|
|
INTEGER door2 |
47 |
|
|
INTEGER door3 |
48 |
|
|
INTEGER VALID |
49 |
|
|
PARAMETER ( VALID = 1 ) |
50 |
|
|
INTEGER INVALID |
51 |
|
|
PARAMETER ( INVALID = 0 ) |
52 |
|
|
INTEGER OPEN |
53 |
|
|
PARAMETER ( OPEN = 1 ) |
54 |
|
|
INTEGER SHUT |
55 |
|
|
PARAMETER ( SHUT = 0 ) |
56 |
cnh |
1.6 |
INTEGER bCount(MAX_NO_THREADS) |
57 |
cnh |
1.7 |
INTEGER masterSet(MAX_NO_THREADS) |