Skip to content

Commit a8ce719

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents b8d0906 + fed32a8 commit a8ce719

34 files changed

+517
-248
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10643,7 +10643,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1064310643

1064410644
// Add any SYCL offloading specific options to the clang-linker-wrapper
1064510645
if (C.hasOffloadToolChain<Action::OFK_SYCL>()) {
10646-
// --sycl-device-libraries=<comma separated list> contains all of the SYCL
10646+
// -sycl-device-libraries=<comma separated list> contains all of the SYCL
1064710647
// device specific libraries that are needed. This provides the list of
1064810648
// files file only.
1064910649
// TODO: This generic list will be populated with only device binaries
@@ -10671,14 +10671,14 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1067110671
LibList += ",";
1067210672
LibList += AddLib;
1067310673
}
10674-
// --sycl-device-libraries=<libs> provides a comma separate list of
10674+
// -sycl-device-libraries=<libs> provides a comma separate list of
1067510675
// libraries to add to the device linking step.
1067610676
// SYCL device libraries can be found.
1067710677
if (LibList.size())
1067810678
CmdArgs.push_back(
10679-
Args.MakeArgString(Twine("--sycl-device-libraries=") + LibList));
10679+
Args.MakeArgString(Twine("-sycl-device-libraries=") + LibList));
1068010680

10681-
// --sycl-device-library-location=<dir> provides the location in which the
10681+
// -sycl-device-library-location=<dir> provides the location in which the
1068210682
// SYCL device libraries can be found.
1068310683
SmallString<128> DeviceLibDir(D.Dir);
1068410684
llvm::sys::path::append(DeviceLibDir, "..", "lib");
@@ -10700,7 +10700,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1070010700
}
1070110701
}
1070210702
CmdArgs.push_back(Args.MakeArgString(
10703-
Twine("--sycl-device-library-location=") + DeviceLibDir));
10703+
Twine("-sycl-device-library-location=") + DeviceLibDir));
1070410704
}
1070510705

