Skip to content

Commit 207da46

Browse files
authored
[sycl-rel] Cherry-pick sycl patches (#18887)
Cherry-pick commits that reached the internal branch between intel/llvm cutoff and release branch pulldown. Patches included: [SYCL][E2E] Fix DeviceLib/assert-windows.cpp run-time errors (#17493) Patch-by: David Garcia Orozco <[email protected]> --- [SYCL] Fix memory leak. (#17632) According to https://github.com/llvm/llvm-project/blob/main/llvm/unittests/Demangle/OutputBufferTest.cpp, `OutputBuffer` has to be manually freed. Patch-by: Marcos Maronas <[email protected]> --- [SYCL][E2E][Matrix] Cleanup of xfail and unsupported (#17688) Patch-by: Dounia Khaldi <[email protected]> --- [SYCL][E2E][Matrix] Restrict XFAIL in some tests to DG2 (#17639) XPASSing in [nightly](https://github.com/intel/llvm/actions/runs/14050841978) but failing in pre/postcommit, make them XFAIL only where they actually fail. Patch-by: Nick Sarnie <[email protected]> --- [SYCL][ESIMD] Move RAII deleter init after buffer allocation. (#17706) The buffer seems to be allocated in the call to `NameNode->print(NameBuf)`, so we need to move the RAII deleter after that call, otherwise the buffer keeps leaking because when the RAII deleter is created, there's no buffer yet. Patch-by: Marcos Maronas <[email protected]> --- [SYCL] Add spill_memory_size unittest (#17657) This adds a unittest for the kernel queries extension according to #17593. Patch-by: Petr Kurapov <[email protected]> --- [SYCL][Bindless][E2E] Add 1D host USM tests (#17374) Adds 1D Host USM backed image tests. This patch also fixes device aspect queries for 1D & 2D USM backed image sampling support. Patch-by: przemektmalon <[email protected]>
1 parent c8a55e8 commit 207da46

15 files changed

+360
-30
lines changed

llvm/lib/SYCLLowerIR/ESIMD/ESIMDVerifier.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ static const char *LegalSYCLFunctionsInStatelessMode[] = {
8989

9090
namespace {
9191

92+
class BuffDeleter {
93+
public:
94+
BuffDeleter(char *Buffer) : Buff(Buffer) {};
95+
~BuffDeleter() { std::free(Buff); };
96+
97+
BuffDeleter() = delete;
98+
BuffDeleter(const BuffDeleter &) = delete;
99+
BuffDeleter(BuffDeleter &&) = delete;
100+
101+
private:
102+
char *Buff;
103+
};
104+
92105
class ESIMDVerifierImpl {
93106
const Module &M;
94107
bool MayNeedForceStatelessMemModeAPI;
@@ -150,6 +163,7 @@ class ESIMDVerifierImpl {
150163

151164
id::OutputBuffer NameBuf;
152165
NameNode->print(NameBuf);
166+
BuffDeleter NameBufDeleter(NameBuf.getBuffer());
153167
StringRef Name(NameBuf.getBuffer(), NameBuf.getCurrentPosition());
154168

155169
// We are interested in functions defined in SYCL namespace, but

sycl/source/detail/device_impl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,17 +671,15 @@ bool device_impl::has(aspect Aspect) const {
671671
ur_bool_t support = false;
672672
bool call_successful =
673673
getAdapter()->call_nocheck<UrApiKind::urDeviceGetInfo>(
674-
MDevice,
675-
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_SUPPORT_EXP,
674+
MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLE_1D_USM_SUPPORT_EXP,
676675
sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS;
677676
return call_successful && support;
678677
}
679678
case aspect::ext_oneapi_bindless_images_sample_2d_usm: {
680679
ur_bool_t support = false;
681680
bool call_successful =
682681
getAdapter()->call_nocheck<UrApiKind::urDeviceGetInfo>(
683-
MDevice,
684-
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_SUPPORT_EXP,
682+
MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLE_2D_USM_SUPPORT_EXP,
685683
sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS;
686684
return call_successful && support;
687685
}

sycl/test-e2e/DeviceLib/assert-windows.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
// REQUIRES: cpu,windows
1+
// REQUIRES: windows
2+
// XFAIL: opencl && gpu
3+
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364
24
//
3-
// RUN: %{build} -o %t.out
5+
// RUN: %{build} -DSYCL_FALLBACK_ASSERT=1 -o %t.out
46
//
5-
// MSVC implementation of assert does not call an unreachable built-in, so the
6-
// program doesn't terminate when fallback is used.
7-
//
8-
// FIXME: SPIR-V Unreachable should be called from the fallback
9-
// explicitly. Since the test is going to crash, we'll have to follow a similar
10-
// approach as on Linux - call the test in a subprocess.
11-
//
12-
// RUN: env SYCL_UR_TRACE=2 SYCL_DEVICELIB_INHIBIT_NATIVE=1 CL_CONFIG_USE_VECTORIZER=False %{run} %t.out | FileCheck %s --check-prefix=CHECK-FALLBACK
13-
// RUN: env SHOULD_CRASH=1 SYCL_DEVICELIB_INHIBIT_NATIVE=1 CL_CONFIG_USE_VECTORIZER=False %{run} %t.out | FileCheck %s --check-prefix=CHECK-MESSAGE
7+
// RUN: not env SHOULD_CRASH=1 SYCL_DEVICELIB_INHIBIT_NATIVE=1 CL_CONFIG_USE_VECTORIZER=False \
8+
// RUN: %{run} %t.out 2>&1 >/dev/null | FileCheck %s --check-prefix=CHECK-MESSAGE
149
//
1510
// CHECK-MESSAGE: {{.*}}assert-windows.cpp:{{[0-9]+}}: (null): global id:
1611
// [{{[0-3]}},0,0], local id: [{{[0-3]}},0,0] Assertion `accessorC[wiID] == 0 &&
1712
// "Invalid value"` failed.
18-
//
19-
// CHECK-FALLBACK: <--- urProgramLink
2013

2114
#include "../helpers.hpp"
2215
#include <array>

sycl/test-e2e/Matrix/SG32/get_coordinate_ops.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
// REQUIRES: aspect-ext_intel_matrix
1616
// REQUIRES-INTEL-DRIVER: lin: 30049, win: 101.4943
1717

18-
// XFAIL: arch-intel_gpu_pvc
19-
// XFAIL-TRACKER: GSD-10524
20-
2118
// RUN: %{build} -o %t.out
2219
// RUN: %{run} %t.out
2320

sycl/test-e2e/Matrix/SG32/joint_matrix_annotated_ptr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
// UNSUPPORTED-INTENDED: aspect-ext_intel_matrix isn't currently supported for
1010
// other triples
1111

12+
// UNSUPPORTED: gpu-intel-dg2
13+
// UNSUPPORTED-INTENDED: SG size = 32 is not currently supported for SYCL Joint
14+
// Matrix by IGC on DG2
15+
1216
// REQUIRES: aspect-ext_intel_matrix
1317
// REQUIRES-INTEL-DRIVER: lin: 27501, win: 101.4943
1418

15-
// XFAIL: run-mode && gpu-intel-dg2
16-
// XFAIL-TRACKER: GSD-4181
17-
1819
// RUN: %{build} -o %t.out
1920
// RUN: %{run} %t.out
2021

sycl/test-e2e/Matrix/SG32/joint_matrix_colA_rowB_colC.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
// UNSUPPORTED-INTENDED: aspect-ext_intel_matrix isn't currently supported for
1010
// other triples
1111

12+
// UNSUPPORTED: gpu-intel-dg2
13+
// UNSUPPORTED-INTENDED: SG size = 32 is not currently supported for SYCL Joint
14+
// Matrix by IGC on DG2
15+
1216
// REQUIRES: aspect-ext_intel_matrix
1317
// REQUIRES-INTEL-DRIVER: lin: 27501, win: 101.4943
1418

15-
// XFAIL: run-mode && gpu-intel-dg2
16-
// XFAIL-TRACKER: GSD-5768
17-
1819
// RUN: %{build} -o %t.out
1920
// RUN: %{run} %t.out
2021

sycl/test-e2e/Matrix/SG32/joint_matrix_int8_colmajorA_colmajorB.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
// RUN: %{run} %t.out
1717

1818
// This tests support of col major layout for matrix B which does transpose and
19-
// then VNNI transform. This is currently only available on AMX
19+
// then VNNI transform. This is currently only available on AMX and PVC
2020

21-
// XFAIL: gpu
21+
// XFAIL: arch-intel_gpu_bmg_g21
2222
// XFAIL-TRACKER: GSD-5768
2323

24+
// UNSUPPORTED: gpu-intel-dg2
25+
// UNSUPPORTED-INTENDED: SG size = 32 is not currently supported for SYCL Joint Matrix by IGC on DG2
26+
2427
#include "common.hpp"
2528

2629
using namespace sycl;

sycl/test-e2e/Matrix/joint_matrix_int8_colmajorA_colmajorB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// RUN: %{run} %t.out
1616

1717
// This tests support of col major layout for matrix B which does transpose and
18-
// then VNNI transform. This is currently only available on AMX
18+
// then VNNI transform. This is currently only available on AMX and PVC
1919

20-
// XFAIL: gpu
20+
// XFAIL: gpu-intel-dg2 || arch-intel_gpu_bmg_g21
2121
// XFAIL-TRACKER: GSD-5768
2222

2323
#include "common.hpp"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// REQUIRES: aspect-ext_oneapi_bindless_images
2+
// REQUIRES: aspect-ext_oneapi_bindless_sampled_image_fetch_1d_usm
3+
// UNSUPPORTED: target-amd
4+
// UNSUPPORTED-INTENDED: Sampled fetch not currently supported on AMD
5+
6+
// RUN: %{build} -o %t.out
7+
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out
8+
9+
#include <iostream>
10+
#include <sycl/detail/core.hpp>
11+
#include <sycl/ext/oneapi/bindless_images.hpp>
12+
#include <sycl/usm.hpp>
13+
14+
class kernel_sampled_fetch;
15+
16+
// Uncomment to print additional test information
17+
// #define VERBOSE_PRINT
18+
19+
int main() {
20+
sycl::device dev;
21+
sycl::queue q(dev);
22+
auto ctxt = q.get_context();
23+
24+
// Declare image size, and expected output and actual output vectors
25+
constexpr size_t width = 32;
26+
constexpr size_t widthInBytes = width * sizeof(float);
27+
std::vector<float> out(width);
28+
std::vector<float> expected(width);
29+
for (int i = 0; i < width; ++i) {
30+
expected[i] = static_cast<float>(i);
31+
}
32+
33+
namespace syclexp = sycl::ext::oneapi::experimental;
34+
35+
try {
36+
// Extension: image descriptor
37+
syclexp::image_descriptor desc({width}, 1, sycl::image_channel_type::fp32);
38+
39+
// Extension: Image creation requires a sampler, but it will have no effect
40+
// on the result, as we will use `fetch_image` in the kernel.
41+
syclexp::bindless_image_sampler samp(
42+
sycl::addressing_mode::repeat,
43+
sycl::coordinate_normalization_mode::normalized,
44+
sycl::filtering_mode::linear);
45+
46+
// Allocate Host USM and initialize with expected data
47+
float *imgMem = sycl::malloc_host<float>(width, q);
48+
memcpy(imgMem, expected.data(), widthInBytes);
49+
50+
// Extension: create the image backed by Host USM and return the handle
51+
auto imgHandle = syclexp::create_image(imgMem, 0, samp, desc, q);
52+
53+
// Create a buffer to output the result from `fetch_image`
54+
sycl::buffer outBuf(out.data(), sycl::range{width});
55+
q.submit([&](sycl::handler &cgh) {
56+
sycl::accessor outAcc{outBuf, cgh, sycl::write_only};
57+
58+
cgh.parallel_for<kernel_sampled_fetch>(width, [=](sycl::id<1> id) {
59+
// Extension: fetch data from sampled image handle
60+
outAcc[id] = syclexp::fetch_image<float>(imgHandle, int(id[0]));
61+
});
62+
});
63+
64+
q.wait_and_throw();
65+
66+
// Extension: cleanup
67+
syclexp::destroy_image_handle(imgHandle, dev, ctxt);
68+
sycl::free(imgMem, ctxt);
69+
} catch (sycl::exception e) {
70+
std::cerr << "SYCL exception caught! : " << e.what() << "\n";
71+
return 1;
72+
} catch (...) {
73+
std::cerr << "Unknown exception caught!\n";
74+
return 2;
75+
}
76+
77+
// collect and validate output
78+
bool validated = true;
79+
for (int i = 0; i < width; i++) {
80+
bool mismatch = false;
81+
if (out[i] != expected[i]) {
82+
mismatch = true;
83+
validated = false;
84+
}
85+
86+
if (mismatch) {
87+
#ifdef VERBOSE_PRINT
88+
std::cout << "Result mismatch! Expected: " << expected[i]
89+
<< ", Actual: " << out[i] << std::endl;
90+
#else
91+
break;
92+
#endif
93+
}
94+
}
95+
if (validated) {
96+
std::cout << "Test passed!" << std::endl;
97+
return 0;
98+
}
99+
100+
std::cout << "Test failed!" << std::endl;
101+
return 3;
102+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// REQUIRES: aspect-ext_oneapi_bindless_images
2+
// REQUIRES: aspect-ext_oneapi_bindless_images_sample_1d_usm
3+
4+
// UNSUPPORTED: hip
5+
// UNSUPPORTED-INTENDED: Host USM backed image support is not yet enabled in UR
6+
// adapter. Also, when provionally enabled, the test crashes upon image
7+
// creation, whereas Device USM backed images do not crash. This issue is
8+
// undetermined.
9+
10+
// RUN: %{build} -o %t.out
11+
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out
12+
13+
#include <cmath>
14+
#include <iostream>
15+
#include <sycl/detail/core.hpp>
16+
17+
#include <sycl/ext/oneapi/bindless_images.hpp>
18+
#include <sycl/usm.hpp>
19+
20+
// Uncomment to print additional test information
21+
// #define VERBOSE_PRINT
22+
23+
class sample_host_usm_image_kernel;
24+
25+
int main() {
26+
27+
sycl::device dev;
28+
sycl::queue q(dev);
29+
auto ctxt = q.get_context();
30+
31+
// declare image data
32+
size_t width = 32;
33+
size_t widthInBytes = width * sizeof(float);
34+
std::vector<float> out(width);
35+
std::vector<float> expected(width);
36+
for (int i = 0; i < width; ++i) {
37+
expected[i] = static_cast<float>(i);
38+
}
39+
40+
try {
41+
sycl::ext::oneapi::experimental::bindless_image_sampler samp(
42+
sycl::addressing_mode::clamp,
43+
sycl::coordinate_normalization_mode::normalized,
44+
sycl::filtering_mode::linear);
45+
46+
// Extension: image descriptor
47+
sycl::ext::oneapi::experimental::image_descriptor desc(
48+
{width}, 1, sycl::image_channel_type::fp32);
49+
50+
// Host USM allocation
51+
float *imgMem = sycl::malloc_host<float>(width, ctxt);
52+
53+
if (imgMem == nullptr) {
54+
std::cerr << "Error allocating host USM!" << std::endl;
55+
return 1;
56+
}
57+
58+
// Initialize input data
59+
for (int i = 0; i < width; ++i) {
60+
imgMem[i] = static_cast<float>(i);
61+
}
62+
63+
// Extension: create the image and return the handle
64+
sycl::ext::oneapi::experimental::sampled_image_handle imgHandle =
65+
sycl::ext::oneapi::experimental::create_image(imgMem, 0 /* pitch */,
66+
samp, desc, dev, ctxt);
67+
68+
sycl::buffer<float, 1> buf((float *)out.data(), sycl::range<1>{width});
69+
q.submit([&](sycl::handler &cgh) {
70+
auto outAcc =
71+
buf.get_access<sycl::access_mode::write>(cgh, sycl::range<1>{width});
72+
73+
cgh.parallel_for<sample_host_usm_image_kernel>(
74+
sycl::nd_range<1>{{width}, {width}}, [=](sycl::nd_item<1> it) {
75+
size_t dim0 = it.get_local_id(0);
76+
77+
// Normalize coordinates -- +0.5 to look towards centre of pixel
78+
float fdim0 = float(dim0 + 0.5f) / (float)width;
79+
80+
// Extension: sample image data from handle
81+
float px = sycl::ext::oneapi::experimental::sample_image<float>(
82+
imgHandle, (float)fdim0);
83+
84+
outAcc[sycl::id<1>{dim0}] = px;
85+
});
86+
});
87+
88+
q.wait_and_throw();
89+
90+
// Extension: cleanup
91+
sycl::ext::oneapi::experimental::destroy_image_handle(imgHandle, dev, ctxt);
92+
sycl::free(imgMem, ctxt);
93+
} catch (sycl::exception e) {
94+
std::cerr << "SYCL exception caught! : " << e.what() << "\n";
95+
return 1;
96+
} catch (...) {
97+
std::cerr << "Unknown exception caught!\n";
98+
return 2;
99+
}
100+
101+
// collect and validate output
102+
bool validated = true;
103+
for (int i = 0; i < width; i++) {
104+
bool mismatch = false;
105+
if (out[i] != expected[i]) {
106+
mismatch = true;
107+
validated = false;
108+
}
109+
110+
if (mismatch) {
111+
#ifdef VERBOSE_PRINT
112+
std::cout << "Result mismatch! Expected: " << expected[i]
113+
<< ", Actual: " << out[i] << std::endl;
114+
#else
115+
break;
116+
#endif
117+
}
118+
}
119+
if (validated) {
120+
std::cout << "Test passed!" << std::endl;
121+
return 0;
122+
}
123+
124+
std::cout << "Test failed!" << std::endl;
125+
return 3;
126+
}

sycl/unittests/Extensions/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ add_subdirectory(VirtualFunctions)
2929
add_subdirectory(VirtualMemory)
3030
add_subdirectory(NumComputeUnits)
3131
add_subdirectory(FreeFunctionCommands)
32+
add_subdirectory(KernelQueries)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_sycl_unittest(KernelQueriesTests OBJECT
2+
SpillMemorySize.cpp
3+
)

0 commit comments

Comments
 (0)