Skip to content

[SYCL] Disable inlining kernel lambda operator at -O0 #7578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5095,8 +5095,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-sycl-std=2020");
}

bool DisableSYCLForceInlineKernelLambda = false;
if (Arg *A = Args.getLastArg(options::OPT_O_Group))
DisableSYCLForceInlineKernelLambda =
A->getOption().matches(options::OPT_O0);
// At -O0, disable the inlining for debugging purposes.
if (!Args.hasFlag(options::OPT_fsycl_force_inline_kernel_lambda,
options::OPT_fno_sycl_force_inline_kernel_lambda, true))
options::OPT_fno_sycl_force_inline_kernel_lambda,
!DisableSYCLForceInlineKernelLambda))
CmdArgs.push_back("-fno-sycl-force-inline-kernel-lambda");

if (!Args.hasFlag(options::OPT_fsycl_unnamed_lambda,
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Driver/sycl.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@
// -fsycl-force-inline-kernel-lambda
// RUN: %clangxx -### -fsycl-device-only -fno-sycl-force-inline-kernel-lambda %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
// RUN: %clang_cl -### -fsycl-device-only -fno-sycl-force-inline-kernel-lambda %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
// RUN: %clangxx -### -fsycl-device-only -O0 %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
// RUN: %clang_cl -### -fsycl-device-only -Od %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
// RUN: %clangxx -### -fsycl-device-only -O1 %s 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
// RUN: %clang_cl -### -fsycl-device-only -O2 %s 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
// CHECK-NOT-INLINE: "-fno-sycl-force-inline-kernel-lambda"
// CHECK-INLINE-NOT: "-fno-sycl-force-inline-kernel-lambda"

/// -fsycl-device-only triple checks
// RUN: %clang -fsycl-device-only -target x86_64-unknown-linux-gnu -### %s 2>&1 \
Expand Down
3 changes: 2 additions & 1 deletion sycl/doc/UsersManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ and not recommended to use in production environment.
Enables/Disables inlining of the kernel lambda operator into the compiler
generated entry point function. This flag does not apply to ESIMD
kernels.
Enabled by default.
Disabled when optimizations are disabled (-O0 or equivalent). Enabled
otherwise.

**`-fgpu-inline-threshold=<n>`**

Expand Down