Skip to content

Add option "-fsycl-allow-device-image-dependencies" #15407

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
Sep 24, 2024
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
11 changes: 9 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -7025,9 +7025,16 @@ def fsycl_remove_unused_external_funcs : Flag<["-"], "fsycl-remove-unused-extern
def fno_sycl_remove_unused_external_funcs : Flag<["-"], "fno-sycl-remove-unused-external-funcs">,
HelpText<"Prevent removal of unused `SYCL_EXTERNAL` functions">;
def fsycl_allow_device_dependencies : Flag<["-"], "fsycl-allow-device-dependencies">,
HelpText<"Allow dependencies between device code images">;
HelpText<"Deprecated: please use -fsycl-allow-device-image-dependencies instead.">,
Flags<[Deprecated]>;
def fno_sycl_allow_device_dependencies : Flag<["-"], "fno-sycl-allow-device-dependencies">,
HelpText<"Do not allow dependencies between device code images (default)">;
HelpText<"Deprecated: please use -fno-sycl-allow-device-image-dependencies instead.">,
Flags<[Deprecated]>;

defm sycl_allow_device_image_dependencies: BoolOptionWithoutMarshalling<"f", "sycl-allow-device-image-dependencies",
PosFlag<SetTrue, [], [ClangOption], "Allow dependencies between device code images">,
NegFlag<SetFalse, [], [ClangOption], "Do not allow dependencies between device code images (default)">>;

def fsycl_dump_device_code_EQ : Joined<["-"], "fsycl-dump-device-code=">,
Flags<[NoXarchOption]>,
HelpText<"Dump device code into the user provided directory.">;
Expand Down
13 changes: 10 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10791,10 +10791,17 @@ static void addArgs(ArgStringList &DstArgs, const llvm::opt::ArgList &Alloc,
}
}

static bool allowDeviceDependencies(const llvm::opt::ArgList &TCArgs) {
static bool allowDeviceImageDependencies(const llvm::opt::ArgList &TCArgs) {
// deprecated
if (TCArgs.hasFlag(options::OPT_fsycl_allow_device_dependencies,
options::OPT_fno_sycl_allow_device_dependencies, false))
return true;

// preferred
if (TCArgs.hasFlag(options::OPT_fsycl_allow_device_image_dependencies,
options::OPT_fno_sycl_allow_device_image_dependencies, false))
return true;

return false;
}

Expand Down Expand Up @@ -10825,7 +10832,7 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
options::OPT_fsycl_esimd_force_stateless_mem, false))
addArgs(PostLinkArgs, TCArgs, {"-lower-esimd-force-stateless-mem=false"});

if (allowDeviceDependencies(TCArgs))
if (allowDeviceImageDependencies(TCArgs))
addArgs(PostLinkArgs, TCArgs, {"-allow-device-image-dependencies"});
}

