Skip to content

Commit 004c9d5

Browse files
committed
Addressed review comments
1 parent 30db943 commit 004c9d5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

sycl/unittests/kernel-and-program/MultipleDevsCache.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323

2424
using namespace sycl;
2525

26-
class MultTestKernel {
27-
public:
28-
void operator()(cl::sycl::item<1>){};
29-
};
26+
class MultTestKernel;
3027

3128
__SYCL_INLINE_NAMESPACE(cl) {
3229
namespace sycl {
@@ -84,8 +81,10 @@ static pi_result redefinedDevicesGet(pi_platform platform,
8481
return PI_SUCCESS;
8582
}
8683

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+
}
8988
return PI_SUCCESS;
9089
}
9190

@@ -188,15 +187,18 @@ TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
188187

189188
auto Bundle = cl::sycl::get_kernel_bundle<sycl::bundle_state::input>(
190189
Queue.get_context());
191-
192190
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>([](){});
195192
});
196193

197194
auto BundleObject = cl::sycl::build(Bundle, Bundle.get_devices());
198195
auto KernelID = cl::sycl::get_kernel_id<MultTestKernel>();
199196
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
200202
auto BundleImpl = getSyclObjImpl(Bundle);
201203
int NumRetains = BundleImpl->size() * 2;
202204

@@ -210,5 +212,7 @@ TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
210212
EXPECT_EQ(KernelCache.size(), (size_t)2) << "Expect 2 kernels in cache";
211213
}
212214
// 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
213217
EXPECT_EQ(KernelReleaseCounter, 3) << "Expect 3 piKernelRelease calls";
214218
}

0 commit comments

Comments
 (0)