Skip to content

Commit

Permalink
Merge branch 'sycl' into sean/copy-const-qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Seanst98 committed Jul 11, 2024
2 parents db0c6a3 + 335ade2 commit 4314f61
Show file tree
Hide file tree
Showing 35 changed files with 277 additions and 288 deletions.
12 changes: 7 additions & 5 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10746,11 +10746,6 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
if (TCArgs.hasFlag(options::OPT_fno_sycl_esimd_force_stateless_mem,
options::OPT_fsycl_esimd_force_stateless_mem, false))
addArgs(PostLinkArgs, TCArgs, {"-lower-esimd-force-stateless-mem=false"});

bool IsUsingLTO = TC.getDriver().isUsingLTO(/*IsDeviceOffloadAction=*/true);
auto LTOMode = TC.getDriver().getLTOMode(/*IsDeviceOffloadAction=*/true);
if (!IsUsingLTO || LTOMode != LTOK_Thin)
addArgs(PostLinkArgs, TCArgs, {"-properties"});
}

// Add any sycl-post-link options that rely on a specific Triple in addition
Expand All @@ -10765,11 +10760,18 @@ static void getTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
llvm::Triple Triple,
bool SpecConstsSupported,
types::ID OutputType) {

bool IsUsingLTO = TC.getDriver().isUsingLTO(/*IsDeviceOffloadAction=*/true);
auto LTOMode = TC.getDriver().getLTOMode(/*IsDeviceOffloadAction=*/true);
if (OutputType == types::TY_LLVM_BC) {
// single file output requested - this means only perform necessary IR
// transformations (like specialization constant intrinsic lowering) and
// output LLVMIR
addArgs(PostLinkArgs, TCArgs, {"-ir-output-only"});
} else if (!IsUsingLTO || LTOMode != LTOK_Thin) {
// Only create a properties file if we are not
// only outputting IR.
addArgs(PostLinkArgs, TCArgs, {"-properties"});
}
if (SpecConstsSupported)
addArgs(PostLinkArgs, TCArgs, {"-spec-const=native"});
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-offload-new-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
// RUN: -Xdevice-post-link -post-link-opt -### %s 2>&1 \
// RUN: | FileCheck -check-prefix WRAPPER_OPTIONS_POSTLINK %s
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-O2 -device-globals -properties -post-link-opt"
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-O2 -device-globals -post-link-opt"

// -fsycl-device-only behavior
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-post-link-options-win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
// RUN: -sycl-device-libraries=%t.devicelib.o \
// RUN: --sycl-post-link-options="-O2 -device-globals -O0" \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck --check-prefix OPTIONS_POSTLINK_JIT_NEW %s
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -properties -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0
4 changes: 2 additions & 2 deletions clang/test/Driver/sycl-post-link-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
//
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
// RUN: -sycl-device-libraries=%t.devicelib.o \
// RUN: --sycl-post-link-options="-O2 -device-globals -properties -O0" \
// RUN: --sycl-post-link-options="-O2 -device-globals -O0" \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck --check-prefix OPTIONS_POSTLINK_JIT_NEW %s
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -properties -O0
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -properties -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0
3 changes: 3 additions & 0 deletions clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ getTripleBasedSYCLPostLinkOpts(const ArgList &Args,
else
PostLinkArgs.push_back("-spec-const=emulation");

if (Triple.isSPIROrSPIRV() || SYCLNativeCPU)
PostLinkArgs.push_back("-properties");

// See if device code splitting is already requested. If not requested, then
// set -split=auto for non-FPGA targets.
bool NoSplit = true;
Expand Down
4 changes: 1 addition & 3 deletions sycl/include/sycl/ext/oneapi/backend/hip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ inline namespace _V1 {
template <>
inline backend_return_t<backend::ext_oneapi_hip, device>
get_native<backend::ext_oneapi_hip, device>(const device &Obj) {
// TODO swap with SYCL 2020 exception when in ABI-break window
if (Obj.get_backend() != backend::ext_oneapi_hip) {
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
PI_ERROR_INVALID_OPERATION);
throw exception(errc::backend_mismatch, "Backends mismatch");
}
// HIP uses a 32-bit int instead of an opaque pointer like other backends,
// so we need a specialization with static_cast instead of reinterpret_cast.
Expand Down
16 changes: 8 additions & 8 deletions sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fabs(T x) {
return __clc_fabs(x);
#else
(void)x;
throw runtime_error("bf16 is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"bf16 is not supported on host.");
#endif
}
template <typename T>
Expand All @@ -60,8 +60,8 @@ std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fmin(T x, T y) {
#else
(void)x;
(void)y;
throw runtime_error("bf16 is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"bf16 is not supported on host.");
#endif
}
template <typename T>
Expand All @@ -71,8 +71,8 @@ std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fmax(T x, T y) {
#else
(void)x;
(void)y;
throw runtime_error("bf16 is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"bf16 is not supported on host.");
#endif
}
template <typename T>
Expand All @@ -83,8 +83,8 @@ std::enable_if_t<detail::is_bf16_storage_type<T>::value, T> fma(T x, T y, T z) {
(void)x;
(void)y;
(void)z;
throw runtime_error("bf16 is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"bf16 is not supported on host.");
#endif
}

Expand Down
Loading

0 comments on commit 4314f61

Please sign in to comment.