From b2bfe5414a5101490344551ab9abcf417a03f9d2 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Tue, 12 Oct 2021 08:48:14 -0500 Subject: [PATCH 1/3] 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. --- dpctl-capi/source/dpctl_sycl_device_manager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dpctl-capi/source/dpctl_sycl_device_manager.cpp b/dpctl-capi/source/dpctl_sycl_device_manager.cpp index 713d9e29ac..67446d6350 100644 --- a/dpctl-capi/source/dpctl_sycl_device_manager.cpp +++ b/dpctl-capi/source/dpctl_sycl_device_manager.cpp @@ -124,7 +124,15 @@ struct DeviceCacheBuilder for (const auto &D : Devices) { if (mRanker(D) < 0) continue; - auto entry = cache_l.emplace(D, D); + + // Per https://github.com/intel/llvm/blob/sycl/sycl/doc/ + // extensions/PlatformContext/PlatformContext.adoc + // sycl::queue(D) would create default platform context + // for capable compiler, sycl::context(D) otherwise + auto Q = queue(D); + auto Ctx = Q.get_context(); + auto entry = cache_l.emplace(D, Ctx); + if (!entry.second) { std::cerr << "Fatal Error during device cache " "construction.\n"; From eb44ece7e68328de38f9ddf7ee1f03011a25edeb Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Tue, 12 Oct 2021 12:41:10 -0500 Subject: [PATCH 2/3] Use rfind instead of index to find latest occurrance of usm_type in pickle bytes --- dpctl/tests/test_sycl_usm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpctl/tests/test_sycl_usm.py b/dpctl/tests/test_sycl_usm.py index 036fc7e391..da19c37668 100644 --- a/dpctl/tests/test_sycl_usm.py +++ b/dpctl/tests/test_sycl_usm.py @@ -201,7 +201,7 @@ def test_pickling_reconstructor_invalid_type(memory_ctor): mobj = memory_ctor(1024, alignment=64) good_pickle_bytes = pickle.dumps(mobj) usm_types = expected_usm_type(memory_ctor).encode("utf-8") - i = good_pickle_bytes.index(usm_types) + i = good_pickle_bytes.rfind(usm_types) bad_pickle_bytes = good_pickle_bytes[:i] + b"u" + good_pickle_bytes[i + 1 :] with pytest.raises(ValueError): pickle.loads(bad_pickle_bytes) From e68bd14354e1a127b8b841de45a9f6d9bb0d352d Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Tue, 12 Oct 2021 13:02:55 -0500 Subject: [PATCH 3/3] Make sure that testing is done with host device enabled --- .github/workflows/conda-package.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 42189e6c9b..4e70c39ca5 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -151,6 +151,7 @@ jobs: run: | # echo "libintelocl.so" | tee /etc/OpenCL/vendors/intel-cpu.icd export OCL_ICD_FILENAMES=libintelocl.so + export SYCL_ENABLE_HOST_DEVICE=1 # clinfo -l python -m pytest --pyargs $MODULE_NAME @@ -208,7 +209,9 @@ jobs: - name: Add library run: echo "OCL_ICD_FILENAMES=C:\Miniconda\Library\lib\intelocl64.dll" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Run tests - run: python -m pytest --pyargs ${{ env.MODULE_NAME }} + run: | + set SYCL_ENABLE_HOST_DEVICE=1 + python -m pytest --pyargs ${{ env.MODULE_NAME }} upload_linux: needs: test_linux