| 1 |
//===-- runtime/reduce.cpp ------------------------------------------------===// |
| 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 |
// REDUCE() implementation |
| 10 |
|
| 11 |
#include "flang/Runtime/reduce.h" |
| 12 |
#include "reduction-templates.h" |
| 13 |
#include "terminator.h" |
| 14 |
#include "tools.h" |
| 15 |
#include "flang/Runtime/descriptor.h" |
| 16 |
|
| 17 |
namespace Fortran::runtime { |
| 18 |
|
| 19 |
template <typename T, bool isByValue> class ReduceAccumulator { |
| 20 |
public: |
| 21 |
using Operation = std::conditional_t<isByValue, ValueReductionOperation<T>, |
| 22 |
ReferenceReductionOperation<T>>; |
| 23 |
RT_API_ATTRS ReduceAccumulator(const Descriptor &array, Operation operation, |
| 24 |
const T *identity, Terminator &terminator) |
| 25 |
: array_{array}, operation_{operation}, identity_{identity}, |
| 26 |
terminator_{terminator} {} |
| 27 |
RT_API_ATTRS void Reinitialize() { result_.reset(); } |
| 28 |
template <typename A> |
| 29 |
RT_API_ATTRS bool AccumulateAt(const SubscriptValue at[]) { |
| 30 |
const auto *operand{array_.Element<A>(at)}; |
| 31 |
if (result_) { |
| 32 |
if constexpr (isByValue) { |
| 33 |
result_ = operation_(*result_, *operand); |
| 34 |
} else { |
| 35 |
result_ = operation_(&*result_, operand); |
| 36 |
} |
| 37 |
} else { |
| 38 |
result_ = *operand; |
| 39 |
} |
| 40 |
return true; |
| 41 |
} |
| 42 |
template <typename A> |
| 43 |
RT_API_ATTRS void GetResult(A *to, int /*zeroBasedDim*/ = -1) { |
| 44 |
if (result_) { |
| 45 |
*to = *result_; |
| 46 |
} else if (identity_) { |
| 47 |
*to = *identity_; |
| 48 |
} else { |
| 49 |
terminator_.Crash("REDUCE() without IDENTITY= has no result"); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
private: |
| 54 |
const Descriptor &array_; |
| 55 |
common::optional<T> result_; |
| 56 |
Operation operation_; |
| 57 |
const T *identity_{nullptr}; |
| 58 |
Terminator &terminator_; |
| 59 |
}; |
| 60 |
|
| 61 |
template <typename T, typename OP, bool hasLength> |
| 62 |
class BufferedReduceAccumulator { |
| 63 |
public: |
| 64 |
RT_API_ATTRS BufferedReduceAccumulator(const Descriptor &array, OP operation, |
| 65 |
const T *identity, Terminator &terminator) |
| 66 |
: array_{array}, operation_{operation}, identity_{identity}, |
| 67 |
terminator_{terminator} {} |
| 68 |
RT_API_ATTRS void Reinitialize() { activeTemp_ = -1; } |
| 69 |
template <typename A> |
| 70 |
RT_API_ATTRS bool AccumulateAt(const SubscriptValue at[]) { |
| 71 |
const auto *operand{array_.Element<A>(at)}; |
| 72 |
if (activeTemp_ >= 0) { |
| 73 |
if constexpr (hasLength) { |
| 74 |
operation_(&*temp_[1 - activeTemp_], length_, &*temp_[activeTemp_], |
| 75 |
operand, length_, length_); |
| 76 |
} else { |
| 77 |
operation_(&*temp_[1 - activeTemp_], &*temp_[activeTemp_], operand); |
| 78 |
} |
| 79 |
activeTemp_ = 1 - activeTemp_; |
| 80 |
} else { |
| 81 |
activeTemp_ = 0; |
| 82 |
std::memcpy(&*temp_[activeTemp_], operand, elementBytes_); |
| 83 |
} |
| 84 |
return true; |
| 85 |
} |
| 86 |
template <typename A> |
| 87 |
RT_API_ATTRS void GetResult(A *to, int /*zeroBasedDim*/ = -1) { |
| 88 |
if (activeTemp_ >= 0) { |
| 89 |
std::memcpy(to, &*temp_[activeTemp_], elementBytes_); |
| 90 |
} else if (identity_) { |
| 91 |
std::memcpy(to, identity_, elementBytes_); |
| 92 |
} else { |
| 93 |
terminator_.Crash("REDUCE() without IDENTITY= has no result"); |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
private: |
| 98 |
const Descriptor &array_; |
| 99 |
OP operation_; |
| 100 |
const T *identity_{nullptr}; |
| 101 |
Terminator &terminator_; |
| 102 |
std::size_t elementBytes_{array_.ElementBytes()}; |
| 103 |
OwningPtr<T> temp_[2]{SizedNew<T>{terminator_}(elementBytes_), |
| 104 |
SizedNew<T>{terminator_}(elementBytes_)}; |
| 105 |
int activeTemp_{-1}; |
| 106 |
std::size_t length_{elementBytes_ / sizeof(T)}; |
| 107 |
}; |
| 108 |
|
| 109 |
extern "C" { |
| 110 |
RT_EXT_API_GROUP_BEGIN |
| 111 |
|
| 112 |
std::int8_t RTDEF(ReduceInteger1Ref)(const Descriptor &array, |
| 113 |
ReferenceReductionOperation<std::int8_t> operation, const char *source, |
| 114 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 115 |
bool ordered) { |
| 116 |
Terminator terminator{source, line}; |
| 117 |
return GetTotalReduction<TypeCategory::Integer, 1>(array, source, line, dim, |
| 118 |
mask, |
| 119 |
ReduceAccumulator<std::int8_t, false>{ |
| 120 |
array, operation, identity, terminator}, |
| 121 |
"REDUCE"); |
| 122 |
} |
| 123 |
std::int8_t RTDEF(ReduceInteger1Value)(const Descriptor &array, |
| 124 |
ValueReductionOperation<std::int8_t> operation, const char *source, |
| 125 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 126 |
bool ordered) { |
| 127 |
Terminator terminator{source, line}; |
| 128 |
return GetTotalReduction<TypeCategory::Integer, 1>(array, source, line, dim, |
| 129 |
mask, |
| 130 |
ReduceAccumulator<std::int8_t, true>{ |
| 131 |
array, operation, identity, terminator}, |
| 132 |
"REDUCE"); |
| 133 |
} |
| 134 |
void RTDEF(ReduceInteger1DimRef)(Descriptor &result, const Descriptor &array, |
| 135 |
ReferenceReductionOperation<std::int8_t> operation, const char *source, |
| 136 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 137 |
bool ordered) { |
| 138 |
Terminator terminator{source, line}; |
| 139 |
using Accumulator = ReduceAccumulator<std::int8_t, false>; |
| 140 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 141 |
PartialReduction<Accumulator, TypeCategory::Integer, 1>(result, array, |
| 142 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 143 |
} |
| 144 |
void RTDEF(ReduceInteger1DimValue)(Descriptor &result, const Descriptor &array, |
| 145 |
ValueReductionOperation<std::int8_t> operation, const char *source, |
| 146 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 147 |
bool ordered) { |
| 148 |
Terminator terminator{source, line}; |
| 149 |
using Accumulator = ReduceAccumulator<std::int8_t, true>; |
| 150 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 151 |
PartialReduction<Accumulator, TypeCategory::Integer, 1>(result, array, |
| 152 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 153 |
} |
| 154 |
std::int16_t RTDEF(ReduceInteger2Ref)(const Descriptor &array, |
| 155 |
ReferenceReductionOperation<std::int16_t> operation, const char *source, |
| 156 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 157 |
bool ordered) { |
| 158 |
Terminator terminator{source, line}; |
| 159 |
return GetTotalReduction<TypeCategory::Integer, 2>(array, source, line, dim, |
| 160 |
mask, |
| 161 |
ReduceAccumulator<std::int16_t, false>{ |
| 162 |
array, operation, identity, terminator}, |
| 163 |
"REDUCE"); |
| 164 |
} |
| 165 |
std::int16_t RTDEF(ReduceInteger2Value)(const Descriptor &array, |
| 166 |
ValueReductionOperation<std::int16_t> operation, const char *source, |
| 167 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 168 |
bool ordered) { |
| 169 |
Terminator terminator{source, line}; |
| 170 |
return GetTotalReduction<TypeCategory::Integer, 2>(array, source, line, dim, |
| 171 |
mask, |
| 172 |
ReduceAccumulator<std::int16_t, true>{ |
| 173 |
array, operation, identity, terminator}, |
| 174 |
"REDUCE"); |
| 175 |
} |
| 176 |
void RTDEF(ReduceInteger2DimRef)(Descriptor &result, const Descriptor &array, |
| 177 |
ReferenceReductionOperation<std::int16_t> operation, const char *source, |
| 178 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 179 |
bool ordered) { |
| 180 |
Terminator terminator{source, line}; |
| 181 |
using Accumulator = ReduceAccumulator<std::int16_t, false>; |
| 182 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 183 |
PartialReduction<Accumulator, TypeCategory::Integer, 2>(result, array, |
| 184 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 185 |
} |
| 186 |
void RTDEF(ReduceInteger2DimValue)(Descriptor &result, const Descriptor &array, |
| 187 |
ValueReductionOperation<std::int16_t> operation, const char *source, |
| 188 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 189 |
bool ordered) { |
| 190 |
Terminator terminator{source, line}; |
| 191 |
using Accumulator = ReduceAccumulator<std::int16_t, true>; |
| 192 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 193 |
PartialReduction<Accumulator, TypeCategory::Integer, 2>(result, array, |
| 194 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 195 |
} |
| 196 |
std::int32_t RTDEF(ReduceInteger4Ref)(const Descriptor &array, |
| 197 |
ReferenceReductionOperation<std::int32_t> operation, const char *source, |
| 198 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 199 |
bool ordered) { |
| 200 |
Terminator terminator{source, line}; |
| 201 |
return GetTotalReduction<TypeCategory::Integer, 4>(array, source, line, dim, |
| 202 |
mask, |
| 203 |
ReduceAccumulator<std::int32_t, false>{ |
| 204 |
array, operation, identity, terminator}, |
| 205 |
"REDUCE"); |
| 206 |
} |
| 207 |
std::int32_t RTDEF(ReduceInteger4Value)(const Descriptor &array, |
| 208 |
ValueReductionOperation<std::int32_t> operation, const char *source, |
| 209 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 210 |
bool ordered) { |
| 211 |
Terminator terminator{source, line}; |
| 212 |
return GetTotalReduction<TypeCategory::Integer, 4>(array, source, line, dim, |
| 213 |
mask, |
| 214 |
ReduceAccumulator<std::int32_t, true>{ |
| 215 |
array, operation, identity, terminator}, |
| 216 |
"REDUCE"); |
| 217 |
} |
| 218 |
void RTDEF(ReduceInteger4DimRef)(Descriptor &result, const Descriptor &array, |
| 219 |
ReferenceReductionOperation<std::int32_t> operation, const char *source, |
| 220 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 221 |
bool ordered) { |
| 222 |
Terminator terminator{source, line}; |
| 223 |
using Accumulator = ReduceAccumulator<std::int32_t, false>; |
| 224 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 225 |
PartialReduction<Accumulator, TypeCategory::Integer, 4>(result, array, |
| 226 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 227 |
} |
| 228 |
void RTDEF(ReduceInteger4DimValue)(Descriptor &result, const Descriptor &array, |
| 229 |
ValueReductionOperation<std::int32_t> operation, const char *source, |
| 230 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 231 |
bool ordered) { |
| 232 |
Terminator terminator{source, line}; |
| 233 |
using Accumulator = ReduceAccumulator<std::int32_t, true>; |
| 234 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 235 |
PartialReduction<Accumulator, TypeCategory::Integer, 4>(result, array, |
| 236 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 237 |
} |
| 238 |
std::int64_t RTDEF(ReduceInteger8Ref)(const Descriptor &array, |
| 239 |
ReferenceReductionOperation<std::int64_t> operation, const char *source, |
| 240 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 241 |
bool ordered) { |
| 242 |
Terminator terminator{source, line}; |
| 243 |
return GetTotalReduction<TypeCategory::Integer, 8>(array, source, line, dim, |
| 244 |
mask, |
| 245 |
ReduceAccumulator<std::int64_t, false>{ |
| 246 |
array, operation, identity, terminator}, |
| 247 |
"REDUCE"); |
| 248 |
} |
| 249 |
std::int64_t RTDEF(ReduceInteger8Value)(const Descriptor &array, |
| 250 |
ValueReductionOperation<std::int64_t> operation, const char *source, |
| 251 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 252 |
bool ordered) { |
| 253 |
Terminator terminator{source, line}; |
| 254 |
return GetTotalReduction<TypeCategory::Integer, 8>(array, source, line, dim, |
| 255 |
mask, |
| 256 |
ReduceAccumulator<std::int64_t, true>{ |
| 257 |
array, operation, identity, terminator}, |
| 258 |
"REDUCE"); |
| 259 |
} |
| 260 |
void RTDEF(ReduceInteger8DimRef)(Descriptor &result, const Descriptor &array, |
| 261 |
ReferenceReductionOperation<std::int64_t> operation, const char *source, |
| 262 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 263 |
bool ordered) { |
| 264 |
Terminator terminator{source, line}; |
| 265 |
using Accumulator = ReduceAccumulator<std::int64_t, false>; |
| 266 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 267 |
PartialReduction<Accumulator, TypeCategory::Integer, 8>(result, array, |
| 268 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 269 |
} |
| 270 |
void RTDEF(ReduceInteger8DimValue)(Descriptor &result, const Descriptor &array, |
| 271 |
ValueReductionOperation<std::int64_t> operation, const char *source, |
| 272 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 273 |
bool ordered) { |
| 274 |
Terminator terminator{source, line}; |
| 275 |
using Accumulator = ReduceAccumulator<std::int64_t, true>; |
| 276 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 277 |
PartialReduction<Accumulator, TypeCategory::Integer, 8>(result, array, |
| 278 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 279 |
} |
| 280 |
#ifdef __SIZEOF_INT128__ |
| 281 |
common::int128_t RTDEF(ReduceInteger16Ref)(const Descriptor &array, |
| 282 |
ReferenceReductionOperation<common::int128_t> operation, const char *source, |
| 283 |
int line, int dim, const Descriptor *mask, const common::int128_t *identity, |
| 284 |
bool ordered) { |
| 285 |
Terminator terminator{source, line}; |
| 286 |
return GetTotalReduction<TypeCategory::Integer, 16>(array, source, line, dim, |
| 287 |
mask, |
| 288 |
ReduceAccumulator<common::int128_t, false>{ |
| 289 |
array, operation, identity, terminator}, |
| 290 |
"REDUCE"); |
| 291 |
} |
| 292 |
common::int128_t RTDEF(ReduceInteger16Value)(const Descriptor &array, |
| 293 |
ValueReductionOperation<common::int128_t> operation, const char *source, |
| 294 |
int line, int dim, const Descriptor *mask, const common::int128_t *identity, |
| 295 |
bool ordered) { |
| 296 |
Terminator terminator{source, line}; |
| 297 |
return GetTotalReduction<TypeCategory::Integer, 16>(array, source, line, dim, |
| 298 |
mask, |
| 299 |
ReduceAccumulator<common::int128_t, true>{ |
| 300 |
array, operation, identity, terminator}, |
| 301 |
"REDUCE"); |
| 302 |
} |
| 303 |
void RTDEF(ReduceInteger16DimRef)(Descriptor &result, const Descriptor &array, |
| 304 |
ReferenceReductionOperation<common::int128_t> operation, const char *source, |
| 305 |
int line, int dim, const Descriptor *mask, const common::int128_t *identity, |
| 306 |
bool ordered) { |
| 307 |
Terminator terminator{source, line}; |
| 308 |
using Accumulator = ReduceAccumulator<common::int128_t, false>; |
| 309 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 310 |
PartialReduction<Accumulator, TypeCategory::Integer, 16>(result, array, |
| 311 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 312 |
} |
| 313 |
void RTDEF(ReduceInteger16DimValue)(Descriptor &result, const Descriptor &array, |
| 314 |
ValueReductionOperation<common::int128_t> operation, const char *source, |
| 315 |
int line, int dim, const Descriptor *mask, const common::int128_t *identity, |
| 316 |
bool ordered) { |
| 317 |
Terminator terminator{source, line}; |
| 318 |
using Accumulator = ReduceAccumulator<common::int128_t, true>; |
| 319 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 320 |
PartialReduction<Accumulator, TypeCategory::Integer, 16>(result, array, |
| 321 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 322 |
} |
| 323 |
#endif |
| 324 |
|
| 325 |
// TODO: real/complex(2 & 3) |
| 326 |
float RTDEF(ReduceReal4Ref)(const Descriptor &array, |
| 327 |
ReferenceReductionOperation<float> operation, const char *source, int line, |
| 328 |
int dim, const Descriptor *mask, const float *identity, bool ordered) { |
| 329 |
Terminator terminator{source, line}; |
| 330 |
return GetTotalReduction<TypeCategory::Real, 4>(array, source, line, dim, |
| 331 |
mask, |
| 332 |
ReduceAccumulator<float, false>{array, operation, identity, terminator}, |
| 333 |
"REDUCE"); |
| 334 |
} |
| 335 |
float RTDEF(ReduceReal4Value)(const Descriptor &array, |
| 336 |
ValueReductionOperation<float> operation, const char *source, int line, |
| 337 |
int dim, const Descriptor *mask, const float *identity, bool ordered) { |
| 338 |
Terminator terminator{source, line}; |
| 339 |
return GetTotalReduction<TypeCategory::Real, 4>(array, source, line, dim, |
| 340 |
mask, |
| 341 |
ReduceAccumulator<float, true>{array, operation, identity, terminator}, |
| 342 |
"REDUCE"); |
| 343 |
} |
| 344 |
void RTDEF(ReduceReal4DimRef)(Descriptor &result, const Descriptor &array, |
| 345 |
ReferenceReductionOperation<float> operation, const char *source, int line, |
| 346 |
int dim, const Descriptor *mask, const float *identity, bool ordered) { |
| 347 |
Terminator terminator{source, line}; |
| 348 |
using Accumulator = ReduceAccumulator<float, false>; |
| 349 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 350 |
PartialReduction<Accumulator, TypeCategory::Real, 4>(result, array, |
| 351 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 352 |
} |
| 353 |
void RTDEF(ReduceReal4DimValue)(Descriptor &result, const Descriptor &array, |
| 354 |
ValueReductionOperation<float> operation, const char *source, int line, |
| 355 |
int dim, const Descriptor *mask, const float *identity, bool ordered) { |
| 356 |
Terminator terminator{source, line}; |
| 357 |
using Accumulator = ReduceAccumulator<float, true>; |
| 358 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 359 |
PartialReduction<Accumulator, TypeCategory::Real, 4>(result, array, |
| 360 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 361 |
} |
| 362 |
double RTDEF(ReduceReal8Ref)(const Descriptor &array, |
| 363 |
ReferenceReductionOperation<double> operation, const char *source, int line, |
| 364 |
int dim, const Descriptor *mask, const double *identity, bool ordered) { |
| 365 |
Terminator terminator{source, line}; |
| 366 |
return GetTotalReduction<TypeCategory::Real, 8>(array, source, line, dim, |
| 367 |
mask, |
| 368 |
ReduceAccumulator<double, false>{array, operation, identity, terminator}, |
| 369 |
"REDUCE"); |
| 370 |
} |
| 371 |
double RTDEF(ReduceReal8Value)(const Descriptor &array, |
| 372 |
ValueReductionOperation<double> operation, const char *source, int line, |
| 373 |
int dim, const Descriptor *mask, const double *identity, bool ordered) { |
| 374 |
Terminator terminator{source, line}; |
| 375 |
return GetTotalReduction<TypeCategory::Real, 8>(array, source, line, dim, |
| 376 |
mask, |
| 377 |
ReduceAccumulator<double, true>{array, operation, identity, terminator}, |
| 378 |
"REDUCE"); |
| 379 |
} |
| 380 |
void RTDEF(ReduceReal8DimRef)(Descriptor &result, const Descriptor &array, |
| 381 |
ReferenceReductionOperation<double> operation, const char *source, int line, |
| 382 |
int dim, const Descriptor *mask, const double *identity, bool ordered) { |
| 383 |
Terminator terminator{source, line}; |
| 384 |
using Accumulator = ReduceAccumulator<double, false>; |
| 385 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 386 |
PartialReduction<Accumulator, TypeCategory::Real, 8>(result, array, |
| 387 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 388 |
} |
| 389 |
void RTDEF(ReduceReal8DimValue)(Descriptor &result, const Descriptor &array, |
| 390 |
ValueReductionOperation<double> operation, const char *source, int line, |
| 391 |
int dim, const Descriptor *mask, const double *identity, bool ordered) { |
| 392 |
Terminator terminator{source, line}; |
| 393 |
using Accumulator = ReduceAccumulator<double, true>; |
| 394 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 395 |
PartialReduction<Accumulator, TypeCategory::Real, 8>(result, array, |
| 396 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 397 |
} |
| 398 |
#if LDBL_MANT_DIG == 64 |
| 399 |
long double RTDEF(ReduceReal10Ref)(const Descriptor &array, |
| 400 |
ReferenceReductionOperation<long double> operation, const char *source, |
| 401 |
int line, int dim, const Descriptor *mask, const long double *identity, |
| 402 |
bool ordered) { |
| 403 |
Terminator terminator{source, line}; |
| 404 |
return GetTotalReduction<TypeCategory::Real, 10>(array, source, line, dim, |
| 405 |
mask, |
| 406 |
ReduceAccumulator<long double, false>{ |
| 407 |
array, operation, identity, terminator}, |
| 408 |
"REDUCE"); |
| 409 |
} |
| 410 |
long double RTDEF(ReduceReal10Value)(const Descriptor &array, |
| 411 |
ValueReductionOperation<long double> operation, const char *source, |
| 412 |
int line, int dim, const Descriptor *mask, const long double *identity, |
| 413 |
bool ordered) { |
| 414 |
Terminator terminator{source, line}; |
| 415 |
return GetTotalReduction<TypeCategory::Real, 10>(array, source, line, dim, |
| 416 |
mask, |
| 417 |
ReduceAccumulator<long double, true>{ |
| 418 |
array, operation, identity, terminator}, |
| 419 |
"REDUCE"); |
| 420 |
} |
| 421 |
void RTDEF(ReduceReal10DimRef)(Descriptor &result, const Descriptor &array, |
| 422 |
ReferenceReductionOperation<long double> operation, const char *source, |
| 423 |
int line, int dim, const Descriptor *mask, const long double *identity, |
| 424 |
bool ordered) { |
| 425 |
Terminator terminator{source, line}; |
| 426 |
using Accumulator = ReduceAccumulator<long double, false>; |
| 427 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 428 |
PartialReduction<Accumulator, TypeCategory::Real, 10>(result, array, |
| 429 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 430 |
} |
| 431 |
void RTDEF(ReduceReal10DimValue)(Descriptor &result, const Descriptor &array, |
| 432 |
ValueReductionOperation<long double> operation, const char *source, |
| 433 |
int line, int dim, const Descriptor *mask, const long double *identity, |
| 434 |
bool ordered) { |
| 435 |
Terminator terminator{source, line}; |
| 436 |
using Accumulator = ReduceAccumulator<long double, true>; |
| 437 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 438 |
PartialReduction<Accumulator, TypeCategory::Real, 10>(result, array, |
| 439 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 440 |
} |
| 441 |
#endif |
| 442 |
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128 |
| 443 |
CppFloat128Type RTDEF(ReduceReal16Ref)(const Descriptor &array, |
| 444 |
ReferenceReductionOperation<CppFloat128Type> operation, const char *source, |
| 445 |
int line, int dim, const Descriptor *mask, const CppFloat128Type *identity, |
| 446 |
bool ordered) { |
| 447 |
Terminator terminator{source, line}; |
| 448 |
return GetTotalReduction<TypeCategory::Real, 16>(array, source, line, dim, |
| 449 |
mask, |
| 450 |
ReduceAccumulator<CppFloat128Type, false>{ |
| 451 |
array, operation, identity, terminator}, |
| 452 |
"REDUCE"); |
| 453 |
} |
| 454 |
CppFloat128Type RTDEF(ReduceReal16Value)(const Descriptor &array, |
| 455 |
ValueReductionOperation<CppFloat128Type> operation, const char *source, |
| 456 |
int line, int dim, const Descriptor *mask, const CppFloat128Type *identity, |
| 457 |
bool ordered) { |
| 458 |
Terminator terminator{source, line}; |
| 459 |
return GetTotalReduction<TypeCategory::Real, 16>(array, source, line, dim, |
| 460 |
mask, |
| 461 |
ReduceAccumulator<CppFloat128Type, true>{ |
| 462 |
array, operation, identity, terminator}, |
| 463 |
"REDUCE"); |
| 464 |
} |
| 465 |
void RTDEF(ReduceReal16DimRef)(Descriptor &result, const Descriptor &array, |
| 466 |
ReferenceReductionOperation<CppFloat128Type> operation, const char *source, |
| 467 |
int line, int dim, const Descriptor *mask, const CppFloat128Type *identity, |
| 468 |
bool ordered) { |
| 469 |
Terminator terminator{source, line}; |
| 470 |
using Accumulator = ReduceAccumulator<CppFloat128Type, false>; |
| 471 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 472 |
PartialReduction<Accumulator, TypeCategory::Real, 16>(result, array, |
| 473 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 474 |
} |
| 475 |
void RTDEF(ReduceReal16DimValue)(Descriptor &result, const Descriptor &array, |
| 476 |
ValueReductionOperation<CppFloat128Type> operation, const char *source, |
| 477 |
int line, int dim, const Descriptor *mask, const CppFloat128Type *identity, |
| 478 |
bool ordered) { |
| 479 |
Terminator terminator{source, line}; |
| 480 |
using Accumulator = ReduceAccumulator<CppFloat128Type, true>; |
| 481 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 482 |
PartialReduction<Accumulator, TypeCategory::Real, 16>(result, array, |
| 483 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 484 |
} |
| 485 |
#endif |
| 486 |
|
| 487 |
void RTDEF(CppReduceComplex4Ref)(std::complex<float> &result, |
| 488 |
const Descriptor &array, |
| 489 |
ReferenceReductionOperation<std::complex<float>> operation, |
| 490 |
const char *source, int line, int dim, const Descriptor *mask, |
| 491 |
const std::complex<float> *identity, bool ordered) { |
| 492 |
Terminator terminator{source, line}; |
| 493 |
result = GetTotalReduction<TypeCategory::Complex, 4>(array, source, line, dim, |
| 494 |
mask, |
| 495 |
ReduceAccumulator<std::complex<float>, false>{ |
| 496 |
array, operation, identity, terminator}, |
| 497 |
"REDUCE"); |
| 498 |
} |
| 499 |
void RTDEF(CppReduceComplex4Value)(std::complex<float> &result, |
| 500 |
const Descriptor &array, |
| 501 |
ValueReductionOperation<std::complex<float>> operation, const char *source, |
| 502 |
int line, int dim, const Descriptor *mask, |
| 503 |
const std::complex<float> *identity, bool ordered) { |
| 504 |
Terminator terminator{source, line}; |
| 505 |
result = GetTotalReduction<TypeCategory::Complex, 4>(array, source, line, dim, |
| 506 |
mask, |
| 507 |
ReduceAccumulator<std::complex<float>, true>{ |
| 508 |
array, operation, identity, terminator}, |
| 509 |
"REDUCE"); |
| 510 |
} |
| 511 |
void RTDEF(CppReduceComplex4DimRef)(Descriptor &result, const Descriptor &array, |
| 512 |
ReferenceReductionOperation<std::complex<float>> operation, |
| 513 |
const char *source, int line, int dim, const Descriptor *mask, |
| 514 |
const std::complex<float> *identity, bool ordered) { |
| 515 |
Terminator terminator{source, line}; |
| 516 |
using Accumulator = ReduceAccumulator<std::complex<float>, false>; |
| 517 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 518 |
PartialReduction<Accumulator, TypeCategory::Complex, 4>(result, array, |
| 519 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 520 |
} |
| 521 |
void RTDEF(CppReduceComplex4DimValue)(Descriptor &result, |
| 522 |
const Descriptor &array, |
| 523 |
ValueReductionOperation<std::complex<float>> operation, const char *source, |
| 524 |
int line, int dim, const Descriptor *mask, |
| 525 |
const std::complex<float> *identity, bool ordered) { |
| 526 |
Terminator terminator{source, line}; |
| 527 |
using Accumulator = ReduceAccumulator<std::complex<float>, true>; |
| 528 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 529 |
PartialReduction<Accumulator, TypeCategory::Complex, 4>(result, array, |
| 530 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 531 |
} |
| 532 |
void RTDEF(CppReduceComplex8Ref)(std::complex<double> &result, |
| 533 |
const Descriptor &array, |
| 534 |
ReferenceReductionOperation<std::complex<double>> operation, |
| 535 |
const char *source, int line, int dim, const Descriptor *mask, |
| 536 |
const std::complex<double> *identity, bool ordered) { |
| 537 |
Terminator terminator{source, line}; |
| 538 |
result = GetTotalReduction<TypeCategory::Complex, 8>(array, source, line, dim, |
| 539 |
mask, |
| 540 |
ReduceAccumulator<std::complex<double>, false>{ |
| 541 |
array, operation, identity, terminator}, |
| 542 |
"REDUCE"); |
| 543 |
} |
| 544 |
void RTDEF(CppReduceComplex8Value)(std::complex<double> &result, |
| 545 |
const Descriptor &array, |
| 546 |
ValueReductionOperation<std::complex<double>> operation, const char *source, |
| 547 |
int line, int dim, const Descriptor *mask, |
| 548 |
const std::complex<double> *identity, bool ordered) { |
| 549 |
Terminator terminator{source, line}; |
| 550 |
result = GetTotalReduction<TypeCategory::Complex, 8>(array, source, line, dim, |
| 551 |
mask, |
| 552 |
ReduceAccumulator<std::complex<double>, true>{ |
| 553 |
array, operation, identity, terminator}, |
| 554 |
"REDUCE"); |
| 555 |
} |
| 556 |
void RTDEF(CppReduceComplex8DimRef)(Descriptor &result, const Descriptor &array, |
| 557 |
ReferenceReductionOperation<std::complex<double>> operation, |
| 558 |
const char *source, int line, int dim, const Descriptor *mask, |
| 559 |
const std::complex<double> *identity, bool ordered) { |
| 560 |
Terminator terminator{source, line}; |
| 561 |
using Accumulator = ReduceAccumulator<std::complex<double>, false>; |
| 562 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 563 |
PartialReduction<Accumulator, TypeCategory::Complex, 8>(result, array, |
| 564 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 565 |
} |
| 566 |
void RTDEF(CppReduceComplex8DimValue)(Descriptor &result, |
| 567 |
const Descriptor &array, |
| 568 |
ValueReductionOperation<std::complex<double>> operation, const char *source, |
| 569 |
int line, int dim, const Descriptor *mask, |
| 570 |
const std::complex<double> *identity, bool ordered) { |
| 571 |
Terminator terminator{source, line}; |
| 572 |
using Accumulator = ReduceAccumulator<std::complex<double>, true>; |
| 573 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 574 |
PartialReduction<Accumulator, TypeCategory::Complex, 8>(result, array, |
| 575 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 576 |
} |
| 577 |
#if LDBL_MANT_DIG == 64 |
| 578 |
void RTDEF(CppReduceComplex10Ref)(std::complex<long double> &result, |
| 579 |
const Descriptor &array, |
| 580 |
ReferenceReductionOperation<std::complex<long double>> operation, |
| 581 |
const char *source, int line, int dim, const Descriptor *mask, |
| 582 |
const std::complex<long double> *identity, bool ordered) { |
| 583 |
Terminator terminator{source, line}; |
| 584 |
result = GetTotalReduction<TypeCategory::Complex, 10>(array, source, line, |
| 585 |
dim, mask, |
| 586 |
ReduceAccumulator<std::complex<long double>, false>{ |
| 587 |
array, operation, identity, terminator}, |
| 588 |
"REDUCE"); |
| 589 |
} |
| 590 |
void RTDEF(CppReduceComplex10Value)(std::complex<long double> &result, |
| 591 |
const Descriptor &array, |
| 592 |
ValueReductionOperation<std::complex<long double>> operation, |
| 593 |
const char *source, int line, int dim, const Descriptor *mask, |
| 594 |
const std::complex<long double> *identity, bool ordered) { |
| 595 |
Terminator terminator{source, line}; |
| 596 |
result = GetTotalReduction<TypeCategory::Complex, 10>(array, source, line, |
| 597 |
dim, mask, |
| 598 |
ReduceAccumulator<std::complex<long double>, true>{ |
| 599 |
array, operation, identity, terminator}, |
| 600 |
"REDUCE"); |
| 601 |
} |
| 602 |
void RTDEF(CppReduceComplex10DimRef)(Descriptor &result, |
| 603 |
const Descriptor &array, |
| 604 |
ReferenceReductionOperation<std::complex<long double>> operation, |
| 605 |
const char *source, int line, int dim, const Descriptor *mask, |
| 606 |
const std::complex<long double> *identity, bool ordered) { |
| 607 |
Terminator terminator{source, line}; |
| 608 |
using Accumulator = ReduceAccumulator<std::complex<long double>, false>; |
| 609 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 610 |
PartialReduction<Accumulator, TypeCategory::Complex, 10>(result, array, |
| 611 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 612 |
} |
| 613 |
void RTDEF(CppReduceComplex10DimValue)(Descriptor &result, |
| 614 |
const Descriptor &array, |
| 615 |
ValueReductionOperation<std::complex<long double>> operation, |
| 616 |
const char *source, int line, int dim, const Descriptor *mask, |
| 617 |
const std::complex<long double> *identity, bool ordered) { |
| 618 |
Terminator terminator{source, line}; |
| 619 |
using Accumulator = ReduceAccumulator<std::complex<long double>, true>; |
| 620 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 621 |
PartialReduction<Accumulator, TypeCategory::Complex, 10>(result, array, |
| 622 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 623 |
} |
| 624 |
#endif |
| 625 |
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128 |
| 626 |
void RTDEF(CppReduceComplex16Ref)(std::complex<CppFloat128Type> &result, |
| 627 |
const Descriptor &array, |
| 628 |
ReferenceReductionOperation<std::complex<CppFloat128Type>> operation, |
| 629 |
const char *source, int line, int dim, const Descriptor *mask, |
| 630 |
const std::complex<CppFloat128Type> *identity, bool ordered) { |
| 631 |
Terminator terminator{source, line}; |
| 632 |
result = GetTotalReduction<TypeCategory::Complex, 16>(array, source, line, |
| 633 |
dim, mask, |
| 634 |
ReduceAccumulator<std::complex<CppFloat128Type>, false>{ |
| 635 |
array, operation, identity, terminator}, |
| 636 |
"REDUCE"); |
| 637 |
} |
| 638 |
void RTDEF(CppReduceComplex16Value)(std::complex<CppFloat128Type> &result, |
| 639 |
const Descriptor &array, |
| 640 |
ValueReductionOperation<std::complex<CppFloat128Type>> operation, |
| 641 |
const char *source, int line, int dim, const Descriptor *mask, |
| 642 |
const std::complex<CppFloat128Type> *identity, bool ordered) { |
| 643 |
Terminator terminator{source, line}; |
| 644 |
result = GetTotalReduction<TypeCategory::Complex, 16>(array, source, line, |
| 645 |
dim, mask, |
| 646 |
ReduceAccumulator<std::complex<CppFloat128Type>, true>{ |
| 647 |
array, operation, identity, terminator}, |
| 648 |
"REDUCE"); |
| 649 |
} |
| 650 |
void RTDEF(CppReduceComplex16DimRef)(Descriptor &result, |
| 651 |
const Descriptor &array, |
| 652 |
ReferenceReductionOperation<std::complex<CppFloat128Type>> operation, |
| 653 |
const char *source, int line, int dim, const Descriptor *mask, |
| 654 |
const std::complex<CppFloat128Type> *identity, bool ordered) { |
| 655 |
Terminator terminator{source, line}; |
| 656 |
using Accumulator = ReduceAccumulator<std::complex<CppFloat128Type>, false>; |
| 657 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 658 |
PartialReduction<Accumulator, TypeCategory::Complex, 16>(result, array, |
| 659 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 660 |
} |
| 661 |
void RTDEF(CppReduceComplex16DimValue)(Descriptor &result, |
| 662 |
const Descriptor &array, |
| 663 |
ValueReductionOperation<std::complex<CppFloat128Type>> operation, |
| 664 |
const char *source, int line, int dim, const Descriptor *mask, |
| 665 |
const std::complex<CppFloat128Type> *identity, bool ordered) { |
| 666 |
Terminator terminator{source, line}; |
| 667 |
using Accumulator = ReduceAccumulator<std::complex<CppFloat128Type>, true>; |
| 668 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 669 |
PartialReduction<Accumulator, TypeCategory::Complex, 16>(result, array, |
| 670 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 671 |
} |
| 672 |
#endif |
| 673 |
|
| 674 |
bool RTDEF(ReduceLogical1Ref)(const Descriptor &array, |
| 675 |
ReferenceReductionOperation<std::int8_t> operation, const char *source, |
| 676 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 677 |
bool ordered) { |
| 678 |
return RTNAME(ReduceInteger1Ref)( |
| 679 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 680 |
} |
| 681 |
bool RTDEF(ReduceLogical1Value)(const Descriptor &array, |
| 682 |
ValueReductionOperation<std::int8_t> operation, const char *source, |
| 683 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 684 |
bool ordered) { |
| 685 |
return RTNAME(ReduceInteger1Value)( |
| 686 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 687 |
} |
| 688 |
void RTDEF(ReduceLogical1DimRef)(Descriptor &result, const Descriptor &array, |
| 689 |
ReferenceReductionOperation<std::int8_t> operation, const char *source, |
| 690 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 691 |
bool ordered) { |
| 692 |
RTNAME(ReduceInteger1DimRef) |
| 693 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 694 |
} |
| 695 |
void RTDEF(ReduceLogical1DimValue)(Descriptor &result, const Descriptor &array, |
| 696 |
ValueReductionOperation<std::int8_t> operation, const char *source, |
| 697 |
int line, int dim, const Descriptor *mask, const std::int8_t *identity, |
| 698 |
bool ordered) { |
| 699 |
RTNAME(ReduceInteger1DimValue) |
| 700 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 701 |
} |
| 702 |
bool RTDEF(ReduceLogical2Ref)(const Descriptor &array, |
| 703 |
ReferenceReductionOperation<std::int16_t> operation, const char *source, |
| 704 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 705 |
bool ordered) { |
| 706 |
return RTNAME(ReduceInteger2Ref)( |
| 707 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 708 |
} |
| 709 |
bool RTDEF(ReduceLogical2Value)(const Descriptor &array, |
| 710 |
ValueReductionOperation<std::int16_t> operation, const char *source, |
| 711 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 712 |
bool ordered) { |
| 713 |
return RTNAME(ReduceInteger2Value)( |
| 714 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 715 |
} |
| 716 |
void RTDEF(ReduceLogical2DimRef)(Descriptor &result, const Descriptor &array, |
| 717 |
ReferenceReductionOperation<std::int16_t> operation, const char *source, |
| 718 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 719 |
bool ordered) { |
| 720 |
RTNAME(ReduceInteger2DimRef) |
| 721 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 722 |
} |
| 723 |
void RTDEF(ReduceLogical2DimValue)(Descriptor &result, const Descriptor &array, |
| 724 |
ValueReductionOperation<std::int16_t> operation, const char *source, |
| 725 |
int line, int dim, const Descriptor *mask, const std::int16_t *identity, |
| 726 |
bool ordered) { |
| 727 |
RTNAME(ReduceInteger2DimValue) |
| 728 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 729 |
} |
| 730 |
bool RTDEF(ReduceLogical4Ref)(const Descriptor &array, |
| 731 |
ReferenceReductionOperation<std::int32_t> operation, const char *source, |
| 732 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 733 |
bool ordered) { |
| 734 |
return RTNAME(ReduceInteger4Ref)( |
| 735 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 736 |
} |
| 737 |
bool RTDEF(ReduceLogical4Value)(const Descriptor &array, |
| 738 |
ValueReductionOperation<std::int32_t> operation, const char *source, |
| 739 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 740 |
bool ordered) { |
| 741 |
return RTNAME(ReduceInteger4Value)( |
| 742 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 743 |
} |
| 744 |
void RTDEF(ReduceLogical4DimRef)(Descriptor &result, const Descriptor &array, |
| 745 |
ReferenceReductionOperation<std::int32_t> operation, const char *source, |
| 746 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 747 |
bool ordered) { |
| 748 |
RTNAME(ReduceInteger4DimRef) |
| 749 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 750 |
} |
| 751 |
void RTDEF(ReduceLogical4DimValue)(Descriptor &result, const Descriptor &array, |
| 752 |
ValueReductionOperation<std::int32_t> operation, const char *source, |
| 753 |
int line, int dim, const Descriptor *mask, const std::int32_t *identity, |
| 754 |
bool ordered) { |
| 755 |
RTNAME(ReduceInteger4DimValue) |
| 756 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 757 |
} |
| 758 |
bool RTDEF(ReduceLogical8Ref)(const Descriptor &array, |
| 759 |
ReferenceReductionOperation<std::int64_t> operation, const char *source, |
| 760 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 761 |
bool ordered) { |
| 762 |
return RTNAME(ReduceInteger8Ref)( |
| 763 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 764 |
} |
| 765 |
bool RTDEF(ReduceLogical8Value)(const Descriptor &array, |
| 766 |
ValueReductionOperation<std::int64_t> operation, const char *source, |
| 767 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 768 |
bool ordered) { |
| 769 |
return RTNAME(ReduceInteger8Value)( |
| 770 |
array, operation, source, line, dim, mask, identity, ordered) != 0; |
| 771 |
} |
| 772 |
void RTDEF(ReduceLogical8DimRef)(Descriptor &result, const Descriptor &array, |
| 773 |
ReferenceReductionOperation<std::int64_t> operation, const char *source, |
| 774 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 775 |
bool ordered) { |
| 776 |
RTNAME(ReduceInteger8DimRef) |
| 777 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 778 |
} |
| 779 |
void RTDEF(ReduceLogical8DimValue)(Descriptor &result, const Descriptor &array, |
| 780 |
ValueReductionOperation<std::int64_t> operation, const char *source, |
| 781 |
int line, int dim, const Descriptor *mask, const std::int64_t *identity, |
| 782 |
bool ordered) { |
| 783 |
RTNAME(ReduceInteger8DimValue) |
| 784 |
(result, array, operation, source, line, dim, mask, identity, ordered); |
| 785 |
} |
| 786 |
|
| 787 |
void RTDEF(ReduceChar1)(char *result, const Descriptor &array, |
| 788 |
ReductionCharOperation<char> operation, const char *source, int line, |
| 789 |
int dim, const Descriptor *mask, const char *identity, bool ordered) { |
| 790 |
Terminator terminator{source, line}; |
| 791 |
BufferedReduceAccumulator<char, ReductionCharOperation<char>, |
| 792 |
/*hasLength=*/true> |
| 793 |
accumulator{array, operation, identity, terminator}; |
| 794 |
DoTotalReduction<char>(array, dim, mask, accumulator, "REDUCE", terminator); |
| 795 |
accumulator.GetResult(result); |
| 796 |
} |
| 797 |
void RTDEF(ReduceCharacter1Dim)(Descriptor &result, const Descriptor &array, |
| 798 |
ReductionCharOperation<char> operation, const char *source, int line, |
| 799 |
int dim, const Descriptor *mask, const char *identity, bool ordered) { |
| 800 |
Terminator terminator{source, line}; |
| 801 |
using Accumulator = BufferedReduceAccumulator<char, |
| 802 |
ReductionCharOperation<char>, /*hasLength=*/true>; |
| 803 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 804 |
PartialReduction<Accumulator, TypeCategory::Character, 1>(result, array, |
| 805 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 806 |
} |
| 807 |
void RTDEF(ReduceChar2)(char16_t *result, const Descriptor &array, |
| 808 |
ReductionCharOperation<char16_t> operation, const char *source, int line, |
| 809 |
int dim, const Descriptor *mask, const char16_t *identity, bool ordered) { |
| 810 |
Terminator terminator{source, line}; |
| 811 |
BufferedReduceAccumulator<char16_t, ReductionCharOperation<char16_t>, |
| 812 |
/*hasLength=*/true> |
| 813 |
accumulator{array, operation, identity, terminator}; |
| 814 |
DoTotalReduction<char16_t>( |
| 815 |
array, dim, mask, accumulator, "REDUCE", terminator); |
| 816 |
accumulator.GetResult(result); |
| 817 |
} |
| 818 |
void RTDEF(ReduceCharacter2Dim)(Descriptor &result, const Descriptor &array, |
| 819 |
ReductionCharOperation<char16_t> operation, const char *source, int line, |
| 820 |
int dim, const Descriptor *mask, const char16_t *identity, bool ordered) { |
| 821 |
Terminator terminator{source, line}; |
| 822 |
using Accumulator = BufferedReduceAccumulator<char16_t, |
| 823 |
ReductionCharOperation<char16_t>, /*hasLength=*/true>; |
| 824 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 825 |
PartialReduction<Accumulator, TypeCategory::Character, 2>(result, array, |
| 826 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 827 |
} |
| 828 |
void RTDEF(ReduceChar4)(char32_t *result, const Descriptor &array, |
| 829 |
ReductionCharOperation<char32_t> operation, const char *source, int line, |
| 830 |
int dim, const Descriptor *mask, const char32_t *identity, bool ordered) { |
| 831 |
Terminator terminator{source, line}; |
| 832 |
BufferedReduceAccumulator<char32_t, ReductionCharOperation<char32_t>, |
| 833 |
/*hasLength=*/true> |
| 834 |
accumulator{array, operation, identity, terminator}; |
| 835 |
DoTotalReduction<char32_t>( |
| 836 |
array, dim, mask, accumulator, "REDUCE", terminator); |
| 837 |
accumulator.GetResult(result); |
| 838 |
} |
| 839 |
void RTDEF(ReduceCharacter4Dim)(Descriptor &result, const Descriptor &array, |
| 840 |
ReductionCharOperation<char32_t> operation, const char *source, int line, |
| 841 |
int dim, const Descriptor *mask, const char32_t *identity, bool ordered) { |
| 842 |
Terminator terminator{source, line}; |
| 843 |
using Accumulator = BufferedReduceAccumulator<char32_t, |
| 844 |
ReductionCharOperation<char32_t>, /*hasLength=*/true>; |
| 845 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 846 |
PartialReduction<Accumulator, TypeCategory::Character, 4>(result, array, |
| 847 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 848 |
} |
| 849 |
|
| 850 |
void RTDEF(ReduceDerivedType)(char *result, const Descriptor &array, |
| 851 |
ReductionDerivedTypeOperation operation, const char *source, int line, |
| 852 |
int dim, const Descriptor *mask, const char *identity, bool ordered) { |
| 853 |
Terminator terminator{source, line}; |
| 854 |
BufferedReduceAccumulator<char, ReductionDerivedTypeOperation, |
| 855 |
/*hasLength=*/false> |
| 856 |
accumulator{array, operation, identity, terminator}; |
| 857 |
DoTotalReduction<char>(array, dim, mask, accumulator, "REDUCE", terminator); |
| 858 |
accumulator.GetResult(result); |
| 859 |
} |
| 860 |
void RTDEF(ReduceDerivedTypeDim)(Descriptor &result, const Descriptor &array, |
| 861 |
ReductionDerivedTypeOperation operation, const char *source, int line, |
| 862 |
int dim, const Descriptor *mask, const char *identity, bool ordered) { |
| 863 |
Terminator terminator{source, line}; |
| 864 |
using Accumulator = BufferedReduceAccumulator<char, |
| 865 |
ReductionDerivedTypeOperation, /*hasLength=*/false>; |
| 866 |
Accumulator accumulator{array, operation, identity, terminator}; |
| 867 |
PartialReduction<Accumulator, TypeCategory::Derived, 0>(result, array, |
| 868 |
array.ElementBytes(), dim, mask, terminator, "REDUCE", accumulator); |
| 869 |
} |
| 870 |
|
| 871 |
RT_EXT_API_GROUP_END |
| 872 |
} // extern "C" |
| 873 |
} // namespace Fortran::runtime |