Skip to content

[NFC][SYCL] Prepare unittests/kernel-and-program for getSyclObjImpl to return raw ref #19221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 57 additions & 57 deletions sycl/unittests/kernel-and-program/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ TEST_F(KernelAndProgramCacheTest, DISABLED_ProgramSourceNegativeBuild) {
// program Prg{Ctx};

// Prg.build_with_source("");
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for source programs";
}

Expand All @@ -117,9 +117,9 @@ TEST_F(KernelAndProgramCacheTest, DISABLED_ProgramSourceNegativeBuildWithOpts) {
// program Prg{Ctx};

// Prg.build_with_source("", "-g");
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for source programs";
}

Expand All @@ -131,9 +131,9 @@ TEST_F(KernelAndProgramCacheTest,

// Prg.compile_with_source("");
// Prg.link();
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for source programs";
}

Expand All @@ -146,9 +146,9 @@ TEST_F(KernelAndProgramCacheTest,

// Prg.compile_with_source("");
// Prg.link();
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for source programs";
}

Expand All @@ -161,9 +161,9 @@ TEST_F(KernelAndProgramCacheTest, KernelBundleInputState) {
sycl::kernel_bundle KernelBundle1 =
sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {KernelID1});

auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();

EXPECT_EQ(Cache.size(), 0U)
<< "Expect empty cache for kernel_bundles build with input_state.";
Expand All @@ -178,9 +178,9 @@ TEST_F(KernelAndProgramCacheTest, KernelBundleObjectState) {
sycl::kernel_bundle KernelBundle1 =
sycl::get_kernel_bundle<sycl::bundle_state::object>(Ctx, {KernelID1});

auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();

EXPECT_EQ(Cache.size(), 0U)
<< "Expect empty cache for kernel_bundles build with object_state.";
Expand All @@ -198,9 +198,9 @@ TEST_F(KernelAndProgramCacheTest, KernelBundleExecutableState) {
sycl::kernel_bundle KernelBundle2 =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(Ctx, {KernelID2});

auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();

EXPECT_EQ(Cache.size(), 1U)
<< "Expect non-empty cache for kernel_bundles with executable_state.";
Expand Down Expand Up @@ -228,9 +228,9 @@ TEST_F(KernelAndProgramCacheTest, SpecConstantCacheNegative) {
EXPECT_EQ(KernelBundle2.get_specialization_constant<SpecConst1>(), 70)
<< "Wrong specialization constant";

auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();

EXPECT_EQ(Cache.size(), 2U) << "Expect an entry for each build in the cache.";
}
Expand All @@ -251,9 +251,9 @@ TEST_F(KernelAndProgramCacheTest, KernelBundleJoin) {
KernelBundles {KernelBundle1, KernelBundle2};
sycl::kernel_bundle KernelBundle3 = sycl::join(KernelBundles);

auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();

EXPECT_EQ(Cache.size(), 1U)
<< "Expect no caching for kennel_bundle created via join.";
Expand All @@ -278,9 +278,9 @@ TEST_F(KernelAndProgramCacheTest, DISABLED_ProgramBuildPositiveBuildOpts) {
// Prg4.build_with_kernel_type<CacheTestKernel>();
// Prg5.build_with_kernel_type<CacheTestKernel2>("-a");

auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 3U) << "Expect non-empty cache for programs";
}

Expand All @@ -291,9 +291,9 @@ TEST_F(KernelAndProgramCacheTest, DISABLED_ProgramBuildNegativeCompileOpts) {

// Prg.compile_with_kernel_type<CacheTestKernel>("-g");
// Prg.link();
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for programs";
}

Expand All @@ -304,93 +304,93 @@ TEST_F(KernelAndProgramCacheTest, DISABLED_ProgramBuildNegativeLinkOpts) {

// Prg.compile_with_kernel_type<CacheTestKernel>();
// Prg.link("-g");
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);
detail::KernelProgramCache::ProgramCache &Cache =
CtxImpl->getKernelProgramCache().acquireCachedPrograms().get();
CtxImpl.getKernelProgramCache().acquireCachedPrograms().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for programs";
}

// Check that kernels built without options are cached.
TEST_F(KernelAndProgramCacheTest, DISABLED_KernelPositive) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.build_with_kernel_type<CacheTestKernel>();
// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::KernelCacheT &Cache =
CtxImpl->getKernelProgramCache().acquireKernelsPerProgramCache().get();
CtxImpl.getKernelProgramCache().acquireKernelsPerProgramCache().get();
EXPECT_EQ(Cache.size(), 1U) << "Expect non-empty cache for kernels";
}

// Check that kernels built with options are cached.
TEST_F(KernelAndProgramCacheTest, DISABLED_KernelPositiveBuildOpts) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.build_with_kernel_type<CacheTestKernel>("-g");

// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::KernelCacheT &Cache =
CtxImpl->getKernelProgramCache().acquireKernelsPerProgramCache().get();
CtxImpl.getKernelProgramCache().acquireKernelsPerProgramCache().get();
EXPECT_EQ(Cache.size(), 1U) << "Expect non-empty cache for kernels";
}

// Check that kernels built with compile options are not cached.
TEST_F(KernelAndProgramCacheTest, DISABLED_KernelNegativeCompileOpts) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.compile_with_kernel_type<CacheTestKernel>("-g");
// Prg.link();
// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::KernelCacheT &Cache =
CtxImpl->getKernelProgramCache().acquireKernelsPerProgramCache().get();
CtxImpl.getKernelProgramCache().acquireKernelsPerProgramCache().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}

// Check that kernels built with link options are not cached.
TEST_F(KernelAndProgramCacheTest, DISABLED_KernelNegativeLinkOpts) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.compile_with_kernel_type<CacheTestKernel>();
// Prg.link("-g");
// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::KernelCacheT &Cache =
CtxImpl->getKernelProgramCache().acquireKernelsPerProgramCache().get();
CtxImpl.getKernelProgramCache().acquireKernelsPerProgramCache().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}

// Check that kernels created from source are not cached.
TEST_F(KernelAndProgramCacheTest, DISABLED_KernelNegativeSource) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.build_with_source("");
// kernel Ker = Prg.get_kernel("test");

detail::KernelProgramCache::KernelCacheT &Cache =
CtxImpl->getKernelProgramCache().acquireKernelsPerProgramCache().get();
CtxImpl.getKernelProgramCache().acquireKernelsPerProgramCache().get();
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}

Expand All @@ -411,77 +411,77 @@ class MockKernelProgramCache : public detail::KernelProgramCache {
// Check that kernels built without options are cached.
TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelPositive) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.build_with_kernel_type<CacheTestKernel>();
// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::FastKernelCacheT &Cache =
MockKernelProgramCache::getFastCache(CtxImpl->getKernelProgramCache());
MockKernelProgramCache::getFastCache(CtxImpl.getKernelProgramCache());
EXPECT_EQ(Cache.size(), 1U) << "Expect non-empty cache for kernels";
}

// Check that kernels built with options are cached.
TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelPositiveBuildOpts) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.build_with_kernel_type<CacheTestKernel>("-g");

// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::FastKernelCacheT &Cache =
MockKernelProgramCache::getFastCache(CtxImpl->getKernelProgramCache());
MockKernelProgramCache::getFastCache(CtxImpl.getKernelProgramCache());
EXPECT_EQ(Cache.size(), 1U) << "Expect non-empty cache for kernels";
}

// Check that kernels built with compile options are not cached.
TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelNegativeCompileOpts) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.compile_with_kernel_type<CacheTestKernel>("-g");
// Prg.link();
// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::FastKernelCacheT &Cache =
MockKernelProgramCache::getFastCache(CtxImpl->getKernelProgramCache());
MockKernelProgramCache::getFastCache(CtxImpl.getKernelProgramCache());
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}

// Check that kernels built with link options are not cached.
TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelNegativeLinkOpts) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.compile_with_kernel_type<CacheTestKernel>();
// Prg.link("-g");
// kernel Ker = Prg.get_kernel<CacheTestKernel>();
detail::KernelProgramCache::FastKernelCacheT &Cache =
MockKernelProgramCache::getFastCache(CtxImpl->getKernelProgramCache());
MockKernelProgramCache::getFastCache(CtxImpl.getKernelProgramCache());
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}

// Check that kernels are not cached if program is created from multiple
// programs.
TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelNegativeLinkedProgs) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg1{Ctx};
// program Prg2{Ctx};
Expand All @@ -492,23 +492,23 @@ TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelNegativeLinkedProgs) {
// kernel Ker = Prg.get_kernel<CacheTestKernel>();

detail::KernelProgramCache::FastKernelCacheT &Cache =
MockKernelProgramCache::getFastCache(CtxImpl->getKernelProgramCache());
MockKernelProgramCache::getFastCache(CtxImpl.getKernelProgramCache());
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}

// Check that kernels created from source are not cached.
TEST_F(KernelAndProgramFastCacheTest, DISABLED_KernelNegativeSource) {
context Ctx{Plt};
auto CtxImpl = detail::getSyclObjImpl(Ctx);
detail::context_impl &CtxImpl = *detail::getSyclObjImpl(Ctx);

globalCtx.reset(new TestCtx{CtxImpl->getHandleRef()});
globalCtx.reset(new TestCtx{CtxImpl.getHandleRef()});

// program Prg{Ctx};

// Prg.build_with_source("");
// kernel Ker = Prg.get_kernel("test");

detail::KernelProgramCache::FastKernelCacheT &Cache =
MockKernelProgramCache::getFastCache(CtxImpl->getKernelProgramCache());
MockKernelProgramCache::getFastCache(CtxImpl.getKernelProgramCache());
EXPECT_EQ(Cache.size(), 0U) << "Expect empty cache for kernels";
}
Loading
Loading