Initial commit

Change-Id: I4bf1707bd3dfeadf2c17b0a7daff372b1925ebbd
This commit is contained in:
Brandon Fliflet
2017-12-21 00:45:38 +01:00
commit 7e9ad41290
1350 changed files with 233156 additions and 0 deletions

View File

@ -0,0 +1,31 @@
# Copyright (c) 2017, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# We require cmake 3.2.0 or later
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
set (RUNTIME_SRCS_API
${CMAKE_CURRENT_SOURCE_DIR}/api.cpp
${CMAKE_CURRENT_SOURCE_DIR}/api.h
${CMAKE_CURRENT_SOURCE_DIR}/cl_types.h
${CMAKE_CURRENT_SOURCE_DIR}/dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dispatch.h
PARENT_SCOPE
)

3760
runtime/api/api.cpp Normal file

File diff suppressed because it is too large Load Diff

887
runtime/api/api.h Normal file
View File

@ -0,0 +1,887 @@
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
#include "CL/cl.h"
#include "CL/cl_gl.h"
#include "runtime/api/dispatch.h"
#ifdef __cplusplus
extern "C" {
#endif
cl_int CL_API_CALL clGetPlatformIDs(
cl_uint numEntries,
cl_platform_id *platforms,
cl_uint *numPlatforms);
cl_int CL_API_CALL clGetPlatformInfo(
cl_platform_id platform,
cl_platform_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetDeviceIDs(
cl_platform_id platform,
cl_device_type deviceType,
cl_uint numEntries,
cl_device_id *devices,
cl_uint *numDevices);
cl_int CL_API_CALL clGetDeviceInfo(
cl_device_id device,
cl_device_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clCreateSubDevices(
cl_device_id inDevice,
const cl_device_partition_property *properties,
cl_uint numDevices,
cl_device_id *outDevices,
cl_uint *numDevicesRet);
cl_int CL_API_CALL clRetainDevice(
cl_device_id device);
cl_int CL_API_CALL clReleaseDevice(
cl_device_id device);
cl_context CL_API_CALL clCreateContext(
const cl_context_properties *properties,
cl_uint numDevices,
const cl_device_id *devices,
void(CL_CALLBACK *funcNotify)(const char *, const void *, size_t, void *),
void *userData,
cl_int *errcodeRet);
cl_context CL_API_CALL clCreateContextFromType(
const cl_context_properties *properties,
cl_device_type deviceType,
void(CL_CALLBACK *funcNotify)(const char *, const void *, size_t, void *),
void *userData,
cl_int *errcodeRet);
cl_int CL_API_CALL clRetainContext(
cl_context context);
cl_int CL_API_CALL clReleaseContext(
cl_context context);
cl_int CL_API_CALL clGetContextInfo(
cl_context context,
cl_context_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetGLContextInfoKHR(
const cl_context_properties *properties,
cl_gl_context_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_command_queue CL_API_CALL clCreateCommandQueue(
cl_context context,
cl_device_id device,
cl_command_queue_properties properties,
cl_int *errcodeRet);
cl_int CL_API_CALL clRetainCommandQueue(
cl_command_queue commandQueue);
cl_int CL_API_CALL clReleaseCommandQueue(
cl_command_queue commandQueue);
cl_int CL_API_CALL clGetCommandQueueInfo(
cl_command_queue commandQueue,
cl_command_queue_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
// deprecated OpenCL 1.0
cl_int CL_API_CALL clSetCommandQueueProperty(
cl_command_queue commandQueue,
cl_command_queue_properties properties,
cl_bool enable,
cl_command_queue_properties *oldProperties);
cl_mem CL_API_CALL clCreateBuffer(
cl_context context,
cl_mem_flags flags,
size_t size,
void *hostPtr,
cl_int *errcodeRet);
cl_mem CL_API_CALL clCreateSubBuffer(
cl_mem buffer,
cl_mem_flags flags,
cl_buffer_create_type bufferCreateType,
const void *bufferCreateInfo,
cl_int *errcodeRet);
cl_mem CL_API_CALL clCreateImage(
cl_context context,
cl_mem_flags flags,
const cl_image_format *imageFormat,
const cl_image_desc *imageDesc,
void *hostPtr,
cl_int *errcodeRet);
// deprecated OpenCL 1.1
cl_mem CL_API_CALL clCreateImage2D(
cl_context context,
cl_mem_flags flags,
const cl_image_format *imageFormat,
size_t imageWidth,
size_t imageHeight,
size_t imageRowPitch,
void *hostPtr,
cl_int *errcodeRet);
// deprecated OpenCL 1.1
cl_mem CL_API_CALL clCreateImage3D(
cl_context context,
cl_mem_flags flags,
const cl_image_format *imageFormat,
size_t imageWidth,
size_t imageHeight,
size_t imageDepth,
size_t imageRowPitch,
size_t imageSlicePitch,
void *hostPtr,
cl_int *errcodeRet);
cl_int CL_API_CALL clRetainMemObject(
cl_mem memobj);
cl_int CL_API_CALL clReleaseMemObject(
cl_mem memobj);
cl_int CL_API_CALL clGetSupportedImageFormats(
cl_context context,
cl_mem_flags flags,
cl_mem_object_type imageType,
cl_uint numEntries,
cl_image_format *imageFormats,
cl_uint *numImageFormats);
cl_int CL_API_CALL clGetMemObjectInfo(
cl_mem memobj,
cl_mem_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetImageInfo(
cl_mem image,
cl_image_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetImageParamsINTEL(
cl_context context,
const cl_image_format *imageFormat,
const cl_image_desc *imageDesc,
size_t *imageRowPitch,
size_t *imageSlicePitch);
cl_int CL_API_CALL clSetMemObjectDestructorCallback(
cl_mem memobj,
void(CL_CALLBACK *funcNotify)(cl_mem, void *),
void *userData);
cl_sampler CL_API_CALL clCreateSampler(
cl_context context,
cl_bool normalizedCoords,
cl_addressing_mode addressingMode,
cl_filter_mode filterMode,
cl_int *errcodeRet);
cl_int CL_API_CALL clRetainSampler(
cl_sampler sampler);
cl_int CL_API_CALL clReleaseSampler(
cl_sampler sampler);
cl_int CL_API_CALL clGetSamplerInfo(
cl_sampler sampler,
cl_sampler_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_program CL_API_CALL clCreateProgramWithSource(
cl_context context,
cl_uint count,
const char **strings,
const size_t *lengths,
cl_int *errcodeRet);
cl_program CL_API_CALL clCreateProgramWithBinary(
cl_context context,
cl_uint numDevices,
const cl_device_id *deviceList,
const size_t *lengths,
const unsigned char **binaries,
cl_int *binaryStatus,
cl_int *errcodeRet);
cl_program CL_API_CALL clCreateProgramWithBuiltInKernels(
cl_context context,
cl_uint numDevices,
const cl_device_id *deviceList,
const char *kernelNames,
cl_int *errcodeRet);
cl_int CL_API_CALL clRetainProgram(
cl_program program);
cl_int CL_API_CALL clReleaseProgram(
cl_program program);
cl_int CL_API_CALL clBuildProgram(
cl_program program,
cl_uint numDevices,
const cl_device_id *deviceList,
const char *options,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData);
cl_int CL_API_CALL clCompileProgram(
cl_program program,
cl_uint numDevices,
const cl_device_id *deviceList,
const char *options,
cl_uint numInputHeaders,
const cl_program *inputHeaders,
const char **headerIncludeNames,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData);
cl_program CL_API_CALL clLinkProgram(
cl_context context,
cl_uint numDevices,
const cl_device_id *deviceList,
const char *options,
cl_uint numInputPrograms,
const cl_program *inputPrograms,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData,
cl_int *errcodeRet);
cl_int CL_API_CALL clUnloadPlatformCompiler(
cl_platform_id platform);
// deprecated OpenCL 1.1
cl_int CL_API_CALL clUnloadCompiler(void);
cl_int CL_API_CALL clGetProgramInfo(
cl_program program,
cl_program_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetProgramBuildInfo(
cl_program program,
cl_device_id device,
cl_program_build_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_kernel CL_API_CALL clCreateKernel(
cl_program program,
const char *kernelName,
cl_int *errcodeRet);
cl_int CL_API_CALL clCreateKernelsInProgram(
cl_program program,
cl_uint numKernels,
cl_kernel *kernels,
cl_uint *numKernelsRet);
cl_int CL_API_CALL clRetainKernel(
cl_kernel kernel);
cl_int CL_API_CALL clReleaseKernel(
cl_kernel kernel);
cl_int CL_API_CALL clSetKernelArg(
cl_kernel kernel,
cl_uint argIndex,
size_t argSize,
const void *argValue);
cl_int CL_API_CALL clGetKernelInfo(
cl_kernel kernel,
cl_kernel_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetKernelArgInfo(
cl_kernel kernel,
cl_uint argIndx,
cl_kernel_arg_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clGetKernelWorkGroupInfo(
cl_kernel kernel,
cl_device_id device,
cl_kernel_work_group_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clWaitForEvents(
cl_uint numEvents,
const cl_event *eventList);
cl_int CL_API_CALL clGetEventInfo(
cl_event event,
cl_event_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_event CL_API_CALL clCreateUserEvent(
cl_context context,
cl_int *errcodeRet);
cl_int CL_API_CALL clRetainEvent(
cl_event event);
cl_int CL_API_CALL clReleaseEvent(
cl_event event);
cl_int CL_API_CALL clSetUserEventStatus(
cl_event event,
cl_int executionStatus);
cl_int CL_API_CALL clSetEventCallback(
cl_event event,
cl_int commandExecCallbackType,
void(CL_CALLBACK *funcNotify)(cl_event, cl_int, void *),
void *userData);
cl_int CL_API_CALL clGetEventProfilingInfo(
cl_event event,
cl_profiling_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clFlush(
cl_command_queue commandQueue);
cl_int CL_API_CALL clFinish(
cl_command_queue commandQueue);
cl_int CL_API_CALL clEnqueueReadBuffer(
cl_command_queue commandQueue,
cl_mem buffer,
cl_bool blockingRead,
size_t offset,
size_t cb,
void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueReadBufferRect(
cl_command_queue commandQueue,
cl_mem buffer,
cl_bool blockingRead,
const size_t *bufferOrigin,
const size_t *hostOrigin,
const size_t *region,
size_t bufferRowPitch,
size_t bufferSlicePitch,
size_t hostRowPitch,
size_t hostSlicePitch,
void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueWriteBuffer(
cl_command_queue commandQueue,
cl_mem buffer,
cl_bool blockingWrite,
size_t offset,
size_t cb,
const void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueWriteBufferRect(
cl_command_queue commandQueue,
cl_mem buffer,
cl_bool blockingWrite,
const size_t *bufferOrigin,
const size_t *hostOrigin,
const size_t *region,
size_t bufferRowPitch,
size_t bufferSlicePitch,
size_t hostRowPitch,
size_t hostSlicePitch,
const void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueFillBuffer(
cl_command_queue commandQueue,
cl_mem buffer,
const void *pattern,
size_t patternSize,
size_t offset,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueCopyBuffer(
cl_command_queue commandQueue,
cl_mem srcBuffer,
cl_mem dstBuffer,
size_t srcOffset,
size_t dstOffset,
size_t cb,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueCopyBufferRect(
cl_command_queue commandQueue,
cl_mem srcBuffer,
cl_mem dstBuffer,
const size_t *srcOrigin,
const size_t *dstOrigin,
const size_t *region,
size_t srcRowPitch,
size_t srcSlicePitch,
size_t dstRowPitch,
size_t dstSlicePitch,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueReadImage(
cl_command_queue commandQueue,
cl_mem image,
cl_bool blockingRead,
const size_t *origin,
const size_t *region,
size_t rowPitch,
size_t slicePitch,
void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueWriteImage(
cl_command_queue commandQueue,
cl_mem image,
cl_bool blockingWrite,
const size_t *origin,
const size_t *region,
size_t inputRowPitch,
size_t inputSlicePitch,
const void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueFillImage(
cl_command_queue commandQueue,
cl_mem image,
const void *fillColor,
const size_t *origin,
const size_t *region,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueCopyImage(
cl_command_queue commandQueue,
cl_mem srcImage,
cl_mem dstImage,
const size_t *srcOrigin,
const size_t *dstOrigin,
const size_t *region,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueCopyImageToBuffer(
cl_command_queue commandQueue,
cl_mem srcImage,
cl_mem dstBuffer,
const size_t *srcOrigin,
const size_t *region,
size_t dstOffset,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueCopyBufferToImage(
cl_command_queue commandQueue,
cl_mem srcBuffer,
cl_mem dstImage,
size_t srcOffset,
const size_t *dstOrigin,
const size_t *region,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
void *CL_API_CALL clEnqueueMapBuffer(
cl_command_queue commandQueue,
cl_mem buffer,
cl_bool blockingMap,
cl_map_flags mapFlags,
size_t offset,
size_t cb,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event,
cl_int *errcodeRet);
void *CL_API_CALL clEnqueueMapImage(
cl_command_queue commandQueue,
cl_mem image,
cl_bool blockingMap,
cl_map_flags mapFlags,
const size_t *origin,
const size_t *region,
size_t *imageRowPitch,
size_t *imageSlicePitch,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event,
cl_int *errcodeRet);
cl_int CL_API_CALL clEnqueueUnmapMemObject(
cl_command_queue commandQueue,
cl_mem memobj,
void *mappedPtr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueMigrateMemObjects(
cl_command_queue commandQueue,
cl_uint numMemObjects,
const cl_mem *memObjects,
cl_mem_migration_flags flags,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueNDRangeKernel(
cl_command_queue commandQueue,
cl_kernel kernel,
cl_uint workDim,
const size_t *globalWorkOffset,
const size_t *globalWorkSize,
const size_t *localWorkSize,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueTask(
cl_command_queue commandQueue,
cl_kernel kernel,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueNativeKernel(
cl_command_queue commandQueue,
void(CL_CALLBACK *userFunc)(void *),
void *args,
size_t cbArgs,
cl_uint numMemObjects,
const cl_mem *memList,
const void **argsMemLoc,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
// deprecated OpenCL 1.1
cl_int CL_API_CALL clEnqueueMarker(
cl_command_queue commandQueue,
cl_event *event);
// deprecated OpenCL 1.1
cl_int CL_API_CALL clEnqueueWaitForEvents(
cl_command_queue commandQueue,
cl_uint numEvents,
const cl_event *eventList);
// deprecated OpenCL 1.1
cl_int CL_API_CALL clEnqueueBarrier(
cl_command_queue commandQueue);
cl_int CL_API_CALL clEnqueueMarkerWithWaitList(
cl_command_queue commandQueue,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueBarrierWithWaitList(
cl_command_queue commandQueue,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
// deprecated OpenCL 1.1
void *CL_API_CALL clGetExtensionFunctionAddress(
const char *funcName);
void *CL_API_CALL clGetExtensionFunctionAddressForPlatform(
cl_platform_id platform,
const char *funcName);
// CL-GL Sharing
cl_mem CL_API_CALL clCreateFromGLBuffer(
cl_context context,
cl_mem_flags flags,
cl_GLuint bufobj,
int *errcodeRet);
// OpenCL 1.2
cl_mem CL_API_CALL clCreateFromGLTexture(
cl_context context,
cl_mem_flags flags,
cl_GLenum target,
cl_GLint miplevel,
cl_GLuint texture,
cl_int *errcodeRet);
// deprecated OpenCL 1.1
cl_mem CL_API_CALL clCreateFromGLTexture2D(
cl_context context,
cl_mem_flags flags,
cl_GLenum target,
cl_GLint miplevel,
cl_GLuint texture,
cl_int *errcodeRet);
// deprecated OpenCL 1.1
cl_mem CL_API_CALL clCreateFromGLTexture3D(
cl_context context,
cl_mem_flags flags,
cl_GLenum target,
cl_GLint miplevel,
cl_GLuint texture,
cl_int *errcodeRet);
cl_mem CL_API_CALL clCreateFromGLRenderbuffer(
cl_context context,
cl_mem_flags flags,
cl_GLuint renderbuffer,
cl_int *errcodeRet);
cl_int CL_API_CALL clGetGLObjectInfo(
cl_mem memobj,
cl_gl_object_type *glObjectType,
cl_GLuint *glObjectName);
cl_int CL_API_CALL clGetGLTextureInfo(
cl_mem memobj,
cl_gl_texture_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_int CL_API_CALL clEnqueueAcquireGLObjects(
cl_command_queue commandQueue,
cl_uint numObjects,
const cl_mem *memObjects,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueReleaseGLObjects(
cl_command_queue commandQueue,
cl_uint numObjects,
const cl_mem *memObjects,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
// OpenCL 2.0
void *CL_API_CALL clSVMAlloc(
cl_context context,
cl_svm_mem_flags flags,
size_t size,
cl_uint alignment);
void CL_API_CALL clSVMFree(
cl_context context,
void *svmPointer);
cl_int CL_API_CALL clEnqueueSVMFree(
cl_command_queue commandQueue,
cl_uint numSvmPointers,
void *svmPointers[],
void(CL_CALLBACK *pfnFreeFunc)(
cl_command_queue queue,
cl_uint numSvmPointers,
void *svmPointers[],
void *userData),
void *userData,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueSVMMemcpy(
cl_command_queue commandQueue,
cl_bool blockingCopy,
void *dstPtr,
const void *srcPtr,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueSVMMemFill(
cl_command_queue commandQueue,
void *svmPtr,
const void *pattern,
size_t patternSize,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueSVMMap(
cl_command_queue commandQueue,
cl_bool blockingMap,
cl_map_flags mapFlags,
void *svmPtr,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clEnqueueSVMUnmap(
cl_command_queue commandQueue,
void *svmPtr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int CL_API_CALL clSetKernelArgSVMPointer(
cl_kernel kernel,
cl_uint argIndex,
const void *argValue);
cl_int CL_API_CALL clSetKernelExecInfo(
cl_kernel kernel,
cl_kernel_exec_info paramName,
size_t paramValueSize,
const void *paramValue);
cl_mem CL_API_CALL clCreatePipe(
cl_context context,
cl_mem_flags flags,
cl_uint pipePacketSize,
cl_uint pipeMaxPackets,
const cl_pipe_properties *properties,
cl_int *errcodeRet);
cl_int CL_API_CALL clGetPipeInfo(
cl_mem pipe,
cl_pipe_info paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet);
cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties(
cl_context context,
cl_device_id device,
const cl_queue_properties *properties,
cl_int *errcodeRet);
cl_command_queue CL_API_CALL clCreateCommandQueueWithPropertiesINTEL(
cl_context context,
cl_device_id device,
const cl_queue_properties_intel *properties,
cl_int *errcodeRet);
cl_sampler CL_API_CALL clCreateSamplerWithProperties(
cl_context context,
const cl_sampler_properties *samplerProperties,
cl_int *errcodeRet);
// OpenCL 2.1
cl_int CL_API_CALL clGetDeviceAndHostTimer(cl_device_id device,
cl_ulong *deviceTimestamp,
cl_ulong *hostTimestamp);
cl_int CL_API_CALL clGetHostTimer(cl_device_id device,
cl_ulong *hostTimestamp);
extern CL_API_ENTRY cl_command_queue CL_API_CALL
clCreatePerfCountersCommandQueueINTEL(
cl_context context,
cl_device_id device,
cl_command_queue_properties properties,
cl_uint configuration,
cl_int *errcodeRet);
extern CL_API_ENTRY cl_int CL_API_CALL
clSetPerformanceConfigurationINTEL(
cl_device_id device,
cl_uint count,
cl_uint *offsets,
cl_uint *values);
extern CL_API_ENTRY cl_event CL_API_CALL
clCreateEventFromGLsyncKHR(
cl_context context,
cl_GLsync sync,
cl_int *errcodeRet) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithILKHR(
cl_context context,
const void *il,
size_t length,
cl_int *errcodeRet) CL_API_SUFFIX__VERSION_1_2;
}

75
runtime/api/cl_types.h Normal file
View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "config.h"
#include "CL/cl.h"
#include "runtime/api/dispatch.h"
#include <cstdint>
struct ClDispatch {
SEntryPointsTable dispatch;
ClDispatch() : dispatch(globalDispatchTable) {
}
};
struct _cl_accelerator_intel : public ClDispatch {
};
struct _cl_command_queue : public ClDispatch {
};
// device_queue is a type used internally
struct _device_queue : public _cl_command_queue {
};
typedef _device_queue *device_queue;
struct _cl_context : public ClDispatch {
bool isSharedContext = false;
};
struct _cl_device_id : public ClDispatch {
};
struct _cl_event : public ClDispatch {
};
struct _cl_kernel : public ClDispatch {
};
struct _cl_mem : public ClDispatch {
};
struct _cl_platform_id : public ClDispatch {
};
struct _cl_program : public ClDispatch {
};
struct _cl_sampler : public ClDispatch {
};
template <typename Type>
inline bool isValidObject(Type object) {
return object && object->dispatch.icdDispatch == &icdGlobalDispatchTable;
}

226
runtime/api/dispatch.cpp Normal file
View File

@ -0,0 +1,226 @@
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "dispatch.h"
#include "api.h"
SDispatchTable icdGlobalDispatchTable =
{
clGetPlatformIDs,
clGetPlatformInfo,
clGetDeviceIDs,
clGetDeviceInfo,
clCreateContext,
clCreateContextFromType,
clRetainContext,
clReleaseContext,
clGetContextInfo,
clCreateCommandQueue,
clRetainCommandQueue,
clReleaseCommandQueue,
clGetCommandQueueInfo,
clSetCommandQueueProperty,
clCreateBuffer,
clCreateImage2D,
clCreateImage3D,
clRetainMemObject,
clReleaseMemObject,
clGetSupportedImageFormats,
clGetMemObjectInfo,
clGetImageInfo,
clCreateSampler,
clRetainSampler,
clReleaseSampler,
clGetSamplerInfo,
clCreateProgramWithSource,
clCreateProgramWithBinary,
clRetainProgram,
clReleaseProgram,
clBuildProgram,
clUnloadCompiler,
clGetProgramInfo,
clGetProgramBuildInfo,
clCreateKernel,
clCreateKernelsInProgram,
clRetainKernel,
clReleaseKernel,
clSetKernelArg,
clGetKernelInfo,
clGetKernelWorkGroupInfo,
clWaitForEvents,
clGetEventInfo,
clRetainEvent,
clReleaseEvent,
clGetEventProfilingInfo,
clFlush,
clFinish,
clEnqueueReadBuffer,
clEnqueueWriteBuffer,
clEnqueueCopyBuffer,
clEnqueueReadImage,
clEnqueueWriteImage,
clEnqueueCopyImage,
clEnqueueCopyImageToBuffer,
clEnqueueCopyBufferToImage,
clEnqueueMapBuffer,
clEnqueueMapImage,
clEnqueueUnmapMemObject,
clEnqueueNDRangeKernel,
clEnqueueTask,
clEnqueueNativeKernel,
clEnqueueMarker,
clEnqueueWaitForEvents,
clEnqueueBarrier,
clGetExtensionFunctionAddress,
/* cl_khr_gl_sharing */
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
/* cl_khr_d3d10_sharing */
nullptr, // clGetDeviceIDsFromD3D10KHR,
nullptr, // clCreateFromD3D10BufferKHR,
nullptr, // clCreateFromD3D10Texture2DKHR,
nullptr, // clCreateFromD3D10Texture3DKHR,
nullptr, // clEnqueueAcquireD3D10ObjectsKHR,
nullptr, // clEnqueueReleaseD3D10ObjectsKHR,
/* OpenCL 1.1 */
clSetEventCallback,
clCreateSubBuffer,
clSetMemObjectDestructorCallback,
clCreateUserEvent,
clSetUserEventStatus,
clEnqueueReadBufferRect,
clEnqueueWriteBufferRect,
clEnqueueCopyBufferRect,
/* cl_ext_device_fission */
nullptr, //clCreateSubDevicesEXT,
nullptr, //clRetainDeviceEXT,
nullptr, //clReleaseDeviceEXT,
/* cl_khr_gl_event */
nullptr,
/* OpenCL 1.2 */
clCreateSubDevices,
clRetainDevice,
clReleaseDevice,
clCreateImage,
clCreateProgramWithBuiltInKernels,
clCompileProgram,
clLinkProgram,
clUnloadPlatformCompiler,
clGetKernelArgInfo,
clEnqueueFillBuffer,
clEnqueueFillImage,
clEnqueueMigrateMemObjects,
clEnqueueMarkerWithWaitList,
clEnqueueBarrierWithWaitList,
clGetExtensionFunctionAddressForPlatform,
nullptr,
/* cl_khr_d3d11_sharing */
nullptr, // clGetDeviceIDsFromD3D11KHR,
nullptr, // clCreateFromD3D11BufferKHR,
nullptr, // clCreateFromD3D11Texture2DKHR,
nullptr, // clCreateFromD3D11Texture3DKHR,
nullptr, // clCreateFromDX9MediaSurfaceKHR,
nullptr, // clEnqueueAcquireD3D11ObjectsKHR,
nullptr, // clEnqueueReleaseD3D11ObjectsKHR,
/* cl_khr_dx9_media_sharing */
nullptr, // clGetDeviceIDsFromDX9MediaAdapterKHR,
nullptr, // clEnqueueAcquireDX9MediaSurfacesKHR,
nullptr, // clEnqueueReleaseDX9MediaSurfacesKHR,
/* cl_khr_egl_image */
nullptr, //clCreateFromEGLImageKHR,
nullptr, //clEnqueueAcquireEGLObjectsKHR,
nullptr, //clEnqueueReleaseEGLObjectsKHR,
/* cl_khr_egl_event */
nullptr, //clCreateEventFromEGLSyncKHR,
/* OpenCL 2.0 */
clCreateCommandQueueWithProperties,
clCreatePipe,
clGetPipeInfo,
clSVMAlloc,
clSVMFree,
clEnqueueSVMFree,
clEnqueueSVMMemcpy,
clEnqueueSVMMemFill,
clEnqueueSVMMap,
clEnqueueSVMUnmap,
clCreateSamplerWithProperties,
clSetKernelArgSVMPointer,
clSetKernelExecInfo,
clGetKernelSubGroupInfoKHR,
/* OpenCL 2.1 */
clCloneKernel,
clCreateProgramWithIL,
clEnqueueSVMMigrateMem,
clGetDeviceAndHostTimer,
clGetHostTimer,
clGetKernelSubGroupInfo,
clSetDefaultDeviceCommandQueue,
};
SCRTDispatchTable crtGlobalDispatchTable = {
clGetKernelArgInfo,
nullptr, // clGetDeviceIDsFromDX9INTEL,
nullptr, // clCreateFromDX9MediaSurfaceINTEL,
nullptr, // clEnqueueAcquireDX9ObjectsINTEL,
nullptr, // clEnqueueReleaseDX9ObjectsINTEL,
clGetImageParamsINTEL,
clCreatePerfCountersCommandQueueINTEL,
clCreateAcceleratorINTEL,
clGetAcceleratorInfoINTEL,
clRetainAcceleratorINTEL,
clReleaseAcceleratorINTEL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
clSetPerformanceConfigurationINTEL};
SEntryPointsTable globalDispatchTable = {&icdGlobalDispatchTable, &crtGlobalDispatchTable};

1304
runtime/api/dispatch.h Normal file

File diff suppressed because it is too large Load Diff