Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions flang-rt/lib/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ set(supported_sources
derived.cpp
descriptor-io.cpp
descriptor.cpp
dot-product.cpp
dot-product-integer.cpp
dot-product-real.cpp
dot-product-complex.cpp
edit-input.cpp
edit-output.cpp
environment.cpp
exceptions.cpp
external-unit.cpp
extrema.cpp
extrema-maxloc.cpp
extrema-minloc.cpp
extrema-maxloc-dim.cpp
extrema-minloc-dim.cpp
extrema-value.cpp
file.cpp
findloc.cpp
findloc-total.cpp
findloc-dim.cpp
format.cpp
inquiry.cpp
internal-unit.cpp
Expand All @@ -46,8 +53,18 @@ set(supported_sources
io-error.cpp
io-stmt.cpp
iostat.cpp
matmul-transpose.cpp
matmul.cpp
matmul-transpose-integer.cpp
matmul-transpose-real.cpp
matmul-transpose-complex.cpp
matmul-transpose-extypes-int16.cpp
matmul-transpose-extypes-real10.cpp
matmul-transpose-extypes-real16.cpp
matmul-integer.cpp
matmul-real.cpp
matmul-complex.cpp
matmul-extypes-int16.cpp
matmul-extypes-real10.cpp
matmul-extypes-real16.cpp
memory.cpp
misc-intrinsic.cpp
namelist.cpp
Expand Down Expand Up @@ -112,17 +129,34 @@ set(gpu_sources
derived-api.cpp
derived.cpp
descriptor.cpp
dot-product.cpp
dot-product-integer.cpp
dot-product-real.cpp
dot-product-complex.cpp
edit-output.cpp
extrema.cpp
extrema-maxloc.cpp
extrema-minloc.cpp
extrema-maxloc-dim.cpp
extrema-minloc-dim.cpp
extrema-value.cpp
environment.cpp
findloc.cpp
findloc-total.cpp
findloc-dim.cpp
format.cpp
inquiry.cpp
internal-unit.cpp
iostat.cpp
matmul-transpose.cpp
matmul.cpp
matmul-transpose-integer.cpp
matmul-transpose-real.cpp
matmul-transpose-complex.cpp
matmul-transpose-extypes-int16.cpp
matmul-transpose-extypes-real10.cpp
matmul-transpose-extypes-real16.cpp
matmul-integer.cpp
matmul-real.cpp
matmul-complex.cpp
matmul-extypes-int16.cpp
matmul-extypes-real10.cpp
matmul-extypes-real16.cpp
memory.cpp
misc-intrinsic.cpp
non-tbp-dio.cpp
Expand Down
42 changes: 42 additions & 0 deletions flang-rt/lib/runtime/dot-product-complex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===-- lib/runtime/dot-product-complex.cpp ---------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

// Complex DOT_PRODUCT entry points.

#include "dot-product.h"

namespace Fortran::runtime {
extern "C" {
RT_EXT_API_GROUP_BEGIN

void RTDEF(CppDotProductComplex4)(CppTypeFor<TypeCategory::Complex, 4> &result,
const Descriptor &x, const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 4>{}(x, y, source, line);
}
void RTDEF(CppDotProductComplex8)(CppTypeFor<TypeCategory::Complex, 8> &result,
const Descriptor &x, const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 8>{}(x, y, source, line);
}
#if HAS_FLOAT80
void RTDEF(CppDotProductComplex10)(
CppTypeFor<TypeCategory::Complex, 10> &result, const Descriptor &x,
const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 10>{}(x, y, source, line);
}
#endif
#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(CppDotProductComplex16)(
CppTypeFor<TypeCategory::Complex, 16> &result, const Descriptor &x,
const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 16>{}(x, y, source, line);
}
#endif

RT_EXT_API_GROUP_END
} // extern "C"
} // namespace Fortran::runtime
65 changes: 65 additions & 0 deletions flang-rt/lib/runtime/dot-product-integer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//===-- lib/runtime/dot-product-integer.cpp ---------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

// Integer and Unsigned DOT_PRODUCT entry points.

#include "dot-product.h"

namespace Fortran::runtime {
extern "C" {
RT_EXT_API_GROUP_BEGIN

CppTypeFor<TypeCategory::Integer, 1> RTDEF(DotProductInteger1)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 1>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Integer, 2> RTDEF(DotProductInteger2)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 2>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Integer, 4> RTDEF(DotProductInteger4)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 4>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Integer, 8> RTDEF(DotProductInteger8)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 8>{}(x, y, source, line);
}
#ifdef __SIZEOF_INT128__
CppTypeFor<TypeCategory::Integer, 16> RTDEF(DotProductInteger16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 16>{}(x, y, source, line);
}
#endif

CppTypeFor<TypeCategory::Unsigned, 1> RTDEF(DotProductUnsigned1)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 1>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Unsigned, 2> RTDEF(DotProductUnsigned2)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 2>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Unsigned, 4> RTDEF(DotProductUnsigned4)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 4>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Unsigned, 8> RTDEF(DotProductUnsigned8)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 8>{}(x, y, source, line);
}
#ifdef __SIZEOF_INT128__
CppTypeFor<TypeCategory::Unsigned, 16> RTDEF(DotProductUnsigned16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 16>{}(x, y, source, line);
}
#endif

RT_EXT_API_GROUP_END
} // extern "C"
} // namespace Fortran::runtime
45 changes: 45 additions & 0 deletions flang-rt/lib/runtime/dot-product-real.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//===-- lib/runtime/dot-product-real.cpp ------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

