HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cl.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2008-2011 The Khronos Group Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and/or associated documentation files (the
6  * "Materials"), to deal in the Materials without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Materials, and to
9  * permit persons to whom the Materials are furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Materials.
14  *
15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22  ******************************************************************************/
23 
24 /*! \file
25  *
26  * \brief C++ bindings for OpenCL 1.0 (rev 48) and OpenCL 1.1 (rev 33)
27  * \author Benedict R. Gaster and Laurent Morichetti
28  *
29  * Additions and fixes from Brian Cole, March 3rd 2010.
30  *
31  * \version 1.1
32  * \date June 2010
33  *
34  * Optional extension support
35  *
36  * cl
37  * cl_ext_device_fission
38  * #define USE_CL_DEVICE_FISSION
39  */
40 
41 // Removed 'mainpage' and 'section' directives from the multiline comment below
42 // to prevent doxygen from overriding the "Introduction to the HDK" help page.
43 
44 /*
45  * For many large applications C++ is the language of choice and so it seems
46  * reasonable to define C++ bindings for OpenCL.
47  *
48  *
49  * The interface is contained with a single C++ header file \em cl.hpp and all
50  * definitions are contained within the namespace \em cl. There is no additional
51  * requirement to include \em cl.h and to use either the C++ or original C
52  * bindings it is enough to simply include \em cl.hpp.
53  *
54  * The bindings themselves are lightweight and correspond closely to the
55  * underlying C API. Using the C++ bindings introduces no additional execution
56  * overhead.
57  *
58  * For detail documentation on the bindings see:
59  *
60  * The OpenCL C++ Wrapper API 1.1 (revision 04)
61  * http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.1.pdf
62  *
63  * \section example Example
64  *
65  * The following example shows a general use case for the C++
66  * bindings, including support for the optional exception feature and
67  * also the supplied vector and string classes, see following sections for
68  * decriptions of these features.
69  *
70  * \code
71  * #define __CL_ENABLE_EXCEPTIONS
72  *
73  * #if defined(__APPLE__) || defined(__MACOSX)
74  * #include <OpenCL/cl.hpp>
75  * #else
76  * #include <CL/cl.hpp>
77  * #endif
78  * #include <cstdio>
79  * #include <cstdlib>
80  * #include <iostream>
81  *
82  * const char * helloStr = "__kernel void "
83  * "hello(void) "
84  * "{ "
85  * " "
86  * "} ";
87  *
88  * int
89  * main(void)
90  * {
91  * cl_int err = CL_SUCCESS;
92  * try {
93  *
94  * std::vector<cl::Platform> platforms;
95  * cl::Platform::get(&platforms);
96  * if (platforms.size() == 0) {
97  * std::cout << "Platform size 0\n";
98  * return -1;
99  * }
100  *
101  * cl_context_properties properties[] =
102  * { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0};
103  * cl::Context context(CL_DEVICE_TYPE_CPU, properties);
104  *
105  * std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
106  *
107  * cl::Program::Sources source(1,
108  * std::make_pair(helloStr,strlen(helloStr)));
109  * cl::Program program_ = cl::Program(context, source);
110  * program_.build(devices);
111  *
112  * cl::Kernel kernel(program_, "hello", &err);
113  *
114  * cl::Event event;
115  * cl::CommandQueue queue(context, devices[0], 0, &err);
116  * queue.enqueueNDRangeKernel(
117  * kernel,
118  * cl::NullRange,
119  * cl::NDRange(4,4),
120  * cl::NullRange,
121  * NULL,
122  * &event);
123  *
124  * event.wait();
125  * }
126  * catch (cl::Error err) {
127  * std::cerr
128  * << "ERROR: "
129  * << err.what()
130  * << "("
131  * << err.err()
132  * << ")"
133  * << std::endl;
134  * }
135  *
136  * return EXIT_SUCCESS;
137  * }
138  *
139  * \endcode
140  *
141  */
142 #ifndef CL_HPP_
143 #define CL_HPP_
144 
145 #ifdef _WIN32
146 #include <windows.h>
147 #include <malloc.h>
148 #if defined(USE_DX_INTEROP)
149 #include <CL/cl_d3d10.h>
150 #endif
151 #endif // _WIN32
152 
153 //
154 #if defined(USE_CL_DEVICE_FISSION)
155 #include <CL/cl_ext.h>
156 #endif
157 
158 #if defined(__APPLE__) || defined(__MACOSX)
159 #include <OpenCL/opencl.h>
160 #else
161 #include <CL/opencl.h>
162 #endif // !__APPLE__
163 
164 // taken from glcorearb.h to avoid including gl.h.
165 typedef int GLint;
166 typedef unsigned int GLenum;
167 typedef unsigned int GLuint;
168 
169 #if !defined(CL_CALLBACK)
170 #define CL_CALLBACK
171 #endif //CL_CALLBACK
172 
173 #include <utility>
174 
175 #if !defined(__NO_STD_VECTOR)
176 #include <vector>
177 #endif
178 
179 #if !defined(__NO_STD_STRING)
180 #include <string>
181 #endif
182 
183 #if defined(linux) || defined(__APPLE__) || defined(__MACOSX)
184 # include <alloca.h>
185 #endif // linux
186 
187 #include <cstring>
188 
189 /*! \namespace cl
190  *
191  * \brief The OpenCL C++ bindings are defined within this namespace.
192  *
193  */
194 namespace cl {
195 
196 #define __INIT_CL_EXT_FCN_PTR(name) \
197  if(!pfn_##name) { \
198  pfn_##name = (PFN_##name) \
199  clGetExtensionFunctionAddress(#name); \
200  if(!pfn_##name) { \
201  } \
202  }
203 
204 class Program;
205 class Device;
206 class Context;
207 class CommandQueue;
208 class Memory;
209 
210 #if defined(__CL_ENABLE_EXCEPTIONS)
211 #include <exception>
212 /*! \class Error
213  * \brief Exception class
214  */
215 class CE_API Error : public std::exception
216 {
217 private:
218  cl_int err_;
219  const char * errStr_;
220 public:
221  /*! Create a new CL error exception for a given error code
222  * and corresponding message.
223  */
224  Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr)
225  {}
226 
227  ~Error() throw() override {}
228 
229  /*! \brief Get error string associated with exception
230  *
231  * \return A memory pointer to the error message string.
232  */
233  const char * what() const throw() override
234  {
235  if (errStr_ == NULL) {
236  return "empty";
237  }
238  else {
239  return errStr_;
240  }
241  }
242 
243  /*! \brief Get error code associated with exception
244  *
245  * \return The error code.
246  */
247  cl_int err(void) const { return err_; }
248 };
249 
250 #define __ERR_STR(x) #x
251 #else
252 #define __ERR_STR(x) NULL
253 #endif // __CL_ENABLE_EXCEPTIONS
254 
255 //! \cond DOXYGEN_DETAIL
256 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
257 #define __GET_DEVICE_INFO_ERR __ERR_STR(clGetDeviceInfo)
258 #define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo)
259 #define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs)
260 #define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs)
261 #define __GET_CONTEXT_INFO_ERR __ERR_STR(clGetContextInfo)
262 #define __GET_EVENT_INFO_ERR __ERR_STR(clGetEventInfo)
263 #define __GET_EVENT_PROFILE_INFO_ERR __ERR_STR(clGetEventProfileInfo)
264 #define __GET_MEM_OBJECT_INFO_ERR __ERR_STR(clGetMemObjectInfo)
265 #define __GET_IMAGE_INFO_ERR __ERR_STR(clGetImageInfo)
266 #define __GET_SAMPLER_INFO_ERR __ERR_STR(clGetSamplerInfo)
267 #define __GET_KERNEL_INFO_ERR __ERR_STR(clGetKernelInfo)
268 #define __GET_KERNEL_WORK_GROUP_INFO_ERR __ERR_STR(clGetKernelWorkGroupInfo)
269 #define __GET_PROGRAM_INFO_ERR __ERR_STR(clGetProgramInfo)
270 #define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo)
271 #define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo)
272 
273 #define __CREATE_CONTEXT_ERR __ERR_STR(clCreateContext)
274 #define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType)
275 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats)
276 
277 #define __CREATE_BUFFER_ERR __ERR_STR(clCreateBuffer)
278 #define __CREATE_SUBBUFFER_ERR __ERR_STR(clCreateSubBuffer)
279 #define __CREATE_GL_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer)
280 #define __GET_GL_OBJECT_INFO_ERR __ERR_STR(clGetGLObjectInfo)
281 #define __CREATE_IMAGE2D_ERR __ERR_STR(clCreateImage2D)
282 #define __CREATE_IMAGE3D_ERR __ERR_STR(clCreateImage3D)
283 #define __CREATE_SAMPLER_ERR __ERR_STR(clCreateSampler)
284 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR __ERR_STR(clSetMemObjectDestructorCallback)
285 
286 #define __CREATE_USER_EVENT_ERR __ERR_STR(clCreateUserEvent)
287 #define __SET_USER_EVENT_STATUS_ERR __ERR_STR(clSetUserEventStatus)
288 #define __SET_EVENT_CALLBACK_ERR __ERR_STR(clSetEventCallback)
289 #define __WAIT_FOR_EVENTS_ERR __ERR_STR(clWaitForEvents)
290 
291 #define __CREATE_KERNEL_ERR __ERR_STR(clCreateKernel)
292 #define __SET_KERNEL_ARGS_ERR __ERR_STR(clSetKernelArg)
293 #define __CREATE_PROGRAM_WITH_SOURCE_ERR __ERR_STR(clCreateProgramWithSource)
294 #define __CREATE_PROGRAM_WITH_BINARY_ERR __ERR_STR(clCreateProgramWithBinary)
295 #define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram)
296 #define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram)
297 
298 #define __CREATE_COMMAND_QUEUE_ERR __ERR_STR(clCreateCommandQueue)
299 #define __SET_COMMAND_QUEUE_PROPERTY_ERR __ERR_STR(clSetCommandQueueProperty)
300 #define __ENQUEUE_READ_BUFFER_ERR __ERR_STR(clEnqueueReadBuffer)
301 #define __ENQUEUE_READ_BUFFER_RECT_ERR __ERR_STR(clEnqueueReadBufferRect)
302 #define __ENQUEUE_WRITE_BUFFER_ERR __ERR_STR(clEnqueueWriteBuffer)
303 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR __ERR_STR(clEnqueueWriteBufferRect)
304 #define __ENQEUE_COPY_BUFFER_ERR __ERR_STR(clEnqueueCopyBuffer)
305 #define __ENQEUE_COPY_BUFFER_RECT_ERR __ERR_STR(clEnqueueCopyBufferRect)
306 #define __ENQUEUE_READ_IMAGE_ERR __ERR_STR(clEnqueueReadImage)
307 #define __ENQUEUE_WRITE_IMAGE_ERR __ERR_STR(clEnqueueWriteImage)
308 #define __ENQUEUE_COPY_IMAGE_ERR __ERR_STR(clEnqueueCopyImage)
309 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR __ERR_STR(clEnqueueCopyImageToBuffer)
310 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR __ERR_STR(clEnqueueCopyBufferToImage)
311 #define __ENQUEUE_MAP_BUFFER_ERR __ERR_STR(clEnqueueMapBuffer)
312 #define __ENQUEUE_MAP_IMAGE_ERR __ERR_STR(clEnqueueMapImage)
313 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR __ERR_STR(clEnqueueUnMapMemObject)
314 #define __ENQUEUE_NDRANGE_KERNEL_ERR __ERR_STR(clEnqueueNDRangeKernel)
315 #define __ENQUEUE_TASK_ERR __ERR_STR(clEnqueueTask)
316 #define __ENQUEUE_NATIVE_KERNEL __ERR_STR(clEnqueueNativeKernel)
317 #define __ENQUEUE_MARKER_ERR __ERR_STR(clEnqueueMarker)
318 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR __ERR_STR(clEnqueueWaitForEvents)
319 #define __ENQUEUE_BARRIER_ERR __ERR_STR(clEnqueueBarrier)
320 #if defined(CL_VERSION_1_2)
321 #define __ENQUEUE_MARKER_WITH_WAIT_LIST_ERR \
322  __ERR_STR(clEnqueueMarkerWithWaitList)
323 #define __ENQUEUE_BARRIER_WITH_WAIT_LIST_ERR \
324  __ERR_STR(clEnqueueBarrierWithWaitList)
325 #endif
326 
327 #define __ENQUEUE_ACQUIRE_GL_ERR __ERR_STR(clEnqueueAcquireGLObjects)
328 #define __ENQUEUE_RELEASE_GL_ERR __ERR_STR(clEnqueueReleaseGLObjects)
329 
330 #define __UNLOAD_COMPILER_ERR __ERR_STR(clUnloadCompiler)
331 
332 #define __FLUSH_ERR __ERR_STR(clFlush)
333 #define __FINISH_ERR __ERR_STR(clFinish)
334 
335 #define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevicesEXT)
336 #endif // __CL_USER_OVERRIDE_ERROR_STRINGS
337 //! \endcond
338 
339 /*! \class string
340  * \brief Simple string class, that provides a limited subset of std::string
341  * functionality but avoids many of the issues that come with that class.
342  */
344 {
345 private:
346  ::size_t size_;
347  char * str_;
348 public:
349  string(void) : size_(0), str_(NULL)
350  {
351  }
352 
353  string(char * str, ::size_t size) :
354  size_(size),
355  str_(NULL)
356  {
357  str_ = new char[size_+1];
358  if (str_ != NULL) {
359  memcpy(str_, str, size_ * sizeof(char));
360  str_[size_] = '\0';
361  }
362  else {
363  size_ = 0;
364  }
365  }
366 
367  string(char * str) :
368  str_(NULL)
369  {
370  size_= ::strlen(str);
371  str_ = new char[size_ + 1];
372  if (str_ != NULL) {
373  memcpy(str_, str, (size_ + 1) * sizeof(char));
374  }
375  else {
376  size_ = 0;
377  }
378  }
379 
380  string& operator=(const string& rhs)
381  {
382  if (this == &rhs) {
383  return *this;
384  }
385 
386  if (rhs.size_ == 0 || rhs.str_ == NULL) {
387  size_ = 0;
388  str_ = NULL;
389  }
390  else {
391  size_ = rhs.size_;
392  str_ = new char[size_ + 1];
393  if (str_ != NULL) {
394  memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char));
395  }
396  else {
397  size_ = 0;
398  }
399  }
400 
401  return *this;
402  }
403 
404  string(const string& rhs)
405  {
406  *this = rhs;
407  }
408 
410  {
411  if (str_ != NULL) {
412  delete[] str_;
413  }
414  }
415 
416  ::size_t size(void) const { return size_; }
417  ::size_t length(void) const { return size(); }
418 
419  const char * c_str(void) const { return (str_) ? str_ : "";}
420 };
421 
422 #if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING)
423 #include <string>
425 #elif !defined(__USE_DEV_STRING)
426 typedef cl::string STRING_CLASS;
427 #endif
428 
429 #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR)
430 #include <vector>
431 #define VECTOR_CLASS std::vector
432 #elif !defined(__USE_DEV_VECTOR)
433 #define VECTOR_CLASS cl::vector
434 #endif
435 
436 #if !defined(__MAX_DEFAULT_VECTOR_SIZE)
437 #define __MAX_DEFAULT_VECTOR_SIZE 10
438 #endif
439 
440 /*! \class vector
441  * \brief Fixed sized vector implementation that mirroring
442  * std::vector functionality.
443  */
444 template <typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
445 class vector
446 {
447 private:
448  T data_[N];
449  unsigned int size_;
450  bool empty_;
451 public:
452  vector() :
453  size_(static_cast<unsigned int>(-1)),
454  empty_(true)
455  {}
456 
457  ~vector() {}
458 
459  unsigned int size(void) const
460  {
461  return size_ + 1;
462  }
463 
464  void clear()
465  {
466  size_ = -1;
467  empty_ = true;
468  }
469 
470  void push_back (const T& x)
471  {
472  if (size() < N) {
473  size_++;
474  data_[size_] = x;
475  empty_ = false;
476  }
477  }
478 
479  void pop_back(void)
480  {
481  if (!empty_) {
482  data_[size_].~T();
483  size_--;
484  if (size_ == -1) {
485  empty_ = true;
486  }
487  }
488  }
489 
490  vector(const vector<T, N>& vec) :
491  size_(vec.size_),
492  empty_(vec.empty_)
493  {
494  if (!empty_) {
495  memcpy(&data_[0], &vec.data_[0], size() * sizeof(T));
496  }
497  }
498 
499  vector(unsigned int size, const T& val = T()) :
500  size_(-1),
501  empty_(true)
502  {
503  for (unsigned int i = 0; i < size; i++) {
504  push_back(val);
505  }
506  }
507 
509  {
510  if (this == &rhs) {
511  return *this;
512  }
513 
514  size_ = rhs.size_;
515  empty_ = rhs.empty_;
516 
517  if (!empty_) {
518  memcpy(&data_[0], &rhs.data_[0], size() * sizeof(T));
519  }
520 
521  return *this;
522  }
523 
525  {
526  if (empty_ && vec.empty_) {
527  return true;
528  }
529 
530  if (size() != vec.size()) {
531  return false;
532  }
533 
534  return memcmp(&data_[0], &vec.data_[0], size() * sizeof(T)) == 0 ? true : false;
535  }
536 
537  operator T* () { return data_; }
538  operator const T* () const { return data_; }
539 
540  bool empty (void) const
541  {
542  return empty_;
543  }
544 
545  unsigned int max_size (void) const
546  {
547  return N;
548  }
549 
550  unsigned int capacity () const
551  {
552  return sizeof(T) * N;
553  }
554 
556  {
557  return data_[index];
558  }
559 
560  T operator[](int index) const
561  {
562  return data_[index];
563  }
564 
565  template<class I>
566  void assign(I start, I end)
567  {
568  clear();
569  while(start < end) {
570  push_back(*start);
571  start++;
572  }
573  }
574 
575  /*! \class iterator
576  * \brief Iterator class for vectors
577  */
578  class iterator
579  {
580  private:
581  vector<T,N> vec_;
582  int index_;
583  bool initialized_;
584  public:
585  iterator(void) :
586  index_(-1),
587  initialized_(false)
588  {
589  index_ = -1;
590  initialized_ = false;
591  }
592 
593  ~iterator(void) {}
594 
596  {
597  iterator i;
598 
599  if (!vec.empty()) {
600  i.index_ = 0;
601  }
602 
603  i.vec_ = vec;
604  i.initialized_ = true;
605  return i;
606  }
607 
608  static iterator end(vector<T,N> &vec)
609  {
610  iterator i;
611 
612  if (!vec.empty()) {
613  i.index_ = vec.size();
614  }
615  i.vec_ = vec;
616  i.initialized_ = true;
617  return i;
618  }
619 
621  {
622  return ((vec_ == i.vec_) &&
623  (index_ == i.index_) &&
624  (initialized_ == i.initialized_));
625  }
626 
628  {
629  return (!(*this==i));
630  }
631 
632  void operator++()
633  {
634  index_++;
635  }
636 
637  void operator++(int x)
638  {
639  index_ += x;
640  }
641 
642  void operator--()
643  {
644  index_--;
645  }
646 
647  void operator--(int x)
648  {
649  index_ -= x;
650  }
651 
653  {
654  return vec_[index_];
655  }
656  };
657 
658  iterator begin(void)
659  {
660  return iterator::begin(*this);
661  }
662 
663  iterator end(void)
664  {
665  return iterator::end(*this);
666  }
667 
668  T& front(void)
669  {
670  return data_[0];
671  }
672 
673  T& back(void)
674  {
675  return data_[size_];
676  }
677 
678  const T& front(void) const
679  {
680  return data_[0];
681  }
682 
683  const T& back(void) const
684  {
685  return data_[size_];
686  }
687 };
688 
689 /*!
690  * \brief size_t class used to interface between C++ and
691  * OpenCL C calls that require arrays of size_t values, who's
692  * size is known statically.
693  */
694 template <int N>
695 struct size_t : public cl::vector< ::size_t, N> { };
696 
697 namespace detail {
698 
699 // GetInfo help struct
700 template <typename Functor, typename T>
702 {
703  static cl_int
704  get(Functor f, cl_uint name, T* param)
705  {
706  return f(name, sizeof(T), param, NULL);
707  }
708 };
709 
710 // Specialized GetInfoHelper for VECTOR_CLASS params
711 template <typename Func, typename T>
712 struct GetInfoHelper<Func, VECTOR_CLASS<T> >
713 {
714  static cl_int get(Func f, cl_uint name, VECTOR_CLASS<T>* param)
715  {
716  ::size_t required;
717  cl_int err = f(name, 0, NULL, &required);
718  if (err != CL_SUCCESS) {
719  return err;
720  }
721 
722  T* value = (T*) alloca(required);
723  err = f(name, required, value, NULL);
724  if (err != CL_SUCCESS) {
725  return err;
726  }
727 
728  param->assign(&value[0], &value[required/sizeof(T)]);
729  return CL_SUCCESS;
730  }
731 };
732 
733 // Specialized for getInfo<CL_PROGRAM_BINARIES>
734 template <typename Func>
735 struct GetInfoHelper<Func, VECTOR_CLASS<char *> >
736 {
737  static cl_int
738  get(Func f, cl_uint name, VECTOR_CLASS<char *>* param)
739  {
740  ::size_t nDevices;
741  ::size_t * binary_sizes;
742  char ** values;
743 
744  cl_int err = f(CL_PROGRAM_NUM_DEVICES, sizeof(nDevices), &nDevices, NULL);
745  if (err != CL_SUCCESS) {
746  return err;
747  }
748 
749  binary_sizes = (::size_t*)alloca(sizeof(::size_t)*nDevices);
750  err = f(CL_PROGRAM_BINARY_SIZES, sizeof(::size_t)*nDevices, binary_sizes, NULL);
751  if (err != CL_SUCCESS) {
752  return err;
753  }
754 
755  values = (char **) alloca(sizeof(char*)*nDevices);
756  for(cl_uint i = 0; i < nDevices; i++ )
757  {
758  if( binary_sizes[i] != 0 )
759  {
760  values[i]= (char *)malloc( sizeof(char)*binary_sizes[i]);
761  }
762  else
763  {
764  values[i] = NULL;
765  }
766  }
767  err = f(name, sizeof(char *)*nDevices, values, NULL);
768  if (err != CL_SUCCESS) {
769  return err;
770  }
771 
772  param->assign(values,values+nDevices);
773  return CL_SUCCESS;
774  }
775 };
776 
777 // Specialized GetInfoHelper for STRING_CLASS params
778 template <typename Func>
780 {
781  static cl_int get(Func f, cl_uint name, STRING_CLASS* param)
782  {
783  ::size_t required;
784  cl_int err = f(name, 0, NULL, &required);
785  if (err != CL_SUCCESS) {
786  return err;
787  }
788 
789  char* value = (char*) alloca(required);
790  err = f(name, required, value, NULL);
791  if (err != CL_SUCCESS) {
792  return err;
793  }
794 
795  *param = value;
796  return CL_SUCCESS;
797  }
798 };
799 
800 #define __GET_INFO_HELPER_WITH_RETAIN(CPP_TYPE) \
801 namespace detail { \
802 template <typename Func> \
803 struct GetInfoHelper<Func, CPP_TYPE> \
804 { \
805  static cl_int get(Func f, cl_uint name, CPP_TYPE* param) \
806  { \
807  cl_uint err = f(name, sizeof(CPP_TYPE), param, NULL); \
808  if (err != CL_SUCCESS) { \
809  return err; \
810  } \
811  \
812  return ReferenceHandler<CPP_TYPE::cl_type>::retain((*param)()); \
813  } \
814 }; \
815 }
816 
817 
818 #define __PARAM_NAME_INFO_1_0(F) \
819  F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \
820  F(cl_platform_info, CL_PLATFORM_VERSION, STRING_CLASS) \
821  F(cl_platform_info, CL_PLATFORM_NAME, STRING_CLASS) \
822  F(cl_platform_info, CL_PLATFORM_VENDOR, STRING_CLASS) \
823  F(cl_platform_info, CL_PLATFORM_EXTENSIONS, STRING_CLASS) \
824  \
825  F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
826  F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
827  F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
828  F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
829  F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, ::size_t) \
830  F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, VECTOR_CLASS< ::size_t>) \
831  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
832  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
833  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
834  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
835  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
836  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
837  F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
838  F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_bitfield) \
839  F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
840  F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
841  F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
842  F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, ::size_t) \
843  F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, ::size_t) \
844  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \
845  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \
846  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \
847  F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
848  F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \
849  F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
850  F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
851  F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
852  F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
853  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
854  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
855  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
856  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
857  F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
858  F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
859  F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
860  F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
861  F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
862  F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, ::size_t) \
863  F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
864  F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
865  F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
866  F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
867  F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) \
868  F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
869  F(cl_device_info, CL_DEVICE_NAME, STRING_CLASS) \
870  F(cl_device_info, CL_DEVICE_VENDOR, STRING_CLASS) \
871  F(cl_device_info, CL_DRIVER_VERSION, STRING_CLASS) \
872  F(cl_device_info, CL_DEVICE_PROFILE, STRING_CLASS) \
873  F(cl_device_info, CL_DEVICE_VERSION, STRING_CLASS) \
874  F(cl_device_info, CL_DEVICE_EXTENSIONS, STRING_CLASS) \
875  \
876  F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
877  F(cl_context_info, CL_CONTEXT_DEVICES, VECTOR_CLASS<Device>) \
878  F(cl_context_info, CL_CONTEXT_PROPERTIES, VECTOR_CLASS<cl_context_properties>) \
879  \
880  F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
881  F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
882  F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
883  F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_uint) \
884  \
885  F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
886  F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
887  F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
888  F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
889  \
890  F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
891  F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
892  F(cl_mem_info, CL_MEM_SIZE, ::size_t) \
893  F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
894  F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
895  F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
896  F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
897  \
898  F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
899  F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, ::size_t) \
900  F(cl_image_info, CL_IMAGE_ROW_PITCH, ::size_t) \
901  F(cl_image_info, CL_IMAGE_SLICE_PITCH, ::size_t) \
902  F(cl_image_info, CL_IMAGE_WIDTH, ::size_t) \
903  F(cl_image_info, CL_IMAGE_HEIGHT, ::size_t) \
904  F(cl_image_info, CL_IMAGE_DEPTH, ::size_t) \
905  \
906  F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
907  F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
908  F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_addressing_mode) \
909  F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_filter_mode) \
910  F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_bool) \
911  \
912  F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
913  F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
914  F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
915  F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS<cl_device_id>) \
916  F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \
917  F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \
918  F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS<char *>) \
919  \
920  F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
921  F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \
922  F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, STRING_CLASS) \
923  \
924  F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, STRING_CLASS) \
925  F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
926  F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
927  F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
928  F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
929  \
930  F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, ::size_t) \
931  F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::size_t<3>) \
932  F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
933  \
934  F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
935  F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
936  F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
937  F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
938 
939 #if defined(CL_VERSION_1_1)
940 #define __PARAM_NAME_INFO_1_1(F) \
941  F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
942  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
943  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
944  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
945  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
946  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
947  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
948  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
949  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
950  F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
951  F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
952  F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \
953  F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, STRING_CLASS) \
954  \
955  F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
956  F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \
957  \
958  F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, ::size_t) \
959  F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
960  \
961  F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
962 #endif // CL_VERSION_1_1
963 
964 #if defined(USE_CL_DEVICE_FISSION)
965 #define __PARAM_NAME_DEVICE_FISSION(F) \
966  F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
967  F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \
968  F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \
969  F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
970  F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, VECTOR_CLASS<cl_device_partition_property_ext>)
971 #endif // USE_CL_DEVICE_FISSION
972 
973 template <typename enum_type, cl_int Name>
974 struct param_traits {};
975 
976 #define __CL_DECLARE_PARAM_TRAITS(token, param_name, T) \
977 struct token; \
978 template<> \
979 struct param_traits<detail:: token,param_name> \
980 { \
981  enum { value = param_name }; \
982  typedef T param_type; \
983 };
984 
986 #if defined(CL_VERSION_1_1)
987 __PARAM_NAME_INFO_1_1(__CL_DECLARE_PARAM_TRAITS)
988 #endif // CL_VERSION_1_1
989 
990 #if defined(USE_CL_DEVICE_FISSION)
991 __PARAM_NAME_DEVICE_FISSION(__CL_DECLARE_PARAM_TRAITS);
992 #endif // USE_CL_DEVICE_FISSION
993 
994 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
996 #endif
997 
998 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1000 #endif
1001 
1002 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1004 #endif
1005 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1007 #endif
1008 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1010 #endif
1011 #ifdef CL_DEVICE_WARP_SIZE_NV
1013 #endif
1014 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1016 #endif
1017 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1019 #endif
1020 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1022 #endif
1023 
1024 // Convenience functions
1025 
1026 template <typename Func, typename T>
1027 inline cl_int
1028 getInfo(Func f, cl_uint name, T* param)
1029 {
1030  return GetInfoHelper<Func, T>::get(f, name, param);
1031 }
1032 
1033 template <typename Func, typename Arg0>
1035 {
1036  Func f_; const Arg0& arg0_;
1037  cl_int operator ()(
1038  cl_uint param, ::size_t size, void* value, ::size_t* size_ret)
1039  { return f_(arg0_, param, size, value, size_ret); }
1040 };
1041 
1042 template <typename Func, typename Arg0, typename Arg1>
1044 {
1045  Func f_; const Arg0& arg0_; const Arg1& arg1_;
1046  cl_int operator ()(
1047  cl_uint param, ::size_t size, void* value, ::size_t* size_ret)
1048  { return f_(arg0_, arg1_, param, size, value, size_ret); }
1049 };
1050 
1051 template <typename Func, typename Arg0, typename T>
1052 inline cl_int
1053 getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
1054 {
1055  GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
1057  ::get(f0, name, param);
1058 }
1059 
1060 template <typename Func, typename Arg0, typename Arg1, typename T>
1061 inline cl_int
1062 getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
1063 {
1064  GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1066  ::get(f0, name, param);
1067 }
1068 
1069 template<typename T>
1071 { };
1072 
1073 template <>
1075 {
1076  // cl_device_id does not have retain().
1077  static cl_int retain(cl_device_id)
1078  { return CL_INVALID_DEVICE; }
1079  // cl_device_id does not have release().
1080  static cl_int release(cl_device_id)
1081  { return CL_INVALID_DEVICE; }
1082 };
1083 
1084 template <>
1086 {
1087  // cl_platform_id does not have retain().
1088  static cl_int retain(cl_platform_id)
1089  { return CL_INVALID_PLATFORM; }
1090  // cl_platform_id does not have release().
1091  static cl_int release(cl_platform_id)
1092  { return CL_INVALID_PLATFORM; }
1093 };
1094 
1095 template <>
1097 {
1098  static cl_int retain(cl_context context)
1099  { return ::clRetainContext(context); }
1100  static cl_int release(cl_context context)
1101  { return ::clReleaseContext(context); }
1102 };
1103 
1104 template <>
1106 {
1108  { return ::clRetainCommandQueue(queue); }
1110  { return ::clReleaseCommandQueue(queue); }
1111 };
1112 
1113 template <>
1115 {
1116  static cl_int retain(cl_mem memory)
1117  { return ::clRetainMemObject(memory); }
1118  static cl_int release(cl_mem memory)
1119  { return ::clReleaseMemObject(memory); }
1120 };
1121 
1122 template <>
1124 {
1125  static cl_int retain(cl_sampler sampler)
1126  { return ::clRetainSampler(sampler); }
1127  static cl_int release(cl_sampler sampler)
1128  { return ::clReleaseSampler(sampler); }
1129 };
1130 
1131 template <>
1133 {
1134  static cl_int retain(cl_program program)
1135  { return ::clRetainProgram(program); }
1136  static cl_int release(cl_program program)
1137  { return ::clReleaseProgram(program); }
1138 };
1139 
1140 template <>
1142 {
1143  static cl_int retain(cl_kernel kernel)
1144  { return ::clRetainKernel(kernel); }
1145  static cl_int release(cl_kernel kernel)
1146  { return ::clReleaseKernel(kernel); }
1147 };
1148 
1149 template <>
1151 {
1152  static cl_int retain(cl_event event)
1153  { return ::clRetainEvent(event); }
1154  static cl_int release(cl_event event)
1155  { return ::clReleaseEvent(event); }
1156 };
1157 
1158 template <typename T>
1159 class Wrapper
1160 {
1161 public:
1162  typedef T cl_type;
1163 
1164 protected:
1166 
1167 public:
1168  Wrapper() : object_(NULL) { }
1169 
1170  Wrapper(const cl_type &obj) : object_(obj) { }
1171 
1173  {
1174  if (object_ != NULL) { release(); }
1175  }
1176 
1178  {
1179  object_ = rhs.object_;
1180  if (object_ != NULL) { retain(); }
1181  }
1182 
1184  {
1185  if (object_ != NULL) { release(); }
1186  object_ = rhs.object_;
1187  if (object_ != NULL) { retain(); }
1188  return *this;
1189  }
1190 
1192  {
1193  if (object_ != NULL) { release(); }
1194  object_ = rhs;
1195  return *this;
1196  }
1197 
1198  cl_type operator ()() const { return object_; }
1199 
1200  cl_type& operator ()() { return object_; }
1201 
1202 protected:
1203 
1204  cl_int retain() const
1205  {
1207  }
1208 
1209  cl_int release() const
1210  {
1212  }
1213 };
1214 
1215 #if defined(__CL_ENABLE_EXCEPTIONS)
1216 static inline cl_int errHandler (
1217  cl_int err,
1218  const char * errStr = NULL)
1219 {
1220  if (err != CL_SUCCESS) {
1221  throw Error(err, errStr);
1222  }
1223  return err;
1224 }
1225 #else
1226 static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
1227 {
1228  return err;
1229 }
1230 #endif // __CL_ENABLE_EXCEPTIONS
1231 
1232 } // namespace detail
1233 //! \endcond
1234 
1235 /*! \stuct ImageFormat
1236  * \brief ImageFormat interface fro cl_image_format.
1237  */
1239 {
1241 
1243  {
1246  }
1247 
1248 #if 0 // Silence -Wdeprecated-copy warnings.
1249  ImageFormat& operator = (const ImageFormat& rhs)
1250  {
1251  if (this != &rhs) {
1254  }
1255  return *this;
1256  }
1257 #endif
1258 };
1259 
1260 /*! \class Device
1261  * \brief Device interface for cl_device_id.
1262  */
1263 class CE_API Device : public detail::Wrapper<cl_device_id>
1264 {
1265 public:
1266  Device() : detail::Wrapper<cl_type>() { }
1267 
1268  Device(const Device& device) : detail::Wrapper<cl_type>(device) { }
1269 
1270  Device(const cl_device_id &device) : detail::Wrapper<cl_type>(device) { }
1271 
1272  Device& operator = (const Device& rhs)
1273  {
1274  if (this != &rhs) {
1276  }
1277  return *this;
1278  }
1279 
1280  Device& operator = (const cl_device_id& rhs)
1281  {
1283  return *this;
1284  }
1285 
1286  template <typename T>
1287  cl_int getInfo(cl_device_info name, T* param) const
1288  {
1289  return detail::errHandler(
1290  detail::getInfo(&::clGetDeviceInfo, object_, name, param),
1291  __GET_DEVICE_INFO_ERR);
1292  }
1293 
1294  template <cl_int name> typename
1296  getInfo(cl_int* err = NULL) const
1297  {
1298  typename detail::param_traits<
1299  detail::cl_device_info, name>::param_type param;
1300  cl_int result = getInfo(name, &param);
1301  if (err != NULL) {
1302  *err = result;
1303  }
1304  return param;
1305  }
1306 
1307 #if defined(USE_CL_DEVICE_FISSION)
1308  cl_int createSubDevices(
1309  const cl_device_partition_property_ext * properties,
1310  VECTOR_CLASS<Device>* devices)
1311  {
1312  typedef CL_API_ENTRY cl_int
1313  ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
1314  cl_device_id /*in_device*/,
1315  const cl_device_partition_property_ext * /* properties */,
1316  cl_uint /*num_entries*/,
1317  cl_device_id * /*out_devices*/,
1318  cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
1319 
1320  static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
1322 
1323  cl_uint n = 0;
1324  cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
1325  if (err != CL_SUCCESS) {
1326  return detail::errHandler(err, __CREATE_SUB_DEVICES);
1327  }
1328 
1329  cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
1330  err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids, NULL);
1331  if (err != CL_SUCCESS) {
1332  return detail::errHandler(err, __CREATE_SUB_DEVICES);
1333  }
1334 
1335  devices->assign(&ids[0], &ids[n]);
1336  return CL_SUCCESS;
1337  }
1338 #endif
1339 };
1340 
1341 /*! \class Platform
1342  * \brief Platform interface.
1343  */
1344 class CE_API Platform : public detail::Wrapper<cl_platform_id>
1345 {
1346 public:
1347  static const Platform null();
1348 
1349  Platform() : detail::Wrapper<cl_type>() { }
1350 
1351  Platform(const Platform& platform) : detail::Wrapper<cl_type>(platform) { }
1352 
1353  Platform(const cl_platform_id &platform) : detail::Wrapper<cl_type>(platform) { }
1354 
1355  Platform& operator = (const Platform& rhs)
1356  {
1357  if (this != &rhs) {
1359  }
1360  return *this;
1361  }
1362 
1363  Platform& operator = (const cl_platform_id& rhs)
1364  {
1366  return *this;
1367  }
1368 
1370  {
1371  return detail::errHandler(
1372  detail::getInfo(&::clGetPlatformInfo, object_, name, param),
1373  __GET_PLATFORM_INFO_ERR);
1374  }
1375 
1376  template <cl_int name> typename
1378  getInfo(cl_int* err = NULL) const
1379  {
1380  typename detail::param_traits<
1381  detail::cl_platform_info, name>::param_type param;
1382  cl_int result = getInfo(name, &param);
1383  if (err != NULL) {
1384  *err = result;
1385  }
1386  return param;
1387  }
1388 
1389  cl_int getDevices(
1391  VECTOR_CLASS<Device>* devices) const
1392  {
1393  cl_uint n = 0;
1394  cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
1395  if (err != CL_SUCCESS) {
1396  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1397  }
1398 
1399  cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
1400  err = ::clGetDeviceIDs(object_, type, n, ids, NULL);
1401  if (err != CL_SUCCESS) {
1402  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1403  }
1404 
1405  devices->assign(&ids[0], &ids[n]);
1406  return CL_SUCCESS;
1407  }
1408 
1409 #if defined(USE_DX_INTEROP)
1410  /*! \brief Get the list of available D3D10 devices.
1411  *
1412  * \param d3d_device_source.
1413  *
1414  * \param d3d_object.
1415  *
1416  * \param d3d_device_set.
1417  *
1418  * \param devices returns a vector of OpenCL D3D10 devices found. The cl::Device
1419  * values returned in devices can be used to identify a specific OpenCL
1420  * device. If \a devices argument is NULL, this argument is ignored.
1421  *
1422  * \return One of the following values:
1423  * - CL_SUCCESS if the function is executed successfully.
1424  *
1425  * The application can query specific capabilities of the OpenCL device(s)
1426  * returned by cl::getDevices. This can be used by the application to
1427  * determine which device(s) to use.
1428  *
1429  * \note In the case that exceptions are enabled and a return value
1430  * other than CL_SUCCESS is generated, then cl::Error exception is
1431  * generated.
1432  */
1433  cl_int getDevices(
1434  cl_d3d10_device_source_khr d3d_device_source,
1435  void * d3d_object,
1436  cl_d3d10_device_set_khr d3d_device_set,
1437  VECTOR_CLASS<Device>* devices) const
1438  {
1439  typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
1440  cl_platform_id platform,
1441  cl_d3d10_device_source_khr d3d_device_source,
1442  void * d3d_object,
1443  cl_d3d10_device_set_khr d3d_device_set,
1444  cl_uint num_entries,
1445  cl_device_id * devices,
1446  cl_uint* num_devices);
1447 
1448  static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
1449  __INIT_CL_EXT_FCN_PTR(clGetDeviceIDsFromD3D10KHR);
1450 
1451  cl_uint n = 0;
1452  cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
1453  object_,
1454  d3d_device_source,
1455  d3d_object,
1456  d3d_device_set,
1457  0,
1458  NULL,
1459  &n);
1460  if (err != CL_SUCCESS) {
1461  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1462  }
1463 
1464  cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
1465  err = pfn_clGetDeviceIDsFromD3D10KHR(
1466  object_,
1467  d3d_device_source,
1468  d3d_object,
1469  d3d_device_set,
1470  n,
1471  ids,
1472  NULL);
1473  if (err != CL_SUCCESS) {
1474  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1475  }
1476 
1477  devices->assign(&ids[0], &ids[n]);
1478  return CL_SUCCESS;
1479  }
1480 #endif
1481 
1482  static cl_int get(
1483  VECTOR_CLASS<Platform>* platforms)
1484  {
1485  cl_uint n = 0;
1486  cl_int err = ::clGetPlatformIDs(0, NULL, &n);
1487  if (err != CL_SUCCESS) {
1488  return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
1489  }
1490 
1491  cl_platform_id* ids = (cl_platform_id*) alloca(
1492  n * sizeof(cl_platform_id));
1493  err = ::clGetPlatformIDs(n, ids, NULL);
1494  if (err != CL_SUCCESS) {
1495  return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
1496  }
1497 
1498  platforms->assign(&ids[0], &ids[n]);
1499  return CL_SUCCESS;
1500  }
1501 };
1502 
1503 #if defined(CL_VERSION_1_2)
1504 static inline cl_int
1505 UnloadCompiler(cl_platform_id platform)
1506 {
1507  return ::clUnloadPlatformCompiler(platform);
1508 }
1509 #else
1510 static inline cl_int
1511 UnloadCompiler()
1512 {
1514 }
1515 #endif
1516 
1517 class CE_API Context : public detail::Wrapper<cl_context>
1518 {
1519 public:
1521  const VECTOR_CLASS<Device>& devices,
1522  cl_context_properties* properties = NULL,
1523  void (CL_CALLBACK * notifyFptr)(
1524  const char *,
1525  const void *,
1526  ::size_t,
1527  void *) = NULL,
1528  void* data = NULL,
1529  cl_int* err = NULL)
1530  {
1531  cl_int error;
1532  object_ = ::clCreateContext(
1533  properties, (cl_uint) devices.size(),
1534  (cl_device_id*) &devices.front(),
1535  notifyFptr, data, &error);
1536 
1537  detail::errHandler(error, __CREATE_CONTEXT_ERR);
1538  if (err != NULL) {
1539  *err = error;
1540  }
1541  }
1542 
1545  cl_context_properties* properties = NULL,
1546  void (CL_CALLBACK * notifyFptr)(
1547  const char *,
1548  const void *,
1549  ::size_t,
1550  void *) = NULL,
1551  void* data = NULL,
1552  cl_int* err = NULL)
1553  {
1554  cl_int error;
1555  object_ = ::clCreateContextFromType(
1556  properties, type, notifyFptr, data, &error);
1557 
1558  detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
1559  if (err != NULL) {
1560  *err = error;
1561  }
1562  }
1563 
1564  Context() : detail::Wrapper<cl_type>() { }
1565 
1566  Context(const Context& context) : detail::Wrapper<cl_type>(context) { }
1567 
1568  Context(const cl_context& context) : detail::Wrapper<cl_type>(context) { }
1569 
1570  Context& operator = (const Context& rhs)
1571  {
1572  if (this != &rhs) {
1574  }
1575  return *this;
1576  }
1577 
1578  Context& operator = (const cl_context& rhs)
1579  {
1581  return *this;
1582  }
1583 
1584  template <typename T>
1585  cl_int getInfo(cl_context_info name, T* param) const
1586  {
1587  return detail::errHandler(
1588  detail::getInfo(&::clGetContextInfo, object_, name, param),
1589  __GET_CONTEXT_INFO_ERR);
1590  }
1591 
1592  template <cl_int name> typename
1594  getInfo(cl_int* err = NULL) const
1595  {
1596  typename detail::param_traits<
1597  detail::cl_context_info, name>::param_type param;
1598  cl_int result = getInfo(name, &param);
1599  if (err != NULL) {
1600  *err = result;
1601  }
1602  return param;
1603  }
1604 
1607  cl_mem_object_type type,
1608  VECTOR_CLASS<ImageFormat>* formats) const
1609  {
1610  cl_uint numEntries;
1611  cl_int err = ::clGetSupportedImageFormats(
1612  object_,
1613  flags,
1614  type,
1615  0,
1616  NULL,
1617  &numEntries);
1618  if (err != CL_SUCCESS) {
1619  return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
1620  }
1621 
1623  alloca(numEntries * sizeof(ImageFormat));
1625  object_,
1626  flags,
1627  type,
1628  numEntries,
1629  (cl_image_format*) value,
1630  NULL);
1631  if (err != CL_SUCCESS) {
1632  return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
1633  }
1634 
1635  formats->assign(&value[0], &value[numEntries]);
1636  return CL_SUCCESS;
1637  }
1638 };
1639 
1641 
1642 /*! \class Event
1643  * \brief Event interface for cl_event.
1644  */
1645 class CE_API Event : public detail::Wrapper<cl_event>
1646 {
1647 public:
1648  Event() : detail::Wrapper<cl_type>() { }
1649 
1650  Event(const Event& event) : detail::Wrapper<cl_type>(event) { }
1651 
1652  Event(const cl_event& event) : detail::Wrapper<cl_type>(event) { }
1653 
1654  Event& operator = (const Event& rhs)
1655  {
1656  if (this != &rhs) {
1658  }
1659  return *this;
1660  }
1661 
1662  Event& operator = (const cl_event& rhs)
1663  {
1665  return *this;
1666  }
1667 
1668  template <typename T>
1669  cl_int getInfo(cl_event_info name, T* param) const
1670  {
1671  return detail::errHandler(
1672  detail::getInfo(&::clGetEventInfo, object_, name, param),
1673  __GET_EVENT_INFO_ERR);
1674  }
1675 
1676  template <cl_int name> typename
1678  getInfo(cl_int* err = NULL) const
1679  {
1680  typename detail::param_traits<
1681  detail::cl_event_info, name>::param_type param;
1682  cl_int result = getInfo(name, &param);
1683  if (err != NULL) {
1684  *err = result;
1685  }
1686  return param;
1687  }
1688 
1689  template <typename T>
1691  {
1692  return detail::errHandler(detail::getInfo(
1693  &::clGetEventProfilingInfo, object_, name, param),
1694  __GET_EVENT_PROFILE_INFO_ERR);
1695  }
1696 
1697  template <cl_int name> typename
1699  getProfilingInfo(cl_int* err = NULL) const
1700  {
1701  typename detail::param_traits<
1702  detail::cl_profiling_info, name>::param_type param;
1703  cl_int result = getProfilingInfo(name, &param);
1704  if (err != NULL) {
1705  *err = result;
1706  }
1707  return param;
1708  }
1709 
1710  cl_int wait() const
1711  {
1712  return detail::errHandler(
1713  ::clWaitForEvents(1, &object_),
1714  __WAIT_FOR_EVENTS_ERR);
1715  }
1716 
1717 #if defined(CL_VERSION_1_1)
1718  cl_int setCallback(
1719  cl_int type,
1720  void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *),
1721  void * user_data = NULL)
1722  {
1723  return detail::errHandler(
1724  ::clSetEventCallback(
1725  object_,
1726  type,
1727  pfn_notify,
1728  user_data),
1729  __SET_EVENT_CALLBACK_ERR);
1730  }
1731 #endif
1732 
1733  static cl_int
1734  waitForEvents(const VECTOR_CLASS<Event>& events)
1735  {
1736  return detail::errHandler(
1737  ::clWaitForEvents(
1738  (cl_uint) events.size(), (cl_event*)&events.front()),
1739  __WAIT_FOR_EVENTS_ERR);
1740  }
1741 };
1742 
1744 
1745 #if defined(CL_VERSION_1_1)
1746 /*! \class UserEvent
1747  * \brief User event interface for cl_event.
1748  */
1749 class CE_API UserEvent : public Event
1750 {
1751 public:
1752  UserEvent(
1753  const Context& context,
1754  cl_int * err = NULL)
1755  {
1756  cl_int error;
1757  object_ = ::clCreateUserEvent(
1758  context(),
1759  &error);
1760 
1761  detail::errHandler(error, __CREATE_USER_EVENT_ERR);
1762  if (err != NULL) {
1763  *err = error;
1764  }
1765  }
1766 
1767  UserEvent() : Event() { }
1768 
1769  UserEvent(const UserEvent& event) : Event(event) { }
1770 
1771  UserEvent& operator = (const UserEvent& rhs)
1772  {
1773  if (this != &rhs) {
1774  Event::operator=(rhs);
1775  }
1776  return *this;
1777  }
1778 
1779  cl_int setStatus(cl_int status)
1780  {
1781  return detail::errHandler(
1782  ::clSetUserEventStatus(object_,status),
1783  __SET_USER_EVENT_STATUS_ERR);
1784  }
1785 };
1786 #endif
1787 
1788 inline static cl_int
1789 WaitForEvents(const VECTOR_CLASS<Event>& events)
1790 {
1791  return detail::errHandler(
1792  ::clWaitForEvents(
1793  (cl_uint) events.size(), (cl_event*)&events.front()),
1794  __WAIT_FOR_EVENTS_ERR);
1795 }
1796 
1797 /*! \class Memory
1798  * \brief Memory interface for cl_mem.
1799  */
1800 class CE_API Memory : public detail::Wrapper<cl_mem>
1801 {
1802 public:
1803  Memory() : detail::Wrapper<cl_type>() { }
1804 
1805  Memory(const Memory& memory) : detail::Wrapper<cl_type>(memory) { }
1806 
1807  Memory(const cl_mem& memory) : detail::Wrapper<cl_type>(memory) { }
1808 
1809  Memory& operator = (const Memory& rhs)
1810  {
1811  if (this != &rhs) {
1813  }
1814  return *this;
1815  }
1816 
1817  Memory& operator = (const cl_mem& rhs)
1818  {
1820  return *this;
1821  }
1822 
1823  template <typename T>
1824  cl_int getInfo(cl_mem_info name, T* param) const
1825  {
1826  return detail::errHandler(
1827  detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
1828  __GET_MEM_OBJECT_INFO_ERR);
1829  }
1830 
1831  template <cl_int name> typename
1833  getInfo(cl_int* err = NULL) const
1834  {
1835  typename detail::param_traits<
1836  detail::cl_mem_info, name>::param_type param;
1837  cl_int result = getInfo(name, &param);
1838  if (err != NULL) {
1839  *err = result;
1840  }
1841  return param;
1842  }
1843 
1844 #if defined(CL_VERSION_1_1)
1845  cl_int setDestructorCallback(
1846  void (CL_CALLBACK * pfn_notify)(cl_mem, void *),
1847  void * user_data = NULL)
1848  {
1849  return detail::errHandler(
1850  ::clSetMemObjectDestructorCallback(
1851  object_,
1852  pfn_notify,
1853  user_data),
1854  __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
1855  }
1856 #endif
1857 
1858 };
1859 
1861 
1862 /*! \class Buffer
1863  * \brief Memory buffer interface.
1864  */
1866 {
1867 public:
1869  const Context& context,
1871  ::size_t size,
1872  void* host_ptr = NULL,
1873  cl_int* err = NULL)
1874  {
1875  cl_int error;
1876  object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
1877 
1878  detail::errHandler(error, __CREATE_BUFFER_ERR);
1879  if (err != NULL) {
1880  *err = error;
1881  }
1882  }
1883 
1884  Buffer() : Memory() { }
1885 
1886  Buffer(const Buffer& buffer) : Memory(buffer) { }
1887 
1888  Buffer(const cl_mem& buffer) : Memory(buffer) { }
1889 
1890  Buffer& operator = (const Buffer& rhs)
1891  {
1892  if (this != &rhs) {
1893  Memory::operator=(rhs);
1894  }
1895  return *this;
1896  }
1897 
1898  Buffer& operator = (const cl_mem& rhs)
1899  {
1900  Memory::operator=(rhs);
1901  return *this;
1902  }
1903 
1904 #if defined(CL_VERSION_1_1)
1905  Buffer createSubBuffer(
1907  cl_buffer_create_type buffer_create_type,
1908  const void * buffer_create_info,
1909  cl_int * err = NULL)
1910  {
1911  Buffer result;
1912  cl_int error;
1913  result.object_ = ::clCreateSubBuffer(
1914  object_,
1915  flags,
1916  buffer_create_type,
1917  buffer_create_info,
1918  &error);
1919 
1920  detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
1921  if (err != NULL) {
1922  *err = error;
1923  }
1924 
1925  return result;
1926  }
1927 #endif
1928 };
1929 
1930 #if defined (USE_DX_INTEROP)
1931 class CE_API BufferD3D10 : public Buffer
1932 {
1933 public:
1934  typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
1935  cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
1936  cl_int* errcode_ret);
1937 
1938  BufferD3D10(
1939  const Context& context,
1941  ID3D10Buffer* bufobj,
1942  cl_int * err = NULL)
1943  {
1944  static PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR = NULL;
1945  __INIT_CL_EXT_FCN_PTR(clCreateFromD3D10BufferKHR);
1946 
1947  cl_int error;
1948  object_ = pfn_clCreateFromD3D10BufferKHR(
1949  context(),
1950  flags,
1951  bufobj,
1952  &error);
1953 
1954  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
1955  if (err != NULL) {
1956  *err = error;
1957  }
1958  }
1959 
1960  BufferD3D10() : Buffer() { }
1961 
1962  BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) { }
1963 
1964  BufferD3D10(const cl_mem& buffer) : Buffer(buffer) { }
1965 
1966  BufferD3D10& operator = (const BufferD3D10& rhs)
1967  {
1968  if (this != &rhs) {
1969  Buffer::operator=(rhs);
1970  }
1971  return *this;
1972  }
1973 
1974  BufferD3D10& operator = (const cl_mem& rhs)
1975  {
1976  Buffer::operator=(rhs);
1977  return *this;
1978  }
1979 };
1980 #endif
1981 
1982 /*! \class BufferGL
1983  * \brief Memory buffer interface for GL interop.
1984  */
1985 class CE_API BufferGL : public Buffer
1986 {
1987 public:
1989  const Context& context,
1990  cl_mem_flags flags,
1991  GLuint bufobj,
1992  cl_int * err = NULL)
1993  {
1994  cl_int error;
1995  object_ = ::clCreateFromGLBuffer(
1996  context(),
1997  flags,
1998  bufobj,
1999  &error);
2000 
2001  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
2002  if (err != NULL) {
2003  *err = error;
2004  }
2005  }
2006 
2007  BufferGL() : Buffer() { }
2008 
2009  BufferGL(const BufferGL& buffer) : Buffer(buffer) { }
2010 
2011  BufferGL(const cl_mem& buffer) : Buffer(buffer) { }
2012 
2013  BufferGL& operator = (const BufferGL& rhs)
2014  {
2015  if (this != &rhs) {
2016  Buffer::operator=(rhs);
2017  }
2018  return *this;
2019  }
2020 
2021  BufferGL& operator = (const cl_mem& rhs)
2022  {
2023  Buffer::operator=(rhs);
2024  return *this;
2025  }
2026 
2028  cl_gl_object_type *type,
2029  GLuint * gl_object_name)
2030  {
2031  return detail::errHandler(
2032  ::clGetGLObjectInfo(object_,type,gl_object_name),
2033  __GET_GL_OBJECT_INFO_ERR);
2034  }
2035 };
2036 
2037 /*! \class BufferRenderGL
2038  * \brief Memory buffer interface for GL interop with renderbuffer.
2039  */
2041 {
2042 public:
2044  const Context& context,
2045  cl_mem_flags flags,
2046  GLuint bufobj,
2047  cl_int * err = NULL)
2048  {
2049  cl_int error;
2050  object_ = ::clCreateFromGLRenderbuffer(
2051  context(),
2052  flags,
2053  bufobj,
2054  &error);
2055 
2056  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
2057  if (err != NULL) {
2058  *err = error;
2059  }
2060  }
2061 
2063 
2064  BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) { }
2065 
2066  BufferRenderGL(const cl_mem& buffer) : Buffer(buffer) { }
2067 
2068  BufferRenderGL& operator = (const BufferRenderGL& rhs)
2069  {
2070  if (this != &rhs) {
2071  Buffer::operator=(rhs);
2072  }
2073  return *this;
2074  }
2075 
2076  BufferRenderGL& operator = (const cl_mem& rhs)
2077  {
2078  Buffer::operator=(rhs);
2079  return *this;
2080  }
2081 
2083  cl_gl_object_type *type,
2084  GLuint * gl_object_name)
2085  {
2086  return detail::errHandler(
2087  ::clGetGLObjectInfo(object_,type,gl_object_name),
2088  __GET_GL_OBJECT_INFO_ERR);
2089  }
2090 };
2091 
2092 /*! \class Image
2093  * \brief Base class interface for all images.
2094  */
2095 class CE_API Image : public Memory
2096 {
2097 protected:
2098  Image() : Memory() { }
2099 
2100  Image(const Image& image) : Memory(image) { }
2101 
2102  Image(const cl_mem& image) : Memory(image) { }
2103 
2104  Image& operator = (const Image& rhs)
2105  {
2106  if (this != &rhs) {
2107  Memory::operator=(rhs);
2108  }
2109  return *this;
2110  }
2111 
2112  Image& operator = (const cl_mem& rhs)
2113  {
2114  Memory::operator=(rhs);
2115  return *this;
2116  }
2117 
2118 public:
2119  template <typename T>
2121  {
2122  return detail::errHandler(
2123  detail::getInfo(&::clGetImageInfo, object_, name, param),
2124  __GET_IMAGE_INFO_ERR);
2125  }
2126 
2127  template <cl_int name> typename
2129  getImageInfo(cl_int* err = NULL) const
2130  {
2131  typename detail::param_traits<
2132  detail::cl_image_info, name>::param_type param;
2133  cl_int result = getImageInfo(name, &param);
2134  if (err != NULL) {
2135  *err = result;
2136  }
2137  return param;
2138  }
2139 };
2140 
2141 /*! \class Image2D
2142  * \brief Image interface for 2D images.
2143  */
2144 class CE_API Image2D : public Image
2145 {
2146 public:
2148  const Context& context,
2149  cl_mem_flags flags,
2151  ::size_t width,
2152  ::size_t height,
2153  ::size_t row_pitch = 0,
2154  void* host_ptr = NULL,
2155  cl_int* err = NULL)
2156  {
2157  cl_int error;
2158 #if defined(CL_VERSION_1_2)
2159  cl_image_desc image_desc;
2160  image_desc.image_width = width;
2161  image_desc.image_height = height;
2162  image_desc.image_row_pitch = row_pitch;
2163 
2164  object_ = ::clCreateImage(
2165  context(), flags, &format, &image_desc, host_ptr, &error);
2166 #else
2167  object_ = ::clCreateImage2D(
2168  context(), flags,&format, width, height, row_pitch, host_ptr, &error);
2169 #endif
2170 
2171  detail::errHandler(error, __CREATE_IMAGE2D_ERR);
2172  if (err != NULL) {
2173  *err = error;
2174  }
2175  }
2176 
2177  Image2D() { }
2178 
2179  Image2D(const Image2D& image2D) : Image(image2D) { }
2180 
2181  Image2D(const cl_mem& image2D) : Image(image2D) { }
2182 
2183  Image2D& operator = (const Image2D& rhs)
2184  {
2185  if (this != &rhs) {
2186  Image::operator=(rhs);
2187  }
2188  return *this;
2189  }
2190 
2191  Image2D& operator = (const cl_mem& rhs)
2192  {
2193  Image::operator=(rhs);
2194  return *this;
2195  }
2196 };
2197 
2198 /*! \class Image2DGL
2199  * \brief 2D image interface for GL interop.
2200  */
2201 class CE_API Image2DGL : public Image2D
2202 {
2203 public:
2205  const Context& context,
2206  cl_mem_flags flags,
2207  GLenum target,
2208  GLint miplevel,
2209  GLuint texobj,
2210  cl_int * err = NULL)
2211  {
2212  cl_int error;
2213 #if defined(CL_VERSION_1_2)
2214  object_ = ::clCreateFromGLTexture(
2215  context(),
2216  flags,
2217  target,
2218  miplevel,
2219  texobj,
2220  &error);
2221 #else
2222  object_ = ::clCreateFromGLTexture2D(
2223  context(),
2224  flags,
2225  target,
2226  miplevel,
2227  texobj,
2228  &error);
2229 #endif
2230 
2231  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
2232  if (err != NULL) {
2233  *err = error;
2234  }
2235  }
2236 
2237  Image2DGL() : Image2D() { }
2238 
2239  Image2DGL(const Image2DGL& image) : Image2D(image) { }
2240 
2241  Image2DGL(const cl_mem& image) : Image2D(image) { }
2242 
2243  Image2DGL& operator = (const Image2DGL& rhs)
2244  {
2245  if (this != &rhs) {
2246  Image2D::operator=(rhs);
2247  }
2248  return *this;
2249  }
2250 
2251  Image2DGL& operator = (const cl_mem& rhs)
2252  {
2253  Image2D::operator=(rhs);
2254  return *this;
2255  }
2256 };
2257 
2258 /*! \class Image3D
2259  * \brief Image interface for 3D images.
2260  */
2261 class CE_API Image3D : public Image
2262 {
2263 public:
2265  const Context& context,
2266  cl_mem_flags flags,
2268  ::size_t width,
2269  ::size_t height,
2270  ::size_t depth,
2271  ::size_t row_pitch = 0,
2272  ::size_t slice_pitch = 0,
2273  void* host_ptr = NULL,
2274  cl_int* err = NULL)
2275  {
2276  cl_int error;
2277 #if defined(CL_VERSION_1_2)
2278  cl_image_desc image_desc;
2279  image_desc.image_width = width;
2280  image_desc.image_height = height;
2281  image_desc.image_depth = depth;
2282  image_desc.image_row_pitch = row_pitch;
2283  image_desc.image_slice_pitch = slice_pitch;
2284 
2285  object_ = ::clCreateImage(
2286  context(), flags, &format, &image_desc, host_ptr, &error);
2287 #else
2288  object_ = ::clCreateImage3D(
2289  context(), flags, &format, width, height, depth, row_pitch,
2290  slice_pitch, host_ptr, &error);
2291 #endif
2292 
2293  detail::errHandler(error, __CREATE_IMAGE3D_ERR);
2294  if (err != NULL) {
2295  *err = error;
2296  }
2297  }
2298 
2299  Image3D() { }
2300 
2301  Image3D(const Image3D& image3D) : Image(image3D) { }
2302 
2303  Image3D(const cl_mem& image3D) : Image(image3D) { }
2304 
2305  Image3D& operator = (const Image3D& rhs)
2306  {
2307  if (this != &rhs) {
2308  Image::operator=(rhs);
2309  }
2310  return *this;
2311  }
2312 
2313  Image3D& operator = (const cl_mem& rhs)
2314  {
2315  Image::operator=(rhs);
2316  return *this;
2317  }
2318 };
2319 
2320 /*! \class Image2DGL
2321  * \brief 2D image interface for GL interop.
2322  */
2323 class CE_API Image3DGL : public Image3D
2324 {
2325 public:
2327  const Context& context,
2328  cl_mem_flags flags,
2329  GLenum target,
2330  GLint miplevel,
2331  GLuint texobj,
2332  cl_int * err = NULL)
2333  {
2334  cl_int error;
2335 #if defined(CL_VERSION_1_2)
2336  object_ = ::clCreateFromGLTexture(
2337  context(),
2338  flags,
2339  target,
2340  miplevel,
2341  texobj,
2342  &error);
2343 #else
2344  object_ = ::clCreateFromGLTexture3D(
2345  context(),
2346  flags,
2347  target,
2348  miplevel,
2349  texobj,
2350  &error);
2351 #endif
2352 
2353  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
2354  if (err != NULL) {
2355  *err = error;
2356  }
2357  }
2358 
2359  Image3DGL() : Image3D() { }
2360 
2361  Image3DGL(const Image3DGL& image) : Image3D(image) { }
2362 
2363  Image3DGL(const cl_mem& image) : Image3D(image) { }
2364 
2365  Image3DGL& operator = (const Image3DGL& rhs)
2366  {
2367  if (this != &rhs) {
2368  Image3D::operator=(rhs);
2369  }
2370  return *this;
2371  }
2372 
2373  Image3DGL& operator = (const cl_mem& rhs)
2374  {
2375  Image3D::operator=(rhs);
2376  return *this;
2377  }
2378 };
2379 
2380 /*! \class Sampler
2381  * \brief Sampler interface for cl_sampler.
2382  */
2383 class CE_API Sampler : public detail::Wrapper<cl_sampler>
2384 {
2385 public:
2386  Sampler() { }
2387 
2389  const Context& context,
2390  cl_bool normalized_coords,
2391  cl_addressing_mode addressing_mode,
2392  cl_filter_mode filter_mode,
2393  cl_int* err = NULL)
2394  {
2395  cl_int error;
2396  object_ = ::clCreateSampler(
2397  context(),
2398  normalized_coords,
2399  addressing_mode,
2400  filter_mode,
2401  &error);
2402 
2403  detail::errHandler(error, __CREATE_SAMPLER_ERR);
2404  if (err != NULL) {
2405  *err = error;
2406  }
2407  }
2408 
2409  Sampler(const Sampler& sampler) : detail::Wrapper<cl_type>(sampler) { }
2410 
2411  Sampler(const cl_sampler& sampler) : detail::Wrapper<cl_type>(sampler) { }
2412 
2413  Sampler& operator = (const Sampler& rhs)
2414  {
2415  if (this != &rhs) {
2417  }
2418  return *this;
2419  }
2420 
2421  Sampler& operator = (const cl_sampler& rhs)
2422  {
2424  return *this;
2425  }
2426 
2427  template <typename T>
2428  cl_int getInfo(cl_sampler_info name, T* param) const
2429  {
2430  return detail::errHandler(
2431  detail::getInfo(&::clGetSamplerInfo, object_, name, param),
2432  __GET_SAMPLER_INFO_ERR);
2433  }
2434 
2435  template <cl_int name> typename
2437  getInfo(cl_int* err = NULL) const
2438  {
2439  typename detail::param_traits<
2440  detail::cl_sampler_info, name>::param_type param;
2441  cl_int result = getInfo(name, &param);
2442  if (err != NULL) {
2443  *err = result;
2444  }
2445  return param;
2446  }
2447 };
2448 
2450 
2451 class Program;
2452 class CommandQueue;
2453 class Kernel;
2454 
2455 /*! \class NDRange
2456  * \brief NDRange interface
2457  */
2459 {
2460 private:
2461  size_t<3> sizes_;
2462  cl_uint dimensions_;
2463 
2464 public:
2466  : dimensions_(0)
2467  { }
2468 
2469  NDRange(::size_t size0)
2470  : dimensions_(1)
2471  {
2472  sizes_.push_back(size0);
2473  }
2474 
2475  NDRange(::size_t size0, ::size_t size1)
2476  : dimensions_(2)
2477  {
2478  sizes_.push_back(size0);
2479  sizes_.push_back(size1);
2480  }
2481 
2482  NDRange(::size_t size0, ::size_t size1, ::size_t size2)
2483  : dimensions_(3)
2484  {
2485  sizes_.push_back(size0);
2486  sizes_.push_back(size1);
2487  sizes_.push_back(size2);
2488  }
2489 
2490  operator const ::size_t*() const { return (const ::size_t*) sizes_; }
2491  ::size_t dimensions() const { return dimensions_; }
2492 };
2493 
2494 static const NDRange NullRange;
2495 
2496 /*!
2497  * \struct LocalSpaceArg
2498  * \brief Local address raper for use with Kernel::setArg
2499  */
2501 {
2503 };
2504 
2505 namespace detail {
2506 
2507 template <typename T>
2509 {
2510  static ::size_t size(const T&) { return sizeof(T); }
2511  static T* ptr(T& value) { return &value; }
2512 };
2513 
2514 template <>
2516 {
2517  static ::size_t size(const LocalSpaceArg& value) { return value.size_; }
2518  static void* ptr(LocalSpaceArg&) { return NULL; }
2519 };
2520 
2521 }
2522 //! \endcond
2523 
2524 inline LocalSpaceArg
2525 __local(::size_t size)
2526 {
2527  LocalSpaceArg ret = { size };
2528  return ret;
2529 }
2530 
2532 
2533 /*! \class Kernel
2534  * \brief Kernel interface that implements cl_kernel
2535  */
2536 class CE_API Kernel : public detail::Wrapper<cl_kernel>
2537 {
2538 public:
2539  inline Kernel(const Program& program, const char* name, cl_int* err = NULL);
2540 
2541  Kernel() { }
2542 
2543  Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) { }
2544 
2545  Kernel(const cl_kernel& kernel) : detail::Wrapper<cl_type>(kernel) { }
2546 
2547  Kernel& operator = (const Kernel& rhs)
2548  {
2549  if (this != &rhs) {
2551  }
2552  return *this;
2553  }
2554 
2555  Kernel& operator = (const cl_kernel& rhs)
2556  {
2558  return *this;
2559  }
2560 
2561  template <typename T>
2562  cl_int getInfo(cl_kernel_info name, T* param) const
2563  {
2564  return detail::errHandler(
2565  detail::getInfo(&::clGetKernelInfo, object_, name, param),
2566  __GET_KERNEL_INFO_ERR);
2567  }
2568 
2569  template <cl_int name> typename
2571  getInfo(cl_int* err = NULL) const
2572  {
2573  typename detail::param_traits<
2574  detail::cl_kernel_info, name>::param_type param;
2575  cl_int result = getInfo(name, &param);
2576  if (err != NULL) {
2577  *err = result;
2578  }
2579  return param;
2580  }
2581 
2582  template <typename T>
2584  const Device& device, cl_kernel_work_group_info name, T* param) const
2585  {
2586  return detail::errHandler(
2588  &::clGetKernelWorkGroupInfo, object_, device(), name, param),
2589  __GET_KERNEL_WORK_GROUP_INFO_ERR);
2590  }
2591 
2592  template <cl_int name> typename
2594  getWorkGroupInfo(const Device& device, cl_int* err = NULL) const
2595  {
2596  typename detail::param_traits<
2597  detail::cl_kernel_work_group_info, name>::param_type param;
2598  cl_int result = getWorkGroupInfo(device, name, &param);
2599  if (err != NULL) {
2600  *err = result;
2601  }
2602  return param;
2603  }
2604 
2605  template <typename T>
2606  cl_int setArg(cl_uint index, T value)
2607  {
2608  return detail::errHandler(
2609  ::clSetKernelArg(
2610  object_,
2611  index,
2614  __SET_KERNEL_ARGS_ERR);
2615  }
2616 
2617  cl_int setArg(cl_uint index, ::size_t size, void* argPtr)
2618  {
2619  return detail::errHandler(
2620  ::clSetKernelArg(object_, index, size, argPtr),
2621  __SET_KERNEL_ARGS_ERR);
2622  }
2623 
2624  KernelFunctor bind(
2625  const CommandQueue& queue,
2626  const NDRange& offset,
2627  const NDRange& global,
2628  const NDRange& local);
2629 
2630  KernelFunctor bind(
2631  const CommandQueue& queue,
2632  const NDRange& global,
2633  const NDRange& local);
2634 };
2635 
2637 
2638 /*! \class Program
2639  * \brief Program interface that implements cl_program.
2640  */
2641 class CE_API Program : public detail::Wrapper<cl_program>
2642 {
2643 public:
2644  typedef VECTOR_CLASS<std::pair<const void*, ::size_t> > Binaries;
2645  typedef VECTOR_CLASS<std::pair<const char*, ::size_t> > Sources;
2646 
2648  const Context& context,
2649  const Sources& sources,
2650  cl_int* err = NULL)
2651  {
2652  cl_int error;
2653 
2654  const ::size_t n = (::size_t)sources.size();
2655  ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t));
2656  const char** strings = (const char**) alloca(n * sizeof(const char*));
2657 
2658  for (::size_t i = 0; i < n; ++i) {
2659  strings[i] = sources[(int)i].first;
2660  lengths[i] = sources[(int)i].second;
2661  }
2662 
2663  object_ = ::clCreateProgramWithSource(
2664  context(), (cl_uint)n, strings, lengths, &error);
2665 
2666  detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
2667  if (err != NULL) {
2668  *err = error;
2669  }
2670  }
2671 
2673  const Context& context,
2674  const VECTOR_CLASS<Device>& devices,
2675  const Binaries& binaries,
2676  VECTOR_CLASS<cl_int>* binaryStatus = NULL,
2677  cl_int* err = NULL)
2678  {
2679  cl_int error;
2680  const ::size_t n = binaries.size();
2681  ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t));
2682  const unsigned char** images = (const unsigned char**) alloca(n * sizeof(const void*));
2683 
2684  for (::size_t i = 0; i < n; ++i) {
2685  images[i] = (const unsigned char*)binaries[(int)i].first;
2686  lengths[i] = binaries[(int)i].second;
2687  }
2688 
2689  object_ = ::clCreateProgramWithBinary(
2690  context(), (cl_uint) devices.size(),
2691  (cl_device_id*)&devices.front(),
2692  lengths, images, binaryStatus != NULL
2693  ? (cl_int*) &binaryStatus->front()
2694  : NULL, &error);
2695 
2696  detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
2697  if (err != NULL) {
2698  *err = error;
2699  }
2700  }
2701 
2702  Program() { }
2703 
2704  Program(const Program& program) : detail::Wrapper<cl_type>(program) { }
2705 
2706  Program(const cl_program& program) : detail::Wrapper<cl_type>(program) { }
2707 
2708  Program& operator = (const Program& rhs)
2709  {
2710  if (this != &rhs) {
2712  }
2713  return *this;
2714  }
2715 
2716  Program& operator = (const cl_program& rhs)
2717  {
2719  return *this;
2720  }
2721 
2722  cl_int build(
2723  const VECTOR_CLASS<Device>& devices,
2724  const char* options = NULL,
2725  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
2726  void* data = NULL) const
2727  {
2728  return detail::errHandler(
2729  ::clBuildProgram(
2730  object_,
2731  (cl_uint)
2732  devices.size(),
2733  (cl_device_id*)&devices.front(),
2734  options,
2735  notifyFptr,
2736  data),
2737  __BUILD_PROGRAM_ERR);
2738  }
2739 
2740  template <typename T>
2741  cl_int getInfo(cl_program_info name, T* param) const
2742  {
2743  return detail::errHandler(
2744  detail::getInfo(&::clGetProgramInfo, object_, name, param),
2745  __GET_PROGRAM_INFO_ERR);
2746  }
2747 
2748  template <cl_int name> typename
2750  getInfo(cl_int* err = NULL) const
2751  {
2752  typename detail::param_traits<
2753  detail::cl_program_info, name>::param_type param;
2754  cl_int result = getInfo(name, &param);
2755  if (err != NULL) {
2756  *err = result;
2757  }
2758  return param;
2759  }
2760 
2761  template <typename T>
2763  const Device& device, cl_program_build_info name, T* param) const
2764  {
2765  return detail::errHandler(
2767  &::clGetProgramBuildInfo, object_, device(), name, param),
2768  __GET_PROGRAM_BUILD_INFO_ERR);
2769  }
2770 
2771  template <cl_int name> typename
2773  getBuildInfo(const Device& device, cl_int* err = NULL) const
2774  {
2775  typename detail::param_traits<
2777  cl_int result = getBuildInfo(device, name, &param);
2778  if (err != NULL) {
2779  *err = result;
2780  }
2781  return param;
2782  }
2783 
2784  cl_int createKernels(VECTOR_CLASS<Kernel>* kernels)
2785  {
2786  cl_uint numKernels;
2787  cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
2788  if (err != CL_SUCCESS) {
2789  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
2790  }
2791 
2792  Kernel* value = (Kernel*) alloca(numKernels * sizeof(Kernel));
2794  object_, numKernels, (cl_kernel*) value, NULL);
2795  if (err != CL_SUCCESS) {
2796  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
2797  }
2798 
2799  kernels->assign(&value[0], &value[numKernels]);
2800  return CL_SUCCESS;
2801  }
2802 };
2803 
2804 template<>
2805 inline VECTOR_CLASS<char *> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const
2806 {
2807  VECTOR_CLASS< ::size_t> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
2808  VECTOR_CLASS<char *> binaries;
2809  for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s)
2810  {
2811  char *ptr = NULL;
2812  if (*s != 0)
2813  ptr = new char[*s];
2814  binaries.push_back(ptr);
2815  }
2816 
2817  cl_int result = getInfo(CL_PROGRAM_BINARIES, &binaries);
2818  if (err != NULL) {
2819  *err = result;
2820  }
2821  return binaries;
2822 }
2823 
2825 
2826 inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
2827 {
2828  cl_int error;
2829 
2830  object_ = ::clCreateKernel(program(), name, &error);
2831  detail::errHandler(error, __CREATE_KERNEL_ERR);
2832 
2833  if (err != NULL) {
2834  *err = error;
2835  }
2836 
2837 }
2838 
2839 /*! \class CommandQueue
2840  * \brief CommandQueue interface for cl_command_queue.
2841  */
2842 class CE_API CommandQueue : public detail::Wrapper<cl_command_queue>
2843 {
2844 public:
2846  const Context& context,
2847  const Device& device,
2848  cl_command_queue_properties properties = 0,
2849  cl_int* err = NULL)
2850  {
2851  cl_int error;
2852  object_ = ::clCreateCommandQueue(
2853  context(), device(), properties, &error);
2854 
2855  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
2856  if (err != NULL) {
2857  *err = error;
2858  }
2859  }
2860 
2862 
2863  CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
2864 
2865  CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
2866 
2867  CommandQueue& operator = (const CommandQueue& rhs)
2868  {
2869  if (this != &rhs) {
2871  }
2872  return *this;
2873  }
2874 
2875  CommandQueue& operator = (const cl_command_queue& rhs)
2876  {
2878  return *this;
2879  }
2880 
2881  template <typename T>
2883  {
2884  return detail::errHandler(
2886  &::clGetCommandQueueInfo, object_, name, param),
2887  __GET_COMMAND_QUEUE_INFO_ERR);
2888  }
2889 
2890  template <cl_int name> typename
2892  getInfo(cl_int* err = NULL) const
2893  {
2894  typename detail::param_traits<
2896  cl_int result = getInfo(name, &param);
2897  if (err != NULL) {
2898  *err = result;
2899  }
2900  return param;
2901  }
2902 
2904  const Buffer& buffer,
2905  cl_bool blocking,
2906  ::size_t offset,
2907  ::size_t size,
2908  void* ptr,
2909  const VECTOR_CLASS<Event>* events = NULL,
2910  Event* event = NULL) const
2911  {
2912  cl_event tmp;
2913  cl_int err = detail::errHandler(
2915  object_, buffer(), blocking, offset, size,
2916  ptr,
2917  (events != NULL) ? (cl_uint) events->size() : 0,
2918  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2919  (event != NULL) ? &tmp : NULL),
2920  __ENQUEUE_READ_BUFFER_ERR);
2921 
2922  if (event != NULL && err == CL_SUCCESS)
2923  *event = tmp;
2924 
2925  return err;
2926  }
2927 
2929  const Buffer& buffer,
2930  cl_bool blocking,
2931  ::size_t offset,
2932  ::size_t size,
2933  const void* ptr,
2934  const VECTOR_CLASS<Event>* events = NULL,
2935  Event* event = NULL) const
2936  {
2937  cl_event tmp;
2938  cl_int err = detail::errHandler(
2940  object_, buffer(), blocking, offset, size,
2941  ptr,
2942  (events != NULL) ? (cl_uint) events->size() : 0,
2943  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2944  (event != NULL) ? &tmp : NULL),
2945  __ENQUEUE_WRITE_BUFFER_ERR);
2946 
2947  if (event != NULL && err == CL_SUCCESS)
2948  *event = tmp;
2949 
2950  return err;
2951  }
2952 
2954  const Buffer& src,
2955  const Buffer& dst,
2956  ::size_t src_offset,
2957  ::size_t dst_offset,
2958  ::size_t size,
2959  const VECTOR_CLASS<Event>* events = NULL,
2960  Event* event = NULL) const
2961  {
2962  cl_event tmp;
2963  cl_int err = detail::errHandler(
2965  object_, src(), dst(), src_offset, dst_offset, size,
2966  (events != NULL) ? (cl_uint) events->size() : 0,
2967  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2968  (event != NULL) ? &tmp : NULL),
2969  __ENQEUE_COPY_BUFFER_ERR);
2970 
2971  if (event != NULL && err == CL_SUCCESS)
2972  *event = tmp;
2973 
2974  return err;
2975  }
2976 
2977 #if defined(CL_VERSION_1_1)
2978  cl_int enqueueReadBufferRect(
2979  const Buffer& buffer,
2980  cl_bool blocking,
2981  const size_t<3>& buffer_offset,
2982  const size_t<3>& host_offset,
2983  const size_t<3>& region,
2984  ::size_t buffer_row_pitch,
2985  ::size_t buffer_slice_pitch,
2986  ::size_t host_row_pitch,
2987  ::size_t host_slice_pitch,
2988  void *ptr,
2989  const VECTOR_CLASS<Event>* events = NULL,
2990  Event* event = NULL) const
2991  {
2992  cl_event tmp;
2993  cl_int err = detail::errHandler(
2994  ::clEnqueueReadBufferRect(
2995  object_,
2996  buffer(),
2997  blocking,
2998  (const ::size_t *)buffer_offset,
2999  (const ::size_t *)host_offset,
3000  (const ::size_t *)region,
3001  buffer_row_pitch,
3002  buffer_slice_pitch,
3003  host_row_pitch,
3004  host_slice_pitch,
3005  ptr,
3006  (events != NULL) ? (cl_uint) events->size() : 0,
3007  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3008  (event != NULL) ? &tmp : NULL),
3009  __ENQUEUE_READ_BUFFER_RECT_ERR);
3010 
3011  if (event != NULL && err == CL_SUCCESS)
3012  *event = tmp;
3013 
3014  return err;
3015  }
3016 
3017 
3018  cl_int enqueueWriteBufferRect(
3019  const Buffer& buffer,
3020  cl_bool blocking,
3021  const size_t<3>& buffer_offset,
3022  const size_t<3>& host_offset,
3023  const size_t<3>& region,
3024  ::size_t buffer_row_pitch,
3025  ::size_t buffer_slice_pitch,
3026  ::size_t host_row_pitch,
3027  ::size_t host_slice_pitch,
3028  void *ptr,
3029  const VECTOR_CLASS<Event>* events = NULL,
3030  Event* event = NULL) const
3031  {
3032  cl_event tmp;
3033  cl_int err = detail::errHandler(
3034  ::clEnqueueWriteBufferRect(
3035  object_,
3036  buffer(),
3037  blocking,
3038  (const ::size_t *)buffer_offset,
3039  (const ::size_t *)host_offset,
3040  (const ::size_t *)region,
3041  buffer_row_pitch,
3042  buffer_slice_pitch,
3043  host_row_pitch,
3044  host_slice_pitch,
3045  ptr,
3046  (events != NULL) ? (cl_uint) events->size() : 0,
3047  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3048  (event != NULL) ? &tmp : NULL),
3049  __ENQUEUE_WRITE_BUFFER_RECT_ERR);
3050 
3051  if (event != NULL && err == CL_SUCCESS)
3052  *event = tmp;
3053 
3054  return err;
3055  }
3056 
3057  cl_int enqueueCopyBufferRect(
3058  const Buffer& src,
3059  const Buffer& dst,
3060  const size_t<3>& src_origin,
3061  const size_t<3>& dst_origin,
3062  const size_t<3>& region,
3063  ::size_t src_row_pitch,
3064  ::size_t src_slice_pitch,
3065  ::size_t dst_row_pitch,
3066  ::size_t dst_slice_pitch,
3067  const VECTOR_CLASS<Event>* events = NULL,
3068  Event* event = NULL) const
3069  {
3070  cl_event tmp;
3071  cl_int err = detail::errHandler(
3072  ::clEnqueueCopyBufferRect(
3073  object_,
3074  src(),
3075  dst(),
3076  (const ::size_t *)src_origin,
3077  (const ::size_t *)dst_origin,
3078  (const ::size_t *)region,
3079  src_row_pitch,
3080  src_slice_pitch,
3081  dst_row_pitch,
3082  dst_slice_pitch,
3083  (events != NULL) ? (cl_uint) events->size() : 0,
3084  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3085  (event != NULL) ? &tmp : NULL),
3086  __ENQEUE_COPY_BUFFER_RECT_ERR);
3087 
3088  if (event != NULL && err == CL_SUCCESS)
3089  *event = tmp;
3090 
3091  return err;
3092  }
3093 #endif
3094 
3096  const Image& image,
3097  cl_bool blocking,
3098  const size_t<3>& origin,
3099  const size_t<3>& region,
3100  ::size_t row_pitch,
3101  ::size_t slice_pitch,
3102  void* ptr,
3103  const VECTOR_CLASS<Event>* events = NULL,
3104  Event* event = NULL) const
3105  {
3106  cl_event tmp;
3107  cl_int err = detail::errHandler(
3109  object_, image(), blocking, (const ::size_t *) origin,
3110  (const ::size_t *) region, row_pitch, slice_pitch, ptr,
3111  (events != NULL) ? (cl_uint) events->size() : 0,
3112  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3113  (event != NULL) ? &tmp : NULL),
3114  __ENQUEUE_READ_IMAGE_ERR);
3115 
3116  if (event != NULL && err == CL_SUCCESS)
3117  *event = tmp;
3118 
3119  return err;
3120  }
3121 
3123  const Image& image,
3124  cl_bool blocking,
3125  const size_t<3>& origin,
3126  const size_t<3>& region,
3127  ::size_t row_pitch,
3128  ::size_t slice_pitch,
3129  void* ptr,
3130  const VECTOR_CLASS<Event>* events = NULL,
3131  Event* event = NULL) const
3132  {
3133  cl_event tmp;
3134  cl_int err = detail::errHandler(
3136  object_, image(), blocking, (const ::size_t *) origin,
3137  (const ::size_t *) region, row_pitch, slice_pitch, ptr,
3138  (events != NULL) ? (cl_uint) events->size() : 0,
3139  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3140  (event != NULL) ? &tmp : NULL),
3141  __ENQUEUE_WRITE_IMAGE_ERR);
3142 
3143  if (event != NULL && err == CL_SUCCESS)
3144  *event = tmp;
3145 
3146  return err;
3147  }
3148 
3150  const Image& src,
3151  const Image& dst,
3152  const size_t<3>& src_origin,
3153  const size_t<3>& dst_origin,
3154  const size_t<3>& region,
3155  const VECTOR_CLASS<Event>* events = NULL,
3156  Event* event = NULL) const
3157  {
3158  cl_event tmp;
3159  cl_int err = detail::errHandler(
3161  object_, src(), dst(), (const ::size_t *) src_origin,
3162  (const ::size_t *)dst_origin, (const ::size_t *) region,
3163  (events != NULL) ? (cl_uint) events->size() : 0,
3164  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3165  (event != NULL) ? &tmp : NULL),
3166  __ENQUEUE_COPY_IMAGE_ERR);
3167 
3168  if (event != NULL && err == CL_SUCCESS)
3169  *event = tmp;
3170 
3171  return err;
3172  }
3173 
3175  const Image& src,
3176  const Buffer& dst,
3177  const size_t<3>& src_origin,
3178  const size_t<3>& region,
3179  ::size_t dst_offset,
3180  const VECTOR_CLASS<Event>* events = NULL,
3181  Event* event = NULL) const
3182  {
3183  cl_event tmp;
3184  cl_int err = detail::errHandler(
3186  object_, src(), dst(), (const ::size_t *) src_origin,
3187  (const ::size_t *) region, dst_offset,
3188  (events != NULL) ? (cl_uint) events->size() : 0,
3189  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3190  (event != NULL) ? &tmp : NULL),
3191  __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
3192 
3193  if (event != NULL && err == CL_SUCCESS)
3194  *event = tmp;
3195 
3196  return err;
3197  }
3198 
3200  const Buffer& src,
3201  const Image& dst,
3202  ::size_t src_offset,
3203  const size_t<3>& dst_origin,
3204  const size_t<3>& region,
3205  const VECTOR_CLASS<Event>* events = NULL,
3206  Event* event = NULL) const
3207  {
3208  cl_event tmp;
3209  cl_int err = detail::errHandler(
3211  object_, src(), dst(), src_offset,
3212  (const ::size_t *) dst_origin, (const ::size_t *) region,
3213  (events != NULL) ? (cl_uint) events->size() : 0,
3214  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3215  (event != NULL) ? &tmp : NULL),
3216  __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
3217 
3218  if (event != NULL && err == CL_SUCCESS)
3219  *event = tmp;
3220 
3221  return err;
3222  }
3223 
3225  const Buffer& buffer,
3226  cl_bool blocking,
3227  cl_map_flags flags,
3228  ::size_t offset,
3229  ::size_t size,
3230  const VECTOR_CLASS<Event>* events = NULL,
3231  Event* event = NULL,
3232  cl_int* err = NULL) const
3233  {
3234  cl_int error;
3235  void * result = ::clEnqueueMapBuffer(
3236  object_, buffer(), blocking, flags, offset, size,
3237  (events != NULL) ? (cl_uint) events->size() : 0,
3238  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3239  (cl_event*) event,
3240  &error);
3241 
3242  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
3243  if (err != NULL) {
3244  *err = error;
3245  }
3246  return result;
3247  }
3248 
3250  const Image& buffer,
3251  cl_bool blocking,
3252  cl_map_flags flags,
3253  const size_t<3>& origin,
3254  const size_t<3>& region,
3255  ::size_t * row_pitch,
3256  ::size_t * slice_pitch,
3257  const VECTOR_CLASS<Event>* events = NULL,
3258  Event* event = NULL,
3259  cl_int* err = NULL) const
3260  {
3261  cl_int error;
3262  void * result = ::clEnqueueMapImage(
3263  object_, buffer(), blocking, flags,
3264  (const ::size_t *) origin, (const ::size_t *) region,
3265  row_pitch, slice_pitch,
3266  (events != NULL) ? (cl_uint) events->size() : 0,
3267  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3268  (cl_event*) event,
3269  &error);
3270 
3271  detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
3272  if (err != NULL) {
3273  *err = error;
3274  }
3275  return result;
3276  }
3277 
3279  const Memory& memory,
3280  void* mapped_ptr,
3281  const VECTOR_CLASS<Event>* events = NULL,
3282  Event* event = NULL) const
3283  {
3284  cl_event tmp;
3285  cl_int err = detail::errHandler(
3287  object_, memory(), mapped_ptr,
3288  (events != NULL) ? (cl_uint) events->size() : 0,
3289  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3290  (event != NULL) ? &tmp : NULL),
3291  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
3292 
3293  if (event != NULL && err == CL_SUCCESS)
3294  *event = tmp;
3295 
3296  return err;
3297  }
3298 
3300  const Kernel& kernel,
3301  const NDRange& offset,
3302  const NDRange& global,
3303  const NDRange& local,
3304  const VECTOR_CLASS<Event>* events = NULL,
3305  Event* event = NULL) const
3306  {
3307  cl_event tmp;
3308  cl_int err = detail::errHandler(
3310  object_, kernel(), (cl_uint) global.dimensions(),
3311  offset.dimensions() != 0 ? (const ::size_t*) offset : NULL,
3312  (const ::size_t*) global,
3313  local.dimensions() != 0 ? (const ::size_t*) local : NULL,
3314  (events != NULL) ? (cl_uint) events->size() : 0,
3315  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3316  (event != NULL) ? &tmp : NULL),
3317  __ENQUEUE_NDRANGE_KERNEL_ERR);
3318 
3319  if (event != NULL && err == CL_SUCCESS)
3320  *event = tmp;
3321 
3322  return err;
3323  }
3324 
3325  cl_int enqueueTask(
3326  const Kernel& kernel,
3327  const VECTOR_CLASS<Event>* events = NULL,
3328  Event* event = NULL) const
3329  {
3330  cl_event tmp;
3331  cl_int err = detail::errHandler(
3332  ::clEnqueueTask(
3333  object_, kernel(),
3334  (events != NULL) ? (cl_uint) events->size() : 0,
3335  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3336  (event != NULL) ? &tmp : NULL),
3337  __ENQUEUE_TASK_ERR);
3338 
3339  if (event != NULL && err == CL_SUCCESS)
3340  *event = tmp;
3341 
3342  return err;
3343  }
3344 
3346  // Our windows API doesn't have the __stdcall for the user pointer
3347  // so we have to change the definition here.
3348 #ifdef _WIN32
3349  void (*userFptr)(void *),
3350 #else
3351  void (CL_CALLBACK *userFptr)(void *),
3352 #endif
3353  std::pair<void*, ::size_t> args,
3354  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3355  const VECTOR_CLASS<const void*>* mem_locs = NULL,
3356  const VECTOR_CLASS<Event>* events = NULL,
3357  Event* event = NULL) const
3358  {
3359  cl_mem * mems = (mem_objects != NULL && mem_objects->size() > 0)
3360  ? (cl_mem*) alloca(mem_objects->size() * sizeof(cl_mem))
3361  : NULL;
3362 
3363  if (mems != NULL) {
3364  for (unsigned int i = 0; i < mem_objects->size(); i++) {
3365  mems[i] = ((*mem_objects)[i])();
3366  }
3367  }
3368 
3369  cl_event tmp;
3370  cl_int err = detail::errHandler(
3372  object_, userFptr, args.first, args.second,
3373  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3374  mems,
3375  (mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL,
3376  (events != NULL) ? (cl_uint) events->size() : 0,
3377  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3378  (event != NULL) ? &tmp : NULL),
3379  __ENQUEUE_NATIVE_KERNEL);
3380 
3381  if (event != NULL && err == CL_SUCCESS)
3382  *event = tmp;
3383 
3384  return err;
3385  }
3386 
3387 #if defined(CL_VERSION_1_2)
3388  cl_int enqueueMarkerWithWaitList(
3389  const VECTOR_CLASS<Event>& events, Event* event = NULL) const
3390  {
3391  return detail::errHandler(
3392  ::clEnqueueMarkerWithWaitList(
3393  object_,
3394  (cl_uint) events.size(),
3395  (const cl_event*) &events.front(),
3396  (cl_event *)event),
3397  __ENQUEUE_MARKER_WITH_WAIT_LIST_ERR);
3398  }
3399 #else
3400  cl_int enqueueMarker(Event* event = NULL) const
3401  {
3402  return detail::errHandler(
3403  ::clEnqueueMarker(object_, (cl_event*) event),
3404  __ENQUEUE_MARKER_ERR);
3405  }
3406 
3407  cl_int enqueueWaitForEvents(const VECTOR_CLASS<Event>& events) const
3408  {
3409  return detail::errHandler(
3411  object_,
3412  (cl_uint) events.size(),
3413  (const cl_event*) &events.front()),
3414  __ENQUEUE_WAIT_FOR_EVENTS_ERR);
3415  }
3416 #endif
3417 
3419  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3420  const VECTOR_CLASS<Event>* events = NULL,
3421  Event* event = NULL) const
3422  {
3423  cl_event tmp;
3424  cl_int err = detail::errHandler(
3426  object_,
3427  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3428  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3429  (events != NULL) ? (cl_uint) events->size() : 0,
3430  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3431  (event != NULL) ? &tmp : NULL),
3432  __ENQUEUE_ACQUIRE_GL_ERR);
3433 
3434  if (event != NULL && err == CL_SUCCESS)
3435  *event = tmp;
3436 
3437  return err;
3438  }
3439 
3441  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3442  const VECTOR_CLASS<Event>* events = NULL,
3443  Event* event = NULL) const
3444  {
3445  cl_event tmp;
3446  cl_int err = detail::errHandler(
3448  object_,
3449  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3450  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3451  (events != NULL) ? (cl_uint) events->size() : 0,
3452  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3453  (event != NULL) ? &tmp : NULL),
3454  __ENQUEUE_RELEASE_GL_ERR);
3455 
3456  if (event != NULL && err == CL_SUCCESS)
3457  *event = tmp;
3458 
3459  return err;
3460  }
3461 
3462 #if defined (USE_DX_INTEROP)
3463 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
3464  cl_command_queue command_queue, cl_uint num_objects,
3465  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
3466  const cl_event* event_wait_list, cl_event* event);
3467 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
3468  cl_command_queue command_queue, cl_uint num_objects,
3469  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
3470  const cl_event* event_wait_list, cl_event* event);
3471 
3472  cl_int enqueueAcquireD3D10Objects(
3473  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3474  const VECTOR_CLASS<Event>* events = NULL,
3475  Event* event = NULL) const
3476  {
3477  static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
3478  __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR);
3479 
3480  cl_event tmp;
3481  cl_int err = detail::errHandler(
3482  pfn_clEnqueueAcquireD3D10ObjectsKHR(
3483  object_,
3484  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3485  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3486  (events != NULL) ? (cl_uint) events->size() : 0,
3487  (events != NULL) ? (cl_event*) &events->front() : NULL,
3488  (event != NULL) ? &tmp : NULL),
3489  __ENQUEUE_ACQUIRE_GL_ERR);
3490 
3491  if (event != NULL && err == CL_SUCCESS)
3492  *event = tmp;
3493 
3494  return err;
3495  }
3496 
3497  cl_int enqueueReleaseD3D10Objects(
3498  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3499  const VECTOR_CLASS<Event>* events = NULL,
3500  Event* event = NULL) const
3501  {
3502  static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
3503  __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR);
3504 
3505  cl_event tmp;
3506  cl_int err = detail::errHandler(
3507  pfn_clEnqueueReleaseD3D10ObjectsKHR(
3508  object_,
3509  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3510  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3511  (events != NULL) ? (cl_uint) events->size() : 0,
3512  (events != NULL) ? (cl_event*) &events->front() : NULL,
3513  (event != NULL) ? &tmp : NULL),
3514  __ENQUEUE_RELEASE_GL_ERR);
3515 
3516  if (event != NULL && err == CL_SUCCESS)
3517  *event = tmp;
3518 
3519  return err;
3520  }
3521 #endif
3522 
3523 #if defined(CL_VERSION_1_2)
3524  cl_int enqueueBarrierWithWaitList(
3525  const VECTOR_CLASS<Event>& events, Event* event = NULL) const
3526  {
3527  return detail::errHandler(
3528  ::clEnqueueBarrierWithWaitList(
3529  object_,
3530  (cl_uint) events.size(),
3531  (const cl_event*) &events.front(),
3532  (cl_event *)event),
3533  __ENQUEUE_BARRIER_ERR);
3534  }
3535 #else
3536  cl_int enqueueBarrier() const
3537  {
3538  return detail::errHandler(
3539  ::clEnqueueBarrier(object_),
3540  __ENQUEUE_BARRIER_ERR);
3541  }
3542 #endif
3543 
3544  cl_int flush() const
3545  {
3546  return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
3547  }
3548 
3549  cl_int finish() const
3550  {
3551  return detail::errHandler(::clFinish(object_), __FINISH_ERR);
3552  }
3553 };
3554 
3556 
3557 /*! \class KernelFunctor
3558  * \brief Kernel functor interface
3559  *
3560  * \note Currently only functors of zero to ten arguments are supported. It
3561  * is straightforward to add more and a more general solution, similar to
3562  * Boost.Lambda could be followed if required in the future.
3563  */
3565 {
3566 private:
3567  Kernel kernel_;
3568  CommandQueue queue_;
3569  NDRange offset_;
3570  NDRange global_;
3571  NDRange local_;
3572 
3573  cl_int err_;
3574 public:
3576 
3578  const Kernel& kernel,
3579  const CommandQueue& queue,
3580  const NDRange& offset,
3581  const NDRange& global,
3582  const NDRange& local) :
3583  kernel_(kernel),
3584  queue_(queue),
3585  offset_(offset),
3586  global_(global),
3587  local_(local),
3588  err_(CL_SUCCESS)
3589  {}
3590 
3591  KernelFunctor& operator=(const KernelFunctor& rhs);
3592 
3593  KernelFunctor(const KernelFunctor& rhs);
3594 
3595  cl_int getError() { return err_; }
3596 
3597  inline Event operator()(const VECTOR_CLASS<Event>* events = NULL);
3598 
3599  template<typename A1>
3600  inline Event operator()(
3601  const A1& a1,
3602  const VECTOR_CLASS<Event>* events = NULL);
3603 
3604  template<class A1, class A2>
3605  inline Event operator()(
3606  const A1& a1,
3607  const A2& a2,
3608  const VECTOR_CLASS<Event>* events = NULL);
3609 
3610  template<class A1, class A2, class A3>
3611  inline Event operator()(
3612  const A1& a1,
3613  const A2& a2,
3614  const A3& a3,
3615  const VECTOR_CLASS<Event>* events = NULL);
3616 
3617  template<class A1, class A2, class A3, class A4>
3618  inline Event operator()(
3619  const A1& a1,
3620  const A2& a2,
3621  const A3& a3,
3622  const A4& a4,
3623  const VECTOR_CLASS<Event>* events = NULL);
3624 
3625  template<class A1, class A2, class A3, class A4, class A5>
3626  inline Event operator()(
3627  const A1& a1,
3628  const A2& a2,
3629  const A3& a3,
3630  const A4& a4,
3631  const A5& a5,
3632  const VECTOR_CLASS<Event>* events = NULL);
3633 
3634  template<class A1, class A2, class A3, class A4, class A5, class A6>
3635  inline Event operator()(
3636  const A1& a1,
3637  const A2& a2,
3638  const A3& a3,
3639  const A4& a4,
3640  const A5& a5,
3641  const A6& a6,
3642  const VECTOR_CLASS<Event>* events = NULL);
3643 
3644  template<class A1, class A2, class A3, class A4,
3645  class A5, class A6, class A7>
3646  inline Event operator()(
3647  const A1& a1,
3648  const A2& a2,
3649  const A3& a3,
3650  const A4& a4,
3651  const A5& a5,
3652  const A6& a6,
3653  const A7& a7,
3654  const VECTOR_CLASS<Event>* events = NULL);
3655 
3656  template<class A1, class A2, class A3, class A4, class A5,
3657  class A6, class A7, class A8>
3658  inline Event operator()(
3659  const A1& a1,
3660  const A2& a2,
3661  const A3& a3,
3662  const A4& a4,
3663  const A5& a5,
3664  const A6& a6,
3665  const A7& a7,
3666  const A8& a8,
3667  const VECTOR_CLASS<Event>* events = NULL);
3668 
3669  template<class A1, class A2, class A3, class A4, class A5,
3670  class A6, class A7, class A8, class A9>
3671  inline Event operator()(
3672  const A1& a1,
3673  const A2& a2,
3674  const A3& a3,
3675  const A4& a4,
3676  const A5& a5,
3677  const A6& a6,
3678  const A7& a7,
3679  const A8& a8,
3680  const A9& a9,
3681  const VECTOR_CLASS<Event>* events = NULL);
3682 
3683  template<class A1, class A2, class A3, class A4, class A5,
3684  class A6, class A7, class A8, class A9, class A10>
3685  inline Event operator()(
3686  const A1& a1,
3687  const A2& a2,
3688  const A3& a3,
3689  const A4& a4,
3690  const A5& a5,
3691  const A6& a6,
3692  const A7& a7,
3693  const A8& a8,
3694  const A9& a9,
3695  const A10& a10,
3696  const VECTOR_CLASS<Event>* events = NULL);
3697 
3698  template<class A1, class A2, class A3, class A4, class A5,
3699  class A6, class A7, class A8, class A9, class A10,
3700  class A11>
3701  inline Event operator()(
3702  const A1& a1,
3703  const A2& a2,
3704  const A3& a3,
3705  const A4& a4,
3706  const A5& a5,
3707  const A6& a6,
3708  const A7& a7,
3709  const A8& a8,
3710  const A9& a9,
3711  const A10& a10,
3712  const A11& a11,
3713  const VECTOR_CLASS<Event>* events = NULL);
3714 
3715  template<class A1, class A2, class A3, class A4, class A5,
3716  class A6, class A7, class A8, class A9, class A10,
3717  class A11, class A12>
3718  inline Event operator()(
3719  const A1& a1,
3720  const A2& a2,
3721  const A3& a3,
3722  const A4& a4,
3723  const A5& a5,
3724  const A6& a6,
3725  const A7& a7,
3726  const A8& a8,
3727  const A9& a9,
3728  const A10& a10,
3729  const A11& a11,
3730  const A12& a12,
3731  const VECTOR_CLASS<Event>* events = NULL);
3732 
3733  template<class A1, class A2, class A3, class A4, class A5,
3734  class A6, class A7, class A8, class A9, class A10,
3735  class A11, class A12, class A13>
3736  inline Event operator()(
3737  const A1& a1,
3738  const A2& a2,
3739  const A3& a3,
3740  const A4& a4,
3741  const A5& a5,
3742  const A6& a6,
3743  const A7& a7,
3744  const A8& a8,
3745  const A9& a9,
3746  const A10& a10,
3747  const A11& a11,
3748  const A12& a12,
3749  const A13& a13,
3750  const VECTOR_CLASS<Event>* events = NULL);
3751 
3752  template<class A1, class A2, class A3, class A4, class A5,
3753  class A6, class A7, class A8, class A9, class A10,
3754  class A11, class A12, class A13, class A14>
3755  inline Event operator()(
3756  const A1& a1,
3757  const A2& a2,
3758  const A3& a3,
3759  const A4& a4,
3760  const A5& a5,
3761  const A6& a6,
3762  const A7& a7,
3763  const A8& a8,
3764  const A9& a9,
3765  const A10& a10,
3766  const A11& a11,
3767  const A12& a12,
3768  const A13& a13,
3769  const A14& a14,
3770  const VECTOR_CLASS<Event>* events = NULL);
3771 
3772  template<class A1, class A2, class A3, class A4, class A5,
3773  class A6, class A7, class A8, class A9, class A10,
3774  class A11, class A12, class A13, class A14, class A15>
3775  inline Event operator()(
3776  const A1& a1,
3777  const A2& a2,
3778  const A3& a3,
3779  const A4& a4,
3780  const A5& a5,
3781  const A6& a6,
3782  const A7& a7,
3783  const A8& a8,
3784  const A9& a9,
3785  const A10& a10,
3786  const A11& a11,
3787  const A12& a12,
3788  const A13& a13,
3789  const A14& a14,
3790  const A15& a15,
3791  const VECTOR_CLASS<Event>* events = NULL);
3792 };
3793 
3795  const CommandQueue& queue,
3796  const NDRange& offset,
3797  const NDRange& global,
3798  const NDRange& local)
3799 {
3800  return KernelFunctor(*this,queue,offset,global,local);
3801 }
3802 
3804  const CommandQueue& queue,
3805  const NDRange& global,
3806  const NDRange& local)
3807 {
3808  return KernelFunctor(*this,queue,NullRange,global,local);
3809 }
3810 
3812 {
3813  if (this == &rhs) {
3814  return *this;
3815  }
3816 
3817  kernel_ = rhs.kernel_;
3818  queue_ = rhs.queue_;
3819  offset_ = rhs.offset_;
3820  global_ = rhs.global_;
3821  local_ = rhs.local_;
3822 
3823  return *this;
3824 }
3825 
3827  kernel_(rhs.kernel_),
3828  queue_(rhs.queue_),
3829  offset_(rhs.offset_),
3830  global_(rhs.global_),
3831  local_(rhs.local_)
3832 {
3833 }
3834 
3835 Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* )
3836 {
3837  Event event;
3838 
3839  err_ = queue_.enqueueNDRangeKernel(
3840  kernel_,
3841  offset_,
3842  global_,
3843  local_,
3844  NULL, // bgaster_fixme - do we want to allow wait event lists?
3845  &event);
3846 
3847  return event;
3848 }
3849 
3850 template<typename A1>
3852  const A1& a1,
3853  const VECTOR_CLASS<Event>* )
3854 {
3855  Event event;
3856 
3857  kernel_.setArg(0,a1);
3858 
3859  err_ = queue_.enqueueNDRangeKernel(
3860  kernel_,
3861  offset_,
3862  global_,
3863  local_,
3864  NULL, // bgaster_fixme - do we want to allow wait event lists?
3865  &event);
3866 
3867  return event;
3868 }
3869 
3870 template<typename A1, typename A2>
3872  const A1& a1,
3873  const A2& a2,
3874  const VECTOR_CLASS<Event>* )
3875 {
3876  Event event;
3877 
3878  kernel_.setArg(0,a1);
3879  kernel_.setArg(1,a2);
3880 
3881  err_ = queue_.enqueueNDRangeKernel(
3882  kernel_,
3883  offset_,
3884  global_,
3885  local_,
3886  NULL, // bgaster_fixme - do we want to allow wait event lists?
3887  &event);
3888 
3889  return event;
3890 }
3891 
3892 template<typename A1, typename A2, typename A3>
3894  const A1& a1,
3895  const A2& a2,
3896  const A3& a3,
3897  const VECTOR_CLASS<Event>* )
3898 {
3899  Event event;
3900 
3901  kernel_.setArg(0,a1);
3902  kernel_.setArg(1,a2);
3903  kernel_.setArg(2,a3);
3904 
3905  err_ = queue_.enqueueNDRangeKernel(
3906  kernel_,
3907  offset_,
3908  global_,
3909  local_,
3910  NULL, // bgaster_fixme - do we want to allow wait event lists?
3911  &event);
3912 
3913  return event;
3914 }
3915 
3916 template<typename A1, typename A2, typename A3, typename A4>
3918  const A1& a1,
3919  const A2& a2,
3920  const A3& a3,
3921  const A4& a4,
3922  const VECTOR_CLASS<Event>* )
3923 {
3924  Event event;
3925 
3926  kernel_.setArg(0,a1);
3927  kernel_.setArg(1,a2);
3928  kernel_.setArg(2,a3);
3929  kernel_.setArg(3,a4);
3930 
3931  err_ = queue_.enqueueNDRangeKernel(
3932  kernel_,
3933  offset_,
3934  global_,
3935  local_,
3936  NULL, // bgaster_fixme - do we want to allow wait event lists?
3937  &event);
3938 
3939  return event;
3940 }
3941 
3942 template<typename A1, typename A2, typename A3, typename A4, typename A5>
3944  const A1& a1,
3945  const A2& a2,
3946  const A3& a3,
3947  const A4& a4,
3948  const A5& a5,
3949  const VECTOR_CLASS<Event>* )
3950 {
3951  Event event;
3952 
3953  kernel_.setArg(0,a1);
3954  kernel_.setArg(1,a2);
3955  kernel_.setArg(2,a3);
3956  kernel_.setArg(3,a4);
3957  kernel_.setArg(4,a5);
3958 
3959  err_ = queue_.enqueueNDRangeKernel(
3960  kernel_,
3961  offset_,
3962  global_,
3963  local_,
3964  NULL, // bgaster_fixme - do we want to allow wait event lists?
3965  &event);
3966 
3967  return event;
3968 }
3969 
3970 template<typename A1, typename A2, typename A3, typename A4, typename A5,
3971  typename A6>
3973  const A1& a1,
3974  const A2& a2,
3975  const A3& a3,
3976  const A4& a4,
3977  const A5& a5,
3978  const A6& a6,
3979  const VECTOR_CLASS<Event>* )
3980 {
3981  Event event;
3982 
3983  kernel_.setArg(0,a1);
3984  kernel_.setArg(1,a2);
3985  kernel_.setArg(2,a3);
3986  kernel_.setArg(3,a4);
3987  kernel_.setArg(4,a5);
3988  kernel_.setArg(5,a6);
3989 
3990  err_ = queue_.enqueueNDRangeKernel(
3991  kernel_,
3992  offset_,
3993  global_,
3994  local_,
3995  NULL, // bgaster_fixme - do we want to allow wait event lists?
3996  &event);
3997 
3998  return event;
3999 }
4000 
4001 template<typename A1, typename A2, typename A3, typename A4,
4002  typename A5, typename A6, typename A7>
4004  const A1& a1,
4005  const A2& a2,
4006  const A3& a3,
4007  const A4& a4,
4008  const A5& a5,
4009  const A6& a6,
4010  const A7& a7,
4011  const VECTOR_CLASS<Event>* )
4012 {
4013  Event event;
4014 
4015  kernel_.setArg(0,a1);
4016  kernel_.setArg(1,a2);
4017  kernel_.setArg(2,a3);
4018  kernel_.setArg(3,a4);
4019  kernel_.setArg(4,a5);
4020  kernel_.setArg(5,a6);
4021  kernel_.setArg(6,a7);
4022 
4023  err_ = queue_.enqueueNDRangeKernel(
4024  kernel_,
4025  offset_,
4026  global_,
4027  local_,
4028  NULL, // bgaster_fixme - do we want to allow wait event lists?
4029  &event);
4030 
4031  return event;
4032 }
4033 
4034 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4035  typename A6, typename A7, typename A8>
4037  const A1& a1,
4038  const A2& a2,
4039  const A3& a3,
4040  const A4& a4,
4041  const A5& a5,
4042  const A6& a6,
4043  const A7& a7,
4044  const A8& a8,
4045  const VECTOR_CLASS<Event>* )
4046 {
4047  Event event;
4048 
4049  kernel_.setArg(0,a1);
4050  kernel_.setArg(1,a2);
4051  kernel_.setArg(2,a3);
4052  kernel_.setArg(3,a4);
4053  kernel_.setArg(4,a5);
4054  kernel_.setArg(5,a6);
4055  kernel_.setArg(6,a7);
4056  kernel_.setArg(7,a8);
4057 
4058  err_ = queue_.enqueueNDRangeKernel(
4059  kernel_,
4060  offset_,
4061  global_,
4062  local_,
4063  NULL, // bgaster_fixme - do we want to allow wait event lists?
4064  &event);
4065 
4066  return event;
4067 }
4068 
4069 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4070  typename A6, typename A7, typename A8, typename A9>
4072  const A1& a1,
4073  const A2& a2,
4074  const A3& a3,
4075  const A4& a4,
4076  const A5& a5,
4077  const A6& a6,
4078  const A7& a7,
4079  const A8& a8,
4080  const A9& a9,
4081  const VECTOR_CLASS<Event>* )
4082 {
4083  Event event;
4084 
4085  kernel_.setArg(0,a1);
4086  kernel_.setArg(1,a2);
4087  kernel_.setArg(2,a3);
4088  kernel_.setArg(3,a4);
4089  kernel_.setArg(4,a5);
4090  kernel_.setArg(5,a6);
4091  kernel_.setArg(6,a7);
4092  kernel_.setArg(7,a8);
4093  kernel_.setArg(8,a9);
4094 
4095  err_ = queue_.enqueueNDRangeKernel(
4096  kernel_,
4097  offset_,
4098  global_,
4099  local_,
4100  NULL, // bgaster_fixme - do we want to allow wait event lists?
4101  &event);
4102 
4103  return event;
4104 }
4105 
4106 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4107  typename A6, typename A7, typename A8, typename A9, typename A10>
4109  const A1& a1,
4110  const A2& a2,
4111  const A3& a3,
4112  const A4& a4,
4113  const A5& a5,
4114  const A6& a6,
4115  const A7& a7,
4116  const A8& a8,
4117  const A9& a9,
4118  const A10& a10,
4119  const VECTOR_CLASS<Event>* )
4120 {
4121  Event event;
4122 
4123  kernel_.setArg(0,a1);
4124  kernel_.setArg(1,a2);
4125  kernel_.setArg(2,a3);
4126  kernel_.setArg(3,a4);
4127  kernel_.setArg(4,a5);
4128  kernel_.setArg(5,a6);
4129  kernel_.setArg(6,a7);
4130  kernel_.setArg(7,a8);
4131  kernel_.setArg(8,a9);
4132  kernel_.setArg(9,a10);
4133 
4134  err_ = queue_.enqueueNDRangeKernel(
4135  kernel_,
4136  offset_,
4137  global_,
4138  local_,
4139  NULL, // bgaster_fixme - do we want to allow wait event lists?
4140  &event);
4141 
4142  return event;
4143 }
4144 
4145 template<class A1, class A2, class A3, class A4, class A5,
4146  class A6, class A7, class A8, class A9, class A10,
4147  class A11>
4149  const A1& a1,
4150  const A2& a2,
4151  const A3& a3,
4152  const A4& a4,
4153  const A5& a5,
4154  const A6& a6,
4155  const A7& a7,
4156  const A8& a8,
4157  const A9& a9,
4158  const A10& a10,
4159  const A11& a11,
4160  const VECTOR_CLASS<Event>* )
4161 {
4162  Event event;
4163 
4164  kernel_.setArg(0,a1);
4165  kernel_.setArg(1,a2);
4166  kernel_.setArg(2,a3);
4167  kernel_.setArg(3,a4);
4168  kernel_.setArg(4,a5);
4169  kernel_.setArg(5,a6);
4170  kernel_.setArg(6,a7);
4171  kernel_.setArg(7,a8);
4172  kernel_.setArg(8,a9);
4173  kernel_.setArg(9,a10);
4174  kernel_.setArg(10,a11);
4175 
4176  err_ = queue_.enqueueNDRangeKernel(
4177  kernel_,
4178  offset_,
4179  global_,
4180  local_,
4181  NULL, // bgaster_fixme - do we want to allow wait event lists?
4182  &event);
4183 
4184  return event;
4185 }
4186 
4187 template<class A1, class A2, class A3, class A4, class A5,
4188  class A6, class A7, class A8, class A9, class A10,
4189  class A11, class A12>
4191  const A1& a1,
4192  const A2& a2,
4193  const A3& a3,
4194  const A4& a4,
4195  const A5& a5,
4196  const A6& a6,
4197  const A7& a7,
4198  const A8& a8,
4199  const A9& a9,
4200  const A10& a10,
4201  const A11& a11,
4202  const A12& a12,
4203  const VECTOR_CLASS<Event>* )
4204 {
4205  Event event;
4206 
4207  kernel_.setArg(0,a1);
4208  kernel_.setArg(1,a2);
4209  kernel_.setArg(2,a3);
4210  kernel_.setArg(3,a4);
4211  kernel_.setArg(4,a5);
4212  kernel_.setArg(5,a6);
4213  kernel_.setArg(6,a7);
4214  kernel_.setArg(7,a8);
4215  kernel_.setArg(8,a9);
4216  kernel_.setArg(9,a10);
4217  kernel_.setArg(10,a11);
4218  kernel_.setArg(11,a12);
4219 
4220  err_ = queue_.enqueueNDRangeKernel(
4221  kernel_,
4222  offset_,
4223  global_,
4224  local_,
4225  NULL, // bgaster_fixme - do we want to allow wait event lists?
4226  &event);
4227 
4228  return event;
4229 }
4230 
4231 template<class A1, class A2, class A3, class A4, class A5,
4232  class A6, class A7, class A8, class A9, class A10,
4233  class A11, class A12, class A13>
4235  const A1& a1,
4236  const A2& a2,
4237  const A3& a3,
4238  const A4& a4,
4239  const A5& a5,
4240  const A6& a6,
4241  const A7& a7,
4242  const A8& a8,
4243  const A9& a9,
4244  const A10& a10,
4245  const A11& a11,
4246  const A12& a12,
4247  const A13& a13,
4248  const VECTOR_CLASS<Event>* )
4249 {
4250  Event event;
4251 
4252  kernel_.setArg(0,a1);
4253  kernel_.setArg(1,a2);
4254  kernel_.setArg(2,a3);
4255  kernel_.setArg(3,a4);
4256  kernel_.setArg(4,a5);
4257  kernel_.setArg(5,a6);
4258  kernel_.setArg(6,a7);
4259  kernel_.setArg(7,a8);
4260  kernel_.setArg(8,a9);
4261  kernel_.setArg(9,a10);
4262  kernel_.setArg(10,a11);
4263  kernel_.setArg(11,a12);
4264  kernel_.setArg(12,a13);
4265 
4266  err_ = queue_.enqueueNDRangeKernel(
4267  kernel_,
4268  offset_,
4269  global_,
4270  local_,
4271  NULL, // bgaster_fixme - do we want to allow wait event lists?
4272  &event);
4273 
4274  return event;
4275 }
4276 
4277 template<class A1, class A2, class A3, class A4, class A5,
4278  class A6, class A7, class A8, class A9, class A10,
4279  class A11, class A12, class A13, class A14>
4281  const A1& a1,
4282  const A2& a2,
4283  const A3& a3,
4284  const A4& a4,
4285  const A5& a5,
4286  const A6& a6,
4287  const A7& a7,
4288  const A8& a8,
4289  const A9& a9,
4290  const A10& a10,
4291  const A11& a11,
4292  const A12& a12,
4293  const A13& a13,
4294  const A14& a14,
4295  const VECTOR_CLASS<Event>* )
4296 {
4297  Event event;
4298 
4299  kernel_.setArg(0,a1);
4300  kernel_.setArg(1,a2);
4301  kernel_.setArg(2,a3);
4302  kernel_.setArg(3,a4);
4303  kernel_.setArg(4,a5);
4304  kernel_.setArg(5,a6);
4305  kernel_.setArg(6,a7);
4306  kernel_.setArg(7,a8);
4307  kernel_.setArg(8,a9);
4308  kernel_.setArg(9,a10);
4309  kernel_.setArg(10,a11);
4310  kernel_.setArg(11,a12);
4311  kernel_.setArg(12,a13);
4312  kernel_.setArg(13,a14);
4313 
4314  err_ = queue_.enqueueNDRangeKernel(
4315  kernel_,
4316  offset_,
4317  global_,
4318  local_,
4319  NULL, // bgaster_fixme - do we want to allow wait event lists?
4320  &event);
4321 
4322  return event;
4323 }
4324 
4325 template<class A1, class A2, class A3, class A4, class A5,
4326  class A6, class A7, class A8, class A9, class A10,
4327  class A11, class A12, class A13, class A14, class A15>
4329  const A1& a1,
4330  const A2& a2,
4331  const A3& a3,
4332  const A4& a4,
4333  const A5& a5,
4334  const A6& a6,
4335  const A7& a7,
4336  const A8& a8,
4337  const A9& a9,
4338  const A10& a10,
4339  const A11& a11,
4340  const A12& a12,
4341  const A13& a13,
4342  const A14& a14,
4343  const A15& a15,
4344  const VECTOR_CLASS<Event>* )
4345 {
4346  Event event;
4347 
4348  kernel_.setArg(0,a1);
4349  kernel_.setArg(1,a2);
4350  kernel_.setArg(2,a3);
4351  kernel_.setArg(3,a4);
4352  kernel_.setArg(4,a5);
4353  kernel_.setArg(5,a6);
4354  kernel_.setArg(6,a7);
4355  kernel_.setArg(7,a8);
4356  kernel_.setArg(8,a9);
4357  kernel_.setArg(9,a10);
4358  kernel_.setArg(10,a11);
4359  kernel_.setArg(11,a12);
4360  kernel_.setArg(12,a13);
4361  kernel_.setArg(13,a14);
4362  kernel_.setArg(14,a15);
4363 
4364  err_ = queue_.enqueueNDRangeKernel(
4365  kernel_,
4366  offset_,
4367  global_,
4368  local_,
4369  NULL, // bgaster_fixme - do we want to allow wait event lists?
4370  &event);
4371 
4372  return event;
4373 }
4374 
4375 #undef __ERR_STR
4376 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
4377 #undef __GET_DEVICE_INFO_ERR
4378 #undef __GET_PLATFORM_INFO_ERR
4379 #undef __GET_DEVICE_IDS_ERR
4380 #undef __GET_CONTEXT_INFO_ERR
4381 #undef __GET_EVENT_INFO_ERR
4382 #undef __GET_EVENT_PROFILE_INFO_ERR
4383 #undef __GET_MEM_OBJECT_INFO_ERR
4384 #undef __GET_IMAGE_INFO_ERR
4385 #undef __GET_SAMPLER_INFO_ERR
4386 #undef __GET_KERNEL_INFO_ERR
4387 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
4388 #undef __GET_PROGRAM_INFO_ERR
4389 #undef __GET_PROGRAM_BUILD_INFO_ERR
4390 #undef __GET_COMMAND_QUEUE_INFO_ERR
4391 
4392 #undef __CREATE_CONTEXT_ERR
4393 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
4394 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
4395 
4396 #undef __CREATE_BUFFER_ERR
4397 #undef __CREATE_SUBBUFFER_ERR
4398 #undef __CREATE_IMAGE2D_ERR
4399 #undef __CREATE_IMAGE3D_ERR
4400 #undef __CREATE_SAMPLER_ERR
4401 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
4402 
4403 #undef __CREATE_USER_EVENT_ERR
4404 #undef __SET_USER_EVENT_STATUS_ERR
4405 #undef __SET_EVENT_CALLBACK_ERR
4406 
4407 #undef __WAIT_FOR_EVENTS_ERR
4408 
4409 #undef __CREATE_KERNEL_ERR
4410 #undef __SET_KERNEL_ARGS_ERR
4411 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
4412 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
4413 #undef __BUILD_PROGRAM_ERR
4414 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
4415 
4416 #undef __CREATE_COMMAND_QUEUE_ERR
4417 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
4418 #undef __ENQUEUE_READ_BUFFER_ERR
4419 #undef __ENQUEUE_WRITE_BUFFER_ERR
4420 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
4421 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
4422 #undef __ENQEUE_COPY_BUFFER_ERR
4423 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
4424 #undef __ENQUEUE_READ_IMAGE_ERR
4425 #undef __ENQUEUE_WRITE_IMAGE_ERR
4426 #undef __ENQUEUE_COPY_IMAGE_ERR
4427 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
4428 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
4429 #undef __ENQUEUE_MAP_BUFFER_ERR
4430 #undef __ENQUEUE_MAP_IMAGE_ERR
4431 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
4432 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
4433 #undef __ENQUEUE_TASK_ERR
4434 #undef __ENQUEUE_NATIVE_KERNEL
4435 
4436 #undef __UNLOAD_COMPILER_ERR
4437 #endif //__CL_USER_OVERRIDE_ERROR_STRINGS
4438 
4439 #undef __GET_INFO_HELPER_WITH_RETAIN
4440 
4441 // Extensions
4442 #undef __INIT_CL_EXT_FCN_PTR
4443 #undef __CREATE_SUB_DEVICES
4444 
4445 #if defined(USE_CL_DEVICE_FISSION)
4446 #undef __PARAM_NAME_DEVICE_FISSION
4447 #endif // USE_CL_DEVICE_FISSION
4448 
4449 } // namespace cl
4450 
4451 #endif // CL_HPP_
GLdouble s
Definition: glew.h:1390
#define CE_API
Definition: CE_API.h:10
struct _cl_device_id * cl_device_id
Definition: cl.h:42
cl_uint cl_device_info
Definition: cl.h:55
unsigned int capacity() const
Definition: cl.hpp:550
vector()
Definition: cl.hpp:452
Memory()
Definition: cl.hpp:1803
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format,::size_t width,::size_t height,::size_t row_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Definition: cl.hpp:2147
Image3D(const cl_mem &image3D)
Definition: cl.hpp:2303
const T & front(void) const
Definition: cl.hpp:678
void push_back(const T &x)
Definition: cl.hpp:470
CL_API_ENTRY cl_int CL_API_CALL clGetEventProfilingInfo(cl_event, cl_profiling_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
#define __GET_INFO_HELPER_WITH_RETAIN(CPP_TYPE)
Definition: cl.hpp:800
CL_API_ENTRY cl_int CL_API_CALL clRetainEvent(cl_event) CL_API_SUFFIX__VERSION_1_0
cl_int getInfo(cl_platform_info name, STRING_CLASS *param) const
Definition: cl.hpp:1369
Image2D(const cl_mem &image2D)
Definition: cl.hpp:2181
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1594
struct _cl_context * cl_context
Definition: cl.h:43
Memory & operator=(const Memory &rhs)
Definition: cl.hpp:1809
NDRange(::size_t size0,::size_t size1,::size_t size2)
Definition: cl.hpp:2482
int GLint
Definition: cl.hpp:165
GLsizeiptr size
Definition: glew.h:1681
GLenum src
Definition: glew.h:2410
static cl_int retain(cl_sampler sampler)
Definition: cl.hpp:1125
CL_API_ENTRY cl_int CL_API_CALL clReleaseMemObject(cl_mem) CL_API_SUFFIX__VERSION_1_0
GLsizei GLenum * sources
Definition: glew.h:3954
CL_API_ENTRY cl_kernel CL_API_CALL clCreateKernel(cl_program, const char *, cl_int *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
KernelFunctor & operator=(const KernelFunctor &rhs)
Definition: cl.hpp:3811
GLuint const GLchar * name
Definition: glew.h:1814
ImageFormat interface fro cl_image_format.
Definition: cl.hpp:1238
CL_API_ENTRY cl_int CL_API_CALL clReleaseKernel(cl_kernel) CL_API_SUFFIX__VERSION_1_0
::size_t length(void) const
Definition: cl.hpp:417
Memory(const Memory &memory)
Definition: cl.hpp:1805
CL_API_ENTRY void *CL_API_CALL clEnqueueMapImage(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t *, const size_t *, size_t *, size_t *, cl_uint, const cl_event *, cl_event *, cl_int *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo(cl_mem, cl_gl_object_type *, cl_GLuint *) CL_API_SUFFIX__VERSION_1_0
cl_uint cl_mem_object_type
Definition: cl.h:81
cl_uint cl_program_build_info
Definition: cl.h:99
cl_ulong cl_device_partition_property_ext
Definition: cl_ext.h:264
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:643
Image & operator=(const Image &rhs)
Definition: cl.hpp:2104
cl_uint cl_addressing_mode
Definition: cl.h:90
Context(cl_device_type type, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *,::size_t, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Definition: cl.hpp:1543
static iterator end(vector< T, N > &vec)
Definition: cl.hpp:608
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueMarker(cl_command_queue, cl_event *) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithSource(cl_context, cl_uint, const char **, const size_t *, cl_int *) CL_API_SUFFIX__VERSION_1_0
static cl_int release(cl_kernel kernel)
Definition: cl.hpp:1145
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1252
const Args & args
Definition: printf.h:628
static cl_int retain(cl_command_queue queue)
Definition: cl.hpp:1107
CommandQueue(const CommandQueue &commandQueue)
Definition: cl.hpp:2863
void * enqueueMapImage(const Image &buffer, cl_bool blocking, cl_map_flags flags, const size_t< 3 > &origin, const size_t< 3 > &region,::size_t *row_pitch,::size_t *slice_pitch, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL, cl_int *err=NULL) const
Definition: cl.hpp:3249
cl_int getBuildInfo(const Device &device, cl_program_build_info name, T *param) const
Definition: cl.hpp:2762
KernelFunctor(const Kernel &kernel, const CommandQueue &queue, const NDRange &offset, const NDRange &global, const NDRange &local)
Definition: cl.hpp:3577
GLenum target
Definition: glew.h:2865
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, VECTOR_CLASS< ImageFormat > *formats) const
Definition: cl.hpp:1605
GLuint index
Definition: glew.h:1814
CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfo(cl_device_id, cl_device_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
cl_int getInfo(cl_mem_info name, T *param) const
Definition: cl.hpp:1824
CL_API_ENTRY cl_int CL_API_CALL clRetainMemObject(cl_mem) CL_API_SUFFIX__VERSION_1_0
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1296
Local address raper for use with Kernel::setArg.
Definition: cl.hpp:2500
CL_API_ENTRY cl_int CL_API_CALL clReleaseProgram(cl_program) CL_API_SUFFIX__VERSION_1_0
detail::param_traits< detail::cl_kernel_work_group_info, name >::param_type getWorkGroupInfo(const Device &device, cl_int *err=NULL) const
Definition: cl.hpp:2594
GLuint const GLfloat * val
Definition: glew.h:2794
BufferGL(const BufferGL &buffer)
Definition: cl.hpp:2009
cl_uint cl_context_info
Definition: cl.h:70
cl_bitfield cl_map_flags
Definition: cl.h:93
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
static cl_int release(cl_mem memory)
Definition: cl.hpp:1118
void * enqueueMapBuffer(const Buffer &buffer, cl_bool blocking, cl_map_flags flags,::size_t offset,::size_t size, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL, cl_int *err=NULL) const
Definition: cl.hpp:3224
CL_API_ENTRY cl_int CL_API_CALL clReleaseSampler(cl_sampler) CL_API_SUFFIX__VERSION_1_0
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
LocalSpaceArg __local(::size_t size)
Definition: cl.hpp:2525
#define CL_PLATFORM_ICD_SUFFIX_KHR
Definition: cl_ext.h:107
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
cl_int getInfo(cl_program_info name, T *param) const
Definition: cl.hpp:2741
::size_t size(const LocalSpaceArg &value)
Definition: cl.hpp:2517
Memory interface for cl_mem.
Definition: cl.hpp:1800
cl_uint cl_program_info
Definition: cl.h:98
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1252
CommandQueue(const cl_command_queue &commandQueue)
Definition: cl.hpp:2865
cl_int getInfo(cl_sampler_info name, T *param) const
Definition: cl.hpp:2428
cl_int enqueueWaitForEvents(const VECTOR_CLASS< Event > &events) const
Definition: cl.hpp:3407
Program(const cl_program &program)
Definition: cl.hpp:2706
cl_uint cl_channel_order
Definition: cl.h:75
CL_API_ENTRY cl_mem CL_API_CALL clCreateBuffer(cl_context, cl_mem_flags, size_t, void *, cl_int *) CL_API_SUFFIX__VERSION_1_0
detail::param_traits< detail::cl_program_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2750
const GLint * first
Definition: glew.h:1528
Image3D(const Context &context, cl_mem_flags flags, ImageFormat format,::size_t width,::size_t height,::size_t depth,::size_t row_pitch=0,::size_t slice_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Definition: cl.hpp:2264
Kernel(const Kernel &kernel)
Definition: cl.hpp:2543
void operator--(int x)
Definition: cl.hpp:647
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
Image3D(const Image3D &image3D)
Definition: cl.hpp:2301
cl_int enqueueWriteBuffer(const Buffer &buffer, cl_bool blocking,::size_t offset,::size_t size, const void *ptr, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:2928
static cl_int retain(cl_device_id)
Definition: cl.hpp:1077
Buffer(const Context &context, cl_mem_flags flags,::size_t size, void *host_ptr=NULL, cl_int *err=NULL)
Definition: cl.hpp:1868
unsigned int GLuint
Definition: cl.hpp:167
CL_API_ENTRY cl_int CL_API_CALL clReleaseContext(cl_context) CL_API_SUFFIX__VERSION_1_0
T & front(void)
Definition: cl.hpp:668
string(char *str)
Definition: cl.hpp:367
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateImage2D(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t, size_t, void *, cl_int *) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
GLhandleARB obj
Definition: glew.h:6236
unsigned int GLenum
Definition: cl.hpp:166
CL_API_ENTRY cl_int CL_API_CALL clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
cl_int enqueueCopyBuffer(const Buffer &src, const Buffer &dst,::size_t src_offset,::size_t dst_offset,::size_t size, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:2953
vector(unsigned int size, const T &val=T())
Definition: cl.hpp:499
cl_uint cl_d3d10_device_source_khr
Definition: cl_d3d10.h:46
Event()
Definition: cl.hpp:1648
CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer(cl_context, cl_mem_flags, cl_GLuint, cl_int *) CL_API_SUFFIX__VERSION_1_0
#define CL_PROGRAM_BINARIES
Definition: cl.h:644
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateImage3D(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t, size_t, size_t, size_t, void *, cl_int *) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
VECTOR_CLASS< std::pair< const void *,::size_t > > Binaries
Definition: cl.hpp:2644
Image3D & operator=(const Image3D &rhs)
Definition: cl.hpp:2305
CL_API_ENTRY cl_int CL_API_CALL clBuildProgram(cl_program, cl_uint, const cl_device_id *, const char *, void(CL_CALLBACK *)(cl_program, void *), void *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithBinary(cl_context, cl_uint, const cl_device_id *, const size_t *, const unsigned char **, cl_int *, cl_int *) CL_API_SUFFIX__VERSION_1_0
cl_int getDevices(cl_device_type type, VECTOR_CLASS< Device > *devices) const
Definition: cl.hpp:1389
CL_API_ENTRY cl_int CL_API_CALL clRetainProgram(cl_program) CL_API_SUFFIX__VERSION_1_0
#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
Definition: cl_ext.h:224
Image3D()
Definition: cl.hpp:2299
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=NULL)
Definition: cl.hpp:2845
cl_uint cl_filter_mode
Definition: cl.h:91
cl_int enqueueCopyImage(const Image &src, const Image &dst, const size_t< 3 > &src_origin, const size_t< 3 > &dst_origin, const size_t< 3 > &region, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3149
string(char *str,::size_t size)
Definition: cl.hpp:353
CL_API_ENTRY cl_int CL_API_CALL clGetEventInfo(cl_event, cl_event_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
GLfloat param
Definition: glew.h:1530
GLenum GLsizei GLenum GLenum const void * image
Definition: glew.h:4943
Kernel()
Definition: cl.hpp:2541
vector(const vector< T, N > &vec)
Definition: cl.hpp:490
Buffer(const Buffer &buffer)
Definition: cl.hpp:1886
static cl_int release(cl_sampler sampler)
Definition: cl.hpp:1127
bool operator!=(iterator i)
Definition: cl.hpp:627
GLuint GLdouble GLdouble GLint GLint order
Definition: glew.h:3446
static cl_int release(cl_program program)
Definition: cl.hpp:1136
Sampler()
Definition: cl.hpp:2386
CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties *, cl_device_type, void(CL_CALLBACK *)(const char *, const void *, size_t, void *), void *, cl_int *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clGetProgramBuildInfo(cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
struct _cl_platform_id * cl_platform_id
Definition: cl.h:41
cl_uint cl_sampler_info
Definition: cl.h:92
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueBarrier(cl_command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Image(const cl_mem &image)
Definition: cl.hpp:2102
bool operator==(vector< T, N > &vec)
Definition: cl.hpp:524
cl_channel_type image_channel_data_type
Definition: cl.h:125
cl_int finish() const
Definition: cl.hpp:3549
Device(const Device &device)
Definition: cl.hpp:1268
cl_int getError()
Definition: cl.hpp:3595
#define CL_API_ENTRY
Definition: cl_platform.h:43
cl_int release() const
Definition: cl.hpp:1209
cl_int getInfo(cl_event_info name, T *param) const
Definition: cl.hpp:1669
cl_uint cl_channel_type
Definition: cl.h:76
#define CL_DEVICE_INTEGRATED_MEMORY_NV
Definition: cl_ext.h:229
#define CL_DEVICE_REGISTERS_PER_BLOCK_NV
Definition: cl_ext.h:225
T & back(void)
Definition: cl.hpp:673
cl_int setArg(cl_uint index,::size_t size, void *argPtr)
Definition: cl.hpp:2617
cl_uint cl_platform_info
Definition: cl.h:54
cl_uint cl_command_queue_info
Definition: cl.h:74
Event interface for cl_event.
Definition: cl.hpp:1645
Program(const Context &context, const Sources &sources, cl_int *err=NULL)
Definition: cl.hpp:2647
CL_API_ENTRY cl_int CL_API_CALL clGetCommandQueueInfo(cl_command_queue, cl_command_queue_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
Buffer & operator=(const Buffer &rhs)
Definition: cl.hpp:1890
cl_int getImageInfo(cl_image_info name, T *param) const
Definition: cl.hpp:2120
Program(const Context &context, const VECTOR_CLASS< Device > &devices, const Binaries &binaries, VECTOR_CLASS< cl_int > *binaryStatus=NULL, cl_int *err=NULL)
Definition: cl.hpp:2672
string(const string &rhs)
Definition: cl.hpp:404
cl_int getObjectInfo(cl_gl_object_type *type, GLuint *gl_object_name)
Definition: cl.hpp:2082
Image3DGL(const Image3DGL &image)
Definition: cl.hpp:2361
string & operator=(const string &rhs)
Definition: cl.hpp:380
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueWaitForEvents(cl_command_queue, cl_uint, const cl_event *) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
CL_API_ENTRY cl_int CL_API_CALL clGetContextInfo(cl_context, cl_context_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
#define CL_SUCCESS
Definition: cl.h:163
static cl_int retain(cl_program program)
Definition: cl.hpp:1134
Image2DGL(const Context &context, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj, cl_int *err=NULL)
Definition: cl.hpp:2204
BufferGL(const Context &context, cl_mem_flags flags, GLuint bufobj, cl_int *err=NULL)
Definition: cl.hpp:1988
cl_uint cl_d3d10_device_set_khr
Definition: cl_d3d10.h:47
GLclampf f
Definition: glew.h:3499
cl_bitfield cl_device_type
Definition: cl.h:53
Buffer()
Definition: cl.hpp:1884
#define VECTOR_CLASS
Definition: cl.hpp:431
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
const T & back(void) const
Definition: cl.hpp:683
CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImageToBuffer(cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *, size_t, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
cl_int enqueueWriteImage(const Image &image, cl_bool blocking, const size_t< 3 > &origin, const size_t< 3 > &region,::size_t row_pitch,::size_t slice_pitch, void *ptr, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3122
#define CL_CALLBACK
Definition: cl.hpp:170
static cl_int retain(cl_mem memory)
Definition: cl.hpp:1116
const Arg0 & arg0_
Definition: cl.hpp:1036
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition: glew.h:5268
CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer(cl_context, cl_mem_flags, cl_GLuint, int *) CL_API_SUFFIX__VERSION_1_0
cl_int enqueueCopyBufferToImage(const Buffer &src, const Image &dst,::size_t src_offset, const size_t< 3 > &dst_origin, const size_t< 3 > &region, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3199
CL_API_ENTRY cl_int CL_API_CALL clReleaseEvent(cl_event) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clFinish(cl_command_queue) CL_API_SUFFIX__VERSION_1_0
static cl_int retain(cl_kernel kernel)
Definition: cl.hpp:1143
CL_API_ENTRY void *CL_API_CALL clEnqueueMapBuffer(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event *, cl_event *, cl_int *) CL_API_SUFFIX__VERSION_1_0
static cl_int get(Functor f, cl_uint name, T *param)
Definition: cl.hpp:704
CL_API_ENTRY cl_int CL_API_CALL clEnqueueUnmapMemObject(cl_command_queue, cl_mem, void *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1678
GLuint buffer
Definition: glew.h:1680
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
Image()
Definition: cl.hpp:2098
#define CL_EXT_SUFFIX__VERSION_1_1
Definition: cl_platform.h:60
CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clRetainCommandQueue(cl_command_queue) CL_API_SUFFIX__VERSION_1_0
Program()
Definition: cl.hpp:2702
struct _cl_kernel * cl_kernel
Definition: cl.h:47
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Definition: cl.hpp:1690
GLuint sampler
Definition: glew.h:3603
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1833
CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *) CL_API_SUFFIX__VERSION_1_0
iterator end(void)
Definition: cl.hpp:663
cl_bitfield cl_command_queue_properties
Definition: cl.h:63
CL_API_ENTRY cl_int CL_API_CALL clGetImageInfo(cl_mem, cl_image_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
Image2D()
Definition: cl.hpp:2177
GLuint GLuint end
Definition: glew.h:1253
T & operator[](int index)
Definition: cl.hpp:555
GLsizei n
Definition: glew.h:4040
cl_int enqueueBarrier() const
Definition: cl.hpp:3536
GLenum GLenum dst
Definition: glew.h:2410
BufferRenderGL(const BufferGL &buffer)
Definition: cl.hpp:2064
cl_int operator()(cl_uint param,::size_t size, void *value,::size_t *size_ret)
Definition: cl.hpp:1046
std::string STRING_CLASS
Definition: cl.hpp:424
void operator--()
Definition: cl.hpp:642
static cl_int release(cl_platform_id)
Definition: cl.hpp:1091
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Definition: cl.hpp:2129
~vector()
Definition: cl.hpp:457
BufferRenderGL(const Context &context, cl_mem_flags flags, GLuint bufobj, cl_int *err=NULL)
Definition: cl.hpp:2043
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the queue
Definition: thread.h:643
#define CL_PROGRAM_BINARY_SIZES
Definition: cl.h:643
GLsizei const GLchar *const * strings
Definition: glew.h:5883
cl_uint cl_event_info
Definition: cl.h:115
Platform(const cl_platform_id &platform)
Definition: cl.hpp:1353
Sampler(const cl_sampler &sampler)
Definition: cl.hpp:2411
CL_API_ENTRY cl_int CL_API_CALL clCreateSubDevicesEXT(cl_device_id, const cl_device_partition_property_ext *, cl_uint, cl_device_id *, cl_uint *) CL_EXT_SUFFIX__VERSION_1_1
Image2D(const Image2D &image2D)
Definition: cl.hpp:2179
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define CL_INVALID_PLATFORM
Definition: cl.h:190
cl_channel_order image_channel_order
Definition: cl.h:124
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_sampler CL_API_CALL clCreateSampler(cl_context, cl_bool, cl_addressing_mode, cl_filter_mode, cl_int *) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
Device(const cl_device_id &device)
Definition: cl.hpp:1270
Image2DGL(const cl_mem &image)
Definition: cl.hpp:2241
cl_int getWorkGroupInfo(const Device &device, cl_kernel_work_group_info name, T *param) const
Definition: cl.hpp:2583
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_command_queue CL_API_CALL clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int *) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
Sampler(const Sampler &sampler)
Definition: cl.hpp:2409
#define CL_DEVICE_GPU_OVERLAP_NV
Definition: cl_ext.h:227
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateFromGLTexture2D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int *) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseGLObjects(cl_command_queue, cl_uint, const cl_mem *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
struct _cl_mem * cl_mem
Definition: cl.h:45
cl_int enqueueMarker(Event *event=NULL) const
Definition: cl.hpp:3400
Image3DGL(const cl_mem &image)
Definition: cl.hpp:2363
CL_API_ENTRY cl_int CL_API_CALL clSetKernelArg(cl_kernel, cl_uint, size_t, const void *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clGetPlatformIDs(cl_uint, cl_platform_id *, cl_uint *) CL_API_SUFFIX__VERSION_1_0
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
cl_int enqueueNDRangeKernel(const Kernel &kernel, const NDRange &offset, const NDRange &global, const NDRange &local, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3299
cl_uint cl_mem_info
Definition: cl.h:82
static void * ptr(LocalSpaceArg &)
Definition: cl.hpp:2518
unsigned int size(void) const
Definition: cl.hpp:459
BufferGL(const cl_mem &buffer)
Definition: cl.hpp:2011
CL_API_ENTRY cl_context CL_API_CALL clCreateContext(const cl_context_properties *, cl_uint, const cl_device_id *, void(CL_CALLBACK *)(const char *, const void *, size_t, void *), void *, cl_int *) CL_API_SUFFIX__VERSION_1_0
NDRange()
Definition: cl.hpp:2465
detail::param_traits< detail::cl_kernel_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2571
GLuint start
Definition: glew.h:1253
VECTOR_CLASS< std::pair< const char *,::size_t > > Sources
Definition: cl.hpp:2645
CL_API_ENTRY cl_int CL_API_CALL clRetainKernel(cl_kernel) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clRetainSampler(cl_sampler) CL_API_SUFFIX__VERSION_1_0
Fixed sized vector implementation that mirroring std::vector functionality.
Definition: cl.hpp:445
Platform interface.
Definition: cl.hpp:1344
GLsizei GLenum GLuint GLuint GLsizei * lengths
Definition: glew.h:2581
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int CL_API_CALL clEnqueueTask(cl_command_queue, cl_kernel, cl_uint, const cl_event *, cl_event *) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
struct _cl_sampler * cl_sampler
Definition: cl.h:49
Context(const Context &context)
Definition: cl.hpp:1566
Buffer(const cl_mem &buffer)
Definition: cl.hpp:1888
#define __PARAM_NAME_INFO_1_0(F)
Definition: cl.hpp:818
Program(const Program &program)
Definition: cl.hpp:2704
cl_type operator()() const
Definition: cl.hpp:1198
cl_int enqueueNativeKernel(void(CL_CALLBACK *userFptr)(void *), std::pair< void *,::size_t > args, const VECTOR_CLASS< Memory > *mem_objects=NULL, const VECTOR_CLASS< const void * > *mem_locs=NULL, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3345
Memory(const cl_mem &memory)
Definition: cl.hpp:1807
CL_API_ENTRY cl_int CL_API_CALL clGetSupportedImageFormats(cl_context, cl_mem_flags, cl_mem_object_type, cl_uint, cl_image_format *, cl_uint *) CL_API_SUFFIX__VERSION_1_0
Image2DGL(const Image2DGL &image)
Definition: cl.hpp:2239
CL_API_ENTRY cl_int CL_API_CALL clGetPlatformInfo(cl_platform_id, cl_platform_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clGetSamplerInfo(cl_sampler, cl_sampler_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
CL_API_ENTRY cl_int CL_API_CALL clGetProgramInfo(cl_program, cl_program_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
#define CL_DEVICE_WARP_SIZE_NV
Definition: cl_ext.h:226
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2437
Platform(const Platform &platform)
Definition: cl.hpp:1351
CL_API_ENTRY cl_int CL_API_CALL clFlush(cl_command_queue) CL_API_SUFFIX__VERSION_1_0
GLsizei const GLchar *const * string
Definition: glew.h:1844
cl_int wait() const
Definition: cl.hpp:1710
Error
Definition: oidn.hpp:306
cl_event event
Definition: glew.h:3695
#define __INIT_CL_EXT_FCN_PTR(name)
Definition: cl.hpp:196
CommandQueue interface for cl_command_queue.
Definition: cl.hpp:2842
cl_int getInfo(Func f, cl_uint name, T *param)
Definition: cl.hpp:1028
cl_int getInfo(Func f, const Arg0 &arg0, const Arg1 &arg1, cl_uint name, T *param)
Definition: cl.hpp:1062
Context(const cl_context &context)
Definition: cl.hpp:1568
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=NULL)
Definition: cl.hpp:2388
unsigned int max_size(void) const
Definition: cl.hpp:545
const char * c_str(void) const
Definition: cl.hpp:419
vector< T, N > & operator=(const vector< T, N > &rhs)
Definition: cl.hpp:508
cl_uint cl_image_info
Definition: cl.h:86
cl_int enqueueUnmapMemObject(const Memory &memory, void *mapped_ptr, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3278
basic_printf_context_t< buffer >::type context
Definition: printf.h:631
static cl_int release(cl_command_queue queue)
Definition: cl.hpp:1109
ImageFormat(cl_channel_order order, cl_channel_type type)
Definition: cl.hpp:1242
const void * ptr(const T *p)
Definition: format.h:3292
intptr_t cl_context_properties
Definition: cl.h:69
Wrapper(const cl_type &obj)
Definition: cl.hpp:1170
struct _cl_event * cl_event
Definition: cl.h:48
class CE_API KernelFunctor
Definition: cl.hpp:2531
cl_int getObjectInfo(cl_gl_object_type *type, GLuint *gl_object_name)
Definition: cl.hpp:2027
struct _cl_command_queue * cl_command_queue
Definition: cl.h:44
void pop_back(void)
Definition: cl.hpp:479
#define CL_PROGRAM_NUM_DEVICES
Definition: cl.h:640
CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBufferToImage(cl_command_queue, cl_mem, cl_mem, size_t, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
bool operator==(iterator i)
Definition: cl.hpp:620
cl_int createKernels(VECTOR_CLASS< Kernel > *kernels)
Definition: cl.hpp:2784
Event(const Event &event)
Definition: cl.hpp:1650
cl_int operator()(cl_uint param,::size_t size, void *value,::size_t *size_ret)
Definition: cl.hpp:1037
cl_int build(const VECTOR_CLASS< Device > &devices, const char *options=NULL, void(CL_CALLBACK *notifyFptr)(cl_program, void *)=NULL, void *data=NULL) const
Definition: cl.hpp:2722
cl_int getInfo(cl_device_info name, T *param) const
Definition: cl.hpp:1287
CL_API_ENTRY cl_int CL_API_CALL clWaitForEvents(cl_uint, const cl_event *) CL_API_SUFFIX__VERSION_1_0
Image3DGL(const Context &context, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj, cl_int *err=NULL)
Definition: cl.hpp:2326
void assign(I start, I end)
Definition: cl.hpp:566
#define CL_INVALID_DEVICE
Definition: cl.h:191
CL_API_ENTRY cl_int CL_API_CALL clEnqueueNativeKernel(cl_command_queue, void(CL_CALLBACK *)(void *), void *, size_t, cl_uint, const cl_mem *, const void **, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
Sampler interface for cl_sampler.
Definition: cl.hpp:2383
static cl_int retain(cl_event event)
Definition: cl.hpp:1152
CL_API_ENTRY cl_int CL_API_CALL clGetMemObjectInfo(cl_mem, cl_mem_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
Kernel functor interface.
Definition: cl.hpp:3564
detail::param_traits< detail::cl_program_build_info, name >::param_type getBuildInfo(const Device &device, cl_int *err=NULL) const
Definition: cl.hpp:2773
::size_t size(void) const
Definition: cl.hpp:416
cl_int enqueueCopyImageToBuffer(const Image &src, const Buffer &dst, const size_t< 3 > &src_origin, const size_t< 3 > &region,::size_t dst_offset, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3174
Wrapper(const Wrapper< cl_type > &rhs)
Definition: cl.hpp:1177
GA_API const UT_StringHolder N
Base class interface for all images.
Definition: cl.hpp:2095
cl_int retain() const
Definition: cl.hpp:1204
Wrapper< cl_type > & operator=(const Wrapper< cl_type > &rhs)
Definition: cl.hpp:1183
~string()
Definition: cl.hpp:409
cl_int getInfo(cl_context_info name, T *param) const
Definition: cl.hpp:1585
static cl_int release(cl_event event)
Definition: cl.hpp:1154
#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
Definition: cl_ext.h:228
rst::
Definition: OpenColorIO.h:1205
cl_int flush() const
Definition: cl.hpp:3544
Memory buffer interface.
Definition: cl.hpp:1865
CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireGLObjects(cl_command_queue, cl_uint, const cl_mem *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
BufferRenderGL(const cl_mem &buffer)
Definition: cl.hpp:2066
CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteImage(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
NDRange interface.
Definition: cl.hpp:2458
Image interface for 2D images.
Definition: cl.hpp:2144
cl_int enqueueReadBuffer(const Buffer &buffer, cl_bool blocking,::size_t offset,::size_t size, void *ptr, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:2903
NDRange(::size_t size0)
Definition: cl.hpp:2469
const GLuint * ids
Definition: glew.h:1684
CL_API_ENTRY cl_int CL_API_CALL clRetainContext(cl_context) CL_API_SUFFIX__VERSION_1_0
::size_t size(const T &)
Definition: cl.hpp:2510
GLuint GLuint GLuint arg1
Definition: glew.h:8265
GLuint64EXT * result
Definition: glew.h:14007
CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImage(cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
cl_int setArg(cl_uint index, T value)
Definition: cl.hpp:2606
cl_uint cl_kernel_work_group_info
Definition: cl.h:111
cl_int getInfo(cl_kernel_info name, T *param) const
Definition: cl.hpp:2562
Kernel interface that implements cl_kernel.
Definition: cl.hpp:2536
#define CL_API_CALL
Definition: cl_platform.h:44
GLuint program
Definition: glew.h:5881
Event(const cl_event &event)
Definition: cl.hpp:1652
Image interface for 3D images.
Definition: cl.hpp:2261
Memory buffer interface for GL interop with renderbuffer.
Definition: cl.hpp:2040
KernelFunctor bind(const CommandQueue &queue, const NDRange &offset, const NDRange &global, const NDRange &local)
Definition: cl.hpp:3794
if(rank==1) return rank
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Definition: cl.hpp:1699
cl_int enqueueAcquireGLObjects(const VECTOR_CLASS< Memory > *mem_objects=NULL, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3418
struct _cl_program * cl_program
Definition: cl.h:46
NDRange(::size_t size0,::size_t size1)
Definition: cl.hpp:2475
cl_uint cl_kernel_info
Definition: cl.h:104
#define const
Definition: zconf.h:214
CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateFromGLTexture3D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int *) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
#define __CL_DECLARE_PARAM_TRAITS(token, param_name, T)
Definition: cl.hpp:976
Device()
Definition: cl.hpp:1266
void operator++()
Definition: cl.hpp:632
CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBuffer(cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
Definition: cl_ext.h:223
Context()
Definition: cl.hpp:1564
Event operator()(const VECTOR_CLASS< Event > *events=NULL)
Definition: cl.hpp:3835
Device interface for cl_device_id.
Definition: cl.hpp:1263
Event & operator=(const Event &rhs)
Definition: cl.hpp:1654
iterator begin(void)
Definition: cl.hpp:658
#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
Definition: cl_ext.h:236
cl_int enqueueTask(const Kernel &kernel, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3325
BufferGL()
Definition: cl.hpp:2007
bool empty(void) const
Definition: cl.hpp:540
CL_API_ENTRY cl_int CL_API_CALL clReleaseCommandQueue(cl_command_queue) CL_API_SUFFIX__VERSION_1_0
cl_int enqueueReleaseGLObjects(const VECTOR_CLASS< Memory > *mem_objects=NULL, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3440
static cl_int waitForEvents(const VECTOR_CLASS< Event > &events)
Definition: cl.hpp:1734
::size_t dimensions() const
Definition: cl.hpp:2491
::size_t size_
Definition: cl.hpp:2502
Program interface that implements cl_program.
Definition: cl.hpp:2641
detail::param_traits< detail::cl_command_queue_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2892
static T * ptr(T &value)
Definition: cl.hpp:2511
static cl_int retain(cl_platform_id)
Definition: cl.hpp:1088
cl_int getInfo(cl_command_queue_info name, T *param) const
Definition: cl.hpp:2882
GLsizei const GLfloat * value
Definition: glew.h:1849
static cl_int retain(cl_context context)
Definition: cl.hpp:1098
size_t class used to interface between C++ and OpenCL C calls that require arrays of size_t values...
Definition: cl.hpp:695
static cl_int release(cl_device_id)
Definition: cl.hpp:1080
Simple string class, that provides a limited subset of std::string functionality but avoids many of t...
Definition: cl.hpp:343
CL_API_ENTRY cl_int CL_API_CALL clGetKernelInfo(cl_kernel, cl_kernel_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
cl_uint cl_gl_object_type
Definition: cl_gl.h:38
Context(const VECTOR_CLASS< Device > &devices, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *,::size_t, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Definition: cl.hpp:1520
cl_uint cl_bool
Definition: cl.h:51
Memory buffer interface for GL interop.
Definition: cl.hpp:1985
Kernel(const cl_kernel &kernel)
Definition: cl.hpp:2545
2D image interface for GL interop.
Definition: cl.hpp:2201
cl_bitfield cl_mem_flags
Definition: cl.h:77
static iterator begin(vector< T, N > &vec)
Definition: cl.hpp:595
void clear()
Definition: cl.hpp:464
const Arg1 & arg1_
Definition: cl.hpp:1045
static cl_int release(cl_context context)
Definition: cl.hpp:1100
const Arg0 & arg0_
Definition: cl.hpp:1045
Platform()
Definition: cl.hpp:1349
cl_type object_
Definition: cl.hpp:1165
Image2D & operator=(const Image2D &rhs)
Definition: cl.hpp:2183
cl_int enqueueReadImage(const Image &image, cl_bool blocking, const size_t< 3 > &origin, const size_t< 3 > &region,::size_t row_pitch,::size_t slice_pitch, void *ptr, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3095
CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadImage(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
T operator[](int index) const
Definition: cl.hpp:560
Image(const Image &image)
Definition: cl.hpp:2100
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glew.h:1254
void operator++(int x)
Definition: cl.hpp:637
type
Definition: core.h:528
Iterator class for vectors.
Definition: cl.hpp:578
detail::param_traits< detail::cl_platform_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1378
cl_uint cl_profiling_info
Definition: cl.h:117
string(void)
Definition: cl.hpp:349
CL_API_ENTRY cl_int CL_API_CALL clGetKernelWorkGroupInfo(cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *, size_t *) CL_API_SUFFIX__VERSION_1_0
GLintptr offset
Definition: glew.h:1682
CL_API_ENTRY cl_int CL_API_CALL clCreateKernelsInProgram(cl_program, cl_uint, cl_kernel *, cl_uint *) CL_API_SUFFIX__VERSION_1_0