Skip to content

Commit eff167b

Browse files
Enable use of default platform context extension (#627)
* 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. * Use rfind instead of index to find latest occurrance of usm_type in pickle bytes * Make sure that testing is done with host device enabled
2 parents 2907977 + e68bd14 commit eff167b

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.github/workflows/conda-package.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ jobs:
151151
run: |
152152
# echo "libintelocl.so" | tee /etc/OpenCL/vendors/intel-cpu.icd
153153
export OCL_ICD_FILENAMES=libintelocl.so
154+
export SYCL_ENABLE_HOST_DEVICE=1
154155
# clinfo -l
155156
python -m pytest --pyargs $MODULE_NAME
156157
@@ -208,7 +209,9 @@ jobs:
208209
- name: Add library
209210
run: echo "OCL_ICD_FILENAMES=C:\Miniconda\Library\lib\intelocl64.dll" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
210211
- name: Run tests
211-
run: python -m pytest --pyargs ${{ env.MODULE_NAME }}
212+
run: |
213+
set SYCL_ENABLE_HOST_DEVICE=1
214+
python -m pytest --pyargs ${{ env.MODULE_NAME }}
212215
213216
upload_linux:
214217
needs: test_linux

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";

dpctl/tests/test_sycl_usm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def test_pickling_reconstructor_invalid_type(memory_ctor):
201201
mobj = memory_ctor(1024, alignment=64)
202202
good_pickle_bytes = pickle.dumps(mobj)
203203
usm_types = expected_usm_type(memory_ctor).encode("utf-8")
204-
i = good_pickle_bytes.index(usm_types)
204+
i = good_pickle_bytes.rfind(usm_types)
205205
bad_pickle_bytes = good_pickle_bytes[:i] + b"u" + good_pickle_bytes[i + 1 :]
206206
with pytest.raises(ValueError):
207207
pickle.loads(bad_pickle_bytes)

0 commit comments

Comments
 (0)