Add support for OpenCL 3.0 Provisional (#108)
authorAlastair Murray <alastair.murray@codeplay.com>
Thu, 7 May 2020 22:23:33 +0000 (23:23 +0100)
committerGitHub <noreply@github.com>
Thu, 7 May 2020 22:23:33 +0000 (15:23 -0700)
* Add support for experimental entry points

The new entry points will only be enabled if `CL_EXPERIMENTAL` is manually set.

* Update experimental implementation points to 3.0 provisional

* Use configure_file to selectively include symbols

CMakeLists.txt
loader/icd_dispatch.c
loader/linux/icd_exports.map [deleted file]
loader/linux/icd_exports.map.in [new file with mode: 0644]
loader/windows/OpenCL.def [deleted file]
loader/windows/OpenCL.def.in [new file with mode: 0644]
test/driver_stub/cl.c
test/driver_stub/icd.c
test/driver_stub/rename_api.h
test/loader_test/param_struct.h
test/loader_test/test_create_calls.c

index 9e2d7df84a3e1ca30cb913e9269990d1b47970b6..f9f43585be04fcfcb93bc3693fc0faed17832c19 100644 (file)
@@ -34,6 +34,11 @@ find_package (Threads REQUIRED)
 # advance. Use it with discretion.
 option (BUILD_SHARED_LIBS "Build shared libs" ON)
 
+# This option enables support for OpenCL 3.0 Provisional in the ICD loader.  It
+# is currently off by default while the specification is provisional, as it may
+# change.
+option (ENABLE_OPENCL30_PROVISIONAL "Enable 3.0 provisional entry points" OFF)
+
 include(CheckFunctionExists)
 check_function_exists(secure_getenv HAVE_SECURE_GETENV)
 check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
@@ -49,6 +54,17 @@ set (OPENCL_ICD_LOADER_SOURCES
     loader/icd_platform.h)
 
 if (WIN32)
+    # By default don't include OpenCL 3.0 symbol definitions (i.e. comment them
+    # out), but include them for OpenCL 3.0 builds.  Once the symbols are no
+    # longer provisional then they may be included unconditionally.
+    set(ENABLE_OPENCL30_SYMBOLS ";")
+    if (ENABLE_OPENCL30_PROVISIONAL)
+      set(ENABLE_OPENCL30_SYMBOLS "")
+    endif ()
+    configure_file(
+        ${CMAKE_CURRENT_SOURCE_DIR}/loader/windows/OpenCL.def.in
+        ${CMAKE_CURRENT_BINARY_DIR}/loader/windows/OpenCL.def)
+
     list (APPEND OPENCL_ICD_LOADER_SOURCES 
         loader/windows/adapter.h
         loader/windows/icd_windows.c
@@ -60,7 +76,7 @@ if (WIN32)
         loader/windows/icd_windows_hkr.h
         loader/windows/icd_windows_apppackage.cpp
         loader/windows/icd_windows_apppackage.h
-        loader/windows/OpenCL.def
+        ${CMAKE_CURRENT_BINARY_DIR}/loader/windows/OpenCL.def
         loader/windows/OpenCL.rc)
     # Only add the DXSDK include directory if the environment variable is
     # defined.  Since the DXSDK has merged into the Windows SDK, this is
@@ -69,10 +85,23 @@ if (WIN32)
         include_directories ($ENV{DXSDK_DIR}/Include)
     endif ()
 else ()
+    # By default don't include OpenCL 3.0 symbol definitions (i.e. comment them
+    # out), but include them for OpenCL 3.0 builds.  Once the symbols are no
+    # longer provisional then they may be included unconditionally.
+    set(ENABLE_OPENCL30_SYMBOLS_START "/*")
+    set(ENABLE_OPENCL30_SYMBOLS_END "*/")
+    if (ENABLE_OPENCL30_PROVISIONAL)
+      set(ENABLE_OPENCL30_SYMBOLS_START "")
+      set(ENABLE_OPENCL30_SYMBOLS_END "")
+    endif ()
+    configure_file(
+        ${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map.in
+        ${CMAKE_CURRENT_BINARY_DIR}/loader/linux/icd_exports.map)
+
     list (APPEND OPENCL_ICD_LOADER_SOURCES
         loader/linux/icd_linux.c
         loader/linux/icd_linux_envvars.c
-        loader/linux/icd_exports.map)
+        ${CMAKE_CURRENT_BINARY_DIR}/loader/linux/icd_exports.map)
 endif ()
 
 set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
@@ -97,13 +126,17 @@ else()
     if (APPLE)
         target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
     else ()
-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_BINARY_DIR}/loader/linux/icd_exports.map")
         target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
     endif ()
 endif ()
 
 include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
