Skip to content

[SYCL][Bindless][E2E] fix unsampled images test failure #13007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sycl/test-e2e/bindless_images/bindless_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@

namespace bindless_helpers {

template <typename DType, int NChannel>
constexpr sycl::vec<DType, NChannel> init_vector(DType val) {
if constexpr (NChannel == 1) {
return sycl::vec<DType, NChannel>{val};
} else if constexpr (NChannel == 2) {
return sycl::vec<DType, NChannel>{val, val};
} else if constexpr (NChannel == 4) {
return sycl::vec<DType, NChannel>{val, val, val, val};
} else {
std::cerr << "Unsupported number of channels " << NChannel << "\n";
exit(-1);
}
}

template <typename DType, int NChannels>
static void fill_rand(std::vector<sycl::vec<DType, NChannels>> &v,
int seed = std::default_random_engine::default_seed) {
assert(!v.empty());
std::default_random_engine generator;
generator.seed(seed);
auto distribution = [&]() {
Expand Down
21 changes: 4 additions & 17 deletions sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <sycl/sycl.hpp>

#include "../bindless_helpers.hpp"
#include "vulkan_common.hpp"

#include <cstdlib>
Expand Down Expand Up @@ -40,20 +41,6 @@ bool equal_vec(sycl::vec<DType, NChannels> v1, sycl::vec<DType, NChannels> v2) {
return true;
}

template <typename DType, int NChannel>
constexpr sycl::vec<DType, NChannel> initVector(DType val) {
if constexpr (NChannel == 1) {
return sycl::vec<DType, NChannel>{val};
} else if constexpr (NChannel == 2) {
return sycl::vec<DType, NChannel>{val, val};
} else if constexpr (NChannel == 4) {
return sycl::vec<DType, NChannel>{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;
Expand Down Expand Up @@ -189,8 +176,8 @@ bool run_sycl(sycl::range<NDims> globalSize, sycl::range<NDims> localSize,
bool validated = true;
for (int i = 0; i < globalSize.size(); i++) {
bool mismatch = false;
VecType expected =
initVector<DType, NChannels>(i) * static_cast<DType>(10.1f);
VecType expected = bindless_helpers::init_vector<DType, NChannels>(i) *
static_cast<DType>(10.1f);
if (!equal_vec<DType, NChannels>(out[i], expected)) {
mismatch = true;
validated = false;
Expand Down Expand Up @@ -273,7 +260,7 @@ bool run_test(sycl::range<NDims> dims, sycl::range<NDims> localSize,
imageSizeBytes, 0 /*flags*/,
(void **)&inputStagingData));
for (int i = 0; i < numElems; ++i) {
inputStagingData[i] = initVector<DType, NChannels>(i);
inputStagingData[i] = bindless_helpers::init_vector<DType, NChannels>(i);
}
vkUnmapMemory(vk_device, inputStagingMemory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ bool run_test(sycl::range<NDims> dims, sycl::range<NDims> local_size,
printString("Populating staging buffer\n");
// Populate staging memory
using VecType = sycl::vec<DType, NChannels>;
std::vector<VecType> input_vector_0;
input_vector_0.reserve(num_elems);
auto init =
bindless_helpers::init_vector<DType, NChannels>(static_cast<DType>(0));

std::vector<VecType> input_vector_0(num_elems, init);
std::srand(seed);
bindless_helpers::fill_rand(input_vector_0);

Expand All @@ -275,8 +277,7 @@ bool run_test(sycl::range<NDims> dims, sycl::range<NDims> local_size,
}
vkUnmapMemory(vk_device, inVkImgRes1.stagingMemory);

std::vector<VecType> input_vector_1;
input_vector_1.reserve(num_elems);
std::vector<VecType> input_vector_1(num_elems, init);
std::srand(seed);
bindless_helpers::fill_rand(input_vector_1);

Expand Down