This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add support for -fopenmp and -fopenacc
ClosedPublic

Authored by FarisRehman on Feb 4 2021, 6:17 AM.

Details

Summary

Add support for the following Fortran dialect options:

  • -fopenmp
  • -fopenacc

Update OpenMP and OpenACC semantics tests to use the new driver if it is built, otherwise use f18.
OpenMP tests that include use omp_lib or run test_symbols.sh have not been updated as they require options -intrinsic-module-directory and -funparse-with-symbols which are currently not implemented in the new driver.
Similarly OpenACC tests that run test_symbols.sh have not been updated.

This patch also moves semanticsContext to CompilerInvocation and created in CompilerInvocation#setSemanticsOpts so that the semantics context can use Fortran::parser::Options#features.

Summary of changes:

  • Move semanticsContext to CompilerInvocation.h
  • Update OpenMP and OpenACC semantics tests that do not rely on -intrinsic-module-directory and -funparse-with-symbols to use %flang

Depends on: D95448

Diff Detail

Event Timeline

FarisRehman created this revision.Feb 4 2021, 6:17 AM
FarisRehman requested review of this revision.Feb 4 2021, 6:17 AM
Herald added a project: Restricted Project. · View Herald Transcript
FarisRehman edited the summary of this revision. (Show Details)Feb 4 2021, 6:22 AM
FarisRehman added a project: Restricted Project.

Rebase off main

Rebase off main as patch D95448, which this patch depends on, has been merged into main.

awarzynski accepted this revision.Feb 8 2021, 10:21 AM

Thank you for this patch @FarisRehman , it's great to see more tests being ported to the new driver!

Although this patches touches many files, it mostly just generalizes the RUN lines. With this change we can easily switch between f18 and flang-new (depending on FLANG_BUILD_NEW_DRIVER), which is very helpful!

LGTM (could you moving options::OPT_fopenmp, options::OPT_fopenacc do a dedicated method before merging?)

clang/include/clang/Driver/Options.td
4219–4220

Could we follow gcc here:

gcc --help=fortran | grep openacc
  -fopenacc                   Enable OpenACC.
clang/lib/Driver/ToolChains/Flang.cpp
25–26

-fopenmp and -fopenacc enable extensions, so they are not dialect options.

flang/lib/Frontend/CompilerInvocation.cpp
350

[nit] language -> extensions

This revision is now accepted and ready to land.Feb 8 2021, 10:21 AM
FarisRehman marked 3 inline comments as done.

Address review comment

Address review comment by @awarzynski

clang/lib/Driver/ToolChains/Flang.cpp
25–26

I decided to add this here as it is listed under "Fortran Dialect Options" in the gfortran documentation: https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html

awarzynski accepted this revision.Feb 9 2021, 5:04 AM
awarzynski added inline comments.
clang/lib/Driver/ToolChains/Flang.cpp
25–26

Makes sense, thanks for clarifying!

This revision was landed with ongoing or failed builds.Feb 10 2021, 2:00 AM
This revision was automatically updated to reflect the committed changes.