Skip to content

Commit b2634a1

Browse files
authored
[SYCL][Test] Extend MultipleDevsCache test to check different order of devices (#16175)
This test case didn't work properly (incorrect number of retains/releases) before the fix for multi-device case: #15546
1 parent 28a09bc commit b2634a1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

+18-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ static ur_result_t redefinedKernelRelease(void *) {
8686
return UR_RESULT_SUCCESS;
8787
}
8888

89-
class MultipleDeviceCacheTest : public ::testing::Test {
89+
class MultipleDeviceCacheTest
90+
: public testing::TestWithParam<std::array<size_t, NumDevices>> {
9091
public:
9192
MultipleDeviceCacheTest() : Mock{}, Plt{sycl::platform()} {}
9293

@@ -109,17 +110,25 @@ class MultipleDeviceCacheTest : public ::testing::Test {
109110

110111
// Test that program is retained for each subset of the list of devices and that
111112
// number of urKernelRelease calls is correct.
112-
TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
113+
TEST_P(MultipleDeviceCacheTest, ProgramRetain) {
113114
{
115+
// Reset counters
116+
RetainCounter = 0;
117+
KernelReleaseCounter = 0;
118+
114119
std::vector<sycl::device> Devices = Plt.get_devices(info::device_type::gpu);
115120
sycl::context Context(Devices);
116121
sycl::queue Queue(Context, Devices[0]);
117122
assert(Devices.size() == NumDevices &&
118123
Context.get_devices().size() == NumDevices);
119124

125+
auto DeviceIndexes = GetParam();
120126
auto KernelID = sycl::get_kernel_id<MultipleDevsCacheTestKernel>();
121127
auto Bundle = sycl::get_kernel_bundle<sycl::bundle_state::input>(
122-
Queue.get_context(), {KernelID});
128+
Queue.get_context(),
129+
{Devices[DeviceIndexes[0]], Devices[DeviceIndexes[1]],
130+
Devices[DeviceIndexes[2]]},
131+
{KernelID});
123132
assert(Bundle.get_devices().size() == NumDevices);
124133

125134
// Internally we create a kernel_bundle for the device associated with the
@@ -178,3 +187,9 @@ TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
178187
// when handle is returned to the caller).
179188
EXPECT_EQ(KernelReleaseCounter, 4) << "Expect 4 piKernelRelease calls";
180189
}
190+
191+
INSTANTIATE_TEST_SUITE_P(
192+
MultipleDeviceCacheInstance, MultipleDeviceCacheTest,
193+
testing::Values(std::array<size_t, NumDevices>{0, 1, 2},
194+
std::array<size_t, NumDevices>{1, 0, 2},
195+
std::array<size_t, NumDevices>{2, 1, 0}));

0 commit comments

Comments
 (0)