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
91 lines
3.0 KiB
C++
91 lines
3.0 KiB
C++
//===- FIROpenACCSupportAnalysis.cpp - FIR OpenACCSupport Analysis -------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the FIR-specific OpenACCSupport analysis.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang/Optimizer/OpenACC/Analysis/FIROpenACCSupportAnalysis.h"
|
|
|
|
#include "flang/Optimizer/Builder/Todo.h"
|
|
#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
|
|
#include "flang/Optimizer/Dialect/FIRType.h"
|
|
#include "flang/Optimizer/OpenACC/Support/FIROpenACCUtils.h"
|
|
#include "mlir/Dialect/OpenACC/OpenACCUtils.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace fir {
|
|
namespace acc {
|
|
|
|
std::string FIROpenACCSupportAnalysis::getVariableName(Value v) {
|
|
return fir::acc::getVariableName(v, /*preferDemangledName=*/true);
|
|
}
|
|
|
|
std::string FIROpenACCSupportAnalysis::getRecipeName(mlir::acc::RecipeKind kind,
|
|
Type type, Value var) {
|
|
return fir::acc::getRecipeName(kind, type, var);
|
|
}
|
|
|
|
mlir::InFlightDiagnostic
|
|
FIROpenACCSupportAnalysis::emitNYI(Location loc, const Twine &message) {
|
|
TODO(loc, message);
|
|
// Should be unreachable, but we return an actual diagnostic
|
|
// to satisfy the interface.
|
|
return mlir::emitError(loc, "not yet implemented: " + message.str());
|
|
}
|
|
|
|
bool FIROpenACCSupportAnalysis::isValidSymbolUse(Operation *user,
|
|
SymbolRefAttr symbol,
|
|
Operation **definingOpPtr) {
|
|
// First check using the default OpenACC utility (recipes, device globals,
|
|
// acc routine, LLVM intrinsics, declare attribute).
|
|
Operation *definingOp = nullptr;
|
|
if (mlir::acc::isValidSymbolUse(user, symbol, &definingOp)) {
|
|
if (definingOpPtr)
|
|
*definingOpPtr = definingOp;
|
|
return true;
|
|
}
|
|
|
|
// Default said no; if we have no defining op, nothing more to check.
|
|
if (!definingOp)
|
|
return false;
|
|
if (definingOpPtr)
|
|
*definingOpPtr = definingOp;
|
|
|
|
// Functions marked as Fortran runtime are valid (GPU version expected
|
|
// to be offloaded).
|
|
if (definingOp->hasAttr("fir.runtime"))
|
|
return true;
|
|
|
|
// Functions with CUF device/global/host_device attribute are valid.
|
|
if (auto cufProcAttr = definingOp->getAttrOfType<cuf::ProcAttributeAttr>(
|
|
cuf::getProcAttrName())) {
|
|
if (cufProcAttr.getValue() != cuf::ProcAttribute::Host)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool FIROpenACCSupportAnalysis::isValidValueUse(Value v, Region ®ion) {
|
|
// First check using the base utility.
|
|
if (mlir::acc::isValidValueUse(v, region))
|
|
return true;
|
|
|
|
// FIR-specific: fir.logical is a trivial scalar type that can be
|
|
// passed by value.
|
|
if (mlir::isa<fir::LogicalType>(v.getType()))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
} // namespace acc
|
|
} // namespace fir
|