CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
98 lines
3.4 KiB
C++
98 lines
3.4 KiB
C++
//===-- lib/runtime/inquiry.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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Implements the inquiry intrinsic functions of Fortran 2018 that
|
|
// inquire about shape information of arrays -- LBOUND and SIZE.
|
|
|
|
#include "flang/Runtime/inquiry.h"
|
|
#include "copy.h"
|
|
#include "flang-rt/runtime/descriptor.h"
|
|
#include "flang-rt/runtime/terminator.h"
|
|
#include "flang-rt/runtime/tools.h"
|
|
#include <algorithm>
|
|
|
|
namespace Fortran::runtime {
|
|
|
|
template <int KIND> struct RawStoreIntegerAt {
|
|
RT_API_ATTRS void operator()(
|
|
void *contiguousIntegerArray, std::size_t at, std::int64_t value) const {
|
|
reinterpret_cast<Fortran::runtime::CppTypeFor<
|
|
Fortran::common::TypeCategory::Integer, KIND> *>(
|
|
contiguousIntegerArray)[at] = value;
|
|
}
|
|
};
|
|
|
|
extern "C" {
|
|
std::int64_t RTDEF(LboundDim)(
|
|
const Descriptor &array, int dim, const char *sourceFile, int line) {
|
|
if (dim < 1 || dim > array.rank()) {
|
|
Terminator terminator{sourceFile, line};
|
|
terminator.Crash(
|
|
"SIZE: bad DIM=%d for ARRAY with rank=%d", dim, array.rank());
|
|
}
|
|
const Dimension &dimension{array.GetDimension(dim - 1)};
|
|
return static_cast<std::int64_t>(dimension.LowerBound());
|
|
}
|
|
|
|
void RTDEF(Ubound)(void *result, const Descriptor &array, int kind,
|
|
const char *sourceFile, int line) {
|
|
Terminator terminator{sourceFile, line};
|
|
INTERNAL_CHECK(array.rank() <= common::maxRank);
|
|
for (SubscriptValue i{0}; i < array.rank(); ++i) {
|
|
const Dimension &dimension{array.GetDimension(i)};
|
|
Fortran::runtime::ApplyIntegerKind<RawStoreIntegerAt, void>(
|
|
kind, terminator, result, i, dimension.UpperBound());
|
|
}
|
|
}
|
|
|
|
std::int64_t RTDEF(Size)(
|
|
const Descriptor &array, const char *sourceFile, int line) {
|
|
std::int64_t result{1};
|
|
for (int i = 0; i < array.rank(); ++i) {
|
|
const Dimension &dimension{array.GetDimension(i)};
|
|
result *= dimension.Extent();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
std::int64_t RTDEF(SizeDim)(
|
|
const Descriptor &array, int dim, const char *sourceFile, int line) {
|
|
if (dim < 1 || dim > array.rank()) {
|
|
Terminator terminator{sourceFile, line};
|
|
terminator.Crash(
|
|
"SIZE: bad DIM=%d for ARRAY with rank=%d", dim, array.rank());
|
|
}
|
|
const Dimension &dimension{array.GetDimension(dim - 1)};
|
|
return static_cast<std::int64_t>(dimension.Extent());
|
|
}
|
|
|
|
void RTDEF(Shape)(void *result, const Descriptor &array, int kind,
|
|
const char *sourceFile, int line) {
|
|
Terminator terminator{sourceFile, line};
|
|
INTERNAL_CHECK(array.rank() <= common::maxRank);
|
|
for (SubscriptValue i{0}; i < array.rank(); ++i) {
|
|
const Dimension &dimension{array.GetDimension(i)};
|
|
Fortran::runtime::ApplyIntegerKind<RawStoreIntegerAt, void>(
|
|
kind, terminator, result, i, dimension.Extent());
|
|
}
|
|
}
|
|
|
|
void RTDEF(Lbound)(void *result, const Descriptor &array, int kind,
|
|
const char *sourceFile, int line) {
|
|
Terminator terminator{sourceFile, line};
|
|
INTERNAL_CHECK(array.rank() <= common::maxRank);
|
|
for (SubscriptValue i{0}; i < array.rank(); ++i) {
|
|
const Dimension &dimension{array.GetDimension(i)};
|
|
Fortran::runtime::ApplyIntegerKind<RawStoreIntegerAt, void>(
|
|
kind, terminator, result, i, dimension.LowerBound());
|
|
}
|
|
}
|
|
|
|
} // extern "C"
|
|
} // namespace Fortran::runtime
|