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