From ececa4b406e5cf13b074f3f846de895d90492233 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Sun, 16 May 2010 13:22:59 +1000 Subject: Fix compile error on 64-bit systems. --- src/openclgl/qclcontextgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openclgl/qclcontextgl.cpp b/src/openclgl/qclcontextgl.cpp index d6235e2..53bcbb5 100644 --- a/src/openclgl/qclcontextgl.cpp +++ b/src/openclgl/qclcontextgl.cpp @@ -225,7 +225,7 @@ bool QCLContextGL::create(const QCLPlatform &platform) (q_PFNCLGETGLCONTEXTINFOKHR)clGetExtensionFunctionAddress ("clGetGLContextInfoKHR"); if (getGLContextInfo && hasSharing) { - cl_uint size; + size_t size; cl_device_id currentDev; if(getGLContextInfo(properties.data(), CL_DEVICES_FOR_GL_CONTEXT_KHR, -- cgit v1.2.3 From 461142f50dc99cde1fe065d2392e0bb17091f875 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 17 May 2010 15:07:10 +1000 Subject: Simplify the QCLVector API Explicit map() and unmap() isn't really necessary. The user can create a QCLBuffer if they need that level of control. --- src/opencl/qclvector.cpp | 70 +++++----------------------------------------- src/opencl/qclvector.h | 40 -------------------------- tests/auto/qcl/tst_qcl.cpp | 16 ++--------- 3 files changed, 10 insertions(+), 116 deletions(-) diff --git a/src/opencl/qclvector.cpp b/src/opencl/qclvector.cpp index b53c3da..10b60c0 100644 --- a/src/opencl/qclvector.cpp +++ b/src/opencl/qclvector.cpp @@ -55,11 +55,10 @@ QT_BEGIN_NAMESPACE OpenCL buffer object to make it appear as a host-accessible array of elements of type T. - Whenever the host CPU calls operator[]() or map(), the - array's contents are mapped into host-accessible memory for - direct access. When the host calls unmap() or sets the vector - on a QCLKernel as an argument, the data is copied back to the - OpenCL compute device (e.g., the GPU). + Whenever the host CPU calls operator[](), the array's contents + are copied into host-accessible memory for direct access. When the + host sets the vector on a QCLKernel as an argument, the data is + copied back to the OpenCL compute device (e.g., the GPU). The type T is restricted to primitive and movable types that do not require explicit construction, destruction, or operator=(). @@ -390,60 +389,22 @@ cl_mem QCLVectorBase::kernelArg() const \fn T &QCLVector::operator[](int index) Returns a reference to the element at \a index in this OpenCL vector. - The vector will be mapped into host memory if necessary. - - \sa map() + The vector will be copied to host memory if necessary. */ /*! \fn const T &QCLVector::operator[](int index) const Returns a const reference to the element at \a index in this - OpenCL vector. The vector will be mapped into host memory + OpenCL vector. The vector will be copied to host memory if necessary. - - \sa map() -*/ - -/*! - \fn void QCLVector::map() - - Maps this OpenCL vector into the host CPU's address space so that - its contents can be read or written. Once the host CPU no longer - needs to access the vector's contents, it should call unmap(). - - This function does nothing if the vector is already mapped. - - The vector will be implicitly unmapped if it is set on a QCLKernel - as an argument. - - \sa unmap(), isMapped() -*/ - -/*! - \fn void QCLVector::unmap() - - Unmaps this OpenCL vector from the host CPU's address space. - The data can then be accessed by a QCLKernel running on the - OpenCL compute device. - - \sa map(), isMapped() -*/ - -/*! - \fn bool QCLVector::isMapped() const - - Returns true if this vector is mapped into the host CPU's - address space; false otherwise. - - \sa map(), unmap() */ /*! \fn void QCLVector::read(T *data, int count, int offset) Reads the \a count elements starting \a offset in this vector - into \a data. The vector does not need to be mapped. + into \a data. \sa write() */ @@ -452,7 +413,6 @@ cl_mem QCLVectorBase::kernelArg() const \fn void QCLVector::write(const T *data, int count, int offset) Writes the \a count elements from \a data to \a offset in this vector. - The vector does not need to be mapped. \sa read() */ @@ -462,22 +422,6 @@ cl_mem QCLVectorBase::kernelArg() const \overload Writes the contents of \a data to \a offset in this vector. - The vector does not need to be mapped. -*/ - -/*! - \fn T *QCLVector::data() const - - Returns a pointer to the first element in the vector. - The vector will be mapped into host memory if necessary. - - \sa map() -*/ - -/*! - \fn cl_mem QCLVector::memoryId() const - - Returns the native OpenCL memory buffer identifier for this vector. */ /*! diff --git a/src/opencl/qclvector.h b/src/opencl/qclvector.h index cd95d80..1864e85 100644 --- a/src/opencl/qclvector.h +++ b/src/opencl/qclvector.h @@ -107,19 +107,11 @@ public: T &operator[](int index); const T &operator[](int index) const; - void map(); - void unmap(); - bool isMapped() const; - void read(T *data, int count, int offset = 0); void write(const T *data, int count, int offset = 0); void write(const QVector &data, int offset = 0); - T *data() const; - - cl_mem memoryId() const; QCLContext *context() const; - QCLBuffer toBuffer() const; private: @@ -188,24 +180,6 @@ Q_INLINE_TEMPLATE const T &QCLVector::operator[](int index) const return (reinterpret_cast(m_mapped))[index]; } -template -Q_INLINE_TEMPLATE void QCLVector::map() -{ - QCLVectorBase::map(); -} - -template -Q_INLINE_TEMPLATE void QCLVector::unmap() -{ - QCLVectorBase::unmap(); -} - -template -Q_INLINE_TEMPLATE bool QCLVector::isMapped() const -{ - return m_mapped != 0; -} - template Q_INLINE_TEMPLATE void QCLVector::write (const T *data, int count, int offset) @@ -229,20 +203,6 @@ Q_INLINE_TEMPLATE void QCLVector::write write(data.constData(), data.size(), offset); } -template -Q_INLINE_TEMPLATE T *QCLVector::data() const -{ - if (!m_mapped) - map(); - return reinterpret_cast(m_mapped); -} - -template -Q_INLINE_TEMPLATE cl_mem QCLVector::memoryId() const -{ - return QCLVectorBase::memoryId(); -} - template Q_INLINE_TEMPLATE QCLContext *QCLVector::context() const { diff --git a/tests/auto/qcl/tst_qcl.cpp b/tests/auto/qcl/tst_qcl.cpp index 066ff88..1837395 100644 --- a/tests/auto/qcl/tst_qcl.cpp +++ b/tests/auto/qcl/tst_qcl.cpp @@ -377,46 +377,37 @@ void tst_QCL::vectorBuffer() QVERIFY(vector1.isNull()); QVERIFY(vector1.isEmpty()); QCOMPARE(vector1.size(), 0); - QVERIFY(vector1.memoryId() == 0); + QVERIFY(vector1.toBuffer().memoryId() == 0); QVERIFY(vector1.context() == 0); - QVERIFY(!vector1.isMapped()); vector1 = context.createVector(100); QVERIFY(!vector1.isNull()); QVERIFY(!vector1.isEmpty()); QCOMPARE(vector1.size(), 100); - QVERIFY(vector1.memoryId() != 0); + QVERIFY(vector1.toBuffer().memoryId() != 0); QVERIFY(vector1.context() == &context); - QVERIFY(!vector1.isMapped()); for (int index = 0; index < 100; ++index) vector1[index] = float(index); - QVERIFY(vector1.isMapped()); - vector1.unmap(); - QVERIFY(!vector1.isMapped()); for (int index = 0; index < 100; ++index) QCOMPARE(vector1[index], float(index)); - QVERIFY(vector1.isMapped()); QCLKernel addToVector = program.createKernel("addToVector"); addToVector.setGlobalWorkSize(vector1.size()); addToVector(vector1, 42.0f); - QVERIFY(!vector1.isMapped()); for (int index = 0; index < 100; ++index) { QCOMPARE(constVectorAt(vector1, index), float(index + 42)); QCOMPARE(vector1[index], float(index + 42)); } - QVERIFY(vector1.isMapped()); vector1.release(); QVERIFY(vector1.isNull()); QVERIFY(vector1.isEmpty()); QCOMPARE(vector1.size(), 0); - QVERIFY(vector1.memoryId() == 0); + QVERIFY(vector1.toBuffer().memoryId() == 0); QVERIFY(vector1.context() == 0); - QVERIFY(!vector1.isMapped()); } void tst_QCL::eventProfiling() @@ -429,7 +420,6 @@ void tst_QCL::eventProfiling() QCLVector vector1 = context.createVector(20000); for (int index = 0; index < vector1.size(); ++index) vector1[index] = float(index); - vector1.unmap(); QCLKernel addToVector = program.createKernel("addToVector"); addToVector.setGlobalWorkSize(vector1.size()); -- cgit v1.2.3 From 194dcab759aeb74aaf70a9c00f77c48fb66acf77 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 17 May 2010 15:50:50 +1000 Subject: qdoc fix --- src/opencl/qcldevice.cpp | 2 +- src/opencl/qclplatform.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opencl/qcldevice.cpp b/src/opencl/qcldevice.cpp index 4c138b1..08f8f68 100644 --- a/src/opencl/qcldevice.cpp +++ b/src/opencl/qcldevice.cpp @@ -872,7 +872,7 @@ bool qt_cl_has_extension(const char *list, size_t listLen, const char *name) } /*! - Returns this if this device has an extension called \a name; + Returns true if this device has an extension called \a name; false otherwise. This function is more efficient than checking for \a name diff --git a/src/opencl/qclplatform.cpp b/src/opencl/qclplatform.cpp index 742e1f7..3739f0e 100644 --- a/src/opencl/qclplatform.cpp +++ b/src/opencl/qclplatform.cpp @@ -214,7 +214,7 @@ QStringList QCLPlatform::extensions() const bool qt_cl_has_extension(const char *list, size_t listLen, const char *name); /*! - Returns this if this platform has an extension called \a name; + Returns true if this platform has an extension called \a name; false otherwise. This function is more efficient than checking for \a name -- cgit v1.2.3 From a8de987f8381130fdf695449c3675a9b42d81274 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 2 Jun 2010 17:13:08 +1000 Subject: Add a function for querying the event's command type. --- src/opencl/qclevent.cpp | 30 ++++++++++++++++++------------ src/opencl/qclevent.h | 1 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/opencl/qclevent.cpp b/src/opencl/qclevent.cpp index f751186..e7d7d1e 100644 --- a/src/opencl/qclevent.cpp +++ b/src/opencl/qclevent.cpp @@ -235,6 +235,22 @@ cl_int QCLEvent::status() const return st; } +/*! + Returns the type of command that generated this event. +*/ +cl_command_type QCLEvent::commandType() const +{ + if (!m_id) + return 0; + cl_command_type type; + cl_int error = clGetEventInfo + (m_id, CL_EVENT_COMMAND_TYPE, sizeof(type), &type, 0); + if (error != CL_SUCCESS) + return 0; + else + return type; +} + /*! Waits for this event to be signalled as finished. The calling thread is blocked until the event is signalled. This function returns @@ -426,18 +442,8 @@ QDebug operator<<(QDebug dbg, const QCLEvent &event) dbg << "QCLEvent()"; return dbg; } - cl_command_type command; - cl_int status; - if (clGetEventInfo(id, CL_EVENT_COMMAND_TYPE, - sizeof(command), &command, 0) != CL_SUCCESS) { - dbg << "QCLEvent(invalid)"; - return dbg; - } - if (clGetEventInfo(id, CL_EVENT_COMMAND_EXECUTION_STATUS, - sizeof(status), &status, 0) != CL_SUCCESS) { - dbg << "QCLEvent(invalid)"; - return dbg; - } + cl_command_type command = event.commandType(); + cl_int status = event.status(); const char *commandName; switch (command) { case CL_COMMAND_NDRANGE_KERNEL: diff --git a/src/opencl/qclevent.h b/src/opencl/qclevent.h index ce6da59..3755846 100644 --- a/src/opencl/qclevent.h +++ b/src/opencl/qclevent.h @@ -73,6 +73,7 @@ public: bool isErrored() const { return status() < 0; } cl_int status() const; + cl_command_type commandType() const; void waitForFinished(); -- cgit v1.2.3 From 99523e563d9012f0827ba261844978884adbc543 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 2 Jun 2010 19:00:30 +1000 Subject: Computation of best-fit local work sizes --- src/opencl/opencl.pro | 3 +- src/opencl/qcldevice.cpp | 4 +- src/opencl/qcldevice.h | 2 +- src/opencl/qclworksize.cpp | 220 ++++++++++++++++++++++++++++++++++++++++++++ src/opencl/qclworksize.h | 6 ++ src/opencl/qclworksize.qdoc | 154 ------------------------------- util/clinfo/clinfo.cpp | 3 +- 7 files changed, 233 insertions(+), 159 deletions(-) create mode 100644 src/opencl/qclworksize.cpp delete mode 100644 src/opencl/qclworksize.qdoc diff --git a/src/opencl/opencl.pro b/src/opencl/opencl.pro index c7dd01e..00f4c0e 100644 --- a/src/opencl/opencl.pro +++ b/src/opencl/opencl.pro @@ -56,7 +56,8 @@ SOURCES += \ qclplatform.cpp \ qclprogram.cpp \ qclsampler.cpp \ - qclvector.cpp + qclvector.cpp \ + qclworksize.cpp HEADERS += $$PRIVATE_HEADERS DEFINES += QT_BUILD_CL_LIB diff --git a/src/opencl/qcldevice.cpp b/src/opencl/qcldevice.cpp index 08f8f68..fe120c9 100644 --- a/src/opencl/qcldevice.cpp +++ b/src/opencl/qcldevice.cpp @@ -361,9 +361,9 @@ QCLWorkSize QCLDevice::maximumWorkItemSize() const \sa maximumWorkItemSize() */ -int QCLDevice::maximumWorkItemsPerGroup() const +size_t QCLDevice::maximumWorkItemsPerGroup() const { - return int(qt_cl_paramSize(m_id, CL_DEVICE_MAX_WORK_GROUP_SIZE)); + return qt_cl_paramSize(m_id, CL_DEVICE_MAX_WORK_GROUP_SIZE); } /*! diff --git a/src/opencl/qcldevice.h b/src/opencl/qcldevice.h index 335114b..241496e 100644 --- a/src/opencl/qcldevice.h +++ b/src/opencl/qcldevice.h @@ -87,7 +87,7 @@ public: QSysInfo::Endian byteOrder() const; QCLWorkSize maximumWorkItemSize() const; - int maximumWorkItemsPerGroup() const; + size_t maximumWorkItemsPerGroup() const; bool hasImage2D() const; bool hasImage3D() const; diff --git a/src/opencl/qclworksize.cpp b/src/opencl/qclworksize.cpp new file mode 100644 index 0000000..3b40808 --- /dev/null +++ b/src/opencl/qclworksize.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenCL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qclworksize.h" +#include "qcldevice.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCLWorkSize + \brief The QCLWorkSize class defines the size of an item of work for an OpenCL kernel. + \since 4.7 + \ingroup opencl + + OpenCL work sizes may be single-dimensional, two-dimensional, + or three-dimensional: + + \code + QCLWorkSize oned(128); + QCLWorkSize twod(16, 16); + QCLWorkSize threed(32, 32, 16); + ... + QCLKernel kernel = ...; + kernel.setGlobalWorkSize(oned); + kernel.setGlobalWorkSize(twod); + kernel.setGlobalWorkSize(threed); + \endcode + + For convenience, QCLKernel::setGlobalWorkSize() and + QCLKernel::setLocalWorkSize() can be specified by a QCLWorkSize + object or direct numeric arguments: + + \code + QCLKernel kernel = ...; + kernel.setGlobalWorkSize(128); + kernel.setGlobalWorkSize(16, 16); + kernel.setGlobalWorkSize(32, 32, 16); + \endcode + + \sa QCLKernel +*/ + +/*! + \fn QCLWorkSize::QCLWorkSize() + + Constructs a default work size consisting of a single dimension + with width() set to 1. +*/ + +/*! + \fn QCLWorkSize::QCLWorkSize(size_t size) + + Constructs a single-dimensional work size with width() set to \a size. +*/ + +/*! + \fn QCLWorkSize::QCLWorkSize(size_t width, size_t height) + + Constructs a two-dimensional work size of \a width x \a height. +*/ + +/*! + \fn QCLWorkSize::QCLWorkSize(const QSize &size) + + Constructs a two-dimensional work size set to \a size. +*/ + +/*! + \fn QCLWorkSize::QCLWorkSize(size_t width, size_t height, size_t depth) + + Constructs a three-dimensional work size of \a width x \a height x + \a depth. +*/ + +/*! + \fn size_t QCLWorkSize::dimensions() const + + Returns the number of dimensions for this work size, 1, 2, or 3. +*/ + +/*! + \fn size_t QCLWorkSize::width() const + + Returns the width of this work size specification. +*/ + +/*! + \fn size_t QCLWorkSize::height() const + + Returns the height of this work size specification. +*/ + +/*! + \fn size_t QCLWorkSize::depth() const + + Returns the depth of this work size specification. +*/ + +/*! + \fn const size_t *QCLWorkSize::sizes() const + + Returns a const pointer to the size array within this object. +*/ + +/*! + \fn bool QCLWorkSize::operator==(const QCLWorkSize &other) const + + Returns true if this work size specification has the same + dimensions as \a other; false otherwise. + + \sa operator!=() +*/ + +/*! + \fn bool QCLWorkSize::operator!=(const QCLWorkSize &other) const + + Returns true if this work size specification does not have + the same dimensions as \a other; false otherwise. + + \sa operator==() +*/ + +static size_t qt_gcd_of_size(size_t x, size_t y) +{ + size_t remainder; + while ((remainder = x % y) != 0) { + x = y; + y = remainder; + } + return y; +} + +/*! + Returns the best-fit local work size that evenly divides this work + size and fits within the maximums defined by \a maxWorkItemSize + and \a maxItemsPerGroup. + + This function is typically used to convert an arbitrary global + work size on a QCLKernel into a compatible local work size. + + \sa QCLKernel::setLocalWorkSize() +*/ +QCLWorkSize QCLWorkSize::toLocalWorkSize + (const QCLWorkSize &maxWorkItemSize, size_t maxItemsPerGroup) const +{ + // Adjust for the maximum work item size in each dimension. + size_t width = m_dim >= 1 ? qt_gcd_of_size(m_sizes[0], maxWorkItemSize.width()) : 1; + size_t height = m_dim >= 2 ? qt_gcd_of_size(m_sizes[1], maxWorkItemSize.height()) : 1; + size_t depth = m_dim >= 3 ? qt_gcd_of_size(m_sizes[2], maxWorkItemSize.depth()) : 1; + + // Reduce in size by a factor of 2 until underneath the maximum group size. + while (maxItemsPerGroup && (width * height * depth) > maxItemsPerGroup) { + width = (width > 1) ? (width / 2) : 1; + height = (height > 1) ? (height / 2) : 1; + depth = (depth > 1) ? (depth / 2) : 1; + } + + // Return the final result. + if (m_dim >= 3) + return QCLWorkSize(width, height, depth); + else if (m_dim >= 2) + return QCLWorkSize(width, height); + else + return QCLWorkSize(width); +} + +/*! + Returns the best-fit local work size that evenly divides this + work size and fits within the maximum work group size of \a device. + + This function is typically used to convert an arbitrary global + work size on a QCLKernel into a compatible local work size. + + \sa QCLKernel::setLocalWorkSize() +*/ +QCLWorkSize QCLWorkSize::toLocalWorkSize(const QCLDevice &device) const +{ + return toLocalWorkSize(device.maximumWorkItemSize(), + device.maximumWorkItemsPerGroup()); +} + +QT_END_NAMESPACE diff --git a/src/opencl/qclworksize.h b/src/opencl/qclworksize.h index 719338c..b1e2ca6 100644 --- a/src/opencl/qclworksize.h +++ b/src/opencl/qclworksize.h @@ -51,6 +51,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(CL) +class QCLDevice; + class Q_CL_EXPORT QCLWorkSize { public: @@ -76,6 +78,10 @@ public: bool operator==(const QCLWorkSize &other) const; bool operator!=(const QCLWorkSize &other) const; + QCLWorkSize toLocalWorkSize + (const QCLWorkSize &maxWorkItemSize, size_t maxItemsPerGroup) const; + QCLWorkSize toLocalWorkSize(const QCLDevice &device) const; + private: size_t m_dim; size_t m_sizes[3]; diff --git a/src/opencl/qclworksize.qdoc b/src/opencl/qclworksize.qdoc deleted file mode 100644 index 122694d..0000000 --- a/src/opencl/qclworksize.qdoc +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenCL module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QCLWorkSize - \brief The QCLWorkSize class defines the size of an item of work for an OpenCL kernel. - \since 4.7 - \ingroup opencl - - OpenCL work sizes may be single-dimensional, two-dimensional, - or three-dimensional: - - \code - QCLWorkSize oned(128); - QCLWorkSize twod(16, 16); - QCLWorkSize threed(32, 32, 16); - ... - QCLKernel kernel = ...; - kernel.setGlobalWorkSize(oned); - kernel.setGlobalWorkSize(twod); - kernel.setGlobalWorkSize(threed); - \endcode - - For convenience, QCLKernel::setGlobalWorkSize() and - QCLKernel::setLocalWorkSize() can be specified by a QCLWorkSize - object or direct numeric arguments: - - \code - QCLKernel kernel = ...; - kernel.setGlobalWorkSize(128); - kernel.setGlobalWorkSize(16, 16); - kernel.setGlobalWorkSize(32, 32, 16); - \endcode - - \sa QCLKernel -*/ - -/*! - \fn QCLWorkSize::QCLWorkSize() - - Constructs a default work size consisting of a single dimension - with width() set to 1. -*/ - -/*! - \fn QCLWorkSize::QCLWorkSize(size_t size) - - Constructs a single-dimensional work size with width() set to \a size. -*/ - -/*! - \fn QCLWorkSize::QCLWorkSize(size_t width, size_t height) - - Constructs a two-dimensional work size of \a width x \a height. -*/ - -/*! - \fn QCLWorkSize::QCLWorkSize(const QSize &size) - - Constructs a two-dimensional work size set to \a size. -*/ - -/*! - \fn QCLWorkSize::QCLWorkSize(size_t width, size_t height, size_t depth) - - Constructs a three-dimensional work size of \a width x \a height x - \a depth. -*/ - -/*! - \fn size_t QCLWorkSize::dimensions() const - - Returns the number of dimensions for this work size, 1, 2, or 3. -*/ - -/*! - \fn size_t QCLWorkSize::width() const - - Returns the width of this work size specification. -*/ - -/*! - \fn size_t QCLWorkSize::height() const - - Returns the height of this work size specification. -*/ - -/*! - \fn size_t QCLWorkSize::depth() const - - Returns the depth of this work size specification. -*/ - -/*! - \fn const size_t *QCLWorkSize::sizes() const - - Returns a const pointer to the size array within this object. -*/ - -/*! - \fn bool QCLWorkSize::operator==(const QCLWorkSize &other) const - - Returns true if this work size specification has the same - dimensions as \a other; false otherwise. - - \sa operator!=() -*/ - -/*! - \fn bool QCLWorkSize::operator!=(const QCLWorkSize &other) const - - Returns true if this work size specification does not have - the same dimensions as \a other; false otherwise. - - \sa operator==() -*/ diff --git a/util/clinfo/clinfo.cpp b/util/clinfo/clinfo.cpp index 73443cd..aa7519a 100644 --- a/util/clinfo/clinfo.cpp +++ b/util/clinfo/clinfo.cpp @@ -100,7 +100,8 @@ int main(int argc, char *argv[]) printf(" Max Work Size : %ux%ux%u\n", uint(size.width()), uint(size.height()), uint(size.depth())); - printf(" Max Items/Group : %d\n", dev.maximumWorkItemsPerGroup()); + printf(" Max Items/Group : %u\n", + uint(dev.maximumWorkItemsPerGroup())); printf(" Local Memory : "); printMemorySize(dev.localMemorySize()); printf(" Global Memory : "); -- cgit v1.2.3 From 81bf568b6fa1f023bbbccee381a6deeb413578bf Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 2 Jun 2010 19:17:04 +1000 Subject: Pad work sizes with 1, not 0 --- src/opencl/qclworksize.cpp | 3 +++ src/opencl/qclworksize.h | 8 ++++---- tests/auto/qcl/tst_qcl.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/opencl/qclworksize.cpp b/src/opencl/qclworksize.cpp index 3b40808..79a351a 100644 --- a/src/opencl/qclworksize.cpp +++ b/src/opencl/qclworksize.cpp @@ -89,18 +89,21 @@ QT_BEGIN_NAMESPACE \fn QCLWorkSize::QCLWorkSize(size_t size) Constructs a single-dimensional work size with width() set to \a size. + The height() and depth() will be set to 1. */ /*! \fn QCLWorkSize::QCLWorkSize(size_t width, size_t height) Constructs a two-dimensional work size of \a width x \a height. + The depth() will be set to 1. */ /*! \fn QCLWorkSize::QCLWorkSize(const QSize &size) Constructs a two-dimensional work size set to \a size. + The depth() will be set to 1. */ /*! diff --git a/src/opencl/qclworksize.h b/src/opencl/qclworksize.h index b1e2ca6..0c5541e 100644 --- a/src/opencl/qclworksize.h +++ b/src/opencl/qclworksize.h @@ -57,13 +57,13 @@ class Q_CL_EXPORT QCLWorkSize { public: QCLWorkSize() - : m_dim(1) { m_sizes[0] = 1; m_sizes[1] = 0; m_sizes[2] = 0; } + : m_dim(1) { m_sizes[0] = 1; m_sizes[1] = 1; m_sizes[2] = 1; } QCLWorkSize(size_t size) - : m_dim(1) { m_sizes[0] = size; m_sizes[1] = 0; m_sizes[2] = 0; } + : m_dim(1) { m_sizes[0] = size; m_sizes[1] = 1; m_sizes[2] = 1; } QCLWorkSize(size_t width, size_t height) - : m_dim(2) { m_sizes[0] = width; m_sizes[1] = height; m_sizes[2] = 0; } + : m_dim(2) { m_sizes[0] = width; m_sizes[1] = height; m_sizes[2] = 1; } QCLWorkSize(const QSize &size) - : m_dim(2) { m_sizes[0] = size.width(); m_sizes[1] = size.height(); m_sizes[2] = 0; } + : m_dim(2) { m_sizes[0] = size.width(); m_sizes[1] = size.height(); m_sizes[2] = 1; } QCLWorkSize(size_t width, size_t height, size_t depth) : m_dim(3) { m_sizes[0] = width; m_sizes[1] = height; m_sizes[2] = depth; } diff --git a/tests/auto/qcl/tst_qcl.cpp b/tests/auto/qcl/tst_qcl.cpp index 1837395..c0f3c4e 100644 --- a/tests/auto/qcl/tst_qcl.cpp +++ b/tests/auto/qcl/tst_qcl.cpp @@ -521,26 +521,26 @@ void tst_QCL::workSize() QCLWorkSize size; QVERIFY(size.dimensions() == 1); QVERIFY(size.width() == 1); - QVERIFY(size.height() == 0); - QVERIFY(size.depth() == 0); + QVERIFY(size.height() == 1); + QVERIFY(size.depth() == 1); QCLWorkSize size1(42); QVERIFY(size1.dimensions() == 1); QVERIFY(size1.width() == 42); - QVERIFY(size1.height() == 0); - QVERIFY(size1.depth() == 0); + QVERIFY(size1.height() == 1); + QVERIFY(size1.depth() == 1); QCLWorkSize size2(42, 63); QVERIFY(size2.dimensions() == 2); QVERIFY(size2.width() == 42); QVERIFY(size2.height() == 63); - QVERIFY(size2.depth() == 0); + QVERIFY(size2.depth() == 1); QCLWorkSize size2b(QSize(63, 42)); QVERIFY(size2b.dimensions() == 2); QVERIFY(size2b.width() == 63); QVERIFY(size2b.height() == 42); - QVERIFY(size2b.depth() == 0); + QVERIFY(size2b.depth() == 1); QCLWorkSize size3(42, 63, 12); QVERIFY(size3.dimensions() == 3); @@ -567,7 +567,7 @@ void tst_QCL::workSize() QVERIFY(size4.dimensions() == 2); QVERIFY(size4.width() == 42); QVERIFY(size4.height() == 63); - QVERIFY(size4.depth() == 0); + QVERIFY(size4.depth() == 1); QVERIFY(size4.width() == size4.sizes()[0]); QVERIFY(size4.height() == size4.sizes()[1]); -- cgit v1.2.3