xref: /llvm-project/flang/include/flang/Runtime/reduce.h (revision fc97d2e68b03bc2979395e84b645e5b3ba35aecd)
1 //===-- include/flang/Runtime/reduce.h --------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // Defines the API for implementations of the transformational intrinsic
10 // function REDUCE(); see F'2023 16.9.173.
11 //
12 // Similar to the definition of the APIs for SUM(), &c., in reduction.h,
13 // there are typed functions here like ReduceInteger4() for total reductions
14 // to scalars and void functions like ReduceInteger4Dim() for partial
15 // reductions to smaller arrays.
16 
17 #ifndef FORTRAN_RUNTIME_REDUCE_H_
18 #define FORTRAN_RUNTIME_REDUCE_H_
19 
20 #include "flang/Common/float128.h"
21 #include "flang/Common/uint128.h"
22 #include "flang/Runtime/cpp-type.h"
23 #include "flang/Runtime/entry-names.h"
24 #include <complex>
25 #include <cstdint>
26 
27 namespace Fortran::runtime {
28 
29 class Descriptor;
30 
31 template <typename T>
32 using ReferenceReductionOperation = T (*)(const T *, const T *);
33 template <typename T> using ValueReductionOperation = T (*)(T, T);
34 template <typename CHAR>
35 using ReductionCharOperation = void (*)(CHAR *hiddenResult,
36     std::size_t resultLen, const CHAR *x, const CHAR *y, std::size_t xLen,
37     std::size_t yLen);
38 using ReductionDerivedTypeOperation = void (*)(
39     void *hiddenResult, const void *x, const void *y);
40 
41 extern "C" {
42 
43 std::int8_t RTDECL(ReduceInteger1Ref)(const Descriptor &,
44     ReferenceReductionOperation<std::int8_t>, const char *source, int line,
45     int dim = 0, const Descriptor *mask = nullptr,
46     const std::int8_t *identity = nullptr, bool ordered = true);
47 std::int8_t RTDECL(ReduceInteger1Value)(const Descriptor &,
48     ValueReductionOperation<std::int8_t>, const char *source, int line,
49     int dim = 0, const Descriptor *mask = nullptr,
50     const std::int8_t *identity = nullptr, bool ordered = true);
51 void RTDECL(ReduceInteger1DimRef)(Descriptor &result, const Descriptor &array,
52     ReferenceReductionOperation<std::int8_t>, const char *source, int line,
53     int dim, const Descriptor *mask = nullptr,
54     const std::int8_t *identity = nullptr, bool ordered = true);
55 void RTDECL(ReduceInteger1DimValue)(Descriptor &result, const Descriptor &array,
56     ValueReductionOperation<std::int8_t>, const char *source, int line, int dim,
57     const Descriptor *mask = nullptr, const std::int8_t *identity = nullptr,
58     bool ordered = true);
59 std::int16_t RTDECL(ReduceInteger2Ref)(const Descriptor &,
60     ReferenceReductionOperation<std::int16_t>, const char *source, int line,
61     int dim = 0, const Descriptor *mask = nullptr,
62     const std::int16_t *identity = nullptr, bool ordered = true);
63 std::int16_t RTDECL(ReduceInteger2Value)(const Descriptor &,
64     ValueReductionOperation<std::int16_t>, const char *source, int line,
65     int dim = 0, const Descriptor *mask = nullptr,
66     const std::int16_t *identity = nullptr, bool ordered = true);
67 void RTDECL(ReduceInteger2DimRef)(Descriptor &result, const Descriptor &array,
68     ReferenceReductionOperation<std::int16_t>, const char *source, int line,
69     int dim, const Descriptor *mask = nullptr,
70     const std::int16_t *identity = nullptr, bool ordered = true);
71 void RTDECL(ReduceInteger2DimValue)(Descriptor &result, const Descriptor &array,
72     ValueReductionOperation<std::int16_t>, const char *source, int line,
73     int dim, const Descriptor *mask = nullptr,
74     const std::int16_t *identity = nullptr, bool ordered = true);
75 std::int32_t RTDECL(ReduceInteger4Ref)(const Descriptor &,
76     ReferenceReductionOperation<std::int32_t>, const char *source, int line,
77     int dim = 0, const Descriptor *mask = nullptr,
78     const std::int32_t *identity = nullptr, bool ordered = true);
79 std::int32_t RTDECL(ReduceInteger4Value)(const Descriptor &,
80     ValueReductionOperation<std::int32_t>, const char *source, int line,
81     int dim = 0, const Descriptor *mask = nullptr,
82     const std::int32_t *identity = nullptr, bool ordered = true);
83 void RTDECL(ReduceInteger4DimRef)(Descriptor &result, const Descriptor &array,
84     ReferenceReductionOperation<std::int32_t>, const char *source, int line,
85     int dim, const Descriptor *mask = nullptr,
86     const std::int32_t *identity = nullptr, bool ordered = true);
87 void RTDECL(ReduceInteger4DimValue)(Descriptor &result, const Descriptor &array,
88     ValueReductionOperation<std::int32_t>, const char *source, int line,
89     int dim, const Descriptor *mask = nullptr,
90     const std::int32_t *identity = nullptr, bool ordered = true);
91 std::int64_t RTDECL(ReduceInteger8Ref)(const Descriptor &,
92     ReferenceReductionOperation<std::int64_t>, const char *source, int line,
93     int dim = 0, const Descriptor *mask = nullptr,
94     const std::int64_t *identity = nullptr, bool ordered = true);
95 std::int64_t RTDECL(ReduceInteger8Value)(const Descriptor &,
96     ValueReductionOperation<std::int64_t>, const char *source, int line,
97     int dim = 0, const Descriptor *mask = nullptr,
98     const std::int64_t *identity = nullptr, bool ordered = true);
99 void RTDECL(ReduceInteger8DimRef)(Descriptor &result, const Descriptor &array,
100     ReferenceReductionOperation<std::int64_t>, const char *source, int line,
101     int dim, const Descriptor *mask = nullptr,
102     const std::int64_t *identity = nullptr, bool ordered = true);
103 void RTDECL(ReduceInteger8DimValue)(Descriptor &result, const Descriptor &array,
104     ValueReductionOperation<std::int64_t>, const char *source, int line,
105     int dim, const Descriptor *mask = nullptr,
106     const std::int64_t *identity = nullptr, bool ordered = true);
107 #ifdef __SIZEOF_INT128__
108 common::int128_t RTDECL(ReduceInteger16Ref)(const Descriptor &,
109     ReferenceReductionOperation<common::int128_t>, const char *source, int line,
110     int dim = 0, const Descriptor *mask = nullptr,
111     const common::int128_t *identity = nullptr, bool ordered = true);
112 common::int128_t RTDECL(ReduceInteger16Value)(const Descriptor &,
113     ValueReductionOperation<common::int128_t>, const char *source, int line,
114     int dim = 0, const Descriptor *mask = nullptr,
115     const common::int128_t *identity = nullptr, bool ordered = true);
116 void RTDECL(ReduceInteger16DimRef)(Descriptor &result, const Descriptor &array,
117     ReferenceReductionOperation<common::int128_t>, const char *source, int line,
118     int dim, const Descriptor *mask = nullptr,
119     const common::int128_t *identity = nullptr, bool ordered = true);
120 void RTDECL(ReduceInteger16DimValue)(Descriptor &result,
121     const Descriptor &array, ValueReductionOperation<common::int128_t>,
122     const char *source, int line, int dim, const Descriptor *mask = nullptr,
123     const common::int128_t *identity = nullptr, bool ordered = true);
124 #endif
125 
126 std::uint8_t RTDECL(ReduceUnsigned1Ref)(const Descriptor &,
127     ReferenceReductionOperation<std::uint8_t>, const char *source, int line,
128     int dim = 0, const Descriptor *mask = nullptr,
129     const std::uint8_t *identity = nullptr, bool ordered = true);
130 std::uint8_t RTDECL(ReduceUnsigned1Value)(const Descriptor &,
131     ValueReductionOperation<std::uint8_t>, const char *source, int line,
132     int dim = 0, const Descriptor *mask = nullptr,
133     const std::uint8_t *identity = nullptr, bool ordered = true);
134 void RTDECL(ReduceUnsigned1DimRef)(Descriptor &result, const Descriptor &array,
135     ReferenceReductionOperation<std::uint8_t>, const char *source, int line,
136     int dim, const Descriptor *mask = nullptr,
137     const std::uint8_t *identity = nullptr, bool ordered = true);
138 void RTDECL(ReduceUnsigned1DimValue)(Descriptor &result,
139     const Descriptor &array, ValueReductionOperation<std::uint8_t>,
140     const char *source, int line, int dim, const Descriptor *mask = nullptr,
141     const std::uint8_t *identity = nullptr, bool ordered = true);
142 std::uint16_t RTDECL(ReduceUnsigned2Ref)(const Descriptor &,
143     ReferenceReductionOperation<std::uint16_t>, const char *source, int line,
144     int dim = 0, const Descriptor *mask = nullptr,
145     const std::uint16_t *identity = nullptr, bool ordered = true);
146 std::uint16_t RTDECL(ReduceUnsigned2Value)(const Descriptor &,
147     ValueReductionOperation<std::uint16_t>, const char *source, int line,
148     int dim = 0, const Descriptor *mask = nullptr,
149     const std::uint16_t *identity = nullptr, bool ordered = true);
150 void RTDECL(ReduceUnsigned2DimRef)(Descriptor &result, const Descriptor &array,
151     ReferenceReductionOperation<std::uint16_t>, const char *source, int line,
152     int dim, const Descriptor *mask = nullptr,
153     const std::uint16_t *identity = nullptr, bool ordered = true);
154 void RTDECL(ReduceUnsigned2DimValue)(Descriptor &result,
155     const Descriptor &array, ValueReductionOperation<std::uint16_t>,
156     const char *source, int line, int dim, const Descriptor *mask = nullptr,
157     const std::uint16_t *identity = nullptr, bool ordered = true);
158 std::uint32_t RTDECL(ReduceUnsigned4Ref)(const Descriptor &,
159     ReferenceReductionOperation<std::uint32_t>, const char *source, int line,
160     int dim = 0, const Descriptor *mask = nullptr,
161     const std::uint32_t *identity = nullptr, bool ordered = true);
162 std::uint32_t RTDECL(ReduceUnsigned4Value)(const Descriptor &,
163     ValueReductionOperation<std::uint32_t>, const char *source, int line,
164     int dim = 0, const Descriptor *mask = nullptr,
165     const std::uint32_t *identity = nullptr, bool ordered = true);
166 void RTDECL(ReduceUnsigned4DimRef)(Descriptor &result, const Descriptor &array,
167     ReferenceReductionOperation<std::uint32_t>, const char *source, int line,
168     int dim, const Descriptor *mask = nullptr,
169     const std::uint32_t *identity = nullptr, bool ordered = true);
170 void RTDECL(ReduceUnsigned4DimValue)(Descriptor &result,
171     const Descriptor &array, ValueReductionOperation<std::uint32_t>,
172     const char *source, int line, int dim, const Descriptor *mask = nullptr,
173     const std::uint32_t *identity = nullptr, bool ordered = true);
174 std::uint64_t RTDECL(ReduceUnsigned8Ref)(const Descriptor &,
175     ReferenceReductionOperation<std::uint64_t>, const char *source, int line,
176     int dim = 0, const Descriptor *mask = nullptr,
177     const std::uint64_t *identity = nullptr, bool ordered = true);
178 std::uint64_t RTDECL(ReduceUnsigned8Value)(const Descriptor &,
179     ValueReductionOperation<std::uint64_t>, const char *source, int line,
180     int dim = 0, const Descriptor *mask = nullptr,
181     const std::uint64_t *identity = nullptr, bool ordered = true);
182 void RTDECL(ReduceUnsigned8DimRef)(Descriptor &result, const Descriptor &array,
183     ReferenceReductionOperation<std::uint64_t>, const char *source, int line,
184     int dim, const Descriptor *mask = nullptr,
185     const std::uint64_t *identity = nullptr, bool ordered = true);
186 void RTDECL(ReduceUnsigned8DimValue)(Descriptor &result,
187     const Descriptor &array, ValueReductionOperation<std::uint64_t>,
188     const char *source, int line, int dim, const Descriptor *mask = nullptr,
189     const std::uint64_t *identity = nullptr, bool ordered = true);
190 #ifdef __SIZEOF_INT128__
191 common::uint128_t RTDECL(ReduceUnsigned16Ref)(const Descriptor &,
192     ReferenceReductionOperation<common::uint128_t>, const char *source,
193     int line, int dim = 0, const Descriptor *mask = nullptr,
194     const common::uint128_t *identity = nullptr, bool ordered = true);
195 common::uint128_t RTDECL(ReduceUnsigned16Value)(const Descriptor &,
196     ValueReductionOperation<common::uint128_t>, const char *source, int line,
197     int dim = 0, const Descriptor *mask = nullptr,
198     const common::uint128_t *identity = nullptr, bool ordered = true);
199 void RTDECL(ReduceUnsigned16DimRef)(Descriptor &result, const Descriptor &array,
200     ReferenceReductionOperation<common::uint128_t>, const char *source,
201     int line, int dim, const Descriptor *mask = nullptr,
202     const common::uint128_t *identity = nullptr, bool ordered = true);
203 void RTDECL(ReduceUnsigned16DimValue)(Descriptor &result,
204     const Descriptor &array, ValueReductionOperation<common::uint128_t>,
205     const char *source, int line, int dim, const Descriptor *mask = nullptr,
206     const common::uint128_t *identity = nullptr, bool ordered = true);
207 #endif
208 
209 // REAL/COMPLEX(2 & 3) return 32-bit float results for the caller to downconvert
210 float RTDECL(ReduceReal2Ref)(const Descriptor &,
211     ReferenceReductionOperation<float>, const char *source, int line,
212     int dim = 0, const Descriptor *mask = nullptr,
213     const float *identity = nullptr, bool ordered = true);
214 float RTDECL(ReduceReal2Value)(const Descriptor &,
215     ValueReductionOperation<float>, const char *source, int line, int dim = 0,
216     const Descriptor *mask = nullptr, const float *identity = nullptr,
217     bool ordered = true);
218 void RTDECL(ReduceReal2DimRef)(Descriptor &result, const Descriptor &array,
219     ReferenceReductionOperation<float>, const char *source, int line, int dim,
220     const Descriptor *mask = nullptr, const float *identity = nullptr,
221     bool ordered = true);
222 void RTDECL(ReduceReal2DimValue)(Descriptor &result, const Descriptor &array,
223     ValueReductionOperation<float>, const char *source, int line, int dim,
224     const Descriptor *mask = nullptr, const float *identity = nullptr,
225     bool ordered = true);
226 float RTDECL(ReduceReal3Ref)(const Descriptor &,
227     ReferenceReductionOperation<float>, const char *source, int line,
228     int dim = 0, const Descriptor *mask = nullptr,
229     const float *identity = nullptr, bool ordered = true);
230 float RTDECL(ReduceReal3Value)(const Descriptor &,
231     ValueReductionOperation<float>, const char *source, int line, int dim = 0,
232     const Descriptor *mask = nullptr, const float *identity = nullptr,
233     bool ordered = true);
234 void RTDECL(ReduceReal3DimRef)(Descriptor &result, const Descriptor &array,
235     ReferenceReductionOperation<float>, const char *source, int line, int dim,
236     const Descriptor *mask = nullptr, const float *identity = nullptr,
237     bool ordered = true);
238 void RTDECL(ReduceReal3DimValue)(Descriptor &result, const Descriptor &array,
239     ValueReductionOperation<float>, const char *source, int line, int dim,
240     const Descriptor *mask = nullptr, const float *identity = nullptr,
241     bool ordered = true);
242 float RTDECL(ReduceReal4Ref)(const Descriptor &,
243     ReferenceReductionOperation<float>, const char *source, int line,
244     int dim = 0, const Descriptor *mask = nullptr,
245     const float *identity = nullptr, bool ordered = true);
246 float RTDECL(ReduceReal4Value)(const Descriptor &,
247     ValueReductionOperation<float>, const char *source, int line, int dim = 0,
248     const Descriptor *mask = nullptr, const float *identity = nullptr,
249     bool ordered = true);
250 void RTDECL(ReduceReal4DimRef)(Descriptor &result, const Descriptor &array,
251     ReferenceReductionOperation<float>, const char *source, int line, int dim,
252     const Descriptor *mask = nullptr, const float *identity = nullptr,
253     bool ordered = true);
254 void RTDECL(ReduceReal4DimValue)(Descriptor &result, const Descriptor &array,
255     ValueReductionOperation<float>, const char *source, int line, int dim,
256     const Descriptor *mask = nullptr, const float *identity = nullptr,
257     bool ordered = true);
258 double RTDECL(ReduceReal8Ref)(const Descriptor &,
259     ReferenceReductionOperation<double>, const char *source, int line,
260     int dim = 0, const Descriptor *mask = nullptr,
261     const double *identity = nullptr, bool ordered = true);
262 double RTDECL(ReduceReal8Value)(const Descriptor &,
263     ValueReductionOperation<double>, const char *source, int line, int dim = 0,
264     const Descriptor *mask = nullptr, const double *identity = nullptr,
265     bool ordered = true);
266 void RTDECL(ReduceReal8DimRef)(Descriptor &result, const Descriptor &array,
267     ReferenceReductionOperation<double>, const char *source, int line, int dim,
268     const Descriptor *mask = nullptr, const double *identity = nullptr,
269     bool ordered = true);
270 void RTDECL(ReduceReal8DimValue)(Descriptor &result, const Descriptor &array,
271     ValueReductionOperation<double>, const char *source, int line, int dim,
272     const Descriptor *mask = nullptr, const double *identity = nullptr,
273     bool ordered = true);
274 #if HAS_FLOAT80
275 CppTypeFor<TypeCategory::Real, 10> RTDECL(ReduceReal10Ref)(const Descriptor &,
276     ReferenceReductionOperation<CppTypeFor<TypeCategory::Real, 10>>,
277     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
278     const CppTypeFor<TypeCategory::Real, 10> *identity = nullptr,
279     bool ordered = true);
280 CppTypeFor<TypeCategory::Real, 10> RTDECL(ReduceReal10Value)(const Descriptor &,
281     ValueReductionOperation<CppTypeFor<TypeCategory::Real, 10>>,
282     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
283     const CppTypeFor<TypeCategory::Real, 10> *identity = nullptr,
284     bool ordered = true);
285 void RTDECL(ReduceReal10DimRef)(Descriptor &result, const Descriptor &array,
286     ReferenceReductionOperation<CppTypeFor<TypeCategory::Real, 10>>,
287     const char *source, int line, int dim, const Descriptor *mask = nullptr,
288     const CppTypeFor<TypeCategory::Real, 10> *identity = nullptr,
289     bool ordered = true);
290 void RTDECL(ReduceReal10DimValue)(Descriptor &result, const Descriptor &array,
291     ValueReductionOperation<CppTypeFor<TypeCategory::Real, 10>>,
292     const char *source, int line, int dim, const Descriptor *mask = nullptr,
293     const CppTypeFor<TypeCategory::Real, 10> *identity = nullptr,
294     bool ordered = true);
295 #endif
296 #if HAS_LDBL128 || HAS_FLOAT128
297 CppFloat128Type RTDECL(ReduceReal16Ref)(const Descriptor &,
298     ReferenceReductionOperation<CppFloat128Type>, const char *source, int line,
299     int dim = 0, const Descriptor *mask = nullptr,
300     const CppFloat128Type *identity = nullptr, bool ordered = true);
301 CppFloat128Type RTDECL(ReduceReal16Value)(const Descriptor &,
302     ValueReductionOperation<CppFloat128Type>, const char *source, int line,
303     int dim = 0, const Descriptor *mask = nullptr,
304     const CppFloat128Type *identity = nullptr, bool ordered = true);
305 void RTDECL(ReduceReal16DimRef)(Descriptor &result, const Descriptor &array,
306     ReferenceReductionOperation<CppFloat128Type>, const char *source, int line,
307     int dim, const Descriptor *mask = nullptr,
308     const CppFloat128Type *identity = nullptr, bool ordered = true);
309 void RTDECL(ReduceReal16DimValue)(Descriptor &result, const Descriptor &array,
310     ValueReductionOperation<CppFloat128Type>, const char *source, int line,
311     int dim, const Descriptor *mask = nullptr,
312     const CppFloat128Type *identity = nullptr, bool ordered = true);
313 #endif
314 
315 void RTDECL(CppReduceComplex2Ref)(CppTypeFor<TypeCategory::Complex, 4> &,
316     const Descriptor &,
317     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
318     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
319     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
320     bool ordered = true);
321 void RTDECL(CppReduceComplex2Value)(CppTypeFor<TypeCategory::Complex, 4> &,
322     const Descriptor &,
323     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
324     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
325     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
326     bool ordered = true);
327 void RTDECL(CppReduceComplex2DimRef)(Descriptor &result,
328     const Descriptor &array,
329     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
330     const char *source, int line, int dim, const Descriptor *mask = nullptr,
331     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
332     bool ordered = true);
333 void RTDECL(CppReduceComplex2DimValue)(Descriptor &result,
334     const Descriptor &array,
335     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
336     const char *source, int line, int dim, const Descriptor *mask = nullptr,
337     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
338     bool ordered = true);
339 void RTDECL(CppReduceComplex3Ref)(CppTypeFor<TypeCategory::Complex, 4> &,
340     const Descriptor &,
341     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
342     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
343     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
344     bool ordered = true);
345 void RTDECL(CppReduceComplex3Value)(CppTypeFor<TypeCategory::Complex, 4> &,
346     const Descriptor &,
347     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
348     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
349     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
350     bool ordered = true);
351 void RTDECL(CppReduceComplex3DimRef)(Descriptor &result,
352     const Descriptor &array,
353     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
354     const char *source, int line, int dim, const Descriptor *mask = nullptr,
355     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
356     bool ordered = true);
357 void RTDECL(CppReduceComplex3DimValue)(Descriptor &result,
358     const Descriptor &array,
359     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
360     const char *source, int line, int dim, const Descriptor *mask = nullptr,
361     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
362     bool ordered = true);
363 void RTDECL(CppReduceComplex4Ref)(CppTypeFor<TypeCategory::Complex, 4> &,
364     const Descriptor &,
365     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
366     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
367     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
368     bool ordered = true);
369 void RTDECL(CppReduceComplex4Value)(CppTypeFor<TypeCategory::Complex, 4> &,
370     const Descriptor &,
371     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
372     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
373     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
374     bool ordered = true);
375 void RTDECL(CppReduceComplex4DimRef)(Descriptor &result,
376     const Descriptor &array,
377     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
378     const char *source, int line, int dim, const Descriptor *mask = nullptr,
379     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
380     bool ordered = true);
381 void RTDECL(CppReduceComplex4DimValue)(Descriptor &result,
382     const Descriptor &array,
383     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 4>>,
384     const char *source, int line, int dim, const Descriptor *mask = nullptr,
385     const CppTypeFor<TypeCategory::Complex, 4> *identity = nullptr,
386     bool ordered = true);
387 void RTDECL(CppReduceComplex8Ref)(CppTypeFor<TypeCategory::Complex, 8> &,
388     const Descriptor &,
389     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 8>>,
390     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
391     const CppTypeFor<TypeCategory::Complex, 8> *identity = nullptr,
392     bool ordered = true);
393 void RTDECL(CppReduceComplex8Value)(CppTypeFor<TypeCategory::Complex, 8> &,
394     const Descriptor &,
395     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 8>>,
396     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
397     const CppTypeFor<TypeCategory::Complex, 8> *identity = nullptr,
398     bool ordered = true);
399 void RTDECL(CppReduceComplex8DimRef)(Descriptor &result,
400     const Descriptor &array,
401     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 8>>,
402     const char *source, int line, int dim, const Descriptor *mask = nullptr,
403     const CppTypeFor<TypeCategory::Complex, 8> *identity = nullptr,
404     bool ordered = true);
405 void RTDECL(CppReduceComplex8DimValue)(Descriptor &result,
406     const Descriptor &array,
407     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 8>>,
408     const char *source, int line, int dim, const Descriptor *mask = nullptr,
409     const CppTypeFor<TypeCategory::Complex, 8> *identity = nullptr,
410     bool ordered = true);
411 #if HAS_FLOAT80
412 void RTDECL(CppReduceComplex10Ref)(CppTypeFor<TypeCategory::Complex, 10> &,
413     const Descriptor &,
414     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 10>>,
415     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
416     const CppTypeFor<TypeCategory::Complex, 10> *identity = nullptr,
417     bool ordered = true);
418 void RTDECL(CppReduceComplex10Value)(CppTypeFor<TypeCategory::Complex, 10> &,
419     const Descriptor &,
420     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 10>>,
421     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
422     const CppTypeFor<TypeCategory::Complex, 10> *identity = nullptr,
423     bool ordered = true);
424 void RTDECL(CppReduceComplex10DimRef)(Descriptor &result,
425     const Descriptor &array,
426     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 10>>,
427     const char *source, int line, int dim, const Descriptor *mask = nullptr,
428     const CppTypeFor<TypeCategory::Complex, 10> *identity = nullptr,
429     bool ordered = true);
430 void RTDECL(CppReduceComplex10DimValue)(Descriptor &result,
431     const Descriptor &array,
432     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 10>>,
433     const char *source, int line, int dim, const Descriptor *mask = nullptr,
434     const CppTypeFor<TypeCategory::Complex, 10> *identity = nullptr,
435     bool ordered = true);
436 #endif
437 #if HAS_LDBL128 || HAS_FLOAT128
438 void RTDECL(CppReduceComplex16Ref)(CppTypeFor<TypeCategory::Complex, 16> &,
439     const Descriptor &,
440     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>,
441     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
442     const CppTypeFor<TypeCategory::Complex, 16> *identity = nullptr,
443     bool ordered = true);
444 void RTDECL(CppReduceComplex16Value)(CppTypeFor<TypeCategory::Complex, 16> &,
445     const Descriptor &,
446     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>,
447     const char *source, int line, int dim = 0, const Descriptor *mask = nullptr,
448     const CppTypeFor<TypeCategory::Complex, 16> *identity = nullptr,
449     bool ordered = true);
450 void RTDECL(CppReduceComplex16DimRef)(Descriptor &result,
451     const Descriptor &array,
452     ReferenceReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>,
453     const char *source, int line, int dim, const Descriptor *mask = nullptr,
454     const CppTypeFor<TypeCategory::Complex, 16> *identity = nullptr,
455     bool ordered = true);
456 void RTDECL(CppReduceComplex16DimValue)(Descriptor &result,
457     const Descriptor &array,
458     ValueReductionOperation<CppTypeFor<TypeCategory::Complex, 16>>,
459     const char *source, int line, int dim, const Descriptor *mask = nullptr,
460     const CppTypeFor<TypeCategory::Complex, 16> *identity = nullptr,
461     bool ordered = true);
462 #endif
463 
464 bool RTDECL(ReduceLogical1Ref)(const Descriptor &,
465     ReferenceReductionOperation<std::int8_t>, const char *source, int line,
466     int dim = 0, const Descriptor *mask = nullptr,
467     const std::int8_t *identity = nullptr, bool ordered = true);
468 bool RTDECL(ReduceLogical1Value)(const Descriptor &,
469     ValueReductionOperation<std::int8_t>, const char *source, int line,
470     int dim = 0, const Descriptor *mask = nullptr,
471     const std::int8_t *identity = nullptr, bool ordered = true);
472 void RTDECL(ReduceLogical1DimRef)(Descriptor &result, const Descriptor &array,
473     ReferenceReductionOperation<std::int8_t>, const char *source, int line,
474     int dim, const Descriptor *mask = nullptr,
475     const std::int8_t *identity = nullptr, bool ordered = true);
476 void RTDECL(ReduceLogical1DimValue)(Descriptor &result, const Descriptor &array,
477     ValueReductionOperation<std::int8_t>, const char *source, int line, int dim,
478     const Descriptor *mask = nullptr, const std::int8_t *identity = nullptr,
479     bool ordered = true);
480 bool RTDECL(ReduceLogical2Ref)(const Descriptor &,
481     ReferenceReductionOperation<std::int16_t>, const char *source, int line,
482     int dim = 0, const Descriptor *mask = nullptr,
483     const std::int16_t *identity = nullptr, bool ordered = true);
484 bool RTDECL(ReduceLogical2Value)(const Descriptor &,
485     ValueReductionOperation<std::int16_t>, const char *source, int line,
486     int dim = 0, const Descriptor *mask = nullptr,
487     const std::int16_t *identity = nullptr, bool ordered = true);
488 void RTDECL(ReduceLogical2DimRef)(Descriptor &result, const Descriptor &array,
489     ReferenceReductionOperation<std::int16_t>, const char *source, int line,
490     int dim, const Descriptor *mask = nullptr,
491     const std::int16_t *identity = nullptr, bool ordered = true);
492 void RTDECL(ReduceLogical2DimValue)(Descriptor &result, const Descriptor &array,
493     ValueReductionOperation<std::int16_t>, const char *source, int line,
494     int dim, const Descriptor *mask = nullptr,
495     const std::int16_t *identity = nullptr, bool ordered = true);
496 bool RTDECL(ReduceLogical4Ref)(const Descriptor &,
497     ReferenceReductionOperation<std::int32_t>, const char *source, int line,
498     int dim = 0, const Descriptor *mask = nullptr,
499     const std::int32_t *identity = nullptr, bool ordered = true);
500 bool RTDECL(ReduceLogical4Value)(const Descriptor &,
501     ValueReductionOperation<std::int32_t>, const char *source, int line,
502     int dim = 0, const Descriptor *mask = nullptr,
503     const std::int32_t *identity = nullptr, bool ordered = true);
504 void RTDECL(ReduceLogical4DimRef)(Descriptor &result, const Descriptor &array,
505     ReferenceReductionOperation<std::int32_t>, const char *source, int line,
506     int dim, const Descriptor *mask = nullptr,
507     const std::int32_t *identity = nullptr, bool ordered = true);
508 void RTDECL(ReduceLogical4DimValue)(Descriptor &result, const Descriptor &array,
509     ValueReductionOperation<std::int32_t>, const char *source, int line,
510     int dim, const Descriptor *mask = nullptr,
511     const std::int32_t *identity = nullptr, bool ordered = true);
512 bool RTDECL(ReduceLogical8Ref)(const Descriptor &,
513     ReferenceReductionOperation<std::int64_t>, const char *source, int line,
514     int dim = 0, const Descriptor *mask = nullptr,
515     const std::int64_t *identity = nullptr, bool ordered = true);
516 bool RTDECL(ReduceLogical8Value)(const Descriptor &,
517     ValueReductionOperation<std::int64_t>, const char *source, int line,
518     int dim = 0, const Descriptor *mask = nullptr,
519     const std::int64_t *identity = nullptr, bool ordered = true);
520 void RTDECL(ReduceLogical8DimRef)(Descriptor &result, const Descriptor &array,
521     ReferenceReductionOperation<std::int64_t>, const char *source, int line,
522     int dim, const Descriptor *mask = nullptr,
523     const std::int64_t *identity = nullptr, bool ordered = true);
524 void RTDECL(ReduceLogical8DimValue)(Descriptor &result, const Descriptor &array,
525     ValueReductionOperation<std::int64_t>, const char *source, int line,
526     int dim, const Descriptor *mask = nullptr,
527     const std::int64_t *identity = nullptr, bool ordered = true);
528 
529 void RTDECL(ReduceChar1)(char *result, const Descriptor &array,
530     ReductionCharOperation<char>, const char *source, int line, int dim = 0,
531     const Descriptor *mask = nullptr, const char *identity = nullptr,
532     bool ordered = true);
533 void RTDECL(ReduceCharacter1Dim)(Descriptor &result, const Descriptor &array,
534     ReductionCharOperation<char>, const char *source, int line, int dim,
535     const Descriptor *mask = nullptr, const char *identity = nullptr,
536     bool ordered = true);
537 void RTDECL(ReduceChar2)(char16_t *result, const Descriptor &array,
538     ReductionCharOperation<char16_t>, const char *source, int line, int dim = 0,
539     const Descriptor *mask = nullptr, const char16_t *identity = nullptr,
540     bool ordered = true);
541 void RTDECL(ReduceCharacter2Dim)(Descriptor &result, const Descriptor &array,
542     ReductionCharOperation<char16_t>, const char *source, int line, int dim,
543     const Descriptor *mask = nullptr, const char16_t *identity = nullptr,
544     bool ordered = true);
545 void RTDECL(ReduceChar4)(char32_t *result, const Descriptor &array,
546     ReductionCharOperation<char32_t>, const char *source, int line, int dim = 0,
547     const Descriptor *mask = nullptr, const char32_t *identity = nullptr,
548     bool ordered = true);
549 void RTDECL(ReduceCharacter4Dim)(Descriptor &result, const Descriptor &array,
550     ReductionCharOperation<char32_t>, const char *source, int line, int dim,
551     const Descriptor *mask = nullptr, const char32_t *identity = nullptr,
552     bool ordered = true);
553 
554 void RTDECL(ReduceDerivedType)(char *result, const Descriptor &array,
555     ReductionDerivedTypeOperation, const char *source, int line, int dim = 0,
556     const Descriptor *mask = nullptr, const char *identity = nullptr,
557     bool ordered = true);
558 void RTDECL(ReduceDerivedTypeDim)(Descriptor &result, const Descriptor &array,
559     ReductionDerivedTypeOperation, const char *source, int line, int dim,
560     const Descriptor *mask = nullptr, const char *identity = nullptr,
561     bool ordered = true);
562 
563 } // extern "C"
564 } // namespace Fortran::runtime
565 #endif // FORTRAN_RUNTIME_REDUCE_H_
566