From a62682d2d151ca75c3f1bd1be57a197d6d9fed1d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Sun, 20 Jun 2010 16:48:56 +1000 Subject: Add OpenCL 1.1 preferred work size query to QCLKernel --- src/opencl/qclext_p.h | 3 +++ src/opencl/qclkernel.cpp | 20 ++++++++++++++++++++ src/opencl/qclkernel.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/src/opencl/qclext_p.h b/src/opencl/qclext_p.h index 68a17b7..a50df50 100644 --- a/src/opencl/qclext_p.h +++ b/src/opencl/qclext_p.h @@ -90,6 +90,9 @@ #ifndef CL_MEM_OFFSET #define CL_MEM_OFFSET 0x1108 #endif +#ifndef CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE +#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3 +#endif // OpenCL-OpenGL sharing. #ifndef CL_INVALID_CL_SHAREGROUP_REFERENCE_KHR diff --git a/src/opencl/qclkernel.cpp b/src/opencl/qclkernel.cpp index b63cc02..aceaa9f 100644 --- a/src/opencl/qclkernel.cpp +++ b/src/opencl/qclkernel.cpp @@ -43,6 +43,7 @@ #include "qclprogram.h" #include "qclbuffer.h" #include "qclcontext.h" +#include "qclext_p.h" #include #include #include @@ -509,6 +510,25 @@ QCLWorkSize QCLKernel::bestLocalWorkSizeImage3D() const return QCLWorkSize(8, 8, 8); } +/*! + Returns the preferred work group size multiple, which is a + performance hint for the local work group size on OpenCL 1.1 + systems. Returns zero if the system is OpenCL 1.0, or a + preferred work group size multiple is not available. +*/ +size_t QCLKernel::preferredWorkSizeMultiple() const +{ + Q_D(const QCLKernel); + size_t size; + if (clGetKernelWorkGroupInfo + (d->id, d->context->defaultDevice().deviceId(), + CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, + sizeof(size), &size, 0) != CL_SUCCESS) + return 0; + else + return size; +} + /*! Sets argument \a index for this kernel to \a value. diff --git a/src/opencl/qclkernel.h b/src/opencl/qclkernel.h index 9ad1d1e..f0721c0 100644 --- a/src/opencl/qclkernel.h +++ b/src/opencl/qclkernel.h @@ -109,6 +109,8 @@ public: QCLWorkSize bestLocalWorkSizeImage2D() const; QCLWorkSize bestLocalWorkSizeImage3D() const; + size_t preferredWorkSizeMultiple() const; + void setArg(int index, cl_int value); void setArg(int index, cl_uint value); void setArg(int index, cl_long value); -- cgit v1.2.3