-
Notifications
You must be signed in to change notification settings - Fork 89
Adapt intercept layer to be used with native OPENCL_LAYERS #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b92bb8b
adapt intercept layer to load natively via OPENCL_LAYERS
bigmat18 a8bd203
Remove ENABLE_OPENCL_NATIVE_LAYER flag to use both methods at runtime
bigmat18 e8a3c9f
Fix CI build failures
bigmat18 70b953c
Fix cast from function ptr to void ptr
bigmat18 5e1b9aa
Remove CLIRN to fix macOS build
bigmat18 1cd4ea6
Reorganize initLayer extension entries
bigmat18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -14148,6 +14148,190 @@ bool CLIntercept::initDispatch( void ) | |||||||
| #error Unknown OS! | ||||||||
| #endif | ||||||||
|
|
||||||||
| /////////////////////////////////////////////////////////////////////////////// | ||||||||
| // | ||||||||
| #define INIT_NATIVE_LAYER_FUNC(funcname) \ | ||||||||
| { \ | ||||||||
| void** pfunc = (void**)( &layer_dispatch . funcname ); \ | ||||||||
| *pfunc = reinterpret_cast<void*>(funcname); \ | ||||||||
| } | ||||||||
|
|
||||||||
| void CLIntercept::initLayer(cl_icd_dispatch& layer_dispatch, const cl_icd_dispatch* target_dispatch) | ||||||||
| { | ||||||||
| m_Dispatch = *target_dispatch; | ||||||||
| layer_dispatch = *target_dispatch; | ||||||||
|
|
||||||||
| INIT_NATIVE_LAYER_FUNC( clGetPlatformIDs ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetPlatformInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetDeviceIDs ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetDeviceInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateContext ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateContextFromType ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainContext ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseContext ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetContextInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateCommandQueue ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainCommandQueue ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseCommandQueue ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetCommandQueueInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetCommandQueueProperty ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateImage2D ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateImage3D ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainMemObject ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseMemObject ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetSupportedImageFormats ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetMemObjectInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetImageInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateSampler ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainSampler ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseSampler ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetSamplerInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateProgramWithSource ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateProgramWithBinary ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainProgram ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseProgram ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clBuildProgram ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clUnloadCompiler ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetProgramInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetProgramBuildInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateKernel ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateKernelsInProgram ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainKernel ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseKernel ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetKernelArg ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetKernelInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetKernelWorkGroupInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clWaitForEvents ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetEventInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainEvent ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseEvent ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetEventProfilingInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clFlush ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clFinish ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReadBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueWriteBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueCopyBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReadImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueWriteImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueCopyImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueCopyImageToBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueCopyBufferToImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueMapBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueMapImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueUnmapMemObject ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueNDRangeKernel ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueTask ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueNativeKernel ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueMarker ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueWaitForEvents ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueBarrier ); | ||||||||
|
|
||||||||
| INIT_NATIVE_LAYER_FUNC( clGetExtensionFunctionAddress ); | ||||||||
|
|
||||||||
| // cl_khr_gl_sharing (optional) | ||||||||
| // The entry points for this extension are exported from the ICD | ||||||||
| // loader even though they are extension APIs. | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetGLContextInfoKHR ); | ||||||||
|
|
||||||||
| #if defined (_WIN32) || defined (__linux__) || defined (__FreeBSD__) | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromGLBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromGLTexture2D ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromGLTexture3D ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromGLRenderbuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetGLObjectInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetGLTextureInfo ); // OpenCL 1.2 | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueAcquireGLObjects ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReleaseGLObjects ); | ||||||||
| #endif | ||||||||
|
|
||||||||
| #if defined(_WIN32) | ||||||||
| // cl_khr_d3d10_sharing | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetDeviceIDsFromD3D10KHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromD3D10BufferKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromD3D10Texture2DKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromD3D10Texture3DKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueAcquireD3D10ObjectsKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReleaseD3D10ObjectsKHR ); | ||||||||
|
|
||||||||
| // cl_khr_d3d11_sharing | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetDeviceIDsFromD3D11KHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromD3D11BufferKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromD3D11Texture2DKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromD3D11Texture3DKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueAcquireD3D11ObjectsKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReleaseD3D11ObjectsKHR ); | ||||||||
|
|
||||||||
| // cl_khr_dx9_media_sharing | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetDeviceIDsFromDX9MediaAdapterKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromDX9MediaSurfaceKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueAcquireDX9MediaSurfacesKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReleaseDX9MediaSurfacesKHR ); | ||||||||
| #endif | ||||||||
|
|
||||||||
| INIT_NATIVE_LAYER_FUNC( clSetEventCallback ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateSubBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetMemObjectDestructorCallback ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateUserEvent ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetUserEventStatus ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReadBufferRect ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueWriteBufferRect ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueCopyBufferRect ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateEventFromGLsyncKHR ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateSubDevices ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clRetainDevice ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clReleaseDevice ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateProgramWithBuiltInKernels ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCompileProgram ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clLinkProgram ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clUnloadPlatformCompiler ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetKernelArgInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueFillBuffer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueFillImage ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueMigrateMemObjects ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueMarkerWithWaitList ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueBarrierWithWaitList ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetExtensionFunctionAddressForPlatform ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateFromGLTexture ); | ||||||||
|
|
||||||||
| #if !defined(__APPLE__) | ||||||||
| // OpenCL 2.0 Entry Points (optional) | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateCommandQueueWithProperties ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreatePipe ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetPipeInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSVMAlloc ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSVMFree ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueSVMFree ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueSVMMemcpy ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueSVMMemFill ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueSVMMap ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueSVMUnmap ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateSamplerWithProperties ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetKernelArgSVMPointer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetKernelExecInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetKernelSubGroupInfoKHR ); | ||||||||
|
|
||||||||
| // OpenCL 2.1 Entry Points (optional) | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCloneKernel ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateProgramWithIL ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clEnqueueSVMMigrateMem ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetDeviceAndHostTimer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetHostTimer ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clGetKernelSubGroupInfo ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetDefaultDeviceCommandQueue ); | ||||||||
|
|
||||||||
| // OpenCL 2.2 Entry Points (optional) | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetProgramReleaseCallback ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetProgramSpecializationConstant ); | ||||||||
|
|
||||||||
| // OpenCL 3.0 Entry Points (optional) | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateBufferWithProperties ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clCreateImageWithProperties ); | ||||||||
| INIT_NATIVE_LAYER_FUNC( clSetContextDestructorCallback ); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add the new OpenCL 3.1 API here, also?
Suggested change
|
||||||||
| #endif | ||||||||
| } | ||||||||
|
|
||||||||
| /////////////////////////////////////////////////////////////////////////////// | ||||||||
| // | ||||||||
| void CLIntercept::dumpMemoryToFile( | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I think we're almost there now. We just need to wrap this block of OpenCL 2.0 and newer functions in:
#if !defined(__APPLE__)Then, the Mac builds should be fixed.