This is an archive of the discontinued LLVM Phabricator instance.

[flang][openacc] Add data operands conversion from FIR
ClosedPublic

Authored by clementval on Apr 7 2023, 4:23 PM.

Details

Summary

This patch revive an old PR attempt [1] to perform the
data operands conversion needed for translation to LLVMIR.

This is currently not supporting box/class type since they will
normally not reach this pass when the proposed change in this RFC [2]
are implemented.

[1] https://github.com/flang-compiler/f18-llvm-project/pull/915
[2] https://discourse.llvm.org/t/rfc-openacc-dialect-data-operation-improvements/69825/2

Depends on D147824

Diff Detail

Event Timeline

clementval created this revision.Apr 7 2023, 4:23 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
clementval requested review of this revision.Apr 7 2023, 4:23 PM
razvanlupusoru accepted this revision.Apr 7 2023, 5:14 PM

Looks great!

I also realized looking at this work that with the proposal from https://discourse.llvm.org/t/rfc-openacc-dialect-data-operation-improvements/69825 , it will be easier to distinguish data from non-data operands (since all data operands will be in the same operand list).

flang/lib/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp
49

nit: should be plural numDataOperands

This revision is now accepted and ready to land.Apr 7 2023, 5:14 PM
PeteSteinfeld requested changes to this revision.Apr 7 2023, 8:11 PM

I'm getting errors when I try to build with these changes. Here's an excerpt from the log file:

[6120/7355] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/
obj.FIRTransforms.dir/OpenACC/OpenACCDataOperandConversion.cpp.o
FAILED: tools/flang/lib/Optimizer/Transforms/CMakeFiles/obj.FIRTransforms.dir/Op
enACC/OpenACCDataOperandConversion.cpp.o 
/home/sw/thirdparty/gcc/gcc-9.3.0/linux86-64/bin/g++ -DFLANG_INCLUDE_TESTS=1 -DF
LANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SO
URCE -D_LIBCPP_ENABLE_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
 -D__STDC_LIMIT_MACROS -I/local/home/psteinfeld/main/825/build/tools/flang/lib/O
ptimizer/Transforms -I/local/home/psteinfeld/main/825/flang/lib/Optimizer/Transf
orms -I/local/home/psteinfeld/main/825/flang/include -I/local/home/psteinfeld/ma
in/825/build/tools/flang/include -I/local/home/psteinfeld/main/825/build/include
 -I/local/home/psteinfeld/main/825/llvm/include -isystem /local/home/psteinfeld/
main/825/llvm/../mlir/include -isystem /local/home/psteinfeld/main/825/build/too
ls/mlir/include -isystem /local/home/psteinfeld/main/825/build/tools/clang/inclu
de -isystem /local/home/psteinfeld/main/825/llvm/../clang/include -fPIC -fno-sem
antic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializer
s -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-
class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wd
elete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentati
on -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecat
ed-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposi
tion -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17
 -MD -MT tools/flang/lib/Optimizer/Transforms/CMakeFiles/obj.FIRTransforms.dir/O
penACC/OpenACCDataOperandConversion.cpp.o -MF tools/flang/lib/Optimizer/Transfor
ms/CMakeFiles/obj.FIRTransforms.dir/OpenACC/OpenACCDataOperandConversion.cpp.o.d
 -o tools/flang/lib/Optimizer/Transforms/CMakeFiles/obj.FIRTransforms.dir/OpenAC
C/OpenACCDataOperandConversion.cpp.o -c /local/home/psteinfeld/main/825/flang/li
b/Optimizer/Transforms/OpenACC/OpenACCDataOperandConversion.cpp
/local/home/psteinfeld/main/825/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDa
taOperandConversion.cpp: In instantiation of ‘mlir::LogicalResult {anonymous}::L
egalizeDataOpForLLVMTranslation<Op>::matchAndRewrite(Op, typename Op::Adaptor, m
lir::ConversionPatternRewriter&) const [with Op = mlir::acc::UpdateOp; typename 
Op::Adaptor = mlir::acc::UpdateOpAdaptor]’:
/local/home/psteinfeld/main/825/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDa
taOperandConversion.cpp:42:3:   required from here
/local/home/psteinfeld/main/825/flang/lib/Optimizer/Transforms/OpenACC/OpenACCDa
taOperandConversion.cpp:62:11: error: ignoring returned value of type ‘mlir::Log
icalResult’, declared with attribute nodiscard [-Werror=unused-result]
   62 |           builder.notifyMatchFailure(op, "BaseBoxType not supported");
      |           ^~~~~~~
In file included from /local/home/psteinfeld/main/825/mlir/include/mlir/Rewrite/
FrozenRewritePatternSet.h:12,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/Transfor
ms/DialectConversion.h:16,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/Conversi
on/LLVMCommon/TypeConverter.h:18,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/Conversi
on/LLVMCommon/Pattern.h:13,
                 from /local/home/psteinfeld/main/825/flang/lib/Optimizer/Transf
orms/OpenACC/OpenACCDataOperandConversion.cpp:11:
/local/home/psteinfeld/main/825/mlir/include/mlir/IR/PatternMatch.h:621:17: note
: in call to ‘mlir::LogicalResult mlir::RewriterBase::notifyMatchFailure(ArgT&&,
 const char*) [with ArgT = mlir::acc::UpdateOp&]’, declared here
  621 |   LogicalResult notifyMatchFailure(ArgT &&arg, const char *msg) {
      |                 ^~~~~~~~~~~~~~~~~~
In file included from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Visit
ors.h:17,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/AttrT
ypeSubElements.h:18,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Stora
geUniquerSupport.h:16,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/TypeS
upport.h:17,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Types
.h:12,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Value
.h:16,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Block
Support.h:16,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Opera
tionSupport.h:17,
                 from /local/home/psteinfeld/main/825/mlir/include/mlir/IR/Diale
ct.h:17,
                 from /local/home/psteinfeld/main/825/flang/include/flang/Optimi
zer/Dialect/FIRDialect.h:16,
                 from /local/home/psteinfeld/main/825/flang/lib/Optimizer/Transf
orms/OpenACC/OpenACCDataOperandConversion.cpp:9:
This revision now requires changes to proceed.Apr 7 2023, 8:11 PM

Rebase + fix an issue

Address review comments

clementval marked an inline comment as done.Apr 10 2023, 9:40 AM

@PeteSteinfeld I rebased and fix an issue. You should be able to build it now.

PeteSteinfeld accepted this revision.Apr 10 2023, 10:15 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Apr 10 2023, 10:15 AM
This revision was automatically updated to reflect the committed changes.