Skip to content

Commit b2bfe54

Browse files
Enable use of default platform context extension
Instead of using sycl::context(const sycl::device &D) constructor to created cached context, use sycl::queue(const sycl::device &D) and extract context from the queue. For capable compiler, i.e. the one that supports https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/PlatformContext/PlatformContext.adoc the queue constructor will use platform default context. For other compilers the sycl::context(D) will get called, so the behavior won't change. If compiler supports default platform context extension, use that when building the cached.
1 parent 2907977 commit b2bfe54

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dpctl-capi/source/dpctl_sycl_device_manager.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ struct DeviceCacheBuilder
124124
for (const auto &D : Devices) {
125125
if (mRanker(D) < 0)
126126
continue;
127-
auto entry = cache_l.emplace(D, D);
127+
128+
// Per https://github.com/intel/llvm/blob/sycl/sycl/doc/
129+
// extensions/PlatformContext/PlatformContext.adoc
130+
// sycl::queue(D) would create default platform context
131+
// for capable compiler, sycl::context(D) otherwise
132+
auto Q = queue(D);
133+
auto Ctx = Q.get_context();
134+
auto entry = cache_l.emplace(D, Ctx);
135+
128136
if (!entry.second) {
129137
std::cerr << "Fatal Error during device cache "
130138
"construction.\n";

0 commit comments

Comments
 (0)