Skip to content

[Driver][SYCL] Generalize huge device code driver option name #9888

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
Jun 22, 2023
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
14 changes: 10 additions & 4 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3058,12 +3058,18 @@ defm sycl_instrument_device_code
BothFlags<[CC1Option, CoreOption], " Instrumentation and Tracing "
"Technology (ITT) instrumentation intrinsics calls "
"(experimental)">>;
def fsycl_link_huge_device_code : Flag<["-"], "fsycl-link-huge-device-code">,
Group<sycl_Group>, HelpText<"Generate and use a custom linker script for huge"
def flink_huge_device_code : Flag<["-"], "flink-huge-device-code">,
Group<Link_Group>, HelpText<"Generate and use a custom linker script for huge"
" device code sections">;
def fno_sycl_link_huge_device_code : Flag<["-"], "fno-sycl-link-huge-device-code">,
Group<sycl_Group>, HelpText<"Do not generate or use a custom linker script"
def fno_link_huge_device_code : Flag<["-"], "fno-link-huge-device-code">,
Group<Link_Group>, HelpText<"Do not generate or use a custom linker script"
" for huge device code sections (default)">;
def fsycl_link_huge_device_code : Flag<["-"], "fsycl-link-huge-device-code">,
Group<sycl_Group>, Alias<flink_huge_device_code>, HelpText<"Generate and use a custom linker script for huge"
" device code sections (deprecated)">, Flags<[Deprecated]>;
def fno_sycl_link_huge_device_code : Flag<["-"], "fno-sycl-link-huge-device-code">,
Group<sycl_Group>, Alias<fno_link_huge_device_code>, HelpText<"Do not generate or use a custom linker script"
" for huge device code sections (default) (deprecated)">, Flags<[Deprecated]>;
defm sycl_id_queries_fit_in_int: BoolFOption<"sycl-id-queries-fit-in-int",
LangOpts<"SYCLValueFitInMaxInt">, DefaultTrue,
PosFlag<SetTrue, [], "Assume">, NegFlag<SetFalse, [], "Do not assume">,
Expand Down
11 changes: 8 additions & 3 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,14 @@ InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
}

// Deprecated options emit a diagnostic about deprecation, but are still
// supported until removed.
if (A->getOption().hasFlag(options::Deprecated)) {
Diag(diag::warn_drv_deprecated_option_release) << A->getAsString(Args);
// supported until removed. It's possible to have a deprecated option which
// aliases with a non-deprecated option, so always compute the argument
// actually used before checking for deprecation.
const Arg *Used = A;
while (Used->getAlias())
Used = Used->getAlias();
if (Used->getOption().hasFlag(options::Deprecated)) {
Diag(diag::warn_drv_deprecated_option_release) << Used->getAsString(Args);
ContainsError |= Diags.getDiagnosticLevel(
diag::warn_drv_deprecated_option_release,
SourceLocation()) > DiagnosticsEngine::Warning;
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,

// If requested, use a custom linker script to handle very large device code
// sections.
if (Args.hasArg(options::OPT_fsycl) &&
Args.hasFlag(options::OPT_fsycl_link_huge_device_code,
options::OPT_fno_sycl_link_huge_device_code, false)) {
if (Args.hasArg(options::OPT_fsycl, options::OPT_fopenmp_targets_EQ) &&
Args.hasFlag(options::OPT_flink_huge_device_code,
options::OPT_fno_link_huge_device_code, false)) {
// Create temporary linker script. Keep it if save-temps is enabled.
const char *LKS;
SmallString<256> Name = llvm::sys::path::filename(Output.getFilename());
Expand Down Expand Up @@ -704,12 +704,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
ScriptOS
<< "/*\n"
" * This linker script allows huge (>3GB) device code\n"
" * sections. It has been auto-generated by the SYCL driver.\n"
" * sections. It has been auto-generated by the driver.\n"
" */\n"
"SECTIONS\n"
"{\n"
" . = SEGMENT_START(\"sycl-device-code\", .);\n"
" SYCL_DEVICE_CODE ALIGN(CONSTANT (MAXPAGESIZE)) + (. & "
" . = SEGMENT_START(\"offload-device-code\", .);\n"
" OFFLOAD_DEVICE_CODE ALIGN(CONSTANT (MAXPAGESIZE)) + (. & "
"(CONSTANT (MAXPAGESIZE) - 1)) :\n"
" {\n"
" *(__CLANG_OFFLOAD_BUNDLE__*)\n"
Expand Down
24 changes: 24 additions & 0 deletions clang/test/Driver/flink-huge-device-code.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// UNSUPPORTED: system-windows
// Test the addition of a custom linker script for huge device code.

// The "fsycl-link-huge-device-code" spelling is deprecated.

// RUN: %clangxx -### -fsycl -fsycl-link-huge-device-code %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-LINKER-SCRIPT %s
// RUN: %clangxx -### -fsycl -flink-huge-device-code %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-LINKER-SCRIPT %s
// RUN: %clangxx -### -fopenmp -fopenmp-targets=x86_64 -flink-huge-device-code %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-LINKER-SCRIPT %s
// CHECK-LINKER-SCRIPT: "-T" "{{.*}}.ld"

// Also check that a user-provided linker script may be used:
// RUN: %clangxx -### -fsycl -fsycl-link-huge-device-code %s \
// RUN: -T custom-user-script.ld 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK-USER-SCRIPT %s
// RUN: %clangxx -### -fsycl -flink-huge-device-code %s \
// RUN: -T custom-user-script.ld 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK-USER-SCRIPT %s
// RUN: %clangxx -### -fopenmp -fopenmp-targets=x86_64 -flink-huge-device-code %s \
// RUN: -T custom-user-script.ld 2>&1 | \
// RUN: FileCheck --check-prefixes=CHECK-USER-SCRIPT %s
// CHECK-USER-SCRIPT: "-T" "custom-user-script.ld"
2 changes: 2 additions & 0 deletions clang/test/Driver/sycl-deprecated.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// Test for any deprecated options
// RUN: %clangxx -fsycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-explicit-simd
// RUN: %clangxx -fno-sycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-explicit-simd
// RUN: %clangxx -fsycl -fsycl-link-huge-device-code %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-link-huge-device-code
// RUN: %clangxx -fsycl -fno-sycl-link-huge-device-code %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-link-huge-device-code
// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release

// RUN: %clangxx -fsycl -sycl-std=1.2.1 %s -### 2>&1 \
Expand Down
12 changes: 0 additions & 12 deletions clang/test/Driver/sycl-huge-device-code-linker-script.cpp

This file was deleted.

4 changes: 3 additions & 1 deletion sycl/doc/UsersManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ and not recommended to use in production environment.
various events inside JIT generated kernels. These device libraries are
linked in by default.

**`-f[no-]sycl-link-huge-device-code`**
**`-f[no-]sycl-link-huge-device-code`** [DEPRECATED]

Place device code later in the linked binary in order to avoid precluding
32-bit PC relative relocations between surrounding ELF sections when device
code is larger than 2GiB. This is disabled by default.

Deprecated in favor of `-f[no-]link-huge-device-code`.

NOTE: This option is currently only supported on Linux.

**`-fsycl-force-target=<T>`**
Expand Down