From 0edc1b47e7a9a0ee056c35f72a755fff29a2b2ab Mon Sep 17 00:00:00 2001 From: "chedy.najjar" Date: Wed, 6 Mar 2024 15:21:53 +0000 Subject: [PATCH 1/3] [SYCL][Bindless][E2E] fix unsampled images test failure * Update the test to initialize the input vectors with 0s to match bindless_helpers::fill_rand requirement of non empty vector. * change the name and move init_vector to bindless_helpers. --- .../bindless_images/bindless_helpers.hpp | 15 +++++++++++++ .../vulkan_interop/sampled_images.cpp | 21 ++++--------------- .../vulkan_interop/unsampled_images.cpp | 9 ++++---- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/sycl/test-e2e/bindless_images/bindless_helpers.hpp b/sycl/test-e2e/bindless_images/bindless_helpers.hpp index 29770196ff2d0..4611d514d7395 100644 --- a/sycl/test-e2e/bindless_images/bindless_helpers.hpp +++ b/sycl/test-e2e/bindless_images/bindless_helpers.hpp @@ -4,9 +4,24 @@ namespace bindless_helpers { +template +constexpr sycl::vec init_vector(DType val) { + if constexpr (NChannel == 1) { + return sycl::vec{val}; + } else if constexpr (NChannel == 2) { + return sycl::vec{val, val}; + } else if constexpr (NChannel == 4) { + return sycl::vec{val, val, val, val}; + } else { + std::cerr << "Unsupported number of channels " << NChannel << "\n"; + exit(-1); + } +} + template static void fill_rand(std::vector> &v, int seed = std::default_random_engine::default_seed) { + assert(!v.empty()); std::default_random_engine generator; generator.seed(seed); auto distribution = [&]() { diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp index db48fb0341f61..feebd5542b3de 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp @@ -10,6 +10,7 @@ #include +#include "../bindless_helpers.hpp" #include "vulkan_common.hpp" #include @@ -40,20 +41,6 @@ bool equal_vec(sycl::vec v1, sycl::vec v2) { return true; } -template -constexpr sycl::vec initVector(DType val) { - if constexpr (NChannel == 1) { - return sycl::vec{val}; - } else if constexpr (NChannel == 2) { - return sycl::vec{val, val}; - } else if constexpr (NChannel == 4) { - return sycl::vec{val, val, val, val}; - } else { - std::cerr << "unsupported number of channels " << NChannel << "\n"; - exit(-1); - } -} - struct handles_t { sycl::ext::oneapi::experimental::sampled_image_handle imgInput; sycl::ext::oneapi::experimental::interop_mem_handle inputInteropMemHandle; @@ -189,8 +176,8 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, bool validated = true; for (int i = 0; i < globalSize.size(); i++) { bool mismatch = false; - VecType expected = - initVector(i) * static_cast(10.1f); + VecType expected = bindless_helpers::init_vector(i) * + static_cast(10.1f); if (!equal_vec(out[i], expected)) { mismatch = true; validated = false; @@ -273,7 +260,7 @@ bool run_test(sycl::range dims, sycl::range localSize, imageSizeBytes, 0 /*flags*/, (void **)&inputStagingData)); for (int i = 0; i < numElems; ++i) { - inputStagingData[i] = initVector(i); + inputStagingData[i] = bindless_helpers::init_vector(i); } vkUnmapMemory(vk_device, inputStagingMemory); diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/unsampled_images.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/unsampled_images.cpp index 16ae8e4701e40..dc6083383affb 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/unsampled_images.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/unsampled_images.cpp @@ -261,8 +261,10 @@ bool run_test(sycl::range dims, sycl::range local_size, printString("Populating staging buffer\n"); // Populate staging memory using VecType = sycl::vec; - std::vector input_vector_0; - input_vector_0.reserve(num_elems); + auto init = + bindless_helpers::init_vector(static_cast(0)); + + std::vector input_vector_0(num_elems, init); std::srand(seed); bindless_helpers::fill_rand(input_vector_0); @@ -275,8 +277,7 @@ bool run_test(sycl::range dims, sycl::range local_size, } vkUnmapMemory(vk_device, inVkImgRes1.stagingMemory); - std::vector input_vector_1; - input_vector_1.reserve(num_elems); + std::vector input_vector_1(num_elems, init); std::srand(seed); bindless_helpers::fill_rand(input_vector_1); From 4605c77e443833298734b590061e985e3c99fdc5 Mon Sep 17 00:00:00 2001 From: "chedy.najjar" Date: Thu, 21 Mar 2024 12:45:18 +0000 Subject: [PATCH 2/3] make use of `using` consistent across vulkan interop tests --- .../bindless_images/vulkan_interop/mipmaps.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp index 36e49e43c1ff5..826c7a8b19c4f 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp @@ -149,7 +149,6 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, } using bindless_helpers::equal_vec; - using bindless_helpers::init_vector; printString("Validating\n"); // Expected is sum of first two levels in the mipmap @@ -167,10 +166,10 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, float norm_coord_z = ((k + 0.5f) / (float)depth); int z = norm_coord_z * (depth >> 1); - VecType expected = - init_vector(i + width * (j + height * k)) + - init_vector(x + (width / 2) * - (y + (height / 2) * z)); + VecType expected = bindless_helpers::init_vector( + i + width * (j + height * k)) + + bindless_helpers::init_vector( + x + (width / 2) * (y + (height / 2) * z)); if (!equal_vec(out[i + width * (j + height * k)], expected)) { @@ -198,8 +197,10 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, float norm_coord_y = ((j + 0.5f) / (float)height); int y = norm_coord_y * (height >> 1); - VecType expected = init_vector(j + (width * i)) + - init_vector(y + (width / 2 * x)); + VecType expected = + bindless_helpers::init_vector(j + (width * i)) + + bindless_helpers::init_vector(y + + (width / 2 * x)); if (!equal_vec(out[j + (width * i)], expected)) { mismatch = true; From 76e93ef56dfcca6d4d86d89d53482947478e3938 Mon Sep 17 00:00:00 2001 From: "chedy.najjar" Date: Fri, 22 Mar 2024 13:39:23 +0000 Subject: [PATCH 3/3] remove the use of `using ..` --- sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp | 6 ++---- .../bindless_images/vulkan_interop/sampled_images.cpp | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp index 826c7a8b19c4f..1b1ae31785eb4 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp @@ -148,8 +148,6 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, exit(-1); } - using bindless_helpers::equal_vec; - printString("Validating\n"); // Expected is sum of first two levels in the mipmap // Each subsequent level repeats in each dimension @@ -171,8 +169,8 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, bindless_helpers::init_vector( x + (width / 2) * (y + (height / 2) * z)); - if (!equal_vec(out[i + width * (j + height * k)], - expected)) { + if (!bindless_helpers::equal_vec( + out[i + width * (j + height * k)], expected)) { mismatch = true; validated = false; } diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp index c75f91e4bc5ec..5f279e12383a9 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp @@ -144,15 +144,13 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, exit(-1); } - using bindless_helpers::equal_vec; - printString("Validating\n"); bool validated = true; for (int i = 0; i < globalSize.size(); i++) { bool mismatch = false; VecType expected = bindless_helpers::init_vector(i) * static_cast(10.1f); - if (!equal_vec(out[i], expected)) { + if (!bindless_helpers::equal_vec(out[i], expected)) { mismatch = true; validated = false; }