Skip to content

Commit bd3bb9e

Browse files
[NFC][SYCL] Prepare unittests/program_manager for getSyclObjImpl to return raw ref (#19220)
I'm planning to change `getSyclObjImpl` to return a raw reference in a later patch, uploading a bunch of PRs in preparation to that to make the subsequent review easier.
1 parent e5676ad commit bd3bb9e

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

sycl/unittests/program_manager/BuildLog.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ TEST(BuildLog, OutputNothingOnLevel1) {
6363
sycl::context Ctx{Dev};
6464
sycl::queue Queue{Ctx, Dev};
6565

66-
auto ContextImpl = getSyclObjImpl(Ctx);
66+
context_impl &ContextImpl = *getSyclObjImpl(Ctx);
6767
// Make sure no kernels are cached
68-
ContextImpl->getKernelProgramCache().reset();
68+
ContextImpl.getKernelProgramCache().reset();
6969

7070
LogRequested = false;
7171
sycl::kernel_bundle KernelBundle =
@@ -90,9 +90,9 @@ TEST(BuildLog, OutputLogOnLevel2) {
9090
sycl::context Ctx{Dev};
9191
sycl::queue Queue{Ctx, Dev};
9292

93-
auto ContextImpl = getSyclObjImpl(Ctx);
93+
context_impl &ContextImpl = *getSyclObjImpl(Ctx);
9494
// Make sure no kernels are cached
95-
ContextImpl->getKernelProgramCache().reset();
95+
ContextImpl.getKernelProgramCache().reset();
9696

9797
LogRequested = false;
9898
sycl::kernel_bundle KernelBundle =

sycl/unittests/program_manager/DynamicLinking/DynamicLinking.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,14 @@ TEST(DynamicLinking, KernelBundleMutualDepBuildIndirect) {
399399
}
400400

401401
template <sycl::bundle_state State>
402-
std::shared_ptr<sycl::detail::device_image_impl>
402+
sycl::detail::device_image_impl &
403403
getImage(const sycl::kernel_bundle<State> &KernelBundle,
404404
const sycl::kernel_id &KernelID) {
405405
auto It =
406406
std::find_if(KernelBundle.begin(), KernelBundle.end(),
407407
[&](auto Image) { return Image.has_kernel(KernelID); });
408408
EXPECT_NE(It, KernelBundle.end());
409-
return sycl::detail::getSyclObjImpl(*It);
409+
return *sycl::detail::getSyclObjImpl(*It);
410410
}
411411

412412
template <sycl::bundle_state State>
@@ -418,16 +418,16 @@ void runSpecConstChecksUnlinked(
418418
20);
419419
// Kernel bundles store spec constant values even if they're not part of any
420420
// images, check image spec const blobs.
421-
std::shared_ptr<sycl::detail::device_image_impl> ImgA =
421+
sycl::detail::device_image_impl &ImgA =
422422
getImage(KernelBundle,
423423
sycl::get_kernel_id<DynamicLinkingTest::MutualDepKernelA>());
424-
std::vector<unsigned char> &BlobA = ImgA->get_spec_const_blob_ref();
424+
std::vector<unsigned char> &BlobA = ImgA.get_spec_const_blob_ref();
425425
int SpecConstVal1 = *reinterpret_cast<int *>(BlobA.data());
426426
EXPECT_EQ(SpecConstVal1, 10);
427-
std::shared_ptr<sycl::detail::device_image_impl> ImgB =
427+
sycl::detail::device_image_impl &ImgB =
428428
getImage(KernelBundle,
429429
sycl::get_kernel_id<DynamicLinkingTest::MutualDepKernelB>());
430-
std::vector<unsigned char> &BlobB = ImgB->get_spec_const_blob_ref();
430+
std::vector<unsigned char> &BlobB = ImgB.get_spec_const_blob_ref();
431431
int SpecConstVal2 = *reinterpret_cast<int *>(BlobB.data());
432432
EXPECT_EQ(SpecConstVal2, 20);
433433
}
@@ -438,16 +438,16 @@ void runSpecConstChecksLinked(
438438
EXPECT_EQ(KernelBundle.get_specialization_constant<SpecConst2>(), 20);
439439
// Kernel bundles store spec constant values even if they're not part of any
440440
// images, check image spec const blobs.
441-
std::shared_ptr<sycl::detail::device_image_impl> ImgA =
441+
sycl::detail::device_image_impl &ImgA =
442442
getImage(KernelBundle,
443443
sycl::get_kernel_id<DynamicLinkingTest::MutualDepKernelA>());
444-
std::shared_ptr<sycl::detail::device_image_impl> ImgB =
444+
sycl::detail::device_image_impl &ImgB =
445445
getImage(KernelBundle,
446446
sycl::get_kernel_id<DynamicLinkingTest::MutualDepKernelB>());
447-
EXPECT_EQ(ImgA, ImgB);
448-
const std::vector<unsigned char> &Blob = ImgA->get_spec_const_blob_ref();
447+
EXPECT_EQ(&ImgA, &ImgB);
448+
const std::vector<unsigned char> &Blob = ImgA.get_spec_const_blob_ref();
449449
const sycl::detail::device_image_impl::SpecConstMapT &SpecConstMap =
450-
ImgA->get_spec_const_data_ref();
450+
ImgA.get_spec_const_data_ref();
451451

452452
auto It = SpecConstMap.find("SC1");
453453
ASSERT_NE(It, SpecConstMap.end());

sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ class MockHandler : public sycl::handler {
165165

166166
const sycl::detail::KernelArgMask *getKernelArgMaskFromBundle(
167167
const sycl::kernel_bundle<sycl::bundle_state::input> &KernelBundle,
168-
std::shared_ptr<sycl::detail::queue_impl> QueueImpl) {
168+
sycl::detail::queue_impl &QueueImpl) {
169169

170170
auto ExecBundle = sycl::link(sycl::compile(KernelBundle));
171171
EXPECT_FALSE(ExecBundle.empty()) << "Expect non-empty exec kernel bundle";
172172

173173
// Emulating processing of command group function
174-
MockHandler MockCGH(*QueueImpl);
174+
MockHandler MockCGH(QueueImpl);
175175
MockCGH.use_kernel_bundle(ExecBundle);
176176
MockCGH.single_task<EAMTestKernel>([] {}); // Actual kernel does not matter
177177

@@ -218,7 +218,7 @@ TEST(EliminatedArgMask, KernelBundleWith2Kernels) {
218218

219219
const sycl::detail::KernelArgMask *EliminatedArgMask =
220220
getKernelArgMaskFromBundle(KernelBundle,
221-
sycl::detail::getSyclObjImpl(Queue));
221+
*sycl::detail::getSyclObjImpl(Queue));
222222
assert(EliminatedArgMask && "EliminatedArgMask must be not null");
223223

224224
sycl::detail::KernelArgMask ExpElimArgMask(EAMTestKernelNumArgs);

0 commit comments

Comments
 (0)