[Beignet] [PATCH 24/57] Add khr_icd define to runtime.

junyan.he at inbox.com junyan.he at inbox.com
Sun Jun 11 05:50:10 UTC 2017


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 runtime/cl_khr_icd.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++
 runtime/cl_khr_icd.h |  32 +++++++++
 2 files changed, 226 insertions(+)
 create mode 100644 runtime/cl_khr_icd.c
 create mode 100644 runtime/cl_khr_icd.h

diff --git a/runtime/cl_khr_icd.c b/runtime/cl_khr_icd.c
new file mode 100644
index 0000000..b0f08ad
--- /dev/null
+++ b/runtime/cl_khr_icd.c
@@ -0,0 +1,194 @@
+/* 
+ * Copyright © 2013 Simon Richter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <ocl_icd.h>
+
+#include "cl_platform_id.h"
+#include "CL/cl_intel.h" // for clGetKernelSubGroupInfoKHR
+/* The interop functions are only available if sharing is enabled */
+#ifdef HAS_GL_EGL
+#define CL_GL_INTEROP(x) x
+#else
+#define CL_GL_INTEROP(x) (void *)NULL
+#endif
+/* These are not yet implemented in Beignet */
+#define CL_NOTYET(x) (void *)NULL
+
+/** Return platform list through ICD interface
+ * This code is used only if a client is linked directly against the library
+ * instead of using the ICD loader. In this case, no other implementations
+ * should exist in the process address space, so the call is equivalent to
+ * clGetPlatformIDs().
+ *
+ * @param[in]   num_entries     Number of entries allocated in return buffer
+ * @param[out]  platforms       Platform identifiers supported by this implementation
+ * @param[out]  num_platforms   Number of platform identifiers returned
+ * @return      OpenCL error code
+ * @retval      CL_SUCCESS                      Successful execution
+ * @retval      CL_PLATFORM_NOT_FOUND_KHR       No platforms provided
+ * @retval      CL_INVALID_VALUE                Invalid parameters
+ */
+cl_int
+clIcdGetPlatformIDsKHR(cl_uint num_entries,
+                       cl_platform_id *platforms,
+                       cl_uint *num_platforms)
+{
+  return clGetPlatformIDs(num_entries, platforms, num_platforms);
+}
+
+struct _cl_icd_dispatch const cl_khr_icd_dispatch = {
+  clGetPlatformIDs,
+  clGetPlatformInfo,
+  clGetDeviceIDs,
+  clGetDeviceInfo,
+  clCreateContext,
+  clCreateContextFromType,
+  clRetainContext,
+  clReleaseContext,
+  clGetContextInfo,
+  clCreateCommandQueue,
+  clRetainCommandQueue,
+  clReleaseCommandQueue,
+  clGetCommandQueueInfo,
+  (void *)NULL, /* 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_GL_INTEROP(clCreateFromGLBuffer),
+  CL_GL_INTEROP(clCreateFromGLTexture2D),
+  CL_NOTYET(clCreateFromGLTexture3D),
+  CL_NOTYET(clCreateFromGLRenderbuffer),
+  CL_NOTYET(clGetGLObjectInfo),
+  CL_NOTYET(clGetGLTextureInfo),
+  CL_GL_INTEROP(clEnqueueAcquireGLObjects),
+  CL_GL_INTEROP(clEnqueueReleaseGLObjects),
+  CL_NOTYET(clGetGLContextInfoKHR),
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  clSetEventCallback,
+  clCreateSubBuffer,
+  clSetMemObjectDestructorCallback,
+  clCreateUserEvent,
+  clSetUserEventStatus,
+  clEnqueueReadBufferRect,
+  clEnqueueWriteBufferRect,
+  clEnqueueCopyBufferRect,
+  CL_NOTYET(clCreateSubDevicesEXT),
+  CL_NOTYET(clRetainDeviceEXT),
+  CL_NOTYET(clReleaseDeviceEXT),
+#ifdef CL_VERSION_1_2
+  (void *)NULL,
+  clCreateSubDevices,
+  clRetainDevice,
+  clReleaseDevice,
+  clCreateImage,
+  clCreateProgramWithBuiltInKernels,
+  clCompileProgram,
+  clLinkProgram,
+  clUnloadPlatformCompiler,
+  clGetKernelArgInfo,
+  clEnqueueFillBuffer,
+  clEnqueueFillImage,
+  clEnqueueMigrateMemObjects,
+  clEnqueueMarkerWithWaitList,
+  clEnqueueBarrierWithWaitList,
+  clGetExtensionFunctionAddressForPlatform,
+  CL_GL_INTEROP(clCreateFromGLTexture),
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+  (void *)NULL,
+#endif
+#ifdef CL_VERSION_2_0
+  clCreateCommandQueueWithProperties,
+  clCreatePipe,
+  clGetPipeInfo,
+  clSVMAlloc,
+  clSVMFree,
+  clEnqueueSVMFree,
+  clEnqueueSVMMemcpy,
+  clEnqueueSVMMemFill,
+  clEnqueueSVMMap,
+  clEnqueueSVMUnmap,
+  clCreateSamplerWithProperties,
+  clSetKernelArgSVMPointer,
+  clSetKernelExecInfo,
+  clGetKernelSubGroupInfoKHR,
+#endif
+};
diff --git a/runtime/cl_khr_icd.h b/runtime/cl_khr_icd.h
new file mode 100644
index 0000000..58cee68
--- /dev/null
+++ b/runtime/cl_khr_icd.h
@@ -0,0 +1,32 @@
+/* 
+ * Copyright © 2013 Simon Richter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __CL_KHR_ICD_H__
+#define __CL_KHR_ICD_H__
+
+#ifdef HAS_OCLIcd
+
+#define SET_ICD(dispatch) \
+  dispatch = &cl_khr_icd_dispatch;
+#define DEFINE_ICD(member) struct _cl_icd_dispatch const *member;
+
+extern struct _cl_icd_dispatch const cl_khr_icd_dispatch;
+#else
+#define SET_ICD(dispatch)
+#define DEFINE_ICD(member)
+#endif
+
+#endif
-- 
2.7.4





More information about the Beignet mailing list