This is an archive of the discontinued LLVM Phabricator instance.

[flang][openacc] OpenACC 3.0 parser
ClosedPublic

Authored by clementval on Jul 12 2020, 4:37 PM.

Details

Summary

This patch introduce the parser for OpenACC 3.0 in Flang. It uses the same TableGen mechanism
than OpenMP.

Diff Detail

Event Timeline

clementval created this revision.Jul 12 2020, 4:37 PM
Herald added a project: Restricted Project. · View Herald Transcript
clementval added a project: Restricted Project.Jul 12 2020, 4:40 PM

When I try to build this (on macos) I get a missing include for unordered_map:

In file included from ../../flang/lib/Semantics/check-omp-structure.h:159:
include/llvm/Frontend/OpenMP/OMP.cpp.inc:2123:6: error: no template named 'unordered_map' in namespace 'std'
std::unordered_map<llvm::omp::Directive, OpenMPDirectiveClauses>
~~~~~^

Adding the include to check-omp-structure.h fixes the build problem.

When I try to build this (on macos) I get a missing include for unordered_map:

In file included from ../../flang/lib/Semantics/check-omp-structure.h:159:
include/llvm/Frontend/OpenMP/OMP.cpp.inc:2123:6: error: no template named 'unordered_map' in namespace 'std'
std::unordered_map<llvm::omp::Directive, OpenMPDirectiveClauses>
~~~~~^

Adding the include to check-omp-structure.h fixes the build problem.

@DavidTruby has seen similar problem here https://reviews.llvm.org/rG6e42a417bacbfd5a1f58b0ccb7c9b34ff9e54523. I'll send a patch today to switch to DenseMap so this should go away with it.

I've already committed a quick fix just moving the header, so builds should work again now.

klausler accepted this revision.Jul 13 2020, 9:39 AM

This looks spectacular to me (at least the f18 parts that I reviewed). Thank you so much for taking on this task and contributing so much value to the project.

flang/include/flang/Parser/parse-tree.h
3853

Minor: eqv and neqv are missing their second periods.

flang/lib/Parser/openacc-parsers.cpp
26

Doesn't OpenMP use something similar? Put it into token-parsers.h and share it, if so.

36

Extra space at end of line, and not in alphabetic order.

88

Where synonyms like this appear, it would probably be more clear to use something like ("DEVICE_TYPE"_tok || "DTYPE"_tok) >> ...) to combine the recognition of the synonymous keywords and have just the one following parser.

155

We use C++-style comments with //, please.

This revision is now accepted and ready to land.Jul 13 2020, 9:39 AM
clementval marked 5 inline comments as done.

Address review comment

This looks spectacular to me (at least the f18 parts that I reviewed). Thank you so much for taking on this task and contributing so much value to the project.

Thanks for the review. I just updated the patch with fixes to your comments.

This revision was automatically updated to reflect the committed changes.

Hi, your git commit contains extra Phabricator tags. You can drop Reviewers: Subscribers: Tags: and the text Summary: from the git commit with the following script:

arcfilter () {
        arc amend
        git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
}

Reviewed By: is considered important by some people. Please keep the tag. (--date=now is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time))

llvm/utils/git/pre-push.py can validate the message does not include unneeded tags.

@klausler I had to temporarly revert this patch since it fails for one buildbot. http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/5677

Even after adding Support as a link dependency it still fails. Will investigate tomorrow.

FAILED: lib/libLLVMFrontendOpenACC.so.11git
: && /home/buildbots/clang.10.0.0/bin/clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -Wl,-z,defs -Wl,-z,nodelete -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/stage1/./lib -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libLLVMFrontendOpenACC.so.11git -o lib/libLLVMFrontendOpenACC.so.11git lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o -Wl,-rpath,"\$ORIGIN/../lib" && :
lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o: In function `llvm::acc::getOpenACCDirectiveName(llvm::acc::Directive)':
ACC.cpp:(.text._ZN4llvm3acc23getOpenACCDirectiveNameENS0_9DirectiveE+0x280): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o: In function `llvm::acc::getOpenACCClauseName(llvm::acc::Clause)':
ACC.cpp:(.text._ZN4llvm3acc20getOpenACCClauseNameENS0_6ClauseE+0x4a4): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o: In function `llvm::acc::isAllowedClauseForDirective(llvm::acc::Directive, llvm::acc::Clause, unsigned int)':
ACC.cpp:(.text._ZN4llvm3acc27isAllowedClauseForDirectiveENS0_9DirectiveENS0_6ClauseEj+0x344): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'

clementval reopened this revision.Jul 14 2020, 8:21 AM

Had to revert because of a failed buildbot. http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/5673

FAILED: lib/libLLVMFrontendOpenACC.so.11git 
: && /home/buildbots/clang.10.0.0/bin/clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/stage1/./lib  -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libLLVMFrontendOpenACC.so.11git -o lib/libLLVMFrontendOpenACC.so.11git lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib" && :
lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o: In function `llvm::acc::getOpenACCDirectiveName(llvm::acc::Directive)':
ACC.cpp:(.text._ZN4llvm3acc23getOpenACCDirectiveNameENS0_9DirectiveE+0x280): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o: In function `llvm::acc::getOpenACCClauseName(llvm::acc::Clause)':
ACC.cpp:(.text._ZN4llvm3acc20getOpenACCClauseNameENS0_6ClauseE+0x4a4): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
lib/Frontend/OpenACC/CMakeFiles/LLVMFrontendOpenACC.dir/ACC.cpp.o: In function `llvm::acc::isAllowedClauseForDirective(llvm::acc::Directive, llvm::acc::Clause, unsigned int)':
ACC.cpp:(.text._ZN4llvm3acc27isAllowedClauseForDirectiveENS0_9DirectiveENS0_6ClauseEj+0x344): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
This revision is now accepted and ready to land.Jul 14 2020, 8:21 AM

Fix after build failure on clang-ppc64le-rhel

This revision was automatically updated to reflect the committed changes.