Skip to content

Commit 604c640

Browse files
committed
Fix unit test implementation for backend kernel argument
1 parent 91820d8 commit 604c640

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

sycl/unittests/Extensions/WorkGroupMemoryBackendArgument.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,40 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <gtest/gtest.h>
10-
#include <helpers/TestKernel.hpp>
10+
#include <helpers/UrImage.hpp>
1111
#include <helpers/UrMock.hpp>
1212
#include <sycl/sycl.hpp>
1313

1414
// Check that the work group memory object is mapped to exactly one backend
1515
// kernel argument.
16-
16+
class WorkGroupMemoryKernel;
1717
namespace syclext = sycl::ext::oneapi::experimental;
18-
using arg_type = syclext::work_group_memory<int, syclext::empty_properties_t>;
18+
using arg_type = syclext::work_group_memory<int>;
19+
20+
namespace sycl {
21+
inline namespace _V1 {
22+
namespace detail {
23+
template <> struct KernelInfo<WorkGroupMemoryKernel> {
24+
static constexpr unsigned getNumParams() { return 1; }
25+
static const detail::kernel_param_desc_t &getParamDesc(int) {
26+
static detail::kernel_param_desc_t WorkGroupMemory = {
27+
detail::kernel_param_kind_t::kind_work_group_memory, 0, 0};
28+
return WorkGroupMemory;
29+
}
30+
static constexpr bool isESIMD() { return false; }
31+
static constexpr bool callsThisItem() { return false; }
32+
static constexpr bool callsAnyThisFreeFunction() { return false; }
33+
static constexpr int64_t getKernelSize() { return sizeof(arg_type); }
34+
static constexpr const char *getName() { return "WorkGroupMemoryKernel"; }
35+
};
36+
37+
} // namespace detail
38+
} // namespace _V1
39+
} // namespace sycl
40+
41+
static sycl::unittest::UrImage Img =
42+
sycl::unittest::generateDefaultImage({"WorkGroupMemoryKernel"});
43+
static sycl::unittest::UrImageArray<1> ImgArray{&Img};
1944

2045
static int urKernelSetArgLocalCalls = 0;
2146
inline ur_result_t redefined_urKernelSetArgLocal(void *) {
@@ -32,9 +57,9 @@ TEST(URArgumentTest, URArgumentTest) {
3257
sycl::queue q{dev};
3358
syclext::submit(q, [&](sycl::handler &cgh) {
3459
arg_type data{cgh};
35-
const auto mykernel = [=](sycl::nd_item<1> it) { data = 42; };
36-
syclext::nd_launch<TestKernel<sizeof(mykernel)>>(
37-
cgh, sycl::nd_range<1>{1, 1}, mykernel);
60+
const auto kernel = [=](sycl::nd_item<1> it) { data = 42; };
61+
syclext::nd_launch<WorkGroupMemoryKernel>(cgh, sycl::nd_range<1>{1, 1},
62+
kernel);
3863
});
3964
q.wait();
4065
ASSERT_EQ(urKernelSetArgLocalCalls, 1);

0 commit comments

Comments
 (0)