Skip to content

Commit 1b562eb

Browse files
committed
Merge remote-tracking branch 'origin/sycl' into no-unsupported
2 parents 21bdd4e + 91ad0ed commit 1b562eb

File tree

7 files changed

+135
-125
lines changed

7 files changed

+135
-125
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ descriptor against the limitations outlined below. If the given descriptor is
241241
deemed invalid, then a `sycl::exception` will be thrown with error code
242242
`sycl::errc::invalid`.
243243

244-
For all image types, the value of `num_channels` must be `1`, `2`, or `4`.
244+
The value of `num_channels` supported by all image types and backends
245+
is `1`, `2`, or `4`.
246+
Some backends also support `num_channels` to be `3`.
245247

246248
For the `standard` image type, the value of `num_levels` and `array_size` must
247249
both be `1`.
@@ -2107,6 +2109,12 @@ There are dimension specific limitations:
21072109
* 3D - No support at the moment. Possible support in non CUDA backends in the
21082110
future.
21092111

2112+
=== 3 channel format support
2113+
2114+
The ability to create an image with 3 channels depends on the backend.
2115+
There is currently no way to query a backend whether it supports this feature.
2116+
This query should be added in a later revision of the proposal.
2117+
21102118
=== Not supported yet
21112119

21122120
These features still need to be handled:
@@ -2319,4 +2327,5 @@ These features still need to be handled:
23192327
sub-region copies.
23202328
|6.4|2024-10-15| - Fix bindless spec examples and include examples in bindless
23212329
spec using asciidoc include.
2330+
|6.5|2024-10-22| - Allow 3-channel image formats on some backends.
23222331
|======================

