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