diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 914c5f7d050e66f16cc5c114f0fbea680e99c36c..f6c48a87c5cf5a6aa0c0900a01c472cb35e64399 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' diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index 6224866a2b4e8c6fcb5a0d783006eb5d8b32ddd6..ad5b7ab80c167ccfadbe3e4d5c7673859528a7b1 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; + } }; // }}} diff --git a/src/wrap_mempool.cpp b/src/wrap_mempool.cpp index 3f26a2f94a2eac2209f5e55563f04daf05e5d942..4ccb61f2f54695071ca1f17469019d7b6a0c31ce 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