// GENERATED FILE - DO NOT EDIT.
// Generated by generate_entry_points.py using data from cl.xml.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// libOpenCL_autogen.cpp: Implements the exported CL functions.

#include "libOpenCL/dispatch.h"

extern "C" {

// CL 1.0
cl_int CL_API_CALL clGetPlatformIDs(cl_uint num_entries,
                                    cl_platform_id *platforms,
                                    cl_uint *num_platforms)
{
    return cl::GetDispatch().clGetPlatformIDs(num_entries, platforms, num_platforms);
}

cl_int CL_API_CALL clGetPlatformInfo(cl_platform_id platform,
                                     cl_platform_info param_name,
                                     size_t param_value_size,
                                     void *param_value,
                                     size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetPlatformInfo(platform, param_name, param_value_size, param_value,
                                               param_value_size_ret);
}

cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
                                  cl_device_type device_type,
                                  cl_uint num_entries,
                                  cl_device_id *devices,
                                  cl_uint *num_devices)
{
    return cl::GetDispatch().clGetDeviceIDs(platform, device_type, num_entries, devices,
                                            num_devices);
}

cl_int CL_API_CALL clGetDeviceInfo(cl_device_id device,
                                   cl_device_info param_name,
                                   size_t param_value_size,
                                   void *param_value,
                                   size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetDeviceInfo(device, param_name, param_value_size, param_value,
                                             param_value_size_ret);
}

cl_context CL_API_CALL clCreateContext(const cl_context_properties *properties,
                                       cl_uint num_devices,
                                       const cl_device_id *devices,
                                       void(CL_CALLBACK *pfn_notify)(const char *errinfo,
                                                                     const void *private_info,
                                                                     size_t cb,
                                                                     void *user_data),
                                       void *user_data,
                                       cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateContext(properties, num_devices, devices, pfn_notify,
                                             user_data, errcode_ret);
}

cl_context CL_API_CALL
clCreateContextFromType(const cl_context_properties *properties,
                        cl_device_type device_type,
                        void(CL_CALLBACK *pfn_notify)(const char *errinfo,
                                                      const void *private_info,
                                                      size_t cb,
                                                      void *user_data),
                        void *user_data,
                        cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateContextFromType(properties, device_type, pfn_notify, user_data,
                                                     errcode_ret);
}

cl_int CL_API_CALL clRetainContext(cl_context context)
{
    return cl::GetDispatch().clRetainContext(context);
}

cl_int CL_API_CALL clReleaseContext(cl_context context)
{
    return cl::GetDispatch().clReleaseContext(context);
}

cl_int CL_API_CALL clGetContextInfo(cl_context context,
                                    cl_context_info param_name,
                                    size_t param_value_size,
                                    void *param_value,
                                    size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetContextInfo(context, param_name, param_value_size, param_value,
                                              param_value_size_ret);
}

cl_int CL_API_CALL clRetainCommandQueue(cl_command_queue command_queue)
{
    return cl::GetDispatch().clRetainCommandQueue(command_queue);
}

cl_int CL_API_CALL clReleaseCommandQueue(cl_command_queue command_queue)
{
    return cl::GetDispatch().clReleaseCommandQueue(command_queue);
}

cl_int CL_API_CALL clGetCommandQueueInfo(cl_command_queue command_queue,
                                         cl_command_queue_info param_name,
                                         size_t param_value_size,
                                         void *param_value,
                                         size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetCommandQueueInfo(command_queue, param_name, param_value_size,
                                                   param_value, param_value_size_ret);
}

cl_mem CL_API_CALL clCreateBuffer(cl_context context,
                                  cl_mem_flags flags,
                                  size_t size,
                                  void *host_ptr,
                                  cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateBuffer(context, flags, size, host_ptr, errcode_ret);
}

cl_int CL_API_CALL clRetainMemObject(cl_mem memobj)
{
    return cl::GetDispatch().clRetainMemObject(memobj);
}

cl_int CL_API_CALL clReleaseMemObject(cl_mem memobj)
{
    return cl::GetDispatch().clReleaseMemObject(memobj);
}

cl_int CL_API_CALL clGetSupportedImageFormats(cl_context context,
                                              cl_mem_flags flags,
                                              cl_mem_object_type image_type,
                                              cl_uint num_entries,
                                              cl_image_format *image_formats,
                                              cl_uint *num_image_formats)
{
    return cl::GetDispatch().clGetSupportedImageFormats(context, flags, image_type, num_entries,
                                                        image_formats, num_image_formats);
}

cl_int CL_API_CALL clGetMemObjectInfo(cl_mem memobj,
                                      cl_mem_info param_name,
                                      size_t param_value_size,
                                      void *param_value,
                                      size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetMemObjectInfo(memobj, param_name, param_value_size, param_value,
                                                param_value_size_ret);
}

