OpenCL C++ Bindings
opencl.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2008-2020 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
312 
325 
389 #ifndef CL_HPP_
390 #define CL_HPP_
391 
392 /* Handle deprecated preprocessor definitions. In each case, we only check for
393  * the old name if the new name is not defined, so that user code can define
394  * both and hence work with either version of the bindings.
395  */
396 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
397 # pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
398 # define CL_HPP_USE_DX_INTEROP
399 #endif
400 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
401 # pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
402 # define CL_HPP_USE_CL_DEVICE_FISSION
403 #endif
404 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
405 # pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
406 # define CL_HPP_ENABLE_EXCEPTIONS
407 #endif
408 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
409 # pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
410 # define CL_HPP_NO_STD_VECTOR
411 #endif
412 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
413 # pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
414 # define CL_HPP_NO_STD_STRING
415 #endif
416 #if defined(VECTOR_CLASS)
417 # pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
418 #endif
419 #if defined(STRING_CLASS)
420 # pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
421 #endif
422 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
423 # pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
424 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
425 #endif
426 
427 /* Warn about features that are no longer supported
428  */
429 #if defined(__USE_DEV_VECTOR)
430 # pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
431 #endif
432 #if defined(__USE_DEV_STRING)
433 # pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
434 #endif
435 
436 /* Detect which version to target */
437 #if !defined(CL_HPP_TARGET_OPENCL_VERSION)
438 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 220 (OpenCL 2.2)")
439 # define CL_HPP_TARGET_OPENCL_VERSION 220
440 #endif
441 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
442  CL_HPP_TARGET_OPENCL_VERSION != 110 && \
443  CL_HPP_TARGET_OPENCL_VERSION != 120 && \
444  CL_HPP_TARGET_OPENCL_VERSION != 200 && \
445  CL_HPP_TARGET_OPENCL_VERSION != 210 && \
446  CL_HPP_TARGET_OPENCL_VERSION != 220 && \
447  CL_HPP_TARGET_OPENCL_VERSION != 300
448 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 220")
449 # undef CL_HPP_TARGET_OPENCL_VERSION
450 # define CL_HPP_TARGET_OPENCL_VERSION 220
451 #endif
452 
453 /* Forward target OpenCL version to C headers if necessary */
454 #if defined(CL_TARGET_OPENCL_VERSION)
455 /* Warn if prior definition of CL_TARGET_OPENCL_VERSION is lower than
456  * requested C++ bindings version */
457 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
458 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
459 #endif
460 #else
461 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
462 #endif
463 
464 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
465 # define CL_HPP_MINIMUM_OPENCL_VERSION 200
466 #endif
467 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
468  CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
469  CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
470  CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
471  CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
472  CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
473  CL_HPP_MINIMUM_OPENCL_VERSION != 300
474 # pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
475 # undef CL_HPP_MINIMUM_OPENCL_VERSION
476 # define CL_HPP_MINIMUM_OPENCL_VERSION 100
477 #endif
478 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
479 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
480 #endif
481 
482 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
483 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS
484 #endif
485 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
486 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS
487 #endif
488 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
489 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS
490 #endif
491 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
492 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS
493 #endif
494 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
495 # define CL_USE_DEPRECATED_OPENCL_2_1_APIS
496 #endif
497 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
498 # define CL_USE_DEPRECATED_OPENCL_2_2_APIS
499 #endif
500 
501 #ifdef _WIN32
502 
503 #include <malloc.h>
504 
505 #if defined(CL_HPP_USE_DX_INTEROP)
506 #include <CL/cl_d3d10.h>
507 #include <CL/cl_dx9_media_sharing.h>
508 #endif
509 #endif // _WIN32
510 
511 #if defined(_MSC_VER)
512 #include <intrin.h>
513 #endif // _MSC_VER
514 
515  // Check for a valid C++ version
516 
517 // Need to do both tests here because for some reason __cplusplus is not
518 // updated in visual studio
519 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
520 #error Visual studio 2013 or another C++11-supporting compiler required
521 #endif
522 
523 //
524 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
525 #include <CL/cl_ext.h>
526 #endif
527 
528 #if defined(__APPLE__) || defined(__MACOSX)
529 #include <OpenCL/opencl.h>
530 #else
531 #include <CL/opencl.h>
532 #endif // !__APPLE__
533 
534 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
535 #define CL_HPP_NOEXCEPT_ noexcept
536 #else
537 #define CL_HPP_NOEXCEPT_
538 #endif
539 
540 #if __cplusplus >= 201703L
541 # define CL_HPP_DEFINE_STATIC_MEMBER_ inline
542 #elif defined(_MSC_VER)
543 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
544 #elif defined(__MINGW32__)
545 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
546 #else
547 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
548 #endif // !_MSC_VER
549 
550 // Define deprecated prefixes and suffixes to ensure compilation
551 // in case they are not pre-defined
552 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
553 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
554 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
555 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED)
556 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
557 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
558 
559 #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
560 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
561 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
562 #if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED)
563 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
564 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
565 
566 #if !defined(CL_CALLBACK)
567 #define CL_CALLBACK
568 #endif //CL_CALLBACK
569 
570 #include <utility>
571 #include <limits>
572 #include <iterator>
573 #include <mutex>
574 #include <cstring>
575 #include <functional>
576 
577 
578 // Define a size_type to represent a correctly resolved size_t
579 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
580 namespace cl {
581  using size_type = ::size_t;
582 } // namespace cl
583 #else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
584 namespace cl {
585  using size_type = size_t;
586 } // namespace cl
587 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
588 
589 
590 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
591 #include <exception>
592 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
593 
594 #if !defined(CL_HPP_NO_STD_VECTOR)
595 #include <vector>
596 namespace cl {
597  template < class T, class Alloc = std::allocator<T> >
598  using vector = std::vector<T, Alloc>;
599 } // namespace cl
600 #endif // #if !defined(CL_HPP_NO_STD_VECTOR)
601 
602 #if !defined(CL_HPP_NO_STD_STRING)
603 #include <string>
604 namespace cl {
605  using string = std::string;
606 } // namespace cl
607 #endif // #if !defined(CL_HPP_NO_STD_STRING)
608 
609 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
610 
611 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
612 #include <memory>
613 namespace cl {
614  // Replace unique_ptr and allocate_pointer for internal use
615  // to allow user to replace them
616  template<class T, class D>
617  using pointer = std::unique_ptr<T, D>;
618 } // namespace cl
619 #endif
620 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
621 #if !defined(CL_HPP_NO_STD_ARRAY)
622 #include <array>
623 namespace cl {
624  template < class T, size_type N >
625  using array = std::array<T, N>;
626 } // namespace cl
627 #endif // #if !defined(CL_HPP_NO_STD_ARRAY)
628 
629 // Define size_type appropriately to allow backward-compatibility
630 // use of the old size_t interface class
631 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
632 namespace cl {
633  namespace compatibility {
638  template <int N>
639  class size_t
640  {
641  private:
642  size_type data_[N];
643 
644  public:
646  size_t()
647  {
648  for (int i = 0; i < N; ++i) {
649  data_[i] = 0;
650  }
651  }
652 
653  size_t(const array<size_type, N> &rhs)
654  {
655  for (int i = 0; i < N; ++i) {
656  data_[i] = rhs[i];
657  }
658  }
659 
660  size_type& operator[](int index)
661  {
662  return data_[index];
663  }
664 
665  const size_type& operator[](int index) const
666  {
667  return data_[index];
668  }
669 
671  operator size_type* () { return data_; }
672 
674  operator const size_type* () const { return data_; }
675 
676  operator array<size_type, N>() const
677  {
678  array<size_type, N> ret;
679 
680  for (int i = 0; i < N; ++i) {
681  ret[i] = data_[i];
682  }
683  return ret;
684  }
685  };
686  } // namespace compatibility
687 
688  template<int N>
689  using size_t = compatibility::size_t<N>;
690 } // namespace cl
691 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
692 
693 // Helper alias to avoid confusing the macros
694 namespace cl {
695  namespace detail {
696  using size_t_array = array<size_type, 3>;
697  } // namespace detail
698 } // namespace cl
699 
700 
706 namespace cl {
707  class Memory;
708 
709 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
710  if (!pfn_##name) { \
711  pfn_##name = (PFN_##name) \
712  clGetExtensionFunctionAddress(#name); \
713  if (!pfn_##name) { \
714  } \
715  }
716 
717 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
718  if (!pfn_##name) { \
719  pfn_##name = (PFN_##name) \
720  clGetExtensionFunctionAddressForPlatform(platform, #name); \
721  if (!pfn_##name) { \
722  } \
723  }
724 
725  class Program;
726  class Device;
727  class Context;
728  class CommandQueue;
729  class DeviceCommandQueue;
730  class Memory;
731  class Buffer;
732  class Pipe;
733 
734 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
735 
739  class Error : public std::exception
740  {
741  private:
742  cl_int err_;
743  const char * errStr_;
744  public:
754  Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr)
755  {}
756 
757  ~Error() throw() {}
758 
763  virtual const char * what() const throw ()
764  {
765  if (errStr_ == NULL) {
766  return "empty";
767  }
768  else {
769  return errStr_;
770  }
771  }
772 
777  cl_int err(void) const { return err_; }
778  };
779 #define CL_HPP_ERR_STR_(x) #x
780 #else
781 #define CL_HPP_ERR_STR_(x) NULL
782 #endif // CL_HPP_ENABLE_EXCEPTIONS
783 
784 
785 namespace detail
786 {
787 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
788 static inline cl_int errHandler (
789  cl_int err,
790  const char * errStr = NULL)
791 {
792  if (err != CL_SUCCESS) {
793  throw Error(err, errStr);
794  }
795  return err;
796 }
797 #else
798 static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
799 {
800  (void) errStr; // suppress unused variable warning
801  return err;
802 }
803 #endif // CL_HPP_ENABLE_EXCEPTIONS
804 }
805 
806 
807 
809 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
810 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
811 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
812 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
813 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
814 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
815 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
816 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
817 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
818 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
819 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
820 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
821 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
822 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
823 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
824 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
825 #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
826 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
827 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
828 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
829 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
830 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
831 
832 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
833 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
834 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
835 
836 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
837 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
838 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
839 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
840 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
841 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
842 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
843 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
844 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
845 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
846 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
847 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
848 
849 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
850 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
851 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
852 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
853 
854 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
855 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
856 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
857 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
858 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
859 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
860 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
861 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
862 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
863 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
864 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
865 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
866 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
867 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
868 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
869 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
870 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
871 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
872 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
873 
874 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
875 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
876 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
877 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
878 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
879 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
880 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
881 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
882 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
883 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
884 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
885 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
886 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
887 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
888 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
889 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
890 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
891 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
892 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
893 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
894 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
895 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
896 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
897 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
898 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
899 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
900 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
901 #define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
902 #define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
903 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
904 
905 
906 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
907 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
908 
909 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
910 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
911 
912 
913 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
914 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
915 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
916 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
917 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
918 
919 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
920 #define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
921 #define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
922 #endif
923 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
924 #define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
925 #define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
926 #endif
927 
928 
932 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
933 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
934 #else
935 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
936 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
937 
941 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
942 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
943 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
944 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
945 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
946 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
947 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
948 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
949 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
950 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
951 
955 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
956 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
957 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
958 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
959 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
960 
964 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
965 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
966 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
967 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
968 
969 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
970 #define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
971 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
972 
973 #endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS
974 
976 
977 namespace detail {
978 
979 // Generic getInfoHelper. The final parameter is used to guide overload
980 // resolution: the actual parameter passed is an int, which makes this
981 // a worse conversion sequence than a specialization that declares the
982 // parameter as an int.
983 template<typename Functor, typename T>
984 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long)
985 {
986  return f(name, sizeof(T), param, NULL);
987 }
988 
989 // Specialized for getInfo<CL_PROGRAM_BINARIES>
990 // Assumes that the output vector was correctly resized on the way in
991 template <typename Func>
992 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param, int)
993 {
994  if (name != CL_PROGRAM_BINARIES) {
995  return CL_INVALID_VALUE;
996  }
997  if (param) {
998  // Create array of pointers, calculate total size and pass pointer array in
999  size_type numBinaries = param->size();
1000  vector<unsigned char*> binariesPointers(numBinaries);
1001 
1002  for (size_type i = 0; i < numBinaries; ++i)
1003  {
1004  binariesPointers[i] = (*param)[i].data();
1005  }
1006 
1007  cl_int err = f(name, numBinaries * sizeof(unsigned char*), binariesPointers.data(), NULL);
1008 
1009  if (err != CL_SUCCESS) {
1010  return err;
1011  }
1012  }
1013 
1014 
1015  return CL_SUCCESS;
1016 }
1017 
1018 // Specialized getInfoHelper for vector params
1019 template <typename Func, typename T>
1020 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param, long)
1021 {
1022  size_type required;
1023  cl_int err = f(name, 0, NULL, &required);
1024  if (err != CL_SUCCESS) {
1025  return err;
1026  }
1027  const size_type elements = required / sizeof(T);
1028 
1029  // Temporary to avoid changing param on an error
1030  vector<T> localData(elements);
1031  err = f(name, required, localData.data(), NULL);
1032  if (err != CL_SUCCESS) {
1033  return err;
1034  }
1035  if (param) {
1036  *param = std::move(localData);
1037  }
1038 
1039  return CL_SUCCESS;
1040 }
1041 
1042 /* Specialization for reference-counted types. This depends on the
1043  * existence of Wrapper<T>::cl_type, and none of the other types having the
1044  * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
1045  * does not work, because when using a derived type (e.g. Context) the generic
1046  * template will provide a better match.
1047  */
1048 template <typename Func, typename T>
1049 inline cl_int getInfoHelper(
1050  Func f, cl_uint name, vector<T>* param, int, typename T::cl_type = 0)
1051 {
1052  size_type required;
1053  cl_int err = f(name, 0, NULL, &required);
1054  if (err != CL_SUCCESS) {
1055  return err;
1056  }
1057 
1058  const size_type elements = required / sizeof(typename T::cl_type);
1059 
1060  vector<typename T::cl_type> value(elements);
1061  err = f(name, required, value.data(), NULL);
1062  if (err != CL_SUCCESS) {
1063  return err;
1064  }
1065 
1066  if (param) {
1067  // Assign to convert CL type to T for each element
1068  param->resize(elements);
1069 
1070  // Assign to param, constructing with retain behaviour
1071  // to correctly capture each underlying CL object
1072  for (size_type i = 0; i < elements; i++) {
1073  (*param)[i] = T(value[i], true);
1074  }
1075  }
1076  return CL_SUCCESS;
1077 }
1078 
1079 // Specialized GetInfoHelper for string params
1080 template <typename Func>
1081 inline cl_int getInfoHelper(Func f, cl_uint name, string* param, long)
1082 {
1083  size_type required;
1084  cl_int err = f(name, 0, NULL, &required);
1085  if (err != CL_SUCCESS) {
1086  return err;
1087  }
1088 
1089  // std::string has a constant data member
1090  // a char vector does not
1091  if (required > 0) {
1092  vector<char> value(required);
1093  err = f(name, required, value.data(), NULL);
1094  if (err != CL_SUCCESS) {
1095  return err;
1096  }
1097  if (param) {
1098  param->assign(begin(value), prev(end(value)));
1099  }
1100  }
1101  else if (param) {
1102  param->assign("");
1103  }
1104  return CL_SUCCESS;
1105 }
1106 
1107 // Specialized GetInfoHelper for clsize_t params
1108 template <typename Func, size_type N>
1109 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param, long)
1110 {
1111  size_type required;
1112  cl_int err = f(name, 0, NULL, &required);
1113  if (err != CL_SUCCESS) {
1114  return err;
1115  }
1116 
1117  size_type elements = required / sizeof(size_type);
1118  vector<size_type> value(elements, 0);
1119 
1120  err = f(name, required, value.data(), NULL);
1121  if (err != CL_SUCCESS) {
1122  return err;
1123  }
1124 
1125  // Bound the copy with N to prevent overruns
1126  // if passed N > than the amount copied
1127  if (elements > N) {
1128  elements = N;
1129  }
1130  for (size_type i = 0; i < elements; ++i) {
1131  (*param)[i] = value[i];
1132  }
1133 
1134  return CL_SUCCESS;
1135 }
1136 
1137 template<typename T> struct ReferenceHandler;
1138 
1139 /* Specialization for reference-counted types. This depends on the
1140  * existence of Wrapper<T>::cl_type, and none of the other types having the
1141  * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
1142  * does not work, because when using a derived type (e.g. Context) the generic
1143  * template will provide a better match.
1144  */
1145 template<typename Func, typename T>
1146 inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0)
1147 {
1148  typename T::cl_type value;
1149  cl_int err = f(name, sizeof(value), &value, NULL);
1150  if (err != CL_SUCCESS) {
1151  return err;
1152  }
1153  *param = value;
1154  if (value != NULL)
1155  {
1156  err = param->retain();
1157  if (err != CL_SUCCESS) {
1158  return err;
1159  }
1160  }
1161  return CL_SUCCESS;
1162 }
1163 
1164 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1165  F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1166  F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1167  F(cl_platform_info, CL_PLATFORM_NAME, string) \
1168  F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1169  F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1170  \
1171  F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1172  F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1173  F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1174  F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1175  F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1176  F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1177  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1178  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1179  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1180  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1181  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1182  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1183  F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1184  F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1185  F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1186  F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1187  F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1188  F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1189  F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1190  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1191  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1192  F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1193  F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1194  F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1195  F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1196  F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1197  F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1198  F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1199  F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1200  F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1201  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1202  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1203  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1204  F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1205  F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1206  F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1207  F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1208  F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1209  F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1210  F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1211  F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1212  F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1213  F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1214  F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1215  F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1216  F(cl_device_info, CL_DEVICE_NAME, string) \
1217  F(cl_device_info, CL_DEVICE_VENDOR, string) \
1218  F(cl_device_info, CL_DRIVER_VERSION, string) \
1219  F(cl_device_info, CL_DEVICE_PROFILE, string) \
1220  F(cl_device_info, CL_DEVICE_VERSION, string) \
1221  F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1222  \
1223  F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1224  F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1225  F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1226  \
1227  F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1228  F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1229  F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1230  F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1231  \
1232  F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1233  F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1234  F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1235  F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1236  \
1237  F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1238  F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1239  F(cl_mem_info, CL_MEM_SIZE, size_type) \
1240  F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1241  F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1242  F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1243  F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1244  \
1245  F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1246  F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1247  F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1248  F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1249  F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1250  F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1251  F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1252  \
1253  F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1254  F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1255  F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1256  F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1257  F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1258  \
1259  F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1260  F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1261  F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1262  F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1263  F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1264  F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1265  F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1266  \
1267  F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1268  F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1269  F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1270  \
1271  F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1272  F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1273  F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1274  F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1275  F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1276  \
1277  F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1278  F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1279  F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1280  \
1281  F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1282  F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1283  F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1284  F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1285 
1286 
1287 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1288  F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1289  F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1290  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1291  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1292  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1293  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1294  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1295  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1296  F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1297  F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1298  \
1299  F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1300  F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1301  \
1302  F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1303  F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1304  \
1305  F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1306 
1307 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1308  F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1309  F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1310  \
1311  F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1312  \
1313  F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1314  \
1315  F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1316  F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1317  F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1318  F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1319  F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1320  \
1321  F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1322  F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1323  F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1324  F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1325  F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1326  F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \
1327  F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1328  F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1329  \
1330  F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1331  F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1332  F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1333 
1334 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1335  F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1336  F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1337  F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1338  F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1339  F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1340  F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1341  F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1342  F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1343  F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1344  F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1345  F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1346  F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1347  F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1348  F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1349  F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1350  F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1351  F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1352  F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1353  F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1354  F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1355  F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1356 
1357 #define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1358  F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1359  F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1360 
1361 #define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1362  F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1363  F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1364 
1365 #define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1366  F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, size_type) \
1367  F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1368  F(cl_kernel_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1369  F(cl_kernel_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type) \
1370  F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1371  F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1372  F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1373  F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1374  F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1375  F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1376  F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array)
1377 
1378 #define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1379  F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1380  F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1381 
1382 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1383  F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1384  F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1385  F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1386  F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1387  F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1388 
1389 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_(F) \
1390  F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1391  F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1392  \
1393  F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1394  F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr) \
1395  F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1396  F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1397  F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1398 
1399 template <typename enum_type, cl_int Name>
1400 struct param_traits {};
1401 
1402 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1403 struct token; \
1404 template<> \
1405 struct param_traits<detail:: token,param_name> \
1406 { \
1407  enum { value = param_name }; \
1408  typedef T param_type; \
1409 };
1410 
1411 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1412 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
1413 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1414 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
1415 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1416 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1417 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
1418 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
1419 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1420 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
1421 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
1422 CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1423 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
1424 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
1425 CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1426 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 220
1427 
1428 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1429 CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1430 #endif // #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1431 
1432 #if defined(CL_HPP_USE_IL_KHR)
1433 CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1434 #endif // #if defined(CL_HPP_USE_IL_KHR)
1435 
1436 
1437 // Flags deprecated in OpenCL 2.0
1438 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1439  F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1440 
1441 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1442  F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1443 
1444 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1445  F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1446 
1447 // Include deprecated query flags based on versions
1448 // Only include deprecated 1.0 flags if 2.0 not active as there is an enum clash
1449 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1450 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1451 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110
1452 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1453 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1454 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
1455 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1456 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1457 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
1458 
1459 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1460 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1461 #endif // CL_HPP_USE_CL_DEVICE_FISSION
1462 
1463 #if defined(cl_khr_extended_versioning)
1464 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_(CL_HPP_DECLARE_PARAM_TRAITS_);
1465 #endif // cl_khr_extended_versioning
1466 
1467 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1468 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, string)
1469 #endif
1470 
1471 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1472 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1473 #endif
1474 
1475 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1476 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1477 #endif
1478 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1479 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1480 #endif
1481 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1482 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1483 #endif
1484 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1485 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1486 #endif
1487 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1488 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1489 #endif
1490 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1491 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1492 #endif
1493 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1494 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1495 #endif
1496 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1497 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1498 #endif
1499 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1500 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1501 #endif
1502 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1503 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1504 #endif
1505 
1506 #ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1507 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1508 #endif
1509 #ifdef CL_DEVICE_JOB_SLOTS_ARM
1510 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1511 #endif
1512 #ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1513 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1514 #endif
1515 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1516 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1517 #endif
1518 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1519 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1520 #endif
1521 
1522 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1523 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1524 #endif
1525 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1526 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1527 #endif
1528 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1529 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1530 #endif
1531 #ifdef CL_DEVICE_WARP_SIZE_NV
1532 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1533 #endif
1534 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1535 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1536 #endif
1537 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1538 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1539 #endif
1540 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1541 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1542 #endif
1543 
1544 // Convenience functions
1545 
1546 template <typename Func, typename T>
1547 inline cl_int
1548 getInfo(Func f, cl_uint name, T* param)
1549 {
1550  return getInfoHelper(f, name, param, 0);
1551 }
1552 
1553 template <typename Func, typename Arg0>
1555 {
1556  Func f_; const Arg0& arg0_;
1557  cl_int operator ()(
1558  cl_uint param, size_type size, void* value, size_type* size_ret)
1559  { return f_(arg0_, param, size, value, size_ret); }
1560 };
1561 
1562 template <typename Func, typename Arg0, typename Arg1>
1564 {
1565  Func f_; const Arg0& arg0_; const Arg1& arg1_;
1566  cl_int operator ()(
1567  cl_uint param, size_type size, void* value, size_type* size_ret)
1568  { return f_(arg0_, arg1_, param, size, value, size_ret); }
1569 };
1570 
1571 template <typename Func, typename Arg0, typename T>
1572 inline cl_int
1573 getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
1574 {
1575  GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
1576  return getInfoHelper(f0, name, param, 0);
1577 }
1578 
1579 template <typename Func, typename Arg0, typename Arg1, typename T>
1580 inline cl_int
1581 getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
1582 {
1583  GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1584  return getInfoHelper(f0, name, param, 0);
1585 }
1586 
1587 
1588 template<typename T>
1590 { };
1591 
1592 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1593 
1596 template <>
1597 struct ReferenceHandler<cl_device_id>
1598 {
1608  static cl_int retain(cl_device_id device)
1609  { return ::clRetainDevice(device); }
1619  static cl_int release(cl_device_id device)
1620  { return ::clReleaseDevice(device); }
1621 };
1622 #else // CL_HPP_TARGET_OPENCL_VERSION >= 120
1623 
1626 template <>
1627 struct ReferenceHandler<cl_device_id>
1628 {
1629  // cl_device_id does not have retain().
1630  static cl_int retain(cl_device_id)
1631  { return CL_SUCCESS; }
1632  // cl_device_id does not have release().
1633  static cl_int release(cl_device_id)
1634  { return CL_SUCCESS; }
1635 };
1636 #endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120)
1637 
1638 template <>
1639 struct ReferenceHandler<cl_platform_id>
1640 {
1641  // cl_platform_id does not have retain().
1642  static cl_int retain(cl_platform_id)
1643  { return CL_SUCCESS; }
1644  // cl_platform_id does not have release().
1645  static cl_int release(cl_platform_id)
1646  { return CL_SUCCESS; }
1647 };
1648 
1649 template <>
1650 struct ReferenceHandler<cl_context>
1651 {
1652  static cl_int retain(cl_context context)
1653  { return ::clRetainContext(context); }
1654  static cl_int release(cl_context context)
1655  { return ::clReleaseContext(context); }
1656 };
1657 
1658 template <>
1659 struct ReferenceHandler<cl_command_queue>
1660 {
1661  static cl_int retain(cl_command_queue queue)
1662  { return ::clRetainCommandQueue(queue); }
1663  static cl_int release(cl_command_queue queue)
1664  { return ::clReleaseCommandQueue(queue); }
1665 };
1666 
1667 template <>
1668 struct ReferenceHandler<cl_mem>
1669 {
1670  static cl_int retain(cl_mem memory)
1671  { return ::clRetainMemObject(memory); }
1672  static cl_int release(cl_mem memory)
1673  { return ::clReleaseMemObject(memory); }
1674 };
1675 
1676 template <>
1677 struct ReferenceHandler<cl_sampler>
1678 {
1679  static cl_int retain(cl_sampler sampler)
1680  { return ::clRetainSampler(sampler); }
1681  static cl_int release(cl_sampler sampler)
1682  { return ::clReleaseSampler(sampler); }
1683 };
1684 
1685 template <>
1686 struct ReferenceHandler<cl_program>
1687 {
1688  static cl_int retain(cl_program program)
1689  { return ::clRetainProgram(program); }
1690  static cl_int release(cl_program program)
1691  { return ::clReleaseProgram(program); }
1692 };
1693 
1694 template <>
1695 struct ReferenceHandler<cl_kernel>
1696 {
1697  static cl_int retain(cl_kernel kernel)
1698  { return ::clRetainKernel(kernel); }
1699  static cl_int release(cl_kernel kernel)
1700  { return ::clReleaseKernel(kernel); }
1701 };
1702 
1703 template <>
1704 struct ReferenceHandler<cl_event>
1705 {
1706  static cl_int retain(cl_event event)
1707  { return ::clRetainEvent(event); }
1708  static cl_int release(cl_event event)
1709  { return ::clReleaseEvent(event); }
1710 };
1711 
1712 
1713 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1714 // Extracts version number with major in the upper 16 bits, minor in the lower 16
1715 static cl_uint getVersion(const vector<char> &versionInfo)
1716 {
1717  int highVersion = 0;
1718  int lowVersion = 0;
1719  int index = 7;
1720  while(versionInfo[index] != '.' ) {
1721  highVersion *= 10;
1722  highVersion += versionInfo[index]-'0';
1723  ++index;
1724  }
1725  ++index;
1726  while(versionInfo[index] != ' ' && versionInfo[index] != '\0') {
1727  lowVersion *= 10;
1728  lowVersion += versionInfo[index]-'0';
1729  ++index;
1730  }
1731  return (highVersion << 16) | lowVersion;
1732 }
1733 
1734 static cl_uint getPlatformVersion(cl_platform_id platform)
1735 {
1736  size_type size = 0;
1737  clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1738 
1739  vector<char> versionInfo(size);
1740  clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1741  return getVersion(versionInfo);
1742 }
1743 
1744 static cl_uint getDevicePlatformVersion(cl_device_id device)
1745 {
1746  cl_platform_id platform;
1747  clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
1748  return getPlatformVersion(platform);
1749 }
1750 
1751 static cl_uint getContextPlatformVersion(cl_context context)
1752 {
1753  // The platform cannot be queried directly, so we first have to grab a
1754  // device and obtain its context
1755  size_type size = 0;
1756  clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1757  if (size == 0)
1758  return 0;
1759  vector<cl_device_id> devices(size/sizeof(cl_device_id));
1760  clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1761  return getDevicePlatformVersion(devices[0]);
1762 }
1763 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1764 
1765 template <typename T>
1766 class Wrapper
1767 {
1768 public:
1769  typedef T cl_type;
1770 
1771 protected:
1772  cl_type object_;
1773 
1774 public:
1775  Wrapper() : object_(NULL) { }
1776 
1777  Wrapper(const cl_type &obj, bool retainObject) : object_(obj)
1778  {
1779  if (retainObject) {
1780  detail::errHandler(retain(), __RETAIN_ERR);
1781  }
1782  }
1783 
1784  ~Wrapper()
1785  {
1786  if (object_ != NULL) { release(); }
1787  }
1788 
1789  Wrapper(const Wrapper<cl_type>& rhs)
1790  {
1791  object_ = rhs.object_;
1792  detail::errHandler(retain(), __RETAIN_ERR);
1793  }
1794 
1795  Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT_
1796  {
1797  object_ = rhs.object_;
1798  rhs.object_ = NULL;
1799  }
1800 
1801  Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
1802  {
1803  if (this != &rhs) {
1804  detail::errHandler(release(), __RELEASE_ERR);
1805  object_ = rhs.object_;
1806  detail::errHandler(retain(), __RETAIN_ERR);
1807  }
1808  return *this;
1809  }
1810 
1811  Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
1812  {
1813  if (this != &rhs) {
1814  detail::errHandler(release(), __RELEASE_ERR);
1815  object_ = rhs.object_;
1816  rhs.object_ = NULL;
1817  }
1818  return *this;
1819  }
1820 
1821  Wrapper<cl_type>& operator = (const cl_type &rhs)
1822  {
1823  detail::errHandler(release(), __RELEASE_ERR);
1824  object_ = rhs;
1825  return *this;
1826  }
1827 
1828  const cl_type& operator ()() const { return object_; }
1829 
1830  cl_type& operator ()() { return object_; }
1831 
1832  cl_type get() const { return object_; }
1833 
1834 protected:
1835  template<typename Func, typename U>
1836  friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
1837 
1838  cl_int retain() const
1839  {
1840  if (object_ != nullptr) {
1841  return ReferenceHandler<cl_type>::retain(object_);
1842  }
1843  else {
1844  return CL_SUCCESS;
1845  }
1846  }
1847 
1848  cl_int release() const
1849  {
1850  if (object_ != nullptr) {
1851  return ReferenceHandler<cl_type>::release(object_);
1852  }
1853  else {
1854  return CL_SUCCESS;
1855  }
1856  }
1857 };
1858 
1859 template <>
1860 class Wrapper<cl_device_id>
1861 {
1862 public:
1863  typedef cl_device_id cl_type;
1864 
1865 protected:
1866  cl_type object_;
1867  bool referenceCountable_;
1868 
1869  static bool isReferenceCountable(cl_device_id device)
1870  {
1871  bool retVal = false;
1872 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1873 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1874  if (device != NULL) {
1875  int version = getDevicePlatformVersion(device);
1876  if(version > ((1 << 16) + 1)) {
1877  retVal = true;
1878  }
1879  }
1880 #else // CL_HPP_MINIMUM_OPENCL_VERSION < 120
1881  retVal = true;
1882 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
1883 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
1884  return retVal;
1885  }
1886 
1887 public:
1888  Wrapper() : object_(NULL), referenceCountable_(false)
1889  {
1890  }
1891 
1892  Wrapper(const cl_type &obj, bool retainObject) :
1893  object_(obj),
1894  referenceCountable_(false)
1895  {
1896  referenceCountable_ = isReferenceCountable(obj);
1897 
1898  if (retainObject) {
1899  detail::errHandler(retain(), __RETAIN_ERR);
1900  }
1901  }
1902 
1903  ~Wrapper()
1904  {
1905  release();
1906  }
1907 
1908  Wrapper(const Wrapper<cl_type>& rhs)
1909  {
1910  object_ = rhs.object_;
1911  referenceCountable_ = isReferenceCountable(object_);
1912  detail::errHandler(retain(), __RETAIN_ERR);
1913  }
1914 
1915  Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT_
1916  {
1917  object_ = rhs.object_;
1918  referenceCountable_ = rhs.referenceCountable_;
1919  rhs.object_ = NULL;
1920  rhs.referenceCountable_ = false;
1921  }
1922 
1923  Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
1924  {
1925  if (this != &rhs) {
1926  detail::errHandler(release(), __RELEASE_ERR);
1927  object_ = rhs.object_;
1928  referenceCountable_ = rhs.referenceCountable_;
1929  detail::errHandler(retain(), __RETAIN_ERR);
1930  }
1931  return *this;
1932  }
1933 
1934  Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
1935  {
1936  if (this != &rhs) {
1937  detail::errHandler(release(), __RELEASE_ERR);
1938  object_ = rhs.object_;
1939  referenceCountable_ = rhs.referenceCountable_;
1940  rhs.object_ = NULL;
1941  rhs.referenceCountable_ = false;
1942  }
1943  return *this;
1944  }
1945 
1946  Wrapper<cl_type>& operator = (const cl_type &rhs)
1947  {
1948  detail::errHandler(release(), __RELEASE_ERR);
1949  object_ = rhs;
1950  referenceCountable_ = isReferenceCountable(object_);
1951  return *this;
1952  }
1953 
1954  const cl_type& operator ()() const { return object_; }
1955 
1956  cl_type& operator ()() { return object_; }
1957 
1958  cl_type get() const { return object_; }
1959 
1960 protected:
1961  template<typename Func, typename U>
1962  friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
1963 
1964  template<typename Func, typename U>
1965  friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*, int, typename U::cl_type);
1966 
1967  cl_int retain() const
1968  {
1969  if( object_ != nullptr && referenceCountable_ ) {
1970  return ReferenceHandler<cl_type>::retain(object_);
1971  }
1972  else {
1973  return CL_SUCCESS;
1974  }
1975  }
1976 
1977  cl_int release() const
1978  {
1979  if (object_ != nullptr && referenceCountable_) {
1980  return ReferenceHandler<cl_type>::release(object_);
1981  }
1982  else {
1983  return CL_SUCCESS;
1984  }
1985  }
1986 };
1987 
1988 template <typename T>
1989 inline bool operator==(const Wrapper<T> &lhs, const Wrapper<T> &rhs)
1990 {
1991  return lhs() == rhs();
1992 }
1993 
1994 template <typename T>
1995 inline bool operator!=(const Wrapper<T> &lhs, const Wrapper<T> &rhs)
1996 {
1997  return !operator==(lhs, rhs);
1998 }
1999 
2000 } // namespace detail
2002 
2003 
2004 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2005 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2006 
2009 class BuildError : public Error
2010 {
2011 private:
2012  BuildLogType buildLogs;
2013 public:
2014  BuildError(cl_int err, const char * errStr, const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2015  {
2016  }
2017 
2018  BuildLogType getBuildLog() const
2019  {
2020  return buildLogs;
2021  }
2022 };
2023 namespace detail {
2024  static inline cl_int buildErrHandler(
2025  cl_int err,
2026  const char * errStr,
2027  const BuildLogType &buildLogs)
2028  {
2029  if (err != CL_SUCCESS) {
2030  throw BuildError(err, errStr, buildLogs);
2031  }
2032  return err;
2033  }
2034 } // namespace detail
2035 
2036 #else
2037 namespace detail {
2038  static inline cl_int buildErrHandler(
2039  cl_int err,
2040  const char * errStr,
2041  const BuildLogType &buildLogs)
2042  {
2043  (void)buildLogs; // suppress unused variable warning
2044  (void)errStr;
2045  return err;
2046  }
2047 } // namespace detail
2048 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2049 
2050 
2056 struct ImageFormat : public cl_image_format
2057 {
2060 
2062  ImageFormat(cl_channel_order order, cl_channel_type type)
2063  {
2064  image_channel_order = order;
2065  image_channel_data_type = type;
2066  }
2067 
2070  {
2071  if (this != &rhs) {
2072  this->image_channel_data_type = rhs.image_channel_data_type;
2073  this->image_channel_order = rhs.image_channel_order;
2074  }
2075  return *this;
2076  }
2077 };
2078 
2086 class Device : public detail::Wrapper<cl_device_id>
2087 {
2088 private:
2089  static std::once_flag default_initialized_;
2090  static Device default_;
2091  static cl_int default_error_;
2092 
2098  static void makeDefault();
2099 
2105  static void makeDefaultProvided(const Device &p) {
2106  default_ = p;
2107  }
2108 
2109 public:
2110 #ifdef CL_HPP_UNIT_TEST_ENABLE
2111 
2117  static void unitTestClearDefault() {
2118  default_ = Device();
2119  }
2120 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
2121 
2123  Device() : detail::Wrapper<cl_type>() { }
2124 
2129  explicit Device(const cl_device_id &device, bool retainObject = false) :
2130  detail::Wrapper<cl_type>(device, retainObject) { }
2131 
2137  cl_int *errResult = NULL)
2138  {
2139  std::call_once(default_initialized_, makeDefault);
2140  detail::errHandler(default_error_);
2141  if (errResult != NULL) {
2142  *errResult = default_error_;
2143  }
2144  return default_;
2145  }
2146 
2154  static Device setDefault(const Device &default_device)
2155  {
2156  std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2157  detail::errHandler(default_error_);
2158  return default_;
2159  }
2160 
2165  Device& operator = (const cl_device_id& rhs)
2166  {
2168  return *this;
2169  }
2170 
2174  Device(const Device& dev) : detail::Wrapper<cl_type>(dev) {}
2175 
2180  {
2182  return *this;
2183  }
2184 
2188  Device(Device&& dev) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(dev)) {}
2189 
2194  {
2195  detail::Wrapper<cl_type>::operator=(std::move(dev));
2196  return *this;
2197  }
2198 
2200  template <typename T>
2201  cl_int getInfo(cl_device_info name, T* param) const
2202  {
2203  return detail::errHandler(
2204  detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2205  __GET_DEVICE_INFO_ERR);
2206  }
2207 
2209  template <cl_device_info name> typename
2211  getInfo(cl_int* err = NULL) const
2212  {
2213  typename detail::param_traits<
2214  detail::cl_device_info, name>::param_type param;
2215  cl_int result = getInfo(name, &param);
2216  if (err != NULL) {
2217  *err = result;
2218  }
2219  return param;
2220  }
2221 
2222 
2223 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2224 
2230  cl_ulong getHostTimer(cl_int *error = nullptr)
2231  {
2232  cl_ulong retVal = 0;
2233  cl_int err =
2234  clGetHostTimer(this->get(), &retVal);
2235  detail::errHandler(
2236  err,
2237  __GET_HOST_TIMER_ERR);
2238  if (error) {
2239  *error = err;
2240  }
2241  return retVal;
2242  }
2243 
2254  std::pair<cl_ulong, cl_ulong> getDeviceAndHostTimer(cl_int *error = nullptr)
2255  {
2256  std::pair<cl_ulong, cl_ulong> retVal;
2257  cl_int err =
2258  clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2259  detail::errHandler(
2260  err,
2261  __GET_DEVICE_AND_HOST_TIMER_ERR);
2262  if (error) {
2263  *error = err;
2264  }
2265  return retVal;
2266  }
2267 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2268 
2272 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2273  cl_int createSubDevices(
2275  const cl_device_partition_property * properties,
2276  vector<Device>* devices)
2277  {
2278  cl_uint n = 0;
2279  cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2280  if (err != CL_SUCCESS) {
2281  return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2282  }
2283 
2284  vector<cl_device_id> ids(n);
2285  err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2286  if (err != CL_SUCCESS) {
2287  return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2288  }
2289 
2290  // Cannot trivially assign because we need to capture intermediates
2291  // with safe construction
2292  if (devices) {
2293  devices->resize(ids.size());
2294 
2295  // Assign to param, constructing with retain behaviour
2296  // to correctly capture each underlying CL object
2297  for (size_type i = 0; i < ids.size(); i++) {
2298  // We do not need to retain because this device is being created
2299  // by the runtime
2300  (*devices)[i] = Device(ids[i], false);
2301  }
2302  }
2303 
2304  return CL_SUCCESS;
2305  }
2306 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2307 
2311  cl_int createSubDevices(
2312  const cl_device_partition_property_ext * properties,
2313  vector<Device>* devices)
2314  {
2315  typedef CL_API_ENTRY cl_int
2316  ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2317  cl_device_id /*in_device*/,
2318  const cl_device_partition_property_ext * /* properties */,
2319  cl_uint /*num_entries*/,
2320  cl_device_id * /*out_devices*/,
2321  cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
2322 
2323  static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2324  CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2325 
2326  cl_uint n = 0;
2327  cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2328  if (err != CL_SUCCESS) {
2329  return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2330  }
2331 
2332  vector<cl_device_id> ids(n);
2333  err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2334  if (err != CL_SUCCESS) {
2335  return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2336  }
2337  // Cannot trivially assign because we need to capture intermediates
2338  // with safe construction
2339  if (devices) {
2340  devices->resize(ids.size());
2341 
2342  // Assign to param, constructing with retain behaviour
2343  // to correctly capture each underlying CL object
2344  for (size_type i = 0; i < ids.size(); i++) {
2345  // We do not need to retain because this device is being created
2346  // by the runtime
2347  (*devices)[i] = Device(ids[i], false);
2348  }
2349  }
2350  return CL_SUCCESS;
2351  }
2352 #endif // defined(CL_HPP_USE_CL_DEVICE_FISSION)
2353 };
2354 
2355 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2356 CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2357 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2358 
2366 class Platform : public detail::Wrapper<cl_platform_id>
2367 {
2368 private:
2369  static std::once_flag default_initialized_;
2370  static Platform default_;
2371  static cl_int default_error_;
2372 
2378  static void makeDefault() {
2379  /* Throwing an exception from a call_once invocation does not do
2380  * what we wish, so we catch it and save the error.
2381  */
2382 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2383  try
2384 #endif
2385  {
2386  // If default wasn't passed ,generate one
2387  // Otherwise set it
2388  cl_uint n = 0;
2389 
2390  cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2391  if (err != CL_SUCCESS) {
2392  default_error_ = err;
2393  return;
2394  }
2395  if (n == 0) {
2396  default_error_ = CL_INVALID_PLATFORM;
2397  return;
2398  }
2399 
2400  vector<cl_platform_id> ids(n);
2401  err = ::clGetPlatformIDs(n, ids.data(), NULL);
2402  if (err != CL_SUCCESS) {
2403  default_error_ = err;
2404  return;
2405  }
2406 
2407  default_ = Platform(ids[0]);
2408  }
2409 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2410  catch (cl::Error &e) {
2411  default_error_ = e.err();
2412  }
2413 #endif
2414  }
2415 
2421  static void makeDefaultProvided(const Platform &p) {
2422  default_ = p;
2423  }
2424 
2425 public:
2426 #ifdef CL_HPP_UNIT_TEST_ENABLE
2427 
2433  static void unitTestClearDefault() {
2434  default_ = Platform();
2435  }
2436 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
2437 
2439  Platform() : detail::Wrapper<cl_type>() { }
2440 
2448  explicit Platform(const cl_platform_id &platform, bool retainObject = false) :
2449  detail::Wrapper<cl_type>(platform, retainObject) { }
2450 
2455  Platform& operator = (const cl_platform_id& rhs)
2456  {
2458  return *this;
2459  }
2460 
2461  static Platform getDefault(
2462  cl_int *errResult = NULL)
2463  {
2464  std::call_once(default_initialized_, makeDefault);
2465  detail::errHandler(default_error_);
2466  if (errResult != NULL) {
2467  *errResult = default_error_;
2468  }
2469  return default_;
2470  }
2471 
2479  static Platform setDefault(const Platform &default_platform)
2480  {
2481  std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2482  detail::errHandler(default_error_);
2483  return default_;
2484  }
2485 
2487  template <typename T>
2488  cl_int getInfo(cl_platform_info name, T* param) const
2489  {
2490  return detail::errHandler(
2491  detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2492  __GET_PLATFORM_INFO_ERR);
2493  }
2494 
2496  template <cl_platform_info name> typename
2498  getInfo(cl_int* err = NULL) const
2499  {
2500  typename detail::param_traits<
2501  detail::cl_platform_info, name>::param_type param;
2502  cl_int result = getInfo(name, &param);
2503  if (err != NULL) {
2504  *err = result;
2505  }
2506  return param;
2507  }
2508 
2513  cl_int getDevices(
2514  cl_device_type type,
2515  vector<Device>* devices) const
2516  {
2517  cl_uint n = 0;
2518  if( devices == NULL ) {
2519  return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2520  }
2521  cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2522  if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2523  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2524  }
2525 
2526  vector<cl_device_id> ids(n);
2527  if (n>0) {
2528  err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2529  if (err != CL_SUCCESS) {
2530  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2531  }
2532  }
2533 
2534  // Cannot trivially assign because we need to capture intermediates
2535  // with safe construction
2536  // We must retain things we obtain from the API to avoid releasing
2537  // API-owned objects.
2538  if (devices) {
2539  devices->resize(ids.size());
2540 
2541  // Assign to param, constructing with retain behaviour
2542  // to correctly capture each underlying CL object
2543  for (size_type i = 0; i < ids.size(); i++) {
2544  (*devices)[i] = Device(ids[i], true);
2545  }
2546  }
2547  return CL_SUCCESS;
2548  }
2549 
2550 #if defined(CL_HPP_USE_DX_INTEROP)
2551 
2574  cl_int getDevices(
2575  cl_d3d10_device_source_khr d3d_device_source,
2576  void * d3d_object,
2577  cl_d3d10_device_set_khr d3d_device_set,
2578  vector<Device>* devices) const
2579  {
2580  typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2581  cl_platform_id platform,
2582  cl_d3d10_device_source_khr d3d_device_source,
2583  void * d3d_object,
2584  cl_d3d10_device_set_khr d3d_device_set,
2585  cl_uint num_entries,
2586  cl_device_id * devices,
2587  cl_uint* num_devices);
2588 
2589  if( devices == NULL ) {
2590  return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2591  }
2592 
2593  static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2594  CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2595 
2596  cl_uint n = 0;
2597  cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2598  object_,
2599  d3d_device_source,
2600  d3d_object,
2601  d3d_device_set,
2602  0,
2603  NULL,
2604  &n);
2605  if (err != CL_SUCCESS) {
2606  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2607  }
2608 
2609  vector<cl_device_id> ids(n);
2610  err = pfn_clGetDeviceIDsFromD3D10KHR(
2611  object_,
2612  d3d_device_source,
2613  d3d_object,
2614  d3d_device_set,
2615  n,
2616  ids.data(),
2617  NULL);
2618  if (err != CL_SUCCESS) {
2619  return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2620  }
2621 
2622  // Cannot trivially assign because we need to capture intermediates
2623  // with safe construction
2624  // We must retain things we obtain from the API to avoid releasing
2625  // API-owned objects.
2626  if (devices) {
2627  devices->resize(ids.size());
2628 
2629  // Assign to param, constructing with retain behaviour
2630  // to correctly capture each underlying CL object
2631  for (size_type i = 0; i < ids.size(); i++) {
2632  (*devices)[i] = Device(ids[i], true);
2633  }
2634  }
2635  return CL_SUCCESS;
2636  }
2637 #endif
2638 
2643  static cl_int get(
2644  vector<Platform>* platforms)
2645  {
2646  cl_uint n = 0;
2647 
2648  if( platforms == NULL ) {
2649  return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2650  }
2651 
2652  cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2653  if (err != CL_SUCCESS) {
2654  return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2655  }
2656 
2657  vector<cl_platform_id> ids(n);
2658  err = ::clGetPlatformIDs(n, ids.data(), NULL);
2659  if (err != CL_SUCCESS) {
2660  return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2661  }
2662 
2663  if (platforms) {
2664  platforms->resize(ids.size());
2665 
2666  // Platforms don't reference count
2667  for (size_type i = 0; i < ids.size(); i++) {
2668  (*platforms)[i] = Platform(ids[i]);
2669  }
2670  }
2671  return CL_SUCCESS;
2672  }
2673 
2678  static cl_int get(
2679  Platform * platform)
2680  {
2681  cl_int err;
2682  Platform default_platform = Platform::getDefault(&err);
2683  if (platform) {
2684  *platform = default_platform;
2685  }
2686  return err;
2687  }
2688 
2697  static Platform get(
2698  cl_int * errResult = NULL)
2699  {
2700  cl_int err;
2701  Platform default_platform = Platform::getDefault(&err);
2702  if (errResult) {
2703  *errResult = err;
2704  }
2705  return default_platform;
2706  }
2707 
2708 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2709  cl_int
2712  {
2713  return ::clUnloadPlatformCompiler(object_);
2714  }
2715 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
2716 }; // class Platform
2717 
2718 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2719 CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2720 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2721 
2722 
2726 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2727 
2731 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
2732 UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
2733 inline cl_int
2735 {
2736  return ::clUnloadCompiler();
2737 }
2738 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2739 
2748 class Context
2749  : public detail::Wrapper<cl_context>
2750 {
2751 private:
2752  static std::once_flag default_initialized_;
2753  static Context default_;
2754  static cl_int default_error_;
2755 
2761  static void makeDefault() {
2762  /* Throwing an exception from a call_once invocation does not do
2763  * what we wish, so we catch it and save the error.
2764  */
2765 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2766  try
2767 #endif
2768  {
2769 #if !defined(__APPLE__) && !defined(__MACOS)
2770  const Platform &p = Platform::getDefault();
2771  cl_platform_id defaultPlatform = p();
2772  cl_context_properties properties[3] = {
2773  CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2774  };
2775 #else // #if !defined(__APPLE__) && !defined(__MACOS)
2776  cl_context_properties *properties = nullptr;
2777 #endif // #if !defined(__APPLE__) && !defined(__MACOS)
2778 
2779  default_ = Context(
2780  CL_DEVICE_TYPE_DEFAULT,
2781  properties,
2782  NULL,
2783  NULL,
2784  &default_error_);
2785  }
2786 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2787  catch (cl::Error &e) {
2788  default_error_ = e.err();
2789  }
2790 #endif
2791  }
2792 
2793 
2799  static void makeDefaultProvided(const Context &c) {
2800  default_ = c;
2801  }
2802 
2803 public:
2804 #ifdef CL_HPP_UNIT_TEST_ENABLE
2805 
2811  static void unitTestClearDefault() {
2812  default_ = Context();
2813  }
2814 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
2815 
2821  const vector<Device>& devices,
2822  cl_context_properties* properties = NULL,
2823  void (CL_CALLBACK * notifyFptr)(
2824  const char *,
2825  const void *,
2826  size_type,
2827  void *) = NULL,
2828  void* data = NULL,
2829  cl_int* err = NULL)
2830  {
2831  cl_int error;
2832 
2833  size_type numDevices = devices.size();
2834  vector<cl_device_id> deviceIDs(numDevices);
2835 
2836  for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2837  deviceIDs[deviceIndex] = (devices[deviceIndex])();
2838  }
2839 
2840  object_ = ::clCreateContext(
2841  properties, (cl_uint) numDevices,
2842  deviceIDs.data(),
2843  notifyFptr, data, &error);
2844 
2845  detail::errHandler(error, __CREATE_CONTEXT_ERR);
2846  if (err != NULL) {
2847  *err = error;
2848  }
2849  }
2850 
2856  const Device& device,
2857  cl_context_properties* properties = NULL,
2858  void (CL_CALLBACK * notifyFptr)(
2859  const char *,
2860  const void *,
2861  size_type,
2862  void *) = NULL,
2863  void* data = NULL,
2864  cl_int* err = NULL)
2865  {
2866  cl_int error;
2867 
2868  cl_device_id deviceID = device();
2869 
2870  object_ = ::clCreateContext(
2871  properties, 1,
2872  &deviceID,
2873  notifyFptr, data, &error);
2874 
2875  detail::errHandler(error, __CREATE_CONTEXT_ERR);
2876  if (err != NULL) {
2877  *err = error;
2878  }
2879  }
2880 
2886  cl_device_type type,
2887  cl_context_properties* properties = NULL,
2888  void (CL_CALLBACK * notifyFptr)(
2889  const char *,
2890  const void *,
2891  size_type,
2892  void *) = NULL,
2893  void* data = NULL,
2894  cl_int* err = NULL)
2895  {
2896  cl_int error;
2897 
2898 #if !defined(__APPLE__) && !defined(__MACOS)
2899  cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2900 
2901  if (properties == NULL) {
2902  // Get a valid platform ID as we cannot send in a blank one
2903  vector<Platform> platforms;
2904  error = Platform::get(&platforms);
2905  if (error != CL_SUCCESS) {
2906  detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2907  if (err != NULL) {
2908  *err = error;
2909  }
2910  return;
2911  }
2912 
2913  // Check the platforms we found for a device of our specified type
2914  cl_context_properties platform_id = 0;
2915  for (unsigned int i = 0; i < platforms.size(); i++) {
2916 
2917  vector<Device> devices;
2918 
2919 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2920  try {
2921 #endif
2922 
2923  error = platforms[i].getDevices(type, &devices);
2924 
2925 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2926  } catch (cl::Error& e) {
2927  error = e.err();
2928  }
2929  // Catch if exceptions are enabled as we don't want to exit if first platform has no devices of type
2930  // We do error checking next anyway, and can throw there if needed
2931 #endif
2932 
2933  // Only squash CL_SUCCESS and CL_DEVICE_NOT_FOUND
2934  if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2935  detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2936  if (err != NULL) {
2937  *err = error;
2938  }
2939  }
2940 
2941  if (devices.size() > 0) {
2942  platform_id = (cl_context_properties)platforms[i]();
2943  break;
2944  }
2945  }
2946 
2947  if (platform_id == 0) {
2948  detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
2949  if (err != NULL) {
2950  *err = CL_DEVICE_NOT_FOUND;
2951  }
2952  return;
2953  }
2954 
2955  prop[1] = platform_id;
2956  properties = &prop[0];
2957  }
2958 #endif
2959  object_ = ::clCreateContextFromType(
2960  properties, type, notifyFptr, data, &error);
2961 
2962  detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2963  if (err != NULL) {
2964  *err = error;
2965  }
2966  }
2967 
2971  Context(const Context& ctx) : detail::Wrapper<cl_type>(ctx) {}
2972 
2977  {
2979  return *this;
2980  }
2981 
2985  Context(Context&& ctx) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(ctx)) {}
2986 
2991  {
2992  detail::Wrapper<cl_type>::operator=(std::move(ctx));
2993  return *this;
2994  }
2995 
2996 
3001  static Context getDefault(cl_int * err = NULL)
3002  {
3003  std::call_once(default_initialized_, makeDefault);
3004  detail::errHandler(default_error_);
3005  if (err != NULL) {
3006  *err = default_error_;
3007  }
3008  return default_;
3009  }
3010 
3018  static Context setDefault(const Context &default_context)
3019  {
3020  std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3021  detail::errHandler(default_error_);
3022  return default_;
3023  }
3024 
3026  Context() : detail::Wrapper<cl_type>() { }
3027 
3033  explicit Context(const cl_context& context, bool retainObject = false) :
3034  detail::Wrapper<cl_type>(context, retainObject) { }
3035 
3041  Context& operator = (const cl_context& rhs)
3042  {
3044  return *this;
3045  }
3046 
3048  template <typename T>
3049  cl_int getInfo(cl_context_info name, T* param) const
3050  {
3051  return detail::errHandler(
3052  detail::getInfo(&::clGetContextInfo, object_, name, param),
3053  __GET_CONTEXT_INFO_ERR);
3054  }
3055 
3057  template <cl_context_info name> typename
3059  getInfo(cl_int* err = NULL) const
3060  {
3061  typename detail::param_traits<
3062  detail::cl_context_info, name>::param_type param;
3063  cl_int result = getInfo(name, &param);
3064  if (err != NULL) {
3065  *err = result;
3066  }
3067  return param;
3068  }
3069 
3075  cl_mem_flags flags,
3076  cl_mem_object_type type,
3077  vector<ImageFormat>* formats) const
3078  {
3079  cl_uint numEntries;
3080 
3081  if (!formats) {
3082  return CL_SUCCESS;
3083  }
3084 
3085  cl_int err = ::clGetSupportedImageFormats(
3086  object_,
3087  flags,
3088  type,
3089  0,
3090  NULL,
3091  &numEntries);
3092  if (err != CL_SUCCESS) {
3093  return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3094  }
3095 
3096  if (numEntries > 0) {
3097  vector<ImageFormat> value(numEntries);
3098  err = ::clGetSupportedImageFormats(
3099  object_,
3100  flags,
3101  type,
3102  numEntries,
3103  (cl_image_format*)value.data(),
3104  NULL);
3105  if (err != CL_SUCCESS) {
3106  return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3107  }
3108 
3109  formats->assign(begin(value), end(value));
3110  }
3111  else {
3112  // If no values are being returned, ensure an empty vector comes back
3113  formats->clear();
3114  }
3115 
3116  return CL_SUCCESS;
3117  }
3118 };
3119 
3120 inline void Device::makeDefault()
3121 {
3122  /* Throwing an exception from a call_once invocation does not do
3123  * what we wish, so we catch it and save the error.
3124  */
3125 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3126  try
3127 #endif
3128  {
3129  cl_int error = 0;
3130 
3131  Context context = Context::getDefault(&error);
3132  detail::errHandler(error, __CREATE_CONTEXT_ERR);
3133 
3134  if (error != CL_SUCCESS) {
3135  default_error_ = error;
3136  }
3137  else {
3138  default_ = context.getInfo<CL_CONTEXT_DEVICES>()[0];
3139  default_error_ = CL_SUCCESS;
3140  }
3141  }
3142 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3143  catch (cl::Error &e) {
3144  default_error_ = e.err();
3145  }
3146 #endif
3147 }
3148 
3149 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3150 CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3151 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3152 
3161 class Event : public detail::Wrapper<cl_event>
3162 {
3163 public:
3165  Event() : detail::Wrapper<cl_type>() { }
3166 
3175  explicit Event(const cl_event& event, bool retainObject = false) :
3176  detail::Wrapper<cl_type>(event, retainObject) { }
3177 
3183  Event& operator = (const cl_event& rhs)
3184  {
3186  return *this;
3187  }
3188 
3190  template <typename T>
3191  cl_int getInfo(cl_event_info name, T* param) const
3192  {
3193  return detail::errHandler(
3194  detail::getInfo(&::clGetEventInfo, object_, name, param),
3195  __GET_EVENT_INFO_ERR);
3196  }
3197 
3199  template <cl_event_info name> typename
3201  getInfo(cl_int* err = NULL) const
3202  {
3203  typename detail::param_traits<
3204  detail::cl_event_info, name>::param_type param;
3205  cl_int result = getInfo(name, &param);
3206  if (err != NULL) {
3207  *err = result;
3208  }
3209  return param;
3210  }
3211 
3213  template <typename T>
3214  cl_int getProfilingInfo(cl_profiling_info name, T* param) const
3215  {
3216  return detail::errHandler(detail::getInfo(
3217  &::clGetEventProfilingInfo, object_, name, param),
3218  __GET_EVENT_PROFILE_INFO_ERR);
3219  }
3220 
3222  template <cl_profiling_info name> typename
3224  getProfilingInfo(cl_int* err = NULL) const
3225  {
3226  typename detail::param_traits<
3227  detail::cl_profiling_info, name>::param_type param;
3228  cl_int result = getProfilingInfo(name, &param);
3229  if (err != NULL) {
3230  *err = result;
3231  }
3232  return param;
3233  }
3234 
3239  cl_int wait() const
3240  {
3241  return detail::errHandler(
3242  ::clWaitForEvents(1, &object_),
3243  __WAIT_FOR_EVENTS_ERR);
3244  }
3245 
3246 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3247 
3251  cl_int setCallback(
3252  cl_int type,
3253  void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *),
3254  void * user_data = NULL)
3255  {
3256  return detail::errHandler(
3257  ::clSetEventCallback(
3258  object_,
3259  type,
3260  pfn_notify,
3261  user_data),
3262  __SET_EVENT_CALLBACK_ERR);
3263  }
3264 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
3265 
3270  static cl_int
3271  waitForEvents(const vector<Event>& events)
3272  {
3273  return detail::errHandler(
3274  ::clWaitForEvents(
3275  (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3276  __WAIT_FOR_EVENTS_ERR);
3277  }
3278 };
3279 
3280 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3281 
3285 class UserEvent : public Event
3286 {
3287 public:
3293  const Context& context,
3294  cl_int * err = NULL)
3295  {
3296  cl_int error;
3297  object_ = ::clCreateUserEvent(
3298  context(),
3299  &error);
3300 
3301  detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3302  if (err != NULL) {
3303  *err = error;
3304  }
3305  }
3306 
3308  UserEvent() : Event() { }
3309 
3314  cl_int setStatus(cl_int status)
3315  {
3316  return detail::errHandler(
3317  ::clSetUserEventStatus(object_,status),
3318  __SET_USER_EVENT_STATUS_ERR);
3319  }
3320 };
3321 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
3322 
3327 inline static cl_int
3328 WaitForEvents(const vector<Event>& events)
3329 {
3330  return detail::errHandler(
3331  ::clWaitForEvents(
3332  (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3333  __WAIT_FOR_EVENTS_ERR);
3334 }
3335 
3344 class Memory : public detail::Wrapper<cl_mem>
3345 {
3346 public:
3348  Memory() : detail::Wrapper<cl_type>() { }
3349 
3361  explicit Memory(const cl_mem& memory, bool retainObject) :
3362  detail::Wrapper<cl_type>(memory, retainObject) { }
3363 
3369  Memory& operator = (const cl_mem& rhs)
3370  {
3372  return *this;
3373  }
3374 
3378  Memory(const Memory& mem) : detail::Wrapper<cl_type>(mem) {}
3379 
3384  {
3386  return *this;
3387  }
3388 
3392  Memory(Memory&& mem) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(mem)) {}
3393 
3398  {
3399  detail::Wrapper<cl_type>::operator=(std::move(mem));
3400  return *this;
3401  }
3402 
3403 
3405  template <typename T>
3406  cl_int getInfo(cl_mem_info name, T* param) const
3407  {
3408  return detail::errHandler(
3409  detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3410  __GET_MEM_OBJECT_INFO_ERR);
3411  }
3412 
3414  template <cl_mem_info name> typename
3416  getInfo(cl_int* err = NULL) const
3417  {
3418  typename detail::param_traits<
3419  detail::cl_mem_info, name>::param_type param;
3420  cl_int result = getInfo(name, &param);
3421  if (err != NULL) {
3422  *err = result;
3423  }
3424  return param;
3425  }
3426 
3427 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3428 
3442  void (CL_CALLBACK * pfn_notify)(cl_mem, void *),
3443  void * user_data = NULL)
3444  {
3445  return detail::errHandler(
3446  ::clSetMemObjectDestructorCallback(
3447  object_,
3448  pfn_notify,
3449  user_data),
3450  __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3451  }
3452 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
3453 
3454 };
3455 
3456 // Pre-declare copy functions
3457 class Buffer;
3458 template< typename IteratorType >
3459 cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
3460 template< typename IteratorType >
3461 cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3462 template< typename IteratorType >
3463 cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
3464 template< typename IteratorType >
3465 cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3466 
3467 
3468 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3469 namespace detail
3470 {
3472  {
3473  public:
3474  static cl_svm_mem_flags getSVMMemFlags()
3475  {
3476  return 0;
3477  }
3478  };
3479 } // namespace detail
3480 
3481 template<class Trait = detail::SVMTraitNull>
3483 {
3484 public:
3485  static cl_svm_mem_flags getSVMMemFlags()
3486  {
3487  return CL_MEM_READ_WRITE |
3488  Trait::getSVMMemFlags();
3489  }
3490 };
3491 
3492 template<class Trait = detail::SVMTraitNull>
3494 {
3495 public:
3496  static cl_svm_mem_flags getSVMMemFlags()
3497  {
3498  return CL_MEM_READ_ONLY |
3499  Trait::getSVMMemFlags();
3500  }
3501 };
3502 
3503 template<class Trait = detail::SVMTraitNull>
3505 {
3506 public:
3507  static cl_svm_mem_flags getSVMMemFlags()
3508  {
3509  return CL_MEM_WRITE_ONLY |
3510  Trait::getSVMMemFlags();
3511  }
3512 };
3513 
3514 template<class Trait = SVMTraitReadWrite<>>
3516 {
3517 public:
3518  static cl_svm_mem_flags getSVMMemFlags()
3519  {
3520  return Trait::getSVMMemFlags();
3521  }
3522 };
3523 
3524 template<class Trait = SVMTraitReadWrite<>>
3526 {
3527 public:
3528  static cl_svm_mem_flags getSVMMemFlags()
3529  {
3530  return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3531  Trait::getSVMMemFlags();
3532  }
3533 };
3534 
3535 template<class Trait = SVMTraitReadWrite<>>
3537 {
3538 public:
3539  static cl_svm_mem_flags getSVMMemFlags()
3540  {
3541  return
3542  CL_MEM_SVM_FINE_GRAIN_BUFFER |
3543  CL_MEM_SVM_ATOMICS |
3544  Trait::getSVMMemFlags();
3545  }
3546 };
3547 
3548 // Pre-declare SVM map function
3549 template<typename T>
3550 inline cl_int enqueueMapSVM(
3551  T* ptr,
3552  cl_bool blocking,
3553  cl_map_flags flags,
3554  size_type size,
3555  const vector<Event>* events = NULL,
3556  Event* event = NULL);
3557 
3569 template<typename T, class SVMTrait>
3571 private:
3572  Context context_;
3573 
3574 public:
3575  typedef T value_type;
3576  typedef value_type* pointer;
3577  typedef const value_type* const_pointer;
3578  typedef value_type& reference;
3579  typedef const value_type& const_reference;
3580  typedef std::size_t size_type;
3581  typedef std::ptrdiff_t difference_type;
3582 
3583  template<typename U>
3584  struct rebind
3585  {
3587  };
3588 
3589  template<typename U, typename V>
3590  friend class SVMAllocator;
3591 
3592  SVMAllocator() :
3593  context_(Context::getDefault())
3594  {
3595  }
3596 
3597  explicit SVMAllocator(cl::Context context) :
3598  context_(context)
3599  {
3600  }
3601 
3602 
3603  SVMAllocator(const SVMAllocator &other) :
3604  context_(other.context_)
3605  {
3606  }
3607 
3608  template<typename U>
3609  SVMAllocator(const SVMAllocator<U, SVMTrait> &other) :
3610  context_(other.context_)
3611  {
3612  }
3613 
3614  ~SVMAllocator()
3615  {
3616  }
3617 
3618  pointer address(reference r) CL_HPP_NOEXCEPT_
3619  {
3620  return std::addressof(r);
3621  }
3622 
3623  const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3624  {
3625  return std::addressof(r);
3626  }
3627 
3634  pointer allocate(
3635  size_type size,
3637  {
3638  // Allocate memory with default alignment matching the size of the type
3639  void* voidPointer =
3640  clSVMAlloc(
3641  context_(),
3642  SVMTrait::getSVMMemFlags(),
3643  size*sizeof(T),
3644  0);
3645  pointer retValue = reinterpret_cast<pointer>(
3646  voidPointer);
3647 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3648  if (!retValue) {
3649  std::bad_alloc excep;
3650  throw excep;
3651  }
3652 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3653 
3654  // If allocation was coarse-grained then map it
3655  if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3656  cl_int err = enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*sizeof(T));
3657  if (err != CL_SUCCESS) {
3658  std::bad_alloc excep;
3659  throw excep;
3660  }
3661  }
3662 
3663  // If exceptions disabled, return null pointer from allocator
3664  return retValue;
3665  }
3666 
3667  void deallocate(pointer p, size_type)
3668  {
3669  clSVMFree(context_(), p);
3670  }
3671 
3676  size_type max_size() const CL_HPP_NOEXCEPT_
3677  {
3678  size_type maxSize = std::numeric_limits<size_type>::max() / sizeof(T);
3679 
3680  for (const Device &d : context_.getInfo<CL_CONTEXT_DEVICES>()) {
3681  maxSize = std::min(
3682  maxSize,
3683  static_cast<size_type>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3684  }
3685 
3686  return maxSize;
3687  }
3688 
3689  template< class U, class... Args >
3690  void construct(U* p, Args&&... args)
3691  {
3692  new(p)T(args...);
3693  }
3694 
3695  template< class U >
3696  void destroy(U* p)
3697  {
3698  p->~U();
3699  }
3700 
3704  inline bool operator==(SVMAllocator const& rhs)
3705  {
3706  return (context_==rhs.context_);
3707  }
3708 
3709  inline bool operator!=(SVMAllocator const& a)
3710  {
3711  return !operator==(a);
3712  }
3713 }; // class SVMAllocator return cl::pointer<T>(tmp, detail::Deleter<T, Alloc>{alloc, copies});
3714 
3715 
3716 template<class SVMTrait>
3717 class SVMAllocator<void, SVMTrait> {
3718 public:
3719  typedef void value_type;
3720  typedef value_type* pointer;
3721  typedef const value_type* const_pointer;
3722 
3723  template<typename U>
3724  struct rebind
3725  {
3727  };
3728 
3729  template<typename U, typename V>
3730  friend class SVMAllocator;
3731 };
3732 
3733 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3734 namespace detail
3735 {
3736  template<class Alloc>
3737  class Deleter {
3738  private:
3739  Alloc alloc_;
3740  size_type copies_;
3741 
3742  public:
3743  typedef typename std::allocator_traits<Alloc>::pointer pointer;
3744 
3745  Deleter(const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3746  {
3747  }
3748 
3749  void operator()(pointer ptr) const {
3750  Alloc tmpAlloc{ alloc_ };
3751  std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3752  std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3753  }
3754  };
3755 } // namespace detail
3756 
3763 template <class T, class Alloc, class... Args>
3764 cl::pointer<T, detail::Deleter<Alloc>> allocate_pointer(const Alloc &alloc_, Args&&... args)
3765 {
3766  Alloc alloc(alloc_);
3767  static const size_type copies = 1;
3768 
3769  // Ensure that creation of the management block and the
3770  // object are dealt with separately such that we only provide a deleter
3771 
3772  T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3773  if (!tmp) {
3774  std::bad_alloc excep;
3775  throw excep;
3776  }
3777  try {
3778  std::allocator_traits<Alloc>::construct(
3779  alloc,
3780  std::addressof(*tmp),
3781  std::forward<Args>(args)...);
3782 
3783  return cl::pointer<T, detail::Deleter<Alloc>>(tmp, detail::Deleter<Alloc>{alloc, copies});
3784  }
3785  catch (std::bad_alloc& b)
3786  {
3787  std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3788  throw;
3789  }
3790 }
3791 
3792 template< class T, class SVMTrait, class... Args >
3793 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3794 {
3795  SVMAllocator<T, SVMTrait> alloc;
3796  return cl::allocate_pointer<T>(alloc, args...);
3797 }
3798 
3799 template< class T, class SVMTrait, class... Args >
3800 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(const cl::Context &c, Args... args)
3801 {
3802  SVMAllocator<T, SVMTrait> alloc(c);
3803  return cl::allocate_pointer<T>(alloc, args...);
3804 }
3805 #endif // #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3806 
3810 template < class T >
3811 using coarse_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>>;
3812 
3816 template < class T >
3817 using fine_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitFine<>>>;
3818 
3822 template < class T >
3823 using atomic_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitAtomic<>>>;
3824 
3825 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3826 
3827 
3834 class Buffer : public Memory
3835 {
3836 public:
3837 
3846  const Context& context,
3847  cl_mem_flags flags,
3848  size_type size,
3849  void* host_ptr = NULL,
3850  cl_int* err = NULL)
3851  {
3852  cl_int error;
3853  object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3854 
3855  detail::errHandler(error, __CREATE_BUFFER_ERR);
3856  if (err != NULL) {
3857  *err = error;
3858  }
3859  }
3860 
3871  cl_mem_flags flags,
3872  size_type size,
3873  void* host_ptr = NULL,
3874  cl_int* err = NULL)
3875  {
3876  cl_int error;
3877 
3878  Context context = Context::getDefault(err);
3879 
3880  object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3881 
3882  detail::errHandler(error, __CREATE_BUFFER_ERR);
3883  if (err != NULL) {
3884  *err = error;
3885  }
3886  }
3887 
3893  template< typename IteratorType >
3895  IteratorType startIterator,
3896  IteratorType endIterator,
3897  bool readOnly,
3898  bool useHostPtr = false,
3899  cl_int* err = NULL)
3900  {
3901  typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3902  cl_int error;
3903 
3904  cl_mem_flags flags = 0;
3905  if( readOnly ) {
3906  flags |= CL_MEM_READ_ONLY;
3907  }
3908  else {
3909  flags |= CL_MEM_READ_WRITE;
3910  }
3911  if( useHostPtr ) {
3912  flags |= CL_MEM_USE_HOST_PTR;
3913  }
3914 
3915  size_type size = sizeof(DataType)*(endIterator - startIterator);
3916 
3917  Context context = Context::getDefault(err);
3918 
3919  if( useHostPtr ) {
3920  object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
3921  } else {
3922  object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3923  }
3924 
3925  detail::errHandler(error, __CREATE_BUFFER_ERR);
3926  if (err != NULL) {
3927  *err = error;
3928  }
3929 
3930  if( !useHostPtr ) {
3931  error = cl::copy(startIterator, endIterator, *this);
3932  detail::errHandler(error, __CREATE_BUFFER_ERR);
3933  if (err != NULL) {
3934  *err = error;
3935  }
3936  }
3937  }
3938 
3944  template< typename IteratorType >
3945  Buffer(const Context &context, IteratorType startIterator, IteratorType endIterator,
3946  bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
3947 
3952  template< typename IteratorType >
3953  Buffer(const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
3954  bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
3955 
3957  Buffer() : Memory() { }
3958 
3966  explicit Buffer(const cl_mem& buffer, bool retainObject = false) :
3967  Memory(buffer, retainObject) { }
3968 
3973  Buffer& operator = (const cl_mem& rhs)
3974  {
3975  Memory::operator=(rhs);
3976  return *this;
3977  }
3978 
3982  Buffer(const Buffer& buf) : Memory(buf) {}
3983 
3988  {
3989  Memory::operator=(buf);
3990  return *this;
3991  }
3992 
3996  Buffer(Buffer&& buf) CL_HPP_NOEXCEPT_ : Memory(std::move(buf)) {}
3997 
4002  {
4003  Memory::operator=(std::move(buf));
4004  return *this;
4005  }
4006 
4007 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
4008 
4013  cl_mem_flags flags,
4014  cl_buffer_create_type buffer_create_type,
4015  const void * buffer_create_info,
4016  cl_int * err = NULL)
4017  {
4018  Buffer result;
4019  cl_int error;
4020  result.object_ = ::clCreateSubBuffer(
4021  object_,
4022  flags,
4023  buffer_create_type,
4024  buffer_create_info,
4025  &error);
4026 
4027  detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4028  if (err != NULL) {
4029  *err = error;
4030  }
4031 
4032  return result;
4033  }
4034 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
4035 };
4036 
4037 #if defined (CL_HPP_USE_DX_INTEROP)
4038 
4046 class BufferD3D10 : public Buffer
4047 {
4048 public:
4049 
4050 
4056  BufferD3D10(
4057  const Context& context,
4058  cl_mem_flags flags,
4059  ID3D10Buffer* bufobj,
4060  cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4061  {
4062  typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4063  cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4064  cl_int* errcode_ret);
4065  PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4066 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4067  vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4068  cl_platform platform = -1;
4069  for( int i = 0; i < props.size(); ++i ) {
4070  if( props[i] == CL_CONTEXT_PLATFORM ) {
4071  platform = props[i+1];
4072  }
4073  }
4074  CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4075 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4076  CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4077 #endif
4078 
4079  cl_int error;
4080  object_ = pfn_clCreateFromD3D10BufferKHR(
4081  context(),
4082  flags,
4083  bufobj,
4084  &error);
4085 
4086  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4087  if (err != NULL) {
4088  *err = error;
4089  }
4090  }
4091 
4093  BufferD3D10() : Buffer() { }
4094 
4102  explicit BufferD3D10(const cl_mem& buffer, bool retainObject = false) :
4103  Buffer(buffer, retainObject) { }
4104 
4109  BufferD3D10& operator = (const cl_mem& rhs)
4110  {
4111  Buffer::operator=(rhs);
4112  return *this;
4113  }
4114 
4118  BufferD3D10(const BufferD3D10& buf) :
4119  Buffer(buf) {}
4120 
4124  BufferD3D10& operator = (const BufferD3D10 &buf)
4125  {
4126  Buffer::operator=(buf);
4127  return *this;
4128  }
4129 
4133  BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4134 
4138  BufferD3D10& operator = (BufferD3D10 &&buf)
4139  {
4140  Buffer::operator=(std::move(buf));
4141  return *this;
4142  }
4143 };
4144 #endif
4145 
4154 class BufferGL : public Buffer
4155 {
4156 public:
4163  const Context& context,
4164  cl_mem_flags flags,
4165  cl_GLuint bufobj,
4166  cl_int * err = NULL)
4167  {
4168  cl_int error;
4169  object_ = ::clCreateFromGLBuffer(
4170  context(),
4171  flags,
4172  bufobj,
4173  &error);
4174 
4175  detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4176  if (err != NULL) {
4177  *err = error;
4178  }
4179  }
4180 
4182  BufferGL() : Buffer() { }
4183 
4191  explicit BufferGL(const cl_mem& buffer, bool retainObject = false) :
4192  Buffer(buffer, retainObject) { }
4193 
4198  BufferGL& operator = (const cl_mem& rhs)
4199  {
4200  Buffer::operator=(rhs);
4201  return *this;
4202  }
4203 
4207  BufferGL(const BufferGL& buf) : Buffer(buf) {}
4208 
4213  {
4214  Buffer::operator=(buf);
4215  return *this;
4216  }
4217 
4221  BufferGL(BufferGL&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4222 
4227  {
4228  Buffer::operator=(std::move(buf));
4229  return *this;
4230  }
4231 
4234  cl_gl_object_type *type,
4235  cl_GLuint * gl_object_name)
4236  {
4237  return detail::errHandler(
4238  ::clGetGLObjectInfo(object_,type,gl_object_name),
4239  __GET_GL_OBJECT_INFO_ERR);
4240  }
4241 };
4242 
4251 class BufferRenderGL : public Buffer
4252 {
4253 public:
4260  const Context& context,
4261  cl_mem_flags flags,
4262  cl_GLuint bufobj,
4263  cl_int * err = NULL)
4264  {
4265  cl_int error;
4266  object_ = ::clCreateFromGLRenderbuffer(
4267  context(),
4268  flags,
4269  bufobj,
4270  &error);
4271 
4272  detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4273  if (err != NULL) {
4274  *err = error;
4275  }
4276  }
4277 
4280 
4288  explicit BufferRenderGL(const cl_mem& buffer, bool retainObject = false) :
4289  Buffer(buffer, retainObject) { }
4290 
4295  BufferRenderGL& operator = (const cl_mem& rhs)
4296  {
4297  Buffer::operator=(rhs);
4298  return *this;
4299  }
4300 
4304  BufferRenderGL(const BufferRenderGL& buf) : Buffer(buf) {}
4305 
4310  {
4311  Buffer::operator=(buf);
4312  return *this;
4313  }
4314 
4318  BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4319 
4324  {
4325  Buffer::operator=(std::move(buf));
4326  return *this;
4327  }
4328 
4331  cl_gl_object_type *type,
4332  cl_GLuint * gl_object_name)
4333  {
4334  return detail::errHandler(
4335  ::clGetGLObjectInfo(object_,type,gl_object_name),
4336  __GET_GL_OBJECT_INFO_ERR);
4337  }
4338 };
4339 
4346 class Image : public Memory
4347 {
4348 protected:
4350  Image() : Memory() { }
4351 
4359  explicit Image(const cl_mem& image, bool retainObject = false) :
4360  Memory(image, retainObject) { }
4361 
4366  Image& operator = (const cl_mem& rhs)
4367  {
4368  Memory::operator=(rhs);
4369  return *this;
4370  }
4371 
4375  Image(const Image& img) : Memory(img) {}
4376 
4380  Image& operator = (const Image &img)
4381  {
4382  Memory::operator=(img);
4383  return *this;
4384  }
4385 
4389  Image(Image&& img) CL_HPP_NOEXCEPT_ : Memory(std::move(img)) {}
4390 
4395  {
4396  Memory::operator=(std::move(img));
4397  return *this;
4398  }
4399 
4400 
4401 public:
4403  template <typename T>
4404  cl_int getImageInfo(cl_image_info name, T* param) const
4405  {
4406  return detail::errHandler(
4407  detail::getInfo(&::clGetImageInfo, object_, name, param),
4408  __GET_IMAGE_INFO_ERR);
4409  }
4410 
4412  template <cl_image_info name> typename
4414  getImageInfo(cl_int* err = NULL) const
4415  {
4416  typename detail::param_traits<
4417  detail::cl_image_info, name>::param_type param;
4418  cl_int result = getImageInfo(name, &param);
4419  if (err != NULL) {
4420  *err = result;
4421  }
4422  return param;
4423  }
4424 };
4425 
4426 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4427 
4433 class Image1D : public Image
4434 {
4435 public:
4441  const Context& context,
4442  cl_mem_flags flags,
4443  ImageFormat format,
4444  size_type width,
4445  void* host_ptr = NULL,
4446  cl_int* err = NULL)
4447  {
4448  cl_int error;
4449  cl_image_desc desc =
4450  {
4451  CL_MEM_OBJECT_IMAGE1D,
4452  width,
4453  0, 0, 0, 0, 0, 0, 0, 0
4454  };
4455  object_ = ::clCreateImage(
4456  context(),
4457  flags,
4458  &format,
4459  &desc,
4460  host_ptr,
4461  &error);
4462 
4463  detail::errHandler(error, __CREATE_IMAGE_ERR);
4464  if (err != NULL) {
4465  *err = error;
4466  }
4467  }
4468 
4470  Image1D() { }
4471 
4479  explicit Image1D(const cl_mem& image1D, bool retainObject = false) :
4480  Image(image1D, retainObject) { }
4481 
4486  Image1D& operator = (const cl_mem& rhs)
4487  {
4488  Image::operator=(rhs);
4489  return *this;
4490  }
4491 
4495  Image1D(const Image1D& img) : Image(img) {}
4496 
4501  {
4502  Image::operator=(img);
4503  return *this;
4504  }
4505 
4509  Image1D(Image1D&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
4510 
4515  {
4516  Image::operator=(std::move(img));
4517  return *this;
4518  }
4519 
4520 };
4521 
4525 class Image1DBuffer : public Image
4526 {
4527 public:
4528  Image1DBuffer(
4529  const Context& context,
4530  cl_mem_flags flags,
4531  ImageFormat format,
4532  size_type width,
4533  const Buffer &buffer,
4534  cl_int* err = NULL)
4535  {
4536  cl_int error;
4537  cl_image_desc desc =
4538  {
4539  CL_MEM_OBJECT_IMAGE1D_BUFFER,
4540  width,
4541  0, 0, 0, 0, 0, 0, 0,
4542  buffer()
4543  };
4544  object_ = ::clCreateImage(
4545  context(),
4546  flags,
4547  &format,
4548  &desc,
4549  NULL,
4550  &error);
4551 
4552  detail::errHandler(error, __CREATE_IMAGE_ERR);
4553  if (err != NULL) {
4554  *err = error;
4555  }
4556  }
4557 
4558  Image1DBuffer() { }
4559 
4567  explicit Image1DBuffer(const cl_mem& image1D, bool retainObject = false) :
4568  Image(image1D, retainObject) { }
4569 
4570  Image1DBuffer& operator = (const cl_mem& rhs)
4571  {
4572  Image::operator=(rhs);
4573  return *this;
4574  }
4575 
4579  Image1DBuffer(const Image1DBuffer& img) : Image(img) {}
4580 
4584  Image1DBuffer& operator = (const Image1DBuffer &img)
4585  {
4586  Image::operator=(img);
4587  return *this;
4588  }
4589 
4593  Image1DBuffer(Image1DBuffer&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
4594 
4598  Image1DBuffer& operator = (Image1DBuffer &&img)
4599  {
4600  Image::operator=(std::move(img));
4601  return *this;
4602  }
4603 
4604 };
4605 
4609 class Image1DArray : public Image
4610 {
4611 public:
4612  Image1DArray(
4613  const Context& context,
4614  cl_mem_flags flags,
4615  ImageFormat format,
4616  size_type arraySize,
4617  size_type width,
4618  size_type rowPitch,
4619  void* host_ptr = NULL,
4620  cl_int* err = NULL)
4621  {
4622  cl_int error;
4623  cl_image_desc desc =
4624  {
4625  CL_MEM_OBJECT_IMAGE1D_ARRAY,
4626  width,
4627  0, 0, // height, depth (unused)
4628  arraySize,
4629  rowPitch,
4630  0, 0, 0, 0
4631  };
4632  object_ = ::clCreateImage(
4633  context(),
4634  flags,
4635  &format,
4636  &desc,
4637  host_ptr,
4638  &error);
4639 
4640  detail::errHandler(error, __CREATE_IMAGE_ERR);
4641  if (err != NULL) {
4642  *err = error;
4643  }
4644  }
4645 
4646  Image1DArray() { }
4647 
4655  explicit Image1DArray(const cl_mem& imageArray, bool retainObject = false) :
4656  Image(imageArray, retainObject) { }
4657 
4658 
4659  Image1DArray& operator = (const cl_mem& rhs)
4660  {
4661  Image::operator=(rhs);
4662  return *this;
4663  }
4664 
4668  Image1DArray(const Image1DArray& img) : Image(img) {}
4669 
4673  Image1DArray& operator = (const Image1DArray &img)
4674  {
4675  Image::operator=(img);
4676  return *this;
4677  }
4678 
4682  Image1DArray(Image1DArray&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
4683 
4687  Image1DArray& operator = (Image1DArray &&img)
4688  {
4689  Image::operator=(std::move(img));
4690  return *this;
4691  }
4692 
4693 };
4694 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4695 
4696 
4703 class Image2D : public Image
4704 {
4705 public:
4711  const Context& context,
4712  cl_mem_flags flags,
4713  ImageFormat format,
4714  size_type width,
4715  size_type height,
4716  size_type row_pitch = 0,
4717  void* host_ptr = NULL,
4718  cl_int* err = NULL)
4719  {
4720  cl_int error;
4721  bool useCreateImage;
4722 
4723 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4724  // Run-time decision based on the actual platform
4725  {
4726  cl_uint version = detail::getContextPlatformVersion(context());
4727  useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
4728  }
4729 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4730  useCreateImage = true;
4731 #else
4732  useCreateImage = false;
4733 #endif
4734 
4735 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4736  if (useCreateImage)
4737  {
4738  cl_image_desc desc =
4739  {
4740  CL_MEM_OBJECT_IMAGE2D,
4741  width,
4742  height,
4743  0, 0, // depth, array size (unused)
4744  row_pitch,
4745  0, 0, 0, 0
4746  };
4747  object_ = ::clCreateImage(
4748  context(),
4749  flags,
4750  &format,
4751  &desc,
4752  host_ptr,
4753  &error);
4754 
4755  detail::errHandler(error, __CREATE_IMAGE_ERR);
4756  if (err != NULL) {
4757  *err = error;
4758  }
4759  }
4760 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
4761 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4762  if (!useCreateImage)
4763  {
4764  object_ = ::clCreateImage2D(
4765  context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4766 
4767  detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4768  if (err != NULL) {
4769  *err = error;
4770  }
4771  }
4772 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
4773  }
4774 
4775 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4776 
4782  const Context& context,
4783  ImageFormat format,
4784  const Buffer &sourceBuffer,
4785  size_type width,
4786  size_type height,
4787  size_type row_pitch = 0,
4788  cl_int* err = nullptr)
4789  {
4790  cl_int error;
4791 
4792  cl_image_desc desc =
4793  {
4794  CL_MEM_OBJECT_IMAGE2D,
4795  width,
4796  height,
4797  0, 0, // depth, array size (unused)
4798  row_pitch,
4799  0, 0, 0,
4800  // Use buffer as input to image
4801  sourceBuffer()
4802  };
4803  object_ = ::clCreateImage(
4804  context(),
4805  0, // flags inherited from buffer
4806  &format,
4807  &desc,
4808  nullptr,
4809  &error);
4810 
4811  detail::errHandler(error, __CREATE_IMAGE_ERR);
4812  if (err != nullptr) {
4813  *err = error;
4814  }
4815  }
4816 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4817 
4818 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
4819 
4832  const Context& context,
4833  cl_channel_order order,
4834  const Image &sourceImage,
4835  cl_int* err = nullptr)
4836  {
4837  cl_int error;
4838 
4839  // Descriptor fields have to match source image
4840  size_type sourceWidth =
4841  sourceImage.getImageInfo<CL_IMAGE_WIDTH>();
4842  size_type sourceHeight =
4843  sourceImage.getImageInfo<CL_IMAGE_HEIGHT>();
4844  size_type sourceRowPitch =
4845  sourceImage.getImageInfo<CL_IMAGE_ROW_PITCH>();
4846  cl_uint sourceNumMIPLevels =
4847  sourceImage.getImageInfo<CL_IMAGE_NUM_MIP_LEVELS>();
4848  cl_uint sourceNumSamples =
4849  sourceImage.getImageInfo<CL_IMAGE_NUM_SAMPLES>();
4850  cl_image_format sourceFormat =
4851  sourceImage.getImageInfo<CL_IMAGE_FORMAT>();
4852 
4853  // Update only the channel order.
4854  // Channel format inherited from source.
4855  sourceFormat.image_channel_order = order;
4856  cl_image_desc desc =
4857  {
4858  CL_MEM_OBJECT_IMAGE2D,
4859  sourceWidth,
4860  sourceHeight,
4861  0, 0, // depth (unused), array size (unused)
4862  sourceRowPitch,
4863  0, // slice pitch (unused)
4864  sourceNumMIPLevels,
4865  sourceNumSamples,
4866  // Use buffer as input to image
4867  sourceImage()
4868  };
4869  object_ = ::clCreateImage(
4870  context(),
4871  0, // flags should be inherited from mem_object
4872  &sourceFormat,
4873  &desc,
4874  nullptr,
4875  &error);
4876 
4877  detail::errHandler(error, __CREATE_IMAGE_ERR);
4878  if (err != nullptr) {
4879  *err = error;
4880  }
4881  }
4882 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200
4883 
4885  Image2D() { }
4886 
4894  explicit Image2D(const cl_mem& image2D, bool retainObject = false) :
4895  Image(image2D, retainObject) { }
4896 
4901  Image2D& operator = (const cl_mem& rhs)
4902  {
4903  Image::operator=(rhs);
4904  return *this;
4905  }
4906 
4910  Image2D(const Image2D& img) : Image(img) {}
4911 
4916  {
4917  Image::operator=(img);
4918  return *this;
4919  }
4920 
4924  Image2D(Image2D&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
4925 
4930  {
4931  Image::operator=(std::move(img));
4932  return *this;
4933  }
4934 
4935 };
4936 
4937 
4938 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
4939 
4948 class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED Image2DGL : public Image2D
4949 {
4950 public:
4957  const Context& context,
4958  cl_mem_flags flags,
4959  cl_GLenum target,
4960  cl_GLint miplevel,
4961  cl_GLuint texobj,
4962  cl_int * err = NULL)
4963  {
4964  cl_int error;
4965  object_ = ::clCreateFromGLTexture2D(
4966  context(),
4967  flags,
4968  target,
4969  miplevel,
4970  texobj,
4971  &error);
4972 
4973  detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
4974  if (err != NULL) {
4975  *err = error;
4976  }
4977 
4978  }
4979 
4981  Image2DGL() : Image2D() { }
4982 
4990  explicit Image2DGL(const cl_mem& image, bool retainObject = false) :
4991  Image2D(image, retainObject) { }
4992 
4997  Image2DGL& operator = (const cl_mem& rhs)
4998  {
4999  Image2D::operator=(rhs);
5000  return *this;
5001  }
5002 
5006  Image2DGL(const Image2DGL& img) : Image2D(img) {}
5007 
5011  Image2DGL& operator = (const Image2DGL &img)
5012  {
5013  Image2D::operator=(img);
5014  return *this;
5015  }
5016 
5020  Image2DGL(Image2DGL&& img) CL_HPP_NOEXCEPT_ : Image2D(std::move(img)) {}
5021 
5025  Image2DGL& operator = (Image2DGL &&img)
5026  {
5027  Image2D::operator=(std::move(img));
5028  return *this;
5029  }
5030 
5031 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
5032 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
5033 
5034 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5035 
5038 class Image2DArray : public Image
5039 {
5040 public:
5041  Image2DArray(
5042  const Context& context,
5043  cl_mem_flags flags,
5044  ImageFormat format,
5045  size_type arraySize,
5046  size_type width,
5047  size_type height,
5048  size_type rowPitch,
5049  size_type slicePitch,
5050  void* host_ptr = NULL,
5051  cl_int* err = NULL)
5052  {
5053  cl_int error;
5054  cl_image_desc desc =
5055  {
5056  CL_MEM_OBJECT_IMAGE2D_ARRAY,
5057  width,
5058  height,
5059  0, // depth (unused)
5060  arraySize,
5061  rowPitch,
5062  slicePitch,
5063  0, 0, 0
5064  };
5065  object_ = ::clCreateImage(
5066  context(),
5067  flags,
5068  &format,
5069  &desc,
5070  host_ptr,
5071  &error);
5072 
5073  detail::errHandler(error, __CREATE_IMAGE_ERR);
5074  if (err != NULL) {
5075  *err = error;
5076  }
5077  }
5078 
5079  Image2DArray() { }
5080 
5088  explicit Image2DArray(const cl_mem& imageArray, bool retainObject = false) : Image(imageArray, retainObject) { }
5089 
5090  Image2DArray& operator = (const cl_mem& rhs)
5091  {
5092  Image::operator=(rhs);
5093  return *this;
5094  }
5095 
5099  Image2DArray(const Image2DArray& img) : Image(img) {}
5100 
5104  Image2DArray& operator = (const Image2DArray &img)
5105  {
5106  Image::operator=(img);
5107  return *this;
5108  }
5109 
5113  Image2DArray(Image2DArray&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
5114 
5118  Image2DArray& operator = (Image2DArray &&img)
5119  {
5120  Image::operator=(std::move(img));
5121  return *this;
5122  }
5123 };
5124 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5125 
5132 class Image3D : public Image
5133 {
5134 public:
5140  const Context& context,
5141  cl_mem_flags flags,
5142  ImageFormat format,
5143  size_type width,
5144  size_type height,
5145  size_type depth,
5146  size_type row_pitch = 0,
5147  size_type slice_pitch = 0,
5148  void* host_ptr = NULL,
5149  cl_int* err = NULL)
5150  {
5151  cl_int error;
5152  bool useCreateImage;
5153 
5154 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5155  // Run-time decision based on the actual platform
5156  {
5157  cl_uint version = detail::getContextPlatformVersion(context());
5158  useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
5159  }
5160 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5161  useCreateImage = true;
5162 #else
5163  useCreateImage = false;
5164 #endif
5165 
5166 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5167  if (useCreateImage)
5168  {
5169  cl_image_desc desc =
5170  {
5171  CL_MEM_OBJECT_IMAGE3D,
5172  width,
5173  height,
5174  depth,
5175  0, // array size (unused)
5176  row_pitch,
5177  slice_pitch,
5178  0, 0, 0
5179  };
5180  object_ = ::clCreateImage(
5181  context(),
5182  flags,
5183  &format,
5184  &desc,
5185  host_ptr,
5186  &error);
5187 
5188  detail::errHandler(error, __CREATE_IMAGE_ERR);
5189  if (err != NULL) {
5190  *err = error;
5191  }
5192  }
5193 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
5194 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5195  if (!useCreateImage)
5196  {
5197  object_ = ::clCreateImage3D(
5198  context(), flags, &format, width, height, depth, row_pitch,
5199  slice_pitch, host_ptr, &error);
5200 
5201  detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5202  if (err != NULL) {
5203  *err = error;
5204  }
5205  }
5206 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
5207  }
5208 
5210  Image3D() : Image() { }
5211 
5219  explicit Image3D(const cl_mem& image3D, bool retainObject = false) :
5220  Image(image3D, retainObject) { }
5221 
5226  Image3D& operator = (const cl_mem& rhs)
5227  {
5228  Image::operator=(rhs);
5229  return *this;
5230  }
5231 
5235  Image3D(const Image3D& img) : Image(img) {}
5236 
5241  {
5242  Image::operator=(img);
5243  return *this;
5244  }
5245 
5249  Image3D(Image3D&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
5250 
5255  {
5256  Image::operator=(std::move(img));
5257  return *this;
5258  }
5259 };
5260 
5261 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5262 
5270 class Image3DGL : public Image3D
5271 {
5272 public:
5279  const Context& context,
5280  cl_mem_flags flags,
5281  cl_GLenum target,
5282  cl_GLint miplevel,
5283  cl_GLuint texobj,
5284  cl_int * err = NULL)
5285  {
5286  cl_int error;
5287  object_ = ::clCreateFromGLTexture3D(
5288  context(),
5289  flags,
5290  target,
5291  miplevel,
5292  texobj,
5293  &error);
5294 
5295  detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5296  if (err != NULL) {
5297  *err = error;
5298  }
5299  }
5300 
5302  Image3DGL() : Image3D() { }
5303 
5311  explicit Image3DGL(const cl_mem& image, bool retainObject = false) :
5312  Image3D(image, retainObject) { }
5313 
5318  Image3DGL& operator = (const cl_mem& rhs)
5319  {
5320  Image3D::operator=(rhs);
5321  return *this;
5322  }
5323 
5327  Image3DGL(const Image3DGL& img) : Image3D(img) {}
5328 
5333  {
5334  Image3D::operator=(img);
5335  return *this;
5336  }
5337 
5341  Image3DGL(Image3DGL&& img) CL_HPP_NOEXCEPT_ : Image3D(std::move(img)) {}
5342 
5347  {
5348  Image3D::operator=(std::move(img));
5349  return *this;
5350  }
5351 };
5352 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
5353 
5354 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5355 
5361 class ImageGL : public Image
5362 {
5363 public:
5364  ImageGL(
5365  const Context& context,
5366  cl_mem_flags flags,
5367  cl_GLenum target,
5368  cl_GLint miplevel,
5369  cl_GLuint texobj,
5370  cl_int * err = NULL)
5371  {
5372  cl_int error;
5373  object_ = ::clCreateFromGLTexture(
5374  context(),
5375  flags,
5376  target,
5377  miplevel,
5378  texobj,
5379  &error);
5380 
5381  detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5382  if (err != NULL) {
5383  *err = error;
5384  }
5385  }
5386 
5387  ImageGL() : Image() { }
5388 
5396  explicit ImageGL(const cl_mem& image, bool retainObject = false) :
5397  Image(image, retainObject) { }
5398 
5399  ImageGL& operator = (const cl_mem& rhs)
5400  {
5401  Image::operator=(rhs);
5402  return *this;
5403  }
5404 
5408  ImageGL(const ImageGL& img) : Image(img) {}
5409 
5413  ImageGL& operator = (const ImageGL &img)
5414  {
5415  Image::operator=(img);
5416  return *this;
5417  }
5418 
5422  ImageGL(ImageGL&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
5423 
5427  ImageGL& operator = (ImageGL &&img)
5428  {
5429  Image::operator=(std::move(img));
5430  return *this;
5431  }
5432 };
5433 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
5434 
5435 
5436 
5437 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5438 
5444 class Pipe : public Memory
5445 {
5446 public:
5447 
5458  const Context& context,
5459  cl_uint packet_size,
5460  cl_uint max_packets,
5461  cl_int* err = NULL)
5462  {
5463  cl_int error;
5464 
5465  cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5466  object_ = ::clCreatePipe(context(), flags, packet_size, max_packets, nullptr, &error);
5467 
5468  detail::errHandler(error, __CREATE_PIPE_ERR);
5469  if (err != NULL) {
5470  *err = error;
5471  }
5472  }
5473 
5483  cl_uint packet_size,
5484  cl_uint max_packets,
5485  cl_int* err = NULL)
5486  {
5487  cl_int error;
5488 
5489  Context context = Context::getDefault(err);
5490 
5491  cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5492  object_ = ::clCreatePipe(context(), flags, packet_size, max_packets, nullptr, &error);
5493 
5494  detail::errHandler(error, __CREATE_PIPE_ERR);
5495  if (err != NULL) {
5496  *err = error;
5497  }
5498  }
5499 
5501  Pipe() : Memory() { }
5502 
5510  explicit Pipe(const cl_mem& pipe, bool retainObject = false) :
5511  Memory(pipe, retainObject) { }
5512 
5517  Pipe& operator = (const cl_mem& rhs)
5518  {
5519  Memory::operator=(rhs);
5520  return *this;
5521  }
5522 
5526  Pipe(const Pipe& pipe) : Memory(pipe) {}
5527 
5531  Pipe& operator = (const Pipe &pipe)
5532  {
5533  Memory::operator=(pipe);
5534  return *this;
5535  }
5536 
5540  Pipe(Pipe&& pipe) CL_HPP_NOEXCEPT_ : Memory(std::move(pipe)) {}
5541 
5546  {
5547  Memory::operator=(std::move(pipe));
5548  return *this;
5549  }
5550 
5552  template <typename T>
5553  cl_int getInfo(cl_pipe_info name, T* param) const
5554  {
5555  return detail::errHandler(
5556  detail::getInfo(&::clGetPipeInfo, object_, name, param),
5557  __GET_PIPE_INFO_ERR);
5558  }
5559 
5561  template <cl_pipe_info name> typename
5563  getInfo(cl_int* err = NULL) const
5564  {
5565  typename detail::param_traits<
5566  detail::cl_pipe_info, name>::param_type param;
5567  cl_int result = getInfo(name, &param);
5568  if (err != NULL) {
5569  *err = result;
5570  }
5571  return param;
5572  }
5573 }; // class Pipe
5574 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
5575 
5576 
5585 class Sampler : public detail::Wrapper<cl_sampler>
5586 {
5587 public:
5589  Sampler() { }
5590 
5596  const Context& context,
5597  cl_bool normalized_coords,
5598  cl_addressing_mode addressing_mode,
5599  cl_filter_mode filter_mode,
5600  cl_int* err = NULL)
5601  {
5602  cl_int error;
5603 
5604 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5605  cl_sampler_properties sampler_properties[] = {
5606  CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5607  CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5608  CL_SAMPLER_FILTER_MODE, filter_mode,
5609  0 };
5610  object_ = ::clCreateSamplerWithProperties(
5611  context(),
5612  sampler_properties,
5613  &error);
5614 
5615  detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5616  if (err != NULL) {
5617  *err = error;
5618  }
5619 #else
5620  object_ = ::clCreateSampler(
5621  context(),
5622  normalized_coords,
5623  addressing_mode,
5624  filter_mode,
5625  &error);
5626 
5627  detail::errHandler(error, __CREATE_SAMPLER_ERR);
5628  if (err != NULL) {
5629  *err = error;
5630  }
5631 #endif
5632  }
5633 
5642  explicit Sampler(const cl_sampler& sampler, bool retainObject = false) :
5643  detail::Wrapper<cl_type>(sampler, retainObject) { }
5644 
5650  Sampler& operator = (const cl_sampler& rhs)
5651  {
5653  return *this;
5654  }
5655 
5659  Sampler(const Sampler& sam) : detail::Wrapper<cl_type>(sam) {}
5660 
5665  {
5667  return *this;
5668  }
5669 
5673  Sampler(Sampler&& sam) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(sam)) {}
5674 
5679  {
5680  detail::Wrapper<cl_type>::operator=(std::move(sam));
5681  return *this;
5682  }
5683 
5685  template <typename T>
5686  cl_int getInfo(cl_sampler_info name, T* param) const
5687  {
5688  return detail::errHandler(
5689  detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5690  __GET_SAMPLER_INFO_ERR);
5691  }
5692 
5694  template <cl_sampler_info name> typename
5696  getInfo(cl_int* err = NULL) const
5697  {
5698  typename detail::param_traits<
5699  detail::cl_sampler_info, name>::param_type param;
5700  cl_int result = getInfo(name, &param);
5701  if (err != NULL) {
5702  *err = result;
5703  }
5704  return param;
5705  }
5706 };
5707 
5708 class Program;
5709 class CommandQueue;
5710 class DeviceCommandQueue;
5711 class Kernel;
5712 
5714 class NDRange
5715 {
5716 private:
5717  size_type sizes_[3];
5718  cl_uint dimensions_;
5719 
5720 public:
5723  : dimensions_(0)
5724  {
5725  sizes_[0] = 0;
5726  sizes_[1] = 0;
5727  sizes_[2] = 0;
5728  }
5729 
5731  NDRange(size_type size0)
5732  : dimensions_(1)
5733  {
5734  sizes_[0] = size0;
5735  sizes_[1] = 1;
5736  sizes_[2] = 1;
5737  }
5738 
5740  NDRange(size_type size0, size_type size1)
5741  : dimensions_(2)
5742  {
5743  sizes_[0] = size0;
5744  sizes_[1] = size1;
5745  sizes_[2] = 1;
5746  }
5747 
5749  NDRange(size_type size0, size_type size1, size_type size2)
5750  : dimensions_(3)
5751  {
5752  sizes_[0] = size0;
5753  sizes_[1] = size1;
5754  sizes_[2] = size2;
5755  }
5756 
5761  operator const size_type*() const {
5762  return sizes_;
5763  }
5764 
5766  size_type dimensions() const
5767  {
5768  return dimensions_;
5769  }
5770 
5772  // runtime number of dimensions
5773  size_type size() const
5774  {
5775  return dimensions_*sizeof(size_type);
5776  }
5777 
5778  size_type* get()
5779  {
5780  return sizes_;
5781  }
5782 
5783  const size_type* get() const
5784  {
5785  return sizes_;
5786  }
5787 };
5788 
5790 static const NDRange NullRange;
5791 
5794 {
5795  size_type size_;
5796 };
5797 
5798 namespace detail {
5799 
5800 template <typename T, class Enable = void>
5802 
5803 // Enable for objects that are not subclasses of memory
5804 // Pointers, constants etc
5805 template <typename T>
5806 struct KernelArgumentHandler<T, typename std::enable_if<!std::is_base_of<cl::Memory, T>::value>::type>
5807 {
5808  static size_type size(const T&) { return sizeof(T); }
5809  static const T* ptr(const T& value) { return &value; }
5810 };
5811 
5812 // Enable for subclasses of memory where we want to get a reference to the cl_mem out
5813 // and pass that in for safety
5814 template <typename T>
5815 struct KernelArgumentHandler<T, typename std::enable_if<std::is_base_of<cl::Memory, T>::value>::type>
5816 {
5817  static size_type size(const T&) { return sizeof(cl_mem); }
5818  static const cl_mem* ptr(const T& value) { return &(value()); }
5819 };
5820 
5821 // Specialization for DeviceCommandQueue defined later
5822 
5823 template <>
5825 {
5826  static size_type size(const LocalSpaceArg& value) { return value.size_; }
5827  static const void* ptr(const LocalSpaceArg&) { return NULL; }
5828 };
5829 
5830 }
5832 
5836 inline LocalSpaceArg
5837 Local(size_type size)
5838 {
5839  LocalSpaceArg ret = { size };
5840  return ret;
5841 }
5842 
5851 class Kernel : public detail::Wrapper<cl_kernel>
5852 {
5853 public:
5854  inline Kernel(const Program& program, const char* name, cl_int* err = NULL);
5855 
5857  Kernel() { }
5858 
5867  explicit Kernel(const cl_kernel& kernel, bool retainObject = false) :
5868  detail::Wrapper<cl_type>(kernel, retainObject) { }
5869 
5875  Kernel& operator = (const cl_kernel& rhs)
5876  {
5878  return *this;
5879  }
5880 
5884  Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) {}
5885 
5889  Kernel& operator = (const Kernel &kernel)
5890  {
5892  return *this;
5893  }
5894 
5898  Kernel(Kernel&& kernel) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(kernel)) {}
5899 
5904  {
5905  detail::Wrapper<cl_type>::operator=(std::move(kernel));
5906  return *this;
5907  }
5908 
5909  template <typename T>
5910  cl_int getInfo(cl_kernel_info name, T* param) const
5911  {
5912  return detail::errHandler(
5913  detail::getInfo(&::clGetKernelInfo, object_, name, param),
5914  __GET_KERNEL_INFO_ERR);
5915  }
5916 
5917  template <cl_kernel_info name> typename
5918  detail::param_traits<detail::cl_kernel_info, name>::param_type
5919  getInfo(cl_int* err = NULL) const
5920  {
5921  typename detail::param_traits<
5922  detail::cl_kernel_info, name>::param_type param;
5923  cl_int result = getInfo(name, &param);
5924  if (err != NULL) {
5925  *err = result;
5926  }
5927  return param;
5928  }
5929 
5930 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5931  template <typename T>
5932  cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param) const
5933  {
5934  return detail::errHandler(
5935  detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5936  __GET_KERNEL_ARG_INFO_ERR);
5937  }
5938 
5939  template <cl_kernel_arg_info name> typename
5940  detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5941  getArgInfo(cl_uint argIndex, cl_int* err = NULL) const
5942  {
5943  typename detail::param_traits<
5944  detail::cl_kernel_arg_info, name>::param_type param;
5945  cl_int result = getArgInfo(argIndex, name, &param);
5946  if (err != NULL) {
5947  *err = result;
5948  }
5949  return param;
5950  }
5951 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
5952 
5953  template <typename T>
5954  cl_int getWorkGroupInfo(
5955  const Device& device, cl_kernel_work_group_info name, T* param) const
5956  {
5957  return detail::errHandler(
5958  detail::getInfo(
5959  &::clGetKernelWorkGroupInfo, object_, device(), name, param),
5960  __GET_KERNEL_WORK_GROUP_INFO_ERR);
5961  }
5962 
5963  template <cl_kernel_work_group_info name> typename
5964  detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
5965  getWorkGroupInfo(const Device& device, cl_int* err = NULL) const
5966  {
5967  typename detail::param_traits<
5968  detail::cl_kernel_work_group_info, name>::param_type param;
5969  cl_int result = getWorkGroupInfo(device, name, &param);
5970  if (err != NULL) {
5971  *err = result;
5972  }
5973  return param;
5974  }
5975 
5976 #if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
5977  cl_int getSubGroupInfo(const cl::Device &dev, cl_kernel_sub_group_info name, const cl::NDRange &range, size_type* param) const
5978  {
5979 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
5980 
5981  return detail::errHandler(
5982  clGetKernelSubGroupInfo(object_, dev(), name, range.size(), range.get(), sizeof(size_type), param, nullptr),
5983  __GET_KERNEL_SUB_GROUP_INFO_ERR);
5984 
5985 #else // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
5986 
5987  typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
5988  static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
5989  CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
5990 
5991  return detail::errHandler(
5992  pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.size(), range.get(), sizeof(size_type), param, nullptr),
5993  __GET_KERNEL_SUB_GROUP_INFO_ERR);
5994 
5995 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
5996  }
5997 
5998  template <cl_kernel_sub_group_info name>
5999  size_type getSubGroupInfo(const cl::Device &dev, const cl::NDRange &range, cl_int* err = NULL) const
6000  {
6001  size_type param;
6002  cl_int result = getSubGroupInfo(dev, name, range, &param);
6003  if (err != NULL) {
6004  *err = result;
6005  }
6006  return param;
6007  }
6008 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6009 
6010 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6011 
6013  template<typename T, class D>
6014  cl_int setArg(cl_uint index, const cl::pointer<T, D> &argPtr)
6015  {
6016  return detail::errHandler(
6017  ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6018  __SET_KERNEL_ARGS_ERR);
6019  }
6020 
6023  template<typename T, class Alloc>
6024  cl_int setArg(cl_uint index, const cl::vector<T, Alloc> &argPtr)
6025  {
6026  return detail::errHandler(
6027  ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6028  __SET_KERNEL_ARGS_ERR);
6029  }
6030 
6033  template<typename T>
6034  typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6035  setArg(cl_uint index, const T argPtr)
6036  {
6037  return detail::errHandler(
6038  ::clSetKernelArgSVMPointer(object_, index, argPtr),
6039  __SET_KERNEL_ARGS_ERR);
6040  }
6041 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6042 
6045  template <typename T>
6046  typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6047  setArg(cl_uint index, const T &value)
6048  {
6049  return detail::errHandler(
6050  ::clSetKernelArg(
6051  object_,
6052  index,
6055  __SET_KERNEL_ARGS_ERR);
6056  }
6057 
6058  cl_int setArg(cl_uint index, size_type size, const void* argPtr)
6059  {
6060  return detail::errHandler(
6061  ::clSetKernelArg(object_, index, size, argPtr),
6062  __SET_KERNEL_ARGS_ERR);
6063  }
6064 
6065 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6066 
6070  cl_int setSVMPointers(const vector<void*> &pointerList)
6071  {
6072  return detail::errHandler(
6073  ::clSetKernelExecInfo(
6074  object_,
6075  CL_KERNEL_EXEC_INFO_SVM_PTRS,
6076  sizeof(void*)*pointerList.size(),
6077  pointerList.data()));
6078  }
6079 
6084  template<int ArrayLength>
6085  cl_int setSVMPointers(const std::array<void*, ArrayLength> &pointerList)
6086  {
6087  return detail::errHandler(
6088  ::clSetKernelExecInfo(
6089  object_,
6090  CL_KERNEL_EXEC_INFO_SVM_PTRS,
6091  sizeof(void*)*pointerList.size(),
6092  pointerList.data()));
6093  }
6094 
6106  cl_int enableFineGrainedSystemSVM(bool svmEnabled)
6107  {
6108  cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6109  return detail::errHandler(
6110  ::clSetKernelExecInfo(
6111  object_,
6112  CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6113  sizeof(cl_bool),
6114  &svmEnabled_
6115  )
6116  );
6117  }
6118 
6119  template<int index, int ArrayLength, class D, typename T0, typename T1, typename... Ts>
6120  void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, const pointer<T0, D> &t0, const pointer<T1, D> &t1, Ts & ... ts)
6121  {
6122  pointerList[index] = static_cast<void*>(t0.get());
6123  setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6124  }
6125 
6126  template<int index, int ArrayLength, typename T0, typename T1, typename... Ts>
6127  typename std::enable_if<std::is_pointer<T0>::value, void>::type
6128  setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6129  {
6130  pointerList[index] = static_cast<void*>(t0);
6131  setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6132  }
6133 
6134  template<int index, int ArrayLength, typename T0, class D>
6135  void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, const pointer<T0, D> &t0)
6136  {
6137  pointerList[index] = static_cast<void*>(t0.get());
6138  }
6139 
6140 
6141  template<int index, int ArrayLength, typename T0>
6142  typename std::enable_if<std::is_pointer<T0>::value, void>::type
6143  setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6144  {
6145  pointerList[index] = static_cast<void*>(t0);
6146  }
6147 
6148  template<typename T0, typename... Ts>
6149  cl_int setSVMPointers(const T0 &t0, Ts & ... ts)
6150  {
6151  std::array<void*, 1 + sizeof...(Ts)> pointerList;
6152 
6153  setSVMPointersHelper<0, 1 + sizeof...(Ts)>(pointerList, t0, ts...);
6154  return detail::errHandler(
6155  ::clSetKernelExecInfo(
6156  object_,
6157  CL_KERNEL_EXEC_INFO_SVM_PTRS,
6158  sizeof(void*)*(1 + sizeof...(Ts)),
6159  pointerList.data()));
6160  }
6161 
6162  template<typename T>
6163  cl_int setExecInfo(cl_kernel_exec_info param_name, const T& val)
6164  {
6165  return detail::errHandler(
6166  ::clSetKernelExecInfo(
6167  object_,
6168  param_name,
6169  sizeof(T),
6170  &val));
6171  }
6172 
6173  template<cl_kernel_exec_info name>
6174  cl_int setExecInfo(typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6175  {
6176  return setExecInfo(name, val);
6177  }
6178 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6179 
6180 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6181 
6187  {
6188  cl_int error;
6189  Kernel retValue(clCloneKernel(this->get(), &error));
6190 
6191  detail::errHandler(error, __CLONE_KERNEL_ERR);
6192  return retValue;
6193  }
6194 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6195 };
6196 
6200 class Program : public detail::Wrapper<cl_program>
6201 {
6202 public:
6203 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6204  typedef vector<vector<unsigned char>> Binaries;
6205  typedef vector<string> Sources;
6206 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6207  typedef vector<std::pair<const void*, size_type> > Binaries;
6208  typedef vector<std::pair<const char*, size_type> > Sources;
6209 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6210 
6211  Program(
6212  const string& source,
6213  bool build = false,
6214  cl_int* err = NULL)
6215  {
6216  cl_int error;
6217 
6218  const char * strings = source.c_str();
6219  const size_type length = source.size();
6220 
6221  Context context = Context::getDefault(err);
6222 
6223  object_ = ::clCreateProgramWithSource(
6224  context(), (cl_uint)1, &strings, &length, &error);
6225 
6226  detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6227 
6228  if (error == CL_SUCCESS && build) {
6229 
6230  error = ::clBuildProgram(
6231  object_,
6232  0,
6233  NULL,
6234 #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6235  "-cl-std=CL2.0",
6236 #else
6237  "",
6238 #endif // #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6239  NULL,
6240  NULL);
6241 
6242  detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6243  }
6244 
6245  if (err != NULL) {
6246  *err = error;
6247  }
6248  }
6249 
6250  Program(
6251  const Context& context,
6252  const string& source,
6253  bool build = false,
6254  cl_int* err = NULL)
6255  {
6256  cl_int error;
6257 
6258  const char * strings = source.c_str();
6259  const size_type length = source.size();
6260 
6261  object_ = ::clCreateProgramWithSource(
6262  context(), (cl_uint)1, &strings, &length, &error);
6263 
6264  detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6265 
6266  if (error == CL_SUCCESS && build) {
6267  error = ::clBuildProgram(
6268  object_,
6269  0,
6270  NULL,
6271 #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6272  "-cl-std=CL2.0",
6273 #else
6274  "",
6275 #endif // #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6276  NULL,
6277  NULL);
6278 
6279  detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6280  }
6281 
6282  if (err != NULL) {
6283  *err = error;
6284  }
6285  }
6286 
6292  const Sources& sources,
6293  cl_int* err = NULL)
6294  {
6295  cl_int error;
6296  Context context = Context::getDefault(err);
6297 
6298  const size_type n = (size_type)sources.size();
6299 
6300  vector<size_type> lengths(n);
6301  vector<const char*> strings(n);
6302 
6303  for (size_type i = 0; i < n; ++i) {
6304 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6305  strings[i] = sources[(int)i].data();
6306  lengths[i] = sources[(int)i].length();
6307 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6308  strings[i] = sources[(int)i].first;
6309  lengths[i] = sources[(int)i].second;
6310 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6311  }
6312 
6313  object_ = ::clCreateProgramWithSource(
6314  context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6315 
6316  detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6317  if (err != NULL) {
6318  *err = error;
6319  }
6320  }
6321 
6327  const Context& context,
6328  const Sources& sources,
6329  cl_int* err = NULL)
6330  {
6331  cl_int error;
6332 
6333  const size_type n = (size_type)sources.size();
6334 
6335  vector<size_type> lengths(n);
6336  vector<const char*> strings(n);
6337 
6338  for (size_type i = 0; i < n; ++i) {
6339 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6340  strings[i] = sources[(int)i].data();
6341  lengths[i] = sources[(int)i].length();
6342 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6343  strings[i] = sources[(int)i].first;
6344  lengths[i] = sources[(int)i].second;
6345 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6346  }
6347 
6348  object_ = ::clCreateProgramWithSource(
6349  context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6350 
6351  detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6352  if (err != NULL) {
6353  *err = error;
6354  }
6355  }
6356 
6357 
6358 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6359 
6364  const vector<char>& IL,
6365  bool build = false,
6366  cl_int* err = NULL)
6367  {
6368  cl_int error;
6369 
6370  Context context = Context::getDefault(err);
6371 
6372 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6373 
6374  object_ = ::clCreateProgramWithIL(
6375  context(), static_cast<const void*>(IL.data()), IL.size(), &error);
6376 
6377 #else // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6378 
6379  typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6380  static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6381  CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6382 
6383  return detail::errHandler(
6384  pfn_clCreateProgramWithILKHR(
6385  context(), static_cast<const void*>(IL.data()), IL.size(), &error);
6386 
6387 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6388 
6389  detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6390 
6391  if (error == CL_SUCCESS && build) {
6392 
6393  error = ::clBuildProgram(
6394  object_,
6395  0,
6396  NULL,
6397 #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6398  "-cl-std=CL2.0",
6399 #else
6400  "",
6401 #endif // #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6402  NULL,
6403  NULL);
6404 
6405  detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6406  }
6407 
6408  if (err != NULL) {
6409  *err = error;
6410  }
6411  }
6412 
6419  const Context& context,
6420  const vector<char>& IL,
6421  bool build = false,
6422  cl_int* err = NULL)
6423  {
6424  cl_int error;
6425 
6426 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6427 
6428  object_ = ::clCreateProgramWithIL(
6429  context(), static_cast<const void*>(IL.data()), IL.size(), &error);
6430 
6431 #else // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6432 
6433  typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6434  static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6435  CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6436 
6437  return detail::errHandler(
6438  pfn_clCreateProgramWithILKHR(
6439  context(), static_cast<const void*>(IL.data()), IL.size(), &error);
6440 
6441 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6442 
6443  detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6444 
6445  if (error == CL_SUCCESS && build) {
6446  error = ::clBuildProgram(
6447  object_,
6448  0,
6449  NULL,
6450 #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6451  "-cl-std=CL2.0",
6452 #else
6453  "",
6454 #endif // #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6455  NULL,
6456  NULL);
6457 
6458  detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6459  }
6460 
6461  if (err != NULL) {
6462  *err = error;
6463  }
6464  }
6465 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6466 
6487  const Context& context,
6488  const vector<Device>& devices,
6489  const Binaries& binaries,
6490  vector<cl_int>* binaryStatus = NULL,
6491  cl_int* err = NULL)
6492  {
6493  cl_int error;
6494 
6495  const size_type numDevices = devices.size();
6496 
6497  // Catch size mismatch early and return
6498  if(binaries.size() != numDevices) {
6499  error = CL_INVALID_VALUE;
6500  detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6501  if (err != NULL) {
6502  *err = error;
6503  }
6504  return;
6505  }
6506 
6507 
6508  vector<size_type> lengths(numDevices);
6509  vector<const unsigned char*> images(numDevices);
6510 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6511  for (size_type i = 0; i < numDevices; ++i) {
6512  images[i] = binaries[i].data();
6513  lengths[i] = binaries[(int)i].size();
6514  }
6515 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6516  for (size_type i = 0; i < numDevices; ++i) {
6517  images[i] = (const unsigned char*)binaries[i].first;
6518  lengths[i] = binaries[(int)i].second;
6519  }
6520 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6521 
6522  vector<cl_device_id> deviceIDs(numDevices);
6523  for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6524  deviceIDs[deviceIndex] = (devices[deviceIndex])();
6525  }
6526 
6527  if(binaryStatus) {
6528  binaryStatus->resize(numDevices);
6529  }
6530 
6531  object_ = ::clCreateProgramWithBinary(
6532  context(), (cl_uint) devices.size(),
6533  deviceIDs.data(),
6534  lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6535  ? &binaryStatus->front()
6536  : NULL, &error);
6537 
6538  detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6539  if (err != NULL) {
6540  *err = error;
6541  }
6542  }
6543 
6544 
6545 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6546 
6551  const Context& context,
6552  const vector<Device>& devices,
6553  const string& kernelNames,
6554  cl_int* err = NULL)
6555  {
6556  cl_int error;
6557 
6558 
6559  size_type numDevices = devices.size();
6560  vector<cl_device_id> deviceIDs(numDevices);
6561  for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6562  deviceIDs[deviceIndex] = (devices[deviceIndex])();
6563  }
6564 
6565  object_ = ::clCreateProgramWithBuiltInKernels(
6566  context(),
6567  (cl_uint) devices.size(),
6568  deviceIDs.data(),
6569  kernelNames.c_str(),
6570  &error);
6571 
6572  detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6573  if (err != NULL) {
6574  *err = error;
6575  }
6576  }
6577 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
6578 
6579  Program() { }
6580 
6581 
6588  explicit Program(const cl_program& program, bool retainObject = false) :
6589  detail::Wrapper<cl_type>(program, retainObject) { }
6590 
6591  Program& operator = (const cl_program& rhs)
6592  {
6594  return *this;
6595  }
6596 
6600  Program(const Program& program) : detail::Wrapper<cl_type>(program) {}
6601 
6605  Program& operator = (const Program &program)
6606  {
6608  return *this;
6609  }
6610 
6614  Program(Program&& program) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(program)) {}
6615 
6619  Program& operator = (Program &&program)
6620  {
6621  detail::Wrapper<cl_type>::operator=(std::move(program));
6622  return *this;
6623  }
6624 
6625  cl_int build(
6626  const vector<Device>& devices,
6627  const char* options = NULL,
6628  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
6629  void* data = NULL) const
6630  {
6631  size_type numDevices = devices.size();
6632  vector<cl_device_id> deviceIDs(numDevices);
6633 
6634  for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6635  deviceIDs[deviceIndex] = (devices[deviceIndex])();
6636  }
6637 
6638  cl_int buildError = ::clBuildProgram(
6639  object_,
6640  (cl_uint)
6641  devices.size(),
6642  deviceIDs.data(),
6643  options,
6644  notifyFptr,
6645  data);
6646 
6647  return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6648  }
6649 
6650  cl_int build(
6651  const Device& device,
6652  const char* options = NULL,
6653  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
6654  void* data = NULL) const
6655  {
6656  cl_device_id deviceID = device();
6657 
6658  cl_int buildError = ::clBuildProgram(
6659  object_,
6660  1,
6661  &deviceID,
6662  options,
6663  notifyFptr,
6664  data);
6665 
6666  BuildLogType buildLog(1);
6667  buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6668  return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6669  }
6670 
6671  cl_int build(
6672  const char* options = NULL,
6673  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
6674  void* data = NULL) const
6675  {
6676  cl_int buildError = ::clBuildProgram(
6677  object_,
6678  0,
6679  NULL,
6680  options,
6681  notifyFptr,
6682  data);
6683 
6684  return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6685  }
6686 
6687 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6688  cl_int compile(
6689  const char* options = NULL,
6690  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
6691  void* data = NULL) const
6692  {
6693  cl_int error = ::clCompileProgram(
6694  object_,
6695  0,
6696  NULL,
6697  options,
6698  0,
6699  NULL,
6700  NULL,
6701  notifyFptr,
6702  data);
6703  return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6704  }
6705 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
6706 
6707  template <typename T>
6708  cl_int getInfo(cl_program_info name, T* param) const
6709  {
6710  return detail::errHandler(
6711  detail::getInfo(&::clGetProgramInfo, object_, name, param),
6712  __GET_PROGRAM_INFO_ERR);
6713  }
6714 
6715  template <cl_program_info name> typename
6716  detail::param_traits<detail::cl_program_info, name>::param_type
6717  getInfo(cl_int* err = NULL) const
6718  {
6719  typename detail::param_traits<
6720  detail::cl_program_info, name>::param_type param;
6721  cl_int result = getInfo(name, &param);
6722  if (err != NULL) {
6723  *err = result;
6724  }
6725  return param;
6726  }
6727 
6728  template <typename T>
6729  cl_int getBuildInfo(
6730  const Device& device, cl_program_build_info name, T* param) const
6731  {
6732  return detail::errHandler(
6733  detail::getInfo(
6734  &::clGetProgramBuildInfo, object_, device(), name, param),
6735  __GET_PROGRAM_BUILD_INFO_ERR);
6736  }
6737 
6738  template <cl_program_build_info name> typename
6739  detail::param_traits<detail::cl_program_build_info, name>::param_type
6740  getBuildInfo(const Device& device, cl_int* err = NULL) const
6741  {
6742  typename detail::param_traits<
6743  detail::cl_program_build_info, name>::param_type param;
6744  cl_int result = getBuildInfo(device, name, &param);
6745  if (err != NULL) {
6746  *err = result;
6747  }
6748  return param;
6749  }
6750 
6756  template <cl_program_build_info name>
6757  vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6758  getBuildInfo(cl_int *err = NULL) const
6759  {
6760  cl_int result = CL_SUCCESS;
6761 
6762  auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6763  vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6764  devInfo;
6765 
6766  // If there was an initial error from getInfo return the error
6767  if (result != CL_SUCCESS) {
6768  if (err != NULL) {
6769  *err = result;
6770  }
6771  return devInfo;
6772  }
6773 
6774  for (const cl::Device &d : devs) {
6775  typename detail::param_traits<
6776  detail::cl_program_build_info, name>::param_type param;
6777  result = getBuildInfo(d, name, &param);
6778  devInfo.push_back(
6780  (d, param));
6781  if (result != CL_SUCCESS) {
6782  // On error, leave the loop and return the error code
6783  break;
6784  }
6785  }
6786  if (err != NULL) {
6787  *err = result;
6788  }
6789  if (result != CL_SUCCESS) {
6790  devInfo.clear();
6791  }
6792  return devInfo;
6793  }
6794 
6795  cl_int createKernels(vector<Kernel>* kernels)
6796  {
6797  cl_uint numKernels;
6798  cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6799  if (err != CL_SUCCESS) {
6800  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6801  }
6802 
6803  vector<cl_kernel> value(numKernels);
6804 
6805  err = ::clCreateKernelsInProgram(
6806  object_, numKernels, value.data(), NULL);
6807  if (err != CL_SUCCESS) {
6808  return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6809  }
6810 
6811  if (kernels) {
6812  kernels->resize(value.size());
6813 
6814  // Assign to param, constructing with retain behaviour
6815  // to correctly capture each underlying CL object
6816  for (size_type i = 0; i < value.size(); i++) {
6817  // We do not need to retain because this kernel is being created
6818  // by the runtime
6819  (*kernels)[i] = Kernel(value[i], false);
6820  }
6821  }
6822  return CL_SUCCESS;
6823  }
6824 
6825 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
6826 #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6827 
6837  CL_EXT_PREFIX__VERSION_2_2_DEPRECATED cl_int setReleaseCallback(
6838  void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data),
6839  void * user_data = NULL) CL_EXT_SUFFIX__VERSION_2_2_DEPRECATED
6840  {
6841  return detail::errHandler(
6842  ::clSetProgramReleaseCallback(
6843  object_,
6844  pfn_notify,
6845  user_data),
6846  __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6847  }
6848 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6849 
6854  template <typename T>
6855  typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6856  setSpecializationConstant(cl_uint index, const T &value)
6857  {
6858  return detail::errHandler(
6859  ::clSetProgramSpecializationConstant(
6860  object_,
6861  index,
6862  sizeof(value),
6863  &value),
6864  __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6865  }
6866 
6871  cl_int setSpecializationConstant(cl_uint index, size_type size, const void* value)
6872  {
6873  return detail::errHandler(
6874  ::clSetProgramSpecializationConstant(
6875  object_,
6876  index,
6877  size,
6878  value),
6879  __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6880  }
6881 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 220
6882 };
6883 
6884 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6885 inline Program linkProgram(
6886  Program input1,
6887  Program input2,
6888  const char* options = NULL,
6889  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
6890  void* data = NULL,
6891  cl_int* err = NULL)
6892 {
6893  cl_int error_local = CL_SUCCESS;
6894 
6895  cl_program programs[2] = { input1(), input2() };
6896 
6897  Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6898  if(error_local!=CL_SUCCESS) {
6899  detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6900  }
6901 
6902  cl_program prog = ::clLinkProgram(
6903  ctx(),
6904  0,
6905  NULL,
6906  options,
6907  2,
6908  programs,
6909  notifyFptr,
6910  data,
6911  &error_local);
6912 
6913  detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6914  if (err != NULL) {
6915  *err = error_local;
6916  }
6917 
6918  return Program(prog);
6919 }
6920 
6921 inline Program linkProgram(
6922  vector<Program> inputPrograms,
6923  const char* options = NULL,
6924  void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
6925  void* data = NULL,
6926  cl_int* err = NULL)
6927 {
6928  cl_int error_local = CL_SUCCESS;
6929 
6930  vector<cl_program> programs(inputPrograms.size());
6931 
6932  for (unsigned int i = 0; i < inputPrograms.size(); i++) {
6933  programs[i] = inputPrograms[i]();
6934  }
6935 
6936  Context ctx;
6937  if(inputPrograms.size() > 0) {
6938  ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6939  if(error_local!=CL_SUCCESS) {
6940  detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6941  }
6942  }
6943  cl_program prog = ::clLinkProgram(
6944  ctx(),
6945  0,
6946  NULL,
6947  options,
6948  (cl_uint)inputPrograms.size(),
6949  programs.data(),
6950  notifyFptr,
6951  data,
6952  &error_local);
6953 
6954  detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6955  if (err != NULL) {
6956  *err = error_local;
6957  }
6958 
6959  return Program(prog, false);
6960 }
6961 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
6962 
6963 // Template specialization for CL_PROGRAM_BINARIES
6964 template <>
6965 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param) const
6966 {
6967  if (name != CL_PROGRAM_BINARIES) {
6968  return CL_INVALID_VALUE;
6969  }
6970  if (param) {
6971  // Resize the parameter array appropriately for each allocation
6972  // and pass down to the helper
6973 
6974  vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6975  size_type numBinaries = sizes.size();
6976 
6977  // Resize the parameter array and constituent arrays
6978  param->resize(numBinaries);
6979  for (size_type i = 0; i < numBinaries; ++i) {
6980  (*param)[i].resize(sizes[i]);
6981  }
6982 
6983  return detail::errHandler(
6984  detail::getInfo(&::clGetProgramInfo, object_, name, param),
6985  __GET_PROGRAM_INFO_ERR);
6986  }
6987 
6988  return CL_SUCCESS;
6989 }
6990 
6991 template<>
6992 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const
6993 {
6994  vector<vector<unsigned char>> binariesVectors;
6995 
6996  cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
6997  if (err != NULL) {
6998  *err = result;
6999  }
7000  return binariesVectors;
7001 }
7002 
7003 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
7004 // Template specialization for clSetProgramSpecializationConstant
7005 template <>
7006 inline cl_int cl::Program::setSpecializationConstant(cl_uint index, const bool &value)
7007 {
7008  cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7009  return detail::errHandler(
7010  ::clSetProgramSpecializationConstant(
7011  object_,
7012  index,
7013  sizeof(ucValue),
7014  &ucValue),
7015  __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7016 }
7017 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 220
7018 
7019 inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
7020 {
7021  cl_int error;
7022 
7023  object_ = ::clCreateKernel(program(), name, &error);
7024  detail::errHandler(error, __CREATE_KERNEL_ERR);
7025 
7026  if (err != NULL) {
7027  *err = error;
7028  }
7029 
7030 }
7031 
7032 enum class QueueProperties : cl_command_queue_properties
7033 {
7034  None = 0,
7035  Profiling = CL_QUEUE_PROFILING_ENABLE,
7036  OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7037 };
7038 
7039 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7040 {
7041  return static_cast<QueueProperties>(static_cast<cl_command_queue_properties>(lhs) | static_cast<cl_command_queue_properties>(rhs));
7042 }
7043 
7047 class CommandQueue : public detail::Wrapper<cl_command_queue>
7048 {
7049 private:
7050  static std::once_flag default_initialized_;
7051  static CommandQueue default_;
7052  static cl_int default_error_;
7053 
7059  static void makeDefault()
7060  {
7061  /* We don't want to throw an error from this function, so we have to
7062  * catch and set the error flag.
7063  */
7064 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7065  try
7066 #endif
7067  {
7068  int error;
7069  Context context = Context::getDefault(&error);
7070 
7071  if (error != CL_SUCCESS) {
7072  default_error_ = error;
7073  }
7074  else {
7075  Device device = Device::getDefault();
7076  default_ = CommandQueue(context, device, 0, &default_error_);
7077  }
7078  }
7079 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7080  catch (cl::Error &e) {
7081  default_error_ = e.err();
7082  }
7083 #endif
7084  }
7085 
7091  static void makeDefaultProvided(const CommandQueue &c) {
7092  default_ = c;
7093  }
7094 
7095 public:
7096 #ifdef CL_HPP_UNIT_TEST_ENABLE
7097 
7103  static void unitTestClearDefault() {
7104  default_ = CommandQueue();
7105  }
7106 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
7107 
7108 
7114  cl_command_queue_properties properties,
7115  cl_int* err = NULL)
7116  {
7117  cl_int error;
7118 
7119  Context context = Context::getDefault(&error);
7120  detail::errHandler(error, __CREATE_CONTEXT_ERR);
7121 
7122  if (error != CL_SUCCESS) {
7123  if (err != NULL) {
7124  *err = error;
7125  }
7126  }
7127  else {
7128  Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
7129  bool useWithProperties;
7130 
7131 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7132  // Run-time decision based on the actual platform
7133  {
7134  cl_uint version = detail::getContextPlatformVersion(context());
7135  useWithProperties = (version >= 0x20000); // OpenCL 2.0 or above
7136  }
7137 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7138  useWithProperties = true;
7139 #else
7140  useWithProperties = false;
7141 #endif
7142 
7143 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7144  if (useWithProperties) {
7145  cl_queue_properties queue_properties[] = {
7146  CL_QUEUE_PROPERTIES, properties, 0 };
7147  if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7148  object_ = ::clCreateCommandQueueWithProperties(
7149  context(), device(), queue_properties, &error);
7150  }
7151  else {
7152  error = CL_INVALID_QUEUE_PROPERTIES;
7153  }
7154 
7155  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7156  if (err != NULL) {
7157  *err = error;
7158  }
7159  }
7160 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7161 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7162  if (!useWithProperties) {
7163  object_ = ::clCreateCommandQueue(
7164  context(), device(), properties, &error);
7165 
7166  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7167  if (err != NULL) {
7168  *err = error;
7169  }
7170  }
7171 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7172  }
7173  }
7174 
7180  QueueProperties properties,
7181  cl_int* err = NULL)
7182  {
7183  cl_int error;
7184 
7185  Context context = Context::getDefault(&error);
7186  detail::errHandler(error, __CREATE_CONTEXT_ERR);
7187 
7188  if (error != CL_SUCCESS) {
7189  if (err != NULL) {
7190  *err = error;
7191  }
7192  }
7193  else {
7194  Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
7195  bool useWithProperties;
7196 
7197 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7198  // Run-time decision based on the actual platform
7199  {
7200  cl_uint version = detail::getContextPlatformVersion(context());
7201  useWithProperties = (version >= 0x20000); // OpenCL 2.0 or above
7202  }
7203 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7204  useWithProperties = true;
7205 #else
7206  useWithProperties = false;
7207 #endif
7208 
7209 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7210  if (useWithProperties) {
7211  cl_queue_properties queue_properties[] = {
7212  CL_QUEUE_PROPERTIES, static_cast<cl_queue_properties>(properties), 0 };
7213 
7214  object_ = ::clCreateCommandQueueWithProperties(
7215  context(), device(), queue_properties, &error);
7216 
7217  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7218  if (err != NULL) {
7219  *err = error;
7220  }
7221  }
7222 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7223 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7224  if (!useWithProperties) {
7225  object_ = ::clCreateCommandQueue(
7226  context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
7227 
7228  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7229  if (err != NULL) {
7230  *err = error;
7231  }
7232  }
7233 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7234 
7235  }
7236  }
7237 
7242  explicit CommandQueue(
7243  const Context& context,
7244  cl_command_queue_properties properties = 0,
7245  cl_int* err = NULL)
7246  {
7247  cl_int error;
7248  bool useWithProperties;
7249  vector<cl::Device> devices;
7250  error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
7251 
7252  detail::errHandler(error, __CREATE_CONTEXT_ERR);
7253 
7254  if (error != CL_SUCCESS)
7255  {
7256  if (err != NULL) {
7257  *err = error;
7258  }
7259  return;
7260  }
7261 
7262 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7263  // Run-time decision based on the actual platform
7264  {
7265  cl_uint version = detail::getContextPlatformVersion(context());
7266  useWithProperties = (version >= 0x20000); // OpenCL 2.0 or above
7267  }
7268 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7269  useWithProperties = true;
7270 #else
7271  useWithProperties = false;
7272 #endif
7273 
7274 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7275  if (useWithProperties) {
7276  cl_queue_properties queue_properties[] = {
7277  CL_QUEUE_PROPERTIES, properties, 0 };
7278  if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7279  object_ = ::clCreateCommandQueueWithProperties(
7280  context(), devices[0](), queue_properties, &error);
7281  }
7282  else {
7283  error = CL_INVALID_QUEUE_PROPERTIES;
7284  }
7285 
7286  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7287  if (err != NULL) {
7288  *err = error;
7289  }
7290  }
7291 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7292 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7293  if (!useWithProperties) {
7294  object_ = ::clCreateCommandQueue(
7295  context(), devices[0](), properties, &error);
7296 
7297  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7298  if (err != NULL) {
7299  *err = error;
7300  }
7301  }
7302 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7303  }
7304 
7309  explicit CommandQueue(
7310  const Context& context,
7311  QueueProperties properties,
7312  cl_int* err = NULL)
7313  {
7314  cl_int error;
7315  bool useWithProperties;
7316  vector<cl::Device> devices;
7317  error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
7318 
7319  detail::errHandler(error, __CREATE_CONTEXT_ERR);
7320 
7321  if (error != CL_SUCCESS)
7322  {
7323  if (err != NULL) {
7324  *err = error;
7325  }
7326  return;
7327  }
7328 
7329 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7330  // Run-time decision based on the actual platform
7331  {
7332  cl_uint version = detail::getContextPlatformVersion(context());
7333  useWithProperties = (version >= 0x20000); // OpenCL 2.0 or above
7334  }
7335 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7336  useWithProperties = true;
7337 #else
7338  useWithProperties = false;
7339 #endif
7340 
7341 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7342  if (useWithProperties) {
7343  cl_queue_properties queue_properties[] = {
7344  CL_QUEUE_PROPERTIES, static_cast<cl_queue_properties>(properties), 0 };
7345  object_ = ::clCreateCommandQueueWithProperties(
7346  context(), devices[0](), queue_properties, &error);
7347 
7348  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7349  if (err != NULL) {
7350  *err = error;
7351  }
7352  }
7353 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7354 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7355  if (!useWithProperties) {
7356  object_ = ::clCreateCommandQueue(
7357  context(), devices[0](), static_cast<cl_command_queue_properties>(properties), &error);
7358 
7359  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7360  if (err != NULL) {
7361  *err = error;
7362  }
7363  }
7364 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7365  }
7366 
7372  const Context& context,
7373  const Device& device,
7374  cl_command_queue_properties properties = 0,
7375  cl_int* err = NULL)
7376  {
7377  cl_int error;
7378  bool useWithProperties;
7379 
7380 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7381  // Run-time decision based on the actual platform
7382  {
7383  cl_uint version = detail::getContextPlatformVersion(context());
7384  useWithProperties = (version >= 0x20000); // OpenCL 2.0 or above
7385  }
7386 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7387  useWithProperties = true;
7388 #else
7389  useWithProperties = false;
7390 #endif
7391 
7392 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7393  if (useWithProperties) {
7394  cl_queue_properties queue_properties[] = {
7395  CL_QUEUE_PROPERTIES, properties, 0 };
7396  object_ = ::clCreateCommandQueueWithProperties(
7397  context(), device(), queue_properties, &error);
7398 
7399  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7400  if (err != NULL) {
7401  *err = error;
7402  }
7403  }
7404 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7405 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7406  if (!useWithProperties) {
7407  object_ = ::clCreateCommandQueue(
7408  context(), device(), properties, &error);
7409 
7410  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7411  if (err != NULL) {
7412  *err = error;
7413  }
7414  }
7415 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7416  }
7417 
7423  const Context& context,
7424  const Device& device,
7425  QueueProperties properties,
7426  cl_int* err = NULL)
7427  {
7428  cl_int error;
7429  bool useWithProperties;
7430 
7431 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7432  // Run-time decision based on the actual platform
7433  {
7434  cl_uint version = detail::getContextPlatformVersion(context());
7435  useWithProperties = (version >= 0x20000); // OpenCL 2.0 or above
7436  }
7437 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7438  useWithProperties = true;
7439 #else
7440  useWithProperties = false;
7441 #endif
7442 
7443 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7444  if (useWithProperties) {
7445  cl_queue_properties queue_properties[] = {
7446  CL_QUEUE_PROPERTIES, static_cast<cl_queue_properties>(properties), 0 };
7447  object_ = ::clCreateCommandQueueWithProperties(
7448  context(), device(), queue_properties, &error);
7449 
7450  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7451  if (err != NULL) {
7452  *err = error;
7453  }
7454  }
7455 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7456 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7457  if (!useWithProperties) {
7458  object_ = ::clCreateCommandQueue(
7459  context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
7460 
7461  detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7462  if (err != NULL) {
7463  *err = error;
7464  }
7465  }
7466 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7467  }
7468 
7469  static CommandQueue getDefault(cl_int * err = NULL)
7470  {
7471  std::call_once(default_initialized_, makeDefault);
7472 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7473  detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7474 #else // CL_HPP_TARGET_OPENCL_VERSION >= 200
7475  detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7476 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7477  if (err != NULL) {
7478  *err = default_error_;
7479  }
7480  return default_;
7481  }
7482 
7490  static CommandQueue setDefault(const CommandQueue &default_queue)
7491  {
7492  std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7493  detail::errHandler(default_error_);
7494  return default_;
7495  }
7496 
7497  CommandQueue() { }
7498 
7499 
7506  explicit CommandQueue(const cl_command_queue& commandQueue, bool retainObject = false) :
7507  detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7508 
7509  CommandQueue& operator = (const cl_command_queue& rhs)
7510  {
7512  return *this;
7513  }
7514 
7518  CommandQueue(const CommandQueue& queue) : detail::Wrapper<cl_type>(queue) {}
7519 
7523  CommandQueue& operator = (const CommandQueue &queue)
7524  {
7526  return *this;
7527  }
7528 
7532  CommandQueue(CommandQueue&& queue) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(queue)) {}
7533 
7537  CommandQueue& operator = (CommandQueue &&queue)
7538  {
7539  detail::Wrapper<cl_type>::operator=(std::move(queue));
7540  return *this;
7541  }
7542 
7543  template <typename T>
7544  cl_int getInfo(cl_command_queue_info name, T* param) const
7545  {
7546  return detail::errHandler(
7547  detail::getInfo(
7548  &::clGetCommandQueueInfo, object_, name, param),
7549  __GET_COMMAND_QUEUE_INFO_ERR);
7550  }
7551 
7552  template <cl_command_queue_info name> typename
7553  detail::param_traits<detail::cl_command_queue_info, name>::param_type
7554  getInfo(cl_int* err = NULL) const
7555  {
7556  typename detail::param_traits<
7557  detail::cl_command_queue_info, name>::param_type param;
7558  cl_int result = getInfo(name, &param);
7559  if (err != NULL) {
7560  *err = result;
7561  }
7562  return param;
7563  }
7564 
7565  cl_int enqueueReadBuffer(
7566  const Buffer& buffer,
7567  cl_bool blocking,
7568  size_type offset,
7569  size_type size,
7570  void* ptr,
7571  const vector<Event>* events = NULL,
7572  Event* event = NULL) const
7573  {
7574  cl_event tmp;
7575  cl_int err = detail::errHandler(
7576  ::clEnqueueReadBuffer(
7577  object_, buffer(), blocking, offset, size,
7578  ptr,
7579  (events != NULL) ? (cl_uint) events->size() : 0,
7580  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7581  (event != NULL) ? &tmp : NULL),
7582  __ENQUEUE_READ_BUFFER_ERR);
7583 
7584  if (event != NULL && err == CL_SUCCESS)
7585  *event = tmp;
7586 
7587  return err;
7588  }
7589 
7590  cl_int enqueueWriteBuffer(
7591  const Buffer& buffer,
7592  cl_bool blocking,
7593  size_type offset,
7594  size_type size,
7595  const void* ptr,
7596  const vector<Event>* events = NULL,
7597  Event* event = NULL) const
7598  {
7599  cl_event tmp;
7600  cl_int err = detail::errHandler(
7601  ::clEnqueueWriteBuffer(
7602  object_, buffer(), blocking, offset, size,
7603  ptr,
7604  (events != NULL) ? (cl_uint) events->size() : 0,
7605  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7606  (event != NULL) ? &tmp : NULL),
7607  __ENQUEUE_WRITE_BUFFER_ERR);
7608 
7609  if (event != NULL && err == CL_SUCCESS)
7610  *event = tmp;
7611 
7612  return err;
7613  }
7614 
7615  cl_int enqueueCopyBuffer(
7616  const Buffer& src,
7617  const Buffer& dst,
7618  size_type src_offset,
7619  size_type dst_offset,
7620  size_type size,
7621  const vector<Event>* events = NULL,
7622  Event* event = NULL) const
7623  {
7624  cl_event tmp;
7625  cl_int err = detail::errHandler(
7626  ::clEnqueueCopyBuffer(
7627  object_, src(), dst(), src_offset, dst_offset, size,
7628  (events != NULL) ? (cl_uint) events->size() : 0,
7629  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7630  (event != NULL) ? &tmp : NULL),
7631  __ENQEUE_COPY_BUFFER_ERR);
7632 
7633  if (event != NULL && err == CL_SUCCESS)
7634  *event = tmp;
7635 
7636  return err;
7637  }
7638 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
7639  cl_int enqueueReadBufferRect(
7640  const Buffer& buffer,
7641  cl_bool blocking,
7642  const array<size_type, 3>& buffer_offset,
7643  const array<size_type, 3>& host_offset,
7644  const array<size_type, 3>& region,
7645  size_type buffer_row_pitch,
7646  size_type buffer_slice_pitch,
7647  size_type host_row_pitch,
7648  size_type host_slice_pitch,
7649  void *ptr,
7650  const vector<Event>* events = NULL,
7651  Event* event = NULL) const
7652  {
7653  cl_event tmp;
7654  cl_int err = detail::errHandler(
7655  ::clEnqueueReadBufferRect(
7656  object_,
7657  buffer(),
7658  blocking,
7659  buffer_offset.data(),
7660  host_offset.data(),
7661  region.data(),
7662  buffer_row_pitch,
7663  buffer_slice_pitch,
7664  host_row_pitch,
7665  host_slice_pitch,
7666  ptr,
7667  (events != NULL) ? (cl_uint) events->size() : 0,
7668  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7669  (event != NULL) ? &tmp : NULL),
7670  __ENQUEUE_READ_BUFFER_RECT_ERR);
7671 
7672  if (event != NULL && err == CL_SUCCESS)
7673  *event = tmp;
7674 
7675  return err;
7676  }
7677 
7678  cl_int enqueueWriteBufferRect(
7679  const Buffer& buffer,
7680  cl_bool blocking,
7681  const array<size_type, 3>& buffer_offset,
7682  const array<size_type, 3>& host_offset,
7683  const array<size_type, 3>& region,
7684  size_type buffer_row_pitch,
7685  size_type buffer_slice_pitch,
7686  size_type host_row_pitch,
7687  size_type host_slice_pitch,
7688  const void *ptr,
7689  const vector<Event>* events = NULL,
7690  Event* event = NULL) const
7691  {
7692  cl_event tmp;
7693  cl_int err = detail::errHandler(
7694  ::clEnqueueWriteBufferRect(
7695  object_,
7696  buffer(),
7697  blocking,
7698  buffer_offset.data(),
7699  host_offset.data(),
7700  region.data(),
7701  buffer_row_pitch,
7702  buffer_slice_pitch,
7703  host_row_pitch,
7704  host_slice_pitch,
7705  ptr,
7706  (events != NULL) ? (cl_uint) events->size() : 0,
7707  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7708  (event != NULL) ? &tmp : NULL),
7709  __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7710 
7711  if (event != NULL && err == CL_SUCCESS)
7712  *event = tmp;
7713 
7714  return err;
7715  }
7716 
7717  cl_int enqueueCopyBufferRect(
7718  const Buffer& src,
7719  const Buffer& dst,
7720  const array<size_type, 3>& src_origin,
7721  const array<size_type, 3>& dst_origin,
7722  const array<size_type, 3>& region,
7723  size_type src_row_pitch,
7724  size_type src_slice_pitch,
7725  size_type dst_row_pitch,
7726  size_type dst_slice_pitch,
7727  const vector<Event>* events = NULL,
7728  Event* event = NULL) const
7729  {
7730  cl_event tmp;
7731  cl_int err = detail::errHandler(
7732  ::clEnqueueCopyBufferRect(
7733  object_,
7734  src(),
7735  dst(),
7736  src_origin.data(),
7737  dst_origin.data(),
7738  region.data(),
7739  src_row_pitch,
7740  src_slice_pitch,
7741  dst_row_pitch,
7742  dst_slice_pitch,
7743  (events != NULL) ? (cl_uint) events->size() : 0,
7744  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7745  (event != NULL) ? &tmp : NULL),
7746  __ENQEUE_COPY_BUFFER_RECT_ERR);
7747 
7748  if (event != NULL && err == CL_SUCCESS)
7749  *event = tmp;
7750 
7751  return err;
7752  }
7753 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
7754 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7755 
7766  template<typename PatternType>
7768  const Buffer& buffer,
7769  PatternType pattern,
7770  size_type offset,
7771  size_type size,
7772  const vector<Event>* events = NULL,
7773  Event* event = NULL) const
7774  {
7775  cl_event tmp;
7776  cl_int err = detail::errHandler(
7777  ::clEnqueueFillBuffer(
7778  object_,
7779  buffer(),
7780  static_cast<void*>(&pattern),
7781  sizeof(PatternType),
7782  offset,
7783  size,
7784  (events != NULL) ? (cl_uint) events->size() : 0,
7785  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7786  (event != NULL) ? &tmp : NULL),
7787  __ENQUEUE_FILL_BUFFER_ERR);
7788 
7789  if (event != NULL && err == CL_SUCCESS)
7790  *event = tmp;
7791 
7792  return err;
7793  }
7794 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
7795 
7796  cl_int enqueueReadImage(
7797  const Image& image,
7798  cl_bool blocking,
7799  const array<size_type, 3>& origin,
7800  const array<size_type, 3>& region,
7801  size_type row_pitch,
7802  size_type slice_pitch,
7803  void* ptr,
7804  const vector<Event>* events = NULL,
7805  Event* event = NULL) const
7806  {
7807  cl_event tmp;
7808  cl_int err = detail::errHandler(
7809  ::clEnqueueReadImage(
7810  object_,
7811  image(),
7812  blocking,
7813  origin.data(),
7814  region.data(),
7815  row_pitch,
7816  slice_pitch,
7817  ptr,
7818  (events != NULL) ? (cl_uint) events->size() : 0,
7819  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7820  (event != NULL) ? &tmp : NULL),
7821  __ENQUEUE_READ_IMAGE_ERR);
7822 
7823  if (event != NULL && err == CL_SUCCESS)
7824  *event = tmp;
7825 
7826  return err;
7827  }
7828 
7829  cl_int enqueueWriteImage(
7830  const Image& image,
7831  cl_bool blocking,
7832  const array<size_type, 3>& origin,
7833  const array<size_type, 3>& region,
7834  size_type row_pitch,
7835  size_type slice_pitch,
7836  const void* ptr,
7837  const vector<Event>* events = NULL,
7838  Event* event = NULL) const
7839  {
7840  cl_event tmp;
7841  cl_int err = detail::errHandler(
7842  ::clEnqueueWriteImage(
7843  object_,
7844  image(),
7845  blocking,
7846  origin.data(),
7847  region.data(),
7848  row_pitch,
7849  slice_pitch,
7850  ptr,
7851  (events != NULL) ? (cl_uint) events->size() : 0,
7852  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7853  (event != NULL) ? &tmp : NULL),
7854  __ENQUEUE_WRITE_IMAGE_ERR);
7855 
7856  if (event != NULL && err == CL_SUCCESS)
7857  *event = tmp;
7858 
7859  return err;
7860  }
7861 
7862  cl_int enqueueCopyImage(
7863  const Image& src,
7864  const Image& dst,
7865  const array<size_type, 3>& src_origin,
7866  const array<size_type, 3>& dst_origin,
7867  const array<size_type, 3>& region,
7868  const vector<Event>* events = NULL,
7869  Event* event = NULL) const
7870  {
7871  cl_event tmp;
7872  cl_int err = detail::errHandler(
7873  ::clEnqueueCopyImage(
7874  object_,
7875  src(),
7876  dst(),
7877  src_origin.data(),
7878  dst_origin.data(),
7879  region.data(),
7880  (events != NULL) ? (cl_uint) events->size() : 0,
7881  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7882  (event != NULL) ? &tmp : NULL),
7883  __ENQUEUE_COPY_IMAGE_ERR);
7884 
7885  if (event != NULL && err == CL_SUCCESS)
7886  *event = tmp;
7887 
7888  return err;
7889  }
7890 
7891 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7892 
7900  const Image& image,
7901  cl_float4 fillColor,
7902  const array<size_type, 3>& origin,
7903  const array<size_type, 3>& region,
7904  const vector<Event>* events = NULL,
7905  Event* event = NULL) const
7906  {
7907  cl_event tmp;
7908  cl_int err = detail::errHandler(
7909  ::clEnqueueFillImage(
7910  object_,
7911  image(),
7912  static_cast<void*>(&fillColor),
7913  origin.data(),
7914  region.data(),
7915  (events != NULL) ? (cl_uint) events->size() : 0,
7916  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7917  (event != NULL) ? &tmp : NULL),
7918  __ENQUEUE_FILL_IMAGE_ERR);
7919 
7920  if (event != NULL && err == CL_SUCCESS)
7921  *event = tmp;
7922 
7923  return err;
7924  }
7925 
7934  const Image& image,
7935  cl_int4 fillColor,
7936  const array<size_type, 3>& origin,
7937  const array<size_type, 3>& region,
7938  const vector<Event>* events = NULL,
7939  Event* event = NULL) const
7940  {
7941  cl_event tmp;
7942  cl_int err = detail::errHandler(
7943  ::clEnqueueFillImage(
7944  object_,
7945  image(),
7946  static_cast<void*>(&fillColor),
7947  origin.data(),
7948  region.data(),
7949  (events != NULL) ? (cl_uint) events->size() : 0,
7950  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7951  (event != NULL) ? &tmp : NULL),
7952  __ENQUEUE_FILL_IMAGE_ERR);
7953 
7954  if (event != NULL && err == CL_SUCCESS)
7955  *event = tmp;
7956 
7957  return err;
7958  }
7959 
7968  const Image& image,
7969  cl_uint4 fillColor,
7970  const array<size_type, 3>& origin,
7971  const array<size_type, 3>& region,
7972  const vector<Event>* events = NULL,
7973  Event* event = NULL) const
7974  {
7975  cl_event tmp;
7976  cl_int err = detail::errHandler(
7977  ::clEnqueueFillImage(
7978  object_,
7979  image(),
7980  static_cast<void*>(&fillColor),
7981  origin.data(),
7982  region.data(),
7983  (events != NULL) ? (cl_uint) events->size() : 0,
7984  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7985  (event != NULL) ? &tmp : NULL),
7986  __ENQUEUE_FILL_IMAGE_ERR);
7987 
7988  if (event != NULL && err == CL_SUCCESS)
7989  *event = tmp;
7990 
7991  return err;
7992  }
7993 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
7994 
7995  cl_int enqueueCopyImageToBuffer(
7996  const Image& src,
7997  const Buffer& dst,
7998  const array<size_type, 3>& src_origin,
7999  const array<size_type, 3>& region,
8000  size_type dst_offset,
8001  const vector<Event>* events = NULL,
8002  Event* event = NULL) const
8003  {
8004  cl_event tmp;
8005  cl_int err = detail::errHandler(
8006  ::clEnqueueCopyImageToBuffer(
8007  object_,
8008  src(),
8009  dst(),
8010  src_origin.data(),
8011  region.data(),
8012  dst_offset,
8013  (events != NULL) ? (cl_uint) events->size() : 0,
8014  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8015  (event != NULL) ? &tmp : NULL),
8016  __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8017 
8018  if (event != NULL && err == CL_SUCCESS)
8019  *event = tmp;
8020 
8021  return err;
8022  }
8023 
8024  cl_int enqueueCopyBufferToImage(
8025  const Buffer& src,
8026  const Image& dst,
8027  size_type src_offset,
8028  const array<size_type, 3>& dst_origin,
8029  const array<size_type, 3>& region,
8030  const vector<Event>* events = NULL,
8031  Event* event = NULL) const
8032  {
8033  cl_event tmp;
8034  cl_int err = detail::errHandler(
8035  ::clEnqueueCopyBufferToImage(
8036  object_,
8037  src(),
8038  dst(),
8039  src_offset,
8040  dst_origin.data(),
8041  region.data(),
8042  (events != NULL) ? (cl_uint) events->size() : 0,
8043  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8044  (event != NULL) ? &tmp : NULL),
8045  __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8046 
8047  if (event != NULL && err == CL_SUCCESS)
8048  *event = tmp;
8049 
8050  return err;
8051  }
8052 
8053  void* enqueueMapBuffer(
8054  const Buffer& buffer,
8055  cl_bool blocking,
8056  cl_map_flags flags,
8057  size_type offset,
8058  size_type size,
8059  const vector<Event>* events = NULL,
8060  Event* event = NULL,
8061  cl_int* err = NULL) const
8062  {
8063  cl_event tmp;
8064  cl_int error;
8065  void * result = ::clEnqueueMapBuffer(
8066  object_, buffer(), blocking, flags, offset, size,
8067  (events != NULL) ? (cl_uint) events->size() : 0,
8068  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8069  (event != NULL) ? &tmp : NULL,
8070  &error);
8071 
8072  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8073  if (err != NULL) {
8074  *err = error;
8075  }
8076  if (event != NULL && error == CL_SUCCESS)
8077  *event = tmp;
8078 
8079  return result;
8080  }
8081 
8082  void* enqueueMapImage(
8083  const Image& buffer,
8084  cl_bool blocking,
8085  cl_map_flags flags,
8086  const array<size_type, 3>& origin,
8087  const array<size_type, 3>& region,
8088  size_type * row_pitch,
8089  size_type * slice_pitch,
8090  const vector<Event>* events = NULL,
8091  Event* event = NULL,
8092  cl_int* err = NULL) const
8093  {
8094  cl_event tmp;
8095  cl_int error;
8096  void * result = ::clEnqueueMapImage(
8097  object_, buffer(), blocking, flags,
8098  origin.data(),
8099  region.data(),
8100  row_pitch, slice_pitch,
8101  (events != NULL) ? (cl_uint) events->size() : 0,
8102  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8103  (event != NULL) ? &tmp : NULL,
8104  &error);
8105 
8106  detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8107  if (err != NULL) {
8108  *err = error;
8109  }
8110  if (event != NULL && error == CL_SUCCESS)
8111  *event = tmp;
8112  return result;
8113  }
8114 
8115 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8116 
8120  template<typename T>
8122  T* ptr,
8123  cl_bool blocking,
8124  cl_map_flags flags,
8125  size_type size,
8126  const vector<Event>* events = NULL,
8127  Event* event = NULL) const
8128  {
8129  cl_event tmp;
8130  cl_int err = detail::errHandler(::clEnqueueSVMMap(
8131  object_, blocking, flags, static_cast<void*>(ptr), size,
8132  (events != NULL) ? (cl_uint)events->size() : 0,
8133  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8134  (event != NULL) ? &tmp : NULL),
8135  __ENQUEUE_MAP_BUFFER_ERR);
8136 
8137  if (event != NULL && err == CL_SUCCESS)
8138  *event = tmp;
8139 
8140  return err;
8141  }
8142 
8143 
8148  template<typename T, class D>
8150  cl::pointer<T, D> &ptr,
8151  cl_bool blocking,
8152  cl_map_flags flags,
8153  size_type size,
8154  const vector<Event>* events = NULL,
8155  Event* event = NULL) const
8156  {
8157  cl_event tmp;
8158  cl_int err = detail::errHandler(::clEnqueueSVMMap(
8159  object_, blocking, flags, static_cast<void*>(ptr.get()), size,
8160  (events != NULL) ? (cl_uint)events->size() : 0,
8161  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8162  (event != NULL) ? &tmp : NULL),
8163  __ENQUEUE_MAP_BUFFER_ERR);
8164 
8165  if (event != NULL && err == CL_SUCCESS)
8166  *event = tmp;
8167 
8168  return err;
8169  }
8170 
8175  template<typename T, class Alloc>
8177  cl::vector<T, Alloc> &container,
8178  cl_bool blocking,
8179  cl_map_flags flags,
8180  const vector<Event>* events = NULL,
8181  Event* event = NULL) const
8182  {
8183  cl_event tmp;
8184  cl_int err = detail::errHandler(::clEnqueueSVMMap(
8185  object_, blocking, flags, static_cast<void*>(container.data()), container.size()*sizeof(T),
8186  (events != NULL) ? (cl_uint)events->size() : 0,
8187  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8188  (event != NULL) ? &tmp : NULL),
8189  __ENQUEUE_MAP_BUFFER_ERR);
8190 
8191  if (event != NULL && err == CL_SUCCESS)
8192  *event = tmp;
8193 
8194  return err;
8195  }
8196 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8197 
8198  cl_int enqueueUnmapMemObject(
8199  const Memory& memory,
8200  void* mapped_ptr,
8201  const vector<Event>* events = NULL,
8202  Event* event = NULL) const
8203  {
8204  cl_event tmp;
8205  cl_int err = detail::errHandler(
8206  ::clEnqueueUnmapMemObject(
8207  object_, memory(), mapped_ptr,
8208  (events != NULL) ? (cl_uint) events->size() : 0,
8209  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8210  (event != NULL) ? &tmp : NULL),
8211  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8212 
8213  if (event != NULL && err == CL_SUCCESS)
8214  *event = tmp;
8215 
8216  return err;
8217  }
8218 
8219 
8220 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8221 
8225  template<typename T>
8227  T* ptr,
8228  const vector<Event>* events = NULL,
8229  Event* event = NULL) const
8230  {
8231  cl_event tmp;
8232  cl_int err = detail::errHandler(
8233  ::clEnqueueSVMUnmap(
8234  object_, static_cast<void*>(ptr),
8235  (events != NULL) ? (cl_uint)events->size() : 0,
8236  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8237  (event != NULL) ? &tmp : NULL),
8238  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8239 
8240  if (event != NULL && err == CL_SUCCESS)
8241  *event = tmp;
8242 
8243  return err;
8244  }
8245 
8250  template<typename T, class D>
8252  cl::pointer<T, D> &ptr,
8253  const vector<Event>* events = NULL,
8254  Event* event = NULL) const
8255  {
8256  cl_event tmp;
8257  cl_int err = detail::errHandler(
8258  ::clEnqueueSVMUnmap(
8259  object_, static_cast<void*>(ptr.get()),
8260  (events != NULL) ? (cl_uint)events->size() : 0,
8261  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8262  (event != NULL) ? &tmp : NULL),
8263  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8264 
8265  if (event != NULL && err == CL_SUCCESS)
8266  *event = tmp;
8267 
8268  return err;
8269  }
8270 
8275  template<typename T, class Alloc>
8277  cl::vector<T, Alloc> &container,
8278  const vector<Event>* events = NULL,
8279  Event* event = NULL) const
8280  {
8281  cl_event tmp;
8282  cl_int err = detail::errHandler(
8283  ::clEnqueueSVMUnmap(
8284  object_, static_cast<void*>(container.data()),
8285  (events != NULL) ? (cl_uint)events->size() : 0,
8286  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8287  (event != NULL) ? &tmp : NULL),
8288  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8289 
8290  if (event != NULL && err == CL_SUCCESS)
8291  *event = tmp;
8292 
8293  return err;
8294  }
8295 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8296 
8297 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8298 
8310  const vector<Event> *events = 0,
8311  Event *event = 0) const
8312  {
8313  cl_event tmp;
8314  cl_int err = detail::errHandler(
8315  ::clEnqueueMarkerWithWaitList(
8316  object_,
8317  (events != NULL) ? (cl_uint) events->size() : 0,
8318  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8319  (event != NULL) ? &tmp : NULL),
8320  __ENQUEUE_MARKER_WAIT_LIST_ERR);
8321 
8322  if (event != NULL && err == CL_SUCCESS)
8323  *event = tmp;
8324 
8325  return err;
8326  }
8327 
8340  const vector<Event> *events = 0,
8341  Event *event = 0) const
8342  {
8343  cl_event tmp;
8344  cl_int err = detail::errHandler(
8345  ::clEnqueueBarrierWithWaitList(
8346  object_,
8347  (events != NULL) ? (cl_uint) events->size() : 0,
8348  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8349  (event != NULL) ? &tmp : NULL),
8350  __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8351 
8352  if (event != NULL && err == CL_SUCCESS)
8353  *event = tmp;
8354 
8355  return err;
8356  }
8357 
8363  const vector<Memory> &memObjects,
8364  cl_mem_migration_flags flags,
8365  const vector<Event>* events = NULL,
8366  Event* event = NULL
8367  ) const
8368  {
8369  cl_event tmp;
8370 
8371  vector<cl_mem> localMemObjects(memObjects.size());
8372 
8373  for( int i = 0; i < (int)memObjects.size(); ++i ) {
8374  localMemObjects[i] = memObjects[i]();
8375  }
8376 
8377  cl_int err = detail::errHandler(
8378  ::clEnqueueMigrateMemObjects(
8379  object_,
8380  (cl_uint)memObjects.size(),
8381  localMemObjects.data(),
8382  flags,
8383  (events != NULL) ? (cl_uint) events->size() : 0,
8384  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8385  (event != NULL) ? &tmp : NULL),
8386  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8387 
8388  if (event != NULL && err == CL_SUCCESS)
8389  *event = tmp;
8390 
8391  return err;
8392  }
8393 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
8394 
8395 
8396 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8397 
8402  template<typename T>
8404  const cl::vector<T*> &svmRawPointers,
8405  const cl::vector<size_type> &sizes,
8406  cl_mem_migration_flags flags = 0,
8407  const vector<Event>* events = NULL,
8408  Event* event = NULL) const
8409  {
8410  cl_event tmp;
8411  cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8412  object_,
8413  svmRawPointers.size(), static_cast<void**>(svmRawPointers.data()),
8414  sizes.data(), // array of sizes not passed
8415  flags,
8416  (events != NULL) ? (cl_uint)events->size() : 0,
8417  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8418  (event != NULL) ? &tmp : NULL),
8419  __ENQUEUE_MIGRATE_SVM_ERR);
8420 
8421  if (event != NULL && err == CL_SUCCESS)
8422  *event = tmp;
8423 
8424  return err;
8425  }
8426 
8431  template<typename T>
8433  const cl::vector<T*> &svmRawPointers,
8434  cl_mem_migration_flags flags = 0,
8435  const vector<Event>* events = NULL,
8436  Event* event = NULL) const
8437  {
8438  return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8439  }
8440 
8441 
8447  template<typename T, class D>
8449  const cl::vector<cl::pointer<T, D>> &svmPointers,
8450  const cl::vector<size_type> &sizes,
8451  cl_mem_migration_flags flags = 0,
8452  const vector<Event>* events = NULL,
8453  Event* event = NULL) const
8454  {
8455  cl::vector<void*> svmRawPointers;
8456  svmRawPointers.reserve(svmPointers.size());
8457  for (auto p : svmPointers) {
8458  svmRawPointers.push_back(static_cast<void*>(p.get()));
8459  }
8460 
8461  return enqueueMigrateSVM(svmRawPointers, sizes, flags, events, event);
8462  }
8463 
8464 
8469  template<typename T, class D>
8471  const cl::vector<cl::pointer<T, D>> &svmPointers,
8472  cl_mem_migration_flags flags = 0,
8473  const vector<Event>* events = NULL,
8474  Event* event = NULL) const
8475  {
8476  return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8477  }
8478 
8484  template<typename T, class Alloc>
8486  const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8487  const cl::vector<size_type> &sizes,
8488  cl_mem_migration_flags flags = 0,
8489  const vector<Event>* events = NULL,
8490  Event* event = NULL) const
8491  {
8492  cl::vector<void*> svmRawPointers;
8493  svmRawPointers.reserve(svmContainers.size());
8494  for (auto p : svmContainers) {
8495  svmRawPointers.push_back(static_cast<void*>(p.data()));
8496  }
8497 
8498  return enqueueMigrateSVM(svmRawPointers, sizes, flags, events, event);
8499  }
8500 
8505  template<typename T, class Alloc>
8507  const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8508  cl_mem_migration_flags flags = 0,
8509  const vector<Event>* events = NULL,
8510  Event* event = NULL) const
8511  {
8512  return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8513  }
8514 
8515 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8516 
8517  cl_int enqueueNDRangeKernel(
8518  const Kernel& kernel,
8519  const NDRange& offset,
8520  const NDRange& global,
8521  const NDRange& local = NullRange,
8522  const vector<Event>* events = NULL,
8523  Event* event = NULL) const
8524  {
8525  cl_event tmp;
8526  cl_int err = detail::errHandler(
8527  ::clEnqueueNDRangeKernel(
8528  object_, kernel(), (cl_uint) global.dimensions(),
8529  offset.dimensions() != 0 ? (const size_type*) offset : NULL,
8530  (const size_type*) global,
8531  local.dimensions() != 0 ? (const size_type*) local : NULL,
8532  (events != NULL) ? (cl_uint) events->size() : 0,
8533  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8534  (event != NULL) ? &tmp : NULL),
8535  __ENQUEUE_NDRANGE_KERNEL_ERR);
8536 
8537  if (event != NULL && err == CL_SUCCESS)
8538  *event = tmp;
8539 
8540  return err;
8541  }
8542 
8543 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8544  CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8545  const Kernel& kernel,
8546  const vector<Event>* events = NULL,
8547  Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
8548  {
8549  cl_event tmp;
8550  cl_int err = detail::errHandler(
8551  ::clEnqueueTask(
8552  object_, kernel(),
8553  (events != NULL) ? (cl_uint) events->size() : 0,
8554  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8555  (event != NULL) ? &tmp : NULL),
8556  __ENQUEUE_TASK_ERR);
8557 
8558  if (event != NULL && err == CL_SUCCESS)
8559  *event = tmp;
8560 
8561  return err;
8562  }
8563 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8564 
8565  cl_int enqueueNativeKernel(
8566  void (CL_CALLBACK *userFptr)(void *),
8567  std::pair<void*, size_type> args,
8568  const vector<Memory>* mem_objects = NULL,
8569  const vector<const void*>* mem_locs = NULL,
8570  const vector<Event>* events = NULL,
8571  Event* event = NULL) const
8572  {
8573  size_type elements = 0;
8574  if (mem_objects != NULL) {
8575  elements = mem_objects->size();
8576  }
8577  vector<cl_mem> mems(elements);
8578  for (unsigned int i = 0; i < elements; i++) {
8579  mems[i] = ((*mem_objects)[i])();
8580  }
8581 
8582  cl_event tmp;
8583  cl_int err = detail::errHandler(
8584  ::clEnqueueNativeKernel(
8585  object_, userFptr, args.first, args.second,
8586  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8587  mems.data(),
8588  (mem_locs != NULL && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : NULL,
8589  (events != NULL) ? (cl_uint) events->size() : 0,
8590  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8591  (event != NULL) ? &tmp : NULL),
8592  __ENQUEUE_NATIVE_KERNEL);
8593 
8594  if (event != NULL && err == CL_SUCCESS)
8595  *event = tmp;
8596 
8597  return err;
8598  }
8599 
8603 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8604  CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8605  cl_int enqueueMarker(Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8606  {
8607  cl_event tmp;
8608  cl_int err = detail::errHandler(
8609  ::clEnqueueMarker(
8610  object_,
8611  (event != NULL) ? &tmp : NULL),
8612  __ENQUEUE_MARKER_ERR);
8613 
8614  if (event != NULL && err == CL_SUCCESS)
8615  *event = tmp;
8616 
8617  return err;
8618  }
8619 
8620  CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8621  cl_int enqueueWaitForEvents(const vector<Event>& events) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8622  {
8623  return detail::errHandler(
8624  ::clEnqueueWaitForEvents(
8625  object_,
8626  (cl_uint) events.size(),
8627  events.size() > 0 ? (const cl_event*) &events.front() : NULL),
8628  __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8629  }
8630 #endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8631 
8632  cl_int enqueueAcquireGLObjects(
8633  const vector<Memory>* mem_objects = NULL,
8634  const vector<Event>* events = NULL,
8635  Event* event = NULL) const
8636  {
8637  cl_event tmp;
8638  cl_int err = detail::errHandler(
8639  ::clEnqueueAcquireGLObjects(
8640  object_,
8641  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8642  (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8643  (events != NULL) ? (cl_uint) events->size() : 0,
8644  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8645  (event != NULL) ? &tmp : NULL),
8646  __ENQUEUE_ACQUIRE_GL_ERR);
8647 
8648  if (event != NULL && err == CL_SUCCESS)
8649  *event = tmp;
8650 
8651  return err;
8652  }
8653 
8654  cl_int enqueueReleaseGLObjects(
8655  const vector<Memory>* mem_objects = NULL,
8656  const vector<Event>* events = NULL,
8657  Event* event = NULL) const
8658  {
8659  cl_event tmp;
8660  cl_int err = detail::errHandler(
8661  ::clEnqueueReleaseGLObjects(
8662  object_,
8663  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8664  (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8665  (events != NULL) ? (cl_uint) events->size() : 0,
8666  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8667  (event != NULL) ? &tmp : NULL),
8668  __ENQUEUE_RELEASE_GL_ERR);
8669 
8670  if (event != NULL && err == CL_SUCCESS)
8671  *event = tmp;
8672 
8673  return err;
8674  }
8675 
8676 #if defined (CL_HPP_USE_DX_INTEROP)
8677 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8678  cl_command_queue command_queue, cl_uint num_objects,
8679  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8680  const cl_event* event_wait_list, cl_event* event);
8681 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8682  cl_command_queue command_queue, cl_uint num_objects,
8683  const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8684  const cl_event* event_wait_list, cl_event* event);
8685 
8686  cl_int enqueueAcquireD3D10Objects(
8687  const vector<Memory>* mem_objects = NULL,
8688  const vector<Event>* events = NULL,
8689  Event* event = NULL) const
8690  {
8691  static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8692 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8693  cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8694  cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8695  cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8696  CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8697 #endif
8698 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8699  CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8700 #endif
8701 
8702  cl_event tmp;
8703  cl_int err = detail::errHandler(
8704  pfn_clEnqueueAcquireD3D10ObjectsKHR(
8705  object_,
8706  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8707  (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8708  (events != NULL) ? (cl_uint) events->size() : 0,
8709  (events != NULL) ? (cl_event*) &events->front() : NULL,
8710  (event != NULL) ? &tmp : NULL),
8711  __ENQUEUE_ACQUIRE_GL_ERR);
8712 
8713  if (event != NULL && err == CL_SUCCESS)
8714  *event = tmp;
8715 
8716  return err;
8717  }
8718 
8719  cl_int enqueueReleaseD3D10Objects(
8720  const vector<Memory>* mem_objects = NULL,
8721  const vector<Event>* events = NULL,
8722  Event* event = NULL) const
8723  {
8724  static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8725 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8726  cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8727  cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8728  cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8729  CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8730 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
8731 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8732  CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8733 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
8734 
8735  cl_event tmp;
8736  cl_int err = detail::errHandler(
8737  pfn_clEnqueueReleaseD3D10ObjectsKHR(
8738  object_,
8739  (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8740  (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8741  (events != NULL) ? (cl_uint) events->size() : 0,
8742  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8743  (event != NULL) ? &tmp : NULL),
8744  __ENQUEUE_RELEASE_GL_ERR);
8745 
8746  if (event != NULL && err == CL_SUCCESS)
8747  *event = tmp;
8748 
8749  return err;
8750  }
8751 #endif
8752 
8756 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8757  CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8758  cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8759  {
8760  return detail::errHandler(
8761  ::clEnqueueBarrier(object_),
8762  __ENQUEUE_BARRIER_ERR);
8763  }
8764 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
8765 
8766  cl_int flush() const
8767  {
8768  return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8769  }
8770 
8771  cl_int finish() const
8772  {
8773  return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8774  }
8775 }; // CommandQueue
8776 
8777 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8778 CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8779 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8780 
8781 
8782 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8783 enum class DeviceQueueProperties : cl_command_queue_properties
8784 {
8785  None = 0,
8786  Profiling = CL_QUEUE_PROFILING_ENABLE,
8787 };
8788 
8789 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8790 {
8791  return static_cast<DeviceQueueProperties>(static_cast<cl_command_queue_properties>(lhs) | static_cast<cl_command_queue_properties>(rhs));
8792 }
8793 
8797 class DeviceCommandQueue : public detail::Wrapper<cl_command_queue>
8798 {
8799 public:
8800 
8805 
8809  DeviceCommandQueue(DeviceQueueProperties properties, cl_int* err = NULL)
8810  {
8811  cl_int error;
8814 
8815  cl_command_queue_properties mergedProperties =
8816  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | static_cast<cl_command_queue_properties>(properties);
8817 
8818  cl_queue_properties queue_properties[] = {
8819  CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8820  object_ = ::clCreateCommandQueueWithProperties(
8821  context(), device(), queue_properties, &error);
8822 
8823  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8824  if (err != NULL) {
8825  *err = error;
8826  }
8827  }
8828 
8833  const Context& context,
8834  const Device& device,
8835  DeviceQueueProperties properties = DeviceQueueProperties::None,
8836  cl_int* err = NULL)
8837  {
8838  cl_int error;
8839 
8840  cl_command_queue_properties mergedProperties =
8841  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | static_cast<cl_command_queue_properties>(properties);
8842  cl_queue_properties queue_properties[] = {
8843  CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8844  object_ = ::clCreateCommandQueueWithProperties(
8845  context(), device(), queue_properties, &error);
8846 
8847  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8848  if (err != NULL) {
8849  *err = error;
8850  }
8851  }
8852 
8857  const Context& context,
8858  const Device& device,
8859  cl_uint queueSize,
8860  DeviceQueueProperties properties = DeviceQueueProperties::None,
8861  cl_int* err = NULL)
8862  {
8863  cl_int error;
8864 
8865  cl_command_queue_properties mergedProperties =
8866  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | static_cast<cl_command_queue_properties>(properties);
8867  cl_queue_properties queue_properties[] = {
8868  CL_QUEUE_PROPERTIES, mergedProperties,
8869  CL_QUEUE_SIZE, queueSize,
8870  0 };
8871  object_ = ::clCreateCommandQueueWithProperties(
8872  context(), device(), queue_properties, &error);
8873 
8874  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8875  if (err != NULL) {
8876  *err = error;
8877  }
8878  }
8879 
8886  explicit DeviceCommandQueue(const cl_command_queue& commandQueue, bool retainObject = false) :
8887  detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8888 
8889  DeviceCommandQueue& operator = (const cl_command_queue& rhs)
8890  {
8892  return *this;
8893  }
8894 
8898  DeviceCommandQueue(const DeviceCommandQueue& queue) : detail::Wrapper<cl_type>(queue) {}
8899 
8903  DeviceCommandQueue& operator = (const DeviceCommandQueue &queue)
8904  {
8906  return *this;
8907  }
8908 
8912  DeviceCommandQueue(DeviceCommandQueue&& queue) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(queue)) {}
8913 
8918  {
8919  detail::Wrapper<cl_type>::operator=(std::move(queue));
8920  return *this;
8921  }
8922 
8923  template <typename T>
8924  cl_int getInfo(cl_command_queue_info name, T* param) const
8925  {
8926  return detail::errHandler(
8927  detail::getInfo(
8928  &::clGetCommandQueueInfo, object_, name, param),
8929  __GET_COMMAND_QUEUE_INFO_ERR);
8930  }
8931 
8932  template <cl_command_queue_info name> typename
8933  detail::param_traits<detail::cl_command_queue_info, name>::param_type
8934  getInfo(cl_int* err = NULL) const
8935  {
8936  typename detail::param_traits<
8937  detail::cl_command_queue_info, name>::param_type param;
8938  cl_int result = getInfo(name, &param);
8939  if (err != NULL) {
8940  *err = result;
8941  }
8942  return param;
8943  }
8944 
8952  cl_int *err = nullptr)
8953  {
8954  cl_int error;
8957 
8958  cl_command_queue_properties properties =
8959  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8960  cl_queue_properties queue_properties[] = {
8961  CL_QUEUE_PROPERTIES, properties,
8962  0 };
8963  DeviceCommandQueue deviceQueue(
8964  ::clCreateCommandQueueWithProperties(
8965  context(), device(), queue_properties, &error));
8966 
8967  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8968  if (err != NULL) {
8969  *err = error;
8970  }
8971 
8972  return deviceQueue;
8973  }
8974 
8982  const Context &context, const Device &device, cl_int *err = nullptr)
8983  {
8984  cl_int error;
8985 
8986  cl_command_queue_properties properties =
8987  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8988  cl_queue_properties queue_properties[] = {
8989  CL_QUEUE_PROPERTIES, properties,
8990  0 };
8991  DeviceCommandQueue deviceQueue(
8992  ::clCreateCommandQueueWithProperties(
8993  context(), device(), queue_properties, &error));
8994 
8995  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8996  if (err != NULL) {
8997  *err = error;
8998  }
8999 
9000  return deviceQueue;
9001  }
9002 
9010  const Context &context, const Device &device, cl_uint queueSize, cl_int *err = nullptr)
9011  {
9012  cl_int error;
9013 
9014  cl_command_queue_properties properties =
9015  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9016  cl_queue_properties queue_properties[] = {
9017  CL_QUEUE_PROPERTIES, properties,
9018  CL_QUEUE_SIZE, queueSize,
9019  0 };
9020  DeviceCommandQueue deviceQueue(
9021  ::clCreateCommandQueueWithProperties(
9022  context(), device(), queue_properties, &error));
9023 
9024  detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9025  if (err != NULL) {
9026  *err = error;
9027  }
9028 
9029  return deviceQueue;
9030  }
9031 
9032 
9033 
9034 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9035 
9041  static DeviceCommandQueue updateDefault(const Context &context, const Device &device, const DeviceCommandQueue &default_queue, cl_int *err = nullptr)
9042  {
9043  cl_int error;
9044  error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9045 
9046  detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9047  if (err != NULL) {
9048  *err = error;
9049  }
9050  return default_queue;
9051  }
9052 
9056  static DeviceCommandQueue getDefault(const CommandQueue &queue, cl_int * err = NULL)
9057  {
9058  return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9059  }
9060 
9061 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9062 }; // DeviceCommandQueue
9063 
9064 namespace detail
9065 {
9066  // Specialization for device command queue
9067  template <>
9069  {
9070  static size_type size(const cl::DeviceCommandQueue&) { return sizeof(cl_command_queue); }
9071  static const cl_command_queue* ptr(const cl::DeviceCommandQueue& value) { return &(value()); }
9072  };
9073 } // namespace detail
9074 
9075 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9076 
9077 
9078 template< typename IteratorType >
9080  const Context &context,
9081  IteratorType startIterator,
9082  IteratorType endIterator,
9083  bool readOnly,
9084  bool useHostPtr,
9085  cl_int* err)
9086 {
9087  typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9088  cl_int error;
9089 
9090  cl_mem_flags flags = 0;
9091  if( readOnly ) {
9092  flags |= CL_MEM_READ_ONLY;
9093  }
9094  else {
9095  flags |= CL_MEM_READ_WRITE;
9096  }
9097  if( useHostPtr ) {
9098  flags |= CL_MEM_USE_HOST_PTR;
9099  }
9100 
9101  size_type size = sizeof(DataType)*(endIterator - startIterator);
9102 
9103  if( useHostPtr ) {
9104  object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
9105  } else {
9106  object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9107  }
9108 
9109  detail::errHandler(error, __CREATE_BUFFER_ERR);
9110  if (err != NULL) {
9111  *err = error;
9112  }
9113 
9114  if( !useHostPtr ) {
9115  CommandQueue queue(context, 0, &error);
9116  detail::errHandler(error, __CREATE_BUFFER_ERR);
9117  if (err != NULL) {
9118  *err = error;
9119  }
9120 
9121  error = cl::copy(queue, startIterator, endIterator, *this);
9122  detail::errHandler(error, __CREATE_BUFFER_ERR);
9123  if (err != NULL) {
9124  *err = error;
9125  }
9126  }
9127 }
9128 
9129 template< typename IteratorType >
9131  const CommandQueue &queue,
9132  IteratorType startIterator,
9133  IteratorType endIterator,
9134  bool readOnly,
9135  bool useHostPtr,
9136  cl_int* err)
9137 {
9138  typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9139  cl_int error;
9140 
9141  cl_mem_flags flags = 0;
9142  if (readOnly) {
9143  flags |= CL_MEM_READ_ONLY;
9144  }
9145  else {
9146  flags |= CL_MEM_READ_WRITE;
9147  }
9148  if (useHostPtr) {
9149  flags |= CL_MEM_USE_HOST_PTR;
9150  }
9151 
9152  size_type size = sizeof(DataType)*(endIterator - startIterator);
9153 
9154  Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9155 
9156  if (useHostPtr) {
9157  object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
9158  }
9159  else {
9160  object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9161  }
9162 
9163  detail::errHandler(error, __CREATE_BUFFER_ERR);
9164  if (err != NULL) {
9165  *err = error;
9166  }
9167 
9168  if (!useHostPtr) {
9169  error = cl::copy(queue, startIterator, endIterator, *this);
9170  detail::errHandler(error, __CREATE_BUFFER_ERR);
9171  if (err != NULL) {
9172  *err = error;
9173  }
9174  }
9175 }
9176 
9177 inline cl_int enqueueReadBuffer(
9178  const Buffer& buffer,
9179  cl_bool blocking,
9180  size_type offset,
9181  size_type size,
9182  void* ptr,
9183  const vector<Event>* events = NULL,
9184  Event* event = NULL)
9185 {
9186  cl_int error;
9187  CommandQueue queue = CommandQueue::getDefault(&error);
9188 
9189  if (error != CL_SUCCESS) {
9190  return error;
9191  }
9192 
9193  return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9194 }
9195 
9196 inline cl_int enqueueWriteBuffer(
9197  const Buffer& buffer,
9198  cl_bool blocking,
9199  size_type offset,
9200  size_type size,
9201  const void* ptr,
9202  const vector<Event>* events = NULL,
9203  Event* event = NULL)
9204 {
9205  cl_int error;
9206  CommandQueue queue = CommandQueue::getDefault(&error);
9207 
9208  if (error != CL_SUCCESS) {
9209  return error;
9210  }
9211 
9212  return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9213 }
9214 
9215 inline void* enqueueMapBuffer(
9216  const Buffer& buffer,
9217  cl_bool blocking,
9218  cl_map_flags flags,
9219  size_type offset,
9220  size_type size,
9221  const vector<Event>* events = NULL,
9222  Event* event = NULL,
9223  cl_int* err = NULL)
9224 {
9225  cl_int error;
9226  CommandQueue queue = CommandQueue::getDefault(&error);
9227  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9228  if (err != NULL) {
9229  *err = error;
9230  }
9231 
9232  void * result = ::clEnqueueMapBuffer(
9233  queue(), buffer(), blocking, flags, offset, size,
9234  (events != NULL) ? (cl_uint) events->size() : 0,
9235  (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9236  (cl_event*) event,
9237  &error);
9238 
9239  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9240  if (err != NULL) {
9241  *err = error;
9242  }
9243  return result;
9244 }
9245 
9246 
9247 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9248 
9253 template<typename T>
9254 inline cl_int enqueueMapSVM(
9255  T* ptr,
9256  cl_bool blocking,
9257  cl_map_flags flags,
9258  size_type size,
9259  const vector<Event>* events,
9260  Event* event)
9261 {
9262  cl_int error;
9263  CommandQueue queue = CommandQueue::getDefault(&error);
9264  if (error != CL_SUCCESS) {
9265  return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9266  }
9267 
9268  return queue.enqueueMapSVM(
9269  ptr, blocking, flags, size, events, event);
9270 }
9271 
9277 template<typename T, class D>
9278 inline cl_int enqueueMapSVM(
9279  cl::pointer<T, D> ptr,
9280  cl_bool blocking,
9281  cl_map_flags flags,
9282  size_type size,
9283  const vector<Event>* events = NULL,
9284  Event* event = NULL)
9285 {
9286  cl_int error;
9287  CommandQueue queue = CommandQueue::getDefault(&error);
9288  if (error != CL_SUCCESS) {
9289  return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9290  }
9291 
9292  return queue.enqueueMapSVM(
9293  ptr, blocking, flags, size, events, event);
9294 }
9295 
9301 template<typename T, class Alloc>
9302 inline cl_int enqueueMapSVM(
9303  cl::vector<T, Alloc> container,
9304  cl_bool blocking,
9305  cl_map_flags flags,
9306  const vector<Event>* events = NULL,
9307  Event* event = NULL)
9308 {
9309  cl_int error;
9310  CommandQueue queue = CommandQueue::getDefault(&error);
9311  if (error != CL_SUCCESS) {
9312  return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9313  }
9314 
9315  return queue.enqueueMapSVM(
9316  container, blocking, flags, events, event);
9317 }
9318 
9319 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9320 
9321 inline cl_int enqueueUnmapMemObject(
9322  const Memory& memory,
9323  void* mapped_ptr,
9324  const vector<Event>* events = NULL,
9325  Event* event = NULL)
9326 {
9327  cl_int error;
9328  CommandQueue queue = CommandQueue::getDefault(&error);
9329  detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9330  if (error != CL_SUCCESS) {
9331  return error;
9332  }
9333 
9334  cl_event tmp;
9335  cl_int err = detail::errHandler(
9336  ::clEnqueueUnmapMemObject(
9337  queue(), memory(), mapped_ptr,
9338  (events != NULL) ? (cl_uint)events->size() : 0,
9339  (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9340  (event != NULL) ? &tmp : NULL),
9341  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9342 
9343  if (event != NULL && err == CL_SUCCESS)
9344  *event = tmp;
9345 
9346  return err;
9347 }
9348 
9349 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9350 
9355 template<typename T>
9356 inline cl_int enqueueUnmapSVM(
9357  T* ptr,
9358  const vector<Event>* events = NULL,
9359  Event* event = NULL)
9360 {
9361  cl_int error;
9362  CommandQueue queue = CommandQueue::getDefault(&error);
9363  if (error != CL_SUCCESS) {
9364  return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9365  }
9366 
9367  return detail::errHandler(queue.enqueueUnmapSVM(ptr, events, event),
9368  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9369 
9370 }
9371 
9377 template<typename T, class D>
9378 inline cl_int enqueueUnmapSVM(
9379  cl::pointer<T, D> &ptr,
9380  const vector<Event>* events = NULL,
9381  Event* event = NULL)
9382 {
9383  cl_int error;
9384  CommandQueue queue = CommandQueue::getDefault(&error);
9385  if (error != CL_SUCCESS) {
9386  return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9387  }
9388 
9389  return detail::errHandler(queue.enqueueUnmapSVM(ptr, events, event),
9390  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9391 }
9392 
9398 template<typename T, class Alloc>
9399 inline cl_int enqueueUnmapSVM(
9400  cl::vector<T, Alloc> &container,
9401  const vector<Event>* events = NULL,
9402  Event* event = NULL)
9403 {
9404  cl_int error;
9405  CommandQueue queue = CommandQueue::getDefault(&error);
9406  if (error != CL_SUCCESS) {
9407  return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9408  }
9409 
9410  return detail::errHandler(queue.enqueueUnmapSVM(container, events, event),
9411  __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9412 }
9413 
9414 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9415 
9416 inline cl_int enqueueCopyBuffer(
9417  const Buffer& src,
9418  const Buffer& dst,
9419  size_type src_offset,
9420  size_type dst_offset,
9421  size_type size,
9422  const vector<Event>* events = NULL,
9423  Event* event = NULL)
9424 {
9425  cl_int error;
9426  CommandQueue queue = CommandQueue::getDefault(&error);
9427 
9428  if (error != CL_SUCCESS) {
9429  return error;
9430  }
9431 
9432  return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9433 }
9434 
9440 template< typename IteratorType >
9441 inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
9442 {
9443  cl_int error;
9444  CommandQueue queue = CommandQueue::getDefault(&error);
9445  if (error != CL_SUCCESS)
9446  return error;
9447 
9448  return cl::copy(queue, startIterator, endIterator, buffer);
9449 }
9450 
9456 template< typename IteratorType >
9457 inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9458 {
9459  cl_int error;
9460  CommandQueue queue = CommandQueue::getDefault(&error);
9461  if (error != CL_SUCCESS)
9462  return error;
9463 
9464  return cl::copy(queue, buffer, startIterator, endIterator);
9465 }
9466 
9472 template< typename IteratorType >
9473 inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
9474 {
9475  typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9476  cl_int error;
9477 
9478  size_type length = endIterator-startIterator;
9479  size_type byteLength = length*sizeof(DataType);
9480 
9481  DataType *pointer =
9482  static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9483  // if exceptions enabled, enqueueMapBuffer will throw
9484  if( error != CL_SUCCESS ) {
9485  return error;
9486  }
9487 #if defined(_MSC_VER)
9488  std::copy(
9489  startIterator,
9490  endIterator,
9491  stdext::checked_array_iterator<DataType*>(
9492  pointer, length));
9493 #else
9494  std::copy(startIterator, endIterator, pointer);
9495 #endif
9496  Event endEvent;
9497  error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9498  // if exceptions enabled, enqueueUnmapMemObject will throw
9499  if( error != CL_SUCCESS ) {
9500  return error;
9501  }
9502  endEvent.wait();
9503  return CL_SUCCESS;
9504 }
9505 
9511 template< typename IteratorType >
9512 inline cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9513 {
9514  typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9515  cl_int error;
9516 
9517  size_type length = endIterator-startIterator;
9518  size_type byteLength = length*sizeof(DataType);
9519 
9520  DataType *pointer =
9521  static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9522  // if exceptions enabled, enqueueMapBuffer will throw
9523  if( error != CL_SUCCESS ) {
9524  return error;
9525  }
9526  std::copy(pointer, pointer + length, startIterator);
9527  Event endEvent;
9528  error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9529  // if exceptions enabled, enqueueUnmapMemObject will throw
9530  if( error != CL_SUCCESS ) {
9531  return error;
9532  }
9533  endEvent.wait();
9534  return CL_SUCCESS;
9535 }
9536 
9537 
9538 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9539 
9542 template<typename T, class Alloc>
9543 inline cl_int mapSVM(cl::vector<T, Alloc> &container)
9544 {
9545  return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9546 }
9547 
9551 template<typename T, class Alloc>
9552 inline cl_int unmapSVM(cl::vector<T, Alloc> &container)
9553 {
9554  return enqueueUnmapSVM(container);
9555 }
9556 
9557 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9558 
9559 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
9560 inline cl_int enqueueReadBufferRect(
9561  const Buffer& buffer,
9562  cl_bool blocking,
9563  const array<size_type, 3>& buffer_offset,
9564  const array<size_type, 3>& host_offset,
9565  const array<size_type, 3>& region,
9566  size_type buffer_row_pitch,
9567  size_type buffer_slice_pitch,
9568  size_type host_row_pitch,
9569  size_type host_slice_pitch,
9570  void *ptr,
9571  const vector<Event>* events = NULL,
9572  Event* event = NULL)
9573 {
9574  cl_int error;
9575  CommandQueue queue = CommandQueue::getDefault(&error);
9576 
9577  if (error != CL_SUCCESS) {
9578  return error;
9579  }
9580 
9581  return queue.enqueueReadBufferRect(
9582  buffer,
9583  blocking,
9584  buffer_offset,
9585  host_offset,
9586  region,
9587  buffer_row_pitch,
9588  buffer_slice_pitch,
9589  host_row_pitch,
9590  host_slice_pitch,
9591  ptr,
9592  events,
9593  event);
9594 }
9595 
9596 inline cl_int enqueueWriteBufferRect(
9597  const Buffer& buffer,
9598  cl_bool blocking,
9599  const array<size_type, 3>& buffer_offset,
9600  const array<size_type, 3>& host_offset,
9601  const array<size_type, 3>& region,
9602  size_type buffer_row_pitch,
9603  size_type buffer_slice_pitch,
9604  size_type host_row_pitch,
9605  size_type host_slice_pitch,
9606  const void *ptr,
9607  const vector<Event>* events = NULL,
9608  Event* event = NULL)
9609 {
9610  cl_int error;
9611  CommandQueue queue = CommandQueue::getDefault(&error);
9612 
9613  if (error != CL_SUCCESS) {
9614  return error;
9615  }
9616 
9617  return queue.enqueueWriteBufferRect(
9618  buffer,
9619  blocking,
9620  buffer_offset,
9621  host_offset,
9622  region,
9623  buffer_row_pitch,
9624  buffer_slice_pitch,
9625  host_row_pitch,
9626  host_slice_pitch,
9627  ptr,
9628  events,
9629  event);
9630 }
9631 
9632 inline cl_int enqueueCopyBufferRect(
9633  const Buffer& src,
9634  const Buffer& dst,
9635  const array<size_type, 3>& src_origin,
9636  const array<size_type, 3>& dst_origin,
9637  const array<size_type, 3>& region,
9638  size_type src_row_pitch,
9639  size_type src_slice_pitch,
9640  size_type dst_row_pitch,
9641  size_type dst_slice_pitch,
9642  const vector<Event>* events = NULL,
9643  Event* event = NULL)
9644 {
9645  cl_int error;
9646  CommandQueue queue = CommandQueue::getDefault(&error);
9647 
9648  if (error != CL_SUCCESS) {
9649  return error;
9650  }
9651 
9652  return queue.enqueueCopyBufferRect(
9653  src,
9654  dst,
9655  src_origin,
9656  dst_origin,
9657  region,
9658  src_row_pitch,
9659  src_slice_pitch,
9660  dst_row_pitch,
9661  dst_slice_pitch,
9662  events,
9663  event);
9664 }
9665 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
9666 
9667 inline cl_int enqueueReadImage(
9668  const Image& image,
9669  cl_bool blocking,
9670  const array<size_type, 3>& origin,
9671  const array<size_type, 3>& region,
9672  size_type row_pitch,
9673  size_type slice_pitch,
9674  void* ptr,
9675  const vector<Event>* events = NULL,
9676  Event* event = NULL)
9677 {
9678  cl_int error;
9679  CommandQueue queue = CommandQueue::getDefault(&error);
9680 
9681  if (error != CL_SUCCESS) {
9682  return error;
9683  }
9684 
9685  return queue.enqueueReadImage(
9686  image,
9687  blocking,
9688  origin,
9689  region,
9690  row_pitch,
9691  slice_pitch,
9692  ptr,
9693  events,
9694  event);
9695 }
9696 
9697 inline cl_int enqueueWriteImage(
9698  const Image& image,
9699  cl_bool blocking,
9700  const array<size_type, 3>& origin,
9701  const array<size_type, 3>& region,
9702  size_type row_pitch,
9703  size_type slice_pitch,
9704  const void* ptr,
9705  const vector<Event>* events = NULL,
9706  Event* event = NULL)
9707 {
9708  cl_int error;
9709  CommandQueue queue = CommandQueue::getDefault(&error);
9710 
9711  if (error != CL_SUCCESS) {
9712  return error;
9713  }
9714 
9715  return queue.enqueueWriteImage(
9716  image,
9717  blocking,
9718  origin,
9719  region,
9720  row_pitch,
9721  slice_pitch,
9722  ptr,
9723  events,
9724  event);
9725 }
9726 
9727 inline cl_int enqueueCopyImage(
9728  const Image& src,
9729  const Image& dst,
9730  const array<size_type, 3>& src_origin,
9731  const array<size_type, 3>& dst_origin,
9732  const array<size_type, 3>& region,
9733  const vector<Event>* events = NULL,
9734  Event* event = NULL)
9735 {
9736  cl_int error;
9737  CommandQueue queue = CommandQueue::getDefault(&error);
9738 
9739  if (error != CL_SUCCESS) {
9740  return error;
9741  }
9742 
9743  return queue.enqueueCopyImage(
9744  src,
9745  dst,
9746  src_origin,
9747  dst_origin,
9748  region,
9749  events,
9750  event);
9751 }
9752 
9753 inline cl_int enqueueCopyImageToBuffer(
9754  const Image& src,
9755  const Buffer& dst,
9756  const array<size_type, 3>& src_origin,
9757  const array<size_type, 3>& region,
9758  size_type dst_offset,
9759  const vector<Event>* events = NULL,
9760  Event* event = NULL)
9761 {
9762  cl_int error;
9763  CommandQueue queue = CommandQueue::getDefault(&error);
9764 
9765  if (error != CL_SUCCESS) {
9766  return error;
9767  }
9768 
9769  return queue.enqueueCopyImageToBuffer(
9770  src,
9771  dst,
9772  src_origin,
9773  region,
9774  dst_offset,
9775  events,
9776  event);
9777 }
9778 
9779 inline cl_int enqueueCopyBufferToImage(
9780  const Buffer& src,
9781  const Image& dst,
9782  size_type src_offset,
9783  const array<size_type, 3>& dst_origin,
9784  const array<size_type, 3>& region,
9785  const vector<Event>* events = NULL,
9786  Event* event = NULL)
9787 {
9788  cl_int error;
9789  CommandQueue queue = CommandQueue::getDefault(&error);
9790 
9791  if (error != CL_SUCCESS) {
9792  return error;
9793  }
9794 
9795  return queue.enqueueCopyBufferToImage(
9796  src,
9797  dst,
9798  src_offset,
9799  dst_origin,
9800  region,
9801  events,
9802  event);
9803 }
9804 
9805 
9806 inline cl_int flush(void)
9807 {
9808  cl_int error;
9809  CommandQueue queue = CommandQueue::getDefault(&error);
9810 
9811  if (error != CL_SUCCESS) {
9812  return error;
9813  }
9814 
9815  return queue.flush();
9816 }
9817 
9818 inline cl_int finish(void)
9819 {
9820  cl_int error;
9821  CommandQueue queue = CommandQueue::getDefault(&error);
9822 
9823  if (error != CL_SUCCESS) {
9824  return error;
9825  }
9826 
9827 
9828  return queue.finish();
9829 }
9830 
9832 {
9833 private:
9834  CommandQueue queue_;
9835  const NDRange offset_;
9836  const NDRange global_;
9837  const NDRange local_;
9838  vector<Event> events_;
9839 
9840  template<typename... Ts>
9841  friend class KernelFunctor;
9842 
9843 public:
9844  EnqueueArgs(NDRange global) :
9845  queue_(CommandQueue::getDefault()),
9846  offset_(NullRange),
9847  global_(global),
9848  local_(NullRange)
9849  {
9850 
9851  }
9852 
9853  EnqueueArgs(NDRange global, NDRange local) :
9854  queue_(CommandQueue::getDefault()),
9855  offset_(NullRange),
9856  global_(global),
9857  local_(local)
9858  {
9859 
9860  }
9861 
9862  EnqueueArgs(NDRange offset, NDRange global, NDRange local) :
9863  queue_(CommandQueue::getDefault()),
9864  offset_(offset),
9865  global_(global),
9866  local_(local)
9867  {
9868 
9869  }
9870 
9871  EnqueueArgs(Event e, NDRange global) :
9872  queue_(CommandQueue::getDefault()),
9873  offset_(NullRange),
9874  global_(global),
9875  local_(NullRange)
9876  {
9877  events_.push_back(e);
9878  }
9879 
9880  EnqueueArgs(Event e, NDRange global, NDRange local) :
9881  queue_(CommandQueue::getDefault()),
9882  offset_(NullRange),
9883  global_(global),
9884  local_(local)
9885  {
9886  events_.push_back(e);
9887  }
9888 
9889  EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) :
9890  queue_(CommandQueue::getDefault()),
9891  offset_(offset),
9892  global_(global),
9893  local_(local)
9894  {
9895  events_.push_back(e);
9896  }
9897 
9898  EnqueueArgs(const vector<Event> &events, NDRange global) :
9899  queue_(CommandQueue::getDefault()),
9900  offset_(NullRange),
9901  global_(global),
9902  local_(NullRange),
9903  events_(events)
9904  {
9905 
9906  }
9907 
9908  EnqueueArgs(const vector<Event> &events, NDRange global, NDRange local) :
9909  queue_(CommandQueue::getDefault()),
9910  offset_(NullRange),
9911  global_(global),
9912  local_(local),
9913  events_(events)
9914  {
9915 
9916  }
9917 
9918  EnqueueArgs(const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
9919  queue_(CommandQueue::getDefault()),
9920  offset_(offset),
9921  global_(global),
9922  local_(local),
9923  events_(events)
9924  {
9925 
9926  }
9927 
9928  EnqueueArgs(CommandQueue &queue, NDRange global) :
9929  queue_(queue),
9930  offset_(NullRange),
9931  global_(global),
9932  local_(NullRange)
9933  {
9934 
9935  }
9936 
9937  EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) :
9938  queue_(queue),
9939  offset_(NullRange),
9940  global_(global),
9941  local_(local)
9942  {
9943 
9944  }
9945 
9946  EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) :
9947  queue_(queue),
9948  offset_(offset),
9949  global_(global),
9950  local_(local)
9951  {
9952 
9953  }
9954 
9955  EnqueueArgs(CommandQueue &queue, Event e, NDRange global) :
9956  queue_(queue),
9957  offset_(NullRange),
9958  global_(global),
9959  local_(NullRange)
9960  {
9961  events_.push_back(e);
9962  }
9963 
9964  EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) :
9965  queue_(queue),
9966  offset_(NullRange),
9967  global_(global),
9968  local_(local)
9969  {
9970  events_.push_back(e);
9971  }
9972 
9973  EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) :
9974  queue_(queue),
9975  offset_(offset),
9976  global_(global),
9977  local_(local)
9978  {
9979  events_.push_back(e);
9980  }
9981 
9982  EnqueueArgs(CommandQueue &queue, const vector<Event> &events, NDRange global) :
9983  queue_(queue),
9984  offset_(NullRange),
9985  global_(global),
9986  local_(NullRange),
9987  events_(events)
9988  {
9989 
9990  }
9991 
9992  EnqueueArgs(CommandQueue &queue, const vector<Event> &events, NDRange global, NDRange local) :
9993  queue_(queue),
9994  offset_(NullRange),
9995  global_(global),
9996  local_(local),
9997  events_(events)
9998  {
9999 
10000  }
10001 
10002  EnqueueArgs(CommandQueue &queue, const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
10003  queue_(queue),
10004  offset_(offset),
10005  global_(global),
10006  local_(local),
10007  events_(events)
10008  {
10009 
10010  }
10011 };
10012 
10013 
10014 //----------------------------------------------------------------------------------------------
10015 
10016 
10021 template<typename... Ts>
10023 {
10024 private:
10025  Kernel kernel_;
10026 
10027  template<int index, typename T0, typename... T1s>
10028  void setArgs(T0&& t0, T1s&&... t1s)
10029  {
10030  kernel_.setArg(index, t0);
10031  setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10032  }
10033 
10034  template<int index, typename T0>
10035  void setArgs(T0&& t0)
10036  {
10037  kernel_.setArg(index, t0);
10038  }
10039 
10040  template<int index>
10041  void setArgs()
10042  {
10043  }
10044 
10045 
10046 public:
10047  KernelFunctor(Kernel kernel) : kernel_(kernel)
10048  {}
10049 
10050  KernelFunctor(
10051  const Program& program,
10052  const string name,
10053  cl_int * err = NULL) :
10054  kernel_(program, name.c_str(), err)
10055  {}
10056 
10059 
10066  const EnqueueArgs& args,
10067  Ts... ts)
10068  {
10069  Event event;
10070  setArgs<0>(std::forward<Ts>(ts)...);
10071 
10072  args.queue_.enqueueNDRangeKernel(
10073  kernel_,
10074  args.offset_,
10075  args.global_,
10076  args.local_,
10077  &args.events_,
10078  &event);
10079 
10080  return event;
10081  }
10082 
10090  const EnqueueArgs& args,
10091  Ts... ts,
10092  cl_int &error)
10093  {
10094  Event event;
10095  setArgs<0>(std::forward<Ts>(ts)...);
10096 
10097  error = args.queue_.enqueueNDRangeKernel(
10098  kernel_,
10099  args.offset_,
10100  args.global_,
10101  args.local_,
10102  &args.events_,
10103  &event);
10104 
10105  return event;
10106  }
10107 
10108 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10109  cl_int setSVMPointers(const vector<void*> &pointerList)
10110  {
10111  return kernel_.setSVMPointers(pointerList);
10112  }
10113 
10114  template<typename T0, typename... T1s>
10115  cl_int setSVMPointers(const T0 &t0, T1s &... ts)
10116  {
10117  return kernel_.setSVMPointers(t0, ts...);
10118  }
10119 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10120 
10121  Kernel getKernel()
10122  {
10123  return kernel_;
10124  }
10125 };
10126 
10127 namespace compatibility {
10132  template<typename... Ts>
10134  {
10135  typedef KernelFunctor<Ts...> FunctorType;
10136 
10137  FunctorType functor_;
10138 
10139  make_kernel(
10140  const Program& program,
10141  const string name,
10142  cl_int * err = NULL) :
10143  functor_(FunctorType(program, name, err))
10144  {}
10145 
10146  make_kernel(
10147  const Kernel kernel) :
10148  functor_(FunctorType(kernel))
10149  {}
10150 
10153 
10155  typedef Event type_(
10156  const EnqueueArgs&,
10157  Ts...);
10158 
10159  Event operator()(
10160  const EnqueueArgs& enqueueArgs,
10161  Ts... args)
10162  {
10163  return functor_(
10164  enqueueArgs, args...);
10165  }
10166  };
10167 } // namespace compatibility
10168 
10169 
10170 //----------------------------------------------------------------------------------------------------------------------
10171 
10172 #undef CL_HPP_ERR_STR_
10173 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10174 #undef __GET_DEVICE_INFO_ERR
10175 #undef __GET_PLATFORM_INFO_ERR
10176 #undef __GET_DEVICE_IDS_ERR
10177 #undef __GET_PLATFORM_IDS_ERR
10178 #undef __GET_CONTEXT_INFO_ERR
10179 #undef __GET_EVENT_INFO_ERR
10180 #undef __GET_EVENT_PROFILE_INFO_ERR
10181 #undef __GET_MEM_OBJECT_INFO_ERR
10182 #undef __GET_IMAGE_INFO_ERR
10183 #undef __GET_SAMPLER_INFO_ERR
10184 #undef __GET_KERNEL_INFO_ERR
10185 #undef __GET_KERNEL_ARG_INFO_ERR
10186 #undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10187 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10188 #undef __GET_PROGRAM_INFO_ERR
10189 #undef __GET_PROGRAM_BUILD_INFO_ERR
10190 #undef __GET_COMMAND_QUEUE_INFO_ERR
10191 #undef __CREATE_CONTEXT_ERR
10192 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
10193 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10194 #undef __CREATE_BUFFER_ERR
10195 #undef __COPY_ERR
10196 #undef __CREATE_SUBBUFFER_ERR
10197 #undef __CREATE_GL_BUFFER_ERR
10198 #undef __CREATE_GL_RENDER_BUFFER_ERR
10199 #undef __GET_GL_OBJECT_INFO_ERR
10200 #undef __CREATE_IMAGE_ERR
10201 #undef __CREATE_GL_TEXTURE_ERR
10202 #undef __IMAGE_DIMENSION_ERR
10203 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10204 #undef __CREATE_USER_EVENT_ERR
10205 #undef __SET_USER_EVENT_STATUS_ERR
10206 #undef __SET_EVENT_CALLBACK_ERR
10207 #undef __WAIT_FOR_EVENTS_ERR
10208 #undef __CREATE_KERNEL_ERR
10209 #undef __SET_KERNEL_ARGS_ERR
10210 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10211 #undef __CREATE_PROGRAM_WITH_IL_ERR
10212 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
10213 #undef __CREATE_PROGRAM_WITH_IL_ERR
10214 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10215 #undef __BUILD_PROGRAM_ERR
10216 #undef __COMPILE_PROGRAM_ERR
10217 #undef __LINK_PROGRAM_ERR
10218 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
10219 #undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10220 #undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10221 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10222 #undef __ENQUEUE_READ_BUFFER_ERR
10223 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
10224 #undef __ENQUEUE_WRITE_BUFFER_ERR
10225 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10226 #undef __ENQEUE_COPY_BUFFER_ERR
10227 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
10228 #undef __ENQUEUE_FILL_BUFFER_ERR
10229 #undef __ENQUEUE_READ_IMAGE_ERR
10230 #undef __ENQUEUE_WRITE_IMAGE_ERR
10231 #undef __ENQUEUE_COPY_IMAGE_ERR
10232 #undef __ENQUEUE_FILL_IMAGE_ERR
10233 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10234 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10235 #undef __ENQUEUE_MAP_BUFFER_ERR
10236 #undef __ENQUEUE_MAP_IMAGE_ERR
10237 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10238 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
10239 #undef __ENQUEUE_NATIVE_KERNEL
10240 #undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10241 #undef __ENQUEUE_MIGRATE_SVM_ERR
10242 #undef __ENQUEUE_ACQUIRE_GL_ERR
10243 #undef __ENQUEUE_RELEASE_GL_ERR
10244 #undef __CREATE_PIPE_ERR
10245 #undef __GET_PIPE_INFO_ERR
10246 #undef __RETAIN_ERR
10247 #undef __RELEASE_ERR
10248 #undef __FLUSH_ERR
10249 #undef __FINISH_ERR
10250 #undef __VECTOR_CAPACITY_ERR
10251 #undef __CREATE_SUB_DEVICES_ERR
10252 #undef __CREATE_SUB_DEVICES_ERR
10253 #undef __ENQUEUE_MARKER_ERR
10254 #undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10255 #undef __ENQUEUE_BARRIER_ERR
10256 #undef __UNLOAD_COMPILER_ERR
10257 #undef __CREATE_GL_TEXTURE_2D_ERR
10258 #undef __CREATE_GL_TEXTURE_3D_ERR
10259 #undef __CREATE_IMAGE2D_ERR
10260 #undef __CREATE_IMAGE3D_ERR
10261 #undef __CREATE_COMMAND_QUEUE_ERR
10262 #undef __ENQUEUE_TASK_ERR
10263 #undef __CREATE_SAMPLER_ERR
10264 #undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10265 #undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10266 #undef __CLONE_KERNEL_ERR
10267 #undef __GET_HOST_TIMER_ERR
10268 #undef __GET_DEVICE_AND_HOST_TIMER_ERR
10269 
10270 #endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS
10271 
10272 // Extensions
10273 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10274 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10275 
10276 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10277 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10278 #endif // CL_HPP_USE_CL_DEVICE_FISSION
10279 
10280 #undef CL_HPP_NOEXCEPT_
10281 #undef CL_HPP_DEFINE_STATIC_MEMBER_
10282 
10283 } // namespace cl
10284 
10285 #endif // CL_HPP_
cl::compatibility::make_kernel::result_type
Event result_type
Return type of the functor.
Definition: opencl.hpp:10152
cl::SVMTraitCoarse
Definition: opencl.hpp:3516
cl::Image2D::Image2D
Image2D(const Context &context, ImageFormat format, const Buffer &sourceBuffer, size_type width, size_type height, size_type row_pitch=0, cl_int *err=nullptr)
Constructs a 2D Image from a buffer.
Definition: opencl.hpp:4781
cl::Image3DGL::Image3DGL
Image3DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:5311
cl::copy
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
Definition: opencl.hpp:9441
cl::Image1DArray::Image1DArray
Image1DArray(const Image1DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4668
cl::CommandQueue::enqueueMigrateSVM
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D >> &svmPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8448
cl::Device::getDeviceAndHostTimer
std::pair< cl_ulong, cl_ulong > getDeviceAndHostTimer(cl_int *error=nullptr)
Definition: opencl.hpp:2254
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
Definition: opencl.hpp:8886
cl::Pipe::getInfo
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Definition: opencl.hpp:5553
cl::CommandQueue::CommandQueue
CommandQueue(const CommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:7518
cl::Device::getInfo
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetDeviceInfo() that returns by value.
Definition: opencl.hpp:2211
cl::Event::getProfilingInfo
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Wrapper for clGetEventProfilingInfo() that returns by value.
Definition: opencl.hpp:3224
cl::SVMAllocator::rebind
Definition: opencl.hpp:3585
cl::Program
Program interface that implements cl_program.
Definition: opencl.hpp:6201
cl::Pipe
Class interface for Pipe Memory Objects.
Definition: opencl.hpp:5445
cl::Sampler
Class interface for cl_sampler.
Definition: opencl.hpp:5586
cl::NDRange::size
size_type size() const
Returns the size of the object in bytes based on the.
Definition: opencl.hpp:5773
cl::BufferGL::BufferGL
BufferGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferGL in a specified context, from a given GL buffer.
Definition: opencl.hpp:4162
cl::BufferRenderGL::BufferRenderGL
BufferRenderGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferRenderGL in a specified context, from a given GL Renderbuffer.
Definition: opencl.hpp:4259
cl::Image2D::Image2D
Image2D(Image2D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4924
cl::Event::setCallback
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=NULL)
Registers a user callback function for a specific command execution status.
Definition: opencl.hpp:3251
cl::Image1D::Image1D
Image1D(Image1D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4509
cl::Platform::unloadCompiler
cl_int unloadCompiler()
Wrapper for clUnloadCompiler().
Definition: opencl.hpp:2711
cl::Kernel::setArg
std::enable_if< std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T argPtr)
setArg overload taking a pointer type
Definition: opencl.hpp:6035
cl::Context::getDefault
static Context getDefault(cl_int *err=NULL)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
Definition: opencl.hpp:3001
cl::Program::Program
Program(const cl_program &program, bool retainObject=false)
Constructor from cl_program - takes ownership.
Definition: opencl.hpp:6588
cl::detail::ReferenceHandler< cl_device_id >::retain
static cl_int retain(cl_device_id device)
Definition: opencl.hpp:1608
cl::Memory::Memory
Memory(const cl_mem &memory, bool retainObject)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:3361
cl::Image1D::Image1D
Image1D(const Image1D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4495
cl::Image2DGL::Image2DGL
Image2DGL(Image2DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5020
cl::CommandQueue::enqueueFillImage
cl_int enqueueFillImage(const Image &image, cl_uint4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > &region, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:7967
cl::CommandQueue::enqueueFillImage
cl_int enqueueFillImage(const Image &image, cl_int4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > &region, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:7933
cl::Buffer::Buffer
Buffer(const Buffer &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:3982
cl::Platform::Platform
Platform()
Default constructor - initializes to NULL.
Definition: opencl.hpp:2439
cl::DeviceCommandQueue::getDefault
static DeviceCommandQueue getDefault(const CommandQueue &queue, cl_int *err=NULL)
Definition: opencl.hpp:9056
cl::CommandQueue::enqueueMigrateSVM
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc >> &svmContainers, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8506
cl::Image2D::Image2D
Image2D()
Default constructor - initializes to NULL.
Definition: opencl.hpp:4885
cl::SVMTraitAtomic
Definition: opencl.hpp:3537
cl::Image3D::Image3D
Image3D()
Default constructor - initializes to NULL.
Definition: opencl.hpp:5210
cl::Context::Context
Context(Context &&ctx) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:2985
cl::UserEvent
Class interface for user events (a subset of cl_event's).
Definition: opencl.hpp:3286
cl::Platform::get
static cl_int get(vector< Platform > *platforms)
Gets a list of available platforms.
Definition: opencl.hpp:2643
cl::Sampler::Sampler
Sampler()
Default constructor - initializes to NULL.
Definition: opencl.hpp:5589
cl::Event::Event
Event(const cl_event &event, bool retainObject=false)
Constructor from cl_event - takes ownership.
Definition: opencl.hpp:3175
cl::Image3D::Image3D
Image3D(Image3D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5249
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue(const Context &context, const Device &device, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
Definition: opencl.hpp:8832
cl::fine_svm_vector
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> >> fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
Definition: opencl.hpp:3817
cl::Image3DGL::operator=
Image3DGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:5318
cl::Buffer
Class interface for Buffer Memory Objects.
Definition: opencl.hpp:3835
cl::Pipe::Pipe
Pipe(cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a the default context.
Definition: opencl.hpp:5482
cl::CommandQueue::CommandQueue
CommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
Definition: opencl.hpp:7506
cl::Pipe::getInfo
detail::param_traits< detail::cl_pipe_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
Definition: opencl.hpp:5563
cl::Image3DGL::Image3DGL
Image3DGL(const Image3DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5327
cl::Program::Program
Program(const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=NULL)
Definition: opencl.hpp:6550
cl::Image3D::operator=
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:5226
cl::Image2D::operator=
Image2D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:4901
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue(const DeviceCommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:8898
cl::Kernel::clone
Kernel clone()
Definition: opencl.hpp:6186
cl::Image1DBuffer
Image interface for 1D buffer images.
Definition: opencl.hpp:4526
cl::BufferRenderGL::BufferRenderGL
BufferRenderGL(const BufferRenderGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4304
cl::NDRange::dimensions
size_type dimensions() const
Queries the number of dimensions in the range.
Definition: opencl.hpp:5766
cl::DeviceCommandQueue::makeDefault
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
Definition: opencl.hpp:8951
cl::Program::Program
Program(const Sources &sources, cl_int *err=NULL)
Definition: opencl.hpp:6291
cl::Device::Device
Device(Device &&dev) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:2188
cl::Sampler::Sampler
Sampler(const Sampler &sam)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5659
cl::CommandQueue::enqueueMigrateSVM
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D >> &svmPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8470
cl::enqueueUnmapSVM
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL)
Definition: opencl.hpp:9356
cl::Kernel::setSVMPointers
cl_int setSVMPointers(const vector< void * > &pointerList)
Definition: opencl.hpp:6070
cl::LocalSpaceArg
Local address wrapper for use with Kernel::setArg.
Definition: opencl.hpp:5794
cl::Memory::Memory
Memory(const Memory &mem)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:3378
cl::Context::Context
Context(const Device &device, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including a specific device.
Definition: opencl.hpp:2855
cl::Context
Class interface for cl_context.
Definition: opencl.hpp:2750
cl::mapSVM
cl_int mapSVM(cl::vector< T, Alloc > &container)
Definition: opencl.hpp:9543
cl::Image::Image
Image(const Image &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4375
cl::Program::Program
Program(Program &&program) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:6614
cl::SVMTraitFine
Definition: opencl.hpp:3526
cl::Buffer::Buffer
Buffer(Buffer &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:3996
cl::Pipe::operator=
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:5517
cl::Buffer::Buffer
Buffer(const Context &context, cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in a specified context.
Definition: opencl.hpp:3845
cl::ImageFormat
Adds constructors and member functions for cl_image_format.
Definition: opencl.hpp:2057
cl::Image::Image
Image(Image &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4389
cl::Program::Program
Program(const Context &context, const vector< char > &IL, bool build=false, cl_int *err=NULL)
Definition: opencl.hpp:6418
cl::Context::getInfo
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetContextInfo() that returns by value.
Definition: opencl.hpp:3059
cl::Buffer::Buffer
Buffer()
Default constructor - initializes to NULL.
Definition: opencl.hpp:3957
cl::Image1D::Image1D
Image1D(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4479
cl::CommandQueue::enqueueBarrierWithWaitList
cl_int enqueueBarrierWithWaitList(const vector< Event > *events=0, Event *event=0) const
Definition: opencl.hpp:8339
cl::Image2DGL::Image2DGL
Image2DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image2DGL in a specified context, from a given GL Texture.
Definition: opencl.hpp:4956
cl::Memory
Class interface for cl_mem.
Definition: opencl.hpp:3345
cl::Program::setSpecializationConstant
cl_int setSpecializationConstant(cl_uint index, size_type size, const void *value)
Sets a SPIR-V specialization constant.
Definition: opencl.hpp:6871
cl::Sampler::Sampler
Sampler(const cl_sampler &sampler, bool retainObject=false)
Constructor from cl_sampler - takes ownership.
Definition: opencl.hpp:5642
cl::Image2DGL::Image2DGL
Image2DGL(const Image2DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5006
cl::ImageGL::ImageGL
ImageGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:5396
cl::Device::Device
Device(const Device &dev)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:2174
cl::Image2DArray::Image2DArray
Image2DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:5088
cl::Event::waitForEvents
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Definition: opencl.hpp:3271
cl::NDRange::NDRange
NDRange(size_type size0, size_type size1)
Constructs two-dimensional range.
Definition: opencl.hpp:5740
cl::CommandQueue::CommandQueue
CommandQueue(const Context &context, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
Definition: opencl.hpp:7242
cl::NDRange::NDRange
NDRange()
Default constructor - resulting range has zero dimensions.
Definition: opencl.hpp:5722
cl::CommandQueue::enqueueFillBuffer
cl_int enqueueFillBuffer(const Buffer &buffer, PatternType pattern, size_type offset, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:7767
cl::Buffer::Buffer
Buffer(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:3966
cl::DeviceCommandQueue
DeviceCommandQueue interface for device cl_command_queues.
Definition: opencl.hpp:8798
cl::Image2D::Image2D
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 2D Image in a specified context.
Definition: opencl.hpp:4710
cl::SVMTraitReadOnly
Definition: opencl.hpp:3494
cl::Image2DArray::Image2DArray
Image2DArray(const Image2DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5099
cl::Pipe::Pipe
Pipe()
Default constructor - initializes to NULL.
Definition: opencl.hpp:5501
cl::NDRange::NDRange
NDRange(size_type size0)
Constructs one-dimensional range.
Definition: opencl.hpp:5731
cl::Buffer::Buffer
Buffer(cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in the default context.
Definition: opencl.hpp:3870
cl::Image2DGL::Image2DGL
Image2DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4990
cl::UnloadCompiler
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Definition: opencl.hpp:2734
cl::Platform::getInfo
detail::param_traits< detail::cl_platform_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetPlatformInfo() that returns by value.
Definition: opencl.hpp:2498
cl::Sampler::getInfo
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
Definition: opencl.hpp:5686
cl::Kernel::Kernel
Kernel()
Default constructor - initializes to NULL.
Definition: opencl.hpp:5857
cl::Memory::operator=
Memory & operator=(const cl_mem &rhs)
Assignment operator from cl_mem - takes ownership.
Definition: opencl.hpp:3369
cl::Memory::setDestructorCallback
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=NULL)
Registers a callback function to be called when the memory object is no longer needed.
Definition: opencl.hpp:3441
cl::CommandQueue::enqueueMigrateSVM
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc >> &svmContainers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8485
cl::Device::operator=
Device & operator=(const cl_device_id &rhs)
Assignment operator from cl_device_id.
Definition: opencl.hpp:2165
cl::Image3DGL::Image3DGL
Image3DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image3DGL in a specified context, from a given GL Texture.
Definition: opencl.hpp:5278
cl::Event::getProfilingInfo
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Wrapper for clGetEventProfilingInfo().
Definition: opencl.hpp:3214
cl::BufferRenderGL::BufferRenderGL
BufferRenderGL()
Default constructor - initializes to NULL.
Definition: opencl.hpp:4279
cl::Kernel::setArg
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD type
Definition: opencl.hpp:6047
cl::Sampler::operator=
Sampler & operator=(const cl_sampler &rhs)
Assignment operator from cl_sampler - takes ownership.
Definition: opencl.hpp:5650
cl::Context::Context
Context(cl_device_type type, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including all or a subset of devices of a specified type.
Definition: opencl.hpp:2885
cl::Sampler::Sampler
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=NULL)
Constructs a Sampler in a specified context.
Definition: opencl.hpp:5595
cl::SVMAllocator
Definition: opencl.hpp:3570
cl::ImageFormat::ImageFormat
ImageFormat(cl_channel_order order, cl_channel_type type)
Initializing constructor.
Definition: opencl.hpp:2062
cl::Image::getImageInfo
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
Definition: opencl.hpp:4404
cl::CommandQueue::CommandQueue
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
Definition: opencl.hpp:7371
cl::Platform::get
static Platform get(cl_int *errResult=NULL)
Gets the first available platform, returning it by value.
Definition: opencl.hpp:2697
cl::Kernel
Class interface for cl_kernel.
Definition: opencl.hpp:5852
cl::CommandQueue::enqueueMapSVM
cl_int enqueueMapSVM(cl::pointer< T, D > &ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8149
cl::SVMAllocator::operator==
bool operator==(SVMAllocator const &rhs)
Definition: opencl.hpp:3704
cl::Program::Program
Program(const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=NULL, cl_int *err=NULL)
Definition: opencl.hpp:6486
cl::CommandQueue::enqueueMarker
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Definition: opencl.hpp:8605
cl::BufferRenderGL::getObjectInfo
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
Definition: opencl.hpp:4330
cl::Kernel::enableFineGrainedSystemSVM
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Definition: opencl.hpp:6106
cl::Image1DBuffer::Image1DBuffer
Image1DBuffer(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4567
cl::Pipe::Pipe
Pipe(const Context &context, cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a specified context.
Definition: opencl.hpp:5457
cl::Context::operator=
Context & operator=(const Context &ctx)
Copy assignment to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:2976
cl::ImageFormat::ImageFormat
ImageFormat()
Default constructor - performs no initialization.
Definition: opencl.hpp:2059
cl::CommandQueue::enqueueUnmapSVM
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8226
cl::Kernel::setArg
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
Definition: opencl.hpp:6014
cl::Platform::operator=
Platform & operator=(const cl_platform_id &rhs)
Assignment operator from cl_platform_id.
Definition: opencl.hpp:2455
cl::BufferGL::getObjectInfo
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
Definition: opencl.hpp:4233
cl::Event::wait
cl_int wait() const
Blocks the calling thread until this event completes.
Definition: opencl.hpp:3239
cl::Sampler::Sampler
Sampler(Sampler &&sam) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5673
cl::Context::getSupportedImageFormats
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
Definition: opencl.hpp:3074
cl::BufferGL::BufferGL
BufferGL(const BufferGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4207
cl::Kernel::setArg
cl_int setArg(cl_uint index, const cl::vector< T, Alloc > &argPtr)
setArg overload taking a vector type.
Definition: opencl.hpp:6024
cl::Memory::Memory
Memory()
Default constructor - initializes to NULL.
Definition: opencl.hpp:3348
cl::compatibility::make_kernel::type_
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
Definition: opencl.hpp:10155
cl::Image
C++ base class for Image Memory objects.
Definition: opencl.hpp:4347
cl::atomic_svm_vector
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> >> atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics.
Definition: opencl.hpp:3823
cl::Context::Context
Context(const vector< Device > &devices, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including a list of specified devices.
Definition: opencl.hpp:2820
cl::Pipe::Pipe
Pipe(Pipe &&pipe) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5540
cl
The OpenCL C++ bindings are defined within this namespace.
Definition: opencl.hpp:584
cl::BufferRenderGL
Class interface for GL Render Buffer Memory Objects.
Definition: opencl.hpp:4252
cl::SVMTraitReadWrite
Definition: opencl.hpp:3483
cl::Device
Class interface for cl_device_id.
Definition: opencl.hpp:2087
cl::Device::Device
Device()
Default constructor - initializes to NULL.
Definition: opencl.hpp:2123
cl::ImageFormat::operator=
ImageFormat & operator=(const ImageFormat &rhs)
Assignment operator.
Definition: opencl.hpp:2069
cl::KernelFunctor::result_type
Event result_type
Return type of the functor.
Definition: opencl.hpp:10058
cl::ImageGL
general image interface for GL interop. We abstract the 2D and 3D GL images into a single instance he...
Definition: opencl.hpp:5362
cl::CommandQueue::CommandQueue
CommandQueue(const Context &context, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
Definition: opencl.hpp:7309
cl::Event::operator=
Event & operator=(const cl_event &rhs)
Assignment operator from cl_event - takes ownership.
Definition: opencl.hpp:3183
cl::Image1DBuffer::Image1DBuffer
Image1DBuffer(Image1DBuffer &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4593
cl::Platform::setDefault
static Platform setDefault(const Platform &default_platform)
Definition: opencl.hpp:2479
cl::Image3D::Image3D
Image3D(const Image3D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5235
cl::Program::setReleaseCallback
CL_EXT_PREFIX__VERSION_2_2_DEPRECATED cl_int setReleaseCallback(void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data=NULL) CL_EXT_SUFFIX__VERSION_2_2_DEPRECATED
Registers a callback function to be called when destructors for program scope global variables are co...
Definition: opencl.hpp:6837
cl::Image::Image
Image()
Default constructor - initializes to NULL.
Definition: opencl.hpp:4350
cl::Program::Program
Program(const vector< char > &IL, bool build=false, cl_int *err=NULL)
Definition: opencl.hpp:6363
cl::Image3D
Class interface for 3D Image Memory objects.
Definition: opencl.hpp:5133
cl::Platform::Platform
Platform(const cl_platform_id &platform, bool retainObject=false)
Constructor from cl_platform_id.
Definition: opencl.hpp:2448
cl::Platform::get
static cl_int get(Platform *platform)
Gets the first available platform.
Definition: opencl.hpp:2678
cl::Kernel::operator=
Kernel & operator=(const cl_kernel &rhs)
Assignment operator from cl_kernel - takes ownership.
Definition: opencl.hpp:5875
cl::BufferRenderGL::BufferRenderGL
BufferRenderGL(BufferRenderGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4318
cl::Image::Image
Image(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4359
cl::Platform::getDevices
cl_int getDevices(cl_device_type type, vector< Device > *devices) const
Gets a list of devices for this platform.
Definition: opencl.hpp:2513
cl::CommandQueue::enqueueMigrateSVM
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8432
cl::Pipe::Pipe
Pipe(const Pipe &pipe)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5526
cl::KernelFunctor
Definition: opencl.hpp:10023
cl::unmapSVM
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Definition: opencl.hpp:9552
cl::Context::Context
Context(const cl_context &context, bool retainObject=false)
Constructor from cl_context - takes ownership.
Definition: opencl.hpp:3033
cl::Image2D
Class interface for 2D Image Memory objects.
Definition: opencl.hpp:4704
cl::Image1D
Class interface for 1D Image Memory objects.
Definition: opencl.hpp:4434
cl::DeviceCommandQueue::makeDefault
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_int *err=nullptr)
Definition: opencl.hpp:8981
cl::Image3DGL::Image3DGL
Image3DGL(Image3DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5341
cl::Platform::getInfo
cl_int getInfo(cl_platform_info name, T *param) const
Wrapper for clGetPlatformInfo().
Definition: opencl.hpp:2488
cl::CommandQueue::enqueueUnmapSVM
cl_int enqueueUnmapSVM(cl::pointer< T, D > &ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8251
cl::detail::GetInfoFunctor1
Definition: opencl.hpp:1564
cl::Image2DGL::Image2DGL
Image2DGL()
Default constructor - initializes to NULL.
Definition: opencl.hpp:4981
cl::Device::setDefault
static Device setDefault(const Device &default_device)
Definition: opencl.hpp:2154
cl::Memory::Memory
Memory(Memory &&mem) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:3392
cl::detail::Deleter
Definition: opencl.hpp:3737
cl::detail::ReferenceHandler
Definition: opencl.hpp:1590
cl::CommandQueue::CommandQueue
CommandQueue(CommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:7532
cl::Context::Context
Context(const Context &ctx)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:2971
cl::CommandQueue::setDefault
static CommandQueue setDefault(const CommandQueue &default_queue)
Definition: opencl.hpp:7490
cl::KernelFunctor::operator()
Event operator()(const EnqueueArgs &args, Ts... ts)
Definition: opencl.hpp:10065
cl::SVMTraitWriteOnly
Definition: opencl.hpp:3505
cl::Image1DArray::Image1DArray
Image1DArray(Image1DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4682
cl::Buffer::Buffer
Buffer(IteratorType startIterator, IteratorType endIterator, bool readOnly, bool useHostPtr=false, cl_int *err=NULL)
Construct a Buffer from a host container via iterators. IteratorType must be random access....
Definition: opencl.hpp:3894
cl::BufferGL::BufferGL
BufferGL(BufferGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4221
cl::Device::getDefault
static Device getDefault(cl_int *errResult=NULL)
Returns the first device on the default context.
Definition: opencl.hpp:2136
cl::CommandQueue::enqueueUnmapSVM
cl_int enqueueUnmapSVM(cl::vector< T, Alloc > &container, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8276
cl::Sampler::getInfo
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetSamplerInfo() that returns by value.
Definition: opencl.hpp:5696
cl::Image2DArray::Image2DArray
Image2DArray(Image2DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5113
cl::Event::Event
Event()
Default constructor - initializes to NULL.
Definition: opencl.hpp:3165
cl::Kernel::setSVMPointers
cl_int setSVMPointers(const std::array< void *, ArrayLength > &pointerList)
Definition: opencl.hpp:6085
cl::Image1DArray::Image1DArray
Image1DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4655
cl::Platform
Class interface for cl_platform_id.
Definition: opencl.hpp:2367
cl::Image3D::Image3D
Image3D(const cl_mem &image3D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:5219
cl::detail::SVMTraitNull
Definition: opencl.hpp:3472
cl::CommandQueue::enqueueMigrateMemObjects
cl_int enqueueMigrateMemObjects(const vector< Memory > &memObjects, cl_mem_migration_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8362
cl::Image3DGL
Class interface for GL 3D Image Memory objects.
Definition: opencl.hpp:5271
cl::enqueueMapSVM
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL)
Definition: opencl.hpp:9254
cl::DeviceCommandQueue::makeDefault
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_uint queueSize, cl_int *err=nullptr)
Definition: opencl.hpp:9009
cl::CommandQueue::enqueueMapSVM
cl_int enqueueMapSVM(cl::vector< T, Alloc > &container, cl_bool blocking, cl_map_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8176
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue(DeviceQueueProperties properties, cl_int *err=NULL)
Definition: opencl.hpp:8809
cl::Image3DGL::Image3DGL
Image3DGL()
Default constructor - initializes to NULL.
Definition: opencl.hpp:5302
cl::Context::getInfo
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
Definition: opencl.hpp:3049
cl::coarse_svm_vector
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> >> coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
Definition: opencl.hpp:3811
cl::CommandQueue::enqueueMigrateSVM
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8403
cl::ImageGL::ImageGL
ImageGL(const ImageGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5408
cl::Event
Class interface for cl_event.
Definition: opencl.hpp:3162
cl::EnqueueArgs
Definition: opencl.hpp:9832
cl::Kernel::Kernel
Kernel(const cl_kernel &kernel, bool retainObject=false)
Constructor from cl_kernel - takes ownership.
Definition: opencl.hpp:5867
cl::Local
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
Definition: opencl.hpp:5837
cl::Kernel::Kernel
Kernel(Kernel &&kernel) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5898
cl::Pipe::Pipe
Pipe(const cl_mem &pipe, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:5510
cl::CommandQueue::CommandQueue
CommandQueue(const Context &context, const Device &device, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
Definition: opencl.hpp:7422
cl::Image::getImageInfo
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Wrapper for clGetImageInfo() that returns by value.
Definition: opencl.hpp:4414
cl::CommandQueue::enqueueMapSVM
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:8121
cl::Program::getBuildInfo
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=NULL) const
Definition: opencl.hpp:6758
cl::SVMAllocator::allocate
pointer allocate(size_type size, typename cl::SVMAllocator< void, SVMTrait >::const_pointer=0)
Definition: opencl.hpp:3634
cl::detail::param_traits
Definition: opencl.hpp:1400
cl::UserEvent::UserEvent
UserEvent()
Default constructor - initializes to NULL.
Definition: opencl.hpp:3308
cl::Memory::getInfo
cl_int getInfo(cl_mem_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Definition: opencl.hpp:3406
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue(DeviceCommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:8912
cl::BufferGL::BufferGL
BufferGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4191
cl::Program::setSpecializationConstant
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant(cl_uint index, const T &value)
Sets a SPIR-V specialization constant.
Definition: opencl.hpp:6856
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue()
Definition: opencl.hpp:8804
cl::NDRange::NDRange
NDRange(size_type size0, size_type size1, size_type size2)
Constructs three-dimensional range.
Definition: opencl.hpp:5749
cl::detail::Wrapper
Definition: opencl.hpp:1767
cl::BufferGL
Class interface for GL Buffer Memory Objects.
Definition: opencl.hpp:4155
cl::Event::getInfo
cl_int getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
Definition: opencl.hpp:3191
cl::detail::GetInfoFunctor0
Definition: opencl.hpp:1555
cl::Buffer::createSubBuffer
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=NULL)
Creates a new buffer object from this.
Definition: opencl.hpp:4012
cl::Memory::getInfo
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
Definition: opencl.hpp:3416
cl::CommandQueue::enqueueFillImage
cl_int enqueueFillImage(const Image &image, cl_float4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > &region, const vector< Event > *events=NULL, Event *event=NULL) const
Definition: opencl.hpp:7899
cl::CommandQueue::enqueueBarrier
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Definition: opencl.hpp:8758
cl::Image2D::Image2D
Image2D(const cl_mem &image2D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4894
cl::allocate_pointer
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
Definition: opencl.hpp:3764
cl::Device::Device
Device(const cl_device_id &device, bool retainObject=false)
Constructor from cl_device_id.
Definition: opencl.hpp:2129
cl::Image2DArray
Image interface for arrays of 2D images.
Definition: opencl.hpp:5039
cl::Image1DArray
Image interface for arrays of 1D images.
Definition: opencl.hpp:4610
cl::Kernel::Kernel
Kernel(const Kernel &kernel)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5884
cl::BufferRenderGL::BufferRenderGL
BufferRenderGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Definition: opencl.hpp:4288
cl::DeviceCommandQueue::updateDefault
static DeviceCommandQueue updateDefault(const Context &context, const Device &device, const DeviceCommandQueue &default_queue, cl_int *err=nullptr)
Definition: opencl.hpp:9041
cl::NDRange
Class interface for specifying NDRange values.
Definition: opencl.hpp:5715
cl::UserEvent::UserEvent
UserEvent(const Context &context, cl_int *err=NULL)
Constructs a user event on a given context.
Definition: opencl.hpp:3292
cl::Device::createSubDevices
cl_int createSubDevices(const cl_device_partition_property *properties, vector< Device > *devices)
Wrapper for clCreateSubDevices().
Definition: opencl.hpp:2274
cl::Event::getInfo
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetEventInfo() that returns by value.
Definition: opencl.hpp:3201
cl::ImageGL::ImageGL
ImageGL(ImageGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:5422
cl::detail::ReferenceHandler< cl_device_id >::release
static cl_int release(cl_device_id device)
Definition: opencl.hpp:1619
cl::CommandQueue
CommandQueue interface for cl_command_queue.
Definition: opencl.hpp:7048
cl::Image::operator=
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:4366
cl::compatibility::make_kernel
Definition: opencl.hpp:10134
cl::UserEvent::setStatus
cl_int setStatus(cl_int status)
Sets the execution status of a user event object.
Definition: opencl.hpp:3314
cl::copy
cl_int copy(const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator)
Definition: opencl.hpp:9512
cl::Buffer::operator=
Buffer & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:3973
cl::BufferGL::operator=
BufferGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:4198
cl::BufferGL::BufferGL
BufferGL()
Default constructor - initializes to NULL.
Definition: opencl.hpp:4182
cl::CommandQueue::enqueueMarkerWithWaitList
cl_int enqueueMarkerWithWaitList(const vector< Event > *events=0, Event *event=0) const
Definition: opencl.hpp:8309
cl::CommandQueue::CommandQueue
CommandQueue(QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
Definition: opencl.hpp:7179
cl::Image1D::operator=
Image1D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:4486
cl::Image1D::Image1D
Image1D()
Default constructor - initializes to NULL.
Definition: opencl.hpp:4470
cl::BufferRenderGL::operator=
BufferRenderGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Definition: opencl.hpp:4295
cl::CommandQueue::CommandQueue
CommandQueue(cl_command_queue_properties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
Definition: opencl.hpp:7113
cl::Context::Context
Context()
Default constructor - initializes to NULL.
Definition: opencl.hpp:3026
cl::Device::getInfo
cl_int getInfo(cl_device_info name, T *param) const
Wrapper for clGetDeviceInfo().
Definition: opencl.hpp:2201
cl::DeviceCommandQueue::DeviceCommandQueue
DeviceCommandQueue(const Context &context, const Device &device, cl_uint queueSize, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
Definition: opencl.hpp:8856
cl::Image1D::Image1D
Image1D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 1D Image in a specified context.
Definition: opencl.hpp:4440
cl::Image2D::Image2D
Image2D(const Context &context, cl_channel_order order, const Image &sourceImage, cl_int *err=nullptr)
Constructs a 2D Image from an image.
Definition: opencl.hpp:4831
cl::Image3D::Image3D
Image3D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type depth, size_type row_pitch=0, size_type slice_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 3D Image in a specified context.
Definition: opencl.hpp:5139
cl::Program::Program
Program(const Program &program)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:6600
cl::Image2DGL
Class interface for GL 2D Image Memory objects.
Definition: opencl.hpp:4949
cl::Image2D::Image2D
Image2D(const Image2D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4910
cl::Device::getHostTimer
cl_ulong getHostTimer(cl_int *error=nullptr)
Definition: opencl.hpp:2230
cl::detail::KernelArgumentHandler
Definition: opencl.hpp:5801
cl::Program::Program
Program(const Context &context, const Sources &sources, cl_int *err=NULL)
Definition: opencl.hpp:6326
cl::Image1DBuffer::Image1DBuffer
Image1DBuffer(const Image1DBuffer &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Definition: opencl.hpp:4579
cl::SVMAllocator::max_size
size_type max_size() const CL_HPP_NOEXCEPT_
Definition: opencl.hpp:3676
cl::Context::setDefault
static Context setDefault(const Context &default_context)
Definition: opencl.hpp:3018