9
9
#define SYCL2020_DISABLE_DEPRECATION_WARNINGS
10
10
11
11
#include < CL/sycl.hpp>
12
+ #include < detail/device_image_impl.hpp>
12
13
13
14
#include < helpers/CommonRedefinitions.hpp>
14
15
#include < helpers/PiImage.hpp>
@@ -41,21 +42,6 @@ template <> const char *get_spec_constant_symbolic_ID<SpecConst1>() {
41
42
} // namespace sycl
42
43
} // __SYCL_INLINE_NAMESPACE(cl)
43
44
44
- int SpecConstVal0 = 0 ;
45
- int SpecConstVal1 = 0 ;
46
-
47
- static pi_result
48
- redefinedProgramSetSpecializationConstant (pi_program prog, pi_uint32 spec_id,
49
- size_t spec_size,
50
- const void *spec_value) {
51
- if (spec_id == 0 )
52
- SpecConstVal0 = *static_cast <const int *>(spec_value);
53
- if (spec_id == 1 )
54
- SpecConstVal1 = *static_cast <const int *>(spec_value);
55
-
56
- return PI_SUCCESS;
57
- }
58
-
59
45
static sycl::unittest::PiImage generateImageWithSpecConsts () {
60
46
using namespace sycl ::unittest;
61
47
@@ -84,7 +70,7 @@ static sycl::unittest::PiImage generateImageWithSpecConsts() {
84
70
static sycl::unittest::PiImage Img = generateImageWithSpecConsts();
85
71
static sycl::unittest::PiImageArray<1 > ImgArray{&Img};
86
72
87
- TEST (SpecConstDefaultValues, DISABLED_DefaultValuesAreSet ) {
73
+ TEST (SpecConstDefaultValues, DefaultValuesAreSet ) {
88
74
sycl::platform Plt{sycl::default_selector ()};
89
75
if (Plt.is_host ()) {
90
76
std::cerr << " Test is not supported on host, skipping\n " ;
@@ -98,8 +84,6 @@ TEST(SpecConstDefaultValues, DISABLED_DefaultValuesAreSet) {
98
84
99
85
sycl::unittest::PiMock Mock{Plt};
100
86
setupDefaultMockAPIs (Mock);
101
- Mock.redefine <sycl::detail::PiApiKind::piextProgramSetSpecializationConstant>(
102
- redefinedProgramSetSpecializationConstant);
103
87
104
88
const sycl::device Dev = Plt.get_devices ()[0 ];
105
89
@@ -109,17 +93,18 @@ TEST(SpecConstDefaultValues, DISABLED_DefaultValuesAreSet) {
109
93
110
94
sycl::kernel_bundle KernelBundle =
111
95
sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev});
112
- auto ExecBundle = sycl::build (KernelBundle);
113
- Queue.submit ([&](sycl::handler &CGH) {
114
- CGH.use_kernel_bundle (ExecBundle);
115
- CGH.single_task <TestKernel>([] {}); // Actual kernel does not matter
116
- });
117
-
118
- EXPECT_EQ (SpecConstVal0, 42 );
119
- EXPECT_EQ (SpecConstVal1, 8 );
96
+
97
+ auto DevImage = sycl::detail::getSyclObjImpl (*KernelBundle.begin ());
98
+ const auto &Blob = DevImage->get_spec_const_blob_ref ();
99
+
100
+ int SpecConstVal1 = *reinterpret_cast <const int *>(Blob.data ());
101
+ int SpecConstVal2 = *(reinterpret_cast <const int *>(Blob.data ()) + 1 );
102
+
103
+ EXPECT_EQ (SpecConstVal1, 42 );
104
+ EXPECT_EQ (SpecConstVal2, 8 );
120
105
}
121
106
122
- TEST (SpecConstDefaultValues, DISABLED_DefaultValuesAreOverriden ) {
107
+ TEST (SpecConstDefaultValues, DefaultValuesAreOverriden ) {
123
108
sycl::platform Plt{sycl::default_selector ()};
124
109
if (Plt.is_host ()) {
125
110
std::cerr << " Test is not supported on host, skipping\n " ;
@@ -133,8 +118,6 @@ TEST(SpecConstDefaultValues, DISABLED_DefaultValuesAreOverriden) {
133
118
134
119
sycl::unittest::PiMock Mock{Plt};
135
120
setupDefaultMockAPIs (Mock);
136
- Mock.redefine <sycl::detail::PiApiKind::piextProgramSetSpecializationConstant>(
137
- redefinedProgramSetSpecializationConstant);
138
121
139
122
const sycl::device Dev = Plt.get_devices ()[0 ];
140
123
@@ -144,13 +127,20 @@ TEST(SpecConstDefaultValues, DISABLED_DefaultValuesAreOverriden) {
144
127
145
128
sycl::kernel_bundle KernelBundle =
146
129
sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev});
130
+
131
+ auto DevImage = sycl::detail::getSyclObjImpl (*KernelBundle.begin ());
132
+ auto &Blob = DevImage->get_spec_const_blob_ref ();
133
+ int SpecConstVal1 = *reinterpret_cast <int *>(Blob.data ());
134
+ int SpecConstVal2 = *(reinterpret_cast <int *>(Blob.data ()) + 1 );
135
+
136
+ EXPECT_EQ (SpecConstVal1, 42 );
137
+ EXPECT_EQ (SpecConstVal2, 8 );
138
+
147
139
KernelBundle.set_specialization_constant <SpecConst1>(80 );
148
- auto ExecBundle = sycl::build (KernelBundle);
149
- Queue.submit ([&](sycl::handler &CGH) {
150
- CGH.use_kernel_bundle (ExecBundle);
151
- CGH.single_task <TestKernel>([] {}); // Actual kernel does not matter
152
- });
153
-
154
- EXPECT_EQ (SpecConstVal0, 80 );
155
- EXPECT_EQ (SpecConstVal1, 8 );
140
+
141
+ SpecConstVal1 = *reinterpret_cast <int *>(Blob.data ());
142
+ SpecConstVal2 = *(reinterpret_cast <int *>(Blob.data ()) + 1 );
143
+
144
+ EXPECT_EQ (SpecConstVal1, 80 );
145
+ EXPECT_EQ (SpecConstVal2, 8 );
156
146
}
0 commit comments