cl_int CL_API_CALL clGetImageInfo(cl_mem image,
                                  cl_image_info param_name,
                                  size_t param_value_size,
                                  void *param_value,
                                  size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetImageInfo(image, param_name, param_value_size, param_value,
                                            param_value_size_ret);
}

cl_int CL_API_CALL clRetainSampler(cl_sampler sampler)
{
    return cl::GetDispatch().clRetainSampler(sampler);
}

cl_int CL_API_CALL clReleaseSampler(cl_sampler sampler)
{
    return cl::GetDispatch().clReleaseSampler(sampler);
}

cl_int CL_API_CALL clGetSamplerInfo(cl_sampler sampler,
                                    cl_sampler_info param_name,
                                    size_t param_value_size,
                                    void *param_value,
                                    size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetSamplerInfo(sampler, param_name, param_value_size, param_value,
                                              param_value_size_ret);
}

cl_program CL_API_CALL clCreateProgramWithSource(cl_context context,
                                                 cl_uint count,
                                                 const char **strings,
                                                 const size_t *lengths,
                                                 cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateProgramWithSource(context, count, strings, lengths,
                                                       errcode_ret);
}

cl_program CL_API_CALL clCreateProgramWithBinary(cl_context context,
                                                 cl_uint num_devices,
                                                 const cl_device_id *device_list,
                                                 const size_t *lengths,
                                                 const unsigned char **binaries,
                                                 cl_int *binary_status,
                                                 cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateProgramWithBinary(context, num_devices, device_list, lengths,
                                                       binaries, binary_status, errcode_ret);
}

cl_int CL_API_CALL clRetainProgram(cl_program program)
{
    return cl::GetDispatch().clRetainProgram(program);
}

cl_int CL_API_CALL clReleaseProgram(cl_program program)
{
    return cl::GetDispatch().clReleaseProgram(program);
}

cl_int CL_API_CALL clBuildProgram(cl_program program,
                                  cl_uint num_devices,
                                  const cl_device_id *device_list,
                                  const char *options,
                                  void(CL_CALLBACK *pfn_notify)(cl_program program,
                                                                void *user_data),
                                  void *user_data)
{
    return cl::GetDispatch().clBuildProgram(program, num_devices, device_list, options, pfn_notify,
                                            user_data);
}

cl_int CL_API_CALL clGetProgramInfo(cl_program program,
                                    cl_program_info param_name,
                                    size_t param_value_size,
                                    void *param_value,
                                    size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetProgramInfo(program, param_name, param_value_size, param_value,
                                              param_value_size_ret);
}

cl_int CL_API_CALL clGetProgramBuildInfo(cl_program program,
                                         cl_device_id device,
                                         cl_program_build_info param_name,
                                         size_t param_value_size,
                                         void *param_value,
                                         size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetProgramBuildInfo(program, device, param_name, param_value_size,
                                                   param_value, param_value_size_ret);
}

cl_kernel CL_API_CALL clCreateKernel(cl_program program,
                                     const char *kernel_name,
                                     cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateKernel(program, kernel_name, errcode_ret);
}

cl_int CL_API_CALL clCreateKernelsInProgram(cl_program program,
                                            cl_uint num_kernels,
                                            cl_kernel *kernels,
                                            cl_uint *num_kernels_ret)
{
    return cl::GetDispatch().clCreateKernelsInProgram(program, num_kernels, kernels,
                                                      num_kernels_ret);
}

cl_int CL_API_CALL clRetainKernel(cl_kernel kernel)
{
    return cl::GetDispatch().clRetainKernel(kernel);
}

cl_int CL_API_CALL clReleaseKernel(cl_kernel kernel)
{
    return cl::GetDispatch().clReleaseKernel(kernel);
}

cl_int CL_API_CALL clSetKernelArg(cl_kernel kernel,
                                  cl_uint arg_index,
                                  size_t arg_size,
                                  const void *arg_value)
{
    return cl::GetDispatch().clSetKernelArg(kernel, arg_index, arg_size, arg_value);
}

cl_int CL_API_CALL clGetKernelInfo(cl_kernel kernel,
                                   cl_kernel_info param_name,
                                   size_t param_value_size,
                                   void *param_value,
                                   size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetKernelInfo(kernel, param_name, param_value_size, param_value,
                                             param_value_size_ret);
}

cl_int CL_API_CALL clGetKernelWorkGroupInfo(cl_kernel kernel,
                                            cl_device_id device,
                                            cl_kernel_work_group_info param_name,
                                            size_t param_value_size,
                                            void *param_value,
                                            size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetKernelWorkGroupInfo(kernel, device, param_name, param_value_size,
                                                      param_value, param_value_size_ret);
}

cl_int CL_API_CALL clWaitForEvents(cl_uint num_events, const cl_event *event_list)
{
    return cl::GetDispatch().clWaitForEvents(num_events, event_list);
}

cl_int CL_API_CALL clGetEventInfo(cl_event event,
                                  cl_event_info param_name,
                                  size_t param_value_size,
                                  void *param_value,
                                  size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetEventInfo(event, param_name, param_value_size, param_value,
                                            param_value_size_ret);
}