-add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+if (ENABLE_OPENCL30_PROVISIONAL)
+  add_definitions (-DCL_TARGET_OPENCL_VERSION=300)
+else()
+  add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+endif()
 
 target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
 target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
index df967cb902b6459a1684a3efd2fc644bb710486c..8bab2bcd51b8110dedf45470fafbb44a580b5814 100644 (file)
@@ -319,6 +319,51 @@ clCreateImage(cl_context              context,
         errcode_ret);
 }
 
+#ifdef CL_VERSION_3_0
+/* ICD loader entry points should not normally be ifdef'ed, but prevent
+ * OpenCL 3.0 provisional entry points from being in general builds before the
+ * specification is finalized. */
+
+CL_API_ENTRY 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) CL_API_SUFFIX__VERSION_3_0
+{
+  KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT);
+  return context->dispatch->clCreateBufferWithProperties(
+      context,
+      properties,
+      flags,
+      size,
+      host_ptr,
+      errcode_ret);
+}
+
+CL_API_ENTRY 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) CL_API_SUFFIX__VERSION_3_0
+{
+  KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT);
+  return context->dispatch->clCreateImageWithProperties(
+      context,
+      properties,
+      flags,
+      image_format,
+      image_desc,
+      host_ptr,
+      errcode_ret);
+}
+
+#endif  // CL_VERSION_3_0
+
 CL_API_ENTRY cl_int CL_API_CALL
 clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0
 {
diff --git a/loader/linux/icd_exports.map b/loader/linux/icd_exports.map
deleted file mode 100644 (file)
index c716a39..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2016-2019 The Khronos Group Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * OpenCL is a trademark of Apple Inc. used under license by Khronos.
- */
-
-OPENCL_1.0 {
-    global:
-        clBuildProgram;
-        clCreateBuffer;
-        clCreateCommandQueue;
-        clCreateContext;
-        clCreateContextFromType;
-        clCreateFromGLBuffer;
-        clCreateFromGLRenderbuffer;
-        clCreateFromGLTexture2D;
-        clCreateFromGLTexture3D;
-        clCreateImage2D;
-        clCreateImage3D;
-        clCreateKernel;
-        clCreateKernelsInProgram;
-        clCreateProgramWithBinary;
-        clCreateProgramWithSource;
-        clCreateSampler;
-        clEnqueueAcquireGLObjects;
-        clEnqueueBarrier;
-        clEnqueueCopyBuffer;
-        clEnqueueCopyBufferToImage;
-        clEnqueueCopyImage;
-        clEnqueueCopyImageToBuffer;
-        clEnqueueMapBuffer;
-        clEnqueueMapImage;
-        clEnqueueMarker;
-        clEnqueueNDRangeKernel;
-        clEnqueueNativeKernel;
-        clEnqueueReadBuffer;
-        clEnqueueReadImage;
-        clEnqueueReleaseGLObjects;
-        clEnqueueTask;
-        clEnqueueUnmapMemObject;
-        clEnqueueWaitForEvents;
-        clEnqueueWriteBuffer;
-        clEnqueueWriteImage;
-        clFinish;
-        clFlush;
-        clGetCommandQueueInfo;
-        clGetContextInfo;
-        clGetDeviceIDs;
-        clGetDeviceInfo;
-        clGetEventInfo;
-        clGetEventProfilingInfo;
-        clGetExtensionFunctionAddress;
-        clGetGLObjectInfo;
-        clGetGLTextureInfo;
-        clGetImageInfo;
-        clGetKernelInfo;
-        clGetKernelWorkGroupInfo;
-        clGetMemObjectInfo;
-        clGetPlatformIDs;
-        clGetPlatformInfo;
-        clGetProgramBuildInfo;
-        clGetProgramInfo;
-        clGetSamplerInfo;
-        clGetSupportedImageFormats;
-        clReleaseCommandQueue;
-        clReleaseContext;
-        clReleaseEvent;
-        clReleaseKernel;
-        clReleaseMemObject;
-        clReleaseProgram;
-        clReleaseSampler;
-        clRetainCommandQueue;
-        clRetainContext;
-        clRetainEvent;
-        clRetainKernel;
-        clRetainMemObject;
-        clRetainProgram;
-        clRetainSampler;
-        clSetCommandQueueProperty;
-        clSetKernelArg;
-        clUnloadCompiler;
-        clWaitForEvents;
-
-    local:
-        /* Everything else is local to ICD. */
-        *;
-};
-
-OPENCL_1.1 {
-    global:
-        clCreateSubBuffer;
-        clCreateUserEvent;
-        clEnqueueCopyBufferRect;
-        clEnqueueReadBufferRect;
-        clEnqueueWriteBufferRect;
-        clSetEventCallback;
-        clSetMemObjectDestructorCallback;
-        clSetUserEventStatus;
-} OPENCL_1.0;
-
-OPENCL_1.2 {
-    global:
-        clCompileProgram;
-        clCreateFromGLTexture;
-        clCreateImage;
-        clCreateProgramWithBuiltInKernels;
-        clCreateSubDevices;
-        clEnqueueBarrierWithWaitList;
-        clEnqueueFillBuffer;
-        clEnqueueFillImage;
-        clEnqueueMarkerWithWaitList;
-        clEnqueueMigrateMemObjects;
-        clGetExtensionFunctionAddressForPlatform;
-        clGetKernelArgInfo;
-        clLinkProgram;
-        clReleaseDevice;
-        clRetainDevice;
-        clUnloadPlatformCompiler;
-} OPENCL_1.1;
-
-OPENCL_2.0 {
-    global:
-        clCreateCommandQueueWithProperties;
-        clCreatePipe;
-        clGetPipeInfo;
-        clSVMAlloc;
-        clSVMFree;
-        clEnqueueSVMFree;
-        clEnqueueSVMMemcpy;
-        clEnqueueSVMMemFill;
-        clEnqueueSVMMap;
-        clEnqueueSVMUnmap;
-        clCreateSamplerWithProperties;
-        clSetKernelArgSVMPointer;
-        clSetKernelExecInfo;
-} OPENCL_1.2;
-
-OPENCL_2.1 {
-    global:
-        clCloneKernel;
-        clCreateProgramWithIL;
-        clEnqueueSVMMigrateMem;
-        clGetDeviceAndHostTimer;
-        clGetHostTimer;
-        clGetKernelSubGroupInfo;
-        clSetDefaultDeviceCommandQueue;
-} OPENCL_2.0;
-
-OPENCL_2.2 {
-    global:
-        clSetProgramReleaseCallback;
-        clSetProgramSpecializationConstant;
-} OPENCL_2.1;
diff --git a/loader/linux/icd_exports.map.in b/loader/linux/icd_exports.map.in
new file mode 100644 (file)
index 0000000..d02f1b1
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2016-2019 The Khronos Group Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * OpenCL is a trademark of Apple Inc. used under license by Khronos.
+ */
+
+OPENCL_1.0 {
+    global:
+        clBuildProgram;
+        clCreateBuffer;
+        clCreateCommandQueue;
+        clCreateContext;
+        clCreateContextFromType;
+        clCreateFromGLBuffer;
+        clCreateFromGLRenderbuffer;
+        clCreateFromGLTexture2D;
+        clCreateFromGLTexture3D;
+        clCreateImage2D;
+        clCreateImage3D;
+        clCreateKernel;
+        clCreateKernelsInProgram;
+        clCreateProgramWithBinary;
+        clCreateProgramWithSource;
+        clCreateSampler;
+        clEnqueueAcquireGLObjects;
+        clEnqueueBarrier;
+        clEnqueueCopyBuffer;
+        clEnqueueCopyBufferToImage;
+        clEnqueueCopyImage;
+        clEnqueueCopyImageToBuffer;
+        clEnqueueMapBuffer;
+        clEnqueueMapImage;
+        clEnqueueMarker;
+        clEnqueueNDRangeKernel;
+        clEnqueueNativeKernel;
+        clEnqueueReadBuffer;
+        clEnqueueReadImage;
+        clEnqueueReleaseGLObjects;
+        clEnqueueTask;
+        clEnqueueUnmapMemObject;
+        clEnqueueWaitForEvents;
+        clEnqueueWriteBuffer;
+        clEnqueueWriteImage;
+        clFinish;
+        clFlush;
+        clGetCommandQueueInfo;
+        clGetContextInfo;
+        clGetDeviceIDs;
+        clGetDeviceInfo;
+        clGetEventInfo;
+        clGetEventProfilingInfo;
+        clGetExtensionFunctionAddress;
+        clGetGLObjectInfo;
+        clGetGLTextureInfo;
+        clGetImageInfo;
+        clGetKernelInfo;
+        clGetKernelWorkGroupInfo;
+        clGetMemObjectInfo;
+        clGetPlatformIDs;
+        clGetPlatformInfo;
+        clGetProgramBuildInfo;
+        clGetProgramInfo;
+        clGetSamplerInfo;
+        clGetSupportedImageFormats;
+        clReleaseCommandQueue;
+        clReleaseContext;
+        clReleaseEvent;
+        clReleaseKernel;
+        clReleaseMemObject;
+        clReleaseProgram;
+        clReleaseSampler;
+        clRetainCommandQueue;
+        clRetainContext;
+        clRetainEvent;
+        clRetainKernel;
+        clRetainMemObject;
+        clRetainProgram;
+        clRetainSampler;
+        clSetCommandQueueProperty;
+        clSetKernelArg;
+        clUnloadCompiler;
+        clWaitForEvents;
+
+    local:
+        /* Everything else is local to ICD. */
+        *;
+};
+
+OPENCL_1.1 {
+    global:
+        clCreateSubBuffer;
+        clCreateUserEvent;
+        clEnqueueCopyBufferRect;
+        clEnqueueReadBufferRect;
+        clEnqueueWriteBufferRect;
+        clSetEventCallback;
+        clSetMemObjectDestructorCallback;
+        clSetUserEventStatus;
+} OPENCL_1.0;
+
+OPENCL_1.2 {
+    global:
+        clCompileProgram;
+        clCreateFromGLTexture;
+        clCreateImage;
+        clCreateProgramWithBuiltInKernels;
+        clCreateSubDevices;
+        clEnqueueBarrierWithWaitList;
+        clEnqueueFillBuffer;
+        clEnqueueFillImage;
+        clEnqueueMarkerWithWaitList;
+        clEnqueueMigrateMemObjects;
+        clGetExtensionFunctionAddressForPlatform;
+        clGetKernelArgInfo;
+        clLinkProgram;
+        clReleaseDevice;
+        clRetainDevice;
+        clUnloadPlatformCompiler;
+} OPENCL_1.1;
+
+OPENCL_2.0 {
+    global:
+        clCreateCommandQueueWithProperties;
+        clCreatePipe;
+        clGetPipeInfo;
+        clSVMAlloc;
+        clSVMFree;
+        clEnqueueSVMFree;
+        clEnqueueSVMMemcpy;
+        clEnqueueSVMMemFill;
+        clEnqueueSVMMap;
+        clEnqueueSVMUnmap;
+        clCreateSamplerWithProperties;
+        clSetKernelArgSVMPointer;
+        clSetKernelExecInfo;
+} OPENCL_1.2;
+
+OPENCL_2.1 {
+    global:
+        clCloneKernel;
+        clCreateProgramWithIL;
+        clEnqueueSVMMigrateMem;
+        clGetDeviceAndHostTimer;
+        clGetHostTimer;
+        clGetKernelSubGroupInfo;
+        clSetDefaultDeviceCommandQueue;
+} OPENCL_2.0;
+
+OPENCL_2.2 {
+    global:
+        clSetProgramReleaseCallback;
+        clSetProgramSpecializationConstant;
+} OPENCL_2.1;
+
+@ENABLE_OPENCL30_SYMBOLS_START@
+OPENCL_3.0 {
+    global:
+        clCreateBufferWithProperties;
+        clCreateImageWithProperties;
+} OPENCL_2.2;
+@ENABLE_OPENCL30_SYMBOLS_END@
diff --git a/loader/windows/OpenCL.def b/loader/windows/OpenCL.def
deleted file mode 100644 (file)
index 98abc9b..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-;
-; Copyright (c) 2016-2019 The Khronos Group Inc.
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;     http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; OpenCL is a trademark of Apple Inc. used under license by Khronos.
-
-EXPORTS
-
-;
-; Note:
-;
-; 1. Functions are grouped into blocks according to the OpenCL API version they
-; were introduced in.
-;
-; 2. Function blocks are sorted in ascending order of the API version.
-;
-; 3. Functions within a block are sorted alphabetically.
-;
-
-; OpenCL 1.0 API
-clBuildProgram
-clCreateBuffer
-clCreateCommandQueue
-clCreateContext
-clCreateContextFromType
-clCreateFromGLBuffer
-clCreateFromGLRenderbuffer
-clCreateFromGLTexture2D
-clCreateFromGLTexture3D
-clCreateImage2D
-clCreateImage3D
-clCreateKernel
-clCreateKernelsInProgram
-clCreateProgramWithBinary
-clCreateProgramWithSource
-clCreateSampler
-clEnqueueAcquireGLObjects
-clEnqueueBarrier
-clEnqueueCopyBuffer
-clEnqueueCopyBufferToImage
-clEnqueueCopyImage
-clEnqueueCopyImageToBuffer
-clEnqueueMapBuffer
-clEnqueueMapImage
-clEnqueueMarker
-clEnqueueNDRangeKernel
-clEnqueueNativeKernel
-clEnqueueReadBuffer
-clEnqueueReadImage
-clEnqueueReleaseGLObjects
-clEnqueueTask
-clEnqueueUnmapMemObject
-clEnqueueWaitForEvents
-clEnqueueWriteBuffer
-clEnqueueWriteImage
-clFinish
-clFlush
-clGetCommandQueueInfo
-clGetContextInfo
-clGetDeviceIDs
-clGetDeviceInfo
-clGetEventInfo
-clGetEventProfilingInfo
-clGetExtensionFunctionAddress
-clGetGLObjectInfo
-clGetGLTextureInfo
-clGetImageInfo
-clGetKernelInfo
-clGetKernelWorkGroupInfo
-clGetMemObjectInfo
-clGetPlatformIDs
-clGetPlatformInfo
-clGetProgramBuildInfo
-clGetProgramInfo
-clGetSamplerInfo
-clGetSupportedImageFormats
-clReleaseCommandQueue
-clReleaseContext
-clReleaseEvent
-clReleaseKernel
-clReleaseMemObject
-clReleaseProgram
-clReleaseSampler
-clRetainCommandQueue
-clRetainContext
-clRetainEvent
-clRetainKernel
-clRetainMemObject
-clRetainProgram
-clRetainSampler
-clSetCommandQueueProperty
-clSetKernelArg
-clUnloadCompiler
-clWaitForEvents
-
-; OpenCL 1.1 API
-clCreateSubBuffer
-clCreateUserEvent
-clEnqueueCopyBufferRect
-clEnqueueReadBufferRect
-clEnqueueWriteBufferRect
-clSetEventCallback
-clSetMemObjectDestructorCallback
-clSetUserEventStatus
-
-; OpenCL 1.2 API
-clCompileProgram
-clCreateFromGLTexture
-clCreateImage
-clCreateProgramWithBuiltInKernels
-clCreateSubDevices
-clEnqueueBarrierWithWaitList
-clEnqueueFillBuffer
-clEnqueueFillImage
-clEnqueueMarkerWithWaitList
-clEnqueueMigrateMemObjects
-clGetExtensionFunctionAddressForPlatform
-clGetKernelArgInfo
-clLinkProgram
-clReleaseDevice
-clRetainDevice
-clUnloadPlatformCompiler
-
-; OpenCL 2.0 API
-clCreateCommandQueueWithProperties
-clCreatePipe
-clCreateSamplerWithProperties
-clEnqueueSVMFree
-clEnqueueSVMMap
-clEnqueueSVMMemcpy
-clEnqueueSVMMemFill
-clEnqueueSVMUnmap
-clGetPipeInfo
-clSetKernelArgSVMPointer
-clSetKernelExecInfo
-clSVMAlloc
-clSVMFree
-
-; OpenCL 2.1 API
-clCloneKernel
-clCreateProgramWithIL
-clEnqueueSVMMigrateMem
-clGetDeviceAndHostTimer
-clGetHostTimer
-clGetKernelSubGroupInfo
-clSetDefaultDeviceCommandQueue
-
-; OpenCL 2.2 API
-clSetProgramReleaseCallback
-clSetProgramSpecializationConstant
-
diff --git a/loader/windows/OpenCL.def.in b/loader/windows/OpenCL.def.in
new file mode 100644 (file)
index 0000000..dbdbda1
--- /dev/null
@@ -0,0 +1,165 @@
+;
+; Copyright (c) 2016-2019 The Khronos Group Inc.
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;     http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+; OpenCL is a trademark of Apple Inc. used under license by Khronos.
+
+EXPORTS
+
+;
+; Note:
+;
+; 1. Functions are grouped into blocks according to the OpenCL API version they
+; were introduced in.
+;
+; 2. Function blocks are sorted in ascending order of the API version.
+;
+; 3. Functions within a block are sorted alphabetically.
+;
+
+; OpenCL 1.0 API
+clBuildProgram
+clCreateBuffer
+clCreateCommandQueue
+clCreateContext
+clCreateContextFromType
+clCreateFromGLBuffer
+clCreateFromGLRenderbuffer
+clCreateFromGLTexture2D
+clCreateFromGLTexture3D
+clCreateImage2D
+clCreateImage3D
+clCreateKernel
+clCreateKernelsInProgram
+clCreateProgramWithBinary
+clCreateProgramWithSource
+clCreateSampler
+clEnqueueAcquireGLObjects
+clEnqueueBarrier
+clEnqueueCopyBuffer
+clEnqueueCopyBufferToImage
+clEnqueueCopyImage
+clEnqueueCopyImageToBuffer
+clEnqueueMapBuffer
+clEnqueueMapImage
+clEnqueueMarker
+clEnqueueNDRangeKernel
+clEnqueueNativeKernel
+clEnqueueReadBuffer
+clEnqueueReadImage
+clEnqueueReleaseGLObjects
+clEnqueueTask
+clEnqueueUnmapMemObject
+clEnqueueWaitForEvents
+clEnqueueWriteBuffer
+clEnqueueWriteImage
+clFinish
+clFlush
+clGetCommandQueueInfo
+clGetContextInfo
+clGetDeviceIDs
+clGetDeviceInfo
+clGetEventInfo
+clGetEventProfilingInfo
+clGetExtensionFunctionAddress
+clGetGLObjectInfo
+clGetGLTextureInfo
+clGetImageInfo
+clGetKernelInfo
+clGetKernelWorkGroupInfo
+clGetMemObjectInfo
+clGetPlatformIDs
+clGetPlatformInfo
+clGetProgramBuildInfo
+clGetProgramInfo
+clGetSamplerInfo
+clGetSupportedImageFormats
+clReleaseCommandQueue
+clReleaseContext
+clReleaseEvent
+clReleaseKernel
+clReleaseMemObject
+clReleaseProgram
+clReleaseSampler
+clRetainCommandQueue
+clRetainContext
+clRetainEvent
+clRetainKernel
+clRetainMemObject
+clRetainProgram
+clRetainSampler
+clSetCommandQueueProperty
+clSetKernelArg
+clUnloadCompiler
+clWaitForEvents
+
+; OpenCL 1.1 API
+clCreateSubBuffer
+clCreateUserEvent
+clEnqueueCopyBufferRect
+clEnqueueReadBufferRect
+clEnqueueWriteBufferRect
+clSetEventCallback
+clSetMemObjectDestructorCallback
+clSetUserEventStatus
+
+; OpenCL 1.2 API
+clCompileProgram
+clCreateFromGLTexture
+clCreateImage
+clCreateProgramWithBuiltInKernels
+clCreateSubDevices
+clEnqueueBarrierWithWaitList
+clEnqueueFillBuffer
+clEnqueueFillImage
+clEnqueueMarkerWithWaitList
+clEnqueueMigrateMemObjects
+clGetExtensionFunctionAddressForPlatform
+clGetKernelArgInfo
+clLinkProgram
+clReleaseDevice
+clRetainDevice
+clUnloadPlatformCompiler
+
+; OpenCL 2.0 API
+clCreateCommandQueueWithProperties
+clCreatePipe
+clCreateSamplerWithProperties
+clEnqueueSVMFree
+clEnqueueSVMMap
+clEnqueueSVMMemcpy
+clEnqueueSVMMemFill
+clEnqueueSVMUnmap
+clGetPipeInfo
+clSetKernelArgSVMPointer
+clSetKernelExecInfo
+clSVMAlloc
+clSVMFree
+
+; OpenCL 2.1 API
+clCloneKernel
+clCreateProgramWithIL
+clEnqueueSVMMigrateMem
+clGetDeviceAndHostTimer
+clGetHostTimer
+clGetKernelSubGroupInfo
+clSetDefaultDeviceCommandQueue
+
+; OpenCL 2.2 API
+clSetProgramReleaseCallback
+clSetProgramSpecializationConstant
+
+; OpenCL 3.0 API
+@ENABLE_OPENCL30_SYMBOLS@clCreateBufferWithProperties
+@ENABLE_OPENCL30_SYMBOLS@clCreateImageWithProperties
index 802192348bcb2a7a8954fbe700ffd3fa86fa566d..ce4d97a294b11017de1ffb60404aafbd3f061078 100644 (file)
@@ -551,6 +551,56 @@ clCreateImage3D(cl_context              context,
     return obj;
 }
 
+#ifdef CL_VERSION_3_0
+
+CL_API_ENTRY 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) CL_API_SUFFIX__VERSION_3_0
+{
+    cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
+    obj->dispatch = dispatchTable;
+    test_icd_stub_log("clCreateBufferWithProperties(%p, %p, %x, %u, %p, %p)\n",
+                      context,
+                      properties,
+                      flags,
+                      size,
+                      host_ptr,
+                      errcode_ret);
+
+    test_icd_stub_log("Value returned: %p\n", obj);
+    return obj;
+}
+
+CL_API_ENTRY 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) CL_API_SUFFIX__VERSION_3_0
+{
+    cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
+    obj->dispatch = dispatchTable;
+    test_icd_stub_log("clCreateImageWithProperties(%p, %p, %x, %p, %p, %p, %p)\n",
+                      context,
+                      properties,
+                      flags,
+                      image_format,
+                      image_desc,
+                      host_ptr,
+                      errcode_ret);
+
+    test_icd_stub_log("Value returned: %p\n", obj);
+    return obj;
+}
+
+#endif  // CL_VERSION_3_0
+
 CL_API_ENTRY cl_int CL_API_CALL
 clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0
 {
index d2b1b2bd0992a6fabdeb547b6cdb383d1df297a3..f3a75d47bc1b99f519881e6e1a41c7ac9964e29b 100644 (file)
@@ -7,6 +7,9 @@
 #define CL_USE_DEPRECATED_OPENCL_1_0_APIS
 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
+#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
+#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
+#define CL_USE_DEPRECATED_OPENCL_2_2_APIS
 
 // Need to rename all CL API functions to prevent ICD loader functions calling
 // themselves via the dispatch table. Include this before cl headers.
@@ -148,12 +151,15 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable)
     ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBufferRect);
     ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferRect);
 
