From 23377f944a59b7022a2fc2c27493ba27ca45108d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 19 Oct 2020 13:13:55 -0500 Subject: [PATCH 1/3] Drop paths-ignore from github CI config --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 914c5f7d..f6c48a87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,6 @@ on: branches: - master pull_request: - paths-ignore: - - 'doc/*.rst' schedule: - cron: '17 3 * * 0' -- GitLab From 87d5a7ed33120125dece420dbf69b2391f663263 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 19 Oct 2020 13:14:18 -0500 Subject: [PATCH 2/3] Add command_qeueue::get_hex_device_version --- src/wrap_cl.hpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index 6224866a..ad5b7ab8 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -1225,7 +1225,7 @@ namespace pyopencl errno = 0; int match_count = sscanf(plat_version.c_str(), "OpenCL %d.%d ", &major_ver, &minor_ver); if (errno || match_count != 2) - throw error("Context._get_hex_version", CL_INVALID_VALUE, + throw error("Context._get_hex_platform_version", CL_INVALID_VALUE, "Platform version string did not have expected format"); return major_ver << 12 | minor_ver << 4; @@ -1576,6 +1576,39 @@ namespace pyopencl { PYOPENCL_CALL_GUARDED(clFlush, (m_queue)); } void finish() { PYOPENCL_CALL_GUARDED_THREADED(clFinish, (m_queue)); } + + // not exposed to python + int get_hex_device_version() const + { + cl_device_id dev; + + PYOPENCL_CALL_GUARDED(clGetCommandQueueInfo, + (m_queue, CL_QUEUE_DEVICE, sizeof(dev), &dev, nullptr)); + + std::string dev_version; + { + size_t param_value_size; + PYOPENCL_CALL_GUARDED(clGetDeviceInfo, + (dev, CL_DEVICE_VERSION, 0, 0, ¶m_value_size)); + + std::vector param_value(param_value_size); + PYOPENCL_CALL_GUARDED(clGetDeviceInfo, + (dev, CL_DEVICE_VERSION, param_value_size, + param_value.empty( ) ? nullptr : ¶m_value.front(), ¶m_value_size)); + + dev_version = + param_value.empty( ) ? "" : std::string(¶m_value.front(), param_value_size-1); + } + + int major_ver, minor_ver; + errno = 0; + int match_count = sscanf(dev_version.c_str(), "OpenCL %d.%d ", &major_ver, &minor_ver); + if (errno || match_count != 2) + throw error("CommandQueue._get_hex_device_version", CL_INVALID_VALUE, + "Platform version string did not have expected format"); + + return major_ver << 12 | minor_ver << 4; + } }; // }}} -- GitLab From f053edf6b83e5b0727dc9420bd5d7c61acf4de6e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 19 Oct 2020 13:14:45 -0500 Subject: [PATCH 3/3] ImmediateAllocator: use clEnqueueMigrateMemObjects to force allocation on CL1.2+ devices --- src/wrap_mempool.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/wrap_mempool.cpp b/src/wrap_mempool.cpp index 3f26a2f9..4ccb61f2 100644 --- a/src/wrap_mempool.cpp +++ b/src/wrap_mempool.cpp @@ -154,14 +154,25 @@ namespace // reported in a deferred manner, it has no way to react // (e.g. by freeing unused memory) because it is not part of // the call stack.) - unsigned zero = 0; - PYOPENCL_CALL_GUARDED(clEnqueueWriteBuffer, ( - m_queue.data(), - ptr, - /* is blocking */ CL_FALSE, - 0, std::min(s, sizeof(zero)), &zero, - 0, NULL, NULL - )); + if (m_queue.get_hex_device_version() < 0x1020) + { + unsigned zero = 0; + PYOPENCL_CALL_GUARDED(clEnqueueWriteBuffer, ( + m_queue.data(), + ptr, + /* is blocking */ CL_FALSE, + 0, std::min(s, sizeof(zero)), &zero, + 0, NULL, NULL + )); + } + else + { + PYOPENCL_CALL_GUARDED(clEnqueueMigrateMemObjects, ( + m_queue.data(), + 1, &ptr, CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED, + 0, NULL, NULL + )); + } // No need to wait for completion here. clWaitForEvents (e.g.) // cannot return mem object allocation failures. This implies that -- GitLab