annotate libgfortran/caf/libcaf.h @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Common declarations for all of GNU Fortran libcaf implementations.
kono
parents:
diff changeset
2 Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 Contributed by Tobias Burnus <burnus@net-b.de>
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of the GNU Fortran Coarray Runtime Library (libcaf).
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 Libcaf is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 Libcaf is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
18 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
19 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
22 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
24 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 #ifndef LIBCAF_H
kono
parents:
diff changeset
27 #define LIBCAF_H
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 #include <stdbool.h>
kono
parents:
diff changeset
30 #include <stddef.h> /* For size_t. */
kono
parents:
diff changeset
31 #include <stdint.h> /* For int32_t. */
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 #include "libgfortran.h"
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 #if 0
kono
parents:
diff changeset
36 #ifndef __GNUC__
kono
parents:
diff changeset
37 #define __attribute__(x)
kono
parents:
diff changeset
38 #define likely(x) (x)
kono
parents:
diff changeset
39 #define unlikely(x) (x)
kono
parents:
diff changeset
40 #else
kono
parents:
diff changeset
41 #define likely(x) __builtin_expect(!!(x), 1)
kono
parents:
diff changeset
42 #define unlikely(x) __builtin_expect(!!(x), 0)
kono
parents:
diff changeset
43 #endif
kono
parents:
diff changeset
44 #endif
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 /* Definitions of the Fortran 2008 standard; need to kept in sync with
kono
parents:
diff changeset
47 ISO_FORTRAN_ENV, cf. gcc/fortran/libgfortran.h. */
kono
parents:
diff changeset
48 typedef enum
kono
parents:
diff changeset
49 {
kono
parents:
diff changeset
50 CAF_STAT_UNLOCKED = 0,
kono
parents:
diff changeset
51 CAF_STAT_LOCKED,
kono
parents:
diff changeset
52 CAF_STAT_LOCKED_OTHER_IMAGE,
kono
parents:
diff changeset
53 CAF_STAT_STOPPED_IMAGE = 6000,
kono
parents:
diff changeset
54 CAF_STAT_FAILED_IMAGE = 6001
kono
parents:
diff changeset
55 }
kono
parents:
diff changeset
56 caf_stat_codes_t;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 /* Describes what type of array we are registerring. Keep in sync with
kono
parents:
diff changeset
60 gcc/fortran/trans.h. */
kono
parents:
diff changeset
61 typedef enum caf_register_t {
kono
parents:
diff changeset
62 CAF_REGTYPE_COARRAY_STATIC,
kono
parents:
diff changeset
63 CAF_REGTYPE_COARRAY_ALLOC,
kono
parents:
diff changeset
64 CAF_REGTYPE_LOCK_STATIC,
kono
parents:
diff changeset
65 CAF_REGTYPE_LOCK_ALLOC,
kono
parents:
diff changeset
66 CAF_REGTYPE_CRITICAL,
kono
parents:
diff changeset
67 CAF_REGTYPE_EVENT_STATIC,
kono
parents:
diff changeset
68 CAF_REGTYPE_EVENT_ALLOC,
kono
parents:
diff changeset
69 CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY,
kono
parents:
diff changeset
70 CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
kono
parents:
diff changeset
71 }
kono
parents:
diff changeset
72 caf_register_t;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 /* Describes the action to take on _caf_deregister. Keep in sync with
kono
parents:
diff changeset
75 gcc/fortran/trans.h. */
kono
parents:
diff changeset
76 typedef enum caf_deregister_t {
kono
parents:
diff changeset
77 CAF_DEREGTYPE_COARRAY_DEREGISTER,
kono
parents:
diff changeset
78 CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY
kono
parents:
diff changeset
79 }
kono
parents:
diff changeset
80 caf_deregister_t;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 typedef void* caf_token_t;
kono
parents:
diff changeset
83 typedef void * caf_team_t;
kono
parents:
diff changeset
84 typedef gfc_array_void gfc_descriptor_t;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 /* Linked list of static coarrays registered. */
kono
parents:
diff changeset
87 typedef struct caf_static_t {
kono
parents:
diff changeset
88 caf_token_t token;
kono
parents:
diff changeset
89 struct caf_static_t *prev;
kono
parents:
diff changeset
90 }
kono
parents:
diff changeset
91 caf_static_t;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* When there is a vector subscript in this dimension, nvec == 0, otherwise,
kono
parents:
diff changeset
94 lower_bound, upper_bound, stride contains the bounds relative to the declared
kono
parents:
diff changeset
95 bounds; kind denotes the integer kind of the elements of vector[]. */
kono
parents:
diff changeset
96 typedef struct caf_vector_t {
kono
parents:
diff changeset
97 size_t nvec;
kono
parents:
diff changeset
98 union {
kono
parents:
diff changeset
99 struct {
kono
parents:
diff changeset
100 void *vector;
kono
parents:
diff changeset
101 int kind;
kono
parents:
diff changeset
102 } v;
kono
parents:
diff changeset
103 struct {
kono
parents:
diff changeset
104 ptrdiff_t lower_bound, upper_bound, stride;
kono
parents:
diff changeset
105 } triplet;
kono
parents:
diff changeset
106 } u;
kono
parents:
diff changeset
107 }
kono
parents:
diff changeset
108 caf_vector_t;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 typedef enum caf_ref_type_t {
kono
parents:
diff changeset
111 /* Reference a component of a derived type, either regular one or an
kono
parents:
diff changeset
112 allocatable or pointer type. For regular ones idx in caf_reference_t is
kono
parents:
diff changeset
113 set to -1. */
kono
parents:
diff changeset
114 CAF_REF_COMPONENT,
kono
parents:
diff changeset
115 /* Reference an allocatable array. */
kono
parents:
diff changeset
116 CAF_REF_ARRAY,
kono
parents:
diff changeset
117 /* Reference a non-allocatable/non-pointer array. */
kono
parents:
diff changeset
118 CAF_REF_STATIC_ARRAY
kono
parents:
diff changeset
119 } caf_ref_type_t;
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 typedef enum caf_array_ref_t {
kono
parents:
diff changeset
122 /* No array ref. This terminates the array ref. */
kono
parents:
diff changeset
123 CAF_ARR_REF_NONE = 0,
kono
parents:
diff changeset
124 /* Reference array elements given by a vector. Only for this mode
kono
parents:
diff changeset
125 caf_reference_t.u.a.dim[i].v is valid. */
kono
parents:
diff changeset
126 CAF_ARR_REF_VECTOR,
kono
parents:
diff changeset
127 /* A full array ref (:). */
kono
parents:
diff changeset
128 CAF_ARR_REF_FULL,
kono
parents:
diff changeset
129 /* Reference a range on elements given by start, end and stride. */
kono
parents:
diff changeset
130 CAF_ARR_REF_RANGE,
kono
parents:
diff changeset
131 /* Only a single item is referenced given in the start member. */
kono
parents:
diff changeset
132 CAF_ARR_REF_SINGLE,
kono
parents:
diff changeset
133 /* An array ref of the kind (i:), where i is an arbitrary valid index in the
kono
parents:
diff changeset
134 array. The index i is given in the start member. */
kono
parents:
diff changeset
135 CAF_ARR_REF_OPEN_END,
kono
parents:
diff changeset
136 /* An array ref of the kind (:i), where the lower bound of the array ref
kono
parents:
diff changeset
137 is given by the remote side. The index i is given in the end member. */
kono
parents:
diff changeset
138 CAF_ARR_REF_OPEN_START
kono
parents:
diff changeset
139 } caf_array_ref_t;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 /* References to remote components of a derived type. */
kono
parents:
diff changeset
142 typedef struct caf_reference_t {
kono
parents:
diff changeset
143 /* A pointer to the next ref or NULL. */
kono
parents:
diff changeset
144 struct caf_reference_t *next;
kono
parents:
diff changeset
145 /* The type of the reference. */
kono
parents:
diff changeset
146 /* caf_ref_type_t, replaced by int to allow specification in fortran FE. */
kono
parents:
diff changeset
147 int type;
kono
parents:
diff changeset
148 /* The size of an item referenced in bytes. I.e. in an array ref this is
kono
parents:
diff changeset
149 the factor to advance the array pointer with to get to the next item.
kono
parents:
diff changeset
150 For component refs this gives just the size of the element referenced. */
kono
parents:
diff changeset
151 size_t item_size;
kono
parents:
diff changeset
152 union {
kono
parents:
diff changeset
153 struct {
kono
parents:
diff changeset
154 /* The offset (in bytes) of the component in the derived type. */
kono
parents:
diff changeset
155 ptrdiff_t offset;
kono
parents:
diff changeset
156 /* The offset (in bytes) to the caf_token associated with this
kono
parents:
diff changeset
157 component. NULL, when not allocatable/pointer ref. */
kono
parents:
diff changeset
158 ptrdiff_t caf_token_offset;
kono
parents:
diff changeset
159 } c;
kono
parents:
diff changeset
160 struct {
kono
parents:
diff changeset
161 /* The mode of the array ref. See CAF_ARR_REF_*. */
kono
parents:
diff changeset
162 /* caf_array_ref_t, replaced by unsigend char to allow specification in
kono
parents:
diff changeset
163 fortran FE. */
kono
parents:
diff changeset
164 unsigned char mode[GFC_MAX_DIMENSIONS];
kono
parents:
diff changeset
165 /* The type of a static array. Unset for array's with descriptors. */
kono
parents:
diff changeset
166 int static_array_type;
kono
parents:
diff changeset
167 /* Subscript refs (s) or vector refs (v). */
kono
parents:
diff changeset
168 union {
kono
parents:
diff changeset
169 struct {
kono
parents:
diff changeset
170 /* The start and end boundary of the ref and the stride. */
kono
parents:
diff changeset
171 index_type start, end, stride;
kono
parents:
diff changeset
172 } s;
kono
parents:
diff changeset
173 struct {
kono
parents:
diff changeset
174 /* nvec entries of kind giving the elements to reference. */
kono
parents:
diff changeset
175 void *vector;
kono
parents:
diff changeset
176 /* The number of entries in vector. */
kono
parents:
diff changeset
177 size_t nvec;
kono
parents:
diff changeset
178 /* The integer kind used for the elements in vector. */
kono
parents:
diff changeset
179 int kind;
kono
parents:
diff changeset
180 } v;
kono
parents:
diff changeset
181 } dim[GFC_MAX_DIMENSIONS];
kono
parents:
diff changeset
182 } a;
kono
parents:
diff changeset
183 } u;
kono
parents:
diff changeset
184 } caf_reference_t;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 void _gfortran_caf_init (int *, char ***);
kono
parents:
diff changeset
187 void _gfortran_caf_finalize (void);
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 int _gfortran_caf_this_image (int);
kono
parents:
diff changeset
190 int _gfortran_caf_num_images (int, int);
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 void _gfortran_caf_register (size_t, caf_register_t, caf_token_t *,
kono
parents:
diff changeset
193 gfc_descriptor_t *, int *, char *, int);
kono
parents:
diff changeset
194 void _gfortran_caf_deregister (caf_token_t *, caf_deregister_t, int *, char *,
kono
parents:
diff changeset
195 int);
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 void _gfortran_caf_sync_all (int *, char *, int);
kono
parents:
diff changeset
198 void _gfortran_caf_sync_memory (int *, char *, int);
kono
parents:
diff changeset
199 void _gfortran_caf_sync_images (int, int[], int *, char *, int);
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 void _gfortran_caf_stop_numeric (int32_t)
kono
parents:
diff changeset
202 __attribute__ ((noreturn));
kono
parents:
diff changeset
203 void _gfortran_caf_stop_str (const char *, int32_t)
kono
parents:
diff changeset
204 __attribute__ ((noreturn));
kono
parents:
diff changeset
205 void _gfortran_caf_error_stop_str (const char *, int32_t)
kono
parents:
diff changeset
206 __attribute__ ((noreturn));
kono
parents:
diff changeset
207 void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
kono
parents:
diff changeset
208 void _gfortran_caf_fail_image (void) __attribute__ ((noreturn));
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, int);
kono
parents:
diff changeset
211 void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int);
kono
parents:
diff changeset
212 void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int);
kono
parents:
diff changeset
213 void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, int);
kono
parents:
diff changeset
214 void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*),
kono
parents:
diff changeset
215 int, int, int *, char *, int, int);
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
kono
parents:
diff changeset
218 caf_vector_t *, gfc_descriptor_t *, int, int, bool,
kono
parents:
diff changeset
219 int *);
kono
parents:
diff changeset
220 void _gfortran_caf_send (caf_token_t, size_t, int, gfc_descriptor_t *,
kono
parents:
diff changeset
221 caf_vector_t *, gfc_descriptor_t *, int, int, bool,
kono
parents:
diff changeset
222 int *);
kono
parents:
diff changeset
223 void _gfortran_caf_sendget (caf_token_t, size_t, int, gfc_descriptor_t *,
kono
parents:
diff changeset
224 caf_vector_t *, caf_token_t, size_t, int,
kono
parents:
diff changeset
225 gfc_descriptor_t *, caf_vector_t *, int, int, bool);
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 void _gfortran_caf_get_by_ref (caf_token_t token, int image_idx,
kono
parents:
diff changeset
228 gfc_descriptor_t *dst, caf_reference_t *refs, int dst_kind,
kono
parents:
diff changeset
229 int src_kind, bool may_require_tmp, bool dst_reallocatable, int *stat);
kono
parents:
diff changeset
230 void _gfortran_caf_send_by_ref (caf_token_t token, int image_index,
kono
parents:
diff changeset
231 gfc_descriptor_t *src, caf_reference_t *refs, int dst_kind,
kono
parents:
diff changeset
232 int src_kind, bool may_require_tmp, bool dst_reallocatable, int *stat);
kono
parents:
diff changeset
233 void _gfortran_caf_sendget_by_ref (
kono
parents:
diff changeset
234 caf_token_t dst_token, int dst_image_index, caf_reference_t *dst_refs,
kono
parents:
diff changeset
235 caf_token_t src_token, int src_image_index, caf_reference_t *src_refs,
kono
parents:
diff changeset
236 int dst_kind, int src_kind, bool may_require_tmp, int *dst_stat,
kono
parents:
diff changeset
237 int *src_stat);
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 void _gfortran_caf_atomic_define (caf_token_t, size_t, int, void *, int *,
kono
parents:
diff changeset
240 int, int);
kono
parents:
diff changeset
241 void _gfortran_caf_atomic_ref (caf_token_t, size_t, int, void *, int *,
kono
parents:
diff changeset
242 int, int);
kono
parents:
diff changeset
243 void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *,
kono
parents:
diff changeset
244 void *, int *, int, int);
kono
parents:
diff changeset
245 void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
kono
parents:
diff changeset
246 int *, int, int);
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int);
kono
parents:
diff changeset
249 void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int);
kono
parents:
diff changeset
250 void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, int);
kono
parents:
diff changeset
251 void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, int);
kono
parents:
diff changeset
252 void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *);
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 void _gfortran_caf_failed_images (gfc_descriptor_t *,
kono
parents:
diff changeset
255 caf_team_t * __attribute__ ((unused)), int *);
kono
parents:
diff changeset
256 int _gfortran_caf_image_status (int, caf_team_t * __attribute__ ((unused)));
kono
parents:
diff changeset
257 void _gfortran_caf_stopped_images (gfc_descriptor_t *,
kono
parents:
diff changeset
258 caf_team_t * __attribute__ ((unused)),
kono
parents:
diff changeset
259 int *);
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 int _gfortran_caf_is_present (caf_token_t, int, caf_reference_t *);
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 #endif /* LIBCAF_H */