Expand All @@ -10843,7 +10850,7 @@ static bool shouldEmitOnlyKernelsAsEntryPoints(const ToolChain &TC,
return true;
// When supporting dynamic linking, non-kernels in a device image can be
// called.
if (allowDeviceDependencies(TCArgs))
if (allowDeviceImageDependencies(TCArgs))
return false;
if (Triple.isNVPTX() || Triple.isAMDGPU())
return false;
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/sycl-deprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
// RUN: %clangxx -fno-sycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-explicit-simd
// RUN: %clangxx -fsycl -fsycl-use-bitcode %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-use-bitcode
// RUN: %clangxx -fsycl -fno-sycl-use-bitcode %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-use-bitcode
// RUN: %clangxx -fsycl -fsycl-allow-device-dependencies %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-allow-device-dependencies
// RUN: %clangxx -fsycl -fno-sycl-allow-device-dependencies %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-allow-device-dependencies
// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release
14 changes: 7 additions & 7 deletions clang/test/Driver/sycl-offload-old-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_OPT_PASS %s
// CHECK_SYCL_POST_LINK_OPT_PASS: sycl-post-link{{.*}}emit-only-kernels-as-entry-points
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fno-sycl-remove-unused-external-funcs %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_OPT_NO_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fsycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_OPT_NO_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fsycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_OPT_NO_PASS %s
// CHECK_SYCL_POST_LINK_OPT_NO_PASS-NOT: sycl-post-link{{.*}}emit-only-kernels-as-entry-points

/// Check selective passing of -allow-device-image-dependencies to sycl-post-link tool
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_fpga -fsycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fsycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fno-sycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_NO_PASS %s
// RUN: %clang_cl -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_fpga -fsycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang_cl -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fsycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang_cl -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fno-sycl-allow-device-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_NO_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_fpga -fsycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fsycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fno-sycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_NO_PASS %s
// RUN: %clang_cl -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_fpga -fsycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang_cl -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fsycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_PASS %s
// RUN: %clang_cl -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen -fno-sycl-allow-device-image-dependencies %s 2>&1 | FileCheck -check-prefix=CHECK_SYCL_POST_LINK_ADID_NO_PASS %s

// CHECK_SYCL_POST_LINK_ADID_PASS: sycl-post-link{{.*}}allow-device-image-dependencies
// CHECK_SYCL_POST_LINK_ADID_NO_PASS-NOT: sycl-post-link{{.*}}allow-device-image-dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Test -fsycl-allow-device-dependencies with dynamic libraries.
// Test -fsycl-allow-device-image-dependencies with dynamic libraries.

// UNSUPPORTED: cuda || hip

// DEFINE: %{dynamic_lib_options} = -fsycl %fPIC %shared_lib -fsycl-allow-device-dependencies -I %S/Inputs %if windows %{-DMAKE_DLL %}
// DEFINE: %{dynamic_lib_options} = -fsycl %fPIC %shared_lib -fsycl-allow-device-image-dependencies -I %S/Inputs %if windows %{-DMAKE_DLL %}
// DEFINE: %{dynamic_lib_suffix} = %if windows %{dll%} %else %{so%}

// RUN: %clangxx %{dynamic_lib_options} %S/Inputs/d.cpp -o %T/libdevice_d.%{dynamic_lib_suffix}
// RUN: %clangxx %{dynamic_lib_options} %S/Inputs/c.cpp %if windows %{%T/libdevice_d.lib%} -o %T/libdevice_c.%{dynamic_lib_suffix}
// RUN: %clangxx %{dynamic_lib_options} %S/Inputs/b.cpp %if windows %{%T/libdevice_c.lib%} -o %T/libdevice_b.%{dynamic_lib_suffix}
// RUN: %clangxx %{dynamic_lib_options} %S/Inputs/a.cpp %if windows %{%T/libdevice_b.lib%} -o %T/libdevice_a.%{dynamic_lib_suffix}

// RUN: %{build} -fsycl-allow-device-dependencies -I %S/Inputs -o %t.out \
// RUN: %{build} -fsycl-allow-device-image-dependencies -I %S/Inputs -o %t.out \
// RUN: %if windows \
// RUN: %{%T/libdevice_a.lib%} \
// RUN: %else \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Test -fsycl-allow-device-dependencies with objects.
// Test -fsycl-allow-device-image-dependencies with objects.

// UNSUPPORTED: cuda || hip

// RUN: %clangxx -fsycl %S/Inputs/a.cpp -I %S/Inputs -c -o %t_a.o
// RUN: %clangxx -fsycl %S/Inputs/b.cpp -I %S/Inputs -c -o %t_b.o
// RUN: %clangxx -fsycl %S/Inputs/c.cpp -I %S/Inputs -c -o %t_c.o
// RUN: %clangxx -fsycl %S/Inputs/d.cpp -I %S/Inputs -c -o %t_d.o
// RUN: %{build} -fsycl-allow-device-dependencies %t_a.o %t_b.o %t_c.o %t_d.o -I %S/Inputs -o %t.out
// RUN: %{build} -fsycl-allow-device-image-dependencies %t_a.o %t_b.o %t_c.o %t_d.o -I %S/Inputs -o %t.out
// RUN: %{run} %t.out

#include "a.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Test -fsycl-allow-device-dependencies with a single dynamic library on Windows
// Test -fsycl-allow-device-image-dependencies with a single dynamic library on Windows
// and Linux.

// UNSUPPORTED: cuda || hip

// RUN: %clangxx -fsycl %fPIC %shared_lib -fsycl-allow-device-dependencies -I %S/Inputs \
// RUN: %clangxx -fsycl %fPIC %shared_lib -fsycl-allow-device-image-dependencies -I %S/Inputs \
// RUN: %S/Inputs/a.cpp \
// RUN: %S/Inputs/b.cpp \
// RUN: %S/Inputs/c.cpp \
Expand Down
Loading