1
- DRAFT DOCUMENT FOR A COARRAY API DEFINTION
1
+ [This document is formatted with GitHub-Flavored Markdown. ]:#
2
+ [For better viewing, including hyperlinks, read it online at ]:#
3
+ [https://github.com/sourceryinstitute/opencoarrays/blob/master/CAF_API.md]:#
2
4
3
- NOTE: The actual function names will have some PREFIX to avoid name clashes.
4
- This prefix can be vendor specific.
5
+ # OpenCoarrays Application Binary Interface (ABI) #
5
6
7
+ * [To Do]
8
+ * [Implementation status]
9
+ * [Definitions and types]
10
+ * [Provided functions]
6
11
7
- Content
8
- 0 TODO
9
- 1 Implementation status
10
- 2 Description of defines and types used in the API
11
- 3 Description of the functions provided by the API
12
+ This document describes the OpenCoarrays application binary interface (ABI) through
13
+ which a compiler accesses coarray functionality. As such, the target audience for
14
+ this document is compiler developers. Most application developers need only write
15
+ standard-conforming Fortran 2008 or 2015 and compile their code with the OpenCoarrays
16
+ 'caf' compiler wrapper without knowledge of the ABI.
12
17
18
+ The actual function names in this document have a PREFIX in the source code to avoid
19
+ name clashes. The prefix can be vendor-specific.
13
20
14
- 0 TODO
21
+ ## <a name="to-do">To Do</a> ##
15
22
16
- - Discuss the current draft
17
- - Add missing functions of the current gfortran implementation
18
- - Address the TODO items
19
- - Extend the functions to match a sensible set
20
- - Update the implementation status, especially for the ARMCI library
23
+ * Discuss the current draft
24
+ * Add missing functions of the current gfortran implementation
25
+ * Address the TODO items
26
+ * Extend the functions to match a sensible set
27
+ * Update the implementation status, especially for the ARMCI library
21
28
29
+ ## <a name="implementation-status">Implementation status</a> ##
22
30
23
-
24
- 1 Implementation status
25
-
26
- The library implementation in this directory should be API compatible
31
+ The library implementation in this directory should be ABI-compatible
27
32
with the wording below, except for some "int errmsg_len" vs. size_t
28
- changes which have not yet been done.
29
-
30
- gfortran development is done in GCC's fortran-caf branch and should
31
- also match - with the same exception - the API described here.
32
-
33
- In both cases, the implementations might be stubs and not fully
34
- working or not fully adhering and should
35
- also match - with the same exception - the API described here.
36
-
37
- In both cases, the implementations might be stubs and not fully
38
- working or not fully adhering to the specification. See also individual
39
- notes below.
33
+ changes that have not yet been implemented.
40
34
35
+ ## <a name="definitions-and-types">Definitions and types</a> ##
41
36
42
-
43
- 2 Description of defines and types used in the API
44
-
45
-
46
- 2.1 caf_token_t
37
+ ### 2.1 caf_token_t ###
47
38
48
39
Typedef of type "void *" on the compiler side. Can be any data
49
40
type on the library side.
50
41
51
-
52
- 2.2 caf_register_t
42
+ ### 2.2 caf_register_t ###
53
43
54
44
Type indicating which kind of coarray variable should be registered.
55
45
56
- typedef enum caf_register_t {
57
- CAF_REGTYPE_COARRAY_STATIC,
58
- CAF_REGTYPE_COARRAY_ALLOC,
59
- CAF_REGTYPE_LOCK_STATIC,
60
- CAF_REGTYPE_LOCK_ALLOC
61
- CAF_REGTYPE_CRTITICAL
62
- }
63
- caf_register_t;
46
+ typedef enum caf_register_t {
47
+ CAF_REGTYPE_COARRAY_STATIC,
48
+ CAF_REGTYPE_COARRAY_ALLOC,
49
+ CAF_REGTYPE_LOCK_STATIC,
50
+ CAF_REGTYPE_LOCK_ALLOC,
51
+ CAF_REGTYPE_CRITICAL,
52
+ CAF_REGTYPE_EVENT_STATIC,
53
+ CAF_REGTYPE_EVENT_ALLOC
54
+ }
55
+ caf_register_t;
64
56
65
57
TODO:
66
58
Check whether this set is complete and makes sense
67
59
68
60
69
- 2.3 caf_token_t
61
+ ### 2.3 caf_token_t ###
70
62
71
- In terms of the processor, some opaque pointer, which is used to identify a
72
- coarray. The exact content is implementation defined by the library.
63
+ In terms of the processor, an opaque pointer, which is used to identify a
64
+ coarray. The exact content is implementation- defined by the library.
73
65
66
+ ### 2.4 Stat values ###
74
67
75
- 2.4 Stat values
76
-
77
- #define STAT_UNLOCKED 0
78
- #define STAT_LOCKED 1
79
- #define STAT_LOCKED_OTHER_IMAGE 2
80
- #define STAT_STOPPED_IMAGE 6000
68
+ #define STAT_UNLOCKED 0
69
+ #define STAT_LOCKED 1
70
+ #define STAT_LOCKED_OTHER_IMAGE 2
71
+ #define STAT_STOPPED_IMAGE 6000
81
72
82
73
TODO:
83
74
Define more, allow room for lib-specific values, update for TS18508.
@@ -86,28 +77,26 @@ TODO:
86
77
values.
87
78
88
79
80
+ ## <a name="provided-functions">Provided functions</a> ##
89
81
90
- 3. Description of the API functions
91
-
82
+ ### 3.1 Initialization function ###
92
83
93
- 3.1 Initialization function
94
-
95
- void caf_init (int *argc, char ***argv)
84
+ void caf_init (int *argc, char ***argv)
96
85
97
86
This function shall be called at startup of the program before the Fortran main
98
87
program. It takes as arguments the command-line arguments of the program. It is
99
88
permitted to pass to NULL pointers as argument; if non-NULL, the library is
100
89
permitted to modify the arguments.
101
90
102
91
Arguments:
103
- argc intent(inout) An integer pointer with the number of arguments
104
- passed to the program or NULL.
105
- argv intent(inout) A pointer to an array of strings with the
106
- command-line arguments or NULL.
92
+ argc intent(inout) An integer pointer with the number of arguments
93
+ passed to the program or NULL.
94
+ argv intent(inout) A pointer to an array of strings with the
95
+ command-line arguments or NULL.
107
96
108
97
NOTE:
109
- The function is modelled after the initialization function of the MPI
110
- ( Message Passing Interface) specification. Due to the way coarray
98
+ The function is modelled after the initialization function of the
99
+ Message Passing Interface (MPI ) specification. Due to the way coarray
111
100
registration (3.5) works, it might not be the first call to the libaray. If
112
101
the main program is not written in Fortran and only a library uses coarrays,
113
102
it can happen that this function is never called. Therefore, it is
121
110
when the command-line intrinsics are invoked.
122
111
123
112
124
- 3.2 Finalization function
113
+ ### 3.2 Finalization function ###
125
114
126
115
void caf_finish (void)
127
116
142
131
compiled with the -fcoarray=lib option.
143
132
144
133
145
- 3.3 Querying the image number
134
+ ### 3.3 Querying the image number ###
146
135
147
136
int caf_this_image (int distance)
148
137
161
150
162
151
163
152
164
- 3.4 Querying the maximal number of images
153
+ ### 3.4 Querying the maximal number of images ###
165
154
166
155
int caf_num_images (int distance, int failed)
167
156
184
173
185
174
186
175
187
- 3.5 Registering coarrays
176
+ ### 3.5 Registering coarrays ###
188
177
189
178
void *caf_register (size_t size, caf_register_t type, caf_token_t *token,
190
179
int *stat, char *errmsg, int errmsg_len)
@@ -249,7 +238,7 @@ TODO:
249
238
250
239
251
240
252
- 3.6 Deregistering coarrays
241
+ ### 3.6 Deregistering coarrays ###
253
242
254
243
void caf_deregister (const caf_token_t *token, int *stat, char *errmsg,
255
244
size_t errmsg_len)
@@ -279,8 +268,7 @@ TODO:
279
268
Change errmsg_len to size_t
280
269
281
270
282
-
283
- 3.7 Sending data from a local image to a remote image
271
+ ### 3.7 Sending data from a local image to a remote image ###
284
272
285
273
void caf_send (caf_token_t token, size_t offset, int image_index,
286
274
gfc_descriptor_t *dest, caf_vector_t *dst_vector,
@@ -334,7 +322,7 @@ OTHER TODOs:
334
322
335
323
336
324
337
- 3.8 Getting data from a remote image
325
+ ### 3.8 Getting data from a remote image ###
338
326
339
327
void caf_get_desc (caf_token_t token, size_t offset,
340
328
int image_index, gfc_descriptor_t *src,
374
362
real/complex kinds 10 and 16, which have the same byte size.
375
363
376
364
377
- 3.9 Sending data between remote images
365
+ ### 3.9 Sending data between remote images ###
378
366
379
367
void caf_sendget (caf_token_t dst_token, size_t dst_offset,
380
368
int dst_image_index, gfc_descriptor_t *dest,
426
414
427
415
428
416
429
- 3.10 Barriers
417
+ ### 3.10 Barriers ###
430
418
431
- 3.10.1 All-Image Barrier
419
+ ### 3.10.1 All-Image Barrier ###
432
420
433
421
void caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)
434
422
452
440
453
441
454
442
455
- 3.10.2 Barrier for Selected Images
443
+ ### 3.10.2 Barrier for Selected Images ###
456
444
457
445
void sync_images (int count, int images[], int *stat,
458
446
char *errmsg, size_t errmsg_len)
479
467
Implemented in GCC 4.x using an int argument for the error-string length.
480
468
Currently, size_t is not implemented.
481
469
482
-
483
-
484
- 3.11 Error abort
470
+ ### 3.11 Error abort ###
485
471
486
472
void error_stop_str (const char *string, int32_t str_len)
487
473
void error_stop (int32_t exit_error_code)
495
481
for ERROR STOP does not.
496
482
497
483
498
- 3.11 Locking and unlocking
484
+ ### 3.11 Locking and unlocking ###
499
485
500
- 3.11.1 Locking a lock variable
486
+ #### 3.11.1 Locking a lock variable ####
501
487
502
488
void caf_lock (caf_token_t token, size_t index, int image_index,
503
489
int *aquired_lock, int *stat, char *errmsg,
@@ -536,7 +522,7 @@ TODO:
536
522
Change errmsg_len to size_t
537
523
538
524
539
- 3.11.2 Unlocking a lock variable
525
+ #### 3.11.2 Unlocking a lock variable ####
540
526
541
527
void caf_unlock (caf_token_t token, size_t index, int image_index,
542
528
int *stat, char *errmsg, int errmsg_len)
@@ -567,3 +553,10 @@ GCC:
567
553
568
554
TODO:
569
555
Change errmsg_len to size_t
556
+
557
+ [Hyperlinks]:#
558
+
559
+ [To Do]: #to-do
560
+ [Implementation status]: #implementation-status
561
+ [Definitions and types]: #definitions-and-types
562
+ [Provided functions]: #provided-functions
0 commit comments