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>
426 typedef std::string STRING_CLASS;
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  if (kernels)
2801  {
2802  kernels->resize(numKernels);
2804  object_, numKernels, (cl_kernel*) kernels->data(), NULL);
2805  if (err != CL_SUCCESS) {
2806  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
2807  }
2808  }
2809 
2810  return CL_SUCCESS;
2811  }
2812 };
2813 
2814 template<>
2815 inline VECTOR_CLASS<char *> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const
2816 {
2817  VECTOR_CLASS< ::size_t> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
2818  VECTOR_CLASS<char *> binaries;
2819  for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s)
2820  {
2821  char *ptr = NULL;
2822  if (*s != 0)
2823  ptr = new char[*s];
2824  binaries.push_back(ptr);
2825  }
2826 
2827  cl_int result = getInfo(CL_PROGRAM_BINARIES, &binaries);
2828  if (err != NULL) {
2829  *err = result;
2830  }
2831  return binaries;
2832 }
2833 
2835 
2836 inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
2837 {
2838  cl_int error;
2839 
2840  object_ = ::clCreateKernel(program(), name, &error);
2841  detail::errHandler(error, __CREATE_KERNEL_ERR);
2842 
2843  if (err != NULL) {
2844  *err = error;
2845  }
2846 
2847 }
2848 
2849 /*! \class CommandQueue
2850  * \brief CommandQueue interface for cl_command_queue.
2851  */
2852 class CE_API CommandQueue : public detail::Wrapper<cl_command_queue>
2853 {
2854 public:
2856  const Context& context,
2857  const Device& device,
2858  cl_command_queue_properties properties = 0,
2859  cl_int* err = NULL)
2860  {
2861  cl_int error;
2862  object_ = ::clCreateCommandQueue(
2863  context(), device(), properties, &error);
2864 
2865  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
2866  if (err != NULL) {
2867  *err = error;
2868  }
2869  }
2870 
2872 
2873  CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
2874 
2875  CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
2876 
2878  {
2879  if (this != &rhs) {
2881  }
2882  return *this;
2883  }
2884 
2886  {
2888  return *this;
2889  }
2890 
2891  template <typename T>
2893  {
2894  return detail::errHandler(
2896  &::clGetCommandQueueInfo, object_, name, param),
2897  __GET_COMMAND_QUEUE_INFO_ERR);
2898  }
2899 
2900  template <cl_int name> typename
2902  getInfo(cl_int* err = NULL) const
2903  {
2904  typename detail::param_traits<
2906  cl_int result = getInfo(name, &param);
2907  if (err != NULL) {
2908  *err = result;
2909  }
2910  return param;
2911  }
2912 
2914  const Buffer& buffer,
2915  cl_bool blocking,
2916  ::size_t offset,
2917  ::size_t size,
2918  void* ptr,
2919  const VECTOR_CLASS<Event>* events = NULL,
2920  Event* event = NULL) const
2921  {
2922  cl_event tmp;
2923  cl_int err = detail::errHandler(
2925  object_, buffer(), blocking, offset, size,
2926  ptr,
2927  (events != NULL) ? (cl_uint) events->size() : 0,
2928  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2929  (event != NULL) ? &tmp : NULL),
2930  __ENQUEUE_READ_BUFFER_ERR);
2931 
2932  if (event != NULL && err == CL_SUCCESS)
2933  *event = tmp;
2934 
2935  return err;
2936  }
2937 
2939  const Buffer& buffer,
2940  cl_bool blocking,
2941  ::size_t offset,
2942  ::size_t size,
2943  const void* ptr,
2944  const VECTOR_CLASS<Event>* events = NULL,
2945  Event* event = NULL) const
2946  {
2947  cl_event tmp;
2948  cl_int err = detail::errHandler(
2950  object_, buffer(), blocking, offset, size,
2951  ptr,
2952  (events != NULL) ? (cl_uint) events->size() : 0,
2953  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2954  (event != NULL) ? &tmp : NULL),
2955  __ENQUEUE_WRITE_BUFFER_ERR);
2956 
2957  if (event != NULL && err == CL_SUCCESS)
2958  *event = tmp;
2959 
2960  return err;
2961  }
2962 
2964  const Buffer& src,
2965  const Buffer& dst,
2966  ::size_t src_offset,
2967  ::size_t dst_offset,
2968  ::size_t size,
2969  const VECTOR_CLASS<Event>* events = NULL,
2970  Event* event = NULL) const
2971  {
2972  cl_event tmp;
2973  cl_int err = detail::errHandler(
2975  object_, src(), dst(), src_offset, dst_offset, size,
2976  (events != NULL) ? (cl_uint) events->size() : 0,
2977  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2978  (event != NULL) ? &tmp : NULL),
2979  __ENQEUE_COPY_BUFFER_ERR);
2980 
2981  if (event != NULL && err == CL_SUCCESS)
2982  *event = tmp;
2983 
2984  return err;
2985  }
2986 
2987 #if defined(CL_VERSION_1_1)
2988  cl_int enqueueReadBufferRect(
2989  const Buffer& buffer,
2990  cl_bool blocking,
2991  const size_t<3>& buffer_offset,
2992  const size_t<3>& host_offset,
2993  const size_t<3>& region,
2994  ::size_t buffer_row_pitch,
2995  ::size_t buffer_slice_pitch,
2996  ::size_t host_row_pitch,
2997  ::size_t host_slice_pitch,
2998  void *ptr,
2999  const VECTOR_CLASS<Event>* events = NULL,
3000  Event* event = NULL) const
3001  {
3002  cl_event tmp;
3003  cl_int err = detail::errHandler(
3004  ::clEnqueueReadBufferRect(
3005  object_,
3006  buffer(),
3007  blocking,
3008  (const ::size_t *)buffer_offset,
3009  (const ::size_t *)host_offset,
3010  (const ::size_t *)region,
3011  buffer_row_pitch,
3012  buffer_slice_pitch,
3013  host_row_pitch,
3014  host_slice_pitch,
3015  ptr,
3016  (events != NULL) ? (cl_uint) events->size() : 0,
3017  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3018  (event != NULL) ? &tmp : NULL),
3019  __ENQUEUE_READ_BUFFER_RECT_ERR);
3020 
3021  if (event != NULL && err == CL_SUCCESS)
3022  *event = tmp;
3023 
3024  return err;
3025  }
3026 
3027 
3028  cl_int enqueueWriteBufferRect(
3029  const Buffer& buffer,
3030  cl_bool blocking,
3031  const size_t<3>& buffer_offset,
3032  const size_t<3>& host_offset,
3033  const size_t<3>& region,
3034  ::size_t buffer_row_pitch,
3035  ::size_t buffer_slice_pitch,
3036  ::size_t host_row_pitch,
3037  ::size_t host_slice_pitch,
3038  void *ptr,
3039  const VECTOR_CLASS<Event>* events = NULL,
3040  Event* event = NULL) const
3041  {
3042  cl_event tmp;
3043  cl_int err = detail::errHandler(
3044  ::clEnqueueWriteBufferRect(
3045  object_,
3046  buffer(),
3047  blocking,
3048  (const ::size_t *)buffer_offset,
3049  (const ::size_t *)host_offset,
3050  (const ::size_t *)region,
3051  buffer_row_pitch,
3052  buffer_slice_pitch,
3053  host_row_pitch,
3054  host_slice_pitch,
3055  ptr,
3056  (events != NULL) ? (cl_uint) events->size() : 0,
3057  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3058  (event != NULL) ? &tmp : NULL),
3059  __ENQUEUE_WRITE_BUFFER_RECT_ERR);
3060 
3061  if (event != NULL && err == CL_SUCCESS)
3062  *event = tmp;
3063 
3064  return err;
3065  }
3066 
3067  cl_int enqueueCopyBufferRect(
3068  const Buffer& src,
3069  const Buffer& dst,
3070  const size_t<3>& src_origin,
3071  const size_t<3>& dst_origin,
3072  const size_t<3>& region,
3073  ::size_t src_row_pitch,
3074  ::size_t src_slice_pitch,
3075  ::size_t dst_row_pitch,
3076  ::size_t dst_slice_pitch,
3077  const VECTOR_CLASS<Event>* events = NULL,
3078  Event* event = NULL) const
3079  {
3080  cl_event tmp;
3081  cl_int err = detail::errHandler(
3082  ::clEnqueueCopyBufferRect(
3083  object_,
3084  src(),
3085  dst(),
3086  (const ::size_t *)src_origin,
3087  (const ::size_t *)dst_origin,
3088  (const ::size_t *)region,
3089  src_row_pitch,
3090  src_slice_pitch,
3091  dst_row_pitch,
3092  dst_slice_pitch,
3093  (events != NULL) ? (cl_uint) events->size() : 0,
3094  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3095  (event != NULL) ? &tmp : NULL),
3096  __ENQEUE_COPY_BUFFER_RECT_ERR);
3097 
3098  if (event != NULL && err == CL_SUCCESS)
3099  *event = tmp;
3100 
3101  return err;
3102  }
3103 #endif
3104 
3106  const Image& image,
3107  cl_bool blocking,
3108  const size_t<3>& origin,
3109  const size_t<3>& region,
3110  ::size_t row_pitch,
3111  ::size_t slice_pitch,
3112  void* ptr,
3113  const VECTOR_CLASS<Event>* events = NULL,
3114  Event* event = NULL) const
3115  {
3116  cl_event tmp;
3117  cl_int err = detail::errHandler(
3119  object_, image(), blocking, (const ::size_t *) origin,
3120  (const ::size_t *) region, row_pitch, slice_pitch, ptr,
3121  (events != NULL) ? (cl_uint) events->size() : 0,
3122  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3123  (event != NULL) ? &tmp : NULL),
3124  __ENQUEUE_READ_IMAGE_ERR);
3125 
3126  if (event != NULL && err == CL_SUCCESS)
3127  *event = tmp;
3128 
3129  return err;
3130  }
3131 
3133  const Image& image,
3134  cl_bool blocking,
3135  const size_t<3>& origin,
3136  const size_t<3>& region,
3137  ::size_t row_pitch,
3138  ::size_t slice_pitch,
3139  void* ptr,
3140  const VECTOR_CLASS<Event>* events = NULL,
3141  Event* event = NULL) const
3142  {
3143  cl_event tmp;
3144  cl_int err = detail::errHandler(
3146  object_, image(), blocking, (const ::size_t *) origin,
3147  (const ::size_t *) region, row_pitch, slice_pitch, ptr,
3148  (events != NULL) ? (cl_uint) events->size() : 0,
3149  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3150  (event != NULL) ? &tmp : NULL),
3151  __ENQUEUE_WRITE_IMAGE_ERR);
3152 
3153  if (event != NULL && err == CL_SUCCESS)
3154  *event = tmp;
3155 
3156  return err;
3157  }
3158 
3160  const Image& src,
3161  const Image& dst,
3162  const size_t<3>& src_origin,
3163  const size_t<3>& dst_origin,
3164  const size_t<3>& region,
3165  const VECTOR_CLASS<Event>* events = NULL,
3166  Event* event = NULL) const
3167  {
3168  cl_event tmp;
3169  cl_int err = detail::errHandler(
3171  object_, src(), dst(), (const ::size_t *) src_origin,
3172  (const ::size_t *)dst_origin, (const ::size_t *) region,
3173  (events != NULL) ? (cl_uint) events->size() : 0,
3174  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3175  (event != NULL) ? &tmp : NULL),
3176  __ENQUEUE_COPY_IMAGE_ERR);
3177 
3178  if (event != NULL && err == CL_SUCCESS)
3179  *event = tmp;
3180 
3181  return err;
3182  }
3183 
3185  const Image& src,
3186  const Buffer& dst,
3187  const size_t<3>& src_origin,
3188  const size_t<3>& region,
3189  ::size_t dst_offset,
3190  const VECTOR_CLASS<Event>* events = NULL,
3191  Event* event = NULL) const
3192  {
3193  cl_event tmp;
3194  cl_int err = detail::errHandler(
3196  object_, src(), dst(), (const ::size_t *) src_origin,
3197  (const ::size_t *) region, dst_offset,
3198  (events != NULL) ? (cl_uint) events->size() : 0,
3199  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3200  (event != NULL) ? &tmp : NULL),
3201  __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
3202 
3203  if (event != NULL && err == CL_SUCCESS)
3204  *event = tmp;
3205 
3206  return err;
3207  }
3208 
3210  const Buffer& src,
3211  const Image& dst,
3212  ::size_t src_offset,
3213  const size_t<3>& dst_origin,
3214  const size_t<3>& region,
3215  const VECTOR_CLASS<Event>* events = NULL,
3216  Event* event = NULL) const
3217  {
3218  cl_event tmp;
3219  cl_int err = detail::errHandler(
3221  object_, src(), dst(), src_offset,
3222  (const ::size_t *) dst_origin, (const ::size_t *) region,
3223  (events != NULL) ? (cl_uint) events->size() : 0,
3224  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3225  (event != NULL) ? &tmp : NULL),
3226  __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
3227 
3228  if (event != NULL && err == CL_SUCCESS)
3229  *event = tmp;
3230 
3231  return err;
3232  }
3233 
3235  const Buffer& buffer,
3236  cl_bool blocking,
3237  cl_map_flags flags,
3238  ::size_t offset,
3239  ::size_t size,
3240  const VECTOR_CLASS<Event>* events = NULL,
3241  Event* event = NULL,
3242  cl_int* err = NULL) const
3243  {
3244  cl_int error;
3245  void * result = ::clEnqueueMapBuffer(
3246  object_, buffer(), blocking, flags, offset, size,
3247  (events != NULL) ? (cl_uint) events->size() : 0,
3248  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3249  (cl_event*) event,
3250  &error);
3251 
3252  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
3253  if (err != NULL) {
3254  *err = error;
3255  }
3256  return result;
3257  }
3258 
3260  const Image& buffer,
3261  cl_bool blocking,
3262  cl_map_flags flags,
3263  const size_t<3>& origin,
3264  const size_t<3>& region,
3265  ::size_t * row_pitch,
3266  ::size_t * slice_pitch,
3267  const VECTOR_CLASS<Event>* events = NULL,
3268  Event* event = NULL,
3269  cl_int* err = NULL) const
3270  {
3271  cl_int error;
3272  void * result = ::clEnqueueMapImage(
3273  object_, buffer(), blocking, flags,
3274  (const ::size_t *) origin, (const ::size_t *) region,
3275  row_pitch, slice_pitch,
3276  (events != NULL) ? (cl_uint) events->size() : 0,
3277  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3278  (cl_event*) event,
3279  &error);
3280 
3281  detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
3282  if (err != NULL) {
3283  *err = error;
3284  }
3285  return result;
3286  }
3287 
3289  const Memory& memory,
3290  void* mapped_ptr,
3291  const VECTOR_CLASS<Event>* events = NULL,
3292  Event* event = NULL) const
3293  {
3294  cl_event tmp;
3295  cl_int err = detail::errHandler(
3297  object_, memory(), mapped_ptr,
3298  (events != NULL) ? (cl_uint) events->size() : 0,
3299  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3300  (event != NULL) ? &tmp : NULL),
3301  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
3302 
3303  if (event != NULL && err == CL_SUCCESS)
3304  *event = tmp;
3305 
3306  return err;
3307  }
3308 
3310  const Kernel& kernel,
3311  const NDRange& offset,
3312  const NDRange& global,
3313  const NDRange& local,
3314  const VECTOR_CLASS<Event>* events = NULL,
3315  Event* event = NULL) const
3316  {
3317  cl_event tmp;
3318  cl_int err = detail::errHandler(
3320  object_, kernel(), (cl_uint) global.dimensions(),
3321  offset.dimensions() != 0 ? (const ::size_t*) offset : NULL,
3322  (const ::size_t*) global,
3323  local.dimensions() != 0 ? (const ::size_t*) local : NULL,
3324  (events != NULL) ? (cl_uint) events->size() : 0,
3325  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3326  (event != NULL) ? &tmp : NULL),
3327  __ENQUEUE_NDRANGE_KERNEL_ERR);
3328 
3329  if (event != NULL && err == CL_SUCCESS)
3330  *event = tmp;
3331 
3332  return err;
3333  }
3334 
3336  const Kernel& kernel,
3337  const VECTOR_CLASS<Event>* events = NULL,
3338  Event* event = NULL) const
3339  {
3340  cl_event tmp;
3341  cl_int err = detail::errHandler(
3342  ::clEnqueueTask(
3343  object_, kernel(),
3344  (events != NULL) ? (cl_uint) events->size() : 0,
3345  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3346  (event != NULL) ? &tmp : NULL),
3347  __ENQUEUE_TASK_ERR);
3348 
3349  if (event != NULL && err == CL_SUCCESS)
3350  *event = tmp;
3351 
3352  return err;
3353  }
3354 
3356  // Our windows API doesn't have the __stdcall for the user pointer
3357  // so we have to change the definition here.
3358 #ifdef _WIN32
3359  void (*userFptr)(void *),
3360 #else
3361  void (CL_CALLBACK *userFptr)(void *),
3362 #endif
3363  std::pair<void*, ::size_t> args,
3364  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3365  const VECTOR_CLASS<const void*>* mem_locs = NULL,
3366  const VECTOR_CLASS<Event>* events = NULL,
3367  Event* event = NULL) const
3368  {
3369  cl_mem * mems = (mem_objects != NULL && mem_objects->size() > 0)
3370  ? (cl_mem*) alloca(mem_objects->size() * sizeof(cl_mem))
3371  : NULL;
3372 
3373  if (mems != NULL) {
3374  for (unsigned int i = 0; i < mem_objects->size(); i++) {
3375  mems[i] = ((*mem_objects)[i])();
3376  }
3377  }
3378 
3379  cl_event tmp;
3380  cl_int err = detail::errHandler(
3382  object_, userFptr, args.first, args.second,
3383  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3384  mems,
3385  (mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL,
3386  (events != NULL) ? (cl_uint) events->size() : 0,
3387  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3388  (event != NULL) ? &tmp : NULL),
3389  __ENQUEUE_NATIVE_KERNEL);
3390 
3391  if (event != NULL && err == CL_SUCCESS)
3392  *event = tmp;
3393 
3394  return err;
3395  }
3396 
3397 #if defined(CL_VERSION_1_2)
3398  cl_int enqueueMarkerWithWaitList(
3399  const VECTOR_CLASS<Event>& events, Event* event = NULL) const
3400  {
3401  return detail::errHandler(
3402  ::clEnqueueMarkerWithWaitList(
3403  object_,
3404  (cl_uint) events.size(),
3405  (const cl_event*) &events.front(),
3406  (cl_event *)event),
3407  __ENQUEUE_MARKER_WITH_WAIT_LIST_ERR);
3408  }
3409 #else
3411  {
3412  return detail::errHandler(
3413  ::clEnqueueMarker(object_, (cl_event*) event),
3414  __ENQUEUE_MARKER_ERR);
3415  }
3416 
3417  cl_int enqueueWaitForEvents(const VECTOR_CLASS<Event>& events) const
3418  {
3419  return detail::errHandler(
3421  object_,
3422  (cl_uint) events.size(),
3423  (const cl_event*) &events.front()),
3424  __ENQUEUE_WAIT_FOR_EVENTS_ERR);
3425  }
3426 #endif
3427 
3429  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3430  const VECTOR_CLASS<Event>* events = NULL,
3431  Event* event = NULL) const
3432  {
3433  cl_event tmp;
3434  cl_int err = detail::errHandler(
3436  object_,
3437  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3438  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3439  (events != NULL) ? (cl_uint) events->size() : 0,
3440  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3441  (event != NULL) ? &tmp : NULL),
3442  __ENQUEUE_ACQUIRE_GL_ERR);
3443 
3444  if (event != NULL && err == CL_SUCCESS)
3445  *event = tmp;
3446 
3447  return err;
3448  }
3449 
3451  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3452  const VECTOR_CLASS<Event>* events = NULL,
3453  Event* event = NULL) const
3454  {
3455  cl_event tmp;
3456  cl_int err = detail::errHandler(
3458  object_,
3459  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3460  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3461  (events != NULL) ? (cl_uint) events->size() : 0,
3462  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3463  (event != NULL) ? &tmp : NULL),
3464  __ENQUEUE_RELEASE_GL_ERR);
3465 
3466  if (event != NULL && err == CL_SUCCESS)
3467  *event = tmp;
3468 
3469  return err;
3470  }
3471 
3472 #if defined (USE_DX_INTEROP)
3473 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
3474  cl_command_queue command_queue, cl_uint num_objects,
3475  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
3476  const cl_event* event_wait_list, cl_event* event);
3477 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
3478  cl_command_queue command_queue, cl_uint num_objects,
3479  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
3480  const cl_event* event_wait_list, cl_event* event);
3481 
3482  cl_int enqueueAcquireD3D10Objects(
3483  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3484  const VECTOR_CLASS<Event>* events = NULL,
3485  Event* event = NULL) const
3486  {
3487  static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
3488  __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR);
3489 
3490  cl_event tmp;
3491  cl_int err = detail::errHandler(
3492  pfn_clEnqueueAcquireD3D10ObjectsKHR(
3493  object_,
3494  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3495  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3496  (events != NULL) ? (cl_uint) events->size() : 0,
3497  (events != NULL) ? (cl_event*) &events->front() : NULL,
3498  (event != NULL) ? &tmp : NULL),
3499  __ENQUEUE_ACQUIRE_GL_ERR);
3500 
3501  if (event != NULL && err == CL_SUCCESS)
3502  *event = tmp;
3503 
3504  return err;
3505  }
3506 
3507  cl_int enqueueReleaseD3D10Objects(
3508  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3509  const VECTOR_CLASS<Event>* events = NULL,
3510  Event* event = NULL) const
3511  {
3512  static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
3513  __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR);
3514 
3515  cl_event tmp;
3516  cl_int err = detail::errHandler(
3517  pfn_clEnqueueReleaseD3D10ObjectsKHR(
3518  object_,
3519  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3520  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3521  (events != NULL) ? (cl_uint) events->size() : 0,
3522  (events != NULL) ? (cl_event*) &events->front() : NULL,
3523  (event != NULL) ? &tmp : NULL),
3524  __ENQUEUE_RELEASE_GL_ERR);
3525 
3526  if (event != NULL && err == CL_SUCCESS)
3527  *event = tmp;
3528 
3529  return err;
3530  }
3531 #endif
3532 
3533 #if defined(CL_VERSION_1_2)
3534  cl_int enqueueBarrierWithWaitList(
3535  const VECTOR_CLASS<Event>& events, Event* event = NULL) const
3536  {
3537  return detail::errHandler(
3538  ::clEnqueueBarrierWithWaitList(
3539  object_,
3540  (cl_uint) events.size(),
3541  (const cl_event*) &events.front(),
3542  (cl_event *)event),
3543  __ENQUEUE_BARRIER_ERR);
3544  }
3545 #else
3547  {
3548  return detail::errHandler(
3549  ::clEnqueueBarrier(object_),
3550  __ENQUEUE_BARRIER_ERR);
3551  }
3552 #endif
3553 
3554  cl_int flush() const
3555  {
3556  return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
3557  }
3558 
3559  cl_int finish() const
3560  {
3561  return detail::errHandler(::clFinish(object_), __FINISH_ERR);
3562  }
3563 };
3564 
3566 
3567 } // namespace cl
3568 
3569 // This function is defined in CE_Context.C. It lets us control kernel enqueues
3570 // from the functor versions, including tracing and skipping event overhead
3571 // when not tracing.
3572 CE_API cl_int
3573 ce_enqueueKernel(const cl::CommandQueue& queue, const cl::Kernel &kernel,
3574  const cl::NDRange &offset, const cl::NDRange &global, const cl::NDRange &local,
3575  const std::vector<cl::Event>* events,
3576  cl::Event* event);
3577 
3578 namespace cl
3579 {
3580 /*! \class KernelFunctor
3581  * \brief Kernel functor interface
3582  *
3583  * \note Currently only functors of zero to ten arguments are supported. It
3584  * is straightforward to add more and a more general solution, similar to
3585  * Boost.Lambda could be followed if required in the future.
3586  */
3588 {
3589 private:
3590  Kernel kernel_;
3591  CommandQueue queue_;
3592  NDRange offset_;
3593  NDRange global_;
3594  NDRange local_;
3595 
3596  cl_int err_;
3597 public:
3599 
3601  const Kernel& kernel,
3602  const CommandQueue& queue,
3603  const NDRange& offset,
3604  const NDRange& global,
3605  const NDRange& local) :
3606  kernel_(kernel),
3607  queue_(queue),
3608  offset_(offset),
3609  global_(global),
3610  local_(local),
3611  err_(CL_SUCCESS)
3612  {}
3613 
3614  KernelFunctor& operator=(const KernelFunctor& rhs);
3615 
3616  KernelFunctor(const KernelFunctor& rhs);
3617 
3618  cl_int getError() { return err_; }
3619 
3620  inline Event operator()(const VECTOR_CLASS<Event>* events = NULL);
3621 
3622  template<typename A1>
3623  inline Event operator()(
3624  const A1& a1,
3625  const VECTOR_CLASS<Event>* events = NULL);
3626 
3627  template<class A1, class A2>
3628  inline Event operator()(
3629  const A1& a1,
3630  const A2& a2,
3631  const VECTOR_CLASS<Event>* events = NULL);
3632 
3633  template<class A1, class A2, class A3>
3634  inline Event operator()(
3635  const A1& a1,
3636  const A2& a2,
3637  const A3& a3,
3638  const VECTOR_CLASS<Event>* events = NULL);
3639 
3640  template<class A1, class A2, class A3, class A4>
3641  inline Event operator()(
3642  const A1& a1,
3643  const A2& a2,
3644  const A3& a3,
3645  const A4& a4,
3646  const VECTOR_CLASS<Event>* events = NULL);
3647 
3648  template<class A1, class A2, class A3, class A4, class A5>
3649  inline Event operator()(
3650  const A1& a1,
3651  const A2& a2,
3652  const A3& a3,
3653  const A4& a4,
3654  const A5& a5,
3655  const VECTOR_CLASS<Event>* events = NULL);
3656 
3657  template<class A1, class A2, class A3, class A4, class A5, class A6>
3658  inline Event operator()(
3659  const A1& a1,
3660  const A2& a2,
3661  const A3& a3,
3662  const A4& a4,
3663  const A5& a5,
3664  const A6& a6,
3665  const VECTOR_CLASS<Event>* events = NULL);
3666 
3667  template<class A1, class A2, class A3, class A4,
3668  class A5, class A6, class A7>
3669  inline Event operator()(
3670  const A1& a1,
3671  const A2& a2,
3672  const A3& a3,
3673  const A4& a4,
3674  const A5& a5,
3675  const A6& a6,
3676  const A7& a7,
3677  const VECTOR_CLASS<Event>* events = NULL);
3678 
3679  template<class A1, class A2, class A3, class A4, class A5,
3680  class A6, class A7, class A8>
3681  inline Event operator()(
3682  const A1& a1,
3683  const A2& a2,
3684  const A3& a3,
3685  const A4& a4,
3686  const A5& a5,
3687  const A6& a6,
3688  const A7& a7,
3689  const A8& a8,
3690  const VECTOR_CLASS<Event>* events = NULL);
3691 
3692  template<class A1, class A2, class A3, class A4, class A5,
3693  class A6, class A7, class A8, class A9>
3694  inline Event operator()(
3695  const A1& a1,
3696  const A2& a2,
3697  const A3& a3,
3698  const A4& a4,
3699  const A5& a5,
3700  const A6& a6,
3701  const A7& a7,
3702  const A8& a8,
3703  const A9& a9,
3704  const VECTOR_CLASS<Event>* events = NULL);
3705 
3706  template<class A1, class A2, class A3, class A4, class A5,
3707  class A6, class A7, class A8, class A9, class A10>
3708  inline Event operator()(
3709  const A1& a1,
3710  const A2& a2,
3711  const A3& a3,
3712  const A4& a4,
3713  const A5& a5,
3714  const A6& a6,
3715  const A7& a7,
3716  const A8& a8,
3717  const A9& a9,
3718  const A10& a10,
3719  const VECTOR_CLASS<Event>* events = NULL);
3720 
3721  template<class A1, class A2, class A3, class A4, class A5,
3722  class A6, class A7, class A8, class A9, class A10,
3723  class A11>
3724  inline Event operator()(
3725  const A1& a1,
3726  const A2& a2,
3727  const A3& a3,
3728  const A4& a4,
3729  const A5& a5,
3730  const A6& a6,
3731  const A7& a7,
3732  const A8& a8,
3733  const A9& a9,
3734  const A10& a10,
3735  const A11& a11,
3736  const VECTOR_CLASS<Event>* events = NULL);
3737 
3738  template<class A1, class A2, class A3, class A4, class A5,
3739  class A6, class A7, class A8, class A9, class A10,
3740  class A11, class A12>
3741  inline Event operator()(
3742  const A1& a1,
3743  const A2& a2,
3744  const A3& a3,
3745  const A4& a4,
3746  const A5& a5,
3747  const A6& a6,
3748  const A7& a7,
3749  const A8& a8,
3750  const A9& a9,
3751  const A10& a10,
3752  const A11& a11,
3753  const A12& a12,
3754  const VECTOR_CLASS<Event>* events = NULL);
3755 
3756  template<class A1, class A2, class A3, class A4, class A5,
3757  class A6, class A7, class A8, class A9, class A10,
3758  class A11, class A12, class A13>
3759  inline Event operator()(
3760  const A1& a1,
3761  const A2& a2,
3762  const A3& a3,
3763  const A4& a4,
3764  const A5& a5,
3765  const A6& a6,
3766  const A7& a7,
3767  const A8& a8,
3768  const A9& a9,
3769  const A10& a10,
3770  const A11& a11,
3771  const A12& a12,
3772  const A13& a13,
3773  const VECTOR_CLASS<Event>* events = NULL);
3774 
3775  template<class A1, class A2, class A3, class A4, class A5,
3776  class A6, class A7, class A8, class A9, class A10,
3777  class A11, class A12, class A13, class A14>
3778  inline Event operator()(
3779  const A1& a1,
3780  const A2& a2,
3781  const A3& a3,
3782  const A4& a4,
3783  const A5& a5,
3784  const A6& a6,
3785  const A7& a7,
3786  const A8& a8,
3787  const A9& a9,
3788  const A10& a10,
3789  const A11& a11,
3790  const A12& a12,
3791  const A13& a13,
3792  const A14& a14,
3793  const VECTOR_CLASS<Event>* events = NULL);
3794 
3795  template<class A1, class A2, class A3, class A4, class A5,
3796  class A6, class A7, class A8, class A9, class A10,
3797  class A11, class A12, class A13, class A14, class A15>
3798  inline Event operator()(
3799  const A1& a1,
3800  const A2& a2,
3801  const A3& a3,
3802  const A4& a4,
3803  const A5& a5,
3804  const A6& a6,
3805  const A7& a7,
3806  const A8& a8,
3807  const A9& a9,
3808  const A10& a10,
3809  const A11& a11,
3810  const A12& a12,
3811  const A13& a13,
3812  const A14& a14,
3813  const A15& a15,
3814  const VECTOR_CLASS<Event>* events = NULL);
3815 
3816  template<class A1, class A2, class A3, class A4, class A5,
3817  class A6, class A7, class A8, class A9, class A10,
3818  class A11, class A12, class A13, class A14, class A15,
3819  class A16>
3820  inline Event operator()(
3821  const A1& a1,
3822  const A2& a2,
3823  const A3& a3,
3824  const A4& a4,
3825  const A5& a5,
3826  const A6& a6,
3827  const A7& a7,
3828  const A8& a8,
3829  const A9& a9,
3830  const A10& a10,
3831  const A11& a11,
3832  const A12& a12,
3833  const A13& a13,
3834  const A14& a14,
3835  const A15& a15,
3836  const A16& a16,
3837  const VECTOR_CLASS<Event>* events = NULL);
3838 
3839  template<class A1, class A2, class A3, class A4, class A5,
3840  class A6, class A7, class A8, class A9, class A10,
3841  class A11, class A12, class A13, class A14, class A15,
3842  class A16, class A17>
3843  inline Event operator()(
3844  const A1& a1,
3845  const A2& a2,
3846  const A3& a3,
3847  const A4& a4,
3848  const A5& a5,
3849  const A6& a6,
3850  const A7& a7,
3851  const A8& a8,
3852  const A9& a9,
3853  const A10& a10,
3854  const A11& a11,
3855  const A12& a12,
3856  const A13& a13,
3857  const A14& a14,
3858  const A15& a15,
3859  const A16& a16,
3860  const A17& a17,
3861  const VECTOR_CLASS<Event>* events = NULL);
3862 
3863  template<class A1, class A2, class A3, class A4, class A5,
3864  class A6, class A7, class A8, class A9, class A10,
3865  class A11, class A12, class A13, class A14, class A15,
3866  class A16, class A17, class A18>
3867  inline Event operator()(
3868  const A1& a1,
3869  const A2& a2,
3870  const A3& a3,
3871  const A4& a4,
3872  const A5& a5,
3873  const A6& a6,
3874  const A7& a7,
3875  const A8& a8,
3876  const A9& a9,
3877  const A10& a10,
3878  const A11& a11,
3879  const A12& a12,
3880  const A13& a13,
3881  const A14& a14,
3882  const A15& a15,
3883  const A16& a16,
3884  const A17& a17,
3885  const A18& a18,
3886  const VECTOR_CLASS<Event>* events = NULL);
3887 
3888  template<class A1, class A2, class A3, class A4, class A5,
3889  class A6, class A7, class A8, class A9, class A10,
3890  class A11, class A12, class A13, class A14, class A15,
3891  class A16, class A17, class A18, class A19>
3892  inline Event operator()(
3893  const A1& a1,
3894  const A2& a2,
3895  const A3& a3,
3896  const A4& a4,
3897  const A5& a5,
3898  const A6& a6,
3899  const A7& a7,
3900  const A8& a8,
3901  const A9& a9,
3902  const A10& a10,
3903  const A11& a11,
3904  const A12& a12,
3905  const A13& a13,
3906  const A14& a14,
3907  const A15& a15,
3908  const A16& a16,
3909  const A17& a17,
3910  const A18& a18,
3911  const A19& a19,
3912  const VECTOR_CLASS<Event>* events = NULL);
3913 
3914  template<class A1, class A2, class A3, class A4, class A5,
3915  class A6, class A7, class A8, class A9, class A10,
3916  class A11, class A12, class A13, class A14, class A15,
3917  class A16, class A17, class A18, class A19, class A20>
3918  inline Event operator()(
3919  const A1& a1,
3920  const A2& a2,
3921  const A3& a3,
3922  const A4& a4,
3923  const A5& a5,
3924  const A6& a6,
3925  const A7& a7,
3926  const A8& a8,
3927  const A9& a9,
3928  const A10& a10,
3929  const A11& a11,
3930  const A12& a12,
3931  const A13& a13,
3932  const A14& a14,
3933  const A15& a15,
3934  const A16& a16,
3935  const A17& a17,
3936  const A18& a18,
3937  const A19& a19,
3938  const A20& a20,
3939  const VECTOR_CLASS<Event>* events = NULL);
3940 
3941  template<class A1, class A2, class A3, class A4, class A5,
3942  class A6, class A7, class A8, class A9, class A10,
3943  class A11, class A12, class A13, class A14, class A15,
3944  class A16, class A17, class A18, class A19, class A20, class A21>
3945  inline Event operator()(
3946  const A1& a1,
3947  const A2& a2,
3948  const A3& a3,
3949  const A4& a4,
3950  const A5& a5,
3951  const A6& a6,
3952  const A7& a7,
3953  const A8& a8,
3954  const A9& a9,
3955  const A10& a10,
3956  const A11& a11,
3957  const A12& a12,
3958  const A13& a13,
3959  const A14& a14,
3960  const A15& a15,
3961  const A16& a16,
3962  const A17& a17,
3963  const A18& a18,
3964  const A19& a19,
3965  const A20& a20,
3966  const A21& a21,
3967  const VECTOR_CLASS<Event>* events = NULL);
3968 
3969  template<class A1, class A2, class A3, class A4, class A5,
3970  class A6, class A7, class A8, class A9, class A10,
3971  class A11, class A12, class A13, class A14, class A15,
3972  class A16, class A17, class A18, class A19, class A20, class A21, class A22>
3973  inline Event operator()(
3974  const A1& a1,
3975  const A2& a2,
3976  const A3& a3,
3977  const A4& a4,
3978  const A5& a5,
3979  const A6& a6,
3980  const A7& a7,
3981  const A8& a8,
3982  const A9& a9,
3983  const A10& a10,
3984  const A11& a11,
3985  const A12& a12,
3986  const A13& a13,
3987  const A14& a14,
3988  const A15& a15,
3989  const A16& a16,
3990  const A17& a17,
3991  const A18& a18,
3992  const A19& a19,
3993  const A20& a20,
3994  const A21& a21,
3995  const A22& a22,
3996  const VECTOR_CLASS<Event>* events = NULL);
3997 };
3998 
4000  const CommandQueue& queue,
4001  const NDRange& offset,
4002  const NDRange& global,
4003  const NDRange& local)
4004 {
4005  return KernelFunctor(*this,queue,offset,global,local);
4006 }
4007 
4009  const CommandQueue& queue,
4010  const NDRange& global,
4011  const NDRange& local)
4012 {
4013  return KernelFunctor(*this,queue,NullRange,global,local);
4014 }
4015 
4017 {
4018  if (this == &rhs) {
4019  return *this;
4020  }
4021 
4022  kernel_ = rhs.kernel_;
4023  queue_ = rhs.queue_;
4024  offset_ = rhs.offset_;
4025  global_ = rhs.global_;
4026  local_ = rhs.local_;
4027 
4028  return *this;
4029 }
4030 
4032  kernel_(rhs.kernel_),
4033  queue_(rhs.queue_),
4034  offset_(rhs.offset_),
4035  global_(rhs.global_),
4036  local_(rhs.local_)
4037 {
4038 }
4039 
4040 Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* )
4041 {
4042  Event event;
4043 
4044  err_ = ce_enqueueKernel(queue_,
4045  kernel_,
4046  offset_,
4047  global_,
4048  local_,
4049  NULL, // bgaster_fixme - do we want to allow wait event lists?
4050  &event);
4051 
4052  return event;
4053 }
4054 
4055 template<typename A1>
4057  const A1& a1,
4058  const VECTOR_CLASS<Event>* )
4059 {
4060  Event event;
4061 
4062  kernel_.setArg(0,a1);
4063 
4064  err_ = ce_enqueueKernel(queue_,
4065  kernel_,
4066  offset_,
4067  global_,
4068  local_,
4069  NULL, // bgaster_fixme - do we want to allow wait event lists?
4070  &event);
4071 
4072  return event;
4073 }
4074 
4075 template<typename A1, typename A2>
4077  const A1& a1,
4078  const A2& a2,
4079  const VECTOR_CLASS<Event>* )
4080 {
4081  Event event;
4082 
4083  kernel_.setArg(0,a1);
4084  kernel_.setArg(1,a2);
4085 
4086  err_ = ce_enqueueKernel(queue_,
4087  kernel_,
4088  offset_,
4089  global_,
4090  local_,
4091  NULL, // bgaster_fixme - do we want to allow wait event lists?
4092  &event);
4093 
4094  return event;
4095 }
4096 
4097 template<typename A1, typename A2, typename A3>
4099  const A1& a1,
4100  const A2& a2,
4101  const A3& a3,
4102  const VECTOR_CLASS<Event>* )
4103 {
4104  Event event;
4105 
4106  kernel_.setArg(0,a1);
4107  kernel_.setArg(1,a2);
4108  kernel_.setArg(2,a3);
4109 
4110  err_ = ce_enqueueKernel(queue_,
4111  kernel_,
4112  offset_,
4113  global_,
4114  local_,
4115  NULL, // bgaster_fixme - do we want to allow wait event lists?
4116  &event);
4117 
4118  return event;
4119 }
4120 
4121 template<typename A1, typename A2, typename A3, typename A4>
4123  const A1& a1,
4124  const A2& a2,
4125  const A3& a3,
4126  const A4& a4,
4127  const VECTOR_CLASS<Event>* )
4128 {
4129  Event event;
4130 
4131  kernel_.setArg(0,a1);
4132  kernel_.setArg(1,a2);
4133  kernel_.setArg(2,a3);
4134  kernel_.setArg(3,a4);
4135 
4136  err_ = ce_enqueueKernel(queue_,
4137  kernel_,
4138  offset_,
4139  global_,
4140  local_,
4141  NULL, // bgaster_fixme - do we want to allow wait event lists?
4142  &event);
4143 
4144  return event;
4145 }
4146 
4147 template<typename A1, typename A2, typename A3, typename A4, typename A5>
4149  const A1& a1,
4150  const A2& a2,
4151  const A3& a3,
4152  const A4& a4,
4153  const A5& a5,
4154  const VECTOR_CLASS<Event>* )
4155 {
4156  Event event;
4157 
4158  kernel_.setArg(0,a1);
4159  kernel_.setArg(1,a2);
4160  kernel_.setArg(2,a3);
4161  kernel_.setArg(3,a4);
4162  kernel_.setArg(4,a5);
4163 
4164  err_ = ce_enqueueKernel(queue_,
4165  kernel_,
4166  offset_,
4167  global_,
4168  local_,
4169  NULL, // bgaster_fixme - do we want to allow wait event lists?
4170  &event);
4171 
4172  return event;
4173 }
4174 
4175 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4176  typename A6>
4178  const A1& a1,
4179  const A2& a2,
4180  const A3& a3,
4181  const A4& a4,
4182  const A5& a5,
4183  const A6& a6,
4184  const VECTOR_CLASS<Event>* )
4185 {
4186  Event event;
4187 
4188  kernel_.setArg(0,a1);
4189  kernel_.setArg(1,a2);
4190  kernel_.setArg(2,a3);
4191  kernel_.setArg(3,a4);
4192  kernel_.setArg(4,a5);
4193  kernel_.setArg(5,a6);
4194 
4195  err_ = ce_enqueueKernel(queue_,
4196  kernel_,
4197  offset_,
4198  global_,
4199  local_,
4200  NULL, // bgaster_fixme - do we want to allow wait event lists?
4201  &event);
4202 
4203  return event;
4204 }
4205 
4206 template<typename A1, typename A2, typename A3, typename A4,
4207  typename A5, typename A6, typename A7>
4209  const A1& a1,
4210  const A2& a2,
4211  const A3& a3,
4212  const A4& a4,
4213  const A5& a5,
4214  const A6& a6,
4215  const A7& a7,
4216  const VECTOR_CLASS<Event>* )
4217 {
4218  Event event;
4219 
4220  kernel_.setArg(0,a1);
4221  kernel_.setArg(1,a2);
4222  kernel_.setArg(2,a3);
4223  kernel_.setArg(3,a4);
4224  kernel_.setArg(4,a5);
4225  kernel_.setArg(5,a6);
4226  kernel_.setArg(6,a7);
4227 
4228  err_ = ce_enqueueKernel(queue_,
4229  kernel_,
4230  offset_,
4231  global_,
4232  local_,
4233  NULL, // bgaster_fixme - do we want to allow wait event lists?
4234  &event);
4235 
4236  return event;
4237 }
4238 
4239 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4240  typename A6, typename A7, typename A8>
4242  const A1& a1,
4243  const A2& a2,
4244  const A3& a3,
4245  const A4& a4,
4246  const A5& a5,
4247  const A6& a6,
4248  const A7& a7,
4249  const A8& a8,
4250  const VECTOR_CLASS<Event>* )
4251 {
4252  Event event;
4253 
4254  kernel_.setArg(0,a1);
4255  kernel_.setArg(1,a2);
4256  kernel_.setArg(2,a3);
4257  kernel_.setArg(3,a4);
4258  kernel_.setArg(4,a5);
4259  kernel_.setArg(5,a6);
4260  kernel_.setArg(6,a7);
4261  kernel_.setArg(7,a8);
4262 
4263  err_ = ce_enqueueKernel(queue_,
4264  kernel_,
4265  offset_,
4266  global_,
4267  local_,
4268  NULL, // bgaster_fixme - do we want to allow wait event lists?
4269  &event);
4270 
4271  return event;
4272 }
4273 
4274 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4275  typename A6, typename A7, typename A8, typename A9>
4277  const A1& a1,
4278  const A2& a2,
4279  const A3& a3,
4280  const A4& a4,
4281  const A5& a5,
4282  const A6& a6,
4283  const A7& a7,
4284  const A8& a8,
4285  const A9& a9,
4286  const VECTOR_CLASS<Event>* )
4287 {
4288  Event event;
4289 
4290  kernel_.setArg(0,a1);
4291  kernel_.setArg(1,a2);
4292  kernel_.setArg(2,a3);
4293  kernel_.setArg(3,a4);
4294  kernel_.setArg(4,a5);
4295  kernel_.setArg(5,a6);
4296  kernel_.setArg(6,a7);
4297  kernel_.setArg(7,a8);
4298  kernel_.setArg(8,a9);
4299 
4300  err_ = ce_enqueueKernel(queue_,
4301  kernel_,
4302  offset_,
4303  global_,
4304  local_,
4305  NULL, // bgaster_fixme - do we want to allow wait event lists?
4306  &event);
4307 
4308  return event;
4309 }
4310 
4311 template<typename A1, typename A2, typename A3, typename A4, typename A5,
4312  typename A6, typename A7, typename A8, typename A9, typename A10>
4314  const A1& a1,
4315  const A2& a2,
4316  const A3& a3,
4317  const A4& a4,
4318  const A5& a5,
4319  const A6& a6,
4320  const A7& a7,
4321  const A8& a8,
4322  const A9& a9,
4323  const A10& a10,
4324  const VECTOR_CLASS<Event>* )
4325 {
4326  Event event;
4327 
4328  kernel_.setArg(0,a1);
4329  kernel_.setArg(1,a2);
4330  kernel_.setArg(2,a3);
4331  kernel_.setArg(3,a4);
4332  kernel_.setArg(4,a5);
4333  kernel_.setArg(5,a6);
4334  kernel_.setArg(6,a7);
4335  kernel_.setArg(7,a8);
4336  kernel_.setArg(8,a9);
4337  kernel_.setArg(9,a10);
4338 
4339  err_ = ce_enqueueKernel(queue_,
4340  kernel_,
4341  offset_,
4342  global_,
4343  local_,
4344  NULL, // bgaster_fixme - do we want to allow wait event lists?
4345  &event);
4346 
4347  return event;
4348 }
4349 
4350 template<class A1, class A2, class A3, class A4, class A5,
4351  class A6, class A7, class A8, class A9, class A10,
4352  class A11>
4354  const A1& a1,
4355  const A2& a2,
4356  const A3& a3,
4357  const A4& a4,
4358  const A5& a5,
4359  const A6& a6,
4360  const A7& a7,
4361  const A8& a8,
4362  const A9& a9,
4363  const A10& a10,
4364  const A11& a11,
4365  const VECTOR_CLASS<Event>* )
4366 {
4367  Event event;
4368 
4369  kernel_.setArg(0,a1);
4370  kernel_.setArg(1,a2);
4371  kernel_.setArg(2,a3);
4372  kernel_.setArg(3,a4);
4373  kernel_.setArg(4,a5);
4374  kernel_.setArg(5,a6);
4375  kernel_.setArg(6,a7);
4376  kernel_.setArg(7,a8);
4377  kernel_.setArg(8,a9);
4378  kernel_.setArg(9,a10);
4379  kernel_.setArg(10,a11);
4380 
4381  err_ = ce_enqueueKernel(queue_,
4382  kernel_,
4383  offset_,
4384  global_,
4385  local_,
4386  NULL, // bgaster_fixme - do we want to allow wait event lists?
4387  &event);
4388 
4389  return event;
4390 }
4391 
4392 template<class A1, class A2, class A3, class A4, class A5,
4393  class A6, class A7, class A8, class A9, class A10,
4394  class A11, class A12>
4396  const A1& a1,
4397  const A2& a2,
4398  const A3& a3,
4399  const A4& a4,
4400  const A5& a5,
4401  const A6& a6,
4402  const A7& a7,
4403  const A8& a8,
4404  const A9& a9,
4405  const A10& a10,
4406  const A11& a11,
4407  const A12& a12,
4408  const VECTOR_CLASS<Event>* )
4409 {
4410  Event event;
4411 
4412  kernel_.setArg(0,a1);
4413  kernel_.setArg(1,a2);
4414  kernel_.setArg(2,a3);
4415  kernel_.setArg(3,a4);
4416  kernel_.setArg(4,a5);
4417  kernel_.setArg(5,a6);
4418  kernel_.setArg(6,a7);
4419  kernel_.setArg(7,a8);
4420  kernel_.setArg(8,a9);
4421  kernel_.setArg(9,a10);
4422  kernel_.setArg(10,a11);
4423  kernel_.setArg(11,a12);
4424 
4425  err_ = ce_enqueueKernel(queue_,
4426  kernel_,
4427  offset_,
4428  global_,
4429  local_,
4430  NULL, // bgaster_fixme - do we want to allow wait event lists?
4431  &event);
4432 
4433  return event;
4434 }
4435 
4436 template<class A1, class A2, class A3, class A4, class A5,
4437  class A6, class A7, class A8, class A9, class A10,
4438  class A11, class A12, class A13>
4440  const A1& a1,
4441  const A2& a2,
4442  const A3& a3,
4443  const A4& a4,
4444  const A5& a5,
4445  const A6& a6,
4446  const A7& a7,
4447  const A8& a8,
4448  const A9& a9,
4449  const A10& a10,
4450  const A11& a11,
4451  const A12& a12,
4452  const A13& a13,
4453  const VECTOR_CLASS<Event>* )
4454 {
4455  Event event;
4456 
4457  kernel_.setArg(0,a1);
4458  kernel_.setArg(1,a2);
4459  kernel_.setArg(2,a3);
4460  kernel_.setArg(3,a4);
4461  kernel_.setArg(4,a5);
4462  kernel_.setArg(5,a6);
4463  kernel_.setArg(6,a7);
4464  kernel_.setArg(7,a8);
4465  kernel_.setArg(8,a9);
4466  kernel_.setArg(9,a10);
4467  kernel_.setArg(10,a11);
4468  kernel_.setArg(11,a12);
4469  kernel_.setArg(12,a13);
4470 
4471  err_ = ce_enqueueKernel(queue_,
4472  kernel_,
4473  offset_,
4474  global_,
4475  local_,
4476  NULL, // bgaster_fixme - do we want to allow wait event lists?
4477  &event);
4478 
4479  return event;
4480 }
4481 
4482 template<class A1, class A2, class A3, class A4, class A5,
4483  class A6, class A7, class A8, class A9, class A10,
4484  class A11, class A12, class A13, class A14>
4486  const A1& a1,
4487  const A2& a2,
4488  const A3& a3,
4489  const A4& a4,
4490  const A5& a5,
4491  const A6& a6,
4492  const A7& a7,
4493  const A8& a8,
4494  const A9& a9,
4495  const A10& a10,
4496  const A11& a11,
4497  const A12& a12,
4498  const A13& a13,
4499  const A14& a14,
4500  const VECTOR_CLASS<Event>* )
4501 {
4502  Event event;
4503 
4504  kernel_.setArg(0,a1);
4505  kernel_.setArg(1,a2);
4506  kernel_.setArg(2,a3);
4507  kernel_.setArg(3,a4);
4508  kernel_.setArg(4,a5);
4509  kernel_.setArg(5,a6);
4510  kernel_.setArg(6,a7);
4511  kernel_.setArg(7,a8);
4512  kernel_.setArg(8,a9);
4513  kernel_.setArg(9,a10);
4514  kernel_.setArg(10,a11);
4515  kernel_.setArg(11,a12);
4516  kernel_.setArg(12,a13);
4517  kernel_.setArg(13,a14);
4518 
4519  err_ = ce_enqueueKernel(queue_,
4520  kernel_,
4521  offset_,
4522  global_,
4523  local_,
4524  NULL, // bgaster_fixme - do we want to allow wait event lists?
4525  &event);
4526 
4527  return event;
4528 }
4529 
4530 template<class A1, class A2, class A3, class A4, class A5,
4531  class A6, class A7, class A8, class A9, class A10,
4532  class A11, class A12, class A13, class A14, class A15>
4534  const A1& a1,
4535  const A2& a2,
4536  const A3& a3,
4537  const A4& a4,
4538  const A5& a5,
4539  const A6& a6,
4540  const A7& a7,
4541  const A8& a8,
4542  const A9& a9,
4543  const A10& a10,
4544  const A11& a11,
4545  const A12& a12,
4546  const A13& a13,
4547  const A14& a14,
4548  const A15& a15,
4549  const VECTOR_CLASS<Event>* )
4550 {
4551  Event event;
4552 
4553  kernel_.setArg(0,a1);
4554  kernel_.setArg(1,a2);
4555  kernel_.setArg(2,a3);
4556  kernel_.setArg(3,a4);
4557  kernel_.setArg(4,a5);
4558  kernel_.setArg(5,a6);
4559  kernel_.setArg(6,a7);
4560  kernel_.setArg(7,a8);
4561  kernel_.setArg(8,a9);
4562  kernel_.setArg(9,a10);
4563  kernel_.setArg(10,a11);
4564  kernel_.setArg(11,a12);
4565  kernel_.setArg(12,a13);
4566  kernel_.setArg(13,a14);
4567  kernel_.setArg(14,a15);
4568 
4569  err_ = ce_enqueueKernel(queue_,
4570  kernel_,
4571  offset_,
4572  global_,
4573  local_,
4574  NULL, // bgaster_fixme - do we want to allow wait event lists?
4575  &event);
4576 
4577  return event;
4578 }
4579 
4580 template<class A1, class A2, class A3, class A4, class A5,
4581  class A6, class A7, class A8, class A9, class A10,
4582  class A11, class A12, class A13, class A14, class A15,
4583  class A16>
4585  const A1& a1,
4586  const A2& a2,
4587  const A3& a3,
4588  const A4& a4,
4589  const A5& a5,
4590  const A6& a6,
4591  const A7& a7,
4592  const A8& a8,
4593  const A9& a9,
4594  const A10& a10,
4595  const A11& a11,
4596  const A12& a12,
4597  const A13& a13,
4598  const A14& a14,
4599  const A15& a15,
4600  const A16& a16,
4601  const VECTOR_CLASS<Event>* )
4602 {
4603  Event event;
4604 
4605  kernel_.setArg(0,a1);
4606  kernel_.setArg(1,a2);
4607  kernel_.setArg(2,a3);
4608  kernel_.setArg(3,a4);
4609  kernel_.setArg(4,a5);
4610  kernel_.setArg(5,a6);
4611  kernel_.setArg(6,a7);
4612  kernel_.setArg(7,a8);
4613  kernel_.setArg(8,a9);
4614  kernel_.setArg(9,a10);
4615  kernel_.setArg(10,a11);
4616  kernel_.setArg(11,a12);
4617  kernel_.setArg(12,a13);
4618  kernel_.setArg(13,a14);
4619  kernel_.setArg(14,a15);
4620  kernel_.setArg(15,a16);
4621 
4622  err_ = ce_enqueueKernel(queue_,
4623  kernel_,
4624  offset_,
4625  global_,
4626  local_,
4627  NULL, // bgaster_fixme - do we want to allow wait event lists?
4628  &event);
4629 
4630  return event;
4631 }
4632 
4633 template<class A1, class A2, class A3, class A4, class A5,
4634  class A6, class A7, class A8, class A9, class A10,
4635  class A11, class A12, class A13, class A14, class A15,
4636  class A16, class A17>
4638  const A1& a1,
4639  const A2& a2,
4640  const A3& a3,
4641  const A4& a4,
4642  const A5& a5,
4643  const A6& a6,
4644  const A7& a7,
4645  const A8& a8,
4646  const A9& a9,
4647  const A10& a10,
4648  const A11& a11,
4649  const A12& a12,
4650  const A13& a13,
4651  const A14& a14,
4652  const A15& a15,
4653  const A16& a16,
4654  const A17& a17,
4655  const VECTOR_CLASS<Event>* )
4656 {
4657  Event event;
4658 
4659  kernel_.setArg(0,a1);
4660  kernel_.setArg(1,a2);
4661  kernel_.setArg(2,a3);
4662  kernel_.setArg(3,a4);
4663  kernel_.setArg(4,a5);
4664  kernel_.setArg(5,a6);
4665  kernel_.setArg(6,a7);
4666  kernel_.setArg(7,a8);
4667  kernel_.setArg(8,a9);
4668  kernel_.setArg(9,a10);
4669  kernel_.setArg(10,a11);
4670  kernel_.setArg(11,a12);
4671  kernel_.setArg(12,a13);
4672  kernel_.setArg(13,a14);
4673  kernel_.setArg(14,a15);
4674  kernel_.setArg(15,a16);
4675  kernel_.setArg(16,a17);
4676 
4677  err_ = ce_enqueueKernel(queue_,
4678  kernel_,
4679  offset_,
4680  global_,
4681  local_,
4682  NULL, // bgaster_fixme - do we want to allow wait event lists?
4683  &event);
4684 
4685  return event;
4686 }
4687 
4688 template<class A1, class A2, class A3, class A4, class A5,
4689  class A6, class A7, class A8, class A9, class A10,
4690  class A11, class A12, class A13, class A14, class A15,
4691  class A16, class A17, class A18>
4693  const A1& a1,
4694  const A2& a2,
4695  const A3& a3,
4696  const A4& a4,
4697  const A5& a5,
4698  const A6& a6,
4699  const A7& a7,
4700  const A8& a8,
4701  const A9& a9,
4702  const A10& a10,
4703  const A11& a11,
4704  const A12& a12,
4705  const A13& a13,
4706  const A14& a14,
4707  const A15& a15,
4708  const A16& a16,
4709  const A17& a17,
4710  const A18& a18,
4711  const VECTOR_CLASS<Event>* )
4712 {
4713  Event event;
4714 
4715  kernel_.setArg(0,a1);
4716  kernel_.setArg(1,a2);
4717  kernel_.setArg(2,a3);
4718  kernel_.setArg(3,a4);
4719  kernel_.setArg(4,a5);
4720  kernel_.setArg(5,a6);
4721  kernel_.setArg(6,a7);
4722  kernel_.setArg(7,a8);
4723  kernel_.setArg(8,a9);
4724  kernel_.setArg(9,a10);
4725  kernel_.setArg(10,a11);
4726  kernel_.setArg(11,a12);
4727  kernel_.setArg(12,a13);
4728  kernel_.setArg(13,a14);
4729  kernel_.setArg(14,a15);
4730  kernel_.setArg(15,a16);
4731  kernel_.setArg(16,a17);
4732  kernel_.setArg(17,a18);
4733 
4734  err_ = ce_enqueueKernel(queue_,
4735  kernel_,
4736  offset_,
4737  global_,
4738  local_,
4739  NULL, // bgaster_fixme - do we want to allow wait event lists?
4740  &event);
4741 
4742  return event;
4743 }
4744 
4745 template<class A1, class A2, class A3, class A4, class A5,
4746  class A6, class A7, class A8, class A9, class A10,
4747  class A11, class A12, class A13, class A14, class A15,
4748  class A16, class A17, class A18, class A19>
4750  const A1& a1,
4751  const A2& a2,
4752  const A3& a3,
4753  const A4& a4,
4754  const A5& a5,
4755  const A6& a6,
4756  const A7& a7,
4757  const A8& a8,
4758  const A9& a9,
4759  const A10& a10,
4760  const A11& a11,
4761  const A12& a12,
4762  const A13& a13,
4763  const A14& a14,
4764  const A15& a15,
4765  const A16& a16,
4766  const A17& a17,
4767  const A18& a18,
4768  const A19& a19,
4769  const VECTOR_CLASS<Event>* )
4770 {
4771  Event event;
4772 
4773  kernel_.setArg(0,a1);
4774  kernel_.setArg(1,a2);
4775  kernel_.setArg(2,a3);
4776  kernel_.setArg(3,a4);
4777  kernel_.setArg(4,a5);
4778  kernel_.setArg(5,a6);
4779  kernel_.setArg(6,a7);
4780  kernel_.setArg(7,a8);
4781  kernel_.setArg(8,a9);
4782  kernel_.setArg(9,a10);
4783  kernel_.setArg(10,a11);
4784  kernel_.setArg(11,a12);
4785  kernel_.setArg(12,a13);
4786  kernel_.setArg(13,a14);
4787  kernel_.setArg(14,a15);
4788  kernel_.setArg(15,a16);
4789  kernel_.setArg(16,a17);
4790  kernel_.setArg(17,a18);
4791  kernel_.setArg(18,a19);
4792 
4793  err_ = ce_enqueueKernel(queue_,
4794  kernel_,
4795  offset_,
4796  global_,
4797  local_,
4798  NULL, // bgaster_fixme - do we want to allow wait event lists?
4799  &event);
4800 
4801  return event;
4802 }
4803 
4804 template<class A1, class A2, class A3, class A4, class A5,
4805  class A6, class A7, class A8, class A9, class A10,
4806  class A11, class A12, class A13, class A14, class A15,
4807  class A16, class A17, class A18, class A19, class A20>
4809  const A1& a1,
4810  const A2& a2,
4811  const A3& a3,
4812  const A4& a4,
4813  const A5& a5,
4814  const A6& a6,
4815  const A7& a7,
4816  const A8& a8,
4817  const A9& a9,
4818  const A10& a10,
4819  const A11& a11,
4820  const A12& a12,
4821  const A13& a13,
4822  const A14& a14,
4823  const A15& a15,
4824  const A16& a16,
4825  const A17& a17,
4826  const A18& a18,
4827  const A19& a19,
4828  const A20& a20,
4829  const VECTOR_CLASS<Event>* )
4830 {
4831  Event event;
4832 
4833  kernel_.setArg(0,a1);
4834  kernel_.setArg(1,a2);
4835  kernel_.setArg(2,a3);
4836  kernel_.setArg(3,a4);
4837  kernel_.setArg(4,a5);
4838  kernel_.setArg(5,a6);
4839  kernel_.setArg(6,a7);
4840  kernel_.setArg(7,a8);
4841  kernel_.setArg(8,a9);
4842  kernel_.setArg(9,a10);
4843  kernel_.setArg(10,a11);
4844  kernel_.setArg(11,a12);
4845  kernel_.setArg(12,a13);
4846  kernel_.setArg(13,a14);
4847  kernel_.setArg(14,a15);
4848  kernel_.setArg(15,a16);
4849  kernel_.setArg(16,a17);
4850  kernel_.setArg(17,a18);
4851  kernel_.setArg(18,a19);
4852  kernel_.setArg(19,a20);
4853 
4854  err_ = ce_enqueueKernel(queue_,
4855  kernel_,
4856  offset_,
4857  global_,
4858  local_,
4859  NULL, // bgaster_fixme - do we want to allow wait event lists?
4860  &event);
4861 
4862  return event;
4863 }
4864 
4865 template<class A1, class A2, class A3, class A4, class A5,
4866  class A6, class A7, class A8, class A9, class A10,
4867  class A11, class A12, class A13, class A14, class A15,
4868  class A16, class A17, class A18, class A19, class A20, class A21>
4870  const A1& a1,
4871  const A2& a2,
4872  const A3& a3,
4873  const A4& a4,
4874  const A5& a5,
4875  const A6& a6,
4876  const A7& a7,
4877  const A8& a8,
4878  const A9& a9,
4879  const A10& a10,
4880  const A11& a11,
4881  const A12& a12,
4882  const A13& a13,
4883  const A14& a14,
4884  const A15& a15,
4885  const A16& a16,
4886  const A17& a17,
4887  const A18& a18,
4888  const A19& a19,
4889  const A20& a20,
4890  const A21& a21,
4891  const VECTOR_CLASS<Event>* )
4892 {
4893  Event event;
4894 
4895  kernel_.setArg(0,a1);
4896  kernel_.setArg(1,a2);
4897  kernel_.setArg(2,a3);
4898  kernel_.setArg(3,a4);
4899  kernel_.setArg(4,a5);
4900  kernel_.setArg(5,a6);
4901  kernel_.setArg(6,a7);
4902  kernel_.setArg(7,a8);
4903  kernel_.setArg(8,a9);
4904  kernel_.setArg(9,a10);
4905  kernel_.setArg(10,a11);
4906  kernel_.setArg(11,a12);
4907  kernel_.setArg(12,a13);
4908  kernel_.setArg(13,a14);
4909  kernel_.setArg(14,a15);
4910  kernel_.setArg(15,a16);
4911  kernel_.setArg(16,a17);
4912  kernel_.setArg(17,a18);
4913  kernel_.setArg(18,a19);
4914  kernel_.setArg(19,a20);
4915  kernel_.setArg(20,a21);
4916 
4917  err_ = ce_enqueueKernel(queue_,
4918  kernel_,
4919  offset_,
4920  global_,
4921  local_,
4922  NULL, // bgaster_fixme - do we want to allow wait event lists?
4923  &event);
4924 
4925  return event;
4926 }
4927 
4928 template<class A1, class A2, class A3, class A4, class A5,
4929  class A6, class A7, class A8, class A9, class A10,
4930  class A11, class A12, class A13, class A14, class A15,
4931  class A16, class A17, class A18, class A19, class A20, class A21, class A22>
4933  const A1& a1,
4934  const A2& a2,
4935  const A3& a3,
4936  const A4& a4,
4937  const A5& a5,
4938  const A6& a6,
4939  const A7& a7,
4940  const A8& a8,
4941  const A9& a9,
4942  const A10& a10,
4943  const A11& a11,
4944  const A12& a12,
4945  const A13& a13,
4946  const A14& a14,
4947  const A15& a15,
4948  const A16& a16,
4949  const A17& a17,
4950  const A18& a18,
4951  const A19& a19,
4952  const A20& a20,
4953  const A21& a21,
4954  const A22& a22,
4955  const VECTOR_CLASS<Event>* )
4956 {
4957  Event event;
4958 
4959  kernel_.setArg(0,a1);
4960  kernel_.setArg(1,a2);
4961  kernel_.setArg(2,a3);
4962  kernel_.setArg(3,a4);
4963  kernel_.setArg(4,a5);
4964  kernel_.setArg(5,a6);
4965  kernel_.setArg(6,a7);
4966  kernel_.setArg(7,a8);
4967  kernel_.setArg(8,a9);
4968  kernel_.setArg(9,a10);
4969  kernel_.setArg(10,a11);
4970  kernel_.setArg(11,a12);
4971  kernel_.setArg(12,a13);
4972  kernel_.setArg(13,a14);
4973  kernel_.setArg(14,a15);
4974  kernel_.setArg(15,a16);
4975  kernel_.setArg(16,a17);
4976  kernel_.setArg(17,a18);
4977  kernel_.setArg(18,a19);
4978  kernel_.setArg(19,a20);
4979  kernel_.setArg(20,a21);
4980  kernel_.setArg(21,a22);
4981 
4982  err_ = ce_enqueueKernel(queue_,
4983  kernel_,
4984  offset_,
4985  global_,
4986  local_,
4987  NULL, // bgaster_fixme - do we want to allow wait event lists?
4988  &event);
4989 
4990  return event;
4991 }
4992 
4993 #undef __ERR_STR
4994 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
4995 #undef __GET_DEVICE_INFO_ERR
4996 #undef __GET_PLATFORM_INFO_ERR
4997 #undef __GET_DEVICE_IDS_ERR
4998 #undef __GET_CONTEXT_INFO_ERR
4999 #undef __GET_EVENT_INFO_ERR
5000 #undef __GET_EVENT_PROFILE_INFO_ERR
5001 #undef __GET_MEM_OBJECT_INFO_ERR
5002 #undef __GET_IMAGE_INFO_ERR
5003 #undef __GET_SAMPLER_INFO_ERR
5004 #undef __GET_KERNEL_INFO_ERR
5005 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
5006 #undef __GET_PROGRAM_INFO_ERR
5007 #undef __GET_PROGRAM_BUILD_INFO_ERR
5008 #undef __GET_COMMAND_QUEUE_INFO_ERR
5009 
5010 #undef __CREATE_CONTEXT_ERR
5011 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
5012 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
5013 
5014 #undef __CREATE_BUFFER_ERR
5015 #undef __CREATE_SUBBUFFER_ERR
5016 #undef __CREATE_IMAGE2D_ERR
5017 #undef __CREATE_IMAGE3D_ERR
5018 #undef __CREATE_SAMPLER_ERR
5019 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
5020 
5021 #undef __CREATE_USER_EVENT_ERR
5022 #undef __SET_USER_EVENT_STATUS_ERR
5023 #undef __SET_EVENT_CALLBACK_ERR
5024 
5025 #undef __WAIT_FOR_EVENTS_ERR
5026 
5027 #undef __CREATE_KERNEL_ERR
5028 #undef __SET_KERNEL_ARGS_ERR
5029 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
5030 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
5031 #undef __BUILD_PROGRAM_ERR
5032 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
5033 
5034 #undef __CREATE_COMMAND_QUEUE_ERR
5035 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
5036 #undef __ENQUEUE_READ_BUFFER_ERR
5037 #undef __ENQUEUE_WRITE_BUFFER_ERR
5038 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
5039 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
5040 #undef __ENQEUE_COPY_BUFFER_ERR
5041 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
5042 #undef __ENQUEUE_READ_IMAGE_ERR
5043 #undef __ENQUEUE_WRITE_IMAGE_ERR
5044 #undef __ENQUEUE_COPY_IMAGE_ERR
5045 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
5046 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
5047 #undef __ENQUEUE_MAP_BUFFER_ERR
5048 #undef __ENQUEUE_MAP_IMAGE_ERR
5049 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
5050 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
5051 #undef __ENQUEUE_TASK_ERR
5052 #undef __ENQUEUE_NATIVE_KERNEL
5053 
5054 #undef __UNLOAD_COMPILER_ERR
5055 #endif //__CL_USER_OVERRIDE_ERROR_STRINGS
5056 
5057 #undef __GET_INFO_HELPER_WITH_RETAIN
5058 
5059 // Extensions
5060 #undef __INIT_CL_EXT_FCN_PTR
5061 #undef __CREATE_SUB_DEVICES
5062 
5063 #if defined(USE_CL_DEVICE_FISSION)
5064 #undef __PARAM_NAME_DEVICE_FISSION
5065 #endif // USE_CL_DEVICE_FISSION
5066 
5067 } // namespace cl
5068 
5069 #endif // CL_HPP_
GLsizei GLenum GLsizei GLsizei GLuint memory
Definition: RE_OGL.h:202
#define CE_API
Definition: CE_API.h:13
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
type
Definition: core.h:556
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:4016
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:632
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:2873
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:3259
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:3600
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 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:3234
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:2875
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:3417
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:2938
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:622
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:2963
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:2855
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:3159
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:3559
< 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:3618
#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
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
string(const string &rhs)
Definition: cl.hpp:406
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
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:3132
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:3209
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:3546
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:632
#define CL_PROGRAM_BINARY_SIZES
Definition: cl.h:709
auto get(const UT_ARTIterator< T > &it) -> decltype(it.key())
Definition: UT_ARTMap.h:1173
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:3410
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:3309
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:3355
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:2852
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:578
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:3288
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:4331
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:3587
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:3184
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
Context provides a wrapper around the Core library context object.
Definition: ImfContext.h:30
cl_int flush() const
Definition: cl.hpp:3554
**If you just want to fire and args
Definition: thread.h:618
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:2913
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:3999
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Definition: cl.hpp:1701
cl_int enqueueAcquireGLObjects(const VECTOR_CLASS< Memory > *mem_objects=NULL, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3428
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:4040
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:3335
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:3450
static cl_int waitForEvents(const VECTOR_CLASS< Event > &events)
Definition: cl.hpp:1736
::size_t dimensions() const
Definition: cl.hpp:2499
::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:2902
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:2892
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:1821
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:3105
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