Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Add test for get_specialization_constant segfault #1634

Open
wants to merge 1 commit into
base: intel
Choose a base branch
from
Open
Changes from all commits
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
27 changes: 27 additions & 0 deletions SYCL/Regression/get_spec_const_vec16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -o %t.out %s
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
//
// Tests that the right value returned after setting a specialization constant
// of sycl::vec<char, 16> type is correct.

#include <sycl/sycl.hpp>

#include <algorithm>

constexpr sycl::specialization_id<sycl::vec<char, 16>> spec_const(20);

int main() {
sycl::vec<char, 16> Result{0};
sycl::vec<char, 16> Ref{5};
sycl::queue Q;
Q.submit([&](sycl::handler &CGH) {
CGH.set_specialization_constant<spec_const>(Ref);
Result = CGH.get_specialization_constant<spec_const>();
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also verify the second part of it via writing inside single_task ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original issue only occurred when the specialization constant was read on host.

auto CompRes = Ref == Result;
assert(std::all_of(&CompRes[0], &CompRes[0] + 16,
[](const bool &A) { return A; }));
return 0;
}