+    /* cl_ext_device_fission */
     ICD_DISPATCH_TABLE_ENTRY ( /*clCreateSubDevicesEXT*/NULL);
     ICD_DISPATCH_TABLE_ENTRY ( /*clRetainDeviceEXT*/ NULL);
     ICD_DISPATCH_TABLE_ENTRY ( /*clReleaseDevice*/NULL);
 
+    /* cl_khr_gl_event */
     ICD_DISPATCH_TABLE_ENTRY ( clCreateEventFromGLsyncKHR); 
 
+    /* OpenCL 1.2 */
     ICD_DISPATCH_TABLE_ENTRY ( clCreateSubDevices);
     ICD_DISPATCH_TABLE_ENTRY ( clRetainDevice);
     ICD_DISPATCH_TABLE_ENTRY ( clReleaseDevice);
@@ -171,6 +177,68 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable)
     ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddressForPlatform);
     ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture);
 
+    /* cl_khr_d3d11_sharing */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* cl_khr_dx9_media_sharing */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* cl_khr_egl_image */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* cl_khr_egl_event */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* OpenCL 2.0 */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* cl_khr_sub_groups */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* OpenCL 2.1 */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+    /* OpenCL 2.2 */
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+
+#ifdef CL_VERSION_3_0
+    /* OpenCL 3.0 */
+    ICD_DISPATCH_TABLE_ENTRY ( clCreateBufferWithProperties );
+    ICD_DISPATCH_TABLE_ENTRY ( clCreateImageWithProperties );
+#else
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+    ICD_DISPATCH_TABLE_ENTRY( NULL );
+#endif  // CL_VERSION_3_0
+
     // return success
     *outDispatchTable = dispatchTable;
     return CL_SUCCESS;
