2019-12-21 04:52:07 +08:00
|
|
|
//===-- runtime/transformational.h ------------------------------*- C++ -*-===//
|
2018-08-03 02:45:11 +08:00
|
|
|
//
|
2019-12-21 04:52:07 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-08-03 02:45:11 +08:00
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-08-03 02:45:11 +08:00
|
|
|
|
2021-05-21 01:37:03 +08:00
|
|
|
// Defines the API for the type-independent transformational intrinsic functions
|
|
|
|
// that rearrange data in arrays: CSHIFT, EOSHIFT, PACK, RESHAPE, SPREAD,
|
|
|
|
// TRANSPOSE, and UNPACK.
|
|
|
|
// These are naive allocating implementations; optimized forms that manipulate
|
|
|
|
// pointer descriptors or that supply functional views of arrays remain to
|
|
|
|
// be defined and may instead be part of lowering (see docs/ArrayComposition.md)
|
|
|
|
// for details).
|
|
|
|
|
2018-08-03 02:45:11 +08:00
|
|
|
#ifndef FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
|
|
|
|
#define FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
|
|
|
|
|
|
|
|
#include "descriptor.h"
|
[flang] Implement reductions in the runtime
Add runtime APIs, implementations, and tests for ALL, ANY, COUNT,
MAXLOC, MAXVAL, MINLOC, MINVAL, PRODUCT, and SUM reduction
transformantional intrinsic functions for all relevant argument
and result types and kinds, both without DIM= arguments
(total reductions) and with (partial reductions).
Complex-valued reductions have their APIs in C so that
C's _Complex types can be used for their results.
Some infrastructure work was also necessary or noticed:
* Usage of "long double" in the compiler was cleaned up a
bit, and host dependences on x86 / MSVC have been isolated
in a new Common/long-double header.
* Character comparison has been exposed via an extern template
so that reductions could use it.
* Mappings from Fortran type category/kind to host C++ types
and vice versa have been isolated into runtime/cpp-type.h and
then used throughout the runtime as appropriate.
* The portable 128-bit integer package in Common/uint128.h
was generalized to support signed comparisons.
* Bugs in descriptor indexing code were fixed.
Differential Revision: https://reviews.llvm.org/D99666
2021-04-01 00:14:08 +08:00
|
|
|
#include "entry-names.h"
|
2020-02-14 06:41:56 +08:00
|
|
|
#include "memory.h"
|
2018-08-03 02:45:11 +08:00
|
|
|
|
|
|
|
namespace Fortran::runtime {
|
2021-05-21 04:49:31 +08:00
|
|
|
|
|
|
|
// TODO: redo API, put under extern "C"
|
|
|
|
OwningPtr<Descriptor> RTNAME(Reshape)(const Descriptor &source,
|
|
|
|
const Descriptor &shape, const Descriptor *pad = nullptr,
|
|
|
|
const Descriptor *order = nullptr, const char *sourceFile = nullptr,
|
|
|
|
int line = 0);
|
|
|
|
|
2021-05-21 01:37:03 +08:00
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
void RTNAME(Cshift)(Descriptor &result, const Descriptor &source,
|
|
|
|
const Descriptor &shift, int dim = 1, const char *sourceFile = nullptr,
|
|
|
|
int line = 0);
|
|
|
|
void RTNAME(CshiftVector)(Descriptor &result, const Descriptor &source,
|
|
|
|
std::int64_t shift, const char *sourceFile = nullptr, int line = 0);
|
|
|
|
|
|
|
|
void RTNAME(Eoshift)(Descriptor &result, const Descriptor &source,
|
|
|
|
const Descriptor &shift, const Descriptor *boundary = nullptr, int dim = 1,
|
|
|
|
const char *sourceFile = nullptr, int line = 0);
|
|
|
|
void RTNAME(EoshiftVector)(Descriptor &result, const Descriptor &source,
|
|
|
|
std::int64_t shift, const Descriptor *boundary = nullptr,
|
|
|
|
const char *sourceFile = nullptr, int line = 0);
|
|
|
|
|
|
|
|
void RTNAME(Pack)(Descriptor &result, const Descriptor &source,
|
|
|
|
const Descriptor &mask, const Descriptor *vector = nullptr,
|
|
|
|
const char *sourceFile = nullptr, int line = 0);
|
2018-08-03 02:45:11 +08:00
|
|
|
|
2021-05-21 01:37:03 +08:00
|
|
|
void RTNAME(Spread)(Descriptor &result, const Descriptor &source, int dim,
|
|
|
|
std::int64_t ncopies, const char *sourceFile = nullptr, int line = 0);
|
|
|
|
|
|
|
|
void RTNAME(Transpose)(Descriptor &result, const Descriptor &matrix,
|
|
|
|
const char *sourceFile = nullptr, int line = 0);
|
|
|
|
|
|
|
|
void RTNAME(Unpack)(Descriptor &result, const Descriptor &vector,
|
|
|
|
const Descriptor &mask, const Descriptor &field,
|
|
|
|
const char *sourceFile = nullptr, int line = 0);
|
|
|
|
|
|
|
|
} // extern "C"
|
|
|
|
} // namespace Fortran::runtime
|
2020-03-29 12:00:16 +08:00
|
|
|
#endif // FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
|