23
23
24
24
using namespace sycl ;
25
25
26
- class MultTestKernel {
27
- public:
28
- void operator ()(cl::sycl::item<1 >){};
29
- };
26
+ class MultTestKernel ;
30
27
31
28
__SYCL_INLINE_NAMESPACE (cl) {
32
29
namespace sycl {
@@ -84,8 +81,10 @@ static pi_result redefinedDevicesGet(pi_platform platform,
84
81
return PI_SUCCESS;
85
82
}
86
83
87
- devices[0 ] = reinterpret_cast <pi_device>(1111 );
88
- devices[1 ] = reinterpret_cast <pi_device>(2222 );
84
+ if (num_entries == 2 && devices) {
85
+ devices[0 ] = reinterpret_cast <pi_device>(1111 );
86
+ devices[1 ] = reinterpret_cast <pi_device>(2222 );
87
+ }
89
88
return PI_SUCCESS;
90
89
}
91
90
@@ -188,15 +187,18 @@ TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
188
187
189
188
auto Bundle = cl::sycl::get_kernel_bundle<sycl::bundle_state::input>(
190
189
Queue.get_context ());
191
-
192
190
Queue.submit ([&](cl::sycl::handler &cgh) {
193
- cgh.parallel_for <MultTestKernel>(cl::sycl::nd_range<1 >(10 , 10 ),
194
- MultTestKernel{});
191
+ cgh.single_task <MultTestKernel>([](){});
195
192
});
196
193
197
194
auto BundleObject = cl::sycl::build (Bundle, Bundle.get_devices ());
198
195
auto KernelID = cl::sycl::get_kernel_id<MultTestKernel>();
199
196
auto Kernel = BundleObject.get_kernel (KernelID);
197
+
198
+ // Because of emulating 2 devices program is retained for each one in build().
199
+ // It is also depends on number of device images. This test has one image,
200
+ // but other tests can create other images. Additional variable is added
201
+ // to control count of piProgramRetain calls
200
202
auto BundleImpl = getSyclObjImpl (Bundle);
201
203
int NumRetains = BundleImpl->size () * 2 ;
202
204
@@ -210,5 +212,7 @@ TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
210
212
EXPECT_EQ (KernelCache.size (), (size_t )2 ) << " Expect 2 kernels in cache" ;
211
213
}
212
214
// Cache is cleared here, check kernel release
215
+ // 3 kernel releases is expected because kernel_bundle::get_kernel() calls piKernelRetain
216
+ // so one more kernel release is needed
213
217
EXPECT_EQ (KernelReleaseCounter, 3 ) << " Expect 3 piKernelRelease calls" ;
214
218
}
0 commit comments