r338032 - [OPENMP] Force OpenMP 4.5 when compiling for offloading.
Jonas Hahnfeld via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 26 09:39:55 PDT 2018
Hi Alexey,
maybe we can now raise the version generally? Is that something that we
want to do before branching for 7.0?
According to http://clang.llvm.org/docs/OpenMPSupport.html, all
directives of OpenMP 4.5 are supported (even if Clang may not generate
optimal code).
Cheers,
Jonas
On 2018-07-26 17:17, Alexey Bataev via cfe-commits wrote:
> Author: abataev
> Date: Thu Jul 26 08:17:38 2018
> New Revision: 338032
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338032&view=rev
> Log:
> [OPENMP] Force OpenMP 4.5 when compiling for offloading.
>
> If the user requested compilation for OpenMP with the offloading
> support, force the version of the OpenMP standard to 4.5 by default.
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/OpenMP/driver.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=338032&r1=338031&r2=338032&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 26 08:17:38 2018
> @@ -4698,7 +4698,7 @@ void Clang::ConstructJob(Compilation &C,
>
> // For all the host OpenMP offloading compile jobs we need to pass
> the targets
> // information using -fopenmp-targets= option.
> - if (isa<CompileJobAction>(JA) &&
> JA.isHostOffloading(Action::OFK_OpenMP)) {
> + if (JA.isHostOffloading(Action::OFK_OpenMP)) {
> SmallString<128> TargetInfo("-fopenmp-targets=");
>
> Arg *Tgts = Args.getLastArg(options::OPT_fopenmp_targets_EQ);
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=338032&r1=338031&r2=338032&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jul 26 08:17:38
> 2018
> @@ -2594,13 +2594,15 @@ static void ParseLangArgs(LangOptions &O
> Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
> Opts.OpenMPIsDevice =
> Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
> + bool IsTargetSpecified =
> + Opts.OpenMPIsDevice ||
> Args.hasArg(options::OPT_fopenmp_targets_EQ);
>
> if (Opts.OpenMP || Opts.OpenMPSimd) {
> - if (int Version =
> - getLastArgIntValue(Args, OPT_fopenmp_version_EQ,
> - IsSimdSpecified ? 45 : Opts.OpenMP,
> Diags))
> + if (int Version = getLastArgIntValue(
> + Args, OPT_fopenmp_version_EQ,
> + (IsSimdSpecified || IsTargetSpecified) ? 45 : Opts.OpenMP,
> Diags))
> Opts.OpenMP = Version;
> - else if (IsSimdSpecified)
> + else if (IsSimdSpecified || IsTargetSpecified)
> Opts.OpenMP = 45;
> // Provide diagnostic when a given target is not expected to be an
> OpenMP
> // device or host.
>
> Modified: cfe/trunk/test/OpenMP/driver.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=338032&r1=338031&r2=338032&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/driver.c (original)
> +++ cfe/trunk/test/OpenMP/driver.c Thu Jul 26 08:17:38 2018
> @@ -1,3 +1,4 @@
> +// REQUIRES: x86-registered-target
> // Test that by default -fnoopenmp-use-tls is passed to frontend.
> //
> // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp | FileCheck
> --check-prefix=CHECK-DEFAULT %s
> @@ -23,7 +24,9 @@
>
> // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 |
> FileCheck --check-prefix=CHECK-45-VERSION %s
> // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-simd | FileCheck
> --check-prefix=CHECK-45-VERSION %s
> +// RUN: %clang %s -c -E -dM -fopenmp=libomp
> -fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck
> --check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
> // CHECK-45-VERSION: #define _OPENMP 201511
> +// CHECK-45-VERSION2: #define _OPENMP 201511
>
> // RUN: %clang %s -c -E -dM -fopenmp-version=1 | FileCheck
> --check-prefix=CHECK-VERSION %s
> // RUN: %clang %s -c -E -dM -fopenmp-version=31 | FileCheck
> --check-prefix=CHECK-VERSION %s
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list