index 7d5130cec36ac895e15b18e7e67ddd58eb498d1c..23498ea92b1df7dd7aaca171d55bd5482ee5d514 100644 (file)
 #define clEnqueueReleaseGLObjects                ___clEnqueueReleaseGLObjects
 #define clGetGLContextInfoKHR                    ___clGetGLContextInfoKHR
 #define clCreateEventFromGLsyncKHR               ___clCreateEventFromGLsyncKHR
+#define clCreateBufferWithProperties             ___clCreateBufferWithProperties
+#define clCreateImageWithProperties              ___clCreateImageWithProperties
 
 #endif /* __RENAME_API_H__ */
index 06a1f2bf803d05e75bf198890d758c0955bfea94..0cedfd5a1247f155785b004a1e7a9323b045a5fa 100644 (file)
@@ -151,6 +151,7 @@ struct clReleaseDevice_st
 
 
 #define NUM_ITEMS_clCreateBuffer 1
+#define NUM_ITEMS_clCreateBufferWithProperties 1
 #define NUM_ITEMS_clCreateSubBuffer 1
 #define NUM_ITEMS_clEnqueueReadBuffer 1
 #define NUM_ITEMS_clEnqueueWriteBuffer 1
@@ -174,6 +175,17 @@ struct clCreateBuffer_st
     void *host_ptr;
     cl_int *errcode_ret;
 };