// Real and Logical DOT_PRODUCT entry points.

#include "dot-product.h"

namespace Fortran::runtime {
extern "C" {
RT_EXT_API_GROUP_BEGIN

CppTypeFor<TypeCategory::Real, 4> RTDEF(DotProductReal4)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 4>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Real, 8> RTDEF(DotProductReal8)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 8>{}(x, y, source, line);
}
#if HAS_FLOAT80
CppTypeFor<TypeCategory::Real, 10> RTDEF(DotProductReal10)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 10>{}(x, y, source, line);
}
#endif
#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(DotProductReal16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 16>{}(x, y, source, line);
}
#endif

bool RTDEF(DotProductLogical)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Logical, 1>{}(x, y, source, line);
}

RT_EXT_API_GROUP_END
} // extern "C"
} // namespace Fortran::runtime
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//===-- lib/runtime/dot-product.cpp -----------------------------*- C++ -*-===//
//===-- lib/runtime/dot-product.h -------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef FLANG_RT_RUNTIME_DOT_PRODUCT_H_
#define FLANG_RT_RUNTIME_DOT_PRODUCT_H_

#include "float.h"
#include "flang-rt/runtime/descriptor.h"
#include "flang-rt/runtime/terminator.h"
Expand Down Expand Up @@ -154,106 +157,6 @@ template <TypeCategory RCAT, int RKIND> struct DotProduct {
}
};

extern "C" {
RT_EXT_API_GROUP_BEGIN

CppTypeFor<TypeCategory::Integer, 1> RTDEF(DotProductInteger1)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 1>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Integer, 2> RTDEF(DotProductInteger2)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 2>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Integer, 4> RTDEF(DotProductInteger4)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 4>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Integer, 8> RTDEF(DotProductInteger8)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 8>{}(x, y, source, line);
}
#ifdef __SIZEOF_INT128__
CppTypeFor<TypeCategory::Integer, 16> RTDEF(DotProductInteger16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Integer, 16>{}(x, y, source, line);
}
#endif

CppTypeFor<TypeCategory::Unsigned, 1> RTDEF(DotProductUnsigned1)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 1>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Unsigned, 2> RTDEF(DotProductUnsigned2)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 2>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Unsigned, 4> RTDEF(DotProductUnsigned4)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 4>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Unsigned, 8> RTDEF(DotProductUnsigned8)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 8>{}(x, y, source, line);
}
#ifdef __SIZEOF_INT128__
CppTypeFor<TypeCategory::Unsigned, 16> RTDEF(DotProductUnsigned16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Unsigned, 16>{}(x, y, source, line);
}
#endif

// TODO: REAL/COMPLEX(2 & 3)
// Intermediate results and operations are at least 64 bits
CppTypeFor<TypeCategory::Real, 4> RTDEF(DotProductReal4)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 4>{}(x, y, source, line);
}
CppTypeFor<TypeCategory::Real, 8> RTDEF(DotProductReal8)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 8>{}(x, y, source, line);
}
#if HAS_FLOAT80
CppTypeFor<TypeCategory::Real, 10> RTDEF(DotProductReal10)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 10>{}(x, y, source, line);
}
#endif
#if HAS_LDBL128 || HAS_FLOAT128
CppTypeFor<TypeCategory::Real, 16> RTDEF(DotProductReal16)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Real, 16>{}(x, y, source, line);
}
#endif

void RTDEF(CppDotProductComplex4)(CppTypeFor<TypeCategory::Complex, 4> &result,
const Descriptor &x, const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 4>{}(x, y, source, line);
}
void RTDEF(CppDotProductComplex8)(CppTypeFor<TypeCategory::Complex, 8> &result,
const Descriptor &x, const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 8>{}(x, y, source, line);
}
#if HAS_FLOAT80
void RTDEF(CppDotProductComplex10)(
CppTypeFor<TypeCategory::Complex, 10> &result, const Descriptor &x,
const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 10>{}(x, y, source, line);
}
#endif
#if HAS_LDBL128 || HAS_FLOAT128
void RTDEF(CppDotProductComplex16)(
CppTypeFor<TypeCategory::Complex, 16> &result, const Descriptor &x,
const Descriptor &y, const char *source, int line) {
result = DotProduct<TypeCategory::Complex, 16>{}(x, y, source, line);
}
#endif

bool RTDEF(DotProductLogical)(
const Descriptor &x, const Descriptor &y, const char *source, int line) {
return DotProduct<TypeCategory::Logical, 1>{}(x, y, source, line);
}

RT_EXT_API_GROUP_END
} // extern "C"
} // namespace Fortran::runtime

#endif // FLANG_RT_RUNTIME_DOT_PRODUCT_H_
25 changes: 25 additions & 0 deletions flang-rt/lib/runtime/extrema-maxloc-dim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- lib/runtime/extrema-maxloc-dim.cpp ----------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

// MAXLOC with DIM= entry point.

#include "extrema.h"

namespace Fortran::runtime {
extern "C" {
RT_EXT_API_GROUP_BEGIN

void RTDEF(MaxlocDim)(Descriptor &result, const Descriptor &x, int kind,
int dim, const char *source, int line, const Descriptor *mask, bool back) {
TypedPartialMaxOrMinLoc<true>(
"MAXLOC", result, x, kind, dim, source, line, mask, back);
}

RT_EXT_API_GROUP_END
} // extern "C"
} // namespace Fortran::runtime
Loading
Loading