FLANG
reduction.h
1//===-- include/flang/Runtime/reduction.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 the reduction transformational intrinsic functions.
10
11#ifndef FORTRAN_RUNTIME_REDUCTION_H_
12#define FORTRAN_RUNTIME_REDUCTION_H_
13
14#include "flang/Common/float128.h"
15#include "flang/Common/uint128.h"
16#include "flang/Runtime/cpp-type.h"
17#include "flang/Runtime/entry-names.h"
18#include <cfloat>
19#include <cinttypes>
20#include <complex>
21#include <cstdint>
22
23namespace Fortran::runtime {
24
25class Descriptor;
26
27extern "C" {
28
29// Reductions that are known to return scalars have per-type entry
30// points. These cover the cases that either have no DIM=
31// argument or have an argument rank of 1. Pass 0 for no DIM=
32// or the value of the DIM= argument so that it may be checked.
33// The data type in the descriptor is checked against the expected
34// return type.
35//
36// Reductions that return arrays are the remaining cases in which
37// the argument rank is greater than one and there is a DIM=
38// argument present. These cases establish and allocate their
39// results in a caller-supplied descriptor, which is assumed to
40// be large enough.
41//
42// Complex-valued SUM and PRODUCT reductions and complex-valued
43// DOT_PRODUCT have their API entry points defined in complex-reduction.h;
44// these here are C wrappers around C++ implementations so as to keep
45// usage of C's _Complex types out of C++ code.
46
47// SUM()
48
49std::int8_t RTDECL(SumInteger1)(const Descriptor &, const char *source,
50 int line, int dim = 0, const Descriptor *mask = nullptr);
51std::int16_t RTDECL(SumInteger2)(const Descriptor &, const char *source,
52 int line, int dim = 0, const Descriptor *mask = nullptr);
53std::int32_t RTDECL(SumInteger4)(const Descriptor &, const char *source,
54 int line, int dim = 0, const Descriptor *mask = nullptr);
55std::int64_t RTDECL(SumInteger8)(const Descriptor &, const char *source,
56 int line, int dim = 0, const Descriptor *mask = nullptr);
57#ifdef __SIZEOF_INT128__
58common::int128_t RTDECL(SumInteger16)(const Descriptor &, const char *source,
59 int line, int dim = 0, const Descriptor *mask = nullptr);
60#endif
61std::uint8_t RTDECL(SumUnsigned1)(const Descriptor &, const char *source,
62 int line, int dim = 0, const Descriptor *mask = nullptr);
63std::uint16_t RTDECL(SumUnsigned2)(const Descriptor &, const char *source,
64 int line, int dim = 0, const Descriptor *mask = nullptr);
65std::uint32_t RTDECL(SumUnsigned4)(const Descriptor &, const char *source,
66 int line, int dim = 0, const Descriptor *mask = nullptr);
67std::uint64_t RTDECL(SumUnsigned8)(const Descriptor &, const char *source,
68 int line, int dim = 0, const Descriptor *mask = nullptr);
69#ifdef __SIZEOF_INT128__
70common::uint128_t RTDECL(SumUnsigned16)(const Descriptor &, const char *source,
71 int line, int dim = 0, const Descriptor *mask = nullptr);
72#endif
73
74// REAL/COMPLEX(2 & 3) return 32-bit float results for the caller to downconvert
75float RTDECL(SumReal2)(const Descriptor &, const char *source, int line,
76 int dim = 0, const Descriptor *mask = nullptr);
77float RTDECL(SumReal3)(const Descriptor &, const char *source, int line,
78 int dim = 0, const Descriptor *mask = nullptr);
79float RTDECL(SumReal4)(const Descriptor &, const char *source, int line,
80 int dim = 0, const Descriptor *mask = nullptr);
81double RTDECL(SumReal8)(const Descriptor &, const char *source, int line,
82 int dim = 0, const Descriptor *mask = nullptr);
83#if HAS_FLOAT80
84CppTypeFor<TypeCategory::Real, 10> RTDECL(SumReal10)(const Descriptor &,
85 const char *source, int line, int dim = 0,
86 const Descriptor *mask = nullptr);
87#endif
88#if HAS_LDBL128 || HAS_FLOAT128
89CppFloat128Type RTDECL(SumReal16)(const Descriptor &, const char *source,
90 int line, int dim = 0, const Descriptor *mask = nullptr);
91#endif
92
93void RTDECL(CppSumComplex2)(CppTypeFor<TypeCategory::Complex, 4> &,
94 const Descriptor &, const char *source, int line, int dim = 0,
95 const Descriptor *mask = nullptr);
96void RTDECL(CppSumComplex3)(CppTypeFor<TypeCategory::Complex, 4> &,
97 const Descriptor &, const char *source, int line, int dim = 0,
98 const Descriptor *mask = nullptr);
99void RTDECL(CppSumComplex4)(CppTypeFor<TypeCategory::Complex, 4> &,
100 const Descriptor &, const char *source, int line, int dim = 0,
101 const Descriptor *mask = nullptr);
102void RTDECL(CppSumComplex8)(CppTypeFor<TypeCategory::Complex, 8> &,
103 const Descriptor &, const char *source, int line, int dim = 0,
104 const Descriptor *mask = nullptr);
105#if HAS_FLOAT80
106void RTDECL(CppSumComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
107 const Descriptor &, const char *source, int line, int dim = 0,
108 const Descriptor *mask = nullptr);
109#endif
110#if HAS_LDBL128 || HAS_FLOAT128
111void RTDECL(CppSumComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
112 const Descriptor &, const char *source, int line, int dim = 0,
113 const Descriptor *mask = nullptr);
114#endif
115
116void RTDECL(SumDim)(Descriptor &result, const Descriptor &array, int dim,
117 const char *source, int line, const Descriptor *mask = nullptr);
118
119// PRODUCT()
120
121std::int8_t RTDECL(ProductInteger1)(const Descriptor &, const char *source,
122 int line, int dim = 0, const Descriptor *mask = nullptr);
123std::int16_t RTDECL(ProductInteger2)(const Descriptor &, const char *source,
124 int line, int dim = 0, const Descriptor *mask = nullptr);
125std::int32_t RTDECL(ProductInteger4)(const Descriptor &, const char *source,
126 int line, int dim = 0, const Descriptor *mask = nullptr);
127std::int64_t RTDECL(ProductInteger8)(const Descriptor &, const char *source,
128 int line, int dim = 0, const Descriptor *mask = nullptr);
129#ifdef __SIZEOF_INT128__
130common::int128_t RTDECL(ProductInteger16)(const Descriptor &,
131 const char *source, int line, int dim = 0,
132 const Descriptor *mask = nullptr);
133#endif
134std::uint8_t RTDECL(ProductUnsigned1)(const Descriptor &, const char *source,
135 int line, int dim = 0, const Descriptor *mask = nullptr);
136std::uint16_t RTDECL(ProductUnsigned2)(const Descriptor &, const char *source,
137 int line, int dim = 0, const Descriptor *mask = nullptr);
138std::uint32_t RTDECL(ProductUnsigned4)(const Descriptor &, const char *source,
139 int line, int dim = 0, const Descriptor *mask = nullptr);
140std::uint64_t RTDECL(ProductUnsigned8)(const Descriptor &, const char *source,
141 int line, int dim = 0, const Descriptor *mask = nullptr);
142#ifdef __SIZEOF_INT128__
143common::uint128_t RTDECL(ProductUnsigned16)(const Descriptor &,
144 const char *source, int line, int dim = 0,
145 const Descriptor *mask = nullptr);
146#endif
147
148// REAL/COMPLEX(2 & 3) return 32-bit float results for the caller to downconvert
149float RTDECL(ProductReal2)(const Descriptor &, const char *source, int line,
150 int dim = 0, const Descriptor *mask = nullptr);
151float RTDECL(ProductReal3)(const Descriptor &, const char *source, int line,
152 int dim = 0, const Descriptor *mask = nullptr);
153float RTDECL(ProductReal4)(const Descriptor &, const char *source, int line,
154 int dim = 0, const Descriptor *mask = nullptr);
155double RTDECL(ProductReal8)(const Descriptor &, const char *source, int line,
156 int dim = 0, const Descriptor *mask = nullptr);
157#if HAS_FLOAT80
158CppTypeFor<TypeCategory::Real, 10> RTDECL(ProductReal10)(const Descriptor &,
159 const char *source, int line, int dim = 0,
160 const Descriptor *mask = nullptr);
161#endif
162#if HAS_LDBL128 || HAS_FLOAT128
163CppFloat128Type RTDECL(ProductReal16)(const Descriptor &, const char *source,
164 int line, int dim = 0, const Descriptor *mask = nullptr);
165#endif
166
167void RTDECL(CppProductComplex2)(CppTypeFor<TypeCategory::Complex, 4> &,
168 const Descriptor &, const char *source, int line, int dim = 0,
169 const Descriptor *mask = nullptr);
170void RTDECL(CppProductComplex3)(CppTypeFor<TypeCategory::Complex, 4> &,
171 const Descriptor &, const char *source, int line, int dim = 0,
172 const Descriptor *mask = nullptr);
173void RTDECL(CppProductComplex4)(CppTypeFor<TypeCategory::Complex, 4> &,
174 const Descriptor &, const char *source, int line, int dim = 0,
175 const Descriptor *mask = nullptr);
176void RTDECL(CppProductComplex8)(CppTypeFor<TypeCategory::Complex, 8> &,
177 const Descriptor &, const char *source, int line, int dim = 0,
178 const Descriptor *mask = nullptr);
179#if HAS_FLOAT80
180void RTDECL(CppProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
181 const Descriptor &, const char *source, int line, int dim = 0,
182 const Descriptor *mask = nullptr);
183#endif
184#if HAS_LDBL128 || HAS_FLOAT128
185void RTDECL(CppProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
186 const Descriptor &, const char *source, int line, int dim = 0,
187 const Descriptor *mask = nullptr);
188#endif
189
190void RTDECL(ProductDim)(Descriptor &result, const Descriptor &array, int dim,
191 const char *source, int line, const Descriptor *mask = nullptr);
192
193// IALL, IANY, IPARITY
194std::int8_t RTDECL(IAll1)(const Descriptor &, const char *source, int line,
195 int dim = 0, const Descriptor *mask = nullptr);
196std::int16_t RTDECL(IAll2)(const Descriptor &, const char *source, int line,
197 int dim = 0, const Descriptor *mask = nullptr);
198std::int32_t RTDECL(IAll4)(const Descriptor &, const char *source, int line,
199 int dim = 0, const Descriptor *mask = nullptr);
200std::int64_t RTDECL(IAll8)(const Descriptor &, const char *source, int line,
201 int dim = 0, const Descriptor *mask = nullptr);
202#ifdef __SIZEOF_INT128__
203common::int128_t RTDECL(IAll16)(const Descriptor &, const char *source,
204 int line, int dim = 0, const Descriptor *mask = nullptr);
205#endif
206void RTDECL(IAllDim)(Descriptor &result, const Descriptor &array, int dim,
207 const char *source, int line, const Descriptor *mask = nullptr);
208
209std::int8_t RTDECL(IAny1)(const Descriptor &, const char *source, int line,
210 int dim = 0, const Descriptor *mask = nullptr);
211std::int16_t RTDECL(IAny2)(const Descriptor &, const char *source, int line,
212 int dim = 0, const Descriptor *mask = nullptr);
213std::int32_t RTDECL(IAny4)(const Descriptor &, const char *source, int line,
214 int dim = 0, const Descriptor *mask = nullptr);
215std::int64_t RTDECL(IAny8)(const Descriptor &, const char *source, int line,
216 int dim = 0, const Descriptor *mask = nullptr);
217#ifdef __SIZEOF_INT128__
218common::int128_t RTDECL(IAny16)(const Descriptor &, const char *source,
219 int line, int dim = 0, const Descriptor *mask = nullptr);
220#endif
221void RTDECL(IAnyDim)(Descriptor &result, const Descriptor &array, int dim,
222 const char *source, int line, const Descriptor *mask = nullptr);
223
224std::int8_t RTDECL(IParity1)(const Descriptor &, const char *source, int line,
225 int dim = 0, const Descriptor *mask = nullptr);
226std::int16_t RTDECL(IParity2)(const Descriptor &, const char *source, int line,
227 int dim = 0, const Descriptor *mask = nullptr);
228std::int32_t RTDECL(IParity4)(const Descriptor &, const char *source, int line,
229 int dim = 0, const Descriptor *mask = nullptr);
230std::int64_t RTDECL(IParity8)(const Descriptor &, const char *source, int line,
231 int dim = 0, const Descriptor *mask = nullptr);
232#ifdef __SIZEOF_INT128__
233common::int128_t RTDECL(IParity16)(const Descriptor &, const char *source,
234 int line, int dim = 0, const Descriptor *mask = nullptr);
235#endif
236void RTDECL(IParityDim)(Descriptor &result, const Descriptor &array, int dim,
237 const char *source, int line, const Descriptor *mask = nullptr);
238
239// FINDLOC, MAXLOC, & MINLOC
240// These return allocated arrays in the supplied descriptor.
241// The default value for KIND= should be the default INTEGER in effect at
242// compilation time.
243void RTDECL(Findloc)(Descriptor &, const Descriptor &x,
244 const Descriptor &target, int kind, const char *source, int line,
245 const Descriptor *mask = nullptr, bool back = false);
246void RTDECL(FindlocDim)(Descriptor &, const Descriptor &x,
247 const Descriptor &target, int kind, int dim, const char *source, int line,
248 const Descriptor *mask = nullptr, bool back = false);
249void RTDECL(MaxlocCharacter)(Descriptor &, const Descriptor &, int kind,
250 const char *source, int line, const Descriptor *mask = nullptr,
251 bool back = false);
252void RTDECL(MaxlocInteger1)(Descriptor &, const Descriptor &, int kind,
253 const char *source, int line, const Descriptor *mask = nullptr,
254 bool back = false);
255void RTDECL(MaxlocInteger2)(Descriptor &, const Descriptor &, int kind,
256 const char *source, int line, const Descriptor *mask = nullptr,
257 bool back = false);
258void RTDECL(MaxlocInteger4)(Descriptor &, const Descriptor &, int kind,
259 const char *source, int line, const Descriptor *mask = nullptr,
260 bool back = false);
261void RTDECL(MaxlocInteger8)(Descriptor &, const Descriptor &, int kind,
262 const char *source, int line, const Descriptor *mask = nullptr,
263 bool back = false);
264void RTDECL(MaxlocInteger16)(Descriptor &, const Descriptor &, int kind,
265 const char *source, int line, const Descriptor *mask = nullptr,
266 bool back = false);
267void RTDECL(MaxlocUnsigned1)(Descriptor &, const Descriptor &, int kind,
268 const char *source, int line, const Descriptor *mask = nullptr,
269 bool back = false);
270void RTDECL(MaxlocUnsigned2)(Descriptor &, const Descriptor &, int kind,
271 const char *source, int line, const Descriptor *mask = nullptr,
272 bool back = false);
273void RTDECL(MaxlocUnsigned4)(Descriptor &, const Descriptor &, int kind,
274 const char *source, int line, const Descriptor *mask = nullptr,
275 bool back = false);
276void RTDECL(MaxlocUnsigned8)(Descriptor &, const Descriptor &, int kind,
277 const char *source, int line, const Descriptor *mask = nullptr,
278 bool back = false);
279void RTDECL(MaxlocUnsigned16)(Descriptor &, const Descriptor &, int kind,
280 const char *source, int line, const Descriptor *mask = nullptr,
281 bool back = false);
282void RTDECL(MaxlocReal4)(Descriptor &, const Descriptor &, int kind,
283 const char *source, int line, const Descriptor *mask = nullptr,
284 bool back = false);
285void RTDECL(MaxlocReal8)(Descriptor &, const Descriptor &, int kind,
286 const char *source, int line, const Descriptor *mask = nullptr,
287 bool back = false);
288void RTDECL(MaxlocReal10)(Descriptor &, const Descriptor &, int kind,
289 const char *source, int line, const Descriptor *mask = nullptr,
290 bool back = false);
291void RTDECL(MaxlocReal16)(Descriptor &, const Descriptor &, int kind,
292 const char *source, int line, const Descriptor *mask = nullptr,
293 bool back = false);
294void RTDECL(MaxlocDim)(Descriptor &, const Descriptor &x, int kind, int dim,
295 const char *source, int line, const Descriptor *mask = nullptr,
296 bool back = false);
297void RTDECL(MinlocCharacter)(Descriptor &, const Descriptor &, int kind,
298 const char *source, int line, const Descriptor *mask = nullptr,
299 bool back = false);
300void RTDECL(MinlocInteger1)(Descriptor &, const Descriptor &, int kind,
301 const char *source, int line, const Descriptor *mask = nullptr,
302 bool back = false);
303void RTDECL(MinlocInteger2)(Descriptor &, const Descriptor &, int kind,
304 const char *source, int line, const Descriptor *mask = nullptr,
305 bool back = false);
306void RTDECL(MinlocInteger4)(Descriptor &, const Descriptor &, int kind,
307 const char *source, int line, const Descriptor *mask = nullptr,
308 bool back = false);
309void RTDECL(MinlocInteger8)(Descriptor &, const Descriptor &, int kind,
310 const char *source, int line, const Descriptor *mask = nullptr,
311 bool back = false);
312void RTDECL(MinlocInteger16)(Descriptor &, const Descriptor &, int kind,
313 const char *source, int line, const Descriptor *mask = nullptr,
314 bool back = false);
315void RTDECL(MinlocUnsigned1)(Descriptor &, const Descriptor &, int kind,
316 const char *source, int line, const Descriptor *mask = nullptr,
317 bool back = false);
318void RTDECL(MinlocUnsigned2)(Descriptor &, const Descriptor &, int kind,
319 const char *source, int line, const Descriptor *mask = nullptr,
320 bool back = false);
321void RTDECL(MinlocUnsigned4)(Descriptor &, const Descriptor &, int kind,
322 const char *source, int line, const Descriptor *mask = nullptr,
323 bool back = false);
324void RTDECL(MinlocUnsigned8)(Descriptor &, const Descriptor &, int kind,
325 const char *source, int line, const Descriptor *mask = nullptr,
326 bool back = false);
327void RTDECL(MinlocUnsigned16)(Descriptor &, const Descriptor &, int kind,
328 const char *source, int line, const Descriptor *mask = nullptr,
329 bool back = false);
330void RTDECL(MinlocReal4)(Descriptor &, const Descriptor &, int kind,
331 const char *source, int line, const Descriptor *mask = nullptr,
332 bool back = false);
333void RTDECL(MinlocReal8)(Descriptor &, const Descriptor &, int kind,
334 const char *source, int line, const Descriptor *mask = nullptr,
335 bool back = false);
336void RTDECL(MinlocReal10)(Descriptor &, const Descriptor &, int kind,
337 const char *source, int line, const Descriptor *mask = nullptr,
338 bool back = false);
339void RTDECL(MinlocReal16)(Descriptor &, const Descriptor &, int kind,
340 const char *source, int line, const Descriptor *mask = nullptr,
341 bool back = false);
342void RTDECL(MinlocDim)(Descriptor &, const Descriptor &x, int kind, int dim,
343 const char *source, int line, const Descriptor *mask = nullptr,
344 bool back = false);
345
346// MAXVAL and MINVAL
347std::int8_t RTDECL(MaxvalInteger1)(const Descriptor &, const char *source,
348 int line, int dim = 0, const Descriptor *mask = nullptr);
349std::int16_t RTDECL(MaxvalInteger2)(const Descriptor &, const char *source,
350 int line, int dim = 0, const Descriptor *mask = nullptr);
351std::int32_t RTDECL(MaxvalInteger4)(const Descriptor &, const char *source,
352 int line, int dim = 0, const Descriptor *mask = nullptr);
353std::int64_t RTDECL(MaxvalInteger8)(const Descriptor &, const char *source,
354 int line, int dim = 0, const Descriptor *mask = nullptr);
355#ifdef __SIZEOF_INT128__
356common::int128_t RTDECL(MaxvalInteger16)(const Descriptor &, const char *source,
357 int line, int dim = 0, const Descriptor *mask = nullptr);
358#endif
359std::uint8_t RTDECL(MaxvalUnsigned1)(const Descriptor &, const char *source,
360 int line, int dim = 0, const Descriptor *mask = nullptr);
361std::uint16_t RTDECL(MaxvalUnsigned2)(const Descriptor &, const char *source,
362 int line, int dim = 0, const Descriptor *mask = nullptr);
363std::uint32_t RTDECL(MaxvalUnsigned4)(const Descriptor &, const char *source,
364 int line, int dim = 0, const Descriptor *mask = nullptr);
365std::uint64_t RTDECL(MaxvalUnsigned8)(const Descriptor &, const char *source,
366 int line, int dim = 0, const Descriptor *mask = nullptr);
367#ifdef __SIZEOF_INT128__
368common::uint128_t RTDECL(MaxvalUnsigned16)(const Descriptor &,
369 const char *source, int line, int dim = 0,
370 const Descriptor *mask = nullptr);
371#endif
372float RTDECL(MaxvalReal2)(const Descriptor &, const char *source, int line,
373 int dim = 0, const Descriptor *mask = nullptr);
374float RTDECL(MaxvalReal3)(const Descriptor &, const char *source, int line,
375 int dim = 0, const Descriptor *mask = nullptr);
376float RTDECL(MaxvalReal4)(const Descriptor &, const char *source, int line,
377 int dim = 0, const Descriptor *mask = nullptr);
378double RTDECL(MaxvalReal8)(const Descriptor &, const char *source, int line,
379 int dim = 0, const Descriptor *mask = nullptr);
380#if HAS_FLOAT80
381CppTypeFor<TypeCategory::Real, 10> RTDECL(MaxvalReal10)(const Descriptor &,
382 const char *source, int line, int dim = 0,
383 const Descriptor *mask = nullptr);
384#endif
385#if HAS_LDBL128 || HAS_FLOAT128
386CppFloat128Type RTDECL(MaxvalReal16)(const Descriptor &, const char *source,
387 int line, int dim = 0, const Descriptor *mask = nullptr);
388#endif
389void RTDECL(MaxvalCharacter)(Descriptor &, const Descriptor &,
390 const char *source, int line, const Descriptor *mask = nullptr);
391
392std::int8_t RTDECL(MinvalInteger1)(const Descriptor &, const char *source,
393 int line, int dim = 0, const Descriptor *mask = nullptr);
394std::int16_t RTDECL(MinvalInteger2)(const Descriptor &, const char *source,
395 int line, int dim = 0, const Descriptor *mask = nullptr);
396std::int32_t RTDECL(MinvalInteger4)(const Descriptor &, const char *source,
397 int line, int dim = 0, const Descriptor *mask = nullptr);
398std::int64_t RTDECL(MinvalInteger8)(const Descriptor &, const char *source,
399 int line, int dim = 0, const Descriptor *mask = nullptr);
400#ifdef __SIZEOF_INT128__
401common::int128_t RTDECL(MinvalInteger16)(const Descriptor &, const char *source,
402 int line, int dim = 0, const Descriptor *mask = nullptr);
403#endif
404std::uint8_t RTDECL(MinvalUnsigned1)(const Descriptor &, const char *source,
405 int line, int dim = 0, const Descriptor *mask = nullptr);
406std::uint16_t RTDECL(MinvalUnsigned2)(const Descriptor &, const char *source,
407 int line, int dim = 0, const Descriptor *mask = nullptr);
408std::uint32_t RTDECL(MinvalUnsigned4)(const Descriptor &, const char *source,
409 int line, int dim = 0, const Descriptor *mask = nullptr);
410std::uint64_t RTDECL(MinvalUnsigned8)(const Descriptor &, const char *source,
411 int line, int dim = 0, const Descriptor *mask = nullptr);
412#ifdef __SIZEOF_INT128__
413common::uint128_t RTDECL(MinvalUnsigned16)(const Descriptor &,
414 const char *source, int line, int dim = 0,
415 const Descriptor *mask = nullptr);
416#endif
417float RTDECL(MinvalReal2)(const Descriptor &, const char *source, int line,
418 int dim = 0, const Descriptor *mask = nullptr);
419float RTDECL(MinvalReal3)(const Descriptor &, const char *source, int line,
420 int dim = 0, const Descriptor *mask = nullptr);
421float RTDECL(MinvalReal4)(const Descriptor &, const char *source, int line,
422 int dim = 0, const Descriptor *mask = nullptr);
423double RTDECL(MinvalReal8)(const Descriptor &, const char *source, int line,
424 int dim = 0, const Descriptor *mask = nullptr);
425#if HAS_FLOAT80
426CppTypeFor<TypeCategory::Real, 10> RTDECL(MinvalReal10)(const Descriptor &,
427 const char *source, int line, int dim = 0,
428 const Descriptor *mask = nullptr);
429#endif
430#if HAS_LDBL128 || HAS_FLOAT128
431CppFloat128Type RTDECL(MinvalReal16)(const Descriptor &, const char *source,
432 int line, int dim = 0, const Descriptor *mask = nullptr);
433#endif
434void RTDECL(MinvalCharacter)(Descriptor &, const Descriptor &,
435 const char *source, int line, const Descriptor *mask = nullptr);
436
437void RTDECL(MaxvalDim)(Descriptor &, const Descriptor &, int dim,
438 const char *source, int line, const Descriptor *mask = nullptr);
439void RTDECL(MinvalDim)(Descriptor &, const Descriptor &, int dim,
440 const char *source, int line, const Descriptor *mask = nullptr);
441
442// NORM2
443float RTDECL(Norm2_2)(
444 const Descriptor &, const char *source, int line, int dim = 0);
445float RTDECL(Norm2_3)(
446 const Descriptor &, const char *source, int line, int dim = 0);
447float RTDECL(Norm2_4)(
448 const Descriptor &, const char *source, int line, int dim = 0);
449double RTDECL(Norm2_8)(
450 const Descriptor &, const char *source, int line, int dim = 0);
451#if HAS_FLOAT80
452CppTypeFor<TypeCategory::Real, 10> RTDECL(Norm2_10)(
453 const Descriptor &, const char *source, int line, int dim = 0);
454#endif
455#if HAS_LDBL128 || HAS_FLOAT128
456CppFloat128Type RTDECL(Norm2_16)(
457 const Descriptor &, const char *source, int line, int dim = 0);
458void RTDECL(Norm2DimReal16)(
459 Descriptor &, const Descriptor &, int dim, const char *source, int line);
460#endif
461void RTDECL(Norm2Dim)(
462 Descriptor &, const Descriptor &, int dim, const char *source, int line);
463
464// ALL, ANY, COUNT, & PARITY logical reductions
465bool RTDECL(All)(const Descriptor &, const char *source, int line, int dim = 0);
466void RTDECL(AllDim)(Descriptor &result, const Descriptor &, int dim,
467 const char *source, int line);
468bool RTDECL(Any)(const Descriptor &, const char *source, int line, int dim = 0);
469void RTDECL(AnyDim)(Descriptor &result, const Descriptor &, int dim,
470 const char *source, int line);
471std::int64_t RTDECL(Count)(
472 const Descriptor &, const char *source, int line, int dim = 0);
473void RTDECL(CountDim)(Descriptor &result, const Descriptor &, int dim, int kind,
474 const char *source, int line);
475bool RTDECL(Parity)(
476 const Descriptor &, const char *source, int line, int dim = 0);
477void RTDECL(ParityDim)(Descriptor &result, const Descriptor &, int dim,
478 const char *source, int line);
479
480// DOT_PRODUCT
481std::int8_t RTDECL(DotProductInteger1)(const Descriptor &, const Descriptor &,
482 const char *source = nullptr, int line = 0);
483std::int16_t RTDECL(DotProductInteger2)(const Descriptor &, const Descriptor &,
484 const char *source = nullptr, int line = 0);
485std::int32_t RTDECL(DotProductInteger4)(const Descriptor &, const Descriptor &,
486 const char *source = nullptr, int line = 0);
487std::int64_t RTDECL(DotProductInteger8)(const Descriptor &, const Descriptor &,
488 const char *source = nullptr, int line = 0);
489#ifdef __SIZEOF_INT128__
490common::int128_t RTDECL(DotProductInteger16)(const Descriptor &,
491 const Descriptor &, const char *source = nullptr, int line = 0);
492#endif
493std::uint8_t RTDECL(DotProductUnsigned1)(const Descriptor &, const Descriptor &,
494 const char *source = nullptr, int line = 0);
495std::uint16_t RTDECL(DotProductUnsigned2)(const Descriptor &,
496 const Descriptor &, const char *source = nullptr, int line = 0);
497std::uint32_t RTDECL(DotProductUnsigned4)(const Descriptor &,
498 const Descriptor &, const char *source = nullptr, int line = 0);
499std::uint64_t RTDECL(DotProductUnsigned8)(const Descriptor &,
500 const Descriptor &, const char *source = nullptr, int line = 0);
501#ifdef __SIZEOF_INT128__
502common::uint128_t RTDECL(DotProductUnsigned16)(const Descriptor &,
503 const Descriptor &, const char *source = nullptr, int line = 0);
504#endif
505float RTDECL(DotProductReal2)(const Descriptor &, const Descriptor &,
506 const char *source = nullptr, int line = 0);
507float RTDECL(DotProductReal3)(const Descriptor &, const Descriptor &,
508 const char *source = nullptr, int line = 0);
509float RTDECL(DotProductReal4)(const Descriptor &, const Descriptor &,
510 const char *source = nullptr, int line = 0);
511double RTDECL(DotProductReal8)(const Descriptor &, const Descriptor &,
512 const char *source = nullptr, int line = 0);
513#if HAS_FLOAT80
514CppTypeFor<TypeCategory::Real, 10> RTDECL(DotProductReal10)(const Descriptor &,
515 const Descriptor &, const char *source = nullptr, int line = 0);
516#endif
517#if HAS_LDBL128 || HAS_FLOAT128
518CppFloat128Type RTDECL(DotProductReal16)(const Descriptor &, const Descriptor &,
519 const char *source = nullptr, int line = 0);
520#endif
521void RTDECL(CppDotProductComplex2)(CppTypeFor<TypeCategory::Complex, 4> &,
522 const Descriptor &, const Descriptor &, const char *source = nullptr,
523 int line = 0);
524void RTDECL(CppDotProductComplex3)(CppTypeFor<TypeCategory::Complex, 4> &,
525 const Descriptor &, const Descriptor &, const char *source = nullptr,
526 int line = 0);
527void RTDECL(CppDotProductComplex4)(CppTypeFor<TypeCategory::Complex, 4> &,
528 const Descriptor &, const Descriptor &, const char *source = nullptr,
529 int line = 0);
530void RTDECL(CppDotProductComplex8)(CppTypeFor<TypeCategory::Complex, 8> &,
531 const Descriptor &, const Descriptor &, const char *source = nullptr,
532 int line = 0);
533#if HAS_FLOAT80
534void RTDECL(CppDotProductComplex10)(CppTypeFor<TypeCategory::Complex, 10> &,
535 const Descriptor &, const Descriptor &, const char *source = nullptr,
536 int line = 0);
537#endif
538#if HAS_LDBL128 || HAS_FLOAT128
539void RTDECL(CppDotProductComplex16)(CppTypeFor<TypeCategory::Complex, 16> &,
540 const Descriptor &, const Descriptor &, const char *source = nullptr,
541 int line = 0);
542#endif
543bool RTDECL(DotProductLogical)(const Descriptor &, const Descriptor &,
544 const char *source = nullptr, int line = 0);
545
546} // extern "C"
547} // namespace Fortran::runtime
548#endif // FORTRAN_RUNTIME_REDUCTION_H_