*
* Additions and fixes from:
* Brian Cole, March 3rd 2010 and April 2012
- * Lee Howes, October 2011, March 2012
* Matt Gruenke, April 2012.
*
- * \version 1.2.1
- * \date September 2012
+ * \version 1.2.4
+ * \date January 2013
*
* Optional extension support
*
#include <CL/cl_ext.h>
#endif
-// TODO: Remove once declaration is moved elsewhere
-//#if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
-//#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
-//#endif // #if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
-
-
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenGL/OpenGL.h>
#include <OpenCL/opencl.h>
#define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram)
#if defined(CL_VERSION_1_2)
#define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram)
-#define __SET_PRINTF_CALLBACK_ERR __ERR_STR(clSetPrintfCallback)
+
#endif // #if defined(CL_VERSION_1_2)
#define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram)
#define __VECTOR_CAPACITY_ERR __ERR_STR(Vector capacity error)
/**
- * CL 1.1 version that uses device fission.
+ * CL 1.2 version that uses device fission.
*/
#if defined(CL_VERSION_1_2)
#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevices)
#endif // __CL_USER_OVERRIDE_ERROR_STRINGS
//! \endcond
+/**
+ * CL 1.2 marker and barrier commands
+ */
+#if defined(CL_VERSION_1_2)
+#define __ENQUEUE_MARKER_WAIT_LIST_ERR __ERR_STR(clEnqueueMarkerWithWaitList)
+#define __ENQUEUE_BARRIER_WAIT_LIST_ERR __ERR_STR(clEnqueueBarrierWithWaitList)
+#endif // #if defined(CL_VERSION_1_2)
#if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING)
typedef std::string STRING_CLASS;
//! \brief Destructor - frees memory used to hold the current value.
~string()
{
- if (str_ != NULL) {
- delete[] str_;
- str_ = NULL;
- }
+ delete[] str_;
+ str_ = NULL;
}
//! \brief Queries the length of the string, excluding any added '\0's.
cl_int* err = NULL)
{
cl_int error;
+
+ ::size_t numDevices = devices.size();
+ cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
+ for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+ deviceIDs[deviceIndex] = (devices[deviceIndex])();
+ }
+
object_ = ::clCreateContext(
- properties, (cl_uint) devices.size(),
- (cl_device_id*) &devices.front(),
+ properties, (cl_uint) numDevices,
+ deviceIDs,
notifyFptr, data, &error);
detail::errHandler(error, __CREATE_CONTEXT_ERR);
cl_int* err = NULL)
{
cl_int error;
+
+ cl_device_id deviceID = device();
+
object_ = ::clCreateContext(
properties, 1,
- (cl_device_id*) &device,
+ &deviceID,
notifyFptr, data, &error);
detail::errHandler(error, __CREATE_CONTEXT_ERR);
formats->assign(&value[0], &value[numEntries]);
return CL_SUCCESS;
}
-
-
-#if defined(CL_VERSION_1_2)
- cl_int setPrintfCallback(
- void (CL_CALLBACK * pfn_notify)(
- cl_context /* program */,
- cl_uint /*printf_data_len */,
- char * /* printf_data_ptr */,
- void * /* user_data */),
- void * user_data )
- {
- return detail::errHandler(
- ::clSetPrintfCallback(
- object_,
- pfn_notify,
- user_data),
- __SET_PRINTF_CALLBACK_ERR);
- }
-#endif // #if defined(CL_VERSION_1_2)
};
inline Device Device::getDefault(cl_int * err)
Buffer(
IteratorType startIterator,
IteratorType endIterator,
- bool readOnly = false,
+ bool readOnly,
bool useHostPtr = false,
cl_int* err = NULL)
{
ImageGL& operator = (const ImageGL& rhs)
{
if (this != &rhs) {
- ImageGL::operator=(rhs);
+ Image::operator=(rhs);
}
return *this;
}
ImageGL& operator = (const cl_mem& rhs)
{
- ImageGL::operator=(rhs);
+ Image::operator=(rhs);
return *this;
}
};
{
typename detail::param_traits<
detail::cl_kernel_arg_info, name>::param_type param;
- cl_int result = getArgInfo(name, argIndex, ¶m);
+ cl_int result = getArgInfo(argIndex, name, ¶m);
if (err != NULL) {
*err = result;
}
lengths[i] = binaries[(int)i].second;
}
+ ::size_t numDevices = devices.size();
+ cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
+ for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+ deviceIDs[deviceIndex] = (devices[deviceIndex])();
+ }
+
object_ = ::clCreateProgramWithBinary(
context(), (cl_uint) devices.size(),
- (cl_device_id*)&devices.front(),
+ deviceIDs,
lengths, images, binaryStatus != NULL
? (cl_int*) &binaryStatus->front()
: NULL, &error);
cl_int* err = NULL)
{
cl_int error;
+
+
+ ::size_t numDevices = devices.size();
+ cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
+ for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+ deviceIDs[deviceIndex] = (devices[deviceIndex])();
+ }
object_ = ::clCreateProgramWithBuiltInKernels(
context(),
(cl_uint) devices.size(),
- (cl_device_id*)&devices.front(),
+ deviceIDs,
kernelNames.c_str(),
&error);
void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
void* data = NULL) const
{
+ ::size_t numDevices = devices.size();
+ cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
+ for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+ deviceIDs[deviceIndex] = (devices[deviceIndex])();
+ }
+
return detail::errHandler(
::clBuildProgram(
object_,
(cl_uint)
devices.size(),
- (cl_device_id*)&devices.front(),
+ deviceIDs,
options,
notifyFptr,
data),
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
- __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
+ __ENQUEUE_MARKER_WAIT_LIST_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
* all events either in the event_wait_list or all previously enqueued commands, queued
* before this command to command_queue, have completed.
*/
- cl_int clEnqueueBarrierWithWaitList(
+ cl_int enqueueBarrierWithWaitList(
const VECTOR_CLASS<Event> *events = 0,
Event *event = 0)
{
cl_event tmp;
cl_int err = detail::errHandler(
- ::clEnqueueMarkerWithWaitList(
+ ::clEnqueueBarrierWithWaitList(
object_,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
- __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
+ __ENQUEUE_BARRIER_WAIT_LIST_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;