Skip to content

Commit

Permalink
[SYCL][Ext][Bindless] Initial implementation of image spirv builtins …
Browse files Browse the repository at this point in the history
…on HIP

TODO: Complete the description with more information.

Signed-off-by: Georgi Mirazchiyski <[email protected]>
  • Loading branch information
GeorgeWeb committed Dec 20, 2024
1 parent 38b5829 commit 437f972
Show file tree
Hide file tree
Showing 50 changed files with 1,215 additions and 55 deletions.
1 change: 1 addition & 0 deletions libclc/libspirv/lib/amdgcn-amdhsa/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ atomic/atomic_max.cl
atomic/atomic_sub.cl
atomic/atomic_store.cl
synchronization/barrier.cl
images/image.cl
math/acos.cl
math/acosh.cl
math/asin.cl
Expand Down
1,076 changes: 1,076 additions & 0 deletions libclc/libspirv/lib/amdgcn-amdhsa/images/image.cl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT)
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
set(UNIFIED_RUNTIME_REPO "https://github.com/GeorgeWeb/unified-runtime.git")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake)

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
Expand Down
2 changes: 1 addition & 1 deletion sycl/cmake/modules/UnifiedRuntimeTag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Date: Thu Dec 19 11:26:01 2024 +0000
# Merge pull request #2277 from igchor/cooperative_fix
# [Spec] fix urKernelSuggestMaxCooperativeGroupCountExp
set(UNIFIED_RUNTIME_TAG ea0f3a1f5f15f9af7bf40bd13669afeb9ada569c)
set(UNIFIED_RUNTIME_TAG georgi/bindless-hip)
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ void release_external_semaphore(external_semaphore semaphoreHandle,
```cpp
#include <sycl/sycl.hpp>

include::../../../test-e2e/bindless_images/examples/example_1_1D_read_write.cpp[lines=9..-1]
include::../../../test-e2e/bindless_images/examples/example_1_1D_read_write.cpp[lines=12..-1]
```

=== Reading from a dynamically sized array of 2D images
Expand All @@ -2055,30 +2055,30 @@ include::../../../test-e2e/bindless_images/examples/example_2_2D_dynamic_read.cp
```cpp
#include <sycl/sycl.hpp>

include::../../../test-e2e/bindless_images/examples/example_3_1D_mipmap_anisotropic_filtering_and_levels.cpp[lines=9..-1]
include::../../../test-e2e/bindless_images/examples/example_3_1D_mipmap_anisotropic_filtering_and_levels.cpp[lines=10..-1]
```

=== 1D image array read/write
```cpp
#include <sycl/sycl.hpp>

include::../../../test-e2e/bindless_images/examples/example_4_1D_array_read_write.cpp[lines=9..-1]
include::../../../test-e2e/bindless_images/examples/example_4_1D_array_read_write.cpp[lines=14..-1]
```

=== Sampling a cubemap

```c++
#include <sycl/sycl.hpp>

include::../../../test-e2e/bindless_images/examples/example_5_sample_cubemap.cpp[lines=9..-1]
include::../../../test-e2e/bindless_images/examples/example_5_sample_cubemap.cpp[lines=10..-1]
```

=== Using imported memory and semaphore objects

```c++
#include <sycl/sycl.hpp>

include::../../../test-e2e/bindless_images/examples/example_6_import_memory_and_semaphores.cpp[lines=8..-1]
include::../../../test-e2e/bindless_images/examples/example_6_import_memory_and_semaphores.cpp[lines=14..-1]
```

== Implementation notes
Expand Down
6 changes: 5 additions & 1 deletion sycl/test-e2e/bindless_images/3_channel_format.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip || level_zero
// UNSUPPORTED-INTENDED: Unimplemented in the HIP adapter yet.
// Also, the feature is not fully implemented in the Level Zero stack.

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_image_array

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
14 changes: 12 additions & 2 deletions sycl/test-e2e/bindless_images/array/read_sampled_array.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_image_array

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down Expand Up @@ -137,7 +137,17 @@ static bool runTest(sycl::range<NDims> dims, sycl::range<NDims> localSize,
unsigned int seed = 0) {
using VecType = sycl::vec<DType, NChannels>;

sycl::device dev;
sycl::device dev{};
// skip half tests if the device does not support the aspect.
if constexpr (std::is_same_v<DType, sycl::half>) {
if (!dev.has(sycl::aspect::fp16)) {
#ifdef VERBOSE_PRINT
std::cout << "Test skipped due to lack of device support for fp16\n";
#endif
return false;
}
}

sycl::queue q(dev);
auto ctxt = q.get_context();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_image_array

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// RUN: %if !any-device-is-hip %{ %{build} -o %t.out %}
// RUN: %if !any-device-is-hip %{ %{run} %t.out %}

#include <iostream>
#include <sycl/detail/core.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_image_array

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// REQUIRES: linux
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: aspect-ext_oneapi_image_array

// RUN: %{build} -o %t.out
// RUN: %{run} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out
Expand Down
2 changes: 0 additions & 2 deletions sycl/test-e2e/bindless_images/cubemap/cubemap_sampled.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// REQUIRES: cuda,aspect-ext_oneapi_cubemap
// REQUIRES: aspect-ext_oneapi_cubemap_seamless_filtering
// REQUIRES: build-and-run-mode

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda,aspect-ext_oneapi_cubemap
// REQUIRES: aspect-ext_oneapi_cubemap

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out
Expand Down
5 changes: 4 additions & 1 deletion sycl/test-e2e/bindless_images/device_to_device_copy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in this test.

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in this test.

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand All @@ -15,9 +18,9 @@ namespace syclexp = sycl::ext::oneapi::experimental;

void copy_image_mem_handle_to_image_mem_handle(
const syclexp::image_descriptor &dataInDesc,
const syclexp::image_descriptor &outDesc,
const std::vector<float> &dataIn1, const std::vector<float> &dataIn2,
sycl::device dev, sycl::queue q, std::vector<float> &out) {
const syclexp::image_descriptor &outDesc, const std::vector<float> &dataIn1,
const std::vector<float> &dataIn2, sycl::device dev, sycl::queue q,
std::vector<float> &out) {

// Check that output image is double size of input images
assert(outDesc.width == dataInDesc.width * 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: windows
// XFAIL: *

// XFAIL: run-mode
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/15851

// RUN: %{build} -l d3d12 -l dxgi -l dxguid -o %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in 'create_image' in this test.

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_mipmap
// REQUIRES: aspect-ext_oneapi_mipmap_anisotropy

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in 'create_image' in this test.

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_cubemap
// REQUIRES: build-and-run-mode

// RUN: %{build} -o %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_external_memory_import
// REQUIRES: aspect-ext_oneapi_external_semaphore_import

// RUN: %{build} -o %t.out
// This test is not being executed via the {run} command due to using invalid
// external input and output file descriptors for the external resource that is
// being imported. The purpose of this test is to showcase the interop APIs and
// in order to properly obtain those descriptors we would need a lot of Vulkan
// context and texture setup as a prerequisite to the example and complicate it.

#include <sycl/detail/core.hpp>
#include <sycl/ext/oneapi/bindless_images.hpp>
Expand Down
6 changes: 5 additions & 1 deletion sycl/test-e2e/bindless_images/image_get_info.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip || level_zero
// UNSUPPORTED-INTENDED: Image channels queries not working correctly on HIP.
// Also, the feature is not fully implemented in the Level Zero stack.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/bindless_images/mipmap/mipmap_read_1D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_mipmap

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/bindless_images/mipmap/mipmap_read_2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_mipmap

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/bindless_images/mipmap/mipmap_read_3D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_mipmap

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out
Expand Down
3 changes: 3 additions & 0 deletions sycl/test-e2e/bindless_images/read_norm_types.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Returning non fp[32/16] values from sampling fails.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out

Expand Down
18 changes: 16 additions & 2 deletions sycl/test-e2e/bindless_images/read_sampled.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip || level_zero
// UNSUPPORTED-INTENDED: Returning non-FP values from fetching fails on HIP.
// Also, the feature is not fully implemented in the Level Zero stack.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out
Expand Down Expand Up @@ -127,7 +131,17 @@ static bool runTest(sycl::range<NDims> dims, sycl::range<NDims> localSize,
unsigned int seed = 0) {
using VecType = sycl::vec<DType, NChannels>;

sycl::device dev;
sycl::device dev{};
// skip half tests if not supported
if constexpr (std::is_same_v<DType, sycl::half>) {
if (!dev.has(sycl::aspect::fp16)) {
#ifdef VERBOSE_PRINT
std::cout << "Test skipped due to lack of device support for fp16\n";
#endif
return false;
}
}

sycl::queue q(dev);
auto ctxt = q.get_context();

Expand Down
3 changes: 3 additions & 0 deletions sycl/test-e2e/bindless_images/read_write_1D.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in 'create_image' in this test.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out

Expand Down
3 changes: 3 additions & 0 deletions sycl/test-e2e/bindless_images/read_write_1D_subregion.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in 'create_image' in this test.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out

Expand Down
3 changes: 3 additions & 0 deletions sycl/test-e2e/bindless_images/read_write_3D_subregion.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Undetermined issue in 'create_image' in this test.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out

Expand Down
3 changes: 3 additions & 0 deletions sycl/test-e2e/bindless_images/read_write_unsampled.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images

// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: Returning non fp[32/16] values from sampling fails.

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_sampled_image_fetch_1d_usm

// RUN: %{build} -o %t.out
Expand Down
1 change: 0 additions & 1 deletion sycl/test-e2e/bindless_images/sampled_fetch/fetch_2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_sampled_image_fetch_2d

// RUN: %{build} -o %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_sampled_image_fetch_2d_usm

// RUN: %{build} -o %t.out
Expand Down
1 change: 0 additions & 1 deletion sycl/test-e2e/bindless_images/sampled_fetch/fetch_3D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_sampled_image_fetch_3d

// RUN: %{build} -o %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/bindless_images/sampling_2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: aspect-ext_oneapi_bindless_images_2d_usm

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out
Expand Down
8 changes: 7 additions & 1 deletion sycl/test-e2e/bindless_images/sampling_2D_USM_shared.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// REQUIRES: cuda
// REQUIRES: aspect-ext_oneapi_bindless_images_shared_usm

// This test is unstable (sometimes passes) on HIP-AMD platforms.
// UNSUPPORTED: hip
// UNSUPPORTED-INTENDED: While rarely, urBindlessImagesSampledImageCreateExp for
// USM image memory type (with linear sampler) sometimes returns an unsupported
// feature result code (1:1 mapping from the native errc from the HIP runtime).
// We think this is likely an issue in the ROCm drivers(could be arch-specific).

// RUN: %{build} -o %t.out
// RUN: %{run-unfiltered-devices} %t.out

Expand Down
Loading

0 comments on commit 437f972

Please sign in to comment.