Skip to content

Commit

Permalink
[SYCL][NATIVECPU][DRIVER] Select remangled libclc variant for Native …
Browse files Browse the repository at this point in the history
…CPU (#13765)

This PR makes it so we build the remangled variants for Native CPU
libclc, and ensures that the driver selects it.
  • Loading branch information
PietroGhg authored May 14, 2024
1 parent 7698ff8 commit 5794326
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions buildbot/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ def do_configure(args):
sycl_enabled_plugins.append("hip")

if args.native_cpu:
#Todo: we should set whatever targets we support for native cpu
libclc_targets_to_build += ';x86_64-unknown-linux-gnu'
# Todo: we should set whatever targets we support for native cpu
libclc_targets_to_build += ";x86_64-unknown-linux-gnu"
libclc_gen_remangled_variants = "ON"
sycl_enabled_plugins.append("native_cpu")


Expand Down
9 changes: 7 additions & 2 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5856,8 +5856,13 @@ class OffloadingActionBuilder final {
llvm::sys::path::append(WithInstallPath, Twine("../../../share/clc"));
LibraryPaths.emplace_back(WithInstallPath.c_str());

// Select libclc variant based on target triple
std::string LibSpirvTargetName = "libspirv-";
// Select libclc variant based on target triple.
// On Windows long is 32 bits, so we have to select the right remangled
// libclc version.
std::string LibSpirvTargetName =
(TC->getAuxTriple()->isOSWindows())
? "remangled-l32-signed_char.libspirv-"
: "remangled-l64-signed_char.libspirv-";
LibSpirvTargetName.append(TC->getTripleString() + ".bc");

for (StringRef LibraryPath : LibraryPaths) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
// REQUIRES: native_cpu
// RUN: %clang -### -fsycl -fsycl-targets=native_cpu -target x86_64-unknown-linux-gnu %s 2> %t.ncpu.out
// RUN: FileCheck %s --input-file %t.ncpu.out
// CHECK: libspirv-x86_64-unknown-linux-gnu.bc
// CHECK: {{(\\|/)}}remangled-l64-signed_char.libspirv-x86_64-unknown-linux-gnu.bc"

// Check that l32 variant is selected for Windows
// RUN: %clang -### -fsycl -fsycl-targets=native_cpu -target x86_64-windows %s 2> %t-win.ncpu.out
// RUN: FileCheck %s --input-file %t-win.ncpu.out --check-prefix=CHECK-WIN
// CHECK-WIN: {{(\\|/)}}remangled-l32-signed_char.libspirv-x86_64-unknown-windows-msvc.bc"

0 comments on commit 5794326

Please sign in to comment.