sycl/include/sycl/ext/oneapi/bindless_images_descriptor.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ namespace ext::oneapi::experimental {
2323

2424
namespace detail {
2525

26-
inline image_channel_order
26+
constexpr image_channel_order
2727
get_image_default_channel_order(unsigned int num_channels) {
2828
switch (num_channels) {
2929
case 1:
3030
return image_channel_order::r;
3131
case 2:
3232
return image_channel_order::rg;
33+
case 3:
34+
return image_channel_order::rgb;
3335
case 4:
3436
return image_channel_order::rgba;
3537
default:
@@ -120,13 +122,9 @@ struct image_descriptor {
120122
}
121123

122124
void verify() const {
123-
124-
if (this->num_channels != 1 && this->num_channels != 2 &&
125-
this->num_channels != 4) {
126-
// Images can only have 1, 2, or 4 channels.
125+
if ((this->num_channels < 1) || (this->num_channels > 4)) {
127126
throw sycl::exception(sycl::errc::invalid,
128-
"Images must have only 1, 2, or 4 channels! Use a "
129-
"valid number of channels instead.");
127+
"Images must have 1, 2, 3, or 4 channels.");
130128
}
131129

132130
switch (this->type) {

sycl/test-e2e/Basic/interop/get_native_ocl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// REQUIRES: opencl, opencl_dev_kit
2-
// RUN: %{build} %opencl_options -o %t.ocl.out
1+
// REQUIRES: opencl, opencl_icd
2+
// RUN: %{build} %opencl_lib -o %t.out
33
// RUN: %{run} %t.out
44

55
#include <CL/cl.h>

sycl/test-e2e/Basic/interop/interop_all_backends.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
// REQUIRES: CUDA || HIP
2-
// RUN: %{build} %if hip %{ -DSYCL_EXT_ONEAPI_BACKEND_HIP %} %else %{ %if cuda %{ -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %} %else %{ %if level_zero %{ -DSYCL_EXT_ONEAPI_BACKEND_L0 %} %} %} -o %t.out
1+
// XFAIL: any-device-is-opencl, any-device-is-cuda, (windows && any-device-is-level_zero), gpu-intel-dg2, hip_amd
2+
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/15819
3+
// RUN: %if any-device-is-opencl %{ %{build} -o %t-opencl.out %}
4+
// RUN: %if any-device-is-level_zero %{ %{build} -DBUILD_FOR_L0 -o %t-l0.out %}
5+
// RUN: %if any-device-is-cuda %{ %{build} -DBUILD_FOR_CUDA -o %t-cuda.out %}
6+
// RUN: %if any-device-is-hip %{ %{build} -DBUILD_FOR_HIP -o %t-hip.out %}
37

48
#include <sycl/backend.hpp>
59
#include <sycl/detail/core.hpp>
610
#include <sycl/properties/all_properties.hpp>
711
#include <sycl/usm.hpp>
812
using namespace sycl;
913

10-
#ifdef SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL
14+
#ifdef BUILD_FOR_CUDA
1115
#include <sycl/ext/oneapi/experimental/backend/cuda.hpp>
1216
constexpr auto BACKEND = backend::ext_oneapi_cuda;
1317
using nativeDevice = CUdevice;
1418
using nativeQueue = CUstream;
1519
using nativeEvent = CUevent;
16-
#elif defined(SYCL_EXT_ONEAPI_BACKEND_HIP)
20+
#elif defined(BUILD_FOR_HIP)
1721
#include <sycl/ext/oneapi/backend/hip.hpp>
1822
constexpr auto BACKEND = backend::ext_oneapi_hip;
1923
using nativeDevice = hipDevice_t;
2024
using nativeQueue = hipStream_t;
2125
using nativeEvent = hipEvent_t;
22-
#elif defined(SYCL_EXT_ONEAPI_BACKEND_L0)
26+
#elif defined(BUILD_FOR_L0)
2327
constexpr auto BACKEND = backend::ext_oneapi_level_zero;
2428
using nativeDevice = ze_device_handle_t;
2529
using nativeQueue = ze_command_queue_handle_t;

sycl/test-e2e/NewOffloadDriver/diamond_shape.cpp

Lines changed: 0 additions & 109 deletions
This file was deleted.

sycl/test-e2e/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ environment:
229229
* **dump_ir**: - compiler can / cannot dump IR;
230230
* **llvm-spirv** - llvm-spirv tool availability;
231231
* **llvm-link** - llvm-link tool availability;
232-
* **fusion**: - Runtime supports kernel fusion;
233232
* **aspect-\<name\>**: - SYCL aspects supported by a device;
234233
* **arch-\<name\>** - [SYCL architecture](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_device_architecture.asciidoc) of a device (e.g. `arch-intel_gpu_pvc`, the name matches what you
235234
can pass into `-fsycl-targets` compiler flag);
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// REQUIRES: cuda
2+
3+
// RUN: %{build} -o %t.out
4+
// RUN: %t.out
5+
6+
#include <iostream>
7+
#include <sycl/detail/core.hpp>
8+
9+
#include <sycl/ext/oneapi/bindless_images.hpp>
10+
11+
// Uncomment to print additional test information
12+
// #define VERBOSE_PRINT
13+
14+
class image_kernel;
15+
16+
namespace syclexp = sycl::ext::oneapi::experimental;
17+
18+
int main() {
19+
sycl::device dev;
20+
sycl::queue q(dev);
21+
auto ctxt = q.get_context();
22+
23+
constexpr size_t width = 512;
24+
std::vector<float> out(width);
25+
std::vector<float> expected(width);
26+
std::vector<sycl::float3> dataIn(width);
27+
float exp = 512;
28+
for (int i = 0; i < width; i++) {
29+
expected[i] = exp;
30+
dataIn[i] = sycl::float3(exp, width, i);
31+
}
32+
33+
try {
34+
// Main point of this test is to check creating an image
35+
// with a 3-channel format
36+
syclexp::image_descriptor desc({width}, 3, sycl::image_channel_type::fp32);
37+
38+
syclexp::image_mem imgMem(desc, dev, ctxt);
39+
40+
q.ext_oneapi_copy(dataIn.data(), imgMem.get_handle(), desc);
41+
q.wait_and_throw();
42+
43+
// Some backends don't support 3-channel formats
44+
// We still try to create the image,
45+
// but we expect it to fail with UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT
46+
syclexp::unsampled_image_handle imgHandle =
47+
sycl::ext::oneapi::experimental::create_image(imgMem, desc, dev, ctxt);
48+
49+
sycl::buffer<float> buf(out.data(), width);
50+
51+
q.submit([&](sycl::handler &cgh) {
52+
sycl::accessor outAcc{buf, cgh};
53+
54+
cgh.parallel_for<image_kernel>(width, [=](sycl::id<1> id) {
55+
#if defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__)
56+
// This shouldn't be hit anyway since CUDA doesn't support
57+
// 3-channel formats, but we need to ensure the kernel can compile
58+
using pixel_t = sycl::float4;
59+
#else
60+
using pixel_t = sycl::float3;
61+
#endif
62+
auto pixel = syclexp::fetch_image<pixel_t>(imgHandle, int(id[0]));
63+
outAcc[id] = pixel[0];
64+
});
65+
});
66+
q.wait_and_throw();
67+
68+
} catch (const sycl::exception &ex) {
69+
const std::string_view errMsg(ex.what());
70+
if (ctxt.get_backend() == sycl::backend::ext_oneapi_cuda) {
71+
if (errMsg.find("UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT") !=
72+
std::string::npos) {
73+
std::cout << "CUDA doesn't support 3-channel formats, test passed."
74+
<< std::endl;
75+
return 0;
76+
}
77+
}
78+
std::cerr << "Unexpected SYCL exception: " << errMsg << "\n";
79+
return 1;
80+
} catch (...) {
81+
std::cerr << "Unknown exception caught!\n";
82+
return 2;
83+
}
84+
85+
bool validated = true;
86+
for (int i = 0; i < width; i++) {
87+
bool mismatch = false;
88+
if (out[i] != expected[i]) {
89+
mismatch = true;
90+
validated = false;
91+
}
92+
93+
if (mismatch) {
94+
#ifdef VERBOSE_PRINT
95+
std::cout << "Result mismatch! Expected: " << expected[i]
96+
<< ", Actual: " << out[i] << std::endl;
97+
#else
98+
break;
99+
#endif
100+
}
101+
}
102+
if (validated) {
103+
std::cout << "Test passed!" << std::endl;
104+
return 0;
105+
}
106+
107+
std::cout << "Test failed!" << std::endl;
108+
return 3;
109+
}

0 commit comments

Comments
 (0)