+#ifdef CL_VERSION_3_0
+struct clCreateBufferWithProperties_st
+{
+    cl_context context;
+    const cl_mem_properties * properties;
+    cl_mem_flags flags;
+    size_t size;
+    void *host_ptr;
+    cl_int *errcode_ret;
+};
+#endif  // CL_VERSION_3_0
 struct clCreateSubBuffer_st 
 {
     cl_mem buffer;
@@ -473,6 +485,7 @@ struct clGetProgramBuildInfo_st
 #define NUM_ITEMS_clCreateImage2D 1
 #define NUM_ITEMS_clCreateImage3D 1
 #define NUM_ITEMS_clCreateImage 1
+#define NUM_ITEMS_clCreateImageWithProperties 1
 #define NUM_ITEMS_clGetSupportedImageFormats 1
 #define NUM_ITEMS_clEnqueueCopyImageToBuffer 1
 #define NUM_ITEMS_clEnqueueCopyBufferToImage 1
@@ -494,6 +507,19 @@ struct clCreateImage_st
     cl_int *errcode_ret;
 };
 
+#ifdef CL_VERSION_3_0
+struct clCreateImageWithProperties_st
+{
+    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;
+};
+#endif  // CL_VERSION_3_0
+
 struct clCreateImage2D_st 
 {
     cl_context context;
index dfce9c248d9f34d181e01f61a0558ba8d882ef84..f7e899094edd00f581aa29961f14197845a2e69d 100644 (file)
@@ -60,6 +60,13 @@ const struct clCreateBuffer_st clCreateBufferData[NUM_ITEMS_clCreateBuffer] =
     {NULL, 0, 0, NULL, NULL}
 };
 