1070610706
auto appendOption = [](SmallString<128> &OptString, StringRef AddOpt) {

clang/test/Driver/sycl-offload-new-driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
// RUN: --sysroot=%S/Inputs/SYCL -### %s 2>&1 \
3939
// RUN: | FileCheck -check-prefix WRAPPER_OPTIONS %s
4040
// WRAPPER_OPTIONS: clang-linker-wrapper{{.*}} "--triple=spir64"
41-
// WRAPPER_OPTIONS-SAME: "--sycl-device-libraries=libsycl-crt.o,libsycl-complex.o,libsycl-complex-fp64.o,libsycl-cmath.o,libsycl-cmath-fp64.o,libsycl-imf.o,libsycl-imf-fp64.o,libsycl-imf-bf16.o,libsycl-itt-user-wrappers.o,libsycl-itt-compiler-wrappers.o,libsycl-itt-stubs.o"
42-
// WRAPPER_OPTIONS-SAME: "--sycl-device-library-location={{.*}}/lib"
41+
// WRAPPER_OPTIONS-SAME: "-sycl-device-libraries=libsycl-crt.o,libsycl-complex.o,libsycl-complex-fp64.o,libsycl-cmath.o,libsycl-cmath-fp64.o,libsycl-imf.o,libsycl-imf-fp64.o,libsycl-imf-bf16.o,libsycl-itt-user-wrappers.o,libsycl-itt-compiler-wrappers.o,libsycl-itt-stubs.o"
42+
// WRAPPER_OPTIONS-SAME: "-sycl-device-library-location={{.*}}/lib"
4343

4444
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
4545
// RUN: -Xspirv-translator -translator-opt -### %s 2>&1 \

opencl/opencl-aot/source/main.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ int main(int Argc, char *Argv[]) {
593593
break;
594594
}
595595

596-
std::string CompilerBuildLog;
596+
std::string CompilerBuildLog, CompilerBuildLogMessage;
597597
std::tie(CompilerBuildLog, ErrorMessage, std::ignore) =
598598
getCompilerBuildLog(ProgramUPtr, DeviceId);
599599

@@ -604,18 +604,20 @@ int main(int Argc, char *Argv[]) {
604604
}
605605

606606
if (!CompilerBuildLog.empty()) {
607-
std::string CompilerBuildLogMessage = "\n" +
608-
CmdToCmdInfoMap[OptCommand].first +
609-
" log:\n" + CompilerBuildLog + '\n';
610-
if (!ErrorMessage.empty())
611-
std::cerr << CompilerBuildLogMessage;
612-
else
613-
logs() << CompilerBuildLogMessage;
607+
// According to the return value of getCompilerBuildLog(), ErrorMessage is
608+
// always empty if CompilerBuildLog is not empty.
609+
CompilerBuildLogMessage = "\n" + CmdToCmdInfoMap[OptCommand].first +
610+
" log:\n" + CompilerBuildLog + '\n';
611+
logs() << CompilerBuildLogMessage;
614612
}
615613

616614
if (clFailed(CLErr)) {
617615
std::string ErrMsg =
618616
"Failed to " + CmdToCmdInfoMap[OptCommand].first + ": ";
617+
// will print CompilerBuildLogMessage when build failed in case verbose is
618+
// false, in order to provide a friendlier compile error for users.
619+
if (!verbose)
620+
std::cerr << CompilerBuildLogMessage;
619621
std::cerr << formatCLError(ErrMsg, CLErr) << '\n';
620622
return CLErr;
621623
}

sycl/include/sycl/ext/intel/esimd/detail/half_type_traits.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ template <>
121121
struct is_esimd_arithmetic_type<half_raw_type, void> : std::true_type {};
122122
#endif // __SYCL_DEVICE_ONLY__
123123

124+
template <>
125+
struct is_esimd_arithmetic_type<sycl::half, void> : std::true_type {};
126+
124127
// Misc
125128
inline std::ostream &operator<<(std::ostream &O, sycl::half const &rhs) {
126129
O << static_cast<float>(rhs);

sycl/source/backend/level_zero.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ __SYCL_EXPORT context make_context(const std::vector<device> &DeviceList,
5555
NativeHandle, DeviceHandles.size(), DeviceHandles.data(), !KeepOwnership,
5656
&PiContext);
5757
// Construct the SYCL context from PI context.
58-
return detail::createSyclObjFromImpl<context>(std::make_shared<context_impl>(
59-
PiContext, detail::defaultAsyncHandler, Plugin, !KeepOwnership));
58+
return detail::createSyclObjFromImpl<context>(
59+
std::make_shared<context_impl>(PiContext, detail::defaultAsyncHandler,
60+
Plugin, DeviceList, !KeepOwnership));
6061
}
6162

6263
//----------------------------------------------------------------------------

sycl/source/detail/context_impl.cpp

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,36 @@ context_impl::context_impl(const std::vector<sycl::device> Devices,
7171

7272
context_impl::context_impl(sycl::detail::pi::PiContext PiContext,
7373
async_handler AsyncHandler, const PluginPtr &Plugin,
74+
const std::vector<sycl::device> &DeviceList,
7475
bool OwnedByRuntime)
75-
: MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler), MDevices(),
76-
MContext(PiContext), MPlatform(), MHostContext(false),
77-
MSupportBufferLocationByDevices(NotChecked) {
78-
79-
std::vector<sycl::detail::pi::PiDevice> DeviceIds;
80-
uint32_t DevicesNum = 0;
81-
// TODO catch an exception and put it to list of asynchronous exceptions
82-
Plugin->call<PiApiKind::piContextGetInfo>(
83-
MContext, PI_CONTEXT_INFO_NUM_DEVICES, sizeof(DevicesNum), &DevicesNum,
84-
nullptr);
85-
DeviceIds.resize(DevicesNum);
86-
// TODO catch an exception and put it to list of asynchronous exceptions
87-
Plugin->call<PiApiKind::piContextGetInfo>(
88-
MContext, PI_CONTEXT_INFO_DEVICES,
89-
sizeof(sycl::detail::pi::PiDevice) * DevicesNum, &DeviceIds[0], nullptr);
90-
91-
if (!DeviceIds.empty()) {
92-
std::shared_ptr<detail::platform_impl> Platform =
93-
platform_impl::getPlatformFromPiDevice(DeviceIds[0], Plugin);
94-
for (sycl::detail::pi::PiDevice Dev : DeviceIds) {
95-
MDevices.emplace_back(createSyclObjFromImpl<device>(
96-
Platform->getOrMakeDeviceImpl(Dev, Platform)));
76+
: MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler),
77+
MDevices(DeviceList), MContext(PiContext), MPlatform(),
78+
MHostContext(false), MSupportBufferLocationByDevices(NotChecked) {
79+
if (!MDevices.empty()) {
80+
MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform());
81+
} else {
82+
std::vector<sycl::detail::pi::PiDevice> DeviceIds;
83+
uint32_t DevicesNum = 0;
84+
// TODO catch an exception and put it to list of asynchronous exceptions
85+
Plugin->call<PiApiKind::piContextGetInfo>(
86+
MContext, PI_CONTEXT_INFO_NUM_DEVICES, sizeof(DevicesNum), &DevicesNum,
87+
nullptr);
88+
DeviceIds.resize(DevicesNum);
89+
// TODO catch an exception and put it to list of asynchronous exceptions
90+
Plugin->call<PiApiKind::piContextGetInfo>(
91+
MContext, PI_CONTEXT_INFO_DEVICES,
92+
sizeof(sycl::detail::pi::PiDevice) * DevicesNum, &DeviceIds[0],
93+
nullptr);
94+
95+
if (!DeviceIds.empty()) {
96+
std::shared_ptr<detail::platform_impl> Platform =
97+
platform_impl::getPlatformFromPiDevice(DeviceIds[0], Plugin);
98+
for (sycl::detail::pi::PiDevice Dev : DeviceIds) {
99+
MDevices.emplace_back(createSyclObjFromImpl<device>(
100+
Platform->getOrMakeDeviceImpl(Dev, Platform)));
101+
}
102+
MPlatform = Platform;
97103
}
98-
MPlatform = Platform;
99104
}
100105
// TODO catch an exception and put it to list of asynchronous exceptions
101106
// getPlugin() will be the same as the Plugin passed. This should be taken

sycl/source/detail/context_impl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class context_impl {
7171
/// transferred to runtime
7272
context_impl(sycl::detail::pi::PiContext PiContext,
7373
async_handler AsyncHandler, const PluginPtr &Plugin,
74+
const std::vector<sycl::device> &DeviceList = {},
7475
bool OwnedByRuntime = true);
7576

7677
~context_impl();

sycl/source/detail/graph_impl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,6 @@ void exec_graph_impl::createCommandBuffers(
724724
}
725725

726726
exec_graph_impl::~exec_graph_impl() {
727-
WriteLock LockImpl(MGraphImpl->MMutex);
728-
729-
// clear all recording queue if not done before (no call to end_recording)
730-
MGraphImpl->clearQueues();
731-
732727
const sycl::detail::PluginPtr &Plugin =
733728
sycl::detail::getSyclObjImpl(MContext)->getPlugin();
734729
MSchedule.clear();

sycl/source/detail/scheduler/commands.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,8 +2488,9 @@ pi_int32 enqueueImpCommandBufferKernel(
24882488
}
24892489

24902490
if (Res != pi_result::PI_SUCCESS) {
2491-
throw sycl::exception(errc::invalid,
2492-
"Failed to add kernel to PI command-buffer");
2491+
const device_impl &DeviceImplem = *(DeviceImpl);
2492+
detail::enqueue_kernel_launch::handleErrorOrWarning(Res, DeviceImplem,
2493+
PiKernel, NDRDesc);
24932494
}
24942495

24952496
return Res;

sycl/test-e2e/Basic/float_division_precise.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %{build} -ffp-model=precise -o %t.out
1+
// DEFINE: %{preciseflag} = %if cl_options %{/fp:precise%} %else %{-ffp-model=precise%}
2+
3+
// RUN: %{build} %{preciseflag} -o %t.out
24
// RUN: %{run} %t.out
35

46
// Tests that -ffp-model=precise causes floating point division to be the same
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
// RUN: %{build} -o %t.out %level_zero_options
3+
// RUN: %{run} %t.out
4+
5+
// This test checks that an interop Level Zero device is properly handled during
6+
// interop context construction.
7+
#include <sycl/ext/oneapi/backend/level_zero.hpp>
8+
#include <sycl/sycl.hpp>
9+
10+
#include <level_zero/ze_api.h>
11+
12+
#include <cassert>
13+
#include <iostream>
14+
#include <vector>
15+
16+
int main(int argc, char *argv[]) {
17+
int level0DriverIndex = 0;
18+
int level0DeviceIndex = 0;
19+
20+
zeInit(0);
21+
uint32_t level0NumDrivers = 0;
22+
zeDriverGet(&level0NumDrivers, nullptr);
23+
24+
assert(level0NumDrivers > 0);
25+
26+
std::vector<ze_driver_handle_t> level0Drivers(level0NumDrivers);
27+
zeDriverGet(&level0NumDrivers, level0Drivers.data());
28+
29+
ze_driver_handle_t level0Driver = level0Drivers[level0DriverIndex];
30+
uint32_t level0NumDevices = 0;
31+
zeDeviceGet(level0Driver, &level0NumDevices, nullptr);
32+
33+
assert(level0NumDevices > 0);
34+
35+
std::vector<ze_device_handle_t> level0Devices(level0NumDevices);
36+
zeDeviceGet(level0Driver, &level0NumDevices, level0Devices.data());
37+
38+
ze_device_handle_t level0Device = level0Devices[level0DeviceIndex];
39+
ze_context_handle_t level0Context = nullptr;
40+
ze_context_desc_t level0ContextDesc = {};
41+
level0ContextDesc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC;
42+
zeContextCreateEx(level0Driver, &level0ContextDesc, 1, &level0Device,
43+
&level0Context);
44+
45+
sycl::device dev;
46+
sycl::device interopDev =
47+
sycl::make_device<sycl::backend::ext_oneapi_level_zero>(level0Device);
48+
sycl::context interopCtx =
49+
sycl::make_context<sycl::backend::ext_oneapi_level_zero>(
50+
{level0Context,
51+
{interopDev},
52+
sycl::ext::oneapi::level_zero::ownership::keep});
53+
54+
assert(interopCtx.get_devices().size() == 1);
55+
assert(interopCtx.get_devices()[0] == interopDev);
56+
sycl::queue q{interopCtx, interopDev};
57+
58+
zeContextDestroy(level0Context);
59+
return 0;
60+
}

sycl/test-e2e/DeviceLib/string_test.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// FIXME: enable opaque pointers support on CPU.
99
// UNSUPPORTED: cpu
1010

11-
// https://github.com/intel/llvm/issues/11434
12-
// XFAIL: gpu-intel-dg2
13-
1411
#include <cassert>
1512
#include <cstdint>
1613
#include <cstring>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
//= bfloat16_half_vector_plus_eq_scalar.cpp - Test for bfloat16 operators =//
4+
//
5+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6+
// See https://llvm.org/LICENSE.txt for license information.
7+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
//
9+
//===----------------------------------------------------------------------===//
10+
#include "../esimd_test_utils.hpp"
11+
#include <iostream>
12+
#include <sycl/ext/intel/esimd.hpp>
13+
#include <sycl/sycl.hpp>
14+
15+
using namespace sycl;
16+
using namespace sycl::ext::intel::esimd;
17+
using namespace sycl::ext::intel::experimental::esimd;
18+
19+
template <typename T> ESIMD_NOINLINE bool test(queue Q) {
20+
std::cout << "Testing T=" << esimd_test::type_name<T>() << "...\n";
21+
22+
constexpr int N = 8;
23+
24+
constexpr int NumOps = 4;
25+
constexpr int CSize = NumOps * N;
26+
27+
T *Mem = malloc_shared<T>(CSize, Q);
28+
T TOne = static_cast<T>(1);
29+
T TTen = static_cast<T>(10);
30+
31+
Q.single_task([=]() SYCL_ESIMD_KERNEL {
32+
{
33+
simd<T, N> Vec(TOne);
34+
Vec += TTen;
35+
Vec.copy_to(Mem);
36+
}
37+
{
38+
simd<T, N> Vec(TOne);
39+
Vec -= TTen;
40+
Vec.copy_to(Mem + N);
41+
}
42+
{
43+
simd<T, N> Vec(TOne);
44+
Vec *= TTen;
45+
Vec.copy_to(Mem + 2 * N);
46+
}
47+
{
48+
simd<T, N> Vec(TOne);
49+
Vec /= TTen;
50+
Vec.copy_to(Mem + 3 * N);
51+
}
52+
}).wait();
53+
54+
bool ReturnValue = true;
55+
for (int i = 0; i < N; ++i) {
56+
if (Mem[i] != TOne + TTen) {
57+
ReturnValue = false;
58+
break;
59+
}
60+
if (Mem[i + N] != TOne - TTen) {
61+
ReturnValue = false;
62+
break;
63+
}
64+
if (Mem[i + 2 * N] != TOne * TTen) {
65+
ReturnValue = false;
66+
break;
67+
}
68+
if (!((Mem[i + 3 * N] == (TOne / TTen)) ||
69+
(std::abs((double)(Mem[i + 3 * N] - (TOne / TTen)) /
70+
(double)(TOne / TTen)) <= 0.001))) {
71+
ReturnValue = false;
72+
break;
73+
}
74+
}
75+
76+
free(Mem, Q);
77+
return ReturnValue;
78+
}
79+
80+
int main() {
81+
queue Q;
82+
esimd_test::printTestLabel(Q);
83+
84+
bool SupportsHalf = Q.get_device().has(aspect::fp16);
85+
86+
bool Passed = true;
87+
Passed &= test<int>(Q);
88+
Passed &= test<float>(Q);
89+
if (SupportsHalf) {
90+
Passed &= test<sycl::half>(Q);
91+
}
92+
93+
#ifdef USE_BF16
94+
// TODO: Reenable once the issue with bfloat16 is resolved
95+
// Passed &= test<sycl::ext::oneapi::bfloat16>(Q);
96+
#endif
97+
#ifdef USE_TF32
98+
Passed &= test<sycl::ext::intel::experimental::esimd::tfloat32>(Q);
99+
#endif
100+
std::cout << (Passed ? "Passed\n" : "FAILED\n");
101+
return Passed ? 0 : 1;
102+
}

0 commit comments

Comments
 (0)