diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-05-17 15:07:10 +1000 |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-05-17 15:07:10 +1000 |
commit | 461142f50dc99cde1fe065d2392e0bb17091f875 (patch) | |
tree | c62830a0ed5f1c284d9b7c7c05ec59f102324d89 /src | |
parent | a924a9f15e2f7bcb8009c6f01e790dd98d67ccb1 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/opencl/qclvector.cpp | 70 | ||||
-rw-r--r-- | src/opencl/qclvector.h | 40 |
2 files changed, 7 insertions, 103 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<T> &data, int offset = 0); - T *data() const; - - cl_mem memoryId() const; QCLContext *context() const; - QCLBuffer toBuffer() const; private: @@ -189,24 +181,6 @@ Q_INLINE_TEMPLATE const T &QCLVector<T>::operator[](int index) const } template <typename T> -Q_INLINE_TEMPLATE void QCLVector<T>::map() -{ - QCLVectorBase::map(); -} - -template <typename T> -Q_INLINE_TEMPLATE void QCLVector<T>::unmap() -{ - QCLVectorBase::unmap(); -} - -template <typename T> -Q_INLINE_TEMPLATE bool QCLVector<T>::isMapped() const -{ - return m_mapped != 0; -} - -template <typename T> Q_INLINE_TEMPLATE void QCLVector<T>::write (const T *data, int count, int offset) { @@ -230,20 +204,6 @@ Q_INLINE_TEMPLATE void QCLVector<T>::write } template <typename T> -Q_INLINE_TEMPLATE T *QCLVector<T>::data() const -{ - if (!m_mapped) - map(); - return reinterpret_cast<T *>(m_mapped); -} - -template <typename T> -Q_INLINE_TEMPLATE cl_mem QCLVector<T>::memoryId() const -{ - return QCLVectorBase::memoryId(); -} - -template <typename T> Q_INLINE_TEMPLATE QCLContext *QCLVector<T>::context() const { return QCLVectorBase::context(); |