+#ifdef CL_VERSION_3_0
+const struct clCreateBufferWithProperties_st clCreateBufferWithPropertiesData[NUM_ITEMS_clCreateBufferWithProperties] =
+{
+    {NULL, NULL, 0, 0, NULL, NULL}
+};
+#endif  // CL_VERSION_3_0
+
 const struct clCreateSubBuffer_st clCreateSubBufferData[NUM_ITEMS_clCreateSubBuffer] =
 {
     {NULL, 0, 0, NULL, NULL}
@@ -70,6 +77,13 @@ const struct clCreateImage_st clCreateImageData[NUM_ITEMS_clCreateImage] =
     { NULL, 0x0, NULL, NULL, NULL, NULL}
 };
 
+#ifdef CL_VERSION_3_0
+const struct clCreateImageWithProperties_st clCreateImageWithPropertiesData[NUM_ITEMS_clCreateImageWithProperties] =
+{
+    { NULL, NULL, 0x0, NULL, NULL, NULL, NULL}
+};
+#endif  // CL_VERSION_3_0
+
 const struct clCreateImage2D_st clCreateImage2DData[NUM_ITEMS_clCreateImage2D] =
 {
     { NULL, 0x0, NULL, 0, 0, 0, NULL, NULL}
@@ -299,6 +313,33 @@ int test_clCreateBuffer(const struct clCreateBuffer_st *data)
 
 }
 