cl_int CL_API_CALL clRetainEvent(cl_event event)
{
    return cl::GetDispatch().clRetainEvent(event);
}

cl_int CL_API_CALL clReleaseEvent(cl_event event)
{
    return cl::GetDispatch().clReleaseEvent(event);
}

cl_int CL_API_CALL clGetEventProfilingInfo(cl_event event,
                                           cl_profiling_info param_name,
                                           size_t param_value_size,
                                           void *param_value,
                                           size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetEventProfilingInfo(event, param_name, param_value_size,
                                                     param_value, param_value_size_ret);
}

cl_int CL_API_CALL clFlush(cl_command_queue command_queue)
{
    return cl::GetDispatch().clFlush(command_queue);
}

cl_int CL_API_CALL clFinish(cl_command_queue command_queue)
{
    return cl::GetDispatch().clFinish(command_queue);
}

cl_int CL_API_CALL clEnqueueReadBuffer(cl_command_queue command_queue,
                                       cl_mem buffer,
                                       cl_bool blocking_read,
                                       size_t offset,
                                       size_t size,
                                       void *ptr,
                                       cl_uint num_events_in_wait_list,
                                       const cl_event *event_wait_list,
                                       cl_event *event)
{
    return cl::GetDispatch().clEnqueueReadBuffer(command_queue, buffer, blocking_read, offset, size,
                                                 ptr, num_events_in_wait_list, event_wait_list,
                                                 event);
}

