Fabcoin Core  0.16.2
P2P Digital Currency
cl.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2008-2010 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 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
25 
26 #if __GNUC__ >= 6
27  #pragma GCC diagnostic ignored "-Wignored-attributes"
28 #endif
29 
146 #ifndef CL_HPP_
147 #define CL_HPP_
148 
149 #ifdef _WIN32
150 #include <windows.h>
151 #include <malloc.h>
152 #if defined(USE_DX_INTEROP)
153 #include <CL/cl_d3d10.h>
154 #endif
155 #endif // _WIN32
156 
157 //
158 #if defined(USE_CL_DEVICE_FISSION)
159 #include <CL/cl_ext.h>
160 #endif
161 
162 #if defined(__APPLE__) || defined(__MACOSX)
163 #include <OpenGL/OpenGL.h>
164 #include <OpenCL/opencl.h>
165 #else
166 #include <GL/gl.h>
167 #include <CL/opencl.h>
168 #endif // !__APPLE__
169 
170 #if !defined(CL_CALLBACK)
171 #define CL_CALLBACK
172 #endif //CL_CALLBACK
173 
174 #include <utility>
175 
176 #if !defined(__NO_STD_VECTOR)
177 #include <vector>
178 #endif
179 
180 #if !defined(__NO_STD_STRING)
181 #include <string>
182 #endif
183 
184 #if defined(linux) || defined(__APPLE__) || defined(__MACOSX)
185 # include <alloca.h>
186 #endif // linux
187 
188 #include <cstring>
189 
195 namespace cl {
196 
197 #define __INIT_CL_EXT_FCN_PTR(name) \
198  if(!pfn_##name) { \
199  pfn_##name = (PFN_##name) \
200  clGetExtensionFunctionAddress(#name); \
201  if(!pfn_##name) { \
202  } \
203  }
204 
205 class Program;
206 class Device;
207 class Context;
208 class CommandQueue;
209 class Memory;
210 
211 #if defined(__CL_ENABLE_EXCEPTIONS)
212 #include <exception>
216 class Error : public std::exception
217 {
218 private:
219  cl_int err_;
220  const char * errStr_;
221 public:
225  Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr)
226  {}
227 
228  ~Error() throw() {}
229 
234  virtual const char * what() const throw ()
235  {
236  if (errStr_ == NULL) {
237  return "empty";
238  }
239  else {
240  return errStr_;
241  }
242  }
243 
248  cl_int err(void) const { return err_; }
249 };
250 
251 #define __ERR_STR(x) #x
252 #else
253 #define __ERR_STR(x) NULL
254 #endif // __CL_ENABLE_EXCEPTIONS
255 
257 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
258 #define __GET_DEVICE_INFO_ERR __ERR_STR(clgetDeviceInfo)
259 #define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo)
260 #define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs)
261 #define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs)
262 #define __GET_CONTEXT_INFO_ERR __ERR_STR(clGetContextInfo)
263 #define __GET_EVENT_INFO_ERR __ERR_STR(clGetEventInfo)
264 #define __GET_EVENT_PROFILE_INFO_ERR __ERR_STR(clGetEventProfileInfo)
265 #define __GET_MEM_OBJECT_INFO_ERR __ERR_STR(clGetMemObjectInfo)
266 #define __GET_IMAGE_INFO_ERR __ERR_STR(clGetImageInfo)
267 #define __GET_SAMPLER_INFO_ERR __ERR_STR(clGetSamplerInfo)
268 #define __GET_KERNEL_INFO_ERR __ERR_STR(clGetKernelInfo)
269 #define __GET_KERNEL_WORK_GROUP_INFO_ERR __ERR_STR(clGetKernelWorkGroupInfo)
270 #define __GET_PROGRAM_INFO_ERR __ERR_STR(clGetProgramInfo)
271 #define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo)
272 #define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo)
273 
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_FILL_BUFFER_ERR __ERR_STR(clEnqueueFillBuffer)
304 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR __ERR_STR(clEnqueueWriteBufferRect)
305 #define __ENQEUE_COPY_BUFFER_ERR __ERR_STR(clEnqueueCopyBuffer)
306 #define __ENQEUE_COPY_BUFFER_RECT_ERR __ERR_STR(clEnqueueCopyBufferRect)
307 #define __ENQUEUE_READ_IMAGE_ERR __ERR_STR(clEnqueueReadImage)
308 #define __ENQUEUE_WRITE_IMAGE_ERR __ERR_STR(clEnqueueWriteImage)
309 #define __ENQUEUE_COPY_IMAGE_ERR __ERR_STR(clEnqueueCopyImage)
310 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR __ERR_STR(clEnqueueCopyImageToBuffer)
311 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR __ERR_STR(clEnqueueCopyBufferToImage)
312 #define __ENQUEUE_MAP_BUFFER_ERR __ERR_STR(clEnqueueMapBuffer)
313 #define __ENQUEUE_MAP_IMAGE_ERR __ERR_STR(clEnqueueMapImage)
314 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR __ERR_STR(clEnqueueUnMapMemObject)
315 #define __ENQUEUE_NDRANGE_KERNEL_ERR __ERR_STR(clEnqueueNDRangeKernel)
316 #define __ENQUEUE_TASK_ERR __ERR_STR(clEnqueueTask)
317 #define __ENQUEUE_NATIVE_KERNEL __ERR_STR(clEnqueueNativeKernel)
318 #define __ENQUEUE_MARKER_ERR __ERR_STR(clEnqueueMarker)
319 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR __ERR_STR(clEnqueueWaitForEvents)
320 #define __ENQUEUE_BARRIER_ERR __ERR_STR(clEnqueueBarrier)
321 
322 #define __ENQUEUE_ACQUIRE_GL_ERR __ERR_STR(clEnqueueAcquireGLObjects)
323 #define __ENQUEUE_RELEASE_GL_ERR __ERR_STR(clEnqueueReleaseGLObjects)
324 
325 #define __UNLOAD_COMPILER_ERR __ERR_STR(clUnloadCompiler)
326 
327 #define __FLUSH_ERR __ERR_STR(clFlush)
328 #define __FINISH_ERR __ERR_STR(clFinish)
329 
330 #define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevicesEXT)
331 #endif // __CL_USER_OVERRIDE_ERROR_STRINGS
332 
338 class string
339 {
340 private:
341  ::size_t size_;
342  char * str_;
343 public:
344  string(void) : size_(0), str_(NULL)
345  {
346  }
347 
348  string(char * str, ::size_t size) :
349  size_(size),
350  str_(NULL)
351  {
352  str_ = new char[size_+1];
353  if (str_ != NULL) {
354  memcpy(str_, str, size_ * sizeof(char));
355  str_[size_] = '\0';
356  }
357  else {
358  size_ = 0;
359  }
360  }
361 
362  string(char * str) :
363  str_(NULL)
364  {
365  size_= ::strlen(str);
366  str_ = new char[size_ + 1];
367  if (str_ != NULL) {
368  memcpy(str_, str, (size_ + 1) * sizeof(char));
369  }
370  else {
371  size_ = 0;
372  }
373  }
374 
375  string& operator=(const string& rhs)
376  {
377  if (this == &rhs) {
378  return *this;
379  }
380 
381  if (rhs.size_ == 0 || rhs.str_ == NULL) {
382  size_ = 0;
383  str_ = NULL;
384  }
385  else {
386  size_ = rhs.size_;
387  str_ = new char[size_ + 1];
388  if (str_ != NULL) {
389  memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char));
390  }
391  else {
392  size_ = 0;
393  }
394  }
395 
396  return *this;
397  }
398 
399  string(const string& rhs)
400  {
401  *this = rhs;
402  }
403 
405  {
406  if (str_ != NULL) {
407  delete[] str_;
408  }
409  }
410 
411  ::size_t size(void) const { return size_; }
412  ::size_t length(void) const { return size(); }
413 
414  const char * c_str(void) const { return (str_) ? str_ : "";}
415 };
416 
417 #if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING)
418 #include <string>
419 typedef std::string STRING_CLASS;
420 #elif !defined(__USE_DEV_STRING)
421 typedef cl::string STRING_CLASS;
422 #endif
423 
424 #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR)
425 #include <vector>
426 #define VECTOR_CLASS std::vector
427 #elif !defined(__USE_DEV_VECTOR)
428 #define VECTOR_CLASS cl::vector
429 #endif
430 
431 #if !defined(__MAX_DEFAULT_VECTOR_SIZE)
432 #define __MAX_DEFAULT_VECTOR_SIZE 10
433 #endif
434 
439 template <typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
440 class vector
441 {
442 private:
443  T data_[N];
444  unsigned int size_;
445  bool empty_;
446 public:
447  vector() :
448  size_(-1),
449  empty_(true)
450  {}
451 
452  ~vector() {}
453 
454  unsigned int size(void) const
455  {
456  return size_ + 1;
457  }
458 
459  void clear()
460  {
461  size_ = -1;
462  empty_ = true;
463  }
464 
465  void push_back (const T& x)
466  {
467  if (size() < N) {
468  size_++;
469  data_[size_] = x;
470  empty_ = false;
471  }
472  }
473 
474  void pop_back(void)
475  {
476  if (!empty_) {
477  data_[size_].~T();
478  size_--;
479  if (size_ == -1) {
480  empty_ = true;
481  }
482  }
483  }
484 
485  vector(const vector<T, N>& vec) :
486  size_(vec.size_),
487  empty_(vec.empty_)
488  {
489  if (!empty_) {
490  memcpy(&data_[0], &vec.data_[0], size() * sizeof(T));
491  }
492  }
493 
494  vector(unsigned int size, const T& val = T()) :
495  size_(-1),
496  empty_(true)
497  {
498  for (unsigned int i = 0; i < size; i++) {
499  push_back(val);
500  }
501  }
502 
504  {
505  if (this == &rhs) {
506  return *this;
507  }
508 
509  size_ = rhs.size_;
510  empty_ = rhs.empty_;
511 
512  if (!empty_) {
513  memcpy(&data_[0], &rhs.data_[0], size() * sizeof(T));
514  }
515 
516  return *this;
517  }
518 
520  {
521  if (empty_ && vec.empty_) {
522  return true;
523  }
524 
525  if (size() != vec.size()) {
526  return false;
527  }
528 
529  return memcmp(&data_[0], &vec.data_[0], size() * sizeof(T)) == 0 ? true : false;
530  }
531 
532  operator T* () { return data_; }
533  operator const T* () const { return data_; }
534 
535  bool empty (void) const
536  {
537  return empty_;
538  }
539 
540  unsigned int max_size (void) const
541  {
542  return N;
543  }
544 
545  unsigned int capacity () const
546  {
547  return sizeof(T) * N;
548  }
549 
550  T& operator[](int index)
551  {
552  return data_[index];
553  }
554 
555  T operator[](int index) const
556  {
557  return data_[index];
558  }
559 
560  template<class I>
561  void assign(I start, I end)
562  {
563  clear();
564  while(start < end) {
565  push_back(*start);
566  start++;
567  }
568  }
569 
573  class iterator
574  {
575  private:
576  vector<T,N> vec_;
577  int index_;
578  bool initialized_;
579  public:
580  iterator(void) :
581  index_(-1),
582  initialized_(false)
583  {
584  index_ = -1;
585  initialized_ = false;
586  }
587 
588  ~iterator(void) {}
589 
591  {
592  iterator i;
593 
594  if (!vec.empty()) {
595  i.index_ = 0;
596  }
597 
598  i.vec_ = vec;
599  i.initialized_ = true;
600  return i;
601  }
602 
603  static iterator end(vector<T,N> &vec)
604  {
605  iterator i;
606 
607  if (!vec.empty()) {
608  i.index_ = vec.size();
609  }
610  i.vec_ = vec;
611  i.initialized_ = true;
612  return i;
613  }
614 
616  {
617  return ((vec_ == i.vec_) &&
618  (index_ == i.index_) &&
619  (initialized_ == i.initialized_));
620  }
621 
623  {
624  return (!(*this==i));
625  }
626 
627  void operator++()
628  {
629  index_++;
630  }
631 
632  void operator++(int x)
633  {
634  index_ += x;
635  }
636 
637  void operator--()
638  {
639  index_--;
640  }
641 
642  void operator--(int x)
643  {
644  index_ -= x;
645  }
646 
648  {
649  return vec_[index_];
650  }
651  };
652 
653  iterator begin(void)
654  {
655  return iterator::begin(*this);
656  }
657 
658  iterator end(void)
659  {
660  return iterator::end(*this);
661  }
662 
663  T& front(void)
664  {
665  return data_[0];
666  }
667 
668  T& back(void)
669  {
670  return data_[size_];
671  }
672 
673  const T& front(void) const
674  {
675  return data_[0];
676  }
677 
678  const T& back(void) const
679  {
680  return data_[size_];
681  }
682 };
683 
689 template <int N>
690 struct size_t : public cl::vector< ::size_t, N> { };
691 
692 namespace detail {
693 
694 // GetInfo help struct
695 template <typename Functor, typename T>
696 struct GetInfoHelper
697 {
698  static cl_int
699  get(Functor f, cl_uint name, T* param)
700  {
701  return f(name, sizeof(T), param, NULL);
702  }
703 };
704 
705 // Specialized GetInfoHelper for VECTOR_CLASS params
706 template <typename Func, typename T>
707 struct GetInfoHelper<Func, VECTOR_CLASS<T> >
708 {
709  static cl_int get(Func f, cl_uint name, VECTOR_CLASS<T>* param)
710  {
711  ::size_t required;
712  cl_int err = f(name, 0, NULL, &required);
713  if (err != CL_SUCCESS) {
714  return err;
715  }
716 
717  T* value = (T*) alloca(required);
718  err = f(name, required, value, NULL);
719  if (err != CL_SUCCESS) {
720  return err;
721  }
722 
723  param->assign(&value[0], &value[required/sizeof(T)]);
724  return CL_SUCCESS;
725  }
726 };
727 
728 // Specialized for getInfo<CL_PROGRAM_BINARIES>
729 template <typename Func>
730 struct GetInfoHelper<Func, VECTOR_CLASS<char *> >
731 {
732  static cl_int
733  get(Func f, cl_uint name, VECTOR_CLASS<char *>* param)
734  {
735  cl_uint err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL);
736  if (err != CL_SUCCESS) {
737  return err;
738  }
739 
740  return CL_SUCCESS;
741  }
742 };
743 
744 // Specialized GetInfoHelper for STRING_CLASS params
745 template <typename Func>
746 struct GetInfoHelper<Func, STRING_CLASS>
747 {
748  static cl_int get(Func f, cl_uint name, STRING_CLASS* param)
749  {
750  ::size_t required;
751  cl_int err = f(name, 0, NULL, &required);
752  if (err != CL_SUCCESS) {
753  return err;
754  }
755 
756  char* value = (char*) alloca(required);
757  err = f(name, required, value, NULL);
758  if (err != CL_SUCCESS) {
759  return err;
760  }
761 
762  *param = value;
763  return CL_SUCCESS;
764  }
765 };
766 
767 #define __GET_INFO_HELPER_WITH_RETAIN(CPP_TYPE) \
768 namespace detail { \
769 template <typename Func> \
770 struct GetInfoHelper<Func, CPP_TYPE> \
771 { \
772  static cl_int get(Func f, cl_uint name, CPP_TYPE* param) \
773  { \
774  cl_uint err = f(name, sizeof(CPP_TYPE), param, NULL); \
775  if (err != CL_SUCCESS) { \
776  return err; \
777  } \
778  \
779  return ReferenceHandler<CPP_TYPE::cl_type>::retain((*param)()); \
780  } \
781 }; \
782 }
783 
784 
785 #define __PARAM_NAME_INFO_1_0(F) \
786  F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \
787  F(cl_platform_info, CL_PLATFORM_VERSION, STRING_CLASS) \
788  F(cl_platform_info, CL_PLATFORM_NAME, STRING_CLASS) \
789  F(cl_platform_info, CL_PLATFORM_VENDOR, STRING_CLASS) \
790  F(cl_platform_info, CL_PLATFORM_EXTENSIONS, STRING_CLASS) \
791  \
792  F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
793  F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
794  F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
795  F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
796  F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, ::size_t) \
797  F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, VECTOR_CLASS< ::size_t>) \
798  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
799  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
800  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
801  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
802  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
803  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
804  F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
805  F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_bitfield) \
806  F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
807  F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
808  F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
809  F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, ::size_t) \
810  F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, ::size_t) \
811  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \
812  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \
813  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \
814  F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_uint) \
815  F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \
816  F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
817  F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
818  F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
819  F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
820  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
821  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
822  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
823  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
824  F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
825  F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
826  F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
827  F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
828  F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
829  F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, ::size_t) \
830  F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
831  F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
832  F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
833  F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
834  F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) \
835  F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
836  F(cl_device_info, CL_DEVICE_NAME, STRING_CLASS) \
837  F(cl_device_info, CL_DEVICE_VENDOR, STRING_CLASS) \
838  F(cl_device_info, CL_DRIVER_VERSION, STRING_CLASS) \
839  F(cl_device_info, CL_DEVICE_PROFILE, STRING_CLASS) \
840  F(cl_device_info, CL_DEVICE_VERSION, STRING_CLASS) \
841  F(cl_device_info, CL_DEVICE_EXTENSIONS, STRING_CLASS) \
842  \
843  F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
844  F(cl_context_info, CL_CONTEXT_DEVICES, VECTOR_CLASS<Device>) \
845  F(cl_context_info, CL_CONTEXT_PROPERTIES, VECTOR_CLASS<cl_context_properties>) \
846  \
847  F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
848  F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
849  F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
850  F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_uint) \
851  \
852  F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
853  F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
854  F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
855  F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
856  \
857  F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
858  F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
859  F(cl_mem_info, CL_MEM_SIZE, ::size_t) \
860  F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
861  F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
862  F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
863  F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
864  \
865  F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
866  F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, ::size_t) \
867  F(cl_image_info, CL_IMAGE_ROW_PITCH, ::size_t) \
868  F(cl_image_info, CL_IMAGE_SLICE_PITCH, ::size_t) \
869  F(cl_image_info, CL_IMAGE_WIDTH, ::size_t) \
870  F(cl_image_info, CL_IMAGE_HEIGHT, ::size_t) \
871  F(cl_image_info, CL_IMAGE_DEPTH, ::size_t) \
872  \
873  F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
874  F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
875  F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_addressing_mode) \
876  F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_filter_mode) \
877  F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_bool) \
878  \
879  F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
880  F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
881  F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
882  F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS<cl_device_id>) \
883  F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \
884  F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \
885  F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS<char *>) \
886  \
887  F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
888  F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \
889  F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, STRING_CLASS) \
890  \
891  F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, STRING_CLASS) \
892  F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
893  F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
894  F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
895  F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
896  \
897  F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, ::size_t) \
898  F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::size_t<3>) \
899  F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
900  \
901  F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
902  F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
903  F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
904  F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
905 
906 #if defined(CL_VERSION_1_1)
907 #define __PARAM_NAME_INFO_1_1(F) \
908  F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
909  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
910  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
911  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
912  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
913  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
914  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
915  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
916  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
917  F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
918  F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
919  F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \
920  \
921  F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
922  F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \
923  \
924  F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, ::size_t) \
925  F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
926  \
927  F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
928 #endif // CL_VERSION_1_1
929 
930 #if defined(USE_CL_DEVICE_FISSION)
931 #define __PARAM_NAME_DEVICE_FISSION(F) \
932  F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
933  F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \
934  F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \
935  F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
936  F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, VECTOR_CLASS<cl_device_partition_property_ext>)
937 #endif // USE_CL_DEVICE_FISSION
938 
939 template <typename enum_type, cl_int Name>
940 struct param_traits {};
941 
942 #define __DECLARE_PARAM_TRAITS(token, param_name, T) \
943 struct token; \
944 template<> \
945 struct param_traits<detail:: token,param_name> \
946 { \
947  enum { value = param_name }; \
948  typedef T param_type; \
949 };
950 
952 #if defined(CL_VERSION_1_1)
953 __PARAM_NAME_INFO_1_1(__DECLARE_PARAM_TRAITS)
954 #endif // CL_VERSION_1_1
955 
956 #if defined(USE_CL_DEVICE_FISSION)
957 __PARAM_NAME_DEVICE_FISSION(__DECLARE_PARAM_TRAITS);
958 #endif // USE_CL_DEVICE_FISSION
959 
960 #undef __DECLARE_PARAM_TRAITS
961 
962 // Convenience functions
963 
964 template <typename Func, typename T>
965 inline cl_int
966 getInfo(Func f, cl_uint name, T* param)
967 {
968  return GetInfoHelper<Func, T>::get(f, name, param);
969 }
970 
971 template <typename Func, typename Arg0>
972 struct GetInfoFunctor0
973 {
974  Func f_; const Arg0& arg0_;
975  cl_int operator ()(
976  cl_uint param, ::size_t size, void* value, ::size_t* size_ret)
977  { return f_(arg0_, param, size, value, size_ret); }
978 };
979 
980 template <typename Func, typename Arg0, typename Arg1>
981 struct GetInfoFunctor1
982 {
983  Func f_; const Arg0& arg0_; const Arg1& arg1_;
984  cl_int operator ()(
985  cl_uint param, ::size_t size, void* value, ::size_t* size_ret)
986  { return f_(arg0_, arg1_, param, size, value, size_ret); }
987 };
988 
989 template <typename Func, typename Arg0, typename T>
990 inline cl_int
991 getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
992 {
993  GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
995  ::get(f0, name, param);
996 }
997 
998 template <typename Func, typename Arg0, typename Arg1, typename T>
999 inline cl_int
1000 getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
1001 {
1002  GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1004  ::get(f0, name, param);
1005 }
1006 
1007 template<typename T>
1008 struct ReferenceHandler
1009 { };
1010 
1011 template <>
1012 struct ReferenceHandler<cl_device_id>
1013 {
1014  // cl_device_id does not have retain().
1015  static cl_int retain(cl_device_id)
1016  { return CL_INVALID_DEVICE; }
1017  // cl_device_id does not have release().
1018  static cl_int release(cl_device_id)
1019  { return CL_INVALID_DEVICE; }
1020 };
1021 
1022 template <>
1023 struct ReferenceHandler<cl_platform_id>
1024 {
1025  // cl_platform_id does not have retain().
1026  static cl_int retain(cl_platform_id)
1027  { return CL_INVALID_PLATFORM; }
1028  // cl_platform_id does not have release().
1029  static cl_int release(cl_platform_id)
1030  { return CL_INVALID_PLATFORM; }
1031 };
1032 
1033 template <>
1034 struct ReferenceHandler<cl_context>
1035 {
1036  static cl_int retain(cl_context context)
1037  { return ::clRetainContext(context); }
1038  static cl_int release(cl_context context)
1039  { return ::clReleaseContext(context); }
1040 };
1041 
1042 template <>
1043 struct ReferenceHandler<cl_command_queue>
1044 {
1045  static cl_int retain(cl_command_queue queue)
1046  { return ::clRetainCommandQueue(queue); }
1047  static cl_int release(cl_command_queue queue)
1048  { return ::clReleaseCommandQueue(queue); }
1049 };
1050 
1051 template <>
1052 struct ReferenceHandler<cl_mem>
1053 {
1054  static cl_int retain(cl_mem memory)
1055  { return ::clRetainMemObject(memory); }
1056  static cl_int release(cl_mem memory)
1057  { return ::clReleaseMemObject(memory); }
1058 };
1059 
1060 template <>
1061 struct ReferenceHandler<cl_sampler>
1062 {
1063  static cl_int retain(cl_sampler sampler)
1064  { return ::clRetainSampler(sampler); }
1065  static cl_int release(cl_sampler sampler)
1066  { return ::clReleaseSampler(sampler); }
1067 };
1068 
1069 template <>
1070 struct ReferenceHandler<cl_program>
1071 {
1072  static cl_int retain(cl_program program)
1073  { return ::clRetainProgram(program); }
1074  static cl_int release(cl_program program)
1075  { return ::clReleaseProgram(program); }
1076 };
1077 
1078 template <>
1079 struct ReferenceHandler<cl_kernel>
1080 {
1081  static cl_int retain(cl_kernel kernel)
1082  { return ::clRetainKernel(kernel); }
1083  static cl_int release(cl_kernel kernel)
1084  { return ::clReleaseKernel(kernel); }
1085 };
1086 
1087 template <>
1088 struct ReferenceHandler<cl_event>
1089 {
1090  static cl_int retain(cl_event event)
1091  { return ::clRetainEvent(event); }
1092  static cl_int release(cl_event event)
1093  { return ::clReleaseEvent(event); }
1094 };
1095 
1096 template <typename T>
1097 class Wrapper
1098 {
1099 public:
1100  typedef T cl_type;
1101 
1102 protected:
1103  cl_type object_;
1104 
1105 public:
1106  Wrapper() : object_(NULL) { }
1107 
1109  {
1110  if (object_ != NULL) { release(); }
1111  }
1112 
1114  {
1115  object_ = rhs.object_;
1116  if (object_ != NULL) { retain(); }
1117  }
1118 
1119  Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
1120  {
1121  if (object_ != NULL) { release(); }
1122  object_ = rhs.object_;
1123  if (object_ != NULL) { retain(); }
1124  return *this;
1125  }
1126 
1127  cl_type operator ()() const { return object_; }
1128 
1129  cl_type& operator ()() { return object_; }
1130 
1131 protected:
1132 
1133  cl_int retain() const
1134  {
1135  return ReferenceHandler<cl_type>::retain(object_);
1136  }
1137 
1138  cl_int release() const
1139  {
1140  return ReferenceHandler<cl_type>::release(object_);
1141  }
1142 };
1143 
1144 #if defined(__CL_ENABLE_EXCEPTIONS)
1145 static inline cl_int errHandler (
1146  cl_int err,
1147  const char * errStr = NULL) throw(Error)
1148 {
1149  if (err != CL_SUCCESS) {
1150  throw Error(err, errStr);
1151  }
1152  return err;
1153 }
1154 #else
1155 static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
1156 {
1157  return err;
1158 }
1159 #endif // __CL_ENABLE_EXCEPTIONS
1160 
1161 } // namespace detail
1163 
1167 struct ImageFormat : public cl_image_format
1168 {
1170 
1171  ImageFormat(cl_channel_order order, cl_channel_type type)
1172  {
1173  image_channel_order = order;
1174  image_channel_data_type = type;
1175  }
1176 
1177  ImageFormat& operator = (const ImageFormat& rhs)
1178  {
1179  if (this != &rhs) {
1180  this->image_channel_data_type = rhs.image_channel_data_type;
1181  this->image_channel_order = rhs.image_channel_order;
1182  }
1183  return *this;
1184  }
1185 };
1186 
1190 class Device : public detail::Wrapper<cl_device_id>
1191 {
1192 public:
1193  Device(cl_device_id device) { object_ = device; }
1194 
1195  Device() : detail::Wrapper<cl_type>() { }
1196 
1197  Device(const Device& device) : detail::Wrapper<cl_type>(device) { }
1198 
1199  Device& operator = (const Device& rhs)
1200  {
1201  if (this != &rhs) {
1203  }
1204  return *this;
1205  }
1206 
1207  template <typename T>
1208  cl_int getInfo(cl_device_info name, T* param) const
1209  {
1210  return detail::errHandler(
1211  detail::getInfo(&::clGetDeviceInfo, object_, name, param),
1212  __GET_DEVICE_INFO_ERR);
1213  }
1214 
1215  template <cl_int name> typename
1217  getInfo(cl_int* err = NULL) const
1218  {
1219  typename detail::param_traits<
1220  detail::cl_device_info, name>::param_type param;
1221  cl_int result = getInfo(name, &param);
1222  if (err != NULL) {
1223  *err = result;
1224  }
1225  return param;
1226  }
1227 
1228 #if defined(USE_CL_DEVICE_FISSION)
1229  cl_int createSubDevices(
1230  const cl_device_partition_property_ext * properties,
1231  VECTOR_CLASS<Device>* devices)
1232  {
1233  typedef CL_API_ENTRY cl_int
1234  ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
1235  cl_device_id /*in_device*/,
1236  const cl_device_partition_property_ext * /* properties */,
1237  cl_uint /*num_entries*/,
1238  cl_device_id * /*out_devices*/,
1239  cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
1240 
1241  static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
1242  __INIT_CL_EXT_FCN_PTR(clCreateSubDevicesEXT);
1243 
1244  cl_uint n = 0;
1245  cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
1246  if (err != CL_SUCCESS) {
1247  return detail::errHandler(err, __CREATE_SUB_DEVICES);
1248  }
1249 
1250  cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
1251  err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids, NULL);
1252  if (err != CL_SUCCESS) {
1253  return detail::errHandler(err, __CREATE_SUB_DEVICES);
1254  }
1255 
1256  devices->assign(&ids[0], &ids[n]);
1257  return CL_SUCCESS;
1258  }
1259 #endif
1260 };
1261 
1265 class Platform : public detail::Wrapper<cl_platform_id>
1266 {
1267 public:
1268  static const Platform null();
1269 
1270  Platform(cl_platform_id platform) { object_ = platform; }
1271 
1272  Platform() : detail::Wrapper<cl_type>() { }
1273 
1274  Platform(const Platform& platform) : detail::Wrapper<cl_type>(platform) { }
1275 
1276  Platform& operator = (const Platform& rhs)
1277  {
1278  if (this != &rhs) {
1280  }
1281  return *this;
1282  }
1283 
1284  cl_int getInfo(cl_platform_info name, STRING_CLASS* param) const
1285  {
1286  return detail::errHandler(
1287  detail::getInfo(&::clGetPlatformInfo, object_, name, param),
1288  __GET_PLATFORM_INFO_ERR);
1289  }
1290 
1291  template <cl_int name> typename
1293  getInfo(cl_int* err = NULL) const
1294  {
1295  typename detail::param_traits<
1296  detail::cl_platform_info, name>::param_type param;
1297  cl_int result = getInfo(name, &param);
1298  if (err != NULL) {
1299  *err = result;
1300  }
1301  return param;
1302  }
1303 
1304  cl_int getDevices(
1305  cl_device_type type,
1306  VECTOR_CLASS<Device>* devices) const
1307  {
1308  cl_uint n = 0;
1309  cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
1310  if (err != CL_SUCCESS) {
1311  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1312  }
1313 
1314  cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
1315  err = ::clGetDeviceIDs(object_, type, n, ids, NULL);
1316  if (err != CL_SUCCESS) {
1317  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1318  }
1319 
1320  devices->assign(&ids[0], &ids[n]);
1321  return CL_SUCCESS;
1322  }
1323 
1324 #if defined(USE_DX_INTEROP)
1325 
1348  cl_int getDevices(
1349  cl_d3d10_device_source_khr d3d_device_source,
1350  void * d3d_object,
1351  cl_d3d10_device_set_khr d3d_device_set,
1352  VECTOR_CLASS<Device>* devices) const
1353  {
1354  typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
1355  cl_platform_id platform,
1356  cl_d3d10_device_source_khr d3d_device_source,
1357  void * d3d_object,
1358  cl_d3d10_device_set_khr d3d_device_set,
1359  cl_uint num_entries,
1360  cl_device_id * devices,
1361  cl_uint* num_devices);
1362 
1363  static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
1364  __INIT_CL_EXT_FCN_PTR(clGetDeviceIDsFromD3D10KHR);
1365 
1366  cl_uint n = 0;
1367  cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
1368  object_,
1369  d3d_device_source,
1370  d3d_object,
1371  d3d_device_set,
1372  0,
1373  NULL,
1374  &n);
1375  if (err != CL_SUCCESS) {
1376  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1377  }
1378 
1379  cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
1380  err = pfn_clGetDeviceIDsFromD3D10KHR(
1381  object_,
1382  d3d_device_source,
1383  d3d_object,
1384  d3d_device_set,
1385  n,
1386  ids,
1387  NULL);
1388  if (err != CL_SUCCESS) {
1389  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
1390  }
1391 
1392  devices->assign(&ids[0], &ids[n]);
1393  return CL_SUCCESS;
1394  }
1395 #endif
1396 
1397  static cl_int get(
1398  VECTOR_CLASS<Platform>* platforms)
1399  {
1400  cl_uint n = 0;
1401  cl_int err = ::clGetPlatformIDs(0, NULL, &n);
1402  if (err != CL_SUCCESS) {
1403  return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
1404  }
1405 
1406  cl_platform_id* ids = (cl_platform_id*) alloca(
1407  n * sizeof(cl_platform_id));
1408  err = ::clGetPlatformIDs(n, ids, NULL);
1409  if (err != CL_SUCCESS) {
1410  return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
1411  }
1412 
1413  platforms->assign(&ids[0], &ids[n]);
1414  return CL_SUCCESS;
1415  }
1416 };
1417 
1418 static inline cl_int
1419 UnloadCompiler()
1420 {
1421  return ::clUnloadCompiler();
1422 }
1423 
1424 class Context : public detail::Wrapper<cl_context>
1425 {
1426 public:
1428  const VECTOR_CLASS<Device>& devices,
1429  cl_context_properties* properties = NULL,
1430  void (CL_CALLBACK * notifyFptr)(
1431  const char *,
1432  const void *,
1433  ::size_t,
1434  void *) = NULL,
1435  void* data = NULL,
1436  cl_int* err = NULL)
1437  {
1438  cl_int error;
1439  object_ = ::clCreateContext(
1440  properties, (cl_uint) devices.size(),
1441  (cl_device_id*) &devices.front(),
1442  notifyFptr, data, &error);
1443 
1444  detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
1445  if (err != NULL) {
1446  *err = error;
1447  }
1448  }
1449 
1451  cl_device_type type,
1452  cl_context_properties* properties = NULL,
1453  void (CL_CALLBACK * notifyFptr)(
1454  const char *,
1455  const void *,
1456  ::size_t,
1457  void *) = NULL,
1458  void* data = NULL,
1459  cl_int* err = NULL)
1460  {
1461  cl_int error;
1462  object_ = ::clCreateContextFromType(
1463  properties, type, notifyFptr, data, &error);
1464 
1465  detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
1466  if (err != NULL) {
1467  *err = error;
1468  }
1469  }
1470 
1471  Context() : detail::Wrapper<cl_type>() { }
1472 
1473  Context(const Context& context) : detail::Wrapper<cl_type>(context) { }
1474 
1475  Context& operator = (const Context& rhs)
1476  {
1477  if (this != &rhs) {
1479  }
1480  return *this;
1481  }
1482 
1483  template <typename T>
1484  cl_int getInfo(cl_context_info name, T* param) const
1485  {
1486  return detail::errHandler(
1487  detail::getInfo(&::clGetContextInfo, object_, name, param),
1488  __GET_CONTEXT_INFO_ERR);
1489  }
1490 
1491  template <cl_int name> typename
1493  getInfo(cl_int* err = NULL) const
1494  {
1495  typename detail::param_traits<
1496  detail::cl_context_info, name>::param_type param;
1497  cl_int result = getInfo(name, &param);
1498  if (err != NULL) {
1499  *err = result;
1500  }
1501  return param;
1502  }
1503 
1505  cl_mem_flags flags,
1506  cl_mem_object_type type,
1507  VECTOR_CLASS<ImageFormat>* formats) const
1508  {
1509  cl_uint numEntries;
1510  cl_int err = ::clGetSupportedImageFormats(
1511  object_,
1512  flags,
1513  type,
1514  0,
1515  NULL,
1516  &numEntries);
1517  if (err != CL_SUCCESS) {
1518  return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
1519  }
1520 
1521  ImageFormat* value = (ImageFormat*)
1522  alloca(numEntries * sizeof(ImageFormat));
1523  err = ::clGetSupportedImageFormats(
1524  object_,
1525  flags,
1526  type,
1527  numEntries,
1528  (cl_image_format*) value,
1529  NULL);
1530  if (err != CL_SUCCESS) {
1531  return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
1532  }
1533 
1534  formats->assign(&value[0], &value[numEntries]);
1535  return CL_SUCCESS;
1536  }
1537 };
1538 
1540 
1541 
1544 class Event : public detail::Wrapper<cl_event>
1545 {
1546 public:
1547  Event() : detail::Wrapper<cl_type>() { }
1548 
1549  Event(const Event& event) : detail::Wrapper<cl_type>(event) { }
1550 
1551  Event& operator = (const Event& rhs)
1552  {
1553  if (this != &rhs) {
1555  }
1556  return *this;
1557  }
1558 
1559  template <typename T>
1560  cl_int getInfo(cl_event_info name, T* param) const
1561  {
1562  return detail::errHandler(
1563  detail::getInfo(&::clGetEventInfo, object_, name, param),
1564  __GET_EVENT_INFO_ERR);
1565  }
1566 
1567  template <cl_int name> typename
1569  getInfo(cl_int* err = NULL) const
1570  {
1571  typename detail::param_traits<
1572  detail::cl_event_info, name>::param_type param;
1573  cl_int result = getInfo(name, &param);
1574  if (err != NULL) {
1575  *err = result;
1576  }
1577  return param;
1578  }
1579 
1580  template <typename T>
1581  cl_int getProfilingInfo(cl_profiling_info name, T* param) const
1582  {
1583  return detail::errHandler(detail::getInfo(
1584  &::clGetEventProfilingInfo, object_, name, param),
1585  __GET_EVENT_PROFILE_INFO_ERR);
1586  }
1587 
1588  template <cl_int name> typename
1590  getProfilingInfo(cl_int* err = NULL) const
1591  {
1592  typename detail::param_traits<
1593  detail::cl_profiling_info, name>::param_type param;
1594  cl_int result = getProfilingInfo(name, &param);
1595  if (err != NULL) {
1596  *err = result;
1597  }
1598  return param;
1599  }
1600 
1601  cl_int wait() const
1602  {
1603  return detail::errHandler(
1604  ::clWaitForEvents(1, &object_),
1605  __WAIT_FOR_EVENTS_ERR);
1606  }
1607 
1608 #if defined(CL_VERSION_1_1)
1609  cl_int setCallback(
1610  cl_int type,
1611  void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *),
1612  void * user_data = NULL)
1613  {
1614  return detail::errHandler(
1615  ::clSetEventCallback(
1616  object_,
1617  type,
1618  pfn_notify,
1619  user_data),
1620  __SET_EVENT_CALLBACK_ERR);
1621  }
1622 #endif
1623 
1624  static cl_int
1625  waitForEvents(const VECTOR_CLASS<Event>& events)
1626  {
1627  return detail::errHandler(
1628  ::clWaitForEvents(
1629  (cl_uint) events.size(), (cl_event*)&events.front()),
1630  __WAIT_FOR_EVENTS_ERR);
1631  }
1632 };
1633 
1635 
1636 #if defined(CL_VERSION_1_1)
1637 
1640 class UserEvent : public Event
1641 {
1642 public:
1643  UserEvent(
1644  const Context& context,
1645  cl_int * err = NULL)
1646  {
1647  cl_int error;
1648  object_ = ::clCreateUserEvent(
1649  context(),
1650  &error);
1651 
1652  detail::errHandler(error, __CREATE_USER_EVENT_ERR);
1653  if (err != NULL) {
1654  *err = error;
1655  }
1656  }
1657 
1658  UserEvent() : Event() { }
1659 
1660  UserEvent(const UserEvent& event) : Event(event) { }
1661 
1662  UserEvent& operator = (const UserEvent& rhs)
1663  {
1664  if (this != &rhs) {
1665  Event::operator=(rhs);
1666  }
1667  return *this;
1668  }
1669 
1670  cl_int setStatus(cl_int status)
1671  {
1672  return detail::errHandler(
1673  ::clSetUserEventStatus(object_,status),
1674  __SET_USER_EVENT_STATUS_ERR);
1675  }
1676 };
1677 #endif
1678 
1679 inline static cl_int
1680 WaitForEvents(const VECTOR_CLASS<Event>& events)
1681 {
1682  return detail::errHandler(
1683  ::clWaitForEvents(
1684  (cl_uint) events.size(), (cl_event*)&events.front()),
1685  __WAIT_FOR_EVENTS_ERR);
1686 }
1687 
1691 class Memory : public detail::Wrapper<cl_mem>
1692 {
1693 public:
1694  Memory() : detail::Wrapper<cl_type>() { }
1695 
1696  Memory(const Memory& memory) : detail::Wrapper<cl_type>(memory) { }
1697 
1698  Memory& operator = (const Memory& rhs)
1699  {
1700  if (this != &rhs) {
1702  }
1703  return *this;
1704  }
1705 
1706  template <typename T>
1707  cl_int getInfo(cl_mem_info name, T* param) const
1708  {
1709  return detail::errHandler(
1710  detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
1711  __GET_MEM_OBJECT_INFO_ERR);
1712  }
1713 
1714  template <cl_int name> typename
1716  getInfo(cl_int* err = NULL) const
1717  {
1718  typename detail::param_traits<
1719  detail::cl_mem_info, name>::param_type param;
1720  cl_int result = getInfo(name, &param);
1721  if (err != NULL) {
1722  *err = result;
1723  }
1724  return param;
1725  }
1726 
1727 #if defined(CL_VERSION_1_1)
1728  cl_int setDestructorCallback(
1729  void (CL_CALLBACK * pfn_notify)(cl_mem, void *),
1730  void * user_data = NULL)
1731  {
1732  return detail::errHandler(
1733  ::clSetMemObjectDestructorCallback(
1734  object_,
1735  pfn_notify,
1736  user_data),
1737  __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
1738  }
1739 #endif
1740 
1741 };
1742 
1744 
1745 
1748 class Buffer : public Memory
1749 {
1750 public:
1752  const Context& context,
1753  cl_mem_flags flags,
1754  ::size_t size,
1755  void* host_ptr = NULL,
1756  cl_int* err = NULL)
1757  {
1758  cl_int error;
1759  object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
1760 
1761  detail::errHandler(error, __CREATE_BUFFER_ERR);
1762  if (err != NULL) {
1763  *err = error;
1764  }
1765  }
1766 
1767  Buffer() : Memory() { }
1768 
1769  Buffer(const Buffer& buffer) : Memory(buffer) { }
1770 
1771  Buffer& operator = (const Buffer& rhs)
1772  {
1773  if (this != &rhs) {
1774  Memory::operator=(rhs);
1775  }
1776  return *this;
1777  }
1778 
1779 #if defined(CL_VERSION_1_1)
1780  Buffer createSubBuffer(
1781  cl_mem_flags flags,
1782  cl_buffer_create_type buffer_create_type,
1783  const void * buffer_create_info,
1784  cl_int * err = NULL)
1785  {
1786  Buffer result;
1787  cl_int error;
1788  result.object_ = ::clCreateSubBuffer(
1789  object_,
1790  flags,
1791  buffer_create_type,
1792  buffer_create_info,
1793  &error);
1794 
1795  detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
1796  if (err != NULL) {
1797  *err = error;
1798  }
1799 
1800  return result;
1801  }
1802 #endif
1803 };
1804 
1805 #if defined (USE_DX_INTEROP)
1806 class BufferD3D10 : public Buffer
1807 {
1808 public:
1809  typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
1810  cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
1811  cl_int* errcode_ret);
1812 
1813  BufferD3D10(
1814  const Context& context,
1815  cl_mem_flags flags,
1816  ID3D10Buffer* bufobj,
1817  cl_int * err = NULL)
1818  {
1819  static PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR = NULL;
1820  __INIT_CL_EXT_FCN_PTR(clCreateFromD3D10BufferKHR);
1821 
1822  cl_int error;
1823  object_ = pfn_clCreateFromD3D10BufferKHR(
1824  context(),
1825  flags,
1826  bufobj,
1827  &error);
1828 
1829  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
1830  if (err != NULL) {
1831  *err = error;
1832  }
1833  }
1834 
1835  BufferD3D10() : Buffer() { }
1836 
1837  BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) { }
1838 
1839  BufferD3D10& operator = (const BufferD3D10& rhs)
1840  {
1841  if (this != &rhs) {
1842  Buffer::operator=(rhs);
1843  }
1844  return *this;
1845  }
1846 };
1847 #endif
1848 
1852 class BufferGL : public Buffer
1853 {
1854 public:
1856  const Context& context,
1857  cl_mem_flags flags,
1858  GLuint bufobj,
1859  cl_int * err = NULL)
1860  {
1861  cl_int error;
1862  object_ = ::clCreateFromGLBuffer(
1863  context(),
1864  flags,
1865  bufobj,
1866  &error);
1867 
1868  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
1869  if (err != NULL) {
1870  *err = error;
1871  }
1872  }
1873 
1874  BufferGL() : Buffer() { }
1875 
1876  BufferGL(const BufferGL& buffer) : Buffer(buffer) { }
1877 
1878  BufferGL& operator = (const BufferGL& rhs)
1879  {
1880  if (this != &rhs) {
1881  Buffer::operator=(rhs);
1882  }
1883  return *this;
1884  }
1885 
1887  cl_gl_object_type *type,
1888  GLuint * gl_object_name)
1889  {
1890  return detail::errHandler(
1891  ::clGetGLObjectInfo(object_,type,gl_object_name),
1892  __GET_GL_OBJECT_INFO_ERR);
1893  }
1894 };
1895 
1899 class BufferRenderGL : public Buffer
1900 {
1901 public:
1903  const Context& context,
1904  cl_mem_flags flags,
1905  GLuint bufobj,
1906  cl_int * err = NULL)
1907  {
1908  cl_int error;
1909  object_ = ::clCreateFromGLRenderbuffer(
1910  context(),
1911  flags,
1912  bufobj,
1913  &error);
1914 
1915  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
1916  if (err != NULL) {
1917  *err = error;
1918  }
1919  }
1920 
1922 
1923  BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) { }
1924 
1925  BufferRenderGL& operator = (const BufferRenderGL& rhs)
1926  {
1927  if (this != &rhs) {
1928  Buffer::operator=(rhs);
1929  }
1930  return *this;
1931  }
1932 
1934  cl_gl_object_type *type,
1935  GLuint * gl_object_name)
1936  {
1937  return detail::errHandler(
1938  ::clGetGLObjectInfo(object_,type,gl_object_name),
1939  __GET_GL_OBJECT_INFO_ERR);
1940  }
1941 };
1942 
1946 class Image : public Memory
1947 {
1948 protected:
1949  Image() : Memory() { }
1950 
1951  Image(const Image& image) : Memory(image) { }
1952 
1953  Image& operator = (const Image& rhs)
1954  {
1955  if (this != &rhs) {
1956  Memory::operator=(rhs);
1957  }
1958  return *this;
1959  }
1960 public:
1961  template <typename T>
1962  cl_int getImageInfo(cl_image_info name, T* param) const
1963  {
1964  return detail::errHandler(
1965  detail::getInfo(&::clGetImageInfo, object_, name, param),
1966  __GET_IMAGE_INFO_ERR);
1967  }
1968 
1969  template <cl_int name> typename
1971  getImageInfo(cl_int* err = NULL) const
1972  {
1973  typename detail::param_traits<
1974  detail::cl_image_info, name>::param_type param;
1975  cl_int result = getImageInfo(name, &param);
1976  if (err != NULL) {
1977  *err = result;
1978  }
1979  return param;
1980  }
1981 };
1982 
1986 class Image2D : public Image
1987 {
1988 public:
1990  const Context& context,
1991  cl_mem_flags flags,
1993  ::size_t width,
1994  ::size_t height,
1995  ::size_t row_pitch = 0,
1996  void* host_ptr = NULL,
1997  cl_int* err = NULL)
1998  {
1999  cl_int error;
2000  object_ = ::clCreateImage2D(
2001  context(), flags,&format, width, height, row_pitch, host_ptr, &error);
2002 
2003  detail::errHandler(error, __CREATE_IMAGE2D_ERR);
2004  if (err != NULL) {
2005  *err = error;
2006  }
2007  }
2008 
2009  Image2D() { }
2010 
2011  Image2D(const Image2D& image2D) : Image(image2D) { }
2012 
2013  Image2D& operator = (const Image2D& rhs)
2014  {
2015  if (this != &rhs) {
2016  Image::operator=(rhs);
2017  }
2018  return *this;
2019  }
2020 };
2021 
2025 class Image2DGL : public Image2D
2026 {
2027 public:
2029  const Context& context,
2030  cl_mem_flags flags,
2031  GLenum target,
2032  GLint miplevel,
2033  GLuint texobj,
2034  cl_int * err = NULL)
2035  {
2036  cl_int error;
2037  object_ = ::clCreateFromGLTexture2D(
2038  context(),
2039  flags,
2040  target,
2041  miplevel,
2042  texobj,
2043  &error);
2044 
2045  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
2046  if (err != NULL) {
2047  *err = error;
2048  }
2049  }
2050 
2051  Image2DGL() : Image2D() { }
2052 
2053  Image2DGL(const Image2DGL& image) : Image2D(image) { }
2054 
2055  Image2DGL& operator = (const Image2DGL& rhs)
2056  {
2057  if (this != &rhs) {
2058  Image2D::operator=(rhs);
2059  }
2060  return *this;
2061  }
2062 };
2063 
2067 class Image3D : public Image
2068 {
2069 public:
2071  const Context& context,
2072  cl_mem_flags flags,
2074  ::size_t width,
2075  ::size_t height,
2076  ::size_t depth,
2077  ::size_t row_pitch = 0,
2078  ::size_t slice_pitch = 0,
2079  void* host_ptr = NULL,
2080  cl_int* err = NULL)
2081  {
2082  cl_int error;
2083  object_ = ::clCreateImage3D(
2084  context(), flags, &format, width, height, depth, row_pitch,
2085  slice_pitch, host_ptr, &error);
2086 
2087  detail::errHandler(error, __CREATE_IMAGE3D_ERR);
2088  if (err != NULL) {
2089  *err = error;
2090  }
2091  }
2092 
2093  Image3D() { }
2094 
2095  Image3D(const Image3D& image3D) : Image(image3D) { }
2096 
2097  Image3D& operator = (const Image3D& rhs)
2098  {
2099  if (this != &rhs) {
2100  Image::operator=(rhs);
2101  }
2102  return *this;
2103  }
2104 };
2105 
2109 class Image3DGL : public Image3D
2110 {
2111 public:
2113  const Context& context,
2114  cl_mem_flags flags,
2115  GLenum target,
2116  GLint miplevel,
2117  GLuint texobj,
2118  cl_int * err = NULL)
2119  {
2120  cl_int error;
2121  object_ = ::clCreateFromGLTexture3D(
2122  context(),
2123  flags,
2124  target,
2125  miplevel,
2126  texobj,
2127  &error);
2128 
2129  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
2130  if (err != NULL) {
2131  *err = error;
2132  }
2133  }
2134 
2135  Image3DGL() : Image3D() { }
2136 
2137  Image3DGL(const Image3DGL& image) : Image3D(image) { }
2138 
2139  Image3DGL& operator = (const Image3DGL& rhs)
2140  {
2141  if (this != &rhs) {
2142  Image3D::operator=(rhs);
2143  }
2144  return *this;
2145  }
2146 };
2147 
2151 class Sampler : public detail::Wrapper<cl_sampler>
2152 {
2153 public:
2154  Sampler() { }
2155 
2157  const Context& context,
2158  cl_bool normalized_coords,
2159  cl_addressing_mode addressing_mode,
2160  cl_filter_mode filter_mode,
2161  cl_int* err = NULL)
2162  {
2163  cl_int error;
2164  object_ = ::clCreateSampler(
2165  context(),
2166  normalized_coords,
2167  addressing_mode,
2168  filter_mode,
2169  &error);
2170 
2171  detail::errHandler(error, __CREATE_SAMPLER_ERR);
2172  if (err != NULL) {
2173  *err = error;
2174  }
2175  }
2176 
2177  Sampler(const Sampler& sampler) : detail::Wrapper<cl_type>(sampler) { }
2178 
2179  Sampler& operator = (const Sampler& rhs)
2180  {
2181  if (this != &rhs) {
2183  }
2184  return *this;
2185  }
2186 
2187  template <typename T>
2188  cl_int getInfo(cl_sampler_info name, T* param) const
2189  {
2190  return detail::errHandler(
2191  detail::getInfo(&::clGetSamplerInfo, object_, name, param),
2192  __GET_SAMPLER_INFO_ERR);
2193  }
2194 
2195  template <cl_int name> typename
2197  getInfo(cl_int* err = NULL) const
2198  {
2199  typename detail::param_traits<
2200  detail::cl_sampler_info, name>::param_type param;
2201  cl_int result = getInfo(name, &param);
2202  if (err != NULL) {
2203  *err = result;
2204  }
2205  return param;
2206  }
2207 };
2208 
2210 
2211 class Program;
2212 class CommandQueue;
2213 class Kernel;
2214 
2218 class NDRange
2219 {
2220 private:
2221  size_t<3> sizes_;
2222  cl_uint dimensions_;
2223 
2224 public:
2226  : dimensions_(0)
2227  { }
2228 
2229  NDRange(::size_t size0)
2230  : dimensions_(1)
2231  {
2232  sizes_.push_back(size0);
2233  }
2234 
2235  NDRange(::size_t size0, ::size_t size1)
2236  : dimensions_(2)
2237  {
2238  sizes_.push_back(size0);
2239  sizes_.push_back(size1);
2240  }
2241 
2242  NDRange(::size_t size0, ::size_t size1, ::size_t size2)
2243  : dimensions_(3)
2244  {
2245  sizes_.push_back(size0);
2246  sizes_.push_back(size1);
2247  sizes_.push_back(size2);
2248  }
2249 
2250  operator const ::size_t*() const { return (const ::size_t*) sizes_; }
2251  ::size_t dimensions() const { return dimensions_; }
2252 };
2253 
2254 static const NDRange NullRange;
2255 
2260 struct LocalSpaceArg
2261 {
2262  ::size_t size_;
2263 };
2264 
2265 namespace detail {
2266 
2267 template <typename T>
2268 struct KernelArgumentHandler
2269 {
2270  static ::size_t size(const T&) { return sizeof(T); }
2271  static T* ptr(T& value) { return &value; }
2272 };
2273 
2274 template <>
2275 struct KernelArgumentHandler<LocalSpaceArg>
2276 {
2277  static ::size_t size(const LocalSpaceArg& value) { return value.size_; }
2278  static void* ptr(LocalSpaceArg&) { return NULL; }
2279 };
2280 
2281 }
2283 
2284 inline LocalSpaceArg
2285 __local(::size_t size)
2286 {
2287  LocalSpaceArg ret = { size };
2288  return ret;
2289 }
2290 
2291 class KernelFunctor;
2292 
2296 class Kernel : public detail::Wrapper<cl_kernel>
2297 {
2298 public:
2299  inline Kernel(const Program& program, const char* name, cl_int* err = NULL);
2300 
2301  Kernel() { }
2302 
2303  Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) { }
2304 
2305  Kernel& operator = (const Kernel& rhs)
2306  {
2307  if (this != &rhs) {
2309  }
2310  return *this;
2311  }
2312 
2313  template <typename T>
2314  cl_int getInfo(cl_kernel_info name, T* param) const
2315  {
2316  return detail::errHandler(
2317  detail::getInfo(&::clGetKernelInfo, object_, name, param),
2318  __GET_KERNEL_INFO_ERR);
2319  }
2320 
2321  template <cl_int name> typename
2323  getInfo(cl_int* err = NULL) const
2324  {
2325  typename detail::param_traits<
2326  detail::cl_kernel_info, name>::param_type param;
2327  cl_int result = getInfo(name, &param);
2328  if (err != NULL) {
2329  *err = result;
2330  }
2331  return param;
2332  }
2333 
2334  template <typename T>
2336  const Device& device, cl_kernel_work_group_info name, T* param) const
2337  {
2338  return detail::errHandler(
2340  &::clGetKernelWorkGroupInfo, object_, device(), name, param),
2341  __GET_KERNEL_WORK_GROUP_INFO_ERR);
2342  }
2343 
2344  template <cl_int name> typename
2346  getWorkGroupInfo(const Device& device, cl_int* err = NULL) const
2347  {
2348  typename detail::param_traits<
2349  detail::cl_kernel_work_group_info, name>::param_type param;
2350  cl_int result = getWorkGroupInfo(device, name, &param);
2351  if (err != NULL) {
2352  *err = result;
2353  }
2354  return param;
2355  }
2356 
2357  template <typename T>
2358  cl_int setArg(cl_uint index, T value)
2359  {
2360  return detail::errHandler(
2361  ::clSetKernelArg(
2362  object_,
2363  index,
2366  __SET_KERNEL_ARGS_ERR);
2367  }
2368 
2369  cl_int setArg(cl_uint index, ::size_t size, void* argPtr)
2370  {
2371  return detail::errHandler(
2372  ::clSetKernelArg(object_, index, size, argPtr),
2373  __SET_KERNEL_ARGS_ERR);
2374  }
2375 
2376  KernelFunctor bind(
2377  const CommandQueue& queue,
2378  const NDRange& offset,
2379  const NDRange& global,
2380  const NDRange& local);
2381 
2382  KernelFunctor bind(
2383  const CommandQueue& queue,
2384  const NDRange& global,
2385  const NDRange& local);
2386 };
2387 
2389 
2390 
2393 class Program : public detail::Wrapper<cl_program>
2394 {
2395 public:
2396  typedef VECTOR_CLASS<std::pair<const void*, ::size_t> > Binaries;
2397  typedef VECTOR_CLASS<std::pair<const char*, ::size_t> > Sources;
2398 
2400  const Context& context,
2401  const Sources& sources,
2402  cl_int* err = NULL)
2403  {
2404  cl_int error;
2405 
2406  const ::size_t n = (::size_t)sources.size();
2407  ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t));
2408  const char** strings = (const char**) alloca(n * sizeof(const char*));
2409 
2410  for (::size_t i = 0; i < n; ++i) {
2411  strings[i] = sources[(int)i].first;
2412  lengths[i] = sources[(int)i].second;
2413  }
2414 
2415  object_ = ::clCreateProgramWithSource(
2416  context(), (cl_uint)n, strings, lengths, &error);
2417 
2418  detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
2419  if (err != NULL) {
2420  *err = error;
2421  }
2422  }
2423 
2425  const Context& context,
2426  const VECTOR_CLASS<Device>& devices,
2427  const Binaries& binaries,
2428  VECTOR_CLASS<cl_int>* binaryStatus = NULL,
2429  cl_int* err = NULL)
2430  {
2431  cl_int error;
2432  const ::size_t n = binaries.size();
2433  ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t));
2434  const unsigned char** images = (const unsigned char**) alloca(n * sizeof(const void*));
2435 
2436  for (::size_t i = 0; i < n; ++i) {
2437  images[i] = (const unsigned char*)binaries[(int)i].first;
2438  lengths[i] = binaries[(int)i].second;
2439  }
2440 
2441  object_ = ::clCreateProgramWithBinary(
2442  context(), (cl_uint) devices.size(),
2443  (cl_device_id*)&devices.front(),
2444  lengths, images, binaryStatus != NULL
2445  ? (cl_int*) &binaryStatus->front()
2446  : NULL, &error);
2447 
2448  detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
2449  if (err != NULL) {
2450  *err = error;
2451  }
2452  }
2453 
2454  Program() { }
2455 
2456  Program(const Program& program) : detail::Wrapper<cl_type>(program) { }
2457 
2458  Program& operator = (const Program& rhs)
2459  {
2460  if (this != &rhs) {
2462  }
2463  return *this;
2464  }
2465 
2466  cl_int build(
2467  const VECTOR_CLASS<Device>& devices,
2468  const char* options = NULL,
2469  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
2470  void* data = NULL) const
2471  {
2472  return detail::errHandler(
2473  ::clBuildProgram(
2474  object_,
2475  (cl_uint)
2476  devices.size(),
2477  (cl_device_id*)&devices.front(),
2478  options,
2479  notifyFptr,
2480  data),
2481  __BUILD_PROGRAM_ERR);
2482  }
2483 
2484  template <typename T>
2485  cl_int getInfo(cl_program_info name, T* param) const
2486  {
2487  return detail::errHandler(
2488  detail::getInfo(&::clGetProgramInfo, object_, name, param),
2489  __GET_PROGRAM_INFO_ERR);
2490  }
2491 
2492  template <cl_int name> typename
2494  getInfo(cl_int* err = NULL) const
2495  {
2496  typename detail::param_traits<
2497  detail::cl_program_info, name>::param_type param;
2498  cl_int result = getInfo(name, &param);
2499  if (err != NULL) {
2500  *err = result;
2501  }
2502  return param;
2503  }
2504 
2505  template <typename T>
2507  const Device& device, cl_program_build_info name, T* param) const
2508  {
2509  return detail::errHandler(
2511  &::clGetProgramBuildInfo, object_, device(), name, param),
2512  __GET_PROGRAM_BUILD_INFO_ERR);
2513  }
2514 
2515  template <cl_int name> typename
2517  getBuildInfo(const Device& device, cl_int* err = NULL) const
2518  {
2519  typename detail::param_traits<
2520  detail::cl_program_build_info, name>::param_type param;
2521  cl_int result = getBuildInfo(device, name, &param);
2522  if (err != NULL) {
2523  *err = result;
2524  }
2525  return param;
2526  }
2527 
2528  cl_int createKernels(VECTOR_CLASS<Kernel>* kernels)
2529  {
2530  cl_uint numKernels;
2531  cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
2532  if (err != CL_SUCCESS) {
2533  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
2534  }
2535 
2536  Kernel* value = (Kernel*) alloca(numKernels * sizeof(Kernel));
2537  err = ::clCreateKernelsInProgram(
2538  object_, numKernels, (cl_kernel*) value, NULL);
2539  if (err != CL_SUCCESS) {
2540  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
2541  }
2542 
2543  kernels->assign(&value[0], &value[numKernels]);
2544  return CL_SUCCESS;
2545  }
2546 };
2547 
2549 
2550 inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
2551 {
2552  cl_int error;
2553 
2554  object_ = ::clCreateKernel(program(), name, &error);
2555  detail::errHandler(error, __CREATE_KERNEL_ERR);
2556 
2557  if (err != NULL) {
2558  *err = error;
2559  }
2560 
2561 }
2562 
2566 class CommandQueue : public detail::Wrapper<cl_command_queue>
2567 {
2568 public:
2570  const Context& context,
2571  const Device& device,
2572  cl_command_queue_properties properties = 0,
2573  cl_int* err = NULL)
2574  {
2575  cl_int error;
2576  object_ = ::clCreateCommandQueue(
2577  context(), device(), properties, &error);
2578 
2579  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
2580  if (err != NULL) {
2581  *err = error;
2582  }
2583  }
2584 
2586 
2587  CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
2588 
2589  CommandQueue& operator = (const CommandQueue& rhs)
2590  {
2591  if (this != &rhs) {
2593  }
2594  return *this;
2595  }
2596 
2597  template <typename T>
2598  cl_int getInfo(cl_command_queue_info name, T* param) const
2599  {
2600  return detail::errHandler(
2602  &::clGetCommandQueueInfo, object_, name, param),
2603  __GET_COMMAND_QUEUE_INFO_ERR);
2604  }
2605 
2606  template <cl_int name> typename
2608  getInfo(cl_int* err = NULL) const
2609  {
2610  typename detail::param_traits<
2611  detail::cl_command_queue_info, name>::param_type param;
2612  cl_int result = getInfo(name, &param);
2613  if (err != NULL) {
2614  *err = result;
2615  }
2616  return param;
2617  }
2618 
2620  const Buffer& buffer,
2621  cl_bool blocking,
2622  ::size_t offset,
2623  ::size_t size,
2624  void* ptr,
2625  const VECTOR_CLASS<Event>* events = NULL,
2626  Event* event = NULL) const
2627  {
2628  return detail::errHandler(
2629  ::clEnqueueReadBuffer(
2630  object_, buffer(), blocking, offset, size,
2631  ptr,
2632  (events != NULL) ? (cl_uint) events->size() : 0,
2633  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2634  (cl_event*) event),
2635  __ENQUEUE_READ_BUFFER_ERR);
2636  }
2637 
2639  const Buffer& buffer,
2640  cl_bool blocking,
2641  ::size_t offset,
2642  ::size_t size,
2643  const void* ptr,
2644  const VECTOR_CLASS<Event>* events = NULL,
2645  Event* event = NULL) const
2646  {
2647  return detail::errHandler(
2648  ::clEnqueueWriteBuffer(
2649  object_, buffer(), blocking, offset, size,
2650  ptr,
2651  (events != NULL) ? (cl_uint) events->size() : 0,
2652  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2653  (cl_event*) event),
2654  __ENQUEUE_WRITE_BUFFER_ERR);
2655  }
2656 
2658  const Buffer& buffer,
2659  const void* ptr,
2660  ::size_t pattern_size,
2661  ::size_t offset,
2662  ::size_t size,
2663  const VECTOR_CLASS<Event>* events = NULL,
2664  Event* event = NULL) const
2665  {
2666  return detail::errHandler(
2667  ::clEnqueueFillBuffer(
2668  object_, buffer(), ptr, pattern_size, offset, size,
2669  (events != NULL) ? (cl_uint) events->size() : 0,
2670  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2671  (cl_event*) event),
2672  __ENQUEUE_FILL_BUFFER_ERR);
2673  }
2674 
2676  const Buffer& src,
2677  const Buffer& dst,
2678  ::size_t src_offset,
2679  ::size_t dst_offset,
2680  ::size_t size,
2681  const VECTOR_CLASS<Event>* events = NULL,
2682  Event* event = NULL) const
2683  {
2684  return detail::errHandler(
2685  ::clEnqueueCopyBuffer(
2686  object_, src(), dst(), src_offset, dst_offset, size,
2687  (events != NULL) ? (cl_uint) events->size() : 0,
2688  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2689  (cl_event*) event),
2690  __ENQEUE_COPY_BUFFER_ERR);
2691  }
2692 
2693 #if defined(CL_VERSION_1_1)
2694  cl_int enqueueReadBufferRect(
2695  const Buffer& buffer,
2696  cl_bool blocking,
2697  const size_t<3>& buffer_offset,
2698  const size_t<3>& host_offset,
2699  const size_t<3>& region,
2700  ::size_t buffer_row_pitch,
2701  ::size_t buffer_slice_pitch,
2702  ::size_t host_row_pitch,
2703  ::size_t host_slice_pitch,
2704  void *ptr,
2705  const VECTOR_CLASS<Event>* events = NULL,
2706  Event* event = NULL) const
2707  {
2708  return detail::errHandler(
2709  ::clEnqueueReadBufferRect(
2710  object_,
2711  buffer(),
2712  blocking,
2713  (const ::size_t *)buffer_offset,
2714  (const ::size_t *)host_offset,
2715  (const ::size_t *)region,
2716  buffer_row_pitch,
2717  buffer_slice_pitch,
2718  host_row_pitch,
2719  host_slice_pitch,
2720  ptr,
2721  (events != NULL) ? (cl_uint) events->size() : 0,
2722  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2723  (cl_event*) event),
2724  __ENQUEUE_READ_BUFFER_RECT_ERR);
2725  }
2726 
2727 
2728  cl_int enqueueWriteBufferRect(
2729  const Buffer& buffer,
2730  cl_bool blocking,
2731  const size_t<3>& buffer_offset,
2732  const size_t<3>& host_offset,
2733  const size_t<3>& region,
2734  ::size_t buffer_row_pitch,
2735  ::size_t buffer_slice_pitch,
2736  ::size_t host_row_pitch,
2737  ::size_t host_slice_pitch,
2738  void *ptr,
2739  const VECTOR_CLASS<Event>* events = NULL,
2740  Event* event = NULL) const
2741  {
2742  return detail::errHandler(
2743  ::clEnqueueWriteBufferRect(
2744  object_,
2745  buffer(),
2746  blocking,
2747  (const ::size_t *)buffer_offset,
2748  (const ::size_t *)host_offset,
2749  (const ::size_t *)region,
2750  buffer_row_pitch,
2751  buffer_slice_pitch,
2752  host_row_pitch,
2753  host_slice_pitch,
2754  ptr,
2755  (events != NULL) ? (cl_uint) events->size() : 0,
2756  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2757  (cl_event*) event),
2758  __ENQUEUE_WRITE_BUFFER_RECT_ERR);
2759  }
2760 
2761  cl_int enqueueCopyBufferRect(
2762  const Buffer& src,
2763  const Buffer& dst,
2764  const size_t<3>& src_origin,
2765  const size_t<3>& dst_origin,
2766  const size_t<3>& region,
2767  ::size_t src_row_pitch,
2768  ::size_t src_slice_pitch,
2769  ::size_t dst_row_pitch,
2770  ::size_t dst_slice_pitch,
2771  const VECTOR_CLASS<Event>* events = NULL,
2772  Event* event = NULL) const
2773  {
2774  return detail::errHandler(
2775  ::clEnqueueCopyBufferRect(
2776  object_,
2777  src(),
2778  dst(),
2779  (const ::size_t *)src_origin,
2780  (const ::size_t *)dst_origin,
2781  (const ::size_t *)region,
2782  src_row_pitch,
2783  src_slice_pitch,
2784  dst_row_pitch,
2785  dst_slice_pitch,
2786  (events != NULL) ? (cl_uint) events->size() : 0,
2787  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2788  (cl_event*) event),
2789  __ENQEUE_COPY_BUFFER_RECT_ERR);
2790  }
2791 #endif
2792 
2794  const Image& image,
2795  cl_bool blocking,
2796  const size_t<3>& origin,
2797  const size_t<3>& region,
2798  ::size_t row_pitch,
2799  ::size_t slice_pitch,
2800  void* ptr,
2801  const VECTOR_CLASS<Event>* events = NULL,
2802  Event* event = NULL) const
2803  {
2804  return detail::errHandler(
2805  ::clEnqueueReadImage(
2806  object_, image(), blocking, (const ::size_t *) origin,
2807  (const ::size_t *) region, row_pitch, slice_pitch, ptr,
2808  (events != NULL) ? (cl_uint) events->size() : 0,
2809  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2810  (cl_event*) event),
2811  __ENQUEUE_READ_IMAGE_ERR);
2812  }
2813 
2815  const Image& image,
2816  cl_bool blocking,
2817  const size_t<3>& origin,
2818  const size_t<3>& region,
2819  ::size_t row_pitch,
2820  ::size_t slice_pitch,
2821  void* ptr,
2822  const VECTOR_CLASS<Event>* events = NULL,
2823  Event* event = NULL) const
2824  {
2825  return detail::errHandler(
2826  ::clEnqueueWriteImage(
2827  object_, image(), blocking, (const ::size_t *) origin,
2828  (const ::size_t *) region, row_pitch, slice_pitch, ptr,
2829  (events != NULL) ? (cl_uint) events->size() : 0,
2830  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2831  (cl_event*) event),
2832  __ENQUEUE_WRITE_IMAGE_ERR);
2833  }
2834 
2836  const Image& src,
2837  const Image& dst,
2838  const size_t<3>& src_origin,
2839  const size_t<3>& dst_origin,
2840  const size_t<3>& region,
2841  const VECTOR_CLASS<Event>* events = NULL,
2842  Event* event = NULL) const
2843  {
2844  return detail::errHandler(
2845  ::clEnqueueCopyImage(
2846  object_, src(), dst(), (const ::size_t *) src_origin,
2847  (const ::size_t *)dst_origin, (const ::size_t *) region,
2848  (events != NULL) ? (cl_uint) events->size() : 0,
2849  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2850  (cl_event*) event),
2851  __ENQUEUE_COPY_IMAGE_ERR);
2852  }
2853 
2855  const Image& src,
2856  const Buffer& dst,
2857  const size_t<3>& src_origin,
2858  const size_t<3>& region,
2859  ::size_t dst_offset,
2860  const VECTOR_CLASS<Event>* events = NULL,
2861  Event* event = NULL) const
2862  {
2863  return detail::errHandler(
2864  ::clEnqueueCopyImageToBuffer(
2865  object_, src(), dst(), (const ::size_t *) src_origin,
2866  (const ::size_t *) region, dst_offset,
2867  (events != NULL) ? (cl_uint) events->size() : 0,
2868  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2869  (cl_event*) event),
2870  __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
2871  }
2872 
2874  const Buffer& src,
2875  const Image& dst,
2876  ::size_t src_offset,
2877  const size_t<3>& dst_origin,
2878  const size_t<3>& region,
2879  const VECTOR_CLASS<Event>* events = NULL,
2880  Event* event = NULL) const
2881  {
2882  return detail::errHandler(
2883  ::clEnqueueCopyBufferToImage(
2884  object_, src(), dst(), src_offset,
2885  (const ::size_t *) dst_origin, (const ::size_t *) region,
2886  (events != NULL) ? (cl_uint) events->size() : 0,
2887  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2888  (cl_event*) event),
2889  __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
2890  }
2891 
2893  const Buffer& buffer,
2894  cl_bool blocking,
2895  cl_map_flags flags,
2896  ::size_t offset,
2897  ::size_t size,
2898  const VECTOR_CLASS<Event>* events = NULL,
2899  Event* event = NULL,
2900  cl_int* err = NULL) const
2901  {
2902  cl_int error;
2903  void * result = ::clEnqueueMapBuffer(
2904  object_, buffer(), blocking, flags, offset, size,
2905  (events != NULL) ? (cl_uint) events->size() : 0,
2906  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2907  (cl_event*) event,
2908  &error);
2909 
2910  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
2911  if (err != NULL) {
2912  *err = error;
2913  }
2914  return result;
2915  }
2916 
2918  const Image& buffer,
2919  cl_bool blocking,
2920  cl_map_flags flags,
2921  const size_t<3>& origin,
2922  const size_t<3>& region,
2923  ::size_t * row_pitch,
2924  ::size_t * slice_pitch,
2925  const VECTOR_CLASS<Event>* events = NULL,
2926  Event* event = NULL,
2927  cl_int* err = NULL) const
2928  {
2929  cl_int error;
2930  void * result = ::clEnqueueMapImage(
2931  object_, buffer(), blocking, flags,
2932  (const ::size_t *) origin, (const ::size_t *) region,
2933  row_pitch, slice_pitch,
2934  (events != NULL) ? (cl_uint) events->size() : 0,
2935  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2936  (cl_event*) event,
2937  &error);
2938 
2939  detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
2940  if (err != NULL) {
2941  *err = error;
2942  }
2943  return result;
2944  }
2945 
2947  const Memory& memory,
2948  void* mapped_ptr,
2949  const VECTOR_CLASS<Event>* events = NULL,
2950  Event* event = NULL) const
2951  {
2952  return detail::errHandler(
2953  ::clEnqueueUnmapMemObject(
2954  object_, memory(), mapped_ptr,
2955  (events != NULL) ? (cl_uint) events->size() : 0,
2956  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2957  (cl_event*) event),
2958  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
2959  }
2960 
2962  const Kernel& kernel,
2963  const NDRange& offset,
2964  const NDRange& global,
2965  const NDRange& local,
2966  const VECTOR_CLASS<Event>* events = NULL,
2967  Event* event = NULL) const
2968  {
2969  return detail::errHandler(
2970  ::clEnqueueNDRangeKernel(
2971  object_, kernel(), (cl_uint) global.dimensions(),
2972  offset.dimensions() != 0 ? (const ::size_t*) offset : NULL,
2973  (const ::size_t*) global,
2974  local.dimensions() != 0 ? (const ::size_t*) local : NULL,
2975  (events != NULL) ? (cl_uint) events->size() : 0,
2976  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2977  (cl_event*) event),
2978  __ENQUEUE_NDRANGE_KERNEL_ERR);
2979  }
2980 
2981  cl_int enqueueTask(
2982  const Kernel& kernel,
2983  const VECTOR_CLASS<Event>* events = NULL,
2984  Event* event = NULL) const
2985  {
2986  return detail::errHandler(
2987  ::clEnqueueTask(
2988  object_, kernel(),
2989  (events != NULL) ? (cl_uint) events->size() : 0,
2990  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
2991  (cl_event*) event),
2992  __ENQUEUE_TASK_ERR);
2993  }
2994 
2996  void (*userFptr)(void *),
2997  std::pair<void*, ::size_t> args,
2998  const VECTOR_CLASS<Memory>* mem_objects = NULL,
2999  const VECTOR_CLASS<const void*>* mem_locs = NULL,
3000  const VECTOR_CLASS<Event>* events = NULL,
3001  Event* event = NULL) const
3002  {
3003  cl_mem * mems = (mem_objects != NULL && mem_objects->size() > 0)
3004  ? (cl_mem*) alloca(mem_objects->size() * sizeof(cl_mem))
3005  : NULL;
3006 
3007  if (mems != NULL) {
3008  for (unsigned int i = 0; i < mem_objects->size(); i++) {
3009  mems[i] = ((*mem_objects)[i])();
3010  }
3011  }
3012 
3013  return detail::errHandler(
3014  ::clEnqueueNativeKernel(
3015  object_, userFptr, args.first, args.second,
3016  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3017  mems,
3018  (mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL,
3019  (events != NULL) ? (cl_uint) events->size() : 0,
3020  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3021  (cl_event*) event),
3022  __ENQUEUE_NATIVE_KERNEL);
3023  }
3024 
3025  cl_int enqueueMarker(Event* event = NULL) const
3026  {
3027  return detail::errHandler(
3028  ::clEnqueueMarker(object_, (cl_event*) event),
3029  __ENQUEUE_MARKER_ERR);
3030  }
3031 
3032  cl_int enqueueWaitForEvents(const VECTOR_CLASS<Event>& events) const
3033  {
3034  return detail::errHandler(
3035  ::clEnqueueWaitForEvents(
3036  object_,
3037  (cl_uint) events.size(),
3038  (const cl_event*) &events.front()),
3039  __ENQUEUE_WAIT_FOR_EVENTS_ERR);
3040  }
3041 
3043  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3044  const VECTOR_CLASS<Event>* events = NULL,
3045  Event* event = NULL) const
3046  {
3047  return detail::errHandler(
3048  ::clEnqueueAcquireGLObjects(
3049  object_,
3050  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3051  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3052  (events != NULL) ? (cl_uint) events->size() : 0,
3053  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3054  (cl_event*) event),
3055  __ENQUEUE_ACQUIRE_GL_ERR);
3056  }
3057 
3059  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3060  const VECTOR_CLASS<Event>* events = NULL,
3061  Event* event = NULL) const
3062  {
3063  return detail::errHandler(
3064  ::clEnqueueReleaseGLObjects(
3065  object_,
3066  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3067  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3068  (events != NULL) ? (cl_uint) events->size() : 0,
3069  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
3070  (cl_event*) event),
3071  __ENQUEUE_RELEASE_GL_ERR);
3072  }
3073 
3074 #if defined (USE_DX_INTEROP)
3075 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
3076  cl_command_queue command_queue, cl_uint num_objects,
3077  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
3078  const cl_event* event_wait_list, cl_event* event);
3079 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
3080  cl_command_queue command_queue, cl_uint num_objects,
3081  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
3082  const cl_event* event_wait_list, cl_event* event);
3083 
3084  cl_int enqueueAcquireD3D10Objects(
3085  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3086  const VECTOR_CLASS<Event>* events = NULL,
3087  Event* event = NULL) const
3088  {
3089  static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
3090  __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR);
3091 
3092  return detail::errHandler(
3093  pfn_clEnqueueAcquireD3D10ObjectsKHR(
3094  object_,
3095  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3096  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3097  (events != NULL) ? (cl_uint) events->size() : 0,
3098  (events != NULL) ? (cl_event*) &events->front() : NULL,
3099  (cl_event*) event),
3100  __ENQUEUE_ACQUIRE_GL_ERR);
3101  }
3102 
3103  cl_int enqueueReleaseD3D10Objects(
3104  const VECTOR_CLASS<Memory>* mem_objects = NULL,
3105  const VECTOR_CLASS<Event>* events = NULL,
3106  Event* event = NULL) const
3107  {
3108  static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
3109  __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR);
3110 
3111  return detail::errHandler(
3112  pfn_clEnqueueReleaseD3D10ObjectsKHR(
3113  object_,
3114  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
3115  (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
3116  (events != NULL) ? (cl_uint) events->size() : 0,
3117  (events != NULL) ? (cl_event*) &events->front() : NULL,
3118  (cl_event*) event),
3119  __ENQUEUE_RELEASE_GL_ERR);
3120  }
3121 #endif
3122 
3123  cl_int enqueueBarrier() const
3124  {
3125  return detail::errHandler(
3126  ::clEnqueueBarrier(object_),
3127  __ENQUEUE_BARRIER_ERR);
3128  }
3129 
3130  cl_int flush() const
3131  {
3132  return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
3133  }
3134 
3135  cl_int finish() const
3136  {
3137  return detail::errHandler(::clFinish(object_), __FINISH_ERR);
3138  }
3139 };
3140 
3142 
3143 
3150 class KernelFunctor
3151 {
3152 private:
3153  Kernel kernel_;
3154  CommandQueue queue_;
3155  NDRange offset_;
3156  NDRange global_;
3157  NDRange local_;
3158 
3159  cl_int err_;
3160 public:
3162 
3164  const Kernel& kernel,
3165  const CommandQueue& queue,
3166  const NDRange& offset,
3167  const NDRange& global,
3168  const NDRange& local) :
3169  kernel_(kernel),
3170  queue_(queue),
3171  offset_(offset),
3172  global_(global),
3173  local_(local),
3174  err_(CL_SUCCESS)
3175  {}
3176 
3177  KernelFunctor& operator=(const KernelFunctor& rhs);
3178 
3179  KernelFunctor(const KernelFunctor& rhs);
3180 
3181  cl_int getError() { return err_; }
3182 
3183  inline Event operator()(const VECTOR_CLASS<Event>* events = NULL);
3184 
3185  template<typename A1>
3186  inline Event operator()(
3187  const A1& a1,
3188  const VECTOR_CLASS<Event>* events = NULL);
3189 
3190  template<class A1, class A2>
3191  inline Event operator()(
3192  const A1& a1,
3193  const A2& a2,
3194  const VECTOR_CLASS<Event>* events = NULL);
3195 
3196  template<class A1, class A2, class A3>
3197  inline Event operator()(
3198  const A1& a1,
3199  const A2& a2,
3200  const A3& a3,
3201  const VECTOR_CLASS<Event>* events = NULL);
3202 
3203  template<class A1, class A2, class A3, class A4>
3204  inline Event operator()(
3205  const A1& a1,
3206  const A2& a2,
3207  const A3& a3,
3208  const A4& a4,
3209  const VECTOR_CLASS<Event>* events = NULL);
3210 
3211  template<class A1, class A2, class A3, class A4, class A5>
3212  inline Event operator()(
3213  const A1& a1,
3214  const A2& a2,
3215  const A3& a3,
3216  const A4& a4,
3217  const A5& a5,
3218  const VECTOR_CLASS<Event>* events = NULL);
3219 
3220  template<class A1, class A2, class A3, class A4, class A5, class A6>
3221  inline Event operator()(
3222  const A1& a1,
3223  const A2& a2,
3224  const A3& a3,
3225  const A4& a4,
3226  const A5& a5,
3227  const A6& a6,
3228  const VECTOR_CLASS<Event>* events = NULL);
3229 
3230  template<class A1, class A2, class A3, class A4,
3231  class A5, class A6, class A7>
3232  inline Event operator()(
3233  const A1& a1,
3234  const A2& a2,
3235  const A3& a3,
3236  const A4& a4,
3237  const A5& a5,
3238  const A6& a6,
3239  const A7& a7,
3240  const VECTOR_CLASS<Event>* events = NULL);
3241 
3242  template<class A1, class A2, class A3, class A4, class A5,
3243  class A6, class A7, class A8>
3244  inline Event operator()(
3245  const A1& a1,
3246  const A2& a2,
3247  const A3& a3,
3248  const A4& a4,
3249  const A5& a5,
3250  const A6& a6,
3251  const A7& a7,
3252  const A8& a8,
3253  const VECTOR_CLASS<Event>* events = NULL);
3254 
3255  template<class A1, class A2, class A3, class A4, class A5,
3256  class A6, class A7, class A8, class A9>
3257  inline Event operator()(
3258  const A1& a1,
3259  const A2& a2,
3260  const A3& a3,
3261  const A4& a4,
3262  const A5& a5,
3263  const A6& a6,
3264  const A7& a7,
3265  const A8& a8,
3266  const A9& a9,
3267  const VECTOR_CLASS<Event>* events = NULL);
3268 
3269  template<class A1, class A2, class A3, class A4, class A5,
3270  class A6, class A7, class A8, class A9, class A10>
3271  inline Event operator()(
3272  const A1& a1,
3273  const A2& a2,
3274  const A3& a3,
3275  const A4& a4,
3276  const A5& a5,
3277  const A6& a6,
3278  const A7& a7,
3279  const A8& a8,
3280  const A9& a9,
3281  const A10& a10,
3282  const VECTOR_CLASS<Event>* events = NULL);
3283 
3284  template<class A1, class A2, class A3, class A4, class A5,
3285  class A6, class A7, class A8, class A9, class A10,
3286  class A11>
3287  inline Event operator()(
3288  const A1& a1,
3289  const A2& a2,
3290  const A3& a3,
3291  const A4& a4,
3292  const A5& a5,
3293  const A6& a6,
3294  const A7& a7,
3295  const A8& a8,
3296  const A9& a9,
3297  const A10& a10,
3298  const A11& a11,
3299  const VECTOR_CLASS<Event>* events = NULL);
3300 
3301  template<class A1, class A2, class A3, class A4, class A5,
3302  class A6, class A7, class A8, class A9, class A10,
3303  class A11, class A12>
3304  inline Event operator()(
3305  const A1& a1,
3306  const A2& a2,
3307  const A3& a3,
3308  const A4& a4,
3309  const A5& a5,
3310  const A6& a6,
3311  const A7& a7,
3312  const A8& a8,
3313  const A9& a9,
3314  const A10& a10,
3315  const A11& a11,
3316  const A12& a12,
3317  const VECTOR_CLASS<Event>* events = NULL);
3318 
3319  template<class A1, class A2, class A3, class A4, class A5,
3320  class A6, class A7, class A8, class A9, class A10,
3321  class A11, class A12, class A13>
3322  inline Event operator()(
3323  const A1& a1,
3324  const A2& a2,
3325  const A3& a3,
3326  const A4& a4,
3327  const A5& a5,
3328  const A6& a6,
3329  const A7& a7,
3330  const A8& a8,
3331  const A9& a9,
3332  const A10& a10,
3333  const A11& a11,
3334  const A12& a12,
3335  const A13& a13,
3336  const VECTOR_CLASS<Event>* events = NULL);
3337 
3338  template<class A1, class A2, class A3, class A4, class A5,
3339  class A6, class A7, class A8, class A9, class A10,
3340  class A11, class A12, class A13, class A14>
3341  inline Event operator()(
3342  const A1& a1,
3343  const A2& a2,
3344  const A3& a3,
3345  const A4& a4,
3346  const A5& a5,
3347  const A6& a6,
3348  const A7& a7,
3349  const A8& a8,
3350  const A9& a9,
3351  const A10& a10,
3352  const A11& a11,
3353  const A12& a12,
3354  const A13& a13,
3355  const A14& a14,
3356  const VECTOR_CLASS<Event>* events = NULL);
3357 
3358  template<class A1, class A2, class A3, class A4, class A5,
3359  class A6, class A7, class A8, class A9, class A10,
3360  class A11, class A12, class A13, class A14, class A15>
3361  inline Event operator()(
3362  const A1& a1,
3363  const A2& a2,
3364  const A3& a3,
3365  const A4& a4,
3366  const A5& a5,
3367  const A6& a6,
3368  const A7& a7,
3369  const A8& a8,
3370  const A9& a9,
3371  const A10& a10,
3372  const A11& a11,
3373  const A12& a12,
3374  const A13& a13,
3375  const A14& a14,
3376  const A15& a15,
3377  const VECTOR_CLASS<Event>* events = NULL);
3378 };
3379 
3381  const CommandQueue& queue,
3382  const NDRange& offset,
3383  const NDRange& global,
3384  const NDRange& local)
3385 {
3386  return KernelFunctor(*this,queue,offset,global,local);
3387 }
3388 
3390  const CommandQueue& queue,
3391  const NDRange& global,
3392  const NDRange& local)
3393 {
3394  return KernelFunctor(*this,queue,NullRange,global,local);
3395 }
3396 
3398 {
3399  if (this == &rhs) {
3400  return *this;
3401  }
3402 
3403  kernel_ = rhs.kernel_;
3404  queue_ = rhs.queue_;
3405  offset_ = rhs.offset_;
3406  global_ = rhs.global_;
3407  local_ = rhs.local_;
3408 
3409  return *this;
3410 }
3411 
3412 inline KernelFunctor::KernelFunctor(const KernelFunctor& rhs) :
3413  kernel_(rhs.kernel_),
3414  queue_(rhs.queue_),
3415  offset_(rhs.offset_),
3416  global_(rhs.global_),
3417  local_(rhs.local_)
3418 {
3419 }
3420 
3421 Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* events)
3422 {
3423  (void)events;
3424  Event event;
3425 
3426  err_ = queue_.enqueueNDRangeKernel(
3427  kernel_,
3428  offset_,
3429  global_,
3430  local_,
3431  NULL, // bgaster_fixme - do we want to allow wait event lists?
3432  &event);
3433 
3434  return event;
3435 }
3436 
3437 template<typename A1>
3439  const A1& a1,
3440  const VECTOR_CLASS<Event>* events)
3441 {
3442  Event event;
3443 
3444  kernel_.setArg(0,a1);
3445 
3446  err_ = queue_.enqueueNDRangeKernel(
3447  kernel_,
3448  offset_,
3449  global_,
3450  local_,
3451  NULL, // bgaster_fixme - do we want to allow wait event lists?
3452  &event);
3453 
3454  return event;
3455 }
3456 
3457 template<typename A1, typename A2>
3459  const A1& a1,
3460  const A2& a2,
3461  const VECTOR_CLASS<Event>* events)
3462 {
3463  Event event;
3464 
3465  kernel_.setArg(0,a1);
3466  kernel_.setArg(1,a2);
3467 
3468  err_ = queue_.enqueueNDRangeKernel(
3469  kernel_,
3470  offset_,
3471  global_,
3472  local_,
3473  NULL, // bgaster_fixme - do we want to allow wait event lists?
3474  &event);
3475 
3476  return event;
3477 }
3478 
3479 template<typename A1, typename A2, typename A3>
3481  const A1& a1,
3482  const A2& a2,
3483  const A3& a3,
3484  const VECTOR_CLASS<Event>* events)
3485 {
3486  Event event;
3487 
3488  kernel_.setArg(0,a1);
3489  kernel_.setArg(1,a2);
3490  kernel_.setArg(2,a3);
3491 
3492  err_ = queue_.enqueueNDRangeKernel(
3493  kernel_,
3494  offset_,
3495  global_,
3496  local_,
3497  NULL, // bgaster_fixme - do we want to allow wait event lists?
3498  &event);
3499 
3500  return event;
3501 }
3502 
3503 template<typename A1, typename A2, typename A3, typename A4>
3505  const A1& a1,
3506  const A2& a2,
3507  const A3& a3,
3508  const A4& a4,
3509  const VECTOR_CLASS<Event>* events)
3510 {
3511  Event event;
3512 
3513  kernel_.setArg(0,a1);
3514  kernel_.setArg(1,a2);
3515  kernel_.setArg(2,a3);
3516  kernel_.setArg(3,a4);
3517 
3518  err_ = queue_.enqueueNDRangeKernel(
3519  kernel_,
3520  offset_,
3521  global_,
3522  local_,
3523  NULL, // bgaster_fixme - do we want to allow wait event lists?
3524  &event);
3525 
3526  return event;
3527 }
3528 
3529 template<typename A1, typename A2, typename A3, typename A4, typename A5>
3531  const A1& a1,
3532  const A2& a2,
3533  const A3& a3,
3534  const A4& a4,
3535  const A5& a5,
3536  const VECTOR_CLASS<Event>* events)
3537 {
3538  Event event;
3539 
3540  kernel_.setArg(0,a1);
3541  kernel_.setArg(1,a2);
3542  kernel_.setArg(2,a3);
3543  kernel_.setArg(3,a4);
3544  kernel_.setArg(4,a5);
3545 
3546  err_ = queue_.enqueueNDRangeKernel(
3547  kernel_,
3548  offset_,
3549  global_,
3550  local_,
3551  NULL, // bgaster_fixme - do we want to allow wait event lists?
3552  &event);
3553 
3554  return event;
3555 }
3556 
3557 template<typename A1, typename A2, typename A3, typename A4, typename A5,
3558  typename A6>
3560  const A1& a1,
3561  const A2& a2,
3562  const A3& a3,
3563  const A4& a4,
3564  const A5& a5,
3565  const A6& a6,
3566  const VECTOR_CLASS<Event>* events)
3567 {
3568  Event event;
3569 
3570  kernel_.setArg(0,a1);
3571  kernel_.setArg(1,a2);
3572  kernel_.setArg(2,a3);
3573  kernel_.setArg(3,a4);
3574  kernel_.setArg(4,a5);
3575  kernel_.setArg(5,a6);
3576 
3577  err_ = queue_.enqueueNDRangeKernel(
3578  kernel_,
3579  offset_,
3580  global_,
3581  local_,
3582  NULL, // bgaster_fixme - do we want to allow wait event lists?
3583  &event);
3584 
3585  return event;
3586 }
3587 
3588 template<typename A1, typename A2, typename A3, typename A4,
3589  typename A5, typename A6, typename A7>
3591  const A1& a1,
3592  const A2& a2,
3593  const A3& a3,
3594  const A4& a4,
3595  const A5& a5,
3596  const A6& a6,
3597  const A7& a7,
3598  const VECTOR_CLASS<Event>* events)
3599 {
3600  Event event;
3601 
3602  kernel_.setArg(0,a1);
3603  kernel_.setArg(1,a2);
3604  kernel_.setArg(2,a3);
3605  kernel_.setArg(3,a4);
3606  kernel_.setArg(4,a5);
3607  kernel_.setArg(5,a6);
3608  kernel_.setArg(6,a7);
3609 
3610  err_ = queue_.enqueueNDRangeKernel(
3611  kernel_,
3612  offset_,
3613  global_,
3614  local_,
3615  NULL, // bgaster_fixme - do we want to allow wait event lists?
3616  &event);
3617 
3618  return event;
3619 }
3620 
3621 template<typename A1, typename A2, typename A3, typename A4, typename A5,
3622  typename A6, typename A7, typename A8>
3624  const A1& a1,
3625  const A2& a2,
3626  const A3& a3,
3627  const A4& a4,
3628  const A5& a5,
3629  const A6& a6,
3630  const A7& a7,
3631  const A8& a8,
3632  const VECTOR_CLASS<Event>* events)
3633 {
3634  Event event;
3635 
3636  kernel_.setArg(0,a1);
3637  kernel_.setArg(1,a2);
3638  kernel_.setArg(2,a3);
3639  kernel_.setArg(3,a4);
3640  kernel_.setArg(4,a5);
3641  kernel_.setArg(5,a6);
3642  kernel_.setArg(6,a7);
3643  kernel_.setArg(7,a8);
3644 
3645  err_ = queue_.enqueueNDRangeKernel(
3646  kernel_,
3647  offset_,
3648  global_,
3649  local_,
3650  NULL, // bgaster_fixme - do we want to allow wait event lists?
3651  &event);
3652 
3653  return event;
3654 }
3655 
3656 template<typename A1, typename A2, typename A3, typename A4, typename A5,
3657  typename A6, typename A7, typename A8, typename A9>
3659  const A1& a1,
3660  const A2& a2,
3661  const A3& a3,
3662  const A4& a4,
3663  const A5& a5,
3664  const A6& a6,
3665  const A7& a7,
3666  const A8& a8,
3667  const A9& a9,
3668  const VECTOR_CLASS<Event>* events)
3669 {
3670  Event event;
3671 
3672  kernel_.setArg(0,a1);
3673  kernel_.setArg(1,a2);
3674  kernel_.setArg(2,a3);
3675  kernel_.setArg(3,a4);
3676  kernel_.setArg(4,a5);
3677  kernel_.setArg(5,a6);
3678  kernel_.setArg(6,a7);
3679  kernel_.setArg(7,a8);
3680  kernel_.setArg(8,a9);
3681 
3682  err_ = queue_.enqueueNDRangeKernel(
3683  kernel_,
3684  offset_,
3685  global_,
3686  local_,
3687  NULL, // bgaster_fixme - do we want to allow wait event lists?
3688  &event);
3689 
3690  return event;
3691 }
3692 
3693 template<typename A1, typename A2, typename A3, typename A4, typename A5,
3694  typename A6, typename A7, typename A8, typename A9, typename A10>
3696  const A1& a1,
3697  const A2& a2,
3698  const A3& a3,
3699  const A4& a4,
3700  const A5& a5,
3701  const A6& a6,
3702  const A7& a7,
3703  const A8& a8,
3704  const A9& a9,
3705  const A10& a10,
3706  const VECTOR_CLASS<Event>* events)
3707 {
3708  Event event;
3709 
3710  kernel_.setArg(0,a1);
3711  kernel_.setArg(1,a2);
3712  kernel_.setArg(2,a3);
3713  kernel_.setArg(3,a4);
3714  kernel_.setArg(4,a5);
3715  kernel_.setArg(5,a6);
3716  kernel_.setArg(6,a7);
3717  kernel_.setArg(7,a8);
3718  kernel_.setArg(8,a9);
3719  kernel_.setArg(9,a10);
3720 
3721  err_ = queue_.enqueueNDRangeKernel(
3722  kernel_,
3723  offset_,
3724  global_,
3725  local_,
3726  NULL, // bgaster_fixme - do we want to allow wait event lists?
3727  &event);
3728 
3729  return event;
3730 }
3731 
3732 template<class A1, class A2, class A3, class A4, class A5,
3733  class A6, class A7, class A8, class A9, class A10,
3734  class A11>
3736  const A1& a1,
3737  const A2& a2,
3738  const A3& a3,
3739  const A4& a4,
3740  const A5& a5,
3741  const A6& a6,
3742  const A7& a7,
3743  const A8& a8,
3744  const A9& a9,
3745  const A10& a10,
3746  const A11& a11,
3747  const VECTOR_CLASS<Event>* events)
3748 {
3749  Event event;
3750 
3751  kernel_.setArg(0,a1);
3752  kernel_.setArg(1,a2);
3753  kernel_.setArg(2,a3);
3754  kernel_.setArg(3,a4);
3755  kernel_.setArg(4,a5);
3756  kernel_.setArg(5,a6);
3757  kernel_.setArg(6,a7);
3758  kernel_.setArg(7,a8);
3759  kernel_.setArg(8,a9);
3760  kernel_.setArg(9,a10);
3761  kernel_.setArg(10,a11);
3762 
3763  err_ = queue_.enqueueNDRangeKernel(
3764  kernel_,
3765  offset_,
3766  global_,
3767  local_,
3768  NULL, // bgaster_fixme - do we want to allow wait event lists?
3769  &event);
3770 
3771  return event;
3772 }
3773 
3774 template<class A1, class A2, class A3, class A4, class A5,
3775  class A6, class A7, class A8, class A9, class A10,
3776  class A11, class A12>
3778  const A1& a1,
3779  const A2& a2,
3780  const A3& a3,
3781  const A4& a4,
3782  const A5& a5,
3783  const A6& a6,
3784  const A7& a7,
3785  const A8& a8,
3786  const A9& a9,
3787  const A10& a10,
3788  const A11& a11,
3789  const A12& a12,
3790  const VECTOR_CLASS<Event>* events)
3791 {
3792  Event event;
3793 
3794  kernel_.setArg(0,a1);
3795  kernel_.setArg(1,a2);
3796  kernel_.setArg(2,a3);
3797  kernel_.setArg(3,a4);
3798  kernel_.setArg(4,a5);
3799  kernel_.setArg(5,a6);
3800  kernel_.setArg(6,a7);
3801  kernel_.setArg(7,a8);
3802  kernel_.setArg(8,a9);
3803  kernel_.setArg(9,a10);
3804  kernel_.setArg(10,a11);
3805  kernel_.setArg(11,a12);
3806 
3807  err_ = queue_.enqueueNDRangeKernel(
3808  kernel_,
3809  offset_,
3810  global_,
3811  local_,
3812  NULL, // bgaster_fixme - do we want to allow wait event lists?
3813  &event);
3814 
3815  return event;
3816 }
3817 
3818 template<class A1, class A2, class A3, class A4, class A5,
3819  class A6, class A7, class A8, class A9, class A10,
3820  class A11, class A12, class A13>
3822  const A1& a1,
3823  const A2& a2,
3824  const A3& a3,
3825  const A4& a4,
3826  const A5& a5,
3827  const A6& a6,
3828  const A7& a7,
3829  const A8& a8,
3830  const A9& a9,
3831  const A10& a10,
3832  const A11& a11,
3833  const A12& a12,
3834  const A13& a13,
3835  const VECTOR_CLASS<Event>* events)
3836 {
3837  Event event;
3838 
3839  kernel_.setArg(0,a1);
3840  kernel_.setArg(1,a2);
3841  kernel_.setArg(2,a3);
3842  kernel_.setArg(3,a4);
3843  kernel_.setArg(4,a5);
3844  kernel_.setArg(5,a6);
3845  kernel_.setArg(6,a7);
3846  kernel_.setArg(7,a8);
3847  kernel_.setArg(8,a9);
3848  kernel_.setArg(9,a10);
3849  kernel_.setArg(10,a11);
3850  kernel_.setArg(11,a12);
3851  kernel_.setArg(12,a13);
3852 
3853  err_ = queue_.enqueueNDRangeKernel(
3854  kernel_,
3855  offset_,
3856  global_,
3857  local_,
3858  NULL, // bgaster_fixme - do we want to allow wait event lists?
3859  &event);
3860 
3861  return event;
3862 }
3863 
3864 template<class A1, class A2, class A3, class A4, class A5,
3865  class A6, class A7, class A8, class A9, class A10,
3866  class A11, class A12, class A13, class A14>
3868  const A1& a1,
3869  const A2& a2,
3870  const A3& a3,
3871  const A4& a4,
3872  const A5& a5,
3873  const A6& a6,
3874  const A7& a7,
3875  const A8& a8,
3876  const A9& a9,
3877  const A10& a10,
3878  const A11& a11,
3879  const A12& a12,
3880  const A13& a13,
3881  const A14& a14,
3882  const VECTOR_CLASS<Event>* events)
3883 {
3884  Event event;
3885 
3886  kernel_.setArg(0,a1);
3887  kernel_.setArg(1,a2);
3888  kernel_.setArg(2,a3);
3889  kernel_.setArg(3,a4);
3890  kernel_.setArg(4,a5);
3891  kernel_.setArg(5,a6);
3892  kernel_.setArg(6,a7);
3893  kernel_.setArg(7,a8);
3894  kernel_.setArg(8,a9);
3895  kernel_.setArg(9,a10);
3896  kernel_.setArg(10,a11);
3897  kernel_.setArg(11,a12);
3898  kernel_.setArg(12,a13);
3899  kernel_.setArg(13,a14);
3900 
3901  err_ = queue_.enqueueNDRangeKernel(
3902  kernel_,
3903  offset_,
3904  global_,
3905  local_,
3906  NULL, // bgaster_fixme - do we want to allow wait event lists?
3907  &event);
3908 
3909  return event;
3910 }
3911 
3912 template<class A1, class A2, class A3, class A4, class A5,
3913  class A6, class A7, class A8, class A9, class A10,
3914  class A11, class A12, class A13, class A14, class A15>
3916  const A1& a1,
3917  const A2& a2,
3918  const A3& a3,
3919  const A4& a4,
3920  const A5& a5,
3921  const A6& a6,
3922  const A7& a7,
3923  const A8& a8,
3924  const A9& a9,
3925  const A10& a10,
3926  const A11& a11,
3927  const A12& a12,
3928  const A13& a13,
3929  const A14& a14,
3930  const A15& a15,
3931  const VECTOR_CLASS<Event>* events)
3932 {
3933  Event event;
3934 
3935  kernel_.setArg(0,a1);
3936  kernel_.setArg(1,a2);
3937  kernel_.setArg(2,a3);
3938  kernel_.setArg(3,a4);
3939  kernel_.setArg(4,a5);
3940  kernel_.setArg(5,a6);
3941  kernel_.setArg(6,a7);
3942  kernel_.setArg(7,a8);
3943  kernel_.setArg(8,a9);
3944  kernel_.setArg(9,a10);
3945  kernel_.setArg(10,a11);
3946  kernel_.setArg(11,a12);
3947  kernel_.setArg(12,a13);
3948  kernel_.setArg(13,a14);
3949  kernel_.setArg(14,a15);
3950 
3951  err_ = queue_.enqueueNDRangeKernel(
3952  kernel_,
3953  offset_,
3954  global_,
3955  local_,
3956  NULL, // bgaster_fixme - do we want to allow wait event lists?
3957  &event);
3958 
3959  return event;
3960 }
3961 
3962 #undef __ERR_STR
3963 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
3964 #undef __GET_DEVICE_INFO_ERR
3965 #undef __GET_PLATFORM_INFO_ERR
3966 #undef __GET_DEVICE_IDS_ERR
3967 #undef __GET_CONTEXT_INFO_ERR
3968 #undef __GET_EVENT_INFO_ERR
3969 #undef __GET_EVENT_PROFILE_INFO_ERR
3970 #undef __GET_MEM_OBJECT_INFO_ERR
3971 #undef __GET_IMAGE_INFO_ERR
3972 #undef __GET_SAMPLER_INFO_ERR
3973 #undef __GET_KERNEL_INFO_ERR
3974 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
3975 #undef __GET_PROGRAM_INFO_ERR
3976 #undef __GET_PROGRAM_BUILD_INFO_ERR
3977 #undef __GET_COMMAND_QUEUE_INFO_ERR
3978 
3979 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
3980 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
3981 
3982 #undef __CREATE_BUFFER_ERR
3983 #undef __CREATE_SUBBUFFER_ERR
3984 #undef __CREATE_IMAGE2D_ERR
3985 #undef __CREATE_IMAGE3D_ERR
3986 #undef __CREATE_SAMPLER_ERR
3987 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
3988 
3989 #undef __CREATE_USER_EVENT_ERR
3990 #undef __SET_USER_EVENT_STATUS_ERR
3991 #undef __SET_EVENT_CALLBACK_ERR
3992 
3993 #undef __WAIT_FOR_EVENTS_ERR
3994 
3995 #undef __CREATE_KERNEL_ERR
3996 #undef __SET_KERNEL_ARGS_ERR
3997 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
3998 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
3999 #undef __BUILD_PROGRAM_ERR
4000 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
4001 
4002 #undef __CREATE_COMMAND_QUEUE_ERR
4003 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
4004 #undef __ENQUEUE_READ_BUFFER_ERR
4005 #undef __ENQUEUE_WRITE_BUFFER_ERR
4006 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
4007 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
4008 #undef __ENQEUE_COPY_BUFFER_ERR
4009 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
4010 #undef __ENQUEUE_READ_IMAGE_ERR
4011 #undef __ENQUEUE_WRITE_IMAGE_ERR
4012 #undef __ENQUEUE_COPY_IMAGE_ERR
4013 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
4014 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
4015 #undef __ENQUEUE_MAP_BUFFER_ERR
4016 #undef __ENQUEUE_MAP_IMAGE_ERR
4017 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
4018 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
4019 #undef __ENQUEUE_TASK_ERR
4020 #undef __ENQUEUE_NATIVE_KERNEL
4021 
4022 #undef __UNLOAD_COMPILER_ERR
4023 #endif //__CL_USER_OVERRIDE_ERROR_STRINGS
4024 
4025 #undef __GET_INFO_HELPER_WITH_RETAIN
4026 
4027 // Extensions
4028 #undef __INIT_CL_EXT_FCN_PTR
4029 #undef __CREATE_SUB_DEVICES
4030 
4031 #if defined(USE_CL_DEVICE_FISSION)
4032 #undef __PARAM_NAME_DEVICE_FISSION
4033 #endif // USE_CL_DEVICE_FISSION
4034 
4035 } // namespace cl
4036 
4037 #endif // CL_HPP_
unsigned int capacity() const
Definition: cl.hpp:545
vector()
Definition: cl.hpp:447
Memory()
Definition: cl.hpp:1694
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:1989
const T & front(void) const
Definition: cl.hpp:673
void push_back(const T &x)
Definition: cl.hpp:465
bool error(const char *fmt, const Args &...args)
Definition: util.h:178
cl_int getInfo(cl_platform_info name, STRING_CLASS *param) const
Definition: cl.hpp:1284
#define __PARAM_NAME_INFO_1_0(F)
Definition: cl.hpp:785
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1493
Memory & operator=(const Memory &rhs)
Definition: cl.hpp:1698
NDRange(::size_t size0,::size_t size1,::size_t size2)
Definition: cl.hpp:2242
static cl_int retain(cl_sampler sampler)
Definition: cl.hpp:1063
KernelFunctor & operator=(const KernelFunctor &rhs)
Definition: cl.hpp:3397
ImageFormat interface fro cl_image_format.
Definition: cl.hpp:1167
::size_t length(void) const
Definition: cl.hpp:412
Memory(const Memory &memory)
Definition: cl.hpp:1696
#define __INIT_CL_EXT_FCN_PTR(name)
Definition: cl.hpp:197
Image & operator=(const Image &rhs)
Definition: cl.hpp:1953
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:1450
static iterator end(vector< T, N > &vec)
Definition: cl.hpp:603
static cl_int release(cl_kernel kernel)
Definition: cl.hpp:1083
static cl_int retain(cl_command_queue queue)
Definition: cl.hpp:1045
CommandQueue(const CommandQueue &commandQueue)
Definition: cl.hpp:2587
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:2917
cl_int getBuildInfo(const Device &device, cl_program_build_info name, T *param) const
Definition: cl.hpp:2506
KernelFunctor(const Kernel &kernel, const CommandQueue &queue, const NDRange &offset, const NDRange &global, const NDRange &local)
Definition: cl.hpp:3163
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, VECTOR_CLASS< ImageFormat > *formats) const
Definition: cl.hpp:1504
cl_int getInfo(cl_mem_info name, T *param) const
Definition: cl.hpp:1707
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1217
Local address raper for use with Kernel::setArg.
Definition: cl.hpp:2260
#define T(i, x)
detail::param_traits< detail::cl_kernel_work_group_info, name >::param_type getWorkGroupInfo(const Device &device, cl_int *err=NULL) const
Definition: cl.hpp:2346
Device(cl_device_id device)
Definition: cl.hpp:1193
BufferGL(const BufferGL &buffer)
Definition: cl.hpp:1876
#define __GET_INFO_HELPER_WITH_RETAIN(CPP_TYPE)
Definition: cl.hpp:767
static cl_int release(cl_mem memory)
Definition: cl.hpp:1056
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:2892
cl_int getInfo(cl_program_info name, T *param) const
Definition: cl.hpp:2485
::size_t size(const LocalSpaceArg &value)
Definition: cl.hpp:2277
Memory interface for cl_mem.
Definition: cl.hpp:1691
cl_int getInfo(cl_sampler_info name, T *param) const
Definition: cl.hpp:2188
cl_int enqueueWaitForEvents(const VECTOR_CLASS< Event > &events) const
Definition: cl.hpp:3032
NDRange offset_
Definition: cl.hpp:3155
detail::param_traits< detail::cl_program_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2494
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:2070
Kernel(const Kernel &kernel)
Definition: cl.hpp:2303
void operator--(int x)
Definition: cl.hpp:642
Image3D(const Image3D &image3D)
Definition: cl.hpp:2095
std::vector< std::string > strings
Definition: Common.h:147
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:2638
static cl_int retain(cl_device_id)
Definition: cl.hpp:1015
Buffer(const Context &context, cl_mem_flags flags,::size_t size, void *host_ptr=NULL, cl_int *err=NULL)
Definition: cl.hpp:1751
T & front(void)
Definition: cl.hpp:663
string(char *str)
Definition: cl.hpp:362
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:2675
vector(unsigned int size, const T &val=T())
Definition: cl.hpp:494
Event()
Definition: cl.hpp:1547
VECTOR_CLASS< std::pair< const void *,::size_t > > Binaries
Definition: cl.hpp:2396
Image3D & operator=(const Image3D &rhs)
Definition: cl.hpp:2097
cl_int getDevices(cl_device_type type, VECTOR_CLASS< Device > *devices) const
Definition: cl.hpp:1304
Image3D()
Definition: cl.hpp:2093
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=NULL)
Definition: cl.hpp:2569
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:2835
string(char *str,::size_t size)
Definition: cl.hpp:348
Kernel()
Definition: cl.hpp:2301
vector(const vector< T, N > &vec)
Definition: cl.hpp:485
Buffer(const Buffer &buffer)
Definition: cl.hpp:1769
static cl_int release(cl_sampler sampler)
Definition: cl.hpp:1065
bool operator!=(iterator i)
Definition: cl.hpp:622
static cl_int release(cl_program program)
Definition: cl.hpp:1074
Sampler()
Definition: cl.hpp:2154
bool operator==(vector< T, N > &vec)
Definition: cl.hpp:519
cl_int finish() const
Definition: cl.hpp:3135
Device(const Device &device)
Definition: cl.hpp:1197
cl_int getError()
Definition: cl.hpp:3181
cl_int release() const
Definition: cl.hpp:1138
cl_int getInfo(cl_event_info name, T *param) const
Definition: cl.hpp:1560
T & back(void)
Definition: cl.hpp:668
cl_int setArg(cl_uint index,::size_t size, void *argPtr)
Definition: cl.hpp:2369
Event interface for cl_event.
Definition: cl.hpp:1544
Program(const Context &context, const Sources &sources, cl_int *err=NULL)
Definition: cl.hpp:2399
Buffer & operator=(const Buffer &rhs)
Definition: cl.hpp:1771
cl_int getImageInfo(cl_image_info name, T *param) const
Definition: cl.hpp:1962
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:2424
string(const string &rhs)
Definition: cl.hpp:399
CryptoPP::PolynomialMod2 operator*(const CryptoPP::PolynomialMod2 &a, const CryptoPP::PolynomialMod2 &b)
Definition: gf2n.h:275
Kernel kernel_
Definition: cl.hpp:3153
cl_int getObjectInfo(cl_gl_object_type *type, GLuint *gl_object_name)
Definition: cl.hpp:1933
#define x(i)
Image3DGL(const Image3DGL &image)
Definition: cl.hpp:2137
string & operator=(const string &rhs)
Definition: cl.hpp:375
#define a1
static cl_int retain(cl_program program)
Definition: cl.hpp:1072
Image2DGL(const Context &context, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj, cl_int *err=NULL)
Definition: cl.hpp:2028
BufferGL(const Context &context, cl_mem_flags flags, GLuint bufobj, cl_int *err=NULL)
Definition: cl.hpp:1855
Buffer()
Definition: cl.hpp:1767
const T & back(void) const
Definition: cl.hpp:678
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:2814
static cl_int retain(cl_mem memory)
Definition: cl.hpp:1054
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:2873
static cl_int retain(cl_kernel kernel)
Definition: cl.hpp:1081
cl_int enqueueFillBuffer(const Buffer &buffer, const void *ptr,::size_t pattern_size,::size_t offset,::size_t size, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:2657
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1569
Image()
Definition: cl.hpp:1949
Program()
Definition: cl.hpp:2454
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Definition: cl.hpp:1581
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1716
const char * name
Definition: rest.cpp:36
iterator end(void)
Definition: cl.hpp:658
Image2D()
Definition: cl.hpp:2009
T & operator[](int index)
Definition: cl.hpp:550
cl_int enqueueBarrier() const
Definition: cl.hpp:3123
BufferRenderGL(const BufferGL &buffer)
Definition: cl.hpp:1923
void operator--()
Definition: cl.hpp:637
static cl_int release(cl_platform_id)
Definition: cl.hpp:1029
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Definition: cl.hpp:1971
~vector()
Definition: cl.hpp:452
BufferRenderGL(const Context &context, cl_mem_flags flags, GLuint bufobj, cl_int *err=NULL)
Definition: cl.hpp:1902
cl_int enqueueNativeKernel(void(*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:2995
Image2D(const Image2D &image2D)
Definition: cl.hpp:2011
cl_int getWorkGroupInfo(const Device &device, cl_kernel_work_group_info name, T *param) const
Definition: cl.hpp:2335
Sampler(const Sampler &sampler)
Definition: cl.hpp:2177
#define CL_CALLBACK
Definition: cl.hpp:171
cl_int enqueueMarker(Event *event=NULL) const
Definition: cl.hpp:3025
NDRange global_
Definition: cl.hpp:3156
CommandQueue queue_
Definition: cl.hpp:3154
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:2961
static void * ptr(LocalSpaceArg &)
Definition: cl.hpp:2278
unsigned int size(void) const
Definition: cl.hpp:454
NDRange()
Definition: cl.hpp:2225
detail::param_traits< detail::cl_kernel_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2323
VECTOR_CLASS< std::pair< const char *,::size_t > > Sources
Definition: cl.hpp:2397
Fixed sized vector implementation that mirroring std::vector functionality.
Definition: cl.hpp:440
Platform interface.
Definition: cl.hpp:1265
Platform(cl_platform_id platform)
Definition: cl.hpp:1270
Context(const Context &context)
Definition: cl.hpp:1473
Program(const Program &program)
Definition: cl.hpp:2456
Image2DGL(const Image2DGL &image)
Definition: cl.hpp:2053
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2197
Platform(const Platform &platform)
Definition: cl.hpp:1274
#define f(x)
Definition: gost.cpp:57
cl_int wait() const
Definition: cl.hpp:1601
CommandQueue interface for cl_command_queue.
Definition: cl.hpp:2566
cl_int getInfo(Func f, cl_uint name, T *param)
Definition: cl.hpp:966
cl_int getInfo(Func f, const Arg0 &arg0, const Arg1 &arg1, cl_uint name, T *param)
Definition: cl.hpp:1000
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:2156
unsigned int max_size(void) const
Definition: cl.hpp:540
const char * c_str(void) const
Definition: cl.hpp:414
vector< T, N > & operator=(const vector< T, N > &rhs)
Definition: cl.hpp:503
cl_int enqueueUnmapMemObject(const Memory &memory, void *mapped_ptr, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:2946
static cl_int release(cl_command_queue queue)
Definition: cl.hpp:1047
ImageFormat(cl_channel_order order, cl_channel_type type)
Definition: cl.hpp:1171
PlatformStyle::TableColorType type
Definition: rpcconsole.cpp:61
uint8_t const size_t const size
Definition: sha3.h:20
void * memcpy(void *a, const void *b, size_t c)
NDRange local_
Definition: cl.hpp:3157
cl_int getObjectInfo(cl_gl_object_type *type, GLuint *gl_object_name)
Definition: cl.hpp:1886
#define I(x, y, z)
Definition: Hash.cpp:82
void pop_back(void)
Definition: cl.hpp:474
bool operator==(iterator i)
Definition: cl.hpp:615
cl_int createKernels(VECTOR_CLASS< Kernel > *kernels)
Definition: cl.hpp:2528
Event(const Event &event)
Definition: cl.hpp:1549
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:2466
cl_int getInfo(cl_device_info name, T *param) const
Definition: cl.hpp:1208
Image3DGL(const Context &context, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj, cl_int *err=NULL)
Definition: cl.hpp:2112
void assign(I start, I end)
Definition: cl.hpp:561
Sampler interface for cl_sampler.
Definition: cl.hpp:2151
static cl_int retain(cl_event event)
Definition: cl.hpp:1090
Kernel functor interface.
Definition: cl.hpp:3150
detail::param_traits< detail::cl_program_build_info, name >::param_type getBuildInfo(const Device &device, cl_int *err=NULL) const
Definition: cl.hpp:2517
::size_t size(void) const
Definition: cl.hpp:411
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:2854
Wrapper(const Wrapper< cl_type > &rhs)
Definition: cl.hpp:1113
Base class interface for all images.
Definition: cl.hpp:1946
cl_int retain() const
Definition: cl.hpp:1133
Wrapper< cl_type > & operator=(const Wrapper< cl_type > &rhs)
Definition: cl.hpp:1119
~string()
Definition: cl.hpp:404
cl_int getInfo(cl_context_info name, T *param) const
Definition: cl.hpp:1484
static cl_int release(cl_event event)
Definition: cl.hpp:1092
cl_int flush() const
Definition: cl.hpp:3130
Memory buffer interface.
Definition: cl.hpp:1748
NDRange interface.
Definition: cl.hpp:2218
Image interface for 2D images.
Definition: cl.hpp:1986
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:2619
NDRange(::size_t size0)
Definition: cl.hpp:2229
::size_t size(const T &)
Definition: cl.hpp:2270
cl_int setArg(cl_uint index, T value)
Definition: cl.hpp:2358
cl_int getInfo(cl_kernel_info name, T *param) const
Definition: cl.hpp:2314
Kernel interface that implements cl_kernel.
Definition: cl.hpp:2296
Image interface for 3D images.
Definition: cl.hpp:2067
#define a3
Memory buffer interface for GL interop with renderbuffer.
Definition: cl.hpp:1899
KernelFunctor bind(const CommandQueue &queue, const NDRange &offset, const NDRange &global, const NDRange &local)
Definition: cl.hpp:3380
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Definition: cl.hpp:1590
cl_int enqueueAcquireGLObjects(const VECTOR_CLASS< Memory > *mem_objects=NULL, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3042
NDRange(::size_t size0,::size_t size1)
Definition: cl.hpp:2235
uint8_t format
Device()
Definition: cl.hpp:1195
void operator++()
Definition: cl.hpp:627
Context()
Definition: cl.hpp:1471
Event operator()(const VECTOR_CLASS< Event > *events=NULL)
Definition: cl.hpp:3421
Device interface for cl_device_id.
Definition: cl.hpp:1190
#define a2
Event & operator=(const Event &rhs)
Definition: cl.hpp:1551
iterator begin(void)
Definition: cl.hpp:653
cl_int enqueueTask(const Kernel &kernel, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:2981
BufferGL()
Definition: cl.hpp:1874
bool empty(void) const
Definition: cl.hpp:535
#define __DECLARE_PARAM_TRAITS(token, param_name, T)
Definition: cl.hpp:942
cl_int enqueueReleaseGLObjects(const VECTOR_CLASS< Memory > *mem_objects=NULL, const VECTOR_CLASS< Event > *events=NULL, Event *event=NULL) const
Definition: cl.hpp:3058
static cl_int waitForEvents(const VECTOR_CLASS< Event > &events)
Definition: cl.hpp:1625
::size_t dimensions() const
Definition: cl.hpp:2251
#define A1
Definition: integer.cpp:2165
Program interface that implements cl_program.
Definition: cl.hpp:2393
detail::param_traits< detail::cl_command_queue_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:2608
static T * ptr(T &value)
Definition: cl.hpp:2271
static cl_int retain(cl_platform_id)
Definition: cl.hpp:1026
cl_int getInfo(cl_command_queue_info name, T *param) const
Definition: cl.hpp:2598
static cl_int retain(cl_context context)
Definition: cl.hpp:1036
size_t class used to interface between C++ and OpenCL C calls that require arrays of size_t values...
Definition: cl.hpp:690
static cl_int release(cl_device_id)
Definition: cl.hpp:1018
Simple string class, that provides a limited subset of std::string functionality but avoids many of t...
Definition: cl.hpp:338
uint8_t const * data
Definition: sha3.h:19
::size_t size_
Definition: cl.hpp:2262
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:1427
Memory buffer interface for GL interop.
Definition: cl.hpp:1852
std::string STRING_CLASS
Definition: cl.hpp:419
2D image interface for GL interop.
Definition: cl.hpp:2025
static iterator begin(vector< T, N > &vec)
Definition: cl.hpp:590
void clear()
Definition: cl.hpp:459
static cl_int release(cl_context context)
Definition: cl.hpp:1038
Platform()
Definition: cl.hpp:1272
cl_type object_
Definition: cl.hpp:1103
Image2D & operator=(const Image2D &rhs)
Definition: cl.hpp:2013
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:2793
T operator[](int index) const
Definition: cl.hpp:555
Image(const Image &image)
Definition: cl.hpp:1951
LocalSpaceArg __local(::size_t size)
Definition: cl.hpp:2285
void operator++(int x)
Definition: cl.hpp:632
Iterator class for vectors.
Definition: cl.hpp:573
detail::param_traits< detail::cl_platform_info, name >::param_type getInfo(cl_int *err=NULL) const
Definition: cl.hpp:1293
string(void)
Definition: cl.hpp:344