+#ifdef CL_VERSION_3_0
+int test_clCreateBufferWithProperties(const struct clCreateBufferWithProperties_st *data)
+{
+    test_icd_app_log("clCreateBufferWithProperties(%p, %p, %x, %u, %p, %p)\n",
+                     context,
+                     data->properties,
+                     data->flags,
+                     data->size,
+                     data->host_ptr,
+                     data->errcode_ret);
+
+    buffer = clCreateBufferWithProperties(context,
+                       data->properties,
+                       data->flags,
+                       data->size,
+                       data->host_ptr,
+                       data->errcode_ret);
+
+    clReleaseMemObjectData->memobj = buffer;
+
+    test_icd_app_log("Value returned: %p\n", buffer);
+
+    return 0;
+
+}
+#endif  // CL_VERSION_3_0
+
 int test_clCreateSubBuffer(const struct clCreateSubBuffer_st *data)
 {
     test_icd_app_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n",
@@ -346,6 +387,34 @@ int test_clCreateImage(const struct clCreateImage_st *data)
 
 }
 
+#ifdef CL_VERSION_3_0
+int test_clCreateImageWithProperties(const struct clCreateImageWithProperties_st *data)
+{
+    test_icd_app_log("clCreateImageWithProperties(%p, %p, %x, %p, %p, %p, %p)\n",
+                     context,
+                     data->properties,
+                     data->flags,
+                     data->image_format,
+                     data->image_desc,
+                     data->host_ptr,
+                     data->errcode_ret);
+
+    image = clCreateImageWithProperties(context,
+                        data->properties,
+                        data->flags,
+                        data->image_format,
+                        data->image_desc,
+                        data->host_ptr,
+                        data->errcode_ret);
+
+    clReleaseMemObjectDataImage[0].memobj = image;
+    test_icd_app_log("Value returned: %p\n", image);
+
+    return 0;
+
+}
+#endif  // CL_VERSION_3_0
+
 int test_clCreateImage2D(const struct clCreateImage2D_st *data)
 {
     test_icd_app_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n",
@@ -710,10 +779,18 @@ int test_create_calls()
 
     test_clCreateBuffer(clCreateBufferData);
 
+#ifdef CL_VERSION_3_0
+    test_clCreateBufferWithProperties(clCreateBufferWithPropertiesData);
+#endif
+
     test_clCreateSubBuffer(clCreateSubBufferData);
 
     test_clCreateImage(clCreateImageData);
 
+#ifdef CL_VERSION_3_0
+    test_clCreateImageWithProperties(clCreateImageWithPropertiesData);
+#endif
+
     test_clReleaseMemObject(clReleaseMemObjectDataImage);
 
     test_clCreateImage2D(clCreateImage2DData);