cl_int CL_API_CALL clEnqueueWriteBuffer(cl_command_queue command_queue,
                                        cl_mem buffer,
                                        cl_bool blocking_write,
                                        size_t offset,
                                        size_t size,
                                        const void *ptr,
                                        cl_uint num_events_in_wait_list,
                                        const cl_event *event_wait_list,
                                        cl_event *event)
{
    return cl::GetDispatch().clEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset,
                                                  size, ptr, num_events_in_wait_list,
                                                  event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueCopyBuffer(cl_command_queue command_queue,
                                       cl_mem src_buffer,
                                       cl_mem dst_buffer,
                                       size_t src_offset,
                                       size_t dst_offset,
                                       size_t size,
                                       cl_uint num_events_in_wait_list,
                                       const cl_event *event_wait_list,
                                       cl_event *event)
{
    return cl::GetDispatch().clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset,
                                                 dst_offset, size, num_events_in_wait_list,
                                                 event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueReadImage(cl_command_queue command_queue,
                                      cl_mem image,
                                      cl_bool blocking_read,
                                      const size_t *origin,
                                      const size_t *region,
                                      size_t row_pitch,
                                      size_t slice_pitch,
                                      void *ptr,
                                      cl_uint num_events_in_wait_list,
                                      const cl_event *event_wait_list,
                                      cl_event *event)
{
    return cl::GetDispatch().clEnqueueReadImage(command_queue, image, blocking_read, origin, region,
                                                row_pitch, slice_pitch, ptr,
                                                num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueWriteImage(cl_command_queue command_queue,
                                       cl_mem image,
                                       cl_bool blocking_write,
                                       const size_t *origin,
                                       const size_t *region,
                                       size_t input_row_pitch,
                                       size_t input_slice_pitch,
                                       const void *ptr,
                                       cl_uint num_events_in_wait_list,
                                       const cl_event *event_wait_list,
                                       cl_event *event)
{
    return cl::GetDispatch().clEnqueueWriteImage(command_queue, image, blocking_write, origin,
                                                 region, input_row_pitch, input_slice_pitch, ptr,
                                                 num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueCopyImage(cl_command_queue command_queue,
                                      cl_mem src_image,
                                      cl_mem dst_image,
                                      const size_t *src_origin,
                                      const size_t *dst_origin,
                                      const size_t *region,
                                      cl_uint num_events_in_wait_list,
                                      const cl_event *event_wait_list,
                                      cl_event *event)
{
    return cl::GetDispatch().clEnqueueCopyImage(command_queue, src_image, dst_image, src_origin,
                                                dst_origin, region, num_events_in_wait_list,
                                                event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueCopyImageToBuffer(cl_command_queue command_queue,
                                              cl_mem src_image,
                                              cl_mem dst_buffer,
                                              const size_t *src_origin,
                                              const size_t *region,
                                              size_t dst_offset,
                                              cl_uint num_events_in_wait_list,
                                              const cl_event *event_wait_list,
                                              cl_event *event)
{
    return cl::GetDispatch().clEnqueueCopyImageToBuffer(
        command_queue, src_image, dst_buffer, src_origin, region, dst_offset,
        num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueCopyBufferToImage(cl_command_queue command_queue,
                                              cl_mem src_buffer,
                                              cl_mem dst_image,
                                              size_t src_offset,
                                              const size_t *dst_origin,
                                              const size_t *region,
                                              cl_uint num_events_in_wait_list,
                                              const cl_event *event_wait_list,
                                              cl_event *event)
{
    return cl::GetDispatch().clEnqueueCopyBufferToImage(
        command_queue, src_buffer, dst_image, src_offset, dst_origin, region,
        num_events_in_wait_list, event_wait_list, event);
}

void *CL_API_CALL clEnqueueMapBuffer(cl_command_queue command_queue,
                                     cl_mem buffer,
                                     cl_bool blocking_map,
                                     cl_map_flags map_flags,
                                     size_t offset,
                                     size_t size,
                                     cl_uint num_events_in_wait_list,
                                     const cl_event *event_wait_list,
                                     cl_event *event,
                                     cl_int *errcode_ret)
{
    return cl::GetDispatch().clEnqueueMapBuffer(command_queue, buffer, blocking_map, map_flags,
                                                offset, size, num_events_in_wait_list,
                                                event_wait_list, event, errcode_ret);
}

void *CL_API_CALL clEnqueueMapImage(cl_command_queue command_queue,
                                    cl_mem image,
                                    cl_bool blocking_map,
                                    cl_map_flags map_flags,
                                    const size_t *origin,
                                    const size_t *region,
                                    size_t *image_row_pitch,
                                    size_t *image_slice_pitch,
                                    cl_uint num_events_in_wait_list,
                                    const cl_event *event_wait_list,
                                    cl_event *event,
                                    cl_int *errcode_ret)
{
    return cl::GetDispatch().clEnqueueMapImage(
        command_queue, image, blocking_map, map_flags, origin, region, image_row_pitch,
        image_slice_pitch, num_events_in_wait_list, event_wait_list, event, errcode_ret);
}

cl_int CL_API_CALL clEnqueueUnmapMemObject(cl_command_queue command_queue,
                                           cl_mem memobj,
                                           void *mapped_ptr,
                                           cl_uint num_events_in_wait_list,
                                           const cl_event *event_wait_list,
                                           cl_event *event)
{
    return cl::GetDispatch().clEnqueueUnmapMemObject(
        command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueNDRangeKernel(cl_command_queue command_queue,
                                          cl_kernel kernel,
                                          cl_uint work_dim,
                                          const size_t *global_work_offset,
                                          const size_t *global_work_size,
                                          const size_t *local_work_size,
                                          cl_uint num_events_in_wait_list,
                                          const cl_event *event_wait_list,
                                          cl_event *event)
{
    return cl::GetDispatch().clEnqueueNDRangeKernel(
        command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size,
        num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueNativeKernel(cl_command_queue command_queue,
                                         void(CL_CALLBACK *user_func)(void *),
                                         void *args,
                                         size_t cb_args,
                                         cl_uint num_mem_objects,
                                         const cl_mem *mem_list,
                                         const void **args_mem_loc,
                                         cl_uint num_events_in_wait_list,
                                         const cl_event *event_wait_list,
                                         cl_event *event)
{
    return cl::GetDispatch().clEnqueueNativeKernel(command_queue, user_func, args, cb_args,
                                                   num_mem_objects, mem_list, args_mem_loc,
                                                   num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clSetCommandQueueProperty(cl_command_queue command_queue,
                                             cl_command_queue_properties properties,
                                             cl_bool enable,
                                             cl_command_queue_properties *old_properties)
{
    return cl::GetDispatch().clSetCommandQueueProperty(command_queue, properties, enable,
                                                       old_properties);
}

cl_mem CL_API_CALL clCreateImage2D(cl_context context,
                                   cl_mem_flags flags,
                                   const cl_image_format *image_format,
                                   size_t image_width,
                                   size_t image_height,
                                   size_t image_row_pitch,
                                   void *host_ptr,
                                   cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateImage2D(context, flags, image_format, image_width,
                                             image_height, image_row_pitch, host_ptr, errcode_ret);
}

cl_mem CL_API_CALL clCreateImage3D(cl_context context,
                                   cl_mem_flags flags,
                                   const cl_image_format *image_format,
                                   size_t image_width,
                                   size_t image_height,
                                   size_t image_depth,
                                   size_t image_row_pitch,
                                   size_t image_slice_pitch,
                                   void *host_ptr,
                                   cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateImage3D(context, flags, image_format, image_width,
                                             image_height, image_depth, image_row_pitch,
                                             image_slice_pitch, host_ptr, errcode_ret);
}

cl_int CL_API_CALL clEnqueueMarker(cl_command_queue command_queue, cl_event *event)
{
    return cl::GetDispatch().clEnqueueMarker(command_queue, event);
}

cl_int CL_API_CALL clEnqueueWaitForEvents(cl_command_queue command_queue,
                                          cl_uint num_events,
                                          const cl_event *event_list)
{
    return cl::GetDispatch().clEnqueueWaitForEvents(command_queue, num_events, event_list);
}

cl_int CL_API_CALL clEnqueueBarrier(cl_command_queue command_queue)
{
    return cl::GetDispatch().clEnqueueBarrier(command_queue);
}

cl_int CL_API_CALL clUnloadCompiler()
{
    return cl::GetDispatch().clUnloadCompiler();
}

void *CL_API_CALL clGetExtensionFunctionAddress(const char *func_name)
{
    return cl::GetDispatch().clGetExtensionFunctionAddress(func_name);
}

cl_command_queue CL_API_CALL clCreateCommandQueue(cl_context context,
                                                  cl_device_id device,
                                                  cl_command_queue_properties properties,
                                                  cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateCommandQueue(context, device, properties, errcode_ret);
}

cl_sampler CL_API_CALL clCreateSampler(cl_context context,
                                       cl_bool normalized_coords,
                                       cl_addressing_mode addressing_mode,
                                       cl_filter_mode filter_mode,
                                       cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateSampler(context, normalized_coords, addressing_mode,
                                             filter_mode, errcode_ret);
}

cl_int CL_API_CALL clEnqueueTask(cl_command_queue command_queue,
                                 cl_kernel kernel,
                                 cl_uint num_events_in_wait_list,
                                 const cl_event *event_wait_list,
                                 cl_event *event)
{
    return cl::GetDispatch().clEnqueueTask(command_queue, kernel, num_events_in_wait_list,
                                           event_wait_list, event);
}

// CL 1.1
cl_mem CL_API_CALL clCreateSubBuffer(cl_mem buffer,
                                     cl_mem_flags flags,
                                     cl_buffer_create_type buffer_create_type,
                                     const void *buffer_create_info,
                                     cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateSubBuffer(buffer, flags, buffer_create_type,
                                               buffer_create_info, errcode_ret);
}

cl_int CL_API_CALL clSetMemObjectDestructorCallback(cl_mem memobj,
                                                    void(CL_CALLBACK *pfn_notify)(cl_mem memobj,
                                                                                  void *user_data),
                                                    void *user_data)
{
    return cl::GetDispatch().clSetMemObjectDestructorCallback(memobj, pfn_notify, user_data);
}

cl_event CL_API_CALL clCreateUserEvent(cl_context context, cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateUserEvent(context, errcode_ret);
}

cl_int CL_API_CALL clSetUserEventStatus(cl_event event, cl_int execution_status)
{
    return cl::GetDispatch().clSetUserEventStatus(event, execution_status);
}

cl_int CL_API_CALL clSetEventCallback(cl_event event,
                                      cl_int command_exec_callback_type,
                                      void(CL_CALLBACK *pfn_notify)(cl_event event,
                                                                    cl_int event_command_status,
                                                                    void *user_data),
                                      void *user_data)
{
    return cl::GetDispatch().clSetEventCallback(event, command_exec_callback_type, pfn_notify,
                                                user_data);
}

cl_int CL_API_CALL clEnqueueReadBufferRect(cl_command_queue command_queue,
                                           cl_mem buffer,
                                           cl_bool blocking_read,
                                           const size_t *buffer_origin,
                                           const size_t *host_origin,
                                           const size_t *region,
                                           size_t buffer_row_pitch,
                                           size_t buffer_slice_pitch,
                                           size_t host_row_pitch,
                                           size_t host_slice_pitch,
                                           void *ptr,
                                           cl_uint num_events_in_wait_list,
                                           const cl_event *event_wait_list,
                                           cl_event *event)
{
    return cl::GetDispatch().clEnqueueReadBufferRect(
        command_queue, buffer, blocking_read, buffer_origin, host_origin, region, buffer_row_pitch,
        buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list,
        event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueWriteBufferRect(cl_command_queue command_queue,
                                            cl_mem buffer,
                                            cl_bool blocking_write,
                                            const size_t *buffer_origin,
                                            const size_t *host_origin,
                                            const size_t *region,
                                            size_t buffer_row_pitch,
                                            size_t buffer_slice_pitch,
                                            size_t host_row_pitch,
                                            size_t host_slice_pitch,
                                            const void *ptr,
                                            cl_uint num_events_in_wait_list,
                                            const cl_event *event_wait_list,
                                            cl_event *event)
{
    return cl::GetDispatch().clEnqueueWriteBufferRect(
        command_queue, buffer, blocking_write, buffer_origin, host_origin, region, buffer_row_pitch,
        buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list,
        event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueCopyBufferRect(cl_command_queue command_queue,
                                           cl_mem src_buffer,
                                           cl_mem dst_buffer,
                                           const size_t *src_origin,
                                           const size_t *dst_origin,
                                           const size_t *region,
                                           size_t src_row_pitch,
                                           size_t src_slice_pitch,
                                           size_t dst_row_pitch,
                                           size_t dst_slice_pitch,
                                           cl_uint num_events_in_wait_list,
                                           const cl_event *event_wait_list,
                                           cl_event *event)
{
    return cl::GetDispatch().clEnqueueCopyBufferRect(
        command_queue, src_buffer, dst_buffer, src_origin, dst_origin, region, src_row_pitch,
        src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events_in_wait_list, event_wait_list,
        event);
}

// CL 1.2
cl_int CL_API_CALL clCreateSubDevices(cl_device_id in_device,
                                      const cl_device_partition_property *properties,
                                      cl_uint num_devices,
                                      cl_device_id *out_devices,
                                      cl_uint *num_devices_ret)
{
    return cl::GetDispatch().clCreateSubDevices(in_device, properties, num_devices, out_devices,
                                                num_devices_ret);
}

cl_int CL_API_CALL clRetainDevice(cl_device_id device)
{
    return cl::GetDispatch().clRetainDevice(device);
}

cl_int CL_API_CALL clReleaseDevice(cl_device_id device)
{
    return cl::GetDispatch().clReleaseDevice(device);
}

cl_mem CL_API_CALL clCreateImage(cl_context context,
                                 cl_mem_flags flags,
                                 const cl_image_format *image_format,
                                 const cl_image_desc *image_desc,
                                 void *host_ptr,
                                 cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateImage(context, flags, image_format, image_desc, host_ptr,
                                           errcode_ret);
}

cl_program CL_API_CALL clCreateProgramWithBuiltInKernels(cl_context context,
                                                         cl_uint num_devices,
                                                         const cl_device_id *device_list,
                                                         const char *kernel_names,
                                                         cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateProgramWithBuiltInKernels(context, num_devices, device_list,
                                                               kernel_names, errcode_ret);
}

cl_int CL_API_CALL clCompileProgram(cl_program program,
                                    cl_uint num_devices,
                                    const cl_device_id *device_list,
                                    const char *options,
                                    cl_uint num_input_headers,
                                    const cl_program *input_headers,
                                    const char **header_include_names,
                                    void(CL_CALLBACK *pfn_notify)(cl_program program,
                                                                  void *user_data),
                                    void *user_data)
{
    return cl::GetDispatch().clCompileProgram(program, num_devices, device_list, options,
                                              num_input_headers, input_headers,
                                              header_include_names, pfn_notify, user_data);
}

cl_program CL_API_CALL clLinkProgram(cl_context context,
                                     cl_uint num_devices,
                                     const cl_device_id *device_list,
                                     const char *options,
                                     cl_uint num_input_programs,
                                     const cl_program *input_programs,
                                     void(CL_CALLBACK *pfn_notify)(cl_program program,
                                                                   void *user_data),
                                     void *user_data,
                                     cl_int *errcode_ret)
{
    return cl::GetDispatch().clLinkProgram(context, num_devices, device_list, options,
                                           num_input_programs, input_programs, pfn_notify,
                                           user_data, errcode_ret);
}

cl_int CL_API_CALL clUnloadPlatformCompiler(cl_platform_id platform)
{
    return cl::GetDispatch().clUnloadPlatformCompiler(platform);
}

cl_int CL_API_CALL clGetKernelArgInfo(cl_kernel kernel,
                                      cl_uint arg_index,
                                      cl_kernel_arg_info param_name,
                                      size_t param_value_size,
                                      void *param_value,
                                      size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetKernelArgInfo(kernel, arg_index, param_name, param_value_size,
                                                param_value, param_value_size_ret);
}

cl_int CL_API_CALL clEnqueueFillBuffer(cl_command_queue command_queue,
                                       cl_mem buffer,
                                       const void *pattern,
                                       size_t pattern_size,
                                       size_t offset,
                                       size_t size,
                                       cl_uint num_events_in_wait_list,
                                       const cl_event *event_wait_list,
                                       cl_event *event)
{
    return cl::GetDispatch().clEnqueueFillBuffer(command_queue, buffer, pattern, pattern_size,
                                                 offset, size, num_events_in_wait_list,
                                                 event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueFillImage(cl_command_queue command_queue,
                                      cl_mem image,
                                      const void *fill_color,
                                      const size_t *origin,
                                      const size_t *region,
                                      cl_uint num_events_in_wait_list,
                                      const cl_event *event_wait_list,
                                      cl_event *event)
{
    return cl::GetDispatch().clEnqueueFillImage(command_queue, image, fill_color, origin, region,
                                                num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueMigrateMemObjects(cl_command_queue command_queue,
                                              cl_uint num_mem_objects,
                                              const cl_mem *mem_objects,
                                              cl_mem_migration_flags flags,
                                              cl_uint num_events_in_wait_list,
                                              const cl_event *event_wait_list,
                                              cl_event *event)
{
    return cl::GetDispatch().clEnqueueMigrateMemObjects(command_queue, num_mem_objects, mem_objects,
                                                        flags, num_events_in_wait_list,
                                                        event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueMarkerWithWaitList(cl_command_queue command_queue,
                                               cl_uint num_events_in_wait_list,
                                               const cl_event *event_wait_list,
                                               cl_event *event)
{
    return cl::GetDispatch().clEnqueueMarkerWithWaitList(command_queue, num_events_in_wait_list,
                                                         event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueBarrierWithWaitList(cl_command_queue command_queue,
                                                cl_uint num_events_in_wait_list,
                                                const cl_event *event_wait_list,
                                                cl_event *event)
{
    return cl::GetDispatch().clEnqueueBarrierWithWaitList(command_queue, num_events_in_wait_list,
                                                          event_wait_list, event);
}

void *CL_API_CALL clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
                                                           const char *func_name)
{
    return cl::GetDispatch().clGetExtensionFunctionAddressForPlatform(platform, func_name);
}

// CL 2.0
cl_command_queue CL_API_CALL
clCreateCommandQueueWithProperties(cl_context context,
                                   cl_device_id device,
                                   const cl_queue_properties *properties,
                                   cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateCommandQueueWithProperties(context, device, properties,
                                                                errcode_ret);
}

cl_mem CL_API_CALL clCreatePipe(cl_context context,
                                cl_mem_flags flags,
                                cl_uint pipe_packet_size,
                                cl_uint pipe_max_packets,
                                const cl_pipe_properties *properties,
                                cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreatePipe(context, flags, pipe_packet_size, pipe_max_packets,
                                          properties, errcode_ret);
}

cl_int CL_API_CALL clGetPipeInfo(cl_mem pipe,
                                 cl_pipe_info param_name,
                                 size_t param_value_size,
                                 void *param_value,
                                 size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetPipeInfo(pipe, param_name, param_value_size, param_value,
                                           param_value_size_ret);
}

void *CL_API_CALL clSVMAlloc(cl_context context,
                             cl_svm_mem_flags flags,
                             size_t size,
                             cl_uint alignment)
{
    return cl::GetDispatch().clSVMAlloc(context, flags, size, alignment);
}

void CL_API_CALL clSVMFree(cl_context context, void *svm_pointer)
{
    return cl::GetDispatch().clSVMFree(context, svm_pointer);
}

cl_sampler CL_API_CALL
clCreateSamplerWithProperties(cl_context context,
                              const cl_sampler_properties *sampler_properties,
                              cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateSamplerWithProperties(context, sampler_properties,
                                                           errcode_ret);
}

cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
                                            cl_uint arg_index,
                                            const void *arg_value)
{
    return cl::GetDispatch().clSetKernelArgSVMPointer(kernel, arg_index, arg_value);
}

cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel,
                                       cl_kernel_exec_info param_name,
                                       size_t param_value_size,
                                       const void *param_value)
{
    return cl::GetDispatch().clSetKernelExecInfo(kernel, param_name, param_value_size, param_value);
}

cl_int CL_API_CALL clEnqueueSVMFree(cl_command_queue command_queue,
                                    cl_uint num_svm_pointers,
                                    void *svm_pointers[],
                                    void(CL_CALLBACK *pfn_free_func)(cl_command_queue queue,
                                                                     cl_uint num_svm_pointers,
                                                                     void *svm_pointers[],
                                                                     void *user_data),
                                    void *user_data,
                                    cl_uint num_events_in_wait_list,
                                    const cl_event *event_wait_list,
                                    cl_event *event)
{
    return cl::GetDispatch().clEnqueueSVMFree(command_queue, num_svm_pointers, svm_pointers,
                                              pfn_free_func, user_data, num_events_in_wait_list,
                                              event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueSVMMemcpy(cl_command_queue command_queue,
                                      cl_bool blocking_copy,
                                      void *dst_ptr,
                                      const void *src_ptr,
                                      size_t size,
                                      cl_uint num_events_in_wait_list,
                                      const cl_event *event_wait_list,
                                      cl_event *event)
{
    return cl::GetDispatch().clEnqueueSVMMemcpy(command_queue, blocking_copy, dst_ptr, src_ptr,
                                                size, num_events_in_wait_list, event_wait_list,
                                                event);
}

cl_int CL_API_CALL clEnqueueSVMMemFill(cl_command_queue command_queue,
                                       void *svm_ptr,
                                       const void *pattern,
                                       size_t pattern_size,
                                       size_t size,
                                       cl_uint num_events_in_wait_list,
                                       const cl_event *event_wait_list,
                                       cl_event *event)
{
    return cl::GetDispatch().clEnqueueSVMMemFill(command_queue, svm_ptr, pattern, pattern_size,
                                                 size, num_events_in_wait_list, event_wait_list,
                                                 event);
}

cl_int CL_API_CALL clEnqueueSVMMap(cl_command_queue command_queue,
                                   cl_bool blocking_map,
                                   cl_map_flags flags,
                                   void *svm_ptr,
                                   size_t size,
                                   cl_uint num_events_in_wait_list,
                                   const cl_event *event_wait_list,
                                   cl_event *event)
{
    return cl::GetDispatch().clEnqueueSVMMap(command_queue, blocking_map, flags, svm_ptr, size,
                                             num_events_in_wait_list, event_wait_list, event);
}

cl_int CL_API_CALL clEnqueueSVMUnmap(cl_command_queue command_queue,
                                     void *svm_ptr,
                                     cl_uint num_events_in_wait_list,
                                     const cl_event *event_wait_list,
                                     cl_event *event)
{
    return cl::GetDispatch().clEnqueueSVMUnmap(command_queue, svm_ptr, num_events_in_wait_list,
                                               event_wait_list, event);
}

// CL 2.1
cl_int CL_API_CALL clSetDefaultDeviceCommandQueue(cl_context context,
                                                  cl_device_id device,
                                                  cl_command_queue command_queue)
{
    return cl::GetDispatch().clSetDefaultDeviceCommandQueue(context, device, command_queue);
}

cl_int CL_API_CALL clGetDeviceAndHostTimer(cl_device_id device,
                                           cl_ulong *device_timestamp,
                                           cl_ulong *host_timestamp)
{
    return cl::GetDispatch().clGetDeviceAndHostTimer(device, device_timestamp, host_timestamp);
}

cl_int CL_API_CALL clGetHostTimer(cl_device_id device, cl_ulong *host_timestamp)
{
    return cl::GetDispatch().clGetHostTimer(device, host_timestamp);
}

cl_program CL_API_CALL clCreateProgramWithIL(cl_context context,
                                             const void *il,
                                             size_t length,
                                             cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateProgramWithIL(context, il, length, errcode_ret);
}

cl_kernel CL_API_CALL clCloneKernel(cl_kernel source_kernel, cl_int *errcode_ret)
{
    return cl::GetDispatch().clCloneKernel(source_kernel, errcode_ret);
}

cl_int CL_API_CALL clGetKernelSubGroupInfo(cl_kernel kernel,
                                           cl_device_id device,
                                           cl_kernel_sub_group_info param_name,
                                           size_t input_value_size,
                                           const void *input_value,
                                           size_t param_value_size,
                                           void *param_value,
                                           size_t *param_value_size_ret)
{
    return cl::GetDispatch().clGetKernelSubGroupInfo(kernel, device, param_name, input_value_size,
                                                     input_value, param_value_size, param_value,
                                                     param_value_size_ret);
}

cl_int CL_API_CALL clEnqueueSVMMigrateMem(cl_command_queue command_queue,
                                          cl_uint num_svm_pointers,
                                          const void **svm_pointers,
                                          const size_t *sizes,
                                          cl_mem_migration_flags flags,
                                          cl_uint num_events_in_wait_list,
                                          const cl_event *event_wait_list,
                                          cl_event *event)
{
    return cl::GetDispatch().clEnqueueSVMMigrateMem(command_queue, num_svm_pointers, svm_pointers,
                                                    sizes, flags, num_events_in_wait_list,
                                                    event_wait_list, event);
}

// CL 2.2
cl_int CL_API_CALL clSetProgramReleaseCallback(cl_program program,
                                               void(CL_CALLBACK *pfn_notify)(cl_program program,
                                                                             void *user_data),
                                               void *user_data)
{
    return cl::GetDispatch().clSetProgramReleaseCallback(program, pfn_notify, user_data);
}

cl_int CL_API_CALL clSetProgramSpecializationConstant(cl_program program,
                                                      cl_uint spec_id,
                                                      size_t spec_size,
                                                      const void *spec_value)
{
    return cl::GetDispatch().clSetProgramSpecializationConstant(program, spec_id, spec_size,
                                                                spec_value);
}

// CL 3.0
cl_int CL_API_CALL clSetContextDestructorCallback(cl_context context,
                                                  void(CL_CALLBACK *pfn_notify)(cl_context context,
                                                                                void *user_data),
                                                  void *user_data)
{
    return cl::GetDispatch().clSetContextDestructorCallback(context, pfn_notify, user_data);
}

cl_mem CL_API_CALL clCreateBufferWithProperties(cl_context context,
                                                const cl_mem_properties *properties,
                                                cl_mem_flags flags,
                                                size_t size,
                                                void *host_ptr,
                                                cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateBufferWithProperties(context, properties, flags, size,
                                                          host_ptr, errcode_ret);
}

cl_mem CL_API_CALL clCreateImageWithProperties(cl_context context,
                                               const cl_mem_properties *properties,
                                               cl_mem_flags flags,
                                               const cl_image_format *image_format,
                                               const cl_image_desc *image_desc,
                                               void *host_ptr,
                                               cl_int *errcode_ret)
{
    return cl::GetDispatch().clCreateImageWithProperties(context, properties, flags, image_format,
                                                         image_desc, host_ptr, errcode_ret);
}

// cl_khr_icd
cl_int CL_API_CALL clIcdGetPlatformIDsKHR(cl_uint num_entries,
                                          cl_platform_id *platforms,
                                          cl_uint *num_platforms)
{
    return cl::GetDispatch().clIcdGetPlatformIDsKHR(num_entries, platforms, num_platforms);
}

}  // extern "C"
