├── .github └── workflows │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md ├── cl.h ├── cmd └── cl-info │ └── main.go ├── examples └── main.go ├── go.mod ├── go.sum ├── include-3.0.13 └── CL │ ├── cl.h │ ├── cl_d3d10.h │ ├── cl_d3d11.h │ ├── cl_dx9_media_sharing.h │ ├── cl_dx9_media_sharing_intel.h │ ├── cl_egl.h │ ├── cl_ext.h │ ├── cl_ext_intel.h │ ├── cl_gl.h │ ├── cl_gl_ext.h │ ├── cl_half.h │ ├── cl_icd.h │ ├── cl_layer.h │ ├── cl_platform.h │ ├── cl_va_api_media_sharing_intel.h │ ├── cl_version.h │ └── opencl.h ├── info.go ├── lib-windows-3.0.13-x64 └── OpenCL.lib ├── opencl.go ├── runner.go ├── runner_test.go └── types.go /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: [push] 3 | 4 | jobs: 5 | test: 6 | strategy: 7 | matrix: 8 | os: [ubuntu-latest, windows-latest, macos-latest] 9 | runs-on: ${{ matrix.os }} 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Setup Go 14 | uses: actions/setup-go@v5 15 | with: 16 | go-version: '1.21.x' 17 | - name: Install dependencies packages for linux 18 | if: runner.os == 'Linux' 19 | run: sudo apt-get install ocl-icd-opencl-dev opencl-headers 20 | - name: Install dependencies 21 | run: go get . 22 | - name: Build 23 | run: go build -v ./... 24 | - name: Run cl-info 25 | run: go run ./cmd/cl-info/ 26 | - name: Test with the Go CLI 27 | run: go test 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # If you prefer the allow list template instead of the deny list, see community template: 2 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore 3 | # 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, built with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | 17 | # Dependency directories (remove the comment below to include it) 18 | # vendor/ 19 | 20 | # Go workspace file 21 | go.work 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 https://opencyber.xyz/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Test](https://github.com/CyberChainXyz/go-opencl/actions/workflows/test.yml/badge.svg)](https://github.com/CyberChainXyz/go-opencl/actions/workflows/test.yml) 2 | [![Go Reference](https://pkg.go.dev/badge/github.com/CyberChainXyz/go-opencl.svg)](https://pkg.go.dev/github.com/CyberChainXyz/go-opencl) 3 | 4 | # go-opencl 5 | 6 | go-opencl provides a high-level interface for OpenCL devices to run OpenCL programs in Go programs conveniently without delving into the annoying details of OpenCL. 7 | 8 | ## Development Status 9 | 10 | **WARNING**: This project is currently under development and has not been fully tested. Use it at your own risk. We welcome any feedback and contributions. 11 | 12 | ## Requirements 13 | 14 | **linux** 15 | ```bash 16 | sudo apt install ocl-icd-opencl-dev opencl-headers 17 | ``` 18 | 19 | **windows** 20 | 21 | This project incorporates OpenCL-Headers and OpenCL-ICD-Loader, which are included in the `include-3.0.13` and `lib-windows-3.0.13-x64` directories respectively for Windows. 22 | 23 | The sources for these components are as follows: 24 | 25 | - OpenCL-Headers: [KhronosGroup/OpenCL-Headers v2023.02.06](https://github.com/KhronosGroup/OpenCL-Headers/releases/tag/v2023.02.06) 26 | 27 | - OpenCL-ICD-Loader: [KhronosGroup/OpenCL-SDK v2023.02.06](https://github.com/KhronosGroup/OpenCL-SDK/releases/tag/v2023.02.06) 28 | 29 | 30 | ## cl-info command 31 | 32 | The cl-info command provides information about the OpenCL platforms and devices on your system. 33 | 34 | To install cl-info, run the following command: 35 | 36 | ```bash 37 | go install github.com/CyberChainXyz/go-opencl/cmd/cl-info@latest 38 | ``` 39 | 40 | ## OpenCL runner 41 | 42 | ```go 43 | import cl "github.com/CyberChainXyz/go-opencl" 44 | ``` 45 | 46 | Refer to the [runner_test.go](./runner_test.go) file or [examples](./examples/) for usage examples of the OpenCL runner. 47 | 48 | ## Other resources 49 | 50 | OPENCL 3.0 Reference: https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/ 51 | -------------------------------------------------------------------------------- /cl.h: -------------------------------------------------------------------------------- 1 | #ifndef _cl_H 2 | 3 | #if __APPLE__ 4 | #include 5 | #else 6 | #include 7 | #endif 8 | 9 | #define _cl_H 10 | #endif 11 | -------------------------------------------------------------------------------- /cmd/cl-info/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kr/pretty" 5 | cl "github.com/CyberChainXyz/go-opencl" 6 | ) 7 | 8 | func main() { 9 | info, _ := cl.Info() 10 | pretty.Println(info) 11 | } 12 | -------------------------------------------------------------------------------- /examples/main.go: -------------------------------------------------------------------------------- 1 | // Package opencl provides a Go interface for interacting with OpenCL devices. 2 | package main 3 | 4 | import ( 5 | "log" 6 | "slices" 7 | "unsafe" 8 | 9 | cl "github.com/CyberChainXyz/go-opencl" 10 | ) 11 | 12 | // TestRunner is a test function that tests the functionality of the OpenCL runner. 13 | func main() { 14 | // Step 1: Get OpenCL device information 15 | info, _ := cl.Info() 16 | 17 | if len(info.Platforms) < 1 { 18 | log.Fatal("No OpenCL Devices") 19 | } 20 | if len(info.Platforms[0].Devices) < 1 { 21 | log.Fatal("No OpenCL Devices") 22 | } 23 | 24 | // Step 2: Initialize the OpenCL runner 25 | device := info.Platforms[0].Devices[0] 26 | runner, err := device.InitRunner() 27 | if err != nil { 28 | log.Fatal("InitRunner err:", err) 29 | } 30 | defer runner.Free() 31 | 32 | // Step 3: Compile the OpenCL kernels 33 | code := `__kernel void helloworld(__global int* in, __global int* out) 34 | { 35 | int num = get_global_id(0); 36 | out[num] = in[num] * in[num]; 37 | }` 38 | codes := []string{code} 39 | kernelNameList := []string{"helloworld"} 40 | err = runner.CompileKernels(codes, kernelNameList, "") 41 | if err != nil { 42 | log.Fatal("CompileKernels err:", err) 43 | } 44 | 45 | // Step 4: Create kernel parameters 46 | /* buffer 1 param */ 47 | input := []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 48 | itemSize := int(unsafe.Sizeof(input[0])) 49 | itemCount := len(input) 50 | 51 | input_buf, err := cl.CreateBuffer(runner, cl.READ_ONLY|cl.COPY_HOST_PTR, input) 52 | if err != nil { 53 | log.Fatal("CreateBuffer err:", err) 54 | } 55 | /* buffer 2 param */ 56 | output_buf, err := runner.CreateEmptyBuffer(cl.WRITE_ONLY, itemCount*itemSize) 57 | if err != nil { 58 | log.Fatal("CreateEmptyBuffer err:", err) 59 | } 60 | 61 | // Step 5: Run the OpenCL kernel 62 | err = runner.RunKernel("helloworld", 1, nil, []uint64{uint64(itemCount)}, nil, []cl.KernelParam{ 63 | cl.BufferParam(input_buf), 64 | cl.BufferParam(output_buf), 65 | }, true) 66 | if err != nil { 67 | log.Fatal("RunKernel err:", err) 68 | } 69 | 70 | // Step 6: Read the output buffer 71 | result := make([]int32, itemCount) 72 | err = cl.ReadBuffer(runner, 0, output_buf, result) 73 | if err != nil { 74 | log.Fatal("ReadBuffer err:", err) 75 | } 76 | log.Printf("Result: %v", result) 77 | 78 | // Step 7: Check the result 79 | expected_result := make([]int32, itemCount) 80 | for i, v := range input { 81 | expected_result[i] = v * v 82 | } 83 | if !slices.Equal(result, expected_result) { 84 | log.Fatal("result error:", result) 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/CyberChainXyz/go-opencl 2 | 3 | go 1.21.0 4 | 5 | require github.com/kr/pretty v0.3.1 6 | 7 | require ( 8 | github.com/kr/text v0.2.0 // indirect 9 | github.com/rogpeppe/go-internal v1.9.0 // indirect 10 | ) 11 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 2 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 3 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 4 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 5 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 6 | github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 7 | github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= 8 | github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= 9 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_d3d10.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_CL_D3D10_H 18 | #define __OPENCL_CL_D3D10_H 19 | 20 | #if defined(_MSC_VER) 21 | #if _MSC_VER >=1500 22 | #pragma warning( push ) 23 | #pragma warning( disable : 4201 ) 24 | #pragma warning( disable : 5105 ) 25 | #endif 26 | #endif 27 | #include 28 | #if defined(_MSC_VER) 29 | #if _MSC_VER >=1500 30 | #pragma warning( pop ) 31 | #endif 32 | #endif 33 | #include 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /****************************************************************************** 41 | * cl_khr_d3d10_sharing */ 42 | #define cl_khr_d3d10_sharing 1 43 | 44 | typedef cl_uint cl_d3d10_device_source_khr; 45 | typedef cl_uint cl_d3d10_device_set_khr; 46 | 47 | /******************************************************************************/ 48 | 49 | /* Error Codes */ 50 | #define CL_INVALID_D3D10_DEVICE_KHR -1002 51 | #define CL_INVALID_D3D10_RESOURCE_KHR -1003 52 | #define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004 53 | #define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005 54 | 55 | /* cl_d3d10_device_source_nv */ 56 | #define CL_D3D10_DEVICE_KHR 0x4010 57 | #define CL_D3D10_DXGI_ADAPTER_KHR 0x4011 58 | 59 | /* cl_d3d10_device_set_nv */ 60 | #define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012 61 | #define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013 62 | 63 | /* cl_context_info */ 64 | #define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014 65 | #define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C 66 | 67 | /* cl_mem_info */ 68 | #define CL_MEM_D3D10_RESOURCE_KHR 0x4015 69 | 70 | /* cl_image_info */ 71 | #define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016 72 | 73 | /* cl_command_type */ 74 | #define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017 75 | #define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018 76 | 77 | /******************************************************************************/ 78 | 79 | typedef cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)( 80 | cl_platform_id platform, 81 | cl_d3d10_device_source_khr d3d_device_source, 82 | void * d3d_object, 83 | cl_d3d10_device_set_khr d3d_device_set, 84 | cl_uint num_entries, 85 | cl_device_id * devices, 86 | cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; 87 | 88 | typedef cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)( 89 | cl_context context, 90 | cl_mem_flags flags, 91 | ID3D10Buffer * resource, 92 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 93 | 94 | typedef cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)( 95 | cl_context context, 96 | cl_mem_flags flags, 97 | ID3D10Texture2D * resource, 98 | UINT subresource, 99 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 100 | 101 | typedef cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)( 102 | cl_context context, 103 | cl_mem_flags flags, 104 | ID3D10Texture3D * resource, 105 | UINT subresource, 106 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 107 | 108 | typedef cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)( 109 | cl_command_queue command_queue, 110 | cl_uint num_objects, 111 | const cl_mem * mem_objects, 112 | cl_uint num_events_in_wait_list, 113 | const cl_event * event_wait_list, 114 | cl_event * event) CL_API_SUFFIX__VERSION_1_0; 115 | 116 | typedef cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)( 117 | cl_command_queue command_queue, 118 | cl_uint num_objects, 119 | const cl_mem * mem_objects, 120 | cl_uint num_events_in_wait_list, 121 | const cl_event * event_wait_list, 122 | cl_event * event) CL_API_SUFFIX__VERSION_1_0; 123 | 124 | /*************************************************************** 125 | * cl_intel_sharing_format_query_d3d10 126 | ***************************************************************/ 127 | #define cl_intel_sharing_format_query_d3d10 1 128 | 129 | /* when cl_khr_d3d10_sharing is supported */ 130 | 131 | extern CL_API_ENTRY cl_int CL_API_CALL 132 | clGetSupportedD3D10TextureFormatsINTEL( 133 | cl_context context, 134 | cl_mem_flags flags, 135 | cl_mem_object_type image_type, 136 | cl_uint num_entries, 137 | DXGI_FORMAT* d3d10_formats, 138 | cl_uint* num_texture_formats) ; 139 | 140 | typedef cl_int (CL_API_CALL * 141 | clGetSupportedD3D10TextureFormatsINTEL_fn)( 142 | cl_context context, 143 | cl_mem_flags flags, 144 | cl_mem_object_type image_type, 145 | cl_uint num_entries, 146 | DXGI_FORMAT* d3d10_formats, 147 | cl_uint* num_texture_formats) ; 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #endif /* __OPENCL_CL_D3D10_H */ 154 | 155 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_d3d11.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_CL_D3D11_H 18 | #define __OPENCL_CL_D3D11_H 19 | 20 | #if defined(_MSC_VER) 21 | #if _MSC_VER >=1500 22 | #pragma warning( push ) 23 | #pragma warning( disable : 4201 ) 24 | #pragma warning( disable : 5105 ) 25 | #endif 26 | #endif 27 | #include 28 | #if defined(_MSC_VER) 29 | #if _MSC_VER >=1500 30 | #pragma warning( pop ) 31 | #endif 32 | #endif 33 | #include 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /****************************************************************************** 41 | * cl_khr_d3d11_sharing */ 42 | #define cl_khr_d3d11_sharing 1 43 | 44 | typedef cl_uint cl_d3d11_device_source_khr; 45 | typedef cl_uint cl_d3d11_device_set_khr; 46 | 47 | /******************************************************************************/ 48 | 49 | /* Error Codes */ 50 | #define CL_INVALID_D3D11_DEVICE_KHR -1006 51 | #define CL_INVALID_D3D11_RESOURCE_KHR -1007 52 | #define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008 53 | #define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009 54 | 55 | /* cl_d3d11_device_source */ 56 | #define CL_D3D11_DEVICE_KHR 0x4019 57 | #define CL_D3D11_DXGI_ADAPTER_KHR 0x401A 58 | 59 | /* cl_d3d11_device_set */ 60 | #define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B 61 | #define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C 62 | 63 | /* cl_context_info */ 64 | #define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D 65 | #define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D 66 | 67 | /* cl_mem_info */ 68 | #define CL_MEM_D3D11_RESOURCE_KHR 0x401E 69 | 70 | /* cl_image_info */ 71 | #define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F 72 | 73 | /* cl_command_type */ 74 | #define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020 75 | #define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021 76 | 77 | /******************************************************************************/ 78 | 79 | typedef cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)( 80 | cl_platform_id platform, 81 | cl_d3d11_device_source_khr d3d_device_source, 82 | void * d3d_object, 83 | cl_d3d11_device_set_khr d3d_device_set, 84 | cl_uint num_entries, 85 | cl_device_id * devices, 86 | cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; 87 | 88 | typedef cl_mem (CL_API_CALL *clCreateFromD3D11BufferKHR_fn)( 89 | cl_context context, 90 | cl_mem_flags flags, 91 | ID3D11Buffer * resource, 92 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 93 | 94 | typedef cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)( 95 | cl_context context, 96 | cl_mem_flags flags, 97 | ID3D11Texture2D * resource, 98 | UINT subresource, 99 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 100 | 101 | typedef cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)( 102 | cl_context context, 103 | cl_mem_flags flags, 104 | ID3D11Texture3D * resource, 105 | UINT subresource, 106 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 107 | 108 | typedef cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)( 109 | cl_command_queue command_queue, 110 | cl_uint num_objects, 111 | const cl_mem * mem_objects, 112 | cl_uint num_events_in_wait_list, 113 | const cl_event * event_wait_list, 114 | cl_event * event) CL_API_SUFFIX__VERSION_1_2; 115 | 116 | typedef cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)( 117 | cl_command_queue command_queue, 118 | cl_uint num_objects, 119 | const cl_mem * mem_objects, 120 | cl_uint num_events_in_wait_list, 121 | const cl_event * event_wait_list, 122 | cl_event * event) CL_API_SUFFIX__VERSION_1_2; 123 | 124 | /*************************************************************** 125 | * cl_intel_sharing_format_query_d3d11 126 | ***************************************************************/ 127 | #define cl_intel_sharing_format_query_d3d11 1 128 | 129 | /* when cl_khr_d3d11_sharing is supported */ 130 | 131 | extern CL_API_ENTRY cl_int CL_API_CALL 132 | clGetSupportedD3D11TextureFormatsINTEL( 133 | cl_context context, 134 | cl_mem_flags flags, 135 | cl_mem_object_type image_type, 136 | cl_uint plane, 137 | cl_uint num_entries, 138 | DXGI_FORMAT* d3d11_formats, 139 | cl_uint* num_texture_formats) ; 140 | 141 | typedef cl_int (CL_API_CALL * 142 | clGetSupportedD3D11TextureFormatsINTEL_fn)( 143 | cl_context context, 144 | cl_mem_flags flags, 145 | cl_mem_object_type image_type, 146 | cl_uint plane, 147 | cl_uint num_entries, 148 | DXGI_FORMAT* d3d11_formats, 149 | cl_uint* num_texture_formats) ; 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | 155 | #endif /* __OPENCL_CL_D3D11_H */ 156 | 157 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_dx9_media_sharing.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_CL_DX9_MEDIA_SHARING_H 18 | #define __OPENCL_CL_DX9_MEDIA_SHARING_H 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /******************************************************************************/ 28 | /* cl_khr_dx9_media_sharing */ 29 | #define cl_khr_dx9_media_sharing 1 30 | 31 | typedef cl_uint cl_dx9_media_adapter_type_khr; 32 | typedef cl_uint cl_dx9_media_adapter_set_khr; 33 | 34 | #if defined(_WIN32) 35 | #if defined(_MSC_VER) 36 | #if _MSC_VER >=1500 37 | #pragma warning( push ) 38 | #pragma warning( disable : 4201 ) 39 | #pragma warning( disable : 5105 ) 40 | #endif 41 | #endif 42 | #include 43 | #if defined(_MSC_VER) 44 | #if _MSC_VER >=1500 45 | #pragma warning( pop ) 46 | #endif 47 | #endif 48 | typedef struct _cl_dx9_surface_info_khr 49 | { 50 | IDirect3DSurface9 *resource; 51 | HANDLE shared_handle; 52 | } cl_dx9_surface_info_khr; 53 | #endif 54 | 55 | 56 | /******************************************************************************/ 57 | 58 | /* Error Codes */ 59 | #define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 60 | #define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 61 | #define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 62 | #define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 63 | 64 | /* cl_media_adapter_type_khr */ 65 | #define CL_ADAPTER_D3D9_KHR 0x2020 66 | #define CL_ADAPTER_D3D9EX_KHR 0x2021 67 | #define CL_ADAPTER_DXVA_KHR 0x2022 68 | 69 | /* cl_media_adapter_set_khr */ 70 | #define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 71 | #define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 72 | 73 | /* cl_context_info */ 74 | #define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 75 | #define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 76 | #define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 77 | 78 | /* cl_mem_info */ 79 | #define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 80 | #define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 81 | 82 | /* cl_image_info */ 83 | #define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A 84 | 85 | /* cl_command_type */ 86 | #define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B 87 | #define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C 88 | 89 | /******************************************************************************/ 90 | 91 | typedef cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( 92 | cl_platform_id platform, 93 | cl_uint num_media_adapters, 94 | cl_dx9_media_adapter_type_khr * media_adapter_type, 95 | void * media_adapters, 96 | cl_dx9_media_adapter_set_khr media_adapter_set, 97 | cl_uint num_entries, 98 | cl_device_id * devices, 99 | cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; 100 | 101 | typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)( 102 | cl_context context, 103 | cl_mem_flags flags, 104 | cl_dx9_media_adapter_type_khr adapter_type, 105 | void * surface_info, 106 | cl_uint plane, 107 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 108 | 109 | typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)( 110 | cl_command_queue command_queue, 111 | cl_uint num_objects, 112 | const cl_mem * mem_objects, 113 | cl_uint num_events_in_wait_list, 114 | const cl_event * event_wait_list, 115 | cl_event * event) CL_API_SUFFIX__VERSION_1_2; 116 | 117 | typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)( 118 | cl_command_queue command_queue, 119 | cl_uint num_objects, 120 | const cl_mem * mem_objects, 121 | cl_uint num_events_in_wait_list, 122 | const cl_event * event_wait_list, 123 | cl_event * event) CL_API_SUFFIX__VERSION_1_2; 124 | 125 | /*************************************** 126 | * cl_intel_dx9_media_sharing extension * 127 | ****************************************/ 128 | 129 | #define cl_intel_dx9_media_sharing 1 130 | 131 | typedef cl_uint cl_dx9_device_source_intel; 132 | typedef cl_uint cl_dx9_device_set_intel; 133 | 134 | /* error codes */ 135 | #define CL_INVALID_DX9_DEVICE_INTEL -1010 136 | #define CL_INVALID_DX9_RESOURCE_INTEL -1011 137 | #define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL -1012 138 | #define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL -1013 139 | 140 | /* cl_dx9_device_source_intel */ 141 | #define CL_D3D9_DEVICE_INTEL 0x4022 142 | #define CL_D3D9EX_DEVICE_INTEL 0x4070 143 | #define CL_DXVA_DEVICE_INTEL 0x4071 144 | 145 | /* cl_dx9_device_set_intel */ 146 | #define CL_PREFERRED_DEVICES_FOR_DX9_INTEL 0x4024 147 | #define CL_ALL_DEVICES_FOR_DX9_INTEL 0x4025 148 | 149 | /* cl_context_info */ 150 | #define CL_CONTEXT_D3D9_DEVICE_INTEL 0x4026 151 | #define CL_CONTEXT_D3D9EX_DEVICE_INTEL 0x4072 152 | #define CL_CONTEXT_DXVA_DEVICE_INTEL 0x4073 153 | 154 | /* cl_mem_info */ 155 | #define CL_MEM_DX9_RESOURCE_INTEL 0x4027 156 | #define CL_MEM_DX9_SHARED_HANDLE_INTEL 0x4074 157 | 158 | /* cl_image_info */ 159 | #define CL_IMAGE_DX9_PLANE_INTEL 0x4075 160 | 161 | /* cl_command_type */ 162 | #define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL 0x402A 163 | #define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL 0x402B 164 | /******************************************************************************/ 165 | 166 | extern CL_API_ENTRY cl_int CL_API_CALL 167 | clGetDeviceIDsFromDX9INTEL( 168 | cl_platform_id platform, 169 | cl_dx9_device_source_intel dx9_device_source, 170 | void* dx9_object, 171 | cl_dx9_device_set_intel dx9_device_set, 172 | cl_uint num_entries, 173 | cl_device_id* devices, 174 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 175 | 176 | typedef cl_int (CL_API_CALL* clGetDeviceIDsFromDX9INTEL_fn)( 177 | cl_platform_id platform, 178 | cl_dx9_device_source_intel dx9_device_source, 179 | void* dx9_object, 180 | cl_dx9_device_set_intel dx9_device_set, 181 | cl_uint num_entries, 182 | cl_device_id* devices, 183 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 184 | 185 | extern CL_API_ENTRY cl_mem CL_API_CALL 186 | clCreateFromDX9MediaSurfaceINTEL( 187 | cl_context context, 188 | cl_mem_flags flags, 189 | IDirect3DSurface9* resource, 190 | HANDLE sharedHandle, 191 | UINT plane, 192 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 193 | 194 | typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)( 195 | cl_context context, 196 | cl_mem_flags flags, 197 | IDirect3DSurface9* resource, 198 | HANDLE sharedHandle, 199 | UINT plane, 200 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 201 | 202 | extern CL_API_ENTRY cl_int CL_API_CALL 203 | clEnqueueAcquireDX9ObjectsINTEL( 204 | cl_command_queue command_queue, 205 | cl_uint num_objects, 206 | const cl_mem* mem_objects, 207 | cl_uint num_events_in_wait_list, 208 | const cl_event* event_wait_list, 209 | cl_event* event) CL_API_SUFFIX__VERSION_1_1; 210 | 211 | typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)( 212 | cl_command_queue command_queue, 213 | cl_uint num_objects, 214 | const cl_mem* mem_objects, 215 | cl_uint num_events_in_wait_list, 216 | const cl_event* event_wait_list, 217 | cl_event* event) CL_API_SUFFIX__VERSION_1_1; 218 | 219 | extern CL_API_ENTRY cl_int CL_API_CALL 220 | clEnqueueReleaseDX9ObjectsINTEL( 221 | cl_command_queue command_queue, 222 | cl_uint num_objects, 223 | cl_mem* mem_objects, 224 | cl_uint num_events_in_wait_list, 225 | const cl_event* event_wait_list, 226 | cl_event* event) CL_API_SUFFIX__VERSION_1_1; 227 | 228 | typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)( 229 | cl_command_queue command_queue, 230 | cl_uint num_objects, 231 | cl_mem* mem_objects, 232 | cl_uint num_events_in_wait_list, 233 | const cl_event* event_wait_list, 234 | cl_event* event) CL_API_SUFFIX__VERSION_1_1; 235 | 236 | /*************************************************************** 237 | * cl_intel_sharing_format_query_dx9 238 | ***************************************************************/ 239 | #define cl_intel_sharing_format_query_dx9 1 240 | 241 | /* when cl_khr_dx9_media_sharing or cl_intel_dx9_media_sharing is supported */ 242 | 243 | extern CL_API_ENTRY cl_int CL_API_CALL 244 | clGetSupportedDX9MediaSurfaceFormatsINTEL( 245 | cl_context context, 246 | cl_mem_flags flags, 247 | cl_mem_object_type image_type, 248 | cl_uint plane, 249 | cl_uint num_entries, 250 | D3DFORMAT* dx9_formats, 251 | cl_uint* num_surface_formats) ; 252 | 253 | typedef cl_int (CL_API_CALL * 254 | clGetSupportedDX9MediaSurfaceFormatsINTEL_fn)( 255 | cl_context context, 256 | cl_mem_flags flags, 257 | cl_mem_object_type image_type, 258 | cl_uint plane, 259 | cl_uint num_entries, 260 | D3DFORMAT* dx9_formats, 261 | cl_uint* num_surface_formats) ; 262 | 263 | #ifdef __cplusplus 264 | } 265 | #endif 266 | 267 | #endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */ 268 | 269 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_dx9_media_sharing_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #include 18 | #pragma message("The Intel DX9 media sharing extensions have been moved into cl_dx9_media_sharing.h. Please include cl_dx9_media_sharing.h directly.") 19 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_egl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_CL_EGL_H 18 | #define __OPENCL_CL_EGL_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /* Command type for events created with clEnqueueAcquireEGLObjectsKHR */ 28 | #define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F 29 | #define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D 30 | #define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E 31 | 32 | /* Error type for clCreateFromEGLImageKHR */ 33 | #define CL_INVALID_EGL_OBJECT_KHR -1093 34 | #define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092 35 | 36 | /* CLeglImageKHR is an opaque handle to an EGLImage */ 37 | typedef void* CLeglImageKHR; 38 | 39 | /* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ 40 | typedef void* CLeglDisplayKHR; 41 | 42 | /* CLeglSyncKHR is an opaque handle to an EGLSync object */ 43 | typedef void* CLeglSyncKHR; 44 | 45 | /* properties passed to clCreateFromEGLImageKHR */ 46 | typedef intptr_t cl_egl_image_properties_khr; 47 | 48 | 49 | #define cl_khr_egl_image 1 50 | 51 | extern CL_API_ENTRY cl_mem CL_API_CALL 52 | clCreateFromEGLImageKHR(cl_context context, 53 | CLeglDisplayKHR egldisplay, 54 | CLeglImageKHR eglimage, 55 | cl_mem_flags flags, 56 | const cl_egl_image_properties_khr * properties, 57 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 58 | 59 | typedef cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)( 60 | cl_context context, 61 | CLeglDisplayKHR egldisplay, 62 | CLeglImageKHR eglimage, 63 | cl_mem_flags flags, 64 | const cl_egl_image_properties_khr * properties, 65 | cl_int * errcode_ret); 66 | 67 | 68 | extern CL_API_ENTRY cl_int CL_API_CALL 69 | clEnqueueAcquireEGLObjectsKHR(cl_command_queue command_queue, 70 | cl_uint num_objects, 71 | const cl_mem * mem_objects, 72 | cl_uint num_events_in_wait_list, 73 | const cl_event * event_wait_list, 74 | cl_event * event) CL_API_SUFFIX__VERSION_1_0; 75 | 76 | typedef cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)( 77 | cl_command_queue command_queue, 78 | cl_uint num_objects, 79 | const cl_mem * mem_objects, 80 | cl_uint num_events_in_wait_list, 81 | const cl_event * event_wait_list, 82 | cl_event * event); 83 | 84 | 85 | extern CL_API_ENTRY cl_int CL_API_CALL 86 | clEnqueueReleaseEGLObjectsKHR(cl_command_queue command_queue, 87 | cl_uint num_objects, 88 | const cl_mem * mem_objects, 89 | cl_uint num_events_in_wait_list, 90 | const cl_event * event_wait_list, 91 | cl_event * event) CL_API_SUFFIX__VERSION_1_0; 92 | 93 | typedef cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)( 94 | cl_command_queue command_queue, 95 | cl_uint num_objects, 96 | const cl_mem * mem_objects, 97 | cl_uint num_events_in_wait_list, 98 | const cl_event * event_wait_list, 99 | cl_event * event); 100 | 101 | 102 | #define cl_khr_egl_event 1 103 | 104 | extern CL_API_ENTRY cl_event CL_API_CALL 105 | clCreateEventFromEGLSyncKHR(cl_context context, 106 | CLeglSyncKHR sync, 107 | CLeglDisplayKHR display, 108 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 109 | 110 | typedef cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)( 111 | cl_context context, 112 | CLeglSyncKHR sync, 113 | CLeglDisplayKHR display, 114 | cl_int * errcode_ret); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* __OPENCL_CL_EGL_H */ 121 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_ext_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | ******************************************************************************/ 17 | 18 | #include 19 | #pragma message("The Intel extensions have been moved into cl_ext.h. Please include cl_ext.h directly.") 20 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_gl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_CL_GL_H 18 | #define __OPENCL_CL_GL_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | typedef cl_uint cl_gl_object_type; 27 | typedef cl_uint cl_gl_texture_info; 28 | typedef cl_uint cl_gl_platform_info; 29 | typedef struct __GLsync *cl_GLsync; 30 | 31 | /* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */ 32 | #define CL_GL_OBJECT_BUFFER 0x2000 33 | #define CL_GL_OBJECT_TEXTURE2D 0x2001 34 | #define CL_GL_OBJECT_TEXTURE3D 0x2002 35 | #define CL_GL_OBJECT_RENDERBUFFER 0x2003 36 | #ifdef CL_VERSION_1_2 37 | #define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E 38 | #define CL_GL_OBJECT_TEXTURE1D 0x200F 39 | #define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 40 | #define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 41 | #endif 42 | 43 | /* cl_gl_texture_info */ 44 | #define CL_GL_TEXTURE_TARGET 0x2004 45 | #define CL_GL_MIPMAP_LEVEL 0x2005 46 | #ifdef CL_VERSION_1_2 47 | #define CL_GL_NUM_SAMPLES 0x2012 48 | #endif 49 | 50 | 51 | extern CL_API_ENTRY cl_mem CL_API_CALL 52 | clCreateFromGLBuffer(cl_context context, 53 | cl_mem_flags flags, 54 | cl_GLuint bufobj, 55 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 56 | 57 | #ifdef CL_VERSION_1_2 58 | 59 | extern CL_API_ENTRY cl_mem CL_API_CALL 60 | clCreateFromGLTexture(cl_context context, 61 | cl_mem_flags flags, 62 | cl_GLenum target, 63 | cl_GLint miplevel, 64 | cl_GLuint texture, 65 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 66 | 67 | #endif 68 | 69 | extern CL_API_ENTRY cl_mem CL_API_CALL 70 | clCreateFromGLRenderbuffer(cl_context context, 71 | cl_mem_flags flags, 72 | cl_GLuint renderbuffer, 73 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; 74 | 75 | extern CL_API_ENTRY cl_int CL_API_CALL 76 | clGetGLObjectInfo(cl_mem memobj, 77 | cl_gl_object_type * gl_object_type, 78 | cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; 79 | 80 | extern CL_API_ENTRY cl_int CL_API_CALL 81 | clGetGLTextureInfo(cl_mem memobj, 82 | cl_gl_texture_info param_name, 83 | size_t param_value_size, 84 | void * param_value, 85 | size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 86 | 87 | extern CL_API_ENTRY cl_int CL_API_CALL 88 | clEnqueueAcquireGLObjects(cl_command_queue command_queue, 89 | cl_uint num_objects, 90 | const cl_mem * mem_objects, 91 | cl_uint num_events_in_wait_list, 92 | const cl_event * event_wait_list, 93 | cl_event * event) CL_API_SUFFIX__VERSION_1_0; 94 | 95 | extern CL_API_ENTRY cl_int CL_API_CALL 96 | clEnqueueReleaseGLObjects(cl_command_queue command_queue, 97 | cl_uint num_objects, 98 | const cl_mem * mem_objects, 99 | cl_uint num_events_in_wait_list, 100 | const cl_event * event_wait_list, 101 | cl_event * event) CL_API_SUFFIX__VERSION_1_0; 102 | 103 | 104 | /* Deprecated OpenCL 1.1 APIs */ 105 | extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL 106 | clCreateFromGLTexture2D(cl_context context, 107 | cl_mem_flags flags, 108 | cl_GLenum target, 109 | cl_GLint miplevel, 110 | cl_GLuint texture, 111 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 112 | 113 | extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL 114 | clCreateFromGLTexture3D(cl_context context, 115 | cl_mem_flags flags, 116 | cl_GLenum target, 117 | cl_GLint miplevel, 118 | cl_GLuint texture, 119 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 120 | 121 | /* cl_khr_gl_sharing extension */ 122 | 123 | #define cl_khr_gl_sharing 1 124 | 125 | typedef cl_uint cl_gl_context_info; 126 | 127 | /* Additional Error Codes */ 128 | #define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 129 | 130 | /* cl_gl_context_info */ 131 | #define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 132 | #define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 133 | 134 | /* Additional cl_context_properties */ 135 | #define CL_GL_CONTEXT_KHR 0x2008 136 | #define CL_EGL_DISPLAY_KHR 0x2009 137 | #define CL_GLX_DISPLAY_KHR 0x200A 138 | #define CL_WGL_HDC_KHR 0x200B 139 | #define CL_CGL_SHAREGROUP_KHR 0x200C 140 | 141 | extern CL_API_ENTRY cl_int CL_API_CALL 142 | clGetGLContextInfoKHR(const cl_context_properties * properties, 143 | cl_gl_context_info param_name, 144 | size_t param_value_size, 145 | void * param_value, 146 | size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 147 | 148 | typedef cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( 149 | const cl_context_properties * properties, 150 | cl_gl_context_info param_name, 151 | size_t param_value_size, 152 | void * param_value, 153 | size_t * param_value_size_ret); 154 | 155 | /* 156 | * cl_khr_gl_event extension 157 | */ 158 | #define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D 159 | 160 | extern CL_API_ENTRY cl_event CL_API_CALL 161 | clCreateEventFromGLsyncKHR(cl_context context, 162 | cl_GLsync sync, 163 | cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1; 164 | 165 | /*************************************************************** 166 | * cl_intel_sharing_format_query_gl 167 | ***************************************************************/ 168 | #define cl_intel_sharing_format_query_gl 1 169 | 170 | /* when cl_khr_gl_sharing is supported */ 171 | 172 | extern CL_API_ENTRY cl_int CL_API_CALL 173 | clGetSupportedGLTextureFormatsINTEL( 174 | cl_context context, 175 | cl_mem_flags flags, 176 | cl_mem_object_type image_type, 177 | cl_uint num_entries, 178 | cl_GLenum* gl_formats, 179 | cl_uint* num_texture_formats) ; 180 | 181 | typedef cl_int (CL_API_CALL * 182 | clGetSupportedGLTextureFormatsINTEL_fn)( 183 | cl_context context, 184 | cl_mem_flags flags, 185 | cl_mem_object_type image_type, 186 | cl_uint num_entries, 187 | cl_GLenum* gl_formats, 188 | cl_uint* num_texture_formats) ; 189 | 190 | #ifdef __cplusplus 191 | } 192 | #endif 193 | 194 | #endif /* __OPENCL_CL_GL_H */ 195 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_gl_ext.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #include 18 | #pragma message("All OpenGL-related extensions have been moved into cl_gl.h. Please include cl_gl.h directly.") 19 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_half.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2019-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /** 18 | * This is a header-only utility library that provides OpenCL host code with 19 | * routines for converting to/from cl_half values. 20 | * 21 | * Example usage: 22 | * 23 | * #include 24 | * ... 25 | * cl_half h = cl_half_from_float(0.5f, CL_HALF_RTE); 26 | * cl_float f = cl_half_to_float(h); 27 | */ 28 | 29 | #ifndef OPENCL_CL_HALF_H 30 | #define OPENCL_CL_HALF_H 31 | 32 | #include 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | 41 | /** 42 | * Rounding mode used when converting to cl_half. 43 | */ 44 | typedef enum 45 | { 46 | CL_HALF_RTE, // round to nearest even 47 | CL_HALF_RTZ, // round towards zero 48 | CL_HALF_RTP, // round towards positive infinity 49 | CL_HALF_RTN, // round towards negative infinity 50 | } cl_half_rounding_mode; 51 | 52 | 53 | /* Private utility macros. */ 54 | #define CL_HALF_EXP_MASK 0x7C00 55 | #define CL_HALF_MAX_FINITE_MAG 0x7BFF 56 | 57 | 58 | /* 59 | * Utility to deal with values that overflow when converting to half precision. 60 | */ 61 | static inline cl_half cl_half_handle_overflow(cl_half_rounding_mode rounding_mode, 62 | uint16_t sign) 63 | { 64 | if (rounding_mode == CL_HALF_RTZ) 65 | { 66 | // Round overflow towards zero -> largest finite number (preserving sign) 67 | return (sign << 15) | CL_HALF_MAX_FINITE_MAG; 68 | } 69 | else if (rounding_mode == CL_HALF_RTP && sign) 70 | { 71 | // Round negative overflow towards positive infinity -> most negative finite number 72 | return (1 << 15) | CL_HALF_MAX_FINITE_MAG; 73 | } 74 | else if (rounding_mode == CL_HALF_RTN && !sign) 75 | { 76 | // Round positive overflow towards negative infinity -> largest finite number 77 | return CL_HALF_MAX_FINITE_MAG; 78 | } 79 | 80 | // Overflow to infinity 81 | return (sign << 15) | CL_HALF_EXP_MASK; 82 | } 83 | 84 | /* 85 | * Utility to deal with values that underflow when converting to half precision. 86 | */ 87 | static inline cl_half cl_half_handle_underflow(cl_half_rounding_mode rounding_mode, 88 | uint16_t sign) 89 | { 90 | if (rounding_mode == CL_HALF_RTP && !sign) 91 | { 92 | // Round underflow towards positive infinity -> smallest positive value 93 | return (sign << 15) | 1; 94 | } 95 | else if (rounding_mode == CL_HALF_RTN && sign) 96 | { 97 | // Round underflow towards negative infinity -> largest negative value 98 | return (sign << 15) | 1; 99 | } 100 | 101 | // Flush to zero 102 | return (sign << 15); 103 | } 104 | 105 | 106 | /** 107 | * Convert a cl_float to a cl_half. 108 | */ 109 | static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode rounding_mode) 110 | { 111 | // Type-punning to get direct access to underlying bits 112 | union 113 | { 114 | cl_float f; 115 | uint32_t i; 116 | } f32; 117 | f32.f = f; 118 | 119 | // Extract sign bit 120 | uint16_t sign = f32.i >> 31; 121 | 122 | // Extract FP32 exponent and mantissa 123 | uint32_t f_exp = (f32.i >> (CL_FLT_MANT_DIG - 1)) & 0xFF; 124 | uint32_t f_mant = f32.i & ((1 << (CL_FLT_MANT_DIG - 1)) - 1); 125 | 126 | // Remove FP32 exponent bias 127 | int32_t exp = f_exp - CL_FLT_MAX_EXP + 1; 128 | 129 | // Add FP16 exponent bias 130 | uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1); 131 | 132 | // Position of the bit that will become the FP16 mantissa LSB 133 | uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG; 134 | 135 | // Check for NaN / infinity 136 | if (f_exp == 0xFF) 137 | { 138 | if (f_mant) 139 | { 140 | // NaN -> propagate mantissa and silence it 141 | uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); 142 | h_mant |= 0x200; 143 | return (sign << 15) | CL_HALF_EXP_MASK | h_mant; 144 | } 145 | else 146 | { 147 | // Infinity -> zero mantissa 148 | return (sign << 15) | CL_HALF_EXP_MASK; 149 | } 150 | } 151 | 152 | // Check for zero 153 | if (!f_exp && !f_mant) 154 | { 155 | return (sign << 15); 156 | } 157 | 158 | // Check for overflow 159 | if (exp >= CL_HALF_MAX_EXP) 160 | { 161 | return cl_half_handle_overflow(rounding_mode, sign); 162 | } 163 | 164 | // Check for underflow 165 | if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) 166 | { 167 | return cl_half_handle_underflow(rounding_mode, sign); 168 | } 169 | 170 | // Check for value that will become denormal 171 | if (exp < -14) 172 | { 173 | // Denormal -> include the implicit 1 from the FP32 mantissa 174 | h_exp = 0; 175 | f_mant |= 1 << (CL_FLT_MANT_DIG - 1); 176 | 177 | // Mantissa shift amount depends on exponent 178 | lsb_pos = -exp + (CL_FLT_MANT_DIG - 25); 179 | } 180 | 181 | // Generate FP16 mantissa by shifting FP32 mantissa 182 | uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); 183 | 184 | // Check whether we need to round 185 | uint32_t halfway = 1 << (lsb_pos - 1); 186 | uint32_t mask = (halfway << 1) - 1; 187 | switch (rounding_mode) 188 | { 189 | case CL_HALF_RTE: 190 | if ((f_mant & mask) > halfway) 191 | { 192 | // More than halfway -> round up 193 | h_mant += 1; 194 | } 195 | else if ((f_mant & mask) == halfway) 196 | { 197 | // Exactly halfway -> round to nearest even 198 | if (h_mant & 0x1) 199 | h_mant += 1; 200 | } 201 | break; 202 | case CL_HALF_RTZ: 203 | // Mantissa has already been truncated -> do nothing 204 | break; 205 | case CL_HALF_RTP: 206 | if ((f_mant & mask) && !sign) 207 | { 208 | // Round positive numbers up 209 | h_mant += 1; 210 | } 211 | break; 212 | case CL_HALF_RTN: 213 | if ((f_mant & mask) && sign) 214 | { 215 | // Round negative numbers down 216 | h_mant += 1; 217 | } 218 | break; 219 | } 220 | 221 | // Check for mantissa overflow 222 | if (h_mant & 0x400) 223 | { 224 | h_exp += 1; 225 | h_mant = 0; 226 | } 227 | 228 | return (sign << 15) | (h_exp << 10) | h_mant; 229 | } 230 | 231 | 232 | /** 233 | * Convert a cl_double to a cl_half. 234 | */ 235 | static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rounding_mode) 236 | { 237 | // Type-punning to get direct access to underlying bits 238 | union 239 | { 240 | cl_double d; 241 | uint64_t i; 242 | } f64; 243 | f64.d = d; 244 | 245 | // Extract sign bit 246 | uint16_t sign = f64.i >> 63; 247 | 248 | // Extract FP64 exponent and mantissa 249 | uint64_t d_exp = (f64.i >> (CL_DBL_MANT_DIG - 1)) & 0x7FF; 250 | uint64_t d_mant = f64.i & (((uint64_t)1 << (CL_DBL_MANT_DIG - 1)) - 1); 251 | 252 | // Remove FP64 exponent bias 253 | int64_t exp = d_exp - CL_DBL_MAX_EXP + 1; 254 | 255 | // Add FP16 exponent bias 256 | uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1); 257 | 258 | // Position of the bit that will become the FP16 mantissa LSB 259 | uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG; 260 | 261 | // Check for NaN / infinity 262 | if (d_exp == 0x7FF) 263 | { 264 | if (d_mant) 265 | { 266 | // NaN -> propagate mantissa and silence it 267 | uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); 268 | h_mant |= 0x200; 269 | return (sign << 15) | CL_HALF_EXP_MASK | h_mant; 270 | } 271 | else 272 | { 273 | // Infinity -> zero mantissa 274 | return (sign << 15) | CL_HALF_EXP_MASK; 275 | } 276 | } 277 | 278 | // Check for zero 279 | if (!d_exp && !d_mant) 280 | { 281 | return (sign << 15); 282 | } 283 | 284 | // Check for overflow 285 | if (exp >= CL_HALF_MAX_EXP) 286 | { 287 | return cl_half_handle_overflow(rounding_mode, sign); 288 | } 289 | 290 | // Check for underflow 291 | if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) 292 | { 293 | return cl_half_handle_underflow(rounding_mode, sign); 294 | } 295 | 296 | // Check for value that will become denormal 297 | if (exp < -14) 298 | { 299 | // Include the implicit 1 from the FP64 mantissa 300 | h_exp = 0; 301 | d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1); 302 | 303 | // Mantissa shift amount depends on exponent 304 | lsb_pos = (uint32_t)(-exp + (CL_DBL_MANT_DIG - 25)); 305 | } 306 | 307 | // Generate FP16 mantissa by shifting FP64 mantissa 308 | uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); 309 | 310 | // Check whether we need to round 311 | uint64_t halfway = (uint64_t)1 << (lsb_pos - 1); 312 | uint64_t mask = (halfway << 1) - 1; 313 | switch (rounding_mode) 314 | { 315 | case CL_HALF_RTE: 316 | if ((d_mant & mask) > halfway) 317 | { 318 | // More than halfway -> round up 319 | h_mant += 1; 320 | } 321 | else if ((d_mant & mask) == halfway) 322 | { 323 | // Exactly halfway -> round to nearest even 324 | if (h_mant & 0x1) 325 | h_mant += 1; 326 | } 327 | break; 328 | case CL_HALF_RTZ: 329 | // Mantissa has already been truncated -> do nothing 330 | break; 331 | case CL_HALF_RTP: 332 | if ((d_mant & mask) && !sign) 333 | { 334 | // Round positive numbers up 335 | h_mant += 1; 336 | } 337 | break; 338 | case CL_HALF_RTN: 339 | if ((d_mant & mask) && sign) 340 | { 341 | // Round negative numbers down 342 | h_mant += 1; 343 | } 344 | break; 345 | } 346 | 347 | // Check for mantissa overflow 348 | if (h_mant & 0x400) 349 | { 350 | h_exp += 1; 351 | h_mant = 0; 352 | } 353 | 354 | return (sign << 15) | (h_exp << 10) | h_mant; 355 | } 356 | 357 | 358 | /** 359 | * Convert a cl_half to a cl_float. 360 | */ 361 | static inline cl_float cl_half_to_float(cl_half h) 362 | { 363 | // Type-punning to get direct access to underlying bits 364 | union 365 | { 366 | cl_float f; 367 | uint32_t i; 368 | } f32; 369 | 370 | // Extract sign bit 371 | uint16_t sign = h >> 15; 372 | 373 | // Extract FP16 exponent and mantissa 374 | uint16_t h_exp = (h >> (CL_HALF_MANT_DIG - 1)) & 0x1F; 375 | uint16_t h_mant = h & 0x3FF; 376 | 377 | // Remove FP16 exponent bias 378 | int32_t exp = h_exp - CL_HALF_MAX_EXP + 1; 379 | 380 | // Add FP32 exponent bias 381 | uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1; 382 | 383 | // Check for NaN / infinity 384 | if (h_exp == 0x1F) 385 | { 386 | if (h_mant) 387 | { 388 | // NaN -> propagate mantissa and silence it 389 | uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG); 390 | f_mant |= 0x400000; 391 | f32.i = (sign << 31) | 0x7F800000 | f_mant; 392 | return f32.f; 393 | } 394 | else 395 | { 396 | // Infinity -> zero mantissa 397 | f32.i = (sign << 31) | 0x7F800000; 398 | return f32.f; 399 | } 400 | } 401 | 402 | // Check for zero / denormal 403 | if (h_exp == 0) 404 | { 405 | if (h_mant == 0) 406 | { 407 | // Zero -> zero exponent 408 | f_exp = 0; 409 | } 410 | else 411 | { 412 | // Denormal -> normalize it 413 | // - Shift mantissa to make most-significant 1 implicit 414 | // - Adjust exponent accordingly 415 | uint32_t shift = 0; 416 | while ((h_mant & 0x400) == 0) 417 | { 418 | h_mant <<= 1; 419 | shift++; 420 | } 421 | h_mant &= 0x3FF; 422 | f_exp -= shift - 1; 423 | } 424 | } 425 | 426 | f32.i = (sign << 31) | (f_exp << 23) | (h_mant << 13); 427 | return f32.f; 428 | } 429 | 430 | 431 | #undef CL_HALF_EXP_MASK 432 | #undef CL_HALF_MAX_FINITE_MAG 433 | 434 | 435 | #ifdef __cplusplus 436 | } 437 | #endif 438 | 439 | 440 | #endif /* OPENCL_CL_HALF_H */ 441 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_icd.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2019-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef OPENCL_CL_ICD_H 18 | #define OPENCL_CL_ICD_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #if defined(_WIN32) 26 | #include 27 | #include 28 | #include 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* 36 | * This file contains pointer type definitions for each of the CL API calls as 37 | * well as a type definition for the dispatch table used by the Khronos ICD 38 | * loader (see cl_khr_icd extension specification for background). 39 | */ 40 | 41 | /* API function pointer definitions */ 42 | 43 | // Platform APIs 44 | typedef cl_int(CL_API_CALL *cl_api_clGetPlatformIDs)( 45 | cl_uint num_entries, cl_platform_id *platforms, 46 | cl_uint *num_platforms) CL_API_SUFFIX__VERSION_1_0; 47 | 48 | typedef cl_int(CL_API_CALL *cl_api_clGetPlatformInfo)( 49 | cl_platform_id platform, cl_platform_info param_name, 50 | size_t param_value_size, void *param_value, 51 | size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 52 | 53 | // Device APIs 54 | typedef cl_int(CL_API_CALL *cl_api_clGetDeviceIDs)( 55 | cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, 56 | cl_device_id *devices, cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_0; 57 | 58 | typedef cl_int(CL_API_CALL *cl_api_clGetDeviceInfo)( 59 | cl_device_id device, cl_device_info param_name, size_t param_value_size, 60 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 61 | 62 | #ifdef CL_VERSION_1_2 63 | 64 | typedef cl_int(CL_API_CALL *cl_api_clCreateSubDevices)( 65 | cl_device_id in_device, 66 | const cl_device_partition_property *partition_properties, 67 | cl_uint num_entries, cl_device_id *out_devices, cl_uint *num_devices); 68 | 69 | typedef cl_int(CL_API_CALL *cl_api_clRetainDevice)( 70 | cl_device_id device) CL_API_SUFFIX__VERSION_1_2; 71 | 72 | typedef cl_int(CL_API_CALL *cl_api_clReleaseDevice)( 73 | cl_device_id device) CL_API_SUFFIX__VERSION_1_2; 74 | 75 | #else 76 | 77 | typedef void *cl_api_clCreateSubDevices; 78 | typedef void *cl_api_clRetainDevice; 79 | typedef void *cl_api_clReleaseDevice; 80 | 81 | #endif 82 | 83 | // Context APIs 84 | typedef cl_context(CL_API_CALL *cl_api_clCreateContext)( 85 | const cl_context_properties *properties, cl_uint num_devices, 86 | const cl_device_id *devices, 87 | void(CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), 88 | void *user_data, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 89 | 90 | typedef cl_context(CL_API_CALL *cl_api_clCreateContextFromType)( 91 | const cl_context_properties *properties, cl_device_type device_type, 92 | void(CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), 93 | void *user_data, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 94 | 95 | typedef cl_int(CL_API_CALL *cl_api_clRetainContext)( 96 | cl_context context) CL_API_SUFFIX__VERSION_1_0; 97 | 98 | typedef cl_int(CL_API_CALL *cl_api_clReleaseContext)( 99 | cl_context context) CL_API_SUFFIX__VERSION_1_0; 100 | 101 | typedef cl_int(CL_API_CALL *cl_api_clGetContextInfo)( 102 | cl_context context, cl_context_info param_name, size_t param_value_size, 103 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 104 | 105 | // Command Queue APIs 106 | typedef cl_command_queue(CL_API_CALL *cl_api_clCreateCommandQueue)( 107 | cl_context context, cl_device_id device, 108 | cl_command_queue_properties properties, 109 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 110 | 111 | #ifdef CL_VERSION_2_0 112 | 113 | typedef 114 | cl_command_queue(CL_API_CALL *cl_api_clCreateCommandQueueWithProperties)( 115 | cl_context /* context */, cl_device_id /* device */, 116 | const cl_queue_properties * /* properties */, 117 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; 118 | 119 | #else 120 | 121 | typedef void *cl_api_clCreateCommandQueueWithProperties; 122 | 123 | #endif 124 | 125 | typedef cl_int(CL_API_CALL *cl_api_clRetainCommandQueue)( 126 | cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; 127 | 128 | typedef cl_int(CL_API_CALL *cl_api_clReleaseCommandQueue)( 129 | cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; 130 | 131 | typedef cl_int(CL_API_CALL *cl_api_clGetCommandQueueInfo)( 132 | cl_command_queue command_queue, cl_command_queue_info param_name, 133 | size_t param_value_size, void *param_value, 134 | size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 135 | 136 | // Memory Object APIs 137 | typedef cl_mem(CL_API_CALL *cl_api_clCreateBuffer)( 138 | cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, 139 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 140 | 141 | #ifdef CL_VERSION_1_2 142 | 143 | typedef cl_mem(CL_API_CALL *cl_api_clCreateImage)( 144 | cl_context context, cl_mem_flags flags, const cl_image_format *image_format, 145 | const cl_image_desc *image_desc, void *host_ptr, 146 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 147 | 148 | #else 149 | 150 | typedef void *cl_api_clCreateImage; 151 | 152 | #endif 153 | 154 | #ifdef CL_VERSION_3_0 155 | 156 | typedef cl_mem(CL_API_CALL *cl_api_clCreateBufferWithProperties)( 157 | cl_context context, const cl_mem_properties *properties, cl_mem_flags flags, 158 | size_t size, void *host_ptr, 159 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_3_0; 160 | 161 | typedef cl_mem(CL_API_CALL *cl_api_clCreateImageWithProperties)( 162 | cl_context context, const cl_mem_properties *properties, cl_mem_flags flags, 163 | const cl_image_format *image_format, const cl_image_desc *image_desc, 164 | void *host_ptr, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_3_0; 165 | 166 | typedef cl_int(CL_API_CALL* cl_api_clSetContextDestructorCallback)( 167 | cl_context context, 168 | void(CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), 169 | void* user_data) CL_API_SUFFIX__VERSION_3_0; 170 | 171 | #else 172 | 173 | typedef void *cl_api_clCreateBufferWithProperties; 174 | typedef void *cl_api_clCreateImageWithProperties; 175 | typedef void *cl_api_clSetContextDestructorCallback; 176 | 177 | #endif 178 | 179 | typedef cl_int(CL_API_CALL *cl_api_clRetainMemObject)( 180 | cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; 181 | 182 | typedef cl_int(CL_API_CALL *cl_api_clReleaseMemObject)( 183 | cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; 184 | 185 | typedef cl_int(CL_API_CALL *cl_api_clGetSupportedImageFormats)( 186 | cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, 187 | cl_uint num_entries, cl_image_format *image_formats, 188 | cl_uint *num_image_formats) CL_API_SUFFIX__VERSION_1_0; 189 | 190 | typedef cl_int(CL_API_CALL *cl_api_clGetMemObjectInfo)( 191 | cl_mem memobj, cl_mem_info param_name, size_t param_value_size, 192 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 193 | 194 | typedef cl_int(CL_API_CALL *cl_api_clGetImageInfo)( 195 | cl_mem image, cl_image_info param_name, size_t param_value_size, 196 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 197 | 198 | #ifdef CL_VERSION_2_0 199 | 200 | typedef cl_mem(CL_API_CALL *cl_api_clCreatePipe)( 201 | cl_context /* context */, cl_mem_flags /* flags */, 202 | cl_uint /* pipe_packet_size */, cl_uint /* pipe_max_packets */, 203 | const cl_pipe_properties * /* properties */, 204 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; 205 | 206 | typedef cl_int(CL_API_CALL *cl_api_clGetPipeInfo)( 207 | cl_mem /* pipe */, cl_pipe_info /* param_name */, 208 | size_t /* param_value_size */, void * /* param_value */, 209 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_2_0; 210 | 211 | typedef void *(CL_API_CALL *cl_api_clSVMAlloc)( 212 | cl_context /* context */, cl_svm_mem_flags /* flags */, size_t /* size */, 213 | unsigned int /* alignment */)CL_API_SUFFIX__VERSION_2_0; 214 | 215 | typedef void(CL_API_CALL *cl_api_clSVMFree)( 216 | cl_context /* context */, 217 | void * /* svm_pointer */) CL_API_SUFFIX__VERSION_2_0; 218 | 219 | #else 220 | 221 | typedef void *cl_api_clCreatePipe; 222 | typedef void *cl_api_clGetPipeInfo; 223 | typedef void *cl_api_clSVMAlloc; 224 | typedef void *cl_api_clSVMFree; 225 | 226 | #endif 227 | 228 | // Sampler APIs 229 | typedef cl_sampler(CL_API_CALL *cl_api_clCreateSampler)( 230 | cl_context context, cl_bool normalized_coords, 231 | cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, 232 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 233 | 234 | typedef cl_int(CL_API_CALL *cl_api_clRetainSampler)( 235 | cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; 236 | 237 | typedef cl_int(CL_API_CALL *cl_api_clReleaseSampler)( 238 | cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; 239 | 240 | typedef cl_int(CL_API_CALL *cl_api_clGetSamplerInfo)( 241 | cl_sampler sampler, cl_sampler_info param_name, size_t param_value_size, 242 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 243 | 244 | #ifdef CL_VERSION_2_0 245 | 246 | typedef 247 | cl_sampler(CL_API_CALL *cl_api_clCreateSamplerWithProperties)( 248 | cl_context /* context */, 249 | const cl_sampler_properties * /* sampler_properties */, 250 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; 251 | 252 | #else 253 | 254 | typedef void *cl_api_clCreateSamplerWithProperties; 255 | 256 | #endif 257 | 258 | // Program Object APIs 259 | typedef cl_program(CL_API_CALL *cl_api_clCreateProgramWithSource)( 260 | cl_context context, cl_uint count, const char **strings, 261 | const size_t *lengths, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 262 | 263 | typedef cl_program(CL_API_CALL *cl_api_clCreateProgramWithBinary)( 264 | cl_context context, cl_uint num_devices, const cl_device_id *device_list, 265 | const size_t *lengths, const unsigned char **binaries, 266 | cl_int *binary_status, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 267 | 268 | #ifdef CL_VERSION_1_2 269 | 270 | typedef 271 | cl_program(CL_API_CALL *cl_api_clCreateProgramWithBuiltInKernels)( 272 | cl_context context, cl_uint num_devices, const cl_device_id *device_list, 273 | const char *kernel_names, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 274 | 275 | #else 276 | 277 | typedef void *cl_api_clCreateProgramWithBuiltInKernels; 278 | 279 | #endif 280 | 281 | typedef cl_int(CL_API_CALL *cl_api_clRetainProgram)( 282 | cl_program program) CL_API_SUFFIX__VERSION_1_0; 283 | 284 | typedef cl_int(CL_API_CALL *cl_api_clReleaseProgram)( 285 | cl_program program) CL_API_SUFFIX__VERSION_1_0; 286 | 287 | typedef cl_int(CL_API_CALL *cl_api_clBuildProgram)( 288 | cl_program program, cl_uint num_devices, const cl_device_id *device_list, 289 | const char *options, 290 | void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), 291 | void *user_data) CL_API_SUFFIX__VERSION_1_0; 292 | 293 | #ifdef CL_VERSION_1_2 294 | 295 | typedef cl_int(CL_API_CALL *cl_api_clCompileProgram)( 296 | cl_program program, cl_uint num_devices, const cl_device_id *device_list, 297 | const char *options, cl_uint num_input_headers, 298 | const cl_program *input_headers, const char **header_include_names, 299 | void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), 300 | void *user_data) CL_API_SUFFIX__VERSION_1_2; 301 | 302 | typedef cl_program(CL_API_CALL *cl_api_clLinkProgram)( 303 | cl_context context, cl_uint num_devices, const cl_device_id *device_list, 304 | const char *options, cl_uint num_input_programs, 305 | const cl_program *input_programs, 306 | void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), 307 | void *user_data, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 308 | 309 | #else 310 | 311 | typedef void *cl_api_clCompileProgram; 312 | typedef void *cl_api_clLinkProgram; 313 | 314 | #endif 315 | 316 | #ifdef CL_VERSION_2_2 317 | 318 | typedef 319 | cl_int(CL_API_CALL *cl_api_clSetProgramSpecializationConstant)( 320 | cl_program program, cl_uint spec_id, size_t spec_size, 321 | const void *spec_value) CL_API_SUFFIX__VERSION_2_2; 322 | 323 | typedef cl_int(CL_API_CALL *cl_api_clSetProgramReleaseCallback)( 324 | cl_program program, 325 | void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), 326 | void *user_data) CL_API_SUFFIX__VERSION_2_2; 327 | 328 | #else 329 | 330 | typedef void *cl_api_clSetProgramSpecializationConstant; 331 | typedef void *cl_api_clSetProgramReleaseCallback; 332 | 333 | #endif 334 | 335 | #ifdef CL_VERSION_1_2 336 | 337 | typedef cl_int(CL_API_CALL *cl_api_clUnloadPlatformCompiler)( 338 | cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2; 339 | 340 | #else 341 | 342 | typedef void *cl_api_clUnloadPlatformCompiler; 343 | 344 | #endif 345 | 346 | typedef cl_int(CL_API_CALL *cl_api_clGetProgramInfo)( 347 | cl_program program, cl_program_info param_name, size_t param_value_size, 348 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 349 | 350 | typedef cl_int(CL_API_CALL *cl_api_clGetProgramBuildInfo)( 351 | cl_program program, cl_device_id device, cl_program_build_info param_name, 352 | size_t param_value_size, void *param_value, 353 | size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 354 | 355 | // Kernel Object APIs 356 | typedef cl_kernel(CL_API_CALL *cl_api_clCreateKernel)( 357 | cl_program program, const char *kernel_name, 358 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 359 | 360 | typedef cl_int(CL_API_CALL *cl_api_clCreateKernelsInProgram)( 361 | cl_program program, cl_uint num_kernels, cl_kernel *kernels, 362 | cl_uint *num_kernels_ret) CL_API_SUFFIX__VERSION_1_0; 363 | 364 | typedef cl_int(CL_API_CALL *cl_api_clRetainKernel)( 365 | cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; 366 | 367 | typedef cl_int(CL_API_CALL *cl_api_clReleaseKernel)( 368 | cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; 369 | 370 | typedef cl_int(CL_API_CALL *cl_api_clSetKernelArg)( 371 | cl_kernel kernel, cl_uint arg_index, size_t arg_size, 372 | const void *arg_value) CL_API_SUFFIX__VERSION_1_0; 373 | 374 | typedef cl_int(CL_API_CALL *cl_api_clGetKernelInfo)( 375 | cl_kernel kernel, cl_kernel_info param_name, size_t param_value_size, 376 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 377 | 378 | #ifdef CL_VERSION_1_2 379 | 380 | typedef cl_int(CL_API_CALL *cl_api_clGetKernelArgInfo)( 381 | cl_kernel kernel, cl_uint arg_indx, cl_kernel_arg_info param_name, 382 | size_t param_value_size, void *param_value, 383 | size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; 384 | 385 | #else 386 | 387 | typedef void *cl_api_clGetKernelArgInfo; 388 | 389 | #endif 390 | 391 | typedef cl_int(CL_API_CALL *cl_api_clGetKernelWorkGroupInfo)( 392 | cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, 393 | size_t param_value_size, void *param_value, 394 | size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 395 | 396 | #ifdef CL_VERSION_2_0 397 | 398 | typedef cl_int(CL_API_CALL *cl_api_clSetKernelArgSVMPointer)( 399 | cl_kernel /* kernel */, cl_uint /* arg_index */, 400 | const void * /* arg_value */) CL_API_SUFFIX__VERSION_2_0; 401 | 402 | typedef cl_int(CL_API_CALL *cl_api_clSetKernelExecInfo)( 403 | cl_kernel /* kernel */, cl_kernel_exec_info /* param_name */, 404 | size_t /* param_value_size */, 405 | const void * /* param_value */) CL_API_SUFFIX__VERSION_2_0; 406 | 407 | typedef cl_int(CL_API_CALL *cl_api_clGetKernelSubGroupInfoKHR)( 408 | cl_kernel /* in_kernel */, cl_device_id /*in_device*/, 409 | cl_kernel_sub_group_info /* param_name */, size_t /*input_value_size*/, 410 | const void * /*input_value*/, size_t /*param_value_size*/, 411 | void * /*param_value*/, 412 | size_t * /*param_value_size_ret*/) CL_API_SUFFIX__VERSION_2_0; 413 | 414 | #else 415 | 416 | typedef void *cl_api_clSetKernelArgSVMPointer; 417 | typedef void *cl_api_clSetKernelExecInfo; 418 | typedef void *cl_api_clGetKernelSubGroupInfoKHR; 419 | 420 | #endif 421 | 422 | // Event Object APIs 423 | typedef cl_int(CL_API_CALL *cl_api_clWaitForEvents)( 424 | cl_uint num_events, const cl_event *event_list) CL_API_SUFFIX__VERSION_1_0; 425 | 426 | typedef cl_int(CL_API_CALL *cl_api_clGetEventInfo)( 427 | cl_event event, cl_event_info param_name, size_t param_value_size, 428 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 429 | 430 | typedef cl_int(CL_API_CALL *cl_api_clRetainEvent)(cl_event event) 431 | CL_API_SUFFIX__VERSION_1_0; 432 | 433 | typedef cl_int(CL_API_CALL *cl_api_clReleaseEvent)(cl_event event) 434 | CL_API_SUFFIX__VERSION_1_0; 435 | 436 | // Profiling APIs 437 | typedef cl_int(CL_API_CALL *cl_api_clGetEventProfilingInfo)( 438 | cl_event event, cl_profiling_info param_name, size_t param_value_size, 439 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 440 | 441 | // Flush and Finish APIs 442 | typedef cl_int(CL_API_CALL *cl_api_clFlush)( 443 | cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; 444 | 445 | typedef cl_int(CL_API_CALL *cl_api_clFinish)( 446 | cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; 447 | 448 | // Enqueued Commands APIs 449 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueReadBuffer)( 450 | cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, 451 | size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, 452 | const cl_event *event_wait_list, 453 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 454 | 455 | #ifdef CL_VERSION_1_1 456 | 457 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueReadBufferRect)( 458 | cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, 459 | const size_t *buffer_origin, const size_t *host_origin, 460 | const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, 461 | size_t host_row_pitch, size_t host_slice_pitch, void *ptr, 462 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 463 | cl_event *event) CL_API_SUFFIX__VERSION_1_1; 464 | 465 | #else 466 | 467 | typedef void *cl_api_clEnqueueReadBufferRect; 468 | 469 | #endif 470 | 471 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueWriteBuffer)( 472 | cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, 473 | size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, 474 | const cl_event *event_wait_list, 475 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 476 | 477 | #ifdef CL_VERSION_1_1 478 | 479 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueWriteBufferRect)( 480 | cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, 481 | const size_t *buffer_origin, const size_t *host_origin, 482 | const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, 483 | size_t host_row_pitch, size_t host_slice_pitch, const void *ptr, 484 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 485 | cl_event *event) CL_API_SUFFIX__VERSION_1_1; 486 | 487 | #else 488 | 489 | typedef void *cl_api_clEnqueueWriteBufferRect; 490 | 491 | #endif 492 | 493 | #ifdef CL_VERSION_1_2 494 | 495 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueFillBuffer)( 496 | cl_command_queue command_queue, cl_mem buffer, const void *pattern, 497 | size_t pattern_size, size_t offset, size_t cb, 498 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 499 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 500 | 501 | #else 502 | 503 | typedef void *cl_api_clEnqueueFillBuffer; 504 | 505 | #endif 506 | 507 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyBuffer)( 508 | cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, 509 | size_t src_offset, size_t dst_offset, size_t cb, 510 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 511 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 512 | 513 | #ifdef CL_VERSION_1_1 514 | 515 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyBufferRect)( 516 | cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, 517 | const size_t *src_origin, const size_t *dst_origin, const size_t *region, 518 | size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, 519 | size_t dst_slice_pitch, cl_uint num_events_in_wait_list, 520 | const cl_event *event_wait_list, 521 | cl_event *event) CL_API_SUFFIX__VERSION_1_1; 522 | 523 | #else 524 | 525 | typedef void *cl_api_clEnqueueCopyBufferRect; 526 | 527 | #endif 528 | 529 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueReadImage)( 530 | cl_command_queue command_queue, cl_mem image, cl_bool blocking_read, 531 | const size_t *origin, const size_t *region, size_t row_pitch, 532 | size_t slice_pitch, void *ptr, cl_uint num_events_in_wait_list, 533 | const cl_event *event_wait_list, 534 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 535 | 536 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueWriteImage)( 537 | cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, 538 | const size_t *origin, const size_t *region, size_t input_row_pitch, 539 | size_t input_slice_pitch, const void *ptr, cl_uint num_events_in_wait_list, 540 | const cl_event *event_wait_list, 541 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 542 | 543 | #ifdef CL_VERSION_1_2 544 | 545 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueFillImage)( 546 | cl_command_queue command_queue, cl_mem image, const void *fill_color, 547 | const size_t origin[3], const size_t region[3], 548 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 549 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 550 | 551 | #else 552 | 553 | typedef void *cl_api_clEnqueueFillImage; 554 | 555 | #endif 556 | 557 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyImage)( 558 | cl_command_queue command_queue, cl_mem src_image, cl_mem dst_image, 559 | const size_t *src_origin, const size_t *dst_origin, const size_t *region, 560 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 561 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 562 | 563 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyImageToBuffer)( 564 | cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer, 565 | const size_t *src_origin, const size_t *region, size_t dst_offset, 566 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 567 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 568 | 569 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyBufferToImage)( 570 | cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image, 571 | size_t src_offset, const size_t *dst_origin, const size_t *region, 572 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 573 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 574 | 575 | typedef void *(CL_API_CALL *cl_api_clEnqueueMapBuffer)( 576 | cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, 577 | cl_map_flags map_flags, size_t offset, size_t cb, 578 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 579 | cl_event *event, cl_int *errcode_ret)CL_API_SUFFIX__VERSION_1_0; 580 | 581 | typedef void *(CL_API_CALL *cl_api_clEnqueueMapImage)( 582 | cl_command_queue command_queue, cl_mem image, cl_bool blocking_map, 583 | cl_map_flags map_flags, const size_t *origin, const size_t *region, 584 | size_t *image_row_pitch, size_t *image_slice_pitch, 585 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 586 | cl_event *event, cl_int *errcode_ret)CL_API_SUFFIX__VERSION_1_0; 587 | 588 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueUnmapMemObject)( 589 | cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, 590 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 591 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 592 | 593 | #ifdef CL_VERSION_1_2 594 | 595 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueMigrateMemObjects)( 596 | cl_command_queue command_queue, cl_uint num_mem_objects, 597 | const cl_mem *mem_objects, cl_mem_migration_flags flags, 598 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 599 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 600 | 601 | #else 602 | 603 | typedef void *cl_api_clEnqueueMigrateMemObjects; 604 | 605 | #endif 606 | 607 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueNDRangeKernel)( 608 | cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, 609 | const size_t *global_work_offset, const size_t *global_work_size, 610 | const size_t *local_work_size, cl_uint num_events_in_wait_list, 611 | const cl_event *event_wait_list, 612 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 613 | 614 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueTask)( 615 | cl_command_queue command_queue, cl_kernel kernel, 616 | cl_uint num_events_in_wait_list, const cl_event *event_wait_list, 617 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 618 | 619 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueNativeKernel)( 620 | cl_command_queue command_queue, void(CL_CALLBACK *user_func)(void *), 621 | void *args, size_t cb_args, cl_uint num_mem_objects, const cl_mem *mem_list, 622 | const void **args_mem_loc, cl_uint num_events_in_wait_list, 623 | const cl_event *event_wait_list, 624 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 625 | 626 | #ifdef CL_VERSION_1_2 627 | 628 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueMarkerWithWaitList)( 629 | cl_command_queue command_queue, cl_uint num_events_in_wait_list, 630 | const cl_event *event_wait_list, 631 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 632 | 633 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueBarrierWithWaitList)( 634 | cl_command_queue command_queue, cl_uint num_events_in_wait_list, 635 | const cl_event *event_wait_list, 636 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 637 | 638 | typedef void *( 639 | CL_API_CALL *cl_api_clGetExtensionFunctionAddressForPlatform)( 640 | cl_platform_id platform, 641 | const char *function_name)CL_API_SUFFIX__VERSION_1_2; 642 | 643 | #else 644 | 645 | typedef void *cl_api_clEnqueueMarkerWithWaitList; 646 | typedef void *cl_api_clEnqueueBarrierWithWaitList; 647 | typedef void *cl_api_clGetExtensionFunctionAddressForPlatform; 648 | 649 | #endif 650 | 651 | // Shared Virtual Memory APIs 652 | 653 | #ifdef CL_VERSION_2_0 654 | 655 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMFree)( 656 | cl_command_queue /* command_queue */, cl_uint /* num_svm_pointers */, 657 | void ** /* svm_pointers */, 658 | void(CL_CALLBACK *pfn_free_func)(cl_command_queue /* queue */, 659 | cl_uint /* num_svm_pointers */, 660 | void ** /* svm_pointers[] */, 661 | void * /* user_data */), 662 | void * /* user_data */, cl_uint /* num_events_in_wait_list */, 663 | const cl_event * /* event_wait_list */, 664 | cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 665 | 666 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMemcpy)( 667 | cl_command_queue /* command_queue */, cl_bool /* blocking_copy */, 668 | void * /* dst_ptr */, const void * /* src_ptr */, size_t /* size */, 669 | cl_uint /* num_events_in_wait_list */, 670 | const cl_event * /* event_wait_list */, 671 | cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 672 | 673 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMemFill)( 674 | cl_command_queue /* command_queue */, void * /* svm_ptr */, 675 | const void * /* pattern */, size_t /* pattern_size */, size_t /* size */, 676 | cl_uint /* num_events_in_wait_list */, 677 | const cl_event * /* event_wait_list */, 678 | cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 679 | 680 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMap)( 681 | cl_command_queue /* command_queue */, cl_bool /* blocking_map */, 682 | cl_map_flags /* map_flags */, void * /* svm_ptr */, size_t /* size */, 683 | cl_uint /* num_events_in_wait_list */, 684 | const cl_event * /* event_wait_list */, 685 | cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 686 | 687 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMUnmap)( 688 | cl_command_queue /* command_queue */, void * /* svm_ptr */, 689 | cl_uint /* num_events_in_wait_list */, 690 | const cl_event * /* event_wait_list */, 691 | cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 692 | 693 | #else 694 | 695 | typedef void *cl_api_clEnqueueSVMFree; 696 | typedef void *cl_api_clEnqueueSVMMemcpy; 697 | typedef void *cl_api_clEnqueueSVMMemFill; 698 | typedef void *cl_api_clEnqueueSVMMap; 699 | typedef void *cl_api_clEnqueueSVMUnmap; 700 | 701 | #endif 702 | 703 | // Deprecated APIs 704 | typedef cl_int(CL_API_CALL *cl_api_clSetCommandQueueProperty)( 705 | cl_command_queue command_queue, cl_command_queue_properties properties, 706 | cl_bool enable, cl_command_queue_properties *old_properties) 707 | CL_API_SUFFIX__VERSION_1_0_DEPRECATED; 708 | 709 | typedef cl_mem(CL_API_CALL *cl_api_clCreateImage2D)( 710 | cl_context context, cl_mem_flags flags, const cl_image_format *image_format, 711 | size_t image_width, size_t image_height, size_t image_row_pitch, 712 | void *host_ptr, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 713 | 714 | typedef cl_mem(CL_API_CALL *cl_api_clCreateImage3D)( 715 | cl_context context, cl_mem_flags flags, const cl_image_format *image_format, 716 | size_t image_width, size_t image_height, size_t image_depth, 717 | size_t image_row_pitch, size_t image_slice_pitch, void *host_ptr, 718 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 719 | 720 | typedef cl_int(CL_API_CALL *cl_api_clUnloadCompiler)(void) 721 | CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 722 | 723 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueMarker)( 724 | cl_command_queue command_queue, 725 | cl_event *event) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 726 | 727 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueWaitForEvents)( 728 | cl_command_queue command_queue, cl_uint num_events, 729 | const cl_event *event_list) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 730 | 731 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueBarrier)( 732 | cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 733 | 734 | typedef void *(CL_API_CALL *cl_api_clGetExtensionFunctionAddress)( 735 | const char *function_name)CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 736 | 737 | // GL and other APIs 738 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLBuffer)( 739 | cl_context context, cl_mem_flags flags, cl_GLuint bufobj, 740 | int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 741 | 742 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLTexture)( 743 | cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, 744 | cl_GLuint texture, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 745 | 746 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLTexture2D)( 747 | cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, 748 | cl_GLuint texture, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 749 | 750 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLTexture3D)( 751 | cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, 752 | cl_GLuint texture, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 753 | 754 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLRenderbuffer)( 755 | cl_context context, cl_mem_flags flags, cl_GLuint renderbuffer, 756 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 757 | 758 | typedef cl_int(CL_API_CALL *cl_api_clGetGLObjectInfo)( 759 | cl_mem memobj, cl_gl_object_type *gl_object_type, 760 | cl_GLuint *gl_object_name) CL_API_SUFFIX__VERSION_1_0; 761 | 762 | typedef cl_int(CL_API_CALL *cl_api_clGetGLTextureInfo)( 763 | cl_mem memobj, cl_gl_texture_info param_name, size_t param_value_size, 764 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 765 | 766 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueAcquireGLObjects)( 767 | cl_command_queue command_queue, cl_uint num_objects, 768 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 769 | const cl_event *event_wait_list, 770 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 771 | 772 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueReleaseGLObjects)( 773 | cl_command_queue command_queue, cl_uint num_objects, 774 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 775 | const cl_event *event_wait_list, 776 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 777 | 778 | /* cl_khr_gl_sharing */ 779 | typedef cl_int(CL_API_CALL *cl_api_clGetGLContextInfoKHR)( 780 | const cl_context_properties *properties, cl_gl_context_info param_name, 781 | size_t param_value_size, void *param_value, size_t *param_value_size_ret); 782 | 783 | /* cl_khr_gl_event */ 784 | typedef cl_event(CL_API_CALL *cl_api_clCreateEventFromGLsyncKHR)( 785 | cl_context context, cl_GLsync sync, cl_int *errcode_ret); 786 | 787 | #if defined(_WIN32) 788 | 789 | /* cl_khr_d3d10_sharing */ 790 | 791 | typedef cl_int(CL_API_CALL *cl_api_clGetDeviceIDsFromD3D10KHR)( 792 | cl_platform_id platform, cl_d3d10_device_source_khr d3d_device_source, 793 | void *d3d_object, cl_d3d10_device_set_khr d3d_device_set, 794 | cl_uint num_entries, cl_device_id *devices, 795 | cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_0; 796 | 797 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D10BufferKHR)( 798 | cl_context context, cl_mem_flags flags, ID3D10Buffer *resource, 799 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 800 | 801 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D10Texture2DKHR)( 802 | cl_context context, cl_mem_flags flags, ID3D10Texture2D *resource, 803 | UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 804 | 805 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D10Texture3DKHR)( 806 | cl_context context, cl_mem_flags flags, ID3D10Texture3D *resource, 807 | UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; 808 | 809 | typedef 810 | cl_int(CL_API_CALL *cl_api_clEnqueueAcquireD3D10ObjectsKHR)( 811 | cl_command_queue command_queue, cl_uint num_objects, 812 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 813 | const cl_event *event_wait_list, 814 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 815 | 816 | typedef 817 | cl_int(CL_API_CALL *cl_api_clEnqueueReleaseD3D10ObjectsKHR)( 818 | cl_command_queue command_queue, cl_uint num_objects, 819 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 820 | const cl_event *event_wait_list, 821 | cl_event *event) CL_API_SUFFIX__VERSION_1_0; 822 | 823 | extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR( 824 | cl_platform_id platform, cl_d3d10_device_source_khr d3d_device_source, 825 | void *d3d_object, cl_d3d10_device_set_khr d3d_device_set, 826 | cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices); 827 | 828 | extern CL_API_ENTRY cl_mem CL_API_CALL 829 | clCreateFromD3D10BufferKHR(cl_context context, cl_mem_flags flags, 830 | ID3D10Buffer *resource, cl_int *errcode_ret); 831 | 832 | extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10Texture2DKHR( 833 | cl_context context, cl_mem_flags flags, ID3D10Texture2D *resource, 834 | UINT subresource, cl_int *errcode_ret); 835 | 836 | extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10Texture3DKHR( 837 | cl_context context, cl_mem_flags flags, ID3D10Texture3D *resource, 838 | UINT subresource, cl_int *errcode_ret); 839 | 840 | extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireD3D10ObjectsKHR( 841 | cl_command_queue command_queue, cl_uint num_objects, 842 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 843 | const cl_event *event_wait_list, cl_event *event); 844 | 845 | extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseD3D10ObjectsKHR( 846 | cl_command_queue command_queue, cl_uint num_objects, 847 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 848 | const cl_event *event_wait_list, cl_event *event); 849 | 850 | /* cl_khr_d3d11_sharing */ 851 | typedef cl_int(CL_API_CALL *cl_api_clGetDeviceIDsFromD3D11KHR)( 852 | cl_platform_id platform, cl_d3d11_device_source_khr d3d_device_source, 853 | void *d3d_object, cl_d3d11_device_set_khr d3d_device_set, 854 | cl_uint num_entries, cl_device_id *devices, 855 | cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2; 856 | 857 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D11BufferKHR)( 858 | cl_context context, cl_mem_flags flags, ID3D11Buffer *resource, 859 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 860 | 861 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D11Texture2DKHR)( 862 | cl_context context, cl_mem_flags flags, ID3D11Texture2D *resource, 863 | UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 864 | 865 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D11Texture3DKHR)( 866 | cl_context context, cl_mem_flags flags, ID3D11Texture3D *resource, 867 | UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 868 | 869 | typedef 870 | cl_int(CL_API_CALL *cl_api_clEnqueueAcquireD3D11ObjectsKHR)( 871 | cl_command_queue command_queue, cl_uint num_objects, 872 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 873 | const cl_event *event_wait_list, 874 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 875 | 876 | typedef 877 | cl_int(CL_API_CALL *cl_api_clEnqueueReleaseD3D11ObjectsKHR)( 878 | cl_command_queue command_queue, cl_uint num_objects, 879 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 880 | const cl_event *event_wait_list, 881 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 882 | 883 | /* cl_khr_dx9_media_sharing */ 884 | typedef 885 | cl_int(CL_API_CALL *cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR)( 886 | cl_platform_id platform, cl_uint num_media_adapters, 887 | cl_dx9_media_adapter_type_khr *media_adapters_type, void *media_adapters, 888 | cl_dx9_media_adapter_set_khr media_adapter_set, cl_uint num_entries, 889 | cl_device_id *devices, cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2; 890 | 891 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromDX9MediaSurfaceKHR)( 892 | cl_context context, cl_mem_flags flags, 893 | cl_dx9_media_adapter_type_khr adapter_type, void *surface_info, 894 | cl_uint plane, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; 895 | 896 | typedef 897 | cl_int(CL_API_CALL *cl_api_clEnqueueAcquireDX9MediaSurfacesKHR)( 898 | cl_command_queue command_queue, cl_uint num_objects, 899 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 900 | const cl_event *event_wait_list, 901 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 902 | 903 | typedef 904 | cl_int(CL_API_CALL *cl_api_clEnqueueReleaseDX9MediaSurfacesKHR)( 905 | cl_command_queue command_queue, cl_uint num_objects, 906 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 907 | const cl_event *event_wait_list, 908 | cl_event *event) CL_API_SUFFIX__VERSION_1_2; 909 | 910 | /* cl_khr_d3d11_sharing */ 911 | extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR( 912 | cl_platform_id platform, cl_d3d11_device_source_khr d3d_device_source, 913 | void *d3d_object, cl_d3d11_device_set_khr d3d_device_set, 914 | cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices); 915 | 916 | extern CL_API_ENTRY cl_mem CL_API_CALL 917 | clCreateFromD3D11BufferKHR(cl_context context, cl_mem_flags flags, 918 | ID3D11Buffer *resource, cl_int *errcode_ret); 919 | 920 | extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11Texture2DKHR( 921 | cl_context context, cl_mem_flags flags, ID3D11Texture2D *resource, 922 | UINT subresource, cl_int *errcode_ret); 923 | 924 | extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11Texture3DKHR( 925 | cl_context context, cl_mem_flags flags, ID3D11Texture3D *resource, 926 | UINT subresource, cl_int *errcode_ret); 927 | 928 | extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireD3D11ObjectsKHR( 929 | cl_command_queue command_queue, cl_uint num_objects, 930 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 931 | const cl_event *event_wait_list, cl_event *event); 932 | 933 | extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseD3D11ObjectsKHR( 934 | cl_command_queue command_queue, cl_uint num_objects, 935 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 936 | const cl_event *event_wait_list, cl_event *event); 937 | 938 | /* cl_khr_dx9_media_sharing */ 939 | extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromDX9MediaAdapterKHR( 940 | cl_platform_id platform, cl_uint num_media_adapters, 941 | cl_dx9_media_adapter_type_khr *media_adapter_type, void *media_adapters, 942 | cl_dx9_media_adapter_set_khr media_adapter_set, cl_uint num_entries, 943 | cl_device_id *devices, cl_uint *num_devices); 944 | 945 | extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromDX9MediaSurfaceKHR( 946 | cl_context context, cl_mem_flags flags, 947 | cl_dx9_media_adapter_type_khr adapter_type, void *surface_info, 948 | cl_uint plane, cl_int *errcode_ret); 949 | 950 | extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireDX9MediaSurfacesKHR( 951 | cl_command_queue command_queue, cl_uint num_objects, 952 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 953 | const cl_event *event_wait_list, cl_event *event); 954 | 955 | extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseDX9MediaSurfacesKHR( 956 | cl_command_queue command_queue, cl_uint num_objects, 957 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 958 | const cl_event *event_wait_list, cl_event *event); 959 | 960 | #else 961 | 962 | /* cl_khr_d3d10_sharing */ 963 | typedef void *cl_api_clGetDeviceIDsFromD3D10KHR; 964 | typedef void *cl_api_clCreateFromD3D10BufferKHR; 965 | typedef void *cl_api_clCreateFromD3D10Texture2DKHR; 966 | typedef void *cl_api_clCreateFromD3D10Texture3DKHR; 967 | typedef void *cl_api_clEnqueueAcquireD3D10ObjectsKHR; 968 | typedef void *cl_api_clEnqueueReleaseD3D10ObjectsKHR; 969 | 970 | /* cl_khr_d3d11_sharing */ 971 | typedef void *cl_api_clGetDeviceIDsFromD3D11KHR; 972 | typedef void *cl_api_clCreateFromD3D11BufferKHR; 973 | typedef void *cl_api_clCreateFromD3D11Texture2DKHR; 974 | typedef void *cl_api_clCreateFromD3D11Texture3DKHR; 975 | typedef void *cl_api_clEnqueueAcquireD3D11ObjectsKHR; 976 | typedef void *cl_api_clEnqueueReleaseD3D11ObjectsKHR; 977 | 978 | /* cl_khr_dx9_media_sharing */ 979 | typedef void *cl_api_clCreateFromDX9MediaSurfaceKHR; 980 | typedef void *cl_api_clEnqueueAcquireDX9MediaSurfacesKHR; 981 | typedef void *cl_api_clEnqueueReleaseDX9MediaSurfacesKHR; 982 | typedef void *cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR; 983 | 984 | #endif 985 | 986 | /* OpenCL 1.1 */ 987 | 988 | #ifdef CL_VERSION_1_1 989 | 990 | typedef cl_int(CL_API_CALL *cl_api_clSetEventCallback)( 991 | cl_event /* event */, cl_int /* command_exec_callback_type */, 992 | void(CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), 993 | void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; 994 | 995 | typedef cl_mem(CL_API_CALL *cl_api_clCreateSubBuffer)( 996 | cl_mem /* buffer */, cl_mem_flags /* flags */, 997 | cl_buffer_create_type /* buffer_create_type */, 998 | const void * /* buffer_create_info */, 999 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; 1000 | 1001 | typedef 1002 | cl_int(CL_API_CALL *cl_api_clSetMemObjectDestructorCallback)( 1003 | cl_mem /* memobj */, 1004 | void(CL_CALLBACK * /*pfn_notify*/)(cl_mem /* memobj */, 1005 | void * /*user_data*/), 1006 | void * /*user_data */) CL_API_SUFFIX__VERSION_1_1; 1007 | 1008 | typedef cl_event(CL_API_CALL *cl_api_clCreateUserEvent)( 1009 | cl_context /* context */, 1010 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; 1011 | 1012 | typedef cl_int(CL_API_CALL *cl_api_clSetUserEventStatus)( 1013 | cl_event /* event */, 1014 | cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; 1015 | 1016 | #else 1017 | 1018 | typedef void *cl_api_clSetEventCallback; 1019 | typedef void *cl_api_clCreateSubBuffer; 1020 | typedef void *cl_api_clSetMemObjectDestructorCallback; 1021 | typedef void *cl_api_clCreateUserEvent; 1022 | typedef void *cl_api_clSetUserEventStatus; 1023 | 1024 | #endif 1025 | 1026 | typedef cl_int(CL_API_CALL *cl_api_clCreateSubDevicesEXT)( 1027 | cl_device_id in_device, 1028 | const cl_device_partition_property_ext *partition_properties, 1029 | cl_uint num_entries, cl_device_id *out_devices, cl_uint *num_devices); 1030 | 1031 | typedef cl_int(CL_API_CALL *cl_api_clRetainDeviceEXT)( 1032 | cl_device_id device) CL_API_SUFFIX__VERSION_1_0; 1033 | 1034 | typedef cl_int(CL_API_CALL *cl_api_clReleaseDeviceEXT)( 1035 | cl_device_id device) CL_API_SUFFIX__VERSION_1_0; 1036 | 1037 | /* cl_khr_egl_image */ 1038 | typedef cl_mem(CL_API_CALL *cl_api_clCreateFromEGLImageKHR)( 1039 | cl_context context, CLeglDisplayKHR display, CLeglImageKHR image, 1040 | cl_mem_flags flags, const cl_egl_image_properties_khr *properties, 1041 | cl_int *errcode_ret); 1042 | 1043 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueAcquireEGLObjectsKHR)( 1044 | cl_command_queue command_queue, cl_uint num_objects, 1045 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 1046 | const cl_event *event_wait_list, cl_event *event); 1047 | 1048 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueReleaseEGLObjectsKHR)( 1049 | cl_command_queue command_queue, cl_uint num_objects, 1050 | const cl_mem *mem_objects, cl_uint num_events_in_wait_list, 1051 | const cl_event *event_wait_list, cl_event *event); 1052 | 1053 | /* cl_khr_egl_event */ 1054 | typedef cl_event(CL_API_CALL *cl_api_clCreateEventFromEGLSyncKHR)( 1055 | cl_context context, CLeglSyncKHR sync, CLeglDisplayKHR display, 1056 | cl_int *errcode_ret); 1057 | 1058 | #ifdef CL_VERSION_2_1 1059 | 1060 | typedef cl_int(CL_API_CALL *cl_api_clSetDefaultDeviceCommandQueue)( 1061 | cl_context context, cl_device_id device, 1062 | cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1; 1063 | 1064 | typedef cl_program(CL_API_CALL *cl_api_clCreateProgramWithIL)( 1065 | cl_context context, const void *il, size_t length, 1066 | cl_int *errcode_ret) CL_API_SUFFIX__VERSION_2_1; 1067 | 1068 | typedef cl_int(CL_API_CALL *cl_api_clGetKernelSubGroupInfo)( 1069 | cl_kernel kernel, cl_device_id device, cl_kernel_sub_group_info param_name, 1070 | size_t input_value_size, const void *input_value, size_t param_value_size, 1071 | void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_2_1; 1072 | 1073 | typedef cl_kernel(CL_API_CALL *cl_api_clCloneKernel)( 1074 | cl_kernel source_kernel, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_2_1; 1075 | 1076 | typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMigrateMem)( 1077 | cl_command_queue command_queue, cl_uint num_svm_pointers, 1078 | const void **svm_pointers, const size_t *sizes, 1079 | cl_mem_migration_flags flags, cl_uint num_events_in_wait_list, 1080 | const cl_event *event_wait_list, 1081 | cl_event *event) CL_API_SUFFIX__VERSION_2_1; 1082 | 1083 | typedef cl_int(CL_API_CALL *cl_api_clGetDeviceAndHostTimer)( 1084 | cl_device_id device, cl_ulong *device_timestamp, 1085 | cl_ulong *host_timestamp) CL_API_SUFFIX__VERSION_2_1; 1086 | 1087 | typedef cl_int(CL_API_CALL *cl_api_clGetHostTimer)( 1088 | cl_device_id device, cl_ulong *host_timestamp) CL_API_SUFFIX__VERSION_2_1; 1089 | 1090 | #else 1091 | 1092 | typedef void *cl_api_clSetDefaultDeviceCommandQueue; 1093 | typedef void *cl_api_clCreateProgramWithIL; 1094 | typedef void *cl_api_clGetKernelSubGroupInfo; 1095 | typedef void *cl_api_clCloneKernel; 1096 | typedef void *cl_api_clEnqueueSVMMigrateMem; 1097 | typedef void *cl_api_clGetDeviceAndHostTimer; 1098 | typedef void *cl_api_clGetHostTimer; 1099 | 1100 | #endif 1101 | 1102 | /* Vendor dispatch table structure */ 1103 | 1104 | typedef struct _cl_icd_dispatch { 1105 | /* OpenCL 1.0 */ 1106 | cl_api_clGetPlatformIDs clGetPlatformIDs; 1107 | cl_api_clGetPlatformInfo clGetPlatformInfo; 1108 | cl_api_clGetDeviceIDs clGetDeviceIDs; 1109 | cl_api_clGetDeviceInfo clGetDeviceInfo; 1110 | cl_api_clCreateContext clCreateContext; 1111 | cl_api_clCreateContextFromType clCreateContextFromType; 1112 | cl_api_clRetainContext clRetainContext; 1113 | cl_api_clReleaseContext clReleaseContext; 1114 | cl_api_clGetContextInfo clGetContextInfo; 1115 | cl_api_clCreateCommandQueue clCreateCommandQueue; 1116 | cl_api_clRetainCommandQueue clRetainCommandQueue; 1117 | cl_api_clReleaseCommandQueue clReleaseCommandQueue; 1118 | cl_api_clGetCommandQueueInfo clGetCommandQueueInfo; 1119 | cl_api_clSetCommandQueueProperty clSetCommandQueueProperty; 1120 | cl_api_clCreateBuffer clCreateBuffer; 1121 | cl_api_clCreateImage2D clCreateImage2D; 1122 | cl_api_clCreateImage3D clCreateImage3D; 1123 | cl_api_clRetainMemObject clRetainMemObject; 1124 | cl_api_clReleaseMemObject clReleaseMemObject; 1125 | cl_api_clGetSupportedImageFormats clGetSupportedImageFormats; 1126 | cl_api_clGetMemObjectInfo clGetMemObjectInfo; 1127 | cl_api_clGetImageInfo clGetImageInfo; 1128 | cl_api_clCreateSampler clCreateSampler; 1129 | cl_api_clRetainSampler clRetainSampler; 1130 | cl_api_clReleaseSampler clReleaseSampler; 1131 | cl_api_clGetSamplerInfo clGetSamplerInfo; 1132 | cl_api_clCreateProgramWithSource clCreateProgramWithSource; 1133 | cl_api_clCreateProgramWithBinary clCreateProgramWithBinary; 1134 | cl_api_clRetainProgram clRetainProgram; 1135 | cl_api_clReleaseProgram clReleaseProgram; 1136 | cl_api_clBuildProgram clBuildProgram; 1137 | cl_api_clUnloadCompiler clUnloadCompiler; 1138 | cl_api_clGetProgramInfo clGetProgramInfo; 1139 | cl_api_clGetProgramBuildInfo clGetProgramBuildInfo; 1140 | cl_api_clCreateKernel clCreateKernel; 1141 | cl_api_clCreateKernelsInProgram clCreateKernelsInProgram; 1142 | cl_api_clRetainKernel clRetainKernel; 1143 | cl_api_clReleaseKernel clReleaseKernel; 1144 | cl_api_clSetKernelArg clSetKernelArg; 1145 | cl_api_clGetKernelInfo clGetKernelInfo; 1146 | cl_api_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; 1147 | cl_api_clWaitForEvents clWaitForEvents; 1148 | cl_api_clGetEventInfo clGetEventInfo; 1149 | cl_api_clRetainEvent clRetainEvent; 1150 | cl_api_clReleaseEvent clReleaseEvent; 1151 | cl_api_clGetEventProfilingInfo clGetEventProfilingInfo; 1152 | cl_api_clFlush clFlush; 1153 | cl_api_clFinish clFinish; 1154 | cl_api_clEnqueueReadBuffer clEnqueueReadBuffer; 1155 | cl_api_clEnqueueWriteBuffer clEnqueueWriteBuffer; 1156 | cl_api_clEnqueueCopyBuffer clEnqueueCopyBuffer; 1157 | cl_api_clEnqueueReadImage clEnqueueReadImage; 1158 | cl_api_clEnqueueWriteImage clEnqueueWriteImage; 1159 | cl_api_clEnqueueCopyImage clEnqueueCopyImage; 1160 | cl_api_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; 1161 | cl_api_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; 1162 | cl_api_clEnqueueMapBuffer clEnqueueMapBuffer; 1163 | cl_api_clEnqueueMapImage clEnqueueMapImage; 1164 | cl_api_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; 1165 | cl_api_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; 1166 | cl_api_clEnqueueTask clEnqueueTask; 1167 | cl_api_clEnqueueNativeKernel clEnqueueNativeKernel; 1168 | cl_api_clEnqueueMarker clEnqueueMarker; 1169 | cl_api_clEnqueueWaitForEvents clEnqueueWaitForEvents; 1170 | cl_api_clEnqueueBarrier clEnqueueBarrier; 1171 | cl_api_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; 1172 | cl_api_clCreateFromGLBuffer clCreateFromGLBuffer; 1173 | cl_api_clCreateFromGLTexture2D clCreateFromGLTexture2D; 1174 | cl_api_clCreateFromGLTexture3D clCreateFromGLTexture3D; 1175 | cl_api_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer; 1176 | cl_api_clGetGLObjectInfo clGetGLObjectInfo; 1177 | cl_api_clGetGLTextureInfo clGetGLTextureInfo; 1178 | cl_api_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; 1179 | cl_api_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; 1180 | cl_api_clGetGLContextInfoKHR clGetGLContextInfoKHR; 1181 | 1182 | /* cl_khr_d3d10_sharing */ 1183 | cl_api_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR; 1184 | cl_api_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR; 1185 | cl_api_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR; 1186 | cl_api_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR; 1187 | cl_api_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR; 1188 | cl_api_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR; 1189 | 1190 | /* OpenCL 1.1 */ 1191 | cl_api_clSetEventCallback clSetEventCallback; 1192 | cl_api_clCreateSubBuffer clCreateSubBuffer; 1193 | cl_api_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; 1194 | cl_api_clCreateUserEvent clCreateUserEvent; 1195 | cl_api_clSetUserEventStatus clSetUserEventStatus; 1196 | cl_api_clEnqueueReadBufferRect clEnqueueReadBufferRect; 1197 | cl_api_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; 1198 | cl_api_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; 1199 | 1200 | /* cl_ext_device_fission */ 1201 | cl_api_clCreateSubDevicesEXT clCreateSubDevicesEXT; 1202 | cl_api_clRetainDeviceEXT clRetainDeviceEXT; 1203 | cl_api_clReleaseDeviceEXT clReleaseDeviceEXT; 1204 | 1205 | /* cl_khr_gl_event */ 1206 | cl_api_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR; 1207 | 1208 | /* OpenCL 1.2 */ 1209 | cl_api_clCreateSubDevices clCreateSubDevices; 1210 | cl_api_clRetainDevice clRetainDevice; 1211 | cl_api_clReleaseDevice clReleaseDevice; 1212 | cl_api_clCreateImage clCreateImage; 1213 | cl_api_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; 1214 | cl_api_clCompileProgram clCompileProgram; 1215 | cl_api_clLinkProgram clLinkProgram; 1216 | cl_api_clUnloadPlatformCompiler clUnloadPlatformCompiler; 1217 | cl_api_clGetKernelArgInfo clGetKernelArgInfo; 1218 | cl_api_clEnqueueFillBuffer clEnqueueFillBuffer; 1219 | cl_api_clEnqueueFillImage clEnqueueFillImage; 1220 | cl_api_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; 1221 | cl_api_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; 1222 | cl_api_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; 1223 | cl_api_clGetExtensionFunctionAddressForPlatform 1224 | clGetExtensionFunctionAddressForPlatform; 1225 | cl_api_clCreateFromGLTexture clCreateFromGLTexture; 1226 | 1227 | /* cl_khr_d3d11_sharing */ 1228 | cl_api_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR; 1229 | cl_api_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR; 1230 | cl_api_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR; 1231 | cl_api_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR; 1232 | cl_api_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR; 1233 | cl_api_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR; 1234 | cl_api_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR; 1235 | 1236 | /* cl_khr_dx9_media_sharing */ 1237 | cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR 1238 | clGetDeviceIDsFromDX9MediaAdapterKHR; 1239 | cl_api_clEnqueueAcquireDX9MediaSurfacesKHR 1240 | clEnqueueAcquireDX9MediaSurfacesKHR; 1241 | cl_api_clEnqueueReleaseDX9MediaSurfacesKHR 1242 | clEnqueueReleaseDX9MediaSurfacesKHR; 1243 | 1244 | /* cl_khr_egl_image */ 1245 | cl_api_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; 1246 | cl_api_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; 1247 | cl_api_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; 1248 | 1249 | /* cl_khr_egl_event */ 1250 | cl_api_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR; 1251 | 1252 | /* OpenCL 2.0 */ 1253 | cl_api_clCreateCommandQueueWithProperties clCreateCommandQueueWithProperties; 1254 | cl_api_clCreatePipe clCreatePipe; 1255 | cl_api_clGetPipeInfo clGetPipeInfo; 1256 | cl_api_clSVMAlloc clSVMAlloc; 1257 | cl_api_clSVMFree clSVMFree; 1258 | cl_api_clEnqueueSVMFree clEnqueueSVMFree; 1259 | cl_api_clEnqueueSVMMemcpy clEnqueueSVMMemcpy; 1260 | cl_api_clEnqueueSVMMemFill clEnqueueSVMMemFill; 1261 | cl_api_clEnqueueSVMMap clEnqueueSVMMap; 1262 | cl_api_clEnqueueSVMUnmap clEnqueueSVMUnmap; 1263 | cl_api_clCreateSamplerWithProperties clCreateSamplerWithProperties; 1264 | cl_api_clSetKernelArgSVMPointer clSetKernelArgSVMPointer; 1265 | cl_api_clSetKernelExecInfo clSetKernelExecInfo; 1266 | 1267 | /* cl_khr_sub_groups */ 1268 | cl_api_clGetKernelSubGroupInfoKHR clGetKernelSubGroupInfoKHR; 1269 | 1270 | /* OpenCL 2.1 */ 1271 | cl_api_clCloneKernel clCloneKernel; 1272 | cl_api_clCreateProgramWithIL clCreateProgramWithIL; 1273 | cl_api_clEnqueueSVMMigrateMem clEnqueueSVMMigrateMem; 1274 | cl_api_clGetDeviceAndHostTimer clGetDeviceAndHostTimer; 1275 | cl_api_clGetHostTimer clGetHostTimer; 1276 | cl_api_clGetKernelSubGroupInfo clGetKernelSubGroupInfo; 1277 | cl_api_clSetDefaultDeviceCommandQueue clSetDefaultDeviceCommandQueue; 1278 | 1279 | /* OpenCL 2.2 */ 1280 | cl_api_clSetProgramReleaseCallback clSetProgramReleaseCallback; 1281 | cl_api_clSetProgramSpecializationConstant clSetProgramSpecializationConstant; 1282 | 1283 | /* OpenCL 3.0 */ 1284 | cl_api_clCreateBufferWithProperties clCreateBufferWithProperties; 1285 | cl_api_clCreateImageWithProperties clCreateImageWithProperties; 1286 | cl_api_clSetContextDestructorCallback clSetContextDestructorCallback; 1287 | 1288 | } cl_icd_dispatch; 1289 | 1290 | #ifdef __cplusplus 1291 | } 1292 | #endif 1293 | 1294 | #endif /* #ifndef OPENCL_CL_ICD_H */ 1295 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_layer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * OpenCL is a trademark of Apple Inc. used under license by Khronos. 17 | */ 18 | 19 | #ifndef OPENCL_CL_LAYER_H 20 | #define OPENCL_CL_LAYER_H 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef cl_uint cl_layer_info; 29 | typedef cl_uint cl_layer_api_version; 30 | #define CL_LAYER_API_VERSION 0x4240 31 | #define CL_LAYER_NAME 0x4241 32 | #define CL_LAYER_API_VERSION_100 100 33 | 34 | extern CL_API_ENTRY cl_int CL_API_CALL 35 | clGetLayerInfo(cl_layer_info param_name, 36 | size_t param_value_size, 37 | void *param_value, 38 | size_t *param_value_size_ret); 39 | 40 | typedef cl_int 41 | (CL_API_CALL *pfn_clGetLayerInfo)(cl_layer_info param_name, 42 | size_t param_value_size, 43 | void *param_value, 44 | size_t *param_value_size_ret); 45 | 46 | extern CL_API_ENTRY cl_int CL_API_CALL 47 | clInitLayer(cl_uint num_entries, 48 | const cl_icd_dispatch *target_dispatch, 49 | cl_uint *num_entries_ret, 50 | const cl_icd_dispatch **layer_dispatch_ret); 51 | 52 | typedef cl_int 53 | (CL_API_CALL *pfn_clInitLayer)(cl_uint num_entries, 54 | const cl_icd_dispatch *target_dispatch, 55 | cl_uint *num_entries_ret, 56 | const cl_icd_dispatch **layer_dispatch_ret); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* OPENCL_CL_LAYER_H */ 63 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_platform.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __CL_PLATFORM_H 18 | #define __CL_PLATFORM_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #if defined(_WIN32) 27 | #if !defined(CL_API_ENTRY) 28 | #define CL_API_ENTRY 29 | #endif 30 | #if !defined(CL_API_CALL) 31 | #define CL_API_CALL __stdcall 32 | #endif 33 | #if !defined(CL_CALLBACK) 34 | #define CL_CALLBACK __stdcall 35 | #endif 36 | #else 37 | #if !defined(CL_API_ENTRY) 38 | #define CL_API_ENTRY 39 | #endif 40 | #if !defined(CL_API_CALL) 41 | #define CL_API_CALL 42 | #endif 43 | #if !defined(CL_CALLBACK) 44 | #define CL_CALLBACK 45 | #endif 46 | #endif 47 | 48 | /* 49 | * Deprecation flags refer to the last version of the header in which the 50 | * feature was not deprecated. 51 | * 52 | * E.g. VERSION_1_1_DEPRECATED means the feature is present in 1.1 without 53 | * deprecation but is deprecated in versions later than 1.1. 54 | */ 55 | 56 | #ifndef CL_API_SUFFIX_USER 57 | #define CL_API_SUFFIX_USER 58 | #endif 59 | 60 | #ifndef CL_API_PREFIX_USER 61 | #define CL_API_PREFIX_USER 62 | #endif 63 | 64 | #define CL_API_SUFFIX_COMMON CL_API_SUFFIX_USER 65 | #define CL_API_PREFIX_COMMON CL_API_PREFIX_USER 66 | 67 | #define CL_API_SUFFIX__VERSION_1_0 CL_API_SUFFIX_COMMON 68 | #define CL_API_SUFFIX__VERSION_1_1 CL_API_SUFFIX_COMMON 69 | #define CL_API_SUFFIX__VERSION_1_2 CL_API_SUFFIX_COMMON 70 | #define CL_API_SUFFIX__VERSION_2_0 CL_API_SUFFIX_COMMON 71 | #define CL_API_SUFFIX__VERSION_2_1 CL_API_SUFFIX_COMMON 72 | #define CL_API_SUFFIX__VERSION_2_2 CL_API_SUFFIX_COMMON 73 | #define CL_API_SUFFIX__VERSION_3_0 CL_API_SUFFIX_COMMON 74 | #define CL_API_SUFFIX__EXPERIMENTAL CL_API_SUFFIX_COMMON 75 | 76 | 77 | #ifdef __GNUC__ 78 | #define CL_API_SUFFIX_DEPRECATED __attribute__((deprecated)) 79 | #define CL_API_PREFIX_DEPRECATED 80 | #elif defined(_WIN32) 81 | #define CL_API_SUFFIX_DEPRECATED 82 | #define CL_API_PREFIX_DEPRECATED __declspec(deprecated) 83 | #else 84 | #define CL_API_SUFFIX_DEPRECATED 85 | #define CL_API_PREFIX_DEPRECATED 86 | #endif 87 | 88 | #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS 89 | #define CL_API_SUFFIX__VERSION_1_0_DEPRECATED CL_API_SUFFIX_COMMON 90 | #define CL_API_PREFIX__VERSION_1_0_DEPRECATED CL_API_PREFIX_COMMON 91 | #else 92 | #define CL_API_SUFFIX__VERSION_1_0_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED 93 | #define CL_API_PREFIX__VERSION_1_0_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED 94 | #endif 95 | 96 | #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS 97 | #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED CL_API_SUFFIX_COMMON 98 | #define CL_API_PREFIX__VERSION_1_1_DEPRECATED CL_API_PREFIX_COMMON 99 | #else 100 | #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED 101 | #define CL_API_PREFIX__VERSION_1_1_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED 102 | #endif 103 | 104 | #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS 105 | #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED CL_API_SUFFIX_COMMON 106 | #define CL_API_PREFIX__VERSION_1_2_DEPRECATED CL_API_PREFIX_COMMON 107 | #else 108 | #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED 109 | #define CL_API_PREFIX__VERSION_1_2_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED 110 | #endif 111 | 112 | #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS 113 | #define CL_API_SUFFIX__VERSION_2_0_DEPRECATED CL_API_SUFFIX_COMMON 114 | #define CL_API_PREFIX__VERSION_2_0_DEPRECATED CL_API_PREFIX_COMMON 115 | #else 116 | #define CL_API_SUFFIX__VERSION_2_0_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED 117 | #define CL_API_PREFIX__VERSION_2_0_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED 118 | #endif 119 | 120 | #ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS 121 | #define CL_API_SUFFIX__VERSION_2_1_DEPRECATED CL_API_SUFFIX_COMMON 122 | #define CL_API_PREFIX__VERSION_2_1_DEPRECATED CL_API_PREFIX_COMMON 123 | #else 124 | #define CL_API_SUFFIX__VERSION_2_1_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED 125 | #define CL_API_PREFIX__VERSION_2_1_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED 126 | #endif 127 | 128 | #ifdef CL_USE_DEPRECATED_OPENCL_2_2_APIS 129 | #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED CL_API_SUFFIX_COMMON 130 | #define CL_API_PREFIX__VERSION_2_2_DEPRECATED CL_API_PREFIX_COMMON 131 | #else 132 | #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED 133 | #define CL_API_PREFIX__VERSION_2_2_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED 134 | #endif 135 | 136 | #if (defined (_WIN32) && defined(_MSC_VER)) 137 | 138 | #if defined(__clang__) 139 | #pragma clang diagnostic push 140 | #pragma clang diagnostic ignored "-Wlanguage-extension-token" 141 | #endif 142 | 143 | /* intptr_t is used in cl.h and provided by stddef.h in Visual C++, but not in clang */ 144 | /* stdint.h was missing before Visual Studio 2010, include it for later versions and for clang */ 145 | #if defined(__clang__) || _MSC_VER >= 1600 146 | #include 147 | #endif 148 | 149 | /* scalar types */ 150 | typedef signed __int8 cl_char; 151 | typedef unsigned __int8 cl_uchar; 152 | typedef signed __int16 cl_short; 153 | typedef unsigned __int16 cl_ushort; 154 | typedef signed __int32 cl_int; 155 | typedef unsigned __int32 cl_uint; 156 | typedef signed __int64 cl_long; 157 | typedef unsigned __int64 cl_ulong; 158 | 159 | typedef unsigned __int16 cl_half; 160 | typedef float cl_float; 161 | typedef double cl_double; 162 | 163 | #if defined(__clang__) 164 | #pragma clang diagnostic pop 165 | #endif 166 | 167 | /* Macro names and corresponding values defined by OpenCL */ 168 | #define CL_CHAR_BIT 8 169 | #define CL_SCHAR_MAX 127 170 | #define CL_SCHAR_MIN (-127-1) 171 | #define CL_CHAR_MAX CL_SCHAR_MAX 172 | #define CL_CHAR_MIN CL_SCHAR_MIN 173 | #define CL_UCHAR_MAX 255 174 | #define CL_SHRT_MAX 32767 175 | #define CL_SHRT_MIN (-32767-1) 176 | #define CL_USHRT_MAX 65535 177 | #define CL_INT_MAX 2147483647 178 | #define CL_INT_MIN (-2147483647-1) 179 | #define CL_UINT_MAX 0xffffffffU 180 | #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) 181 | #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) 182 | #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) 183 | 184 | #define CL_FLT_DIG 6 185 | #define CL_FLT_MANT_DIG 24 186 | #define CL_FLT_MAX_10_EXP +38 187 | #define CL_FLT_MAX_EXP +128 188 | #define CL_FLT_MIN_10_EXP -37 189 | #define CL_FLT_MIN_EXP -125 190 | #define CL_FLT_RADIX 2 191 | #define CL_FLT_MAX 340282346638528859811704183484516925440.0f 192 | #define CL_FLT_MIN 1.175494350822287507969e-38f 193 | #define CL_FLT_EPSILON 1.1920928955078125e-7f 194 | 195 | #define CL_HALF_DIG 3 196 | #define CL_HALF_MANT_DIG 11 197 | #define CL_HALF_MAX_10_EXP +4 198 | #define CL_HALF_MAX_EXP +16 199 | #define CL_HALF_MIN_10_EXP -4 200 | #define CL_HALF_MIN_EXP -13 201 | #define CL_HALF_RADIX 2 202 | #define CL_HALF_MAX 65504.0f 203 | #define CL_HALF_MIN 6.103515625e-05f 204 | #define CL_HALF_EPSILON 9.765625e-04f 205 | 206 | #define CL_DBL_DIG 15 207 | #define CL_DBL_MANT_DIG 53 208 | #define CL_DBL_MAX_10_EXP +308 209 | #define CL_DBL_MAX_EXP +1024 210 | #define CL_DBL_MIN_10_EXP -307 211 | #define CL_DBL_MIN_EXP -1021 212 | #define CL_DBL_RADIX 2 213 | #define CL_DBL_MAX 1.7976931348623158e+308 214 | #define CL_DBL_MIN 2.225073858507201383090e-308 215 | #define CL_DBL_EPSILON 2.220446049250313080847e-16 216 | 217 | #define CL_M_E 2.7182818284590452354 218 | #define CL_M_LOG2E 1.4426950408889634074 219 | #define CL_M_LOG10E 0.43429448190325182765 220 | #define CL_M_LN2 0.69314718055994530942 221 | #define CL_M_LN10 2.30258509299404568402 222 | #define CL_M_PI 3.14159265358979323846 223 | #define CL_M_PI_2 1.57079632679489661923 224 | #define CL_M_PI_4 0.78539816339744830962 225 | #define CL_M_1_PI 0.31830988618379067154 226 | #define CL_M_2_PI 0.63661977236758134308 227 | #define CL_M_2_SQRTPI 1.12837916709551257390 228 | #define CL_M_SQRT2 1.41421356237309504880 229 | #define CL_M_SQRT1_2 0.70710678118654752440 230 | 231 | #define CL_M_E_F 2.718281828f 232 | #define CL_M_LOG2E_F 1.442695041f 233 | #define CL_M_LOG10E_F 0.434294482f 234 | #define CL_M_LN2_F 0.693147181f 235 | #define CL_M_LN10_F 2.302585093f 236 | #define CL_M_PI_F 3.141592654f 237 | #define CL_M_PI_2_F 1.570796327f 238 | #define CL_M_PI_4_F 0.785398163f 239 | #define CL_M_1_PI_F 0.318309886f 240 | #define CL_M_2_PI_F 0.636619772f 241 | #define CL_M_2_SQRTPI_F 1.128379167f 242 | #define CL_M_SQRT2_F 1.414213562f 243 | #define CL_M_SQRT1_2_F 0.707106781f 244 | 245 | #define CL_NAN (CL_INFINITY - CL_INFINITY) 246 | #define CL_HUGE_VALF ((cl_float) 1e50) 247 | #define CL_HUGE_VAL ((cl_double) 1e500) 248 | #define CL_MAXFLOAT CL_FLT_MAX 249 | #define CL_INFINITY CL_HUGE_VALF 250 | 251 | #else 252 | 253 | #include 254 | 255 | /* scalar types */ 256 | typedef int8_t cl_char; 257 | typedef uint8_t cl_uchar; 258 | typedef int16_t cl_short; 259 | typedef uint16_t cl_ushort; 260 | typedef int32_t cl_int; 261 | typedef uint32_t cl_uint; 262 | typedef int64_t cl_long; 263 | typedef uint64_t cl_ulong; 264 | 265 | typedef uint16_t cl_half; 266 | typedef float cl_float; 267 | typedef double cl_double; 268 | 269 | /* Macro names and corresponding values defined by OpenCL */ 270 | #define CL_CHAR_BIT 8 271 | #define CL_SCHAR_MAX 127 272 | #define CL_SCHAR_MIN (-127-1) 273 | #define CL_CHAR_MAX CL_SCHAR_MAX 274 | #define CL_CHAR_MIN CL_SCHAR_MIN 275 | #define CL_UCHAR_MAX 255 276 | #define CL_SHRT_MAX 32767 277 | #define CL_SHRT_MIN (-32767-1) 278 | #define CL_USHRT_MAX 65535 279 | #define CL_INT_MAX 2147483647 280 | #define CL_INT_MIN (-2147483647-1) 281 | #define CL_UINT_MAX 0xffffffffU 282 | #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) 283 | #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) 284 | #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) 285 | 286 | #define CL_FLT_DIG 6 287 | #define CL_FLT_MANT_DIG 24 288 | #define CL_FLT_MAX_10_EXP +38 289 | #define CL_FLT_MAX_EXP +128 290 | #define CL_FLT_MIN_10_EXP -37 291 | #define CL_FLT_MIN_EXP -125 292 | #define CL_FLT_RADIX 2 293 | #define CL_FLT_MAX 340282346638528859811704183484516925440.0f 294 | #define CL_FLT_MIN 1.175494350822287507969e-38f 295 | #define CL_FLT_EPSILON 1.1920928955078125e-7f 296 | 297 | #define CL_HALF_DIG 3 298 | #define CL_HALF_MANT_DIG 11 299 | #define CL_HALF_MAX_10_EXP +4 300 | #define CL_HALF_MAX_EXP +16 301 | #define CL_HALF_MIN_10_EXP -4 302 | #define CL_HALF_MIN_EXP -13 303 | #define CL_HALF_RADIX 2 304 | #define CL_HALF_MAX 65504.0f 305 | #define CL_HALF_MIN 6.103515625e-05f 306 | #define CL_HALF_EPSILON 9.765625e-04f 307 | 308 | #define CL_DBL_DIG 15 309 | #define CL_DBL_MANT_DIG 53 310 | #define CL_DBL_MAX_10_EXP +308 311 | #define CL_DBL_MAX_EXP +1024 312 | #define CL_DBL_MIN_10_EXP -307 313 | #define CL_DBL_MIN_EXP -1021 314 | #define CL_DBL_RADIX 2 315 | #define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 316 | #define CL_DBL_MIN 2.225073858507201383090e-308 317 | #define CL_DBL_EPSILON 2.220446049250313080847e-16 318 | 319 | #define CL_M_E 2.7182818284590452354 320 | #define CL_M_LOG2E 1.4426950408889634074 321 | #define CL_M_LOG10E 0.43429448190325182765 322 | #define CL_M_LN2 0.69314718055994530942 323 | #define CL_M_LN10 2.30258509299404568402 324 | #define CL_M_PI 3.14159265358979323846 325 | #define CL_M_PI_2 1.57079632679489661923 326 | #define CL_M_PI_4 0.78539816339744830962 327 | #define CL_M_1_PI 0.31830988618379067154 328 | #define CL_M_2_PI 0.63661977236758134308 329 | #define CL_M_2_SQRTPI 1.12837916709551257390 330 | #define CL_M_SQRT2 1.41421356237309504880 331 | #define CL_M_SQRT1_2 0.70710678118654752440 332 | 333 | #define CL_M_E_F 2.718281828f 334 | #define CL_M_LOG2E_F 1.442695041f 335 | #define CL_M_LOG10E_F 0.434294482f 336 | #define CL_M_LN2_F 0.693147181f 337 | #define CL_M_LN10_F 2.302585093f 338 | #define CL_M_PI_F 3.141592654f 339 | #define CL_M_PI_2_F 1.570796327f 340 | #define CL_M_PI_4_F 0.785398163f 341 | #define CL_M_1_PI_F 0.318309886f 342 | #define CL_M_2_PI_F 0.636619772f 343 | #define CL_M_2_SQRTPI_F 1.128379167f 344 | #define CL_M_SQRT2_F 1.414213562f 345 | #define CL_M_SQRT1_2_F 0.707106781f 346 | 347 | #if defined( __GNUC__ ) 348 | #define CL_HUGE_VALF __builtin_huge_valf() 349 | #define CL_HUGE_VAL __builtin_huge_val() 350 | #define CL_NAN __builtin_nanf( "" ) 351 | #else 352 | #define CL_HUGE_VALF ((cl_float) 1e50) 353 | #define CL_HUGE_VAL ((cl_double) 1e500) 354 | float nanf( const char * ); 355 | #define CL_NAN nanf( "" ) 356 | #endif 357 | #define CL_MAXFLOAT CL_FLT_MAX 358 | #define CL_INFINITY CL_HUGE_VALF 359 | 360 | #endif 361 | 362 | #include 363 | 364 | /* Mirror types to GL types. Mirror types allow us to avoid deciding which 87s to load based on whether we are using GL or GLES here. */ 365 | typedef unsigned int cl_GLuint; 366 | typedef int cl_GLint; 367 | typedef unsigned int cl_GLenum; 368 | 369 | /* 370 | * Vector types 371 | * 372 | * Note: OpenCL requires that all types be naturally aligned. 373 | * This means that vector types must be naturally aligned. 374 | * For example, a vector of four floats must be aligned to 375 | * a 16 byte boundary (calculated as 4 * the natural 4-byte 376 | * alignment of the float). The alignment qualifiers here 377 | * will only function properly if your compiler supports them 378 | * and if you don't actively work to defeat them. For example, 379 | * in order for a cl_float4 to be 16 byte aligned in a struct, 380 | * the start of the struct must itself be 16-byte aligned. 381 | * 382 | * Maintaining proper alignment is the user's responsibility. 383 | */ 384 | 385 | /* Define basic vector types */ 386 | #if defined( __VEC__ ) 387 | #if !defined(__clang__) 388 | #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ 389 | #endif 390 | typedef __vector unsigned char __cl_uchar16; 391 | typedef __vector signed char __cl_char16; 392 | typedef __vector unsigned short __cl_ushort8; 393 | typedef __vector signed short __cl_short8; 394 | typedef __vector unsigned int __cl_uint4; 395 | typedef __vector signed int __cl_int4; 396 | typedef __vector float __cl_float4; 397 | #define __CL_UCHAR16__ 1 398 | #define __CL_CHAR16__ 1 399 | #define __CL_USHORT8__ 1 400 | #define __CL_SHORT8__ 1 401 | #define __CL_UINT4__ 1 402 | #define __CL_INT4__ 1 403 | #define __CL_FLOAT4__ 1 404 | #endif 405 | 406 | #if defined( __SSE__ ) 407 | #if defined( __MINGW64__ ) 408 | #include 409 | #else 410 | #include 411 | #endif 412 | #if defined( __GNUC__ ) 413 | typedef float __cl_float4 __attribute__((vector_size(16))); 414 | #else 415 | typedef __m128 __cl_float4; 416 | #endif 417 | #define __CL_FLOAT4__ 1 418 | #endif 419 | 420 | #if defined( __SSE2__ ) 421 | #if defined( __MINGW64__ ) 422 | #include 423 | #else 424 | #include 425 | #endif 426 | #if defined( __GNUC__ ) 427 | typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16))); 428 | typedef cl_char __cl_char16 __attribute__((vector_size(16))); 429 | typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16))); 430 | typedef cl_short __cl_short8 __attribute__((vector_size(16))); 431 | typedef cl_uint __cl_uint4 __attribute__((vector_size(16))); 432 | typedef cl_int __cl_int4 __attribute__((vector_size(16))); 433 | typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16))); 434 | typedef cl_long __cl_long2 __attribute__((vector_size(16))); 435 | typedef cl_double __cl_double2 __attribute__((vector_size(16))); 436 | #else 437 | typedef __m128i __cl_uchar16; 438 | typedef __m128i __cl_char16; 439 | typedef __m128i __cl_ushort8; 440 | typedef __m128i __cl_short8; 441 | typedef __m128i __cl_uint4; 442 | typedef __m128i __cl_int4; 443 | typedef __m128i __cl_ulong2; 444 | typedef __m128i __cl_long2; 445 | typedef __m128d __cl_double2; 446 | #endif 447 | #define __CL_UCHAR16__ 1 448 | #define __CL_CHAR16__ 1 449 | #define __CL_USHORT8__ 1 450 | #define __CL_SHORT8__ 1 451 | #define __CL_INT4__ 1 452 | #define __CL_UINT4__ 1 453 | #define __CL_ULONG2__ 1 454 | #define __CL_LONG2__ 1 455 | #define __CL_DOUBLE2__ 1 456 | #endif 457 | 458 | #if defined( __MMX__ ) 459 | #include 460 | #if defined( __GNUC__ ) 461 | typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8))); 462 | typedef cl_char __cl_char8 __attribute__((vector_size(8))); 463 | typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8))); 464 | typedef cl_short __cl_short4 __attribute__((vector_size(8))); 465 | typedef cl_uint __cl_uint2 __attribute__((vector_size(8))); 466 | typedef cl_int __cl_int2 __attribute__((vector_size(8))); 467 | typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8))); 468 | typedef cl_long __cl_long1 __attribute__((vector_size(8))); 469 | typedef cl_float __cl_float2 __attribute__((vector_size(8))); 470 | #else 471 | typedef __m64 __cl_uchar8; 472 | typedef __m64 __cl_char8; 473 | typedef __m64 __cl_ushort4; 474 | typedef __m64 __cl_short4; 475 | typedef __m64 __cl_uint2; 476 | typedef __m64 __cl_int2; 477 | typedef __m64 __cl_ulong1; 478 | typedef __m64 __cl_long1; 479 | typedef __m64 __cl_float2; 480 | #endif 481 | #define __CL_UCHAR8__ 1 482 | #define __CL_CHAR8__ 1 483 | #define __CL_USHORT4__ 1 484 | #define __CL_SHORT4__ 1 485 | #define __CL_INT2__ 1 486 | #define __CL_UINT2__ 1 487 | #define __CL_ULONG1__ 1 488 | #define __CL_LONG1__ 1 489 | #define __CL_FLOAT2__ 1 490 | #endif 491 | 492 | #if defined( __AVX__ ) 493 | #if defined( __MINGW64__ ) 494 | #include 495 | #else 496 | #include 497 | #endif 498 | #if defined( __GNUC__ ) 499 | typedef cl_float __cl_float8 __attribute__((vector_size(32))); 500 | typedef cl_double __cl_double4 __attribute__((vector_size(32))); 501 | #else 502 | typedef __m256 __cl_float8; 503 | typedef __m256d __cl_double4; 504 | #endif 505 | #define __CL_FLOAT8__ 1 506 | #define __CL_DOUBLE4__ 1 507 | #endif 508 | 509 | /* Define capabilities for anonymous struct members. */ 510 | #if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 511 | #define __CL_HAS_ANON_STRUCT__ 1 512 | #define __CL_ANON_STRUCT__ 513 | #elif defined(_WIN32) && defined(_MSC_VER) && !defined(__STDC__) 514 | #define __CL_HAS_ANON_STRUCT__ 1 515 | #define __CL_ANON_STRUCT__ 516 | #elif defined(__GNUC__) && ! defined(__STRICT_ANSI__) 517 | #define __CL_HAS_ANON_STRUCT__ 1 518 | #define __CL_ANON_STRUCT__ __extension__ 519 | #elif defined(__clang__) 520 | #define __CL_HAS_ANON_STRUCT__ 1 521 | #define __CL_ANON_STRUCT__ __extension__ 522 | #else 523 | #define __CL_HAS_ANON_STRUCT__ 0 524 | #define __CL_ANON_STRUCT__ 525 | #endif 526 | 527 | #if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ 528 | /* Disable warning C4201: nonstandard extension used : nameless struct/union */ 529 | #pragma warning( push ) 530 | #pragma warning( disable : 4201 ) 531 | #endif 532 | 533 | /* Define alignment keys */ 534 | #if defined( __GNUC__ ) || defined(__INTEGRITY) 535 | #define CL_ALIGNED(_x) __attribute__ ((aligned(_x))) 536 | #elif defined( _WIN32) && (_MSC_VER) 537 | /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */ 538 | /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */ 539 | /* #include */ 540 | /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */ 541 | #define CL_ALIGNED(_x) 542 | #else 543 | #warning Need to implement some method to align data here 544 | #define CL_ALIGNED(_x) 545 | #endif 546 | 547 | /* Indicate whether .xyzw, .s0123 and .hi.lo are supported */ 548 | #if __CL_HAS_ANON_STRUCT__ 549 | /* .xyzw and .s0123...{f|F} are supported */ 550 | #define CL_HAS_NAMED_VECTOR_FIELDS 1 551 | /* .hi and .lo are supported */ 552 | #define CL_HAS_HI_LO_VECTOR_FIELDS 1 553 | #endif 554 | 555 | /* Define cl_vector types */ 556 | 557 | /* ---- cl_charn ---- */ 558 | typedef union 559 | { 560 | cl_char CL_ALIGNED(2) s[2]; 561 | #if __CL_HAS_ANON_STRUCT__ 562 | __CL_ANON_STRUCT__ struct{ cl_char x, y; }; 563 | __CL_ANON_STRUCT__ struct{ cl_char s0, s1; }; 564 | __CL_ANON_STRUCT__ struct{ cl_char lo, hi; }; 565 | #endif 566 | #if defined( __CL_CHAR2__) 567 | __cl_char2 v2; 568 | #endif 569 | }cl_char2; 570 | 571 | typedef union 572 | { 573 | cl_char CL_ALIGNED(4) s[4]; 574 | #if __CL_HAS_ANON_STRUCT__ 575 | __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; }; 576 | __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; }; 577 | __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; }; 578 | #endif 579 | #if defined( __CL_CHAR2__) 580 | __cl_char2 v2[2]; 581 | #endif 582 | #if defined( __CL_CHAR4__) 583 | __cl_char4 v4; 584 | #endif 585 | }cl_char4; 586 | 587 | /* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */ 588 | typedef cl_char4 cl_char3; 589 | 590 | typedef union 591 | { 592 | cl_char CL_ALIGNED(8) s[8]; 593 | #if __CL_HAS_ANON_STRUCT__ 594 | __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; }; 595 | __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; }; 596 | __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; }; 597 | #endif 598 | #if defined( __CL_CHAR2__) 599 | __cl_char2 v2[4]; 600 | #endif 601 | #if defined( __CL_CHAR4__) 602 | __cl_char4 v4[2]; 603 | #endif 604 | #if defined( __CL_CHAR8__ ) 605 | __cl_char8 v8; 606 | #endif 607 | }cl_char8; 608 | 609 | typedef union 610 | { 611 | cl_char CL_ALIGNED(16) s[16]; 612 | #if __CL_HAS_ANON_STRUCT__ 613 | __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 614 | __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 615 | __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; }; 616 | #endif 617 | #if defined( __CL_CHAR2__) 618 | __cl_char2 v2[8]; 619 | #endif 620 | #if defined( __CL_CHAR4__) 621 | __cl_char4 v4[4]; 622 | #endif 623 | #if defined( __CL_CHAR8__ ) 624 | __cl_char8 v8[2]; 625 | #endif 626 | #if defined( __CL_CHAR16__ ) 627 | __cl_char16 v16; 628 | #endif 629 | }cl_char16; 630 | 631 | 632 | /* ---- cl_ucharn ---- */ 633 | typedef union 634 | { 635 | cl_uchar CL_ALIGNED(2) s[2]; 636 | #if __CL_HAS_ANON_STRUCT__ 637 | __CL_ANON_STRUCT__ struct{ cl_uchar x, y; }; 638 | __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; }; 639 | __CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; }; 640 | #endif 641 | #if defined( __cl_uchar2__) 642 | __cl_uchar2 v2; 643 | #endif 644 | }cl_uchar2; 645 | 646 | typedef union 647 | { 648 | cl_uchar CL_ALIGNED(4) s[4]; 649 | #if __CL_HAS_ANON_STRUCT__ 650 | __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; }; 651 | __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; }; 652 | __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; }; 653 | #endif 654 | #if defined( __CL_UCHAR2__) 655 | __cl_uchar2 v2[2]; 656 | #endif 657 | #if defined( __CL_UCHAR4__) 658 | __cl_uchar4 v4; 659 | #endif 660 | }cl_uchar4; 661 | 662 | /* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */ 663 | typedef cl_uchar4 cl_uchar3; 664 | 665 | typedef union 666 | { 667 | cl_uchar CL_ALIGNED(8) s[8]; 668 | #if __CL_HAS_ANON_STRUCT__ 669 | __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; }; 670 | __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; }; 671 | __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; }; 672 | #endif 673 | #if defined( __CL_UCHAR2__) 674 | __cl_uchar2 v2[4]; 675 | #endif 676 | #if defined( __CL_UCHAR4__) 677 | __cl_uchar4 v4[2]; 678 | #endif 679 | #if defined( __CL_UCHAR8__ ) 680 | __cl_uchar8 v8; 681 | #endif 682 | }cl_uchar8; 683 | 684 | typedef union 685 | { 686 | cl_uchar CL_ALIGNED(16) s[16]; 687 | #if __CL_HAS_ANON_STRUCT__ 688 | __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 689 | __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 690 | __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; }; 691 | #endif 692 | #if defined( __CL_UCHAR2__) 693 | __cl_uchar2 v2[8]; 694 | #endif 695 | #if defined( __CL_UCHAR4__) 696 | __cl_uchar4 v4[4]; 697 | #endif 698 | #if defined( __CL_UCHAR8__ ) 699 | __cl_uchar8 v8[2]; 700 | #endif 701 | #if defined( __CL_UCHAR16__ ) 702 | __cl_uchar16 v16; 703 | #endif 704 | }cl_uchar16; 705 | 706 | 707 | /* ---- cl_shortn ---- */ 708 | typedef union 709 | { 710 | cl_short CL_ALIGNED(4) s[2]; 711 | #if __CL_HAS_ANON_STRUCT__ 712 | __CL_ANON_STRUCT__ struct{ cl_short x, y; }; 713 | __CL_ANON_STRUCT__ struct{ cl_short s0, s1; }; 714 | __CL_ANON_STRUCT__ struct{ cl_short lo, hi; }; 715 | #endif 716 | #if defined( __CL_SHORT2__) 717 | __cl_short2 v2; 718 | #endif 719 | }cl_short2; 720 | 721 | typedef union 722 | { 723 | cl_short CL_ALIGNED(8) s[4]; 724 | #if __CL_HAS_ANON_STRUCT__ 725 | __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; }; 726 | __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; }; 727 | __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; }; 728 | #endif 729 | #if defined( __CL_SHORT2__) 730 | __cl_short2 v2[2]; 731 | #endif 732 | #if defined( __CL_SHORT4__) 733 | __cl_short4 v4; 734 | #endif 735 | }cl_short4; 736 | 737 | /* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */ 738 | typedef cl_short4 cl_short3; 739 | 740 | typedef union 741 | { 742 | cl_short CL_ALIGNED(16) s[8]; 743 | #if __CL_HAS_ANON_STRUCT__ 744 | __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; }; 745 | __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; }; 746 | __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; }; 747 | #endif 748 | #if defined( __CL_SHORT2__) 749 | __cl_short2 v2[4]; 750 | #endif 751 | #if defined( __CL_SHORT4__) 752 | __cl_short4 v4[2]; 753 | #endif 754 | #if defined( __CL_SHORT8__ ) 755 | __cl_short8 v8; 756 | #endif 757 | }cl_short8; 758 | 759 | typedef union 760 | { 761 | cl_short CL_ALIGNED(32) s[16]; 762 | #if __CL_HAS_ANON_STRUCT__ 763 | __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 764 | __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 765 | __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; }; 766 | #endif 767 | #if defined( __CL_SHORT2__) 768 | __cl_short2 v2[8]; 769 | #endif 770 | #if defined( __CL_SHORT4__) 771 | __cl_short4 v4[4]; 772 | #endif 773 | #if defined( __CL_SHORT8__ ) 774 | __cl_short8 v8[2]; 775 | #endif 776 | #if defined( __CL_SHORT16__ ) 777 | __cl_short16 v16; 778 | #endif 779 | }cl_short16; 780 | 781 | 782 | /* ---- cl_ushortn ---- */ 783 | typedef union 784 | { 785 | cl_ushort CL_ALIGNED(4) s[2]; 786 | #if __CL_HAS_ANON_STRUCT__ 787 | __CL_ANON_STRUCT__ struct{ cl_ushort x, y; }; 788 | __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; }; 789 | __CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; }; 790 | #endif 791 | #if defined( __CL_USHORT2__) 792 | __cl_ushort2 v2; 793 | #endif 794 | }cl_ushort2; 795 | 796 | typedef union 797 | { 798 | cl_ushort CL_ALIGNED(8) s[4]; 799 | #if __CL_HAS_ANON_STRUCT__ 800 | __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; }; 801 | __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; }; 802 | __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; }; 803 | #endif 804 | #if defined( __CL_USHORT2__) 805 | __cl_ushort2 v2[2]; 806 | #endif 807 | #if defined( __CL_USHORT4__) 808 | __cl_ushort4 v4; 809 | #endif 810 | }cl_ushort4; 811 | 812 | /* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */ 813 | typedef cl_ushort4 cl_ushort3; 814 | 815 | typedef union 816 | { 817 | cl_ushort CL_ALIGNED(16) s[8]; 818 | #if __CL_HAS_ANON_STRUCT__ 819 | __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; }; 820 | __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; }; 821 | __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; }; 822 | #endif 823 | #if defined( __CL_USHORT2__) 824 | __cl_ushort2 v2[4]; 825 | #endif 826 | #if defined( __CL_USHORT4__) 827 | __cl_ushort4 v4[2]; 828 | #endif 829 | #if defined( __CL_USHORT8__ ) 830 | __cl_ushort8 v8; 831 | #endif 832 | }cl_ushort8; 833 | 834 | typedef union 835 | { 836 | cl_ushort CL_ALIGNED(32) s[16]; 837 | #if __CL_HAS_ANON_STRUCT__ 838 | __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 839 | __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 840 | __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; }; 841 | #endif 842 | #if defined( __CL_USHORT2__) 843 | __cl_ushort2 v2[8]; 844 | #endif 845 | #if defined( __CL_USHORT4__) 846 | __cl_ushort4 v4[4]; 847 | #endif 848 | #if defined( __CL_USHORT8__ ) 849 | __cl_ushort8 v8[2]; 850 | #endif 851 | #if defined( __CL_USHORT16__ ) 852 | __cl_ushort16 v16; 853 | #endif 854 | }cl_ushort16; 855 | 856 | 857 | /* ---- cl_halfn ---- */ 858 | typedef union 859 | { 860 | cl_half CL_ALIGNED(4) s[2]; 861 | #if __CL_HAS_ANON_STRUCT__ 862 | __CL_ANON_STRUCT__ struct{ cl_half x, y; }; 863 | __CL_ANON_STRUCT__ struct{ cl_half s0, s1; }; 864 | __CL_ANON_STRUCT__ struct{ cl_half lo, hi; }; 865 | #endif 866 | #if defined( __CL_HALF2__) 867 | __cl_half2 v2; 868 | #endif 869 | }cl_half2; 870 | 871 | typedef union 872 | { 873 | cl_half CL_ALIGNED(8) s[4]; 874 | #if __CL_HAS_ANON_STRUCT__ 875 | __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w; }; 876 | __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3; }; 877 | __CL_ANON_STRUCT__ struct{ cl_half2 lo, hi; }; 878 | #endif 879 | #if defined( __CL_HALF2__) 880 | __cl_half2 v2[2]; 881 | #endif 882 | #if defined( __CL_HALF4__) 883 | __cl_half4 v4; 884 | #endif 885 | }cl_half4; 886 | 887 | /* cl_half3 is identical in size, alignment and behavior to cl_half4. See section 6.1.5. */ 888 | typedef cl_half4 cl_half3; 889 | 890 | typedef union 891 | { 892 | cl_half CL_ALIGNED(16) s[8]; 893 | #if __CL_HAS_ANON_STRUCT__ 894 | __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w; }; 895 | __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7; }; 896 | __CL_ANON_STRUCT__ struct{ cl_half4 lo, hi; }; 897 | #endif 898 | #if defined( __CL_HALF2__) 899 | __cl_half2 v2[4]; 900 | #endif 901 | #if defined( __CL_HALF4__) 902 | __cl_half4 v4[2]; 903 | #endif 904 | #if defined( __CL_HALF8__ ) 905 | __cl_half8 v8; 906 | #endif 907 | }cl_half8; 908 | 909 | typedef union 910 | { 911 | cl_half CL_ALIGNED(32) s[16]; 912 | #if __CL_HAS_ANON_STRUCT__ 913 | __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 914 | __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 915 | __CL_ANON_STRUCT__ struct{ cl_half8 lo, hi; }; 916 | #endif 917 | #if defined( __CL_HALF2__) 918 | __cl_half2 v2[8]; 919 | #endif 920 | #if defined( __CL_HALF4__) 921 | __cl_half4 v4[4]; 922 | #endif 923 | #if defined( __CL_HALF8__ ) 924 | __cl_half8 v8[2]; 925 | #endif 926 | #if defined( __CL_HALF16__ ) 927 | __cl_half16 v16; 928 | #endif 929 | }cl_half16; 930 | 931 | /* ---- cl_intn ---- */ 932 | typedef union 933 | { 934 | cl_int CL_ALIGNED(8) s[2]; 935 | #if __CL_HAS_ANON_STRUCT__ 936 | __CL_ANON_STRUCT__ struct{ cl_int x, y; }; 937 | __CL_ANON_STRUCT__ struct{ cl_int s0, s1; }; 938 | __CL_ANON_STRUCT__ struct{ cl_int lo, hi; }; 939 | #endif 940 | #if defined( __CL_INT2__) 941 | __cl_int2 v2; 942 | #endif 943 | }cl_int2; 944 | 945 | typedef union 946 | { 947 | cl_int CL_ALIGNED(16) s[4]; 948 | #if __CL_HAS_ANON_STRUCT__ 949 | __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; }; 950 | __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; }; 951 | __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; }; 952 | #endif 953 | #if defined( __CL_INT2__) 954 | __cl_int2 v2[2]; 955 | #endif 956 | #if defined( __CL_INT4__) 957 | __cl_int4 v4; 958 | #endif 959 | }cl_int4; 960 | 961 | /* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */ 962 | typedef cl_int4 cl_int3; 963 | 964 | typedef union 965 | { 966 | cl_int CL_ALIGNED(32) s[8]; 967 | #if __CL_HAS_ANON_STRUCT__ 968 | __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; }; 969 | __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; }; 970 | __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; }; 971 | #endif 972 | #if defined( __CL_INT2__) 973 | __cl_int2 v2[4]; 974 | #endif 975 | #if defined( __CL_INT4__) 976 | __cl_int4 v4[2]; 977 | #endif 978 | #if defined( __CL_INT8__ ) 979 | __cl_int8 v8; 980 | #endif 981 | }cl_int8; 982 | 983 | typedef union 984 | { 985 | cl_int CL_ALIGNED(64) s[16]; 986 | #if __CL_HAS_ANON_STRUCT__ 987 | __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 988 | __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 989 | __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; }; 990 | #endif 991 | #if defined( __CL_INT2__) 992 | __cl_int2 v2[8]; 993 | #endif 994 | #if defined( __CL_INT4__) 995 | __cl_int4 v4[4]; 996 | #endif 997 | #if defined( __CL_INT8__ ) 998 | __cl_int8 v8[2]; 999 | #endif 1000 | #if defined( __CL_INT16__ ) 1001 | __cl_int16 v16; 1002 | #endif 1003 | }cl_int16; 1004 | 1005 | 1006 | /* ---- cl_uintn ---- */ 1007 | typedef union 1008 | { 1009 | cl_uint CL_ALIGNED(8) s[2]; 1010 | #if __CL_HAS_ANON_STRUCT__ 1011 | __CL_ANON_STRUCT__ struct{ cl_uint x, y; }; 1012 | __CL_ANON_STRUCT__ struct{ cl_uint s0, s1; }; 1013 | __CL_ANON_STRUCT__ struct{ cl_uint lo, hi; }; 1014 | #endif 1015 | #if defined( __CL_UINT2__) 1016 | __cl_uint2 v2; 1017 | #endif 1018 | }cl_uint2; 1019 | 1020 | typedef union 1021 | { 1022 | cl_uint CL_ALIGNED(16) s[4]; 1023 | #if __CL_HAS_ANON_STRUCT__ 1024 | __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; }; 1025 | __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; }; 1026 | __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; }; 1027 | #endif 1028 | #if defined( __CL_UINT2__) 1029 | __cl_uint2 v2[2]; 1030 | #endif 1031 | #if defined( __CL_UINT4__) 1032 | __cl_uint4 v4; 1033 | #endif 1034 | }cl_uint4; 1035 | 1036 | /* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */ 1037 | typedef cl_uint4 cl_uint3; 1038 | 1039 | typedef union 1040 | { 1041 | cl_uint CL_ALIGNED(32) s[8]; 1042 | #if __CL_HAS_ANON_STRUCT__ 1043 | __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; }; 1044 | __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; }; 1045 | __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; }; 1046 | #endif 1047 | #if defined( __CL_UINT2__) 1048 | __cl_uint2 v2[4]; 1049 | #endif 1050 | #if defined( __CL_UINT4__) 1051 | __cl_uint4 v4[2]; 1052 | #endif 1053 | #if defined( __CL_UINT8__ ) 1054 | __cl_uint8 v8; 1055 | #endif 1056 | }cl_uint8; 1057 | 1058 | typedef union 1059 | { 1060 | cl_uint CL_ALIGNED(64) s[16]; 1061 | #if __CL_HAS_ANON_STRUCT__ 1062 | __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 1063 | __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 1064 | __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; }; 1065 | #endif 1066 | #if defined( __CL_UINT2__) 1067 | __cl_uint2 v2[8]; 1068 | #endif 1069 | #if defined( __CL_UINT4__) 1070 | __cl_uint4 v4[4]; 1071 | #endif 1072 | #if defined( __CL_UINT8__ ) 1073 | __cl_uint8 v8[2]; 1074 | #endif 1075 | #if defined( __CL_UINT16__ ) 1076 | __cl_uint16 v16; 1077 | #endif 1078 | }cl_uint16; 1079 | 1080 | /* ---- cl_longn ---- */ 1081 | typedef union 1082 | { 1083 | cl_long CL_ALIGNED(16) s[2]; 1084 | #if __CL_HAS_ANON_STRUCT__ 1085 | __CL_ANON_STRUCT__ struct{ cl_long x, y; }; 1086 | __CL_ANON_STRUCT__ struct{ cl_long s0, s1; }; 1087 | __CL_ANON_STRUCT__ struct{ cl_long lo, hi; }; 1088 | #endif 1089 | #if defined( __CL_LONG2__) 1090 | __cl_long2 v2; 1091 | #endif 1092 | }cl_long2; 1093 | 1094 | typedef union 1095 | { 1096 | cl_long CL_ALIGNED(32) s[4]; 1097 | #if __CL_HAS_ANON_STRUCT__ 1098 | __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; }; 1099 | __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; }; 1100 | __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; }; 1101 | #endif 1102 | #if defined( __CL_LONG2__) 1103 | __cl_long2 v2[2]; 1104 | #endif 1105 | #if defined( __CL_LONG4__) 1106 | __cl_long4 v4; 1107 | #endif 1108 | }cl_long4; 1109 | 1110 | /* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */ 1111 | typedef cl_long4 cl_long3; 1112 | 1113 | typedef union 1114 | { 1115 | cl_long CL_ALIGNED(64) s[8]; 1116 | #if __CL_HAS_ANON_STRUCT__ 1117 | __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; }; 1118 | __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; }; 1119 | __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; }; 1120 | #endif 1121 | #if defined( __CL_LONG2__) 1122 | __cl_long2 v2[4]; 1123 | #endif 1124 | #if defined( __CL_LONG4__) 1125 | __cl_long4 v4[2]; 1126 | #endif 1127 | #if defined( __CL_LONG8__ ) 1128 | __cl_long8 v8; 1129 | #endif 1130 | }cl_long8; 1131 | 1132 | typedef union 1133 | { 1134 | cl_long CL_ALIGNED(128) s[16]; 1135 | #if __CL_HAS_ANON_STRUCT__ 1136 | __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 1137 | __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 1138 | __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; }; 1139 | #endif 1140 | #if defined( __CL_LONG2__) 1141 | __cl_long2 v2[8]; 1142 | #endif 1143 | #if defined( __CL_LONG4__) 1144 | __cl_long4 v4[4]; 1145 | #endif 1146 | #if defined( __CL_LONG8__ ) 1147 | __cl_long8 v8[2]; 1148 | #endif 1149 | #if defined( __CL_LONG16__ ) 1150 | __cl_long16 v16; 1151 | #endif 1152 | }cl_long16; 1153 | 1154 | 1155 | /* ---- cl_ulongn ---- */ 1156 | typedef union 1157 | { 1158 | cl_ulong CL_ALIGNED(16) s[2]; 1159 | #if __CL_HAS_ANON_STRUCT__ 1160 | __CL_ANON_STRUCT__ struct{ cl_ulong x, y; }; 1161 | __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; }; 1162 | __CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; }; 1163 | #endif 1164 | #if defined( __CL_ULONG2__) 1165 | __cl_ulong2 v2; 1166 | #endif 1167 | }cl_ulong2; 1168 | 1169 | typedef union 1170 | { 1171 | cl_ulong CL_ALIGNED(32) s[4]; 1172 | #if __CL_HAS_ANON_STRUCT__ 1173 | __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; }; 1174 | __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; }; 1175 | __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; }; 1176 | #endif 1177 | #if defined( __CL_ULONG2__) 1178 | __cl_ulong2 v2[2]; 1179 | #endif 1180 | #if defined( __CL_ULONG4__) 1181 | __cl_ulong4 v4; 1182 | #endif 1183 | }cl_ulong4; 1184 | 1185 | /* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */ 1186 | typedef cl_ulong4 cl_ulong3; 1187 | 1188 | typedef union 1189 | { 1190 | cl_ulong CL_ALIGNED(64) s[8]; 1191 | #if __CL_HAS_ANON_STRUCT__ 1192 | __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; }; 1193 | __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; }; 1194 | __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; }; 1195 | #endif 1196 | #if defined( __CL_ULONG2__) 1197 | __cl_ulong2 v2[4]; 1198 | #endif 1199 | #if defined( __CL_ULONG4__) 1200 | __cl_ulong4 v4[2]; 1201 | #endif 1202 | #if defined( __CL_ULONG8__ ) 1203 | __cl_ulong8 v8; 1204 | #endif 1205 | }cl_ulong8; 1206 | 1207 | typedef union 1208 | { 1209 | cl_ulong CL_ALIGNED(128) s[16]; 1210 | #if __CL_HAS_ANON_STRUCT__ 1211 | __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 1212 | __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 1213 | __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; }; 1214 | #endif 1215 | #if defined( __CL_ULONG2__) 1216 | __cl_ulong2 v2[8]; 1217 | #endif 1218 | #if defined( __CL_ULONG4__) 1219 | __cl_ulong4 v4[4]; 1220 | #endif 1221 | #if defined( __CL_ULONG8__ ) 1222 | __cl_ulong8 v8[2]; 1223 | #endif 1224 | #if defined( __CL_ULONG16__ ) 1225 | __cl_ulong16 v16; 1226 | #endif 1227 | }cl_ulong16; 1228 | 1229 | 1230 | /* --- cl_floatn ---- */ 1231 | 1232 | typedef union 1233 | { 1234 | cl_float CL_ALIGNED(8) s[2]; 1235 | #if __CL_HAS_ANON_STRUCT__ 1236 | __CL_ANON_STRUCT__ struct{ cl_float x, y; }; 1237 | __CL_ANON_STRUCT__ struct{ cl_float s0, s1; }; 1238 | __CL_ANON_STRUCT__ struct{ cl_float lo, hi; }; 1239 | #endif 1240 | #if defined( __CL_FLOAT2__) 1241 | __cl_float2 v2; 1242 | #endif 1243 | }cl_float2; 1244 | 1245 | typedef union 1246 | { 1247 | cl_float CL_ALIGNED(16) s[4]; 1248 | #if __CL_HAS_ANON_STRUCT__ 1249 | __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; }; 1250 | __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; }; 1251 | __CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; }; 1252 | #endif 1253 | #if defined( __CL_FLOAT2__) 1254 | __cl_float2 v2[2]; 1255 | #endif 1256 | #if defined( __CL_FLOAT4__) 1257 | __cl_float4 v4; 1258 | #endif 1259 | }cl_float4; 1260 | 1261 | /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */ 1262 | typedef cl_float4 cl_float3; 1263 | 1264 | typedef union 1265 | { 1266 | cl_float CL_ALIGNED(32) s[8]; 1267 | #if __CL_HAS_ANON_STRUCT__ 1268 | __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; }; 1269 | __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; }; 1270 | __CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; }; 1271 | #endif 1272 | #if defined( __CL_FLOAT2__) 1273 | __cl_float2 v2[4]; 1274 | #endif 1275 | #if defined( __CL_FLOAT4__) 1276 | __cl_float4 v4[2]; 1277 | #endif 1278 | #if defined( __CL_FLOAT8__ ) 1279 | __cl_float8 v8; 1280 | #endif 1281 | }cl_float8; 1282 | 1283 | typedef union 1284 | { 1285 | cl_float CL_ALIGNED(64) s[16]; 1286 | #if __CL_HAS_ANON_STRUCT__ 1287 | __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 1288 | __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 1289 | __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; }; 1290 | #endif 1291 | #if defined( __CL_FLOAT2__) 1292 | __cl_float2 v2[8]; 1293 | #endif 1294 | #if defined( __CL_FLOAT4__) 1295 | __cl_float4 v4[4]; 1296 | #endif 1297 | #if defined( __CL_FLOAT8__ ) 1298 | __cl_float8 v8[2]; 1299 | #endif 1300 | #if defined( __CL_FLOAT16__ ) 1301 | __cl_float16 v16; 1302 | #endif 1303 | }cl_float16; 1304 | 1305 | /* --- cl_doublen ---- */ 1306 | 1307 | typedef union 1308 | { 1309 | cl_double CL_ALIGNED(16) s[2]; 1310 | #if __CL_HAS_ANON_STRUCT__ 1311 | __CL_ANON_STRUCT__ struct{ cl_double x, y; }; 1312 | __CL_ANON_STRUCT__ struct{ cl_double s0, s1; }; 1313 | __CL_ANON_STRUCT__ struct{ cl_double lo, hi; }; 1314 | #endif 1315 | #if defined( __CL_DOUBLE2__) 1316 | __cl_double2 v2; 1317 | #endif 1318 | }cl_double2; 1319 | 1320 | typedef union 1321 | { 1322 | cl_double CL_ALIGNED(32) s[4]; 1323 | #if __CL_HAS_ANON_STRUCT__ 1324 | __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; }; 1325 | __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; }; 1326 | __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; }; 1327 | #endif 1328 | #if defined( __CL_DOUBLE2__) 1329 | __cl_double2 v2[2]; 1330 | #endif 1331 | #if defined( __CL_DOUBLE4__) 1332 | __cl_double4 v4; 1333 | #endif 1334 | }cl_double4; 1335 | 1336 | /* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */ 1337 | typedef cl_double4 cl_double3; 1338 | 1339 | typedef union 1340 | { 1341 | cl_double CL_ALIGNED(64) s[8]; 1342 | #if __CL_HAS_ANON_STRUCT__ 1343 | __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; }; 1344 | __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; }; 1345 | __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; }; 1346 | #endif 1347 | #if defined( __CL_DOUBLE2__) 1348 | __cl_double2 v2[4]; 1349 | #endif 1350 | #if defined( __CL_DOUBLE4__) 1351 | __cl_double4 v4[2]; 1352 | #endif 1353 | #if defined( __CL_DOUBLE8__ ) 1354 | __cl_double8 v8; 1355 | #endif 1356 | }cl_double8; 1357 | 1358 | typedef union 1359 | { 1360 | cl_double CL_ALIGNED(128) s[16]; 1361 | #if __CL_HAS_ANON_STRUCT__ 1362 | __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; 1363 | __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; 1364 | __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; }; 1365 | #endif 1366 | #if defined( __CL_DOUBLE2__) 1367 | __cl_double2 v2[8]; 1368 | #endif 1369 | #if defined( __CL_DOUBLE4__) 1370 | __cl_double4 v4[4]; 1371 | #endif 1372 | #if defined( __CL_DOUBLE8__ ) 1373 | __cl_double8 v8[2]; 1374 | #endif 1375 | #if defined( __CL_DOUBLE16__ ) 1376 | __cl_double16 v16; 1377 | #endif 1378 | }cl_double16; 1379 | 1380 | /* Macro to facilitate debugging 1381 | * Usage: 1382 | * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source. 1383 | * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \" 1384 | * Each line thereafter of OpenCL C source must end with: \n\ 1385 | * The last line ends in "; 1386 | * 1387 | * Example: 1388 | * 1389 | * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\ 1390 | * kernel void foo( int a, float * b ) \n\ 1391 | * { \n\ 1392 | * // my comment \n\ 1393 | * *b[ get_global_id(0)] = a; \n\ 1394 | * } \n\ 1395 | * "; 1396 | * 1397 | * This should correctly set up the line, (column) and file information for your source 1398 | * string so you can do source level debugging. 1399 | */ 1400 | #define __CL_STRINGIFY( _x ) # _x 1401 | #define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x ) 1402 | #define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n" 1403 | 1404 | #ifdef __cplusplus 1405 | } 1406 | #endif 1407 | 1408 | #if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ 1409 | #pragma warning( pop ) 1410 | #endif 1411 | 1412 | #endif /* __CL_PLATFORM_H */ 1413 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_va_api_media_sharing_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H 18 | #define __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /*************************************************************** 29 | * cl_intel_sharing_format_query_va_api 30 | ***************************************************************/ 31 | #define cl_intel_sharing_format_query_va_api 1 32 | 33 | /* when cl_intel_va_api_media_sharing is supported */ 34 | 35 | extern CL_API_ENTRY cl_int CL_API_CALL 36 | clGetSupportedVA_APIMediaSurfaceFormatsINTEL( 37 | cl_context context, 38 | cl_mem_flags flags, 39 | cl_mem_object_type image_type, 40 | cl_uint plane, 41 | cl_uint num_entries, 42 | VAImageFormat* va_api_formats, 43 | cl_uint* num_surface_formats) ; 44 | 45 | typedef cl_int (CL_API_CALL * 46 | clGetSupportedVA_APIMediaSurfaceFormatsINTEL_fn)( 47 | cl_context context, 48 | cl_mem_flags flags, 49 | cl_mem_object_type image_type, 50 | cl_uint plane, 51 | cl_uint num_entries, 52 | VAImageFormat* va_api_formats, 53 | cl_uint* num_surface_formats) ; 54 | 55 | /****************************************** 56 | * cl_intel_va_api_media_sharing extension * 57 | *******************************************/ 58 | 59 | #define cl_intel_va_api_media_sharing 1 60 | 61 | /* error codes */ 62 | #define CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL -1098 63 | #define CL_INVALID_VA_API_MEDIA_SURFACE_INTEL -1099 64 | #define CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL -1100 65 | #define CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL -1101 66 | 67 | /* cl_va_api_device_source_intel */ 68 | #define CL_VA_API_DISPLAY_INTEL 0x4094 69 | 70 | /* cl_va_api_device_set_intel */ 71 | #define CL_PREFERRED_DEVICES_FOR_VA_API_INTEL 0x4095 72 | #define CL_ALL_DEVICES_FOR_VA_API_INTEL 0x4096 73 | 74 | /* cl_context_info */ 75 | #define CL_CONTEXT_VA_API_DISPLAY_INTEL 0x4097 76 | 77 | /* cl_mem_info */ 78 | #define CL_MEM_VA_API_MEDIA_SURFACE_INTEL 0x4098 79 | 80 | /* cl_image_info */ 81 | #define CL_IMAGE_VA_API_PLANE_INTEL 0x4099 82 | 83 | /* cl_command_type */ 84 | #define CL_COMMAND_ACQUIRE_VA_API_MEDIA_SURFACES_INTEL 0x409A 85 | #define CL_COMMAND_RELEASE_VA_API_MEDIA_SURFACES_INTEL 0x409B 86 | 87 | typedef cl_uint cl_va_api_device_source_intel; 88 | typedef cl_uint cl_va_api_device_set_intel; 89 | 90 | extern CL_API_ENTRY cl_int CL_API_CALL 91 | clGetDeviceIDsFromVA_APIMediaAdapterINTEL( 92 | cl_platform_id platform, 93 | cl_va_api_device_source_intel media_adapter_type, 94 | void* media_adapter, 95 | cl_va_api_device_set_intel media_adapter_set, 96 | cl_uint num_entries, 97 | cl_device_id* devices, 98 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; 99 | 100 | typedef cl_int (CL_API_CALL * clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)( 101 | cl_platform_id platform, 102 | cl_va_api_device_source_intel media_adapter_type, 103 | void* media_adapter, 104 | cl_va_api_device_set_intel media_adapter_set, 105 | cl_uint num_entries, 106 | cl_device_id* devices, 107 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; 108 | 109 | extern CL_API_ENTRY cl_mem CL_API_CALL 110 | clCreateFromVA_APIMediaSurfaceINTEL( 111 | cl_context context, 112 | cl_mem_flags flags, 113 | VASurfaceID* surface, 114 | cl_uint plane, 115 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 116 | 117 | typedef cl_mem (CL_API_CALL * clCreateFromVA_APIMediaSurfaceINTEL_fn)( 118 | cl_context context, 119 | cl_mem_flags flags, 120 | VASurfaceID* surface, 121 | cl_uint plane, 122 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 123 | 124 | extern CL_API_ENTRY cl_int CL_API_CALL 125 | clEnqueueAcquireVA_APIMediaSurfacesINTEL( 126 | cl_command_queue command_queue, 127 | cl_uint num_objects, 128 | const cl_mem* mem_objects, 129 | cl_uint num_events_in_wait_list, 130 | const cl_event* event_wait_list, 131 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 132 | 133 | typedef cl_int (CL_API_CALL *clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)( 134 | cl_command_queue command_queue, 135 | cl_uint num_objects, 136 | const cl_mem* mem_objects, 137 | cl_uint num_events_in_wait_list, 138 | const cl_event* event_wait_list, 139 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 140 | 141 | extern CL_API_ENTRY cl_int CL_API_CALL 142 | clEnqueueReleaseVA_APIMediaSurfacesINTEL( 143 | cl_command_queue command_queue, 144 | cl_uint num_objects, 145 | const cl_mem* mem_objects, 146 | cl_uint num_events_in_wait_list, 147 | const cl_event* event_wait_list, 148 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 149 | 150 | typedef cl_int (CL_API_CALL *clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)( 151 | cl_command_queue command_queue, 152 | cl_uint num_objects, 153 | const cl_mem* mem_objects, 154 | cl_uint num_events_in_wait_list, 155 | const cl_event* event_wait_list, 156 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif /* __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H */ 163 | 164 | -------------------------------------------------------------------------------- /include-3.0.13/CL/cl_version.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2018-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __CL_VERSION_H 18 | #define __CL_VERSION_H 19 | 20 | /* Detect which version to target */ 21 | #if !defined(CL_TARGET_OPENCL_VERSION) 22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)") 23 | #define CL_TARGET_OPENCL_VERSION 300 24 | #endif 25 | #if CL_TARGET_OPENCL_VERSION != 100 && \ 26 | CL_TARGET_OPENCL_VERSION != 110 && \ 27 | CL_TARGET_OPENCL_VERSION != 120 && \ 28 | CL_TARGET_OPENCL_VERSION != 200 && \ 29 | CL_TARGET_OPENCL_VERSION != 210 && \ 30 | CL_TARGET_OPENCL_VERSION != 220 && \ 31 | CL_TARGET_OPENCL_VERSION != 300 32 | #pragma message("cl_version: CL_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300). Defaulting to 300 (OpenCL 3.0)") 33 | #undef CL_TARGET_OPENCL_VERSION 34 | #define CL_TARGET_OPENCL_VERSION 300 35 | #endif 36 | 37 | 38 | /* OpenCL Version */ 39 | #if CL_TARGET_OPENCL_VERSION >= 300 && !defined(CL_VERSION_3_0) 40 | #define CL_VERSION_3_0 1 41 | #endif 42 | #if CL_TARGET_OPENCL_VERSION >= 220 && !defined(CL_VERSION_2_2) 43 | #define CL_VERSION_2_2 1 44 | #endif 45 | #if CL_TARGET_OPENCL_VERSION >= 210 && !defined(CL_VERSION_2_1) 46 | #define CL_VERSION_2_1 1 47 | #endif 48 | #if CL_TARGET_OPENCL_VERSION >= 200 && !defined(CL_VERSION_2_0) 49 | #define CL_VERSION_2_0 1 50 | #endif 51 | #if CL_TARGET_OPENCL_VERSION >= 120 && !defined(CL_VERSION_1_2) 52 | #define CL_VERSION_1_2 1 53 | #endif 54 | #if CL_TARGET_OPENCL_VERSION >= 110 && !defined(CL_VERSION_1_1) 55 | #define CL_VERSION_1_1 1 56 | #endif 57 | #if CL_TARGET_OPENCL_VERSION >= 100 && !defined(CL_VERSION_1_0) 58 | #define CL_VERSION_1_0 1 59 | #endif 60 | 61 | /* Allow deprecated APIs for older OpenCL versions. */ 62 | #if CL_TARGET_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS) 63 | #define CL_USE_DEPRECATED_OPENCL_2_2_APIS 64 | #endif 65 | #if CL_TARGET_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) 66 | #define CL_USE_DEPRECATED_OPENCL_2_1_APIS 67 | #endif 68 | #if CL_TARGET_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 69 | #define CL_USE_DEPRECATED_OPENCL_2_0_APIS 70 | #endif 71 | #if CL_TARGET_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 72 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS 73 | #endif 74 | #if CL_TARGET_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 75 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 76 | #endif 77 | #if CL_TARGET_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 78 | #define CL_USE_DEPRECATED_OPENCL_1_0_APIS 79 | #endif 80 | 81 | #endif /* __CL_VERSION_H */ 82 | -------------------------------------------------------------------------------- /include-3.0.13/CL/opencl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_H 18 | #define __OPENCL_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __OPENCL_H */ 33 | -------------------------------------------------------------------------------- /info.go: -------------------------------------------------------------------------------- 1 | package opencl 2 | 3 | // #include "cl.h" 4 | // #ifndef CL_DEVICE_PCI_BUS_INFO_KHR 5 | // #define CL_DEVICE_PCI_BUS_INFO_KHR 0x410F 6 | // #endif 7 | import "C" 8 | 9 | import ( 10 | "fmt" 11 | "strings" 12 | "unsafe" 13 | ) 14 | 15 | func getPCIBusInfo(device_id C.cl_device_id) (PCIBusInfo, error) { 16 | var info PCIBusInfo 17 | 18 | // Try standard KHR extension first 19 | var khrBusInfo [4]C.cl_uint 20 | err := C.clGetDeviceInfo(device_id, C.CL_DEVICE_PCI_BUS_INFO_KHR, 21 | C.sizeof_cl_uint*4, unsafe.Pointer(&khrBusInfo[0]), nil) 22 | if err == C.CL_SUCCESS { 23 | info.Domain = khrBusInfo[0] 24 | info.Bus = khrBusInfo[1] 25 | info.Device = khrBusInfo[2] 26 | info.Function = khrBusInfo[3] 27 | return info, nil 28 | } 29 | 30 | return info, fmt.Errorf("PCI bus info not available") 31 | } 32 | 33 | func getOneDevie(platform_id C.cl_platform_id, device_id C.cl_device_id) (*OpenCLDevice, error) { 34 | var device = OpenCLDevice{Platform_id: platform_id, Device_id: device_id} 35 | 36 | // Try to get PCI bus info 37 | if pciInfo, err := getPCIBusInfo(device_id); err == nil { 38 | device.PCIInfo = pciInfo 39 | } 40 | 41 | // max_clock_frequency 42 | var err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_MAX_CLOCK_FREQUENCY, C.sizeof_cl_uint, 43 | unsafe.Pointer(&device.Max_clock_frequency), nil) 44 | if err != C.CL_SUCCESS { 45 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 46 | } 47 | 48 | // max_mem_alloc_size 49 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_MAX_MEM_ALLOC_SIZE, C.sizeof_cl_ulong, 50 | unsafe.Pointer(&device.Max_mem_alloc_size), nil) 51 | if err != C.CL_SUCCESS { 52 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 53 | } 54 | 55 | // global_mem_size 56 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_GLOBAL_MEM_SIZE, C.sizeof_cl_ulong, 57 | unsafe.Pointer(&device.Global_mem_size), nil) 58 | if err != C.CL_SUCCESS { 59 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 60 | } 61 | 62 | // max_compute_units 63 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_MAX_COMPUTE_UNITS, C.sizeof_cl_uint, 64 | unsafe.Pointer(&device.Max_compute_units), nil) 65 | if err != C.CL_SUCCESS { 66 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 67 | } 68 | 69 | // max_work_group_size 70 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_MAX_WORK_GROUP_SIZE, C.sizeof_size_t, 71 | unsafe.Pointer(&device.Max_work_group_size), nil) 72 | if err != C.CL_SUCCESS { 73 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 74 | } 75 | 76 | // device_type 77 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_TYPE, C.sizeof_cl_device_type, 78 | unsafe.Pointer(&device.Device_type), nil) 79 | if err != C.CL_SUCCESS { 80 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 81 | } 82 | 83 | // Max_work_item_dimensions 84 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, C.sizeof_cl_uint, 85 | unsafe.Pointer(&device.Max_work_item_dimensions), nil) 86 | if err != C.CL_SUCCESS { 87 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 88 | } 89 | 90 | // Max_work_item_sizes 91 | device.Max_work_item_sizes = make([]C.size_t, device.Max_work_item_dimensions, device.Max_work_item_dimensions) 92 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_MAX_WORK_ITEM_SIZES, C.sizeof_size_t*C.size_t(device.Max_work_item_dimensions), 93 | unsafe.Pointer(&device.Max_work_item_sizes[0]), nil) 94 | if err != C.CL_SUCCESS { 95 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 96 | } 97 | 98 | var infoSize C.size_t 99 | // name 100 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_NAME, 0, nil, &infoSize) 101 | if err != C.CL_SUCCESS { 102 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 103 | } 104 | var info = make([]byte, infoSize, infoSize) 105 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_NAME, infoSize, unsafe.Pointer(&info[0]), nil) 106 | if err != C.CL_SUCCESS { 107 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 108 | } 109 | device.Name = string(info[:len(info)-1]) 110 | 111 | // profile 112 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_PROFILE, 0, nil, &infoSize) 113 | if err != C.CL_SUCCESS { 114 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 115 | } 116 | info = make([]byte, infoSize, infoSize) 117 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_PROFILE, infoSize, unsafe.Pointer(&info[0]), nil) 118 | if err != C.CL_SUCCESS { 119 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 120 | } 121 | device.Profile = string(info[:len(info)-1]) 122 | 123 | // version 124 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_VERSION, 0, nil, &infoSize) 125 | if err != C.CL_SUCCESS { 126 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 127 | } 128 | info = make([]byte, infoSize, infoSize) 129 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_VERSION, infoSize, unsafe.Pointer(&info[0]), nil) 130 | if err != C.CL_SUCCESS { 131 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 132 | } 133 | device.Version = strings.Trim(string(info[:len(info)-1]), " ") 134 | 135 | // vendor 136 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_VENDOR, 0, nil, &infoSize) 137 | if err != C.CL_SUCCESS { 138 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 139 | } 140 | info = make([]byte, infoSize, infoSize) 141 | err = C.clGetDeviceInfo(device_id, C.CL_DEVICE_VENDOR, infoSize, unsafe.Pointer(&info[0]), nil) 142 | if err != C.CL_SUCCESS { 143 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 144 | } 145 | device.Vendor = string(info[:len(info)-1]) 146 | 147 | // driver_version 148 | err = C.clGetDeviceInfo(device_id, C.CL_DRIVER_VERSION, 0, nil, &infoSize) 149 | if err != C.CL_SUCCESS { 150 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 151 | } 152 | info = make([]byte, infoSize, infoSize) 153 | err = C.clGetDeviceInfo(device_id, C.CL_DRIVER_VERSION, infoSize, unsafe.Pointer(&info[0]), nil) 154 | if err != C.CL_SUCCESS { 155 | return &device, fmt.Errorf("clGetDeviceInfo Err: %v", err) 156 | } 157 | device.Driver_version = string(info[:len(info)-1]) 158 | 159 | return &device, nil 160 | } 161 | 162 | func getOnePlatform(platform_id C.cl_platform_id) (*OpenCLPlatform, error) { 163 | var platform = OpenCLPlatform{Platform_id: platform_id} 164 | 165 | var infoSize C.size_t 166 | // name 167 | var err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_NAME, 0, nil, &infoSize) 168 | if err != C.CL_SUCCESS { 169 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 170 | } 171 | var info = make([]byte, infoSize, infoSize) 172 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_NAME, infoSize, unsafe.Pointer(&info[0]), nil) 173 | if err != C.CL_SUCCESS { 174 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 175 | } 176 | platform.Name = string(info[:len(info)-1]) 177 | 178 | // profile 179 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_PROFILE, 0, nil, &infoSize) 180 | if err != C.CL_SUCCESS { 181 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 182 | } 183 | info = make([]byte, infoSize, infoSize) 184 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_PROFILE, infoSize, unsafe.Pointer(&info[0]), nil) 185 | if err != C.CL_SUCCESS { 186 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 187 | } 188 | platform.Profile = string(info[:len(info)-1]) 189 | 190 | // version 191 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_VERSION, 0, nil, &infoSize) 192 | if err != C.CL_SUCCESS { 193 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 194 | } 195 | info = make([]byte, infoSize, infoSize) 196 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_VERSION, infoSize, unsafe.Pointer(&info[0]), nil) 197 | if err != C.CL_SUCCESS { 198 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 199 | } 200 | platform.Version = strings.Trim(string(info[:len(info)-1]), " ") 201 | 202 | // vendor 203 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_VENDOR, 0, nil, &infoSize) 204 | if err != C.CL_SUCCESS { 205 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 206 | } 207 | info = make([]byte, infoSize, infoSize) 208 | err = C.clGetPlatformInfo(platform_id, C.CL_PLATFORM_VENDOR, infoSize, unsafe.Pointer(&info[0]), nil) 209 | if err != C.CL_SUCCESS { 210 | return &platform, fmt.Errorf("clGetPlatformInfo Err: %v", err) 211 | } 212 | platform.Vendor = string(info[:len(info)-1]) 213 | 214 | // devices 215 | err = C.clGetDeviceIDs(platform_id, C.CL_DEVICE_TYPE_ALL, 0, nil, &platform.Device_count) 216 | if err != C.CL_SUCCESS { 217 | return &platform, fmt.Errorf("clGetDeviceIDs Err: %v", err) 218 | } 219 | var device_ids = make([]C.cl_device_id, platform.Device_count, platform.Device_count) 220 | err = C.clGetDeviceIDs(platform_id, C.CL_DEVICE_TYPE_ALL, platform.Device_count, &device_ids[0], nil) 221 | if err != C.CL_SUCCESS { 222 | return &platform, fmt.Errorf("clGetDeviceIDs Err: %v", err) 223 | } 224 | 225 | for _, device_id := range device_ids { 226 | device, _ := getOneDevie(platform.Platform_id, device_id) 227 | platform.Devices = append(platform.Devices, device) 228 | } 229 | 230 | return &platform, nil 231 | } 232 | 233 | func Info() (*OpenCLInfo, error) { 234 | var info OpenCLInfo 235 | 236 | var err = C.clGetPlatformIDs(0, nil, &info.Platform_count) 237 | if err != C.CL_SUCCESS { 238 | return &info, fmt.Errorf("clGetPlatformIDs Err: %v", err) 239 | } 240 | 241 | if info.Platform_count == 0 { 242 | return &info, nil 243 | } 244 | 245 | var platform_ids = make([]C.cl_platform_id, info.Platform_count, info.Platform_count) 246 | err = C.clGetPlatformIDs(info.Platform_count, &platform_ids[0], nil) 247 | if err != C.CL_SUCCESS { 248 | return &info, fmt.Errorf("clGetPlatformIDs Err: %v", err) 249 | } 250 | 251 | for _, platform_id := range platform_ids { 252 | platform, _ := getOnePlatform(platform_id) 253 | info.Platforms = append(info.Platforms, platform) 254 | } 255 | 256 | return &info, nil 257 | } 258 | -------------------------------------------------------------------------------- /lib-windows-3.0.13-x64/OpenCL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyberChainXyz/go-opencl/216260c11a44332ab884bb141facc6b560f501ad/lib-windows-3.0.13-x64/OpenCL.lib -------------------------------------------------------------------------------- /opencl.go: -------------------------------------------------------------------------------- 1 | package opencl 2 | 3 | // #cgo CFLAGS: -DCL_TARGET_OPENCL_VERSION=120 4 | // #cgo linux LDFLAGS: -lOpenCL 5 | // #cgo darwin LDFLAGS: -framework OpenCL 6 | // #cgo windows CFLAGS: -I${SRCDIR}/include-3.0.13 7 | // #cgo windows LDFLAGS: -L${SRCDIR}/lib-windows-3.0.13-x64 -lOpenCL 8 | import "C" 9 | -------------------------------------------------------------------------------- /runner.go: -------------------------------------------------------------------------------- 1 | package opencl 2 | 3 | // #include "cl.h" 4 | import "C" 5 | 6 | import ( 7 | "fmt" 8 | "unsafe" 9 | ) 10 | 11 | // Buffer represents an OpenCL buffer. 12 | type Buffer struct { 13 | buffer C.cl_mem 14 | } 15 | 16 | // OpenCLRunner represents an OpenCL runner. 17 | type OpenCLRunner struct { 18 | Device *OpenCLDevice 19 | Context C.cl_context 20 | CommandQueue C.cl_command_queue 21 | 22 | Program C.cl_program 23 | Kernels map[string]C.cl_kernel 24 | Buffers []*Buffer 25 | } 26 | 27 | // InitRunner initializes an OpenCLRunner for the given OpenCLDevice. 28 | // It creates a context and a command queue. 29 | func (device *OpenCLDevice) InitRunner() (*OpenCLRunner, error) { 30 | var runner = OpenCLRunner{Device: device} 31 | 32 | // clCreateContext 33 | var context_properties = [3]C.cl_context_properties{ 34 | C.CL_CONTEXT_PLATFORM, 35 | C.cl_context_properties(uintptr(unsafe.Pointer(device.Platform_id))), 36 | 0, 37 | } 38 | var err C.cl_int 39 | var context = C.clCreateContext(&context_properties[0], 1, &device.Device_id, nil, nil, &err) 40 | if err != C.CL_SUCCESS { 41 | return nil, fmt.Errorf("clCreateContext Err: %v", err) 42 | } 43 | 44 | // clCreateCommandQueue 45 | var commandQueueProperties C.cl_command_queue_properties = 0 46 | var commandQueue = C.clCreateCommandQueue(context, device.Device_id, commandQueueProperties, &err) 47 | if err != C.CL_SUCCESS { 48 | C.clReleaseContext(context) 49 | return nil, fmt.Errorf("clCreateCommandQueueErr: %v", err) 50 | } 51 | 52 | runner.Context = context 53 | runner.CommandQueue = commandQueue 54 | 55 | return &runner, nil 56 | } 57 | 58 | // Free releases all resources associated with the OpenCLRunner. 59 | func (runner *OpenCLRunner) Free() error { 60 | var err C.cl_int 61 | 62 | if len(runner.Kernels) > 0 { 63 | for _, kernel := range runner.Kernels { 64 | err = C.clReleaseKernel(kernel) 65 | } 66 | } 67 | 68 | if runner.Program != nil { 69 | err = C.clReleaseProgram(runner.Program) 70 | } 71 | 72 | if len(runner.Buffers) > 0 { 73 | for _, buffer := range runner.Buffers { 74 | err = C.clReleaseMemObject(buffer.buffer) 75 | } 76 | } 77 | 78 | err = C.clReleaseCommandQueue(runner.CommandQueue) 79 | err = C.clReleaseContext(runner.Context) 80 | 81 | if err != C.CL_SUCCESS { 82 | return fmt.Errorf("OpenCLRunner.Free cl_err: %v", err) 83 | } 84 | 85 | return nil 86 | } 87 | 88 | // CompileKernels compiles OpenCL kernels from the provided source code. 89 | func (runner *OpenCLRunner) CompileKernels(codeSourceList []string, kernelNameList []string, options string) error { 90 | var codes [](*C.char) 91 | for _, codeSource := range codeSourceList { 92 | code_src := C.CString(codeSource) 93 | defer C.free(unsafe.Pointer(code_src)) 94 | codes = append(codes, code_src) 95 | } 96 | 97 | var err C.cl_int 98 | 99 | // clCreateProgramWithSource 100 | var program = C.clCreateProgramWithSource(runner.Context, C.cl_uint(len(codes)), &codes[0], nil, &err) 101 | if err != C.CL_SUCCESS { 102 | return fmt.Errorf("clCreateProgramWithSource Err: %v", err) 103 | } 104 | 105 | cl_options := C.CString(options) 106 | defer C.free(unsafe.Pointer(cl_options)) 107 | 108 | // clBuildProgram 109 | err = C.clBuildProgram(program, 1, &runner.Device.Device_id, cl_options, nil, nil) 110 | if err != C.CL_SUCCESS { 111 | var logSize C.size_t 112 | var err2 = C.clGetProgramBuildInfo(program, runner.Device.Device_id, C.CL_PROGRAM_BUILD_LOG, 0, nil, &logSize) 113 | if err2 != C.CL_SUCCESS { 114 | C.clReleaseProgram(program) 115 | return fmt.Errorf("clGetProgramBuildInfo Err: %v", err2) 116 | } 117 | 118 | var log_buf = make([]byte, logSize, logSize) 119 | err2 = C.clGetProgramBuildInfo(program, runner.Device.Device_id, C.CL_PROGRAM_BUILD_LOG, logSize, unsafe.Pointer(&log_buf[0]), nil) 120 | 121 | if err2 != C.CL_SUCCESS { 122 | C.clReleaseProgram(program) 123 | return fmt.Errorf("clGetProgramBuildInfo Err: %v", err2) 124 | } 125 | 126 | fmt.Printf("clBuildProgram Err log: %s\n", string(log_buf)) 127 | 128 | C.clReleaseProgram(program) 129 | return fmt.Errorf("clBuildProgram Err: %v", err) 130 | } 131 | 132 | // clCreateKernel 133 | runner.Kernels = make(map[string]C.cl_kernel) 134 | for _, kernelName := range kernelNameList { 135 | var kernel_name = C.CString(kernelName) 136 | defer C.free(unsafe.Pointer(kernel_name)) 137 | 138 | var kernel = C.clCreateKernel(program, kernel_name, &err) 139 | if err != C.CL_SUCCESS { 140 | C.clReleaseProgram(program) 141 | return fmt.Errorf("clCreateKernel Err: %v", err) 142 | } 143 | runner.Kernels[kernelName] = kernel 144 | } 145 | 146 | runner.Program = program 147 | 148 | return nil 149 | } 150 | 151 | const ( 152 | READ_WRITE C.cl_mem_flags = C.CL_MEM_READ_WRITE 153 | WRITE_ONLY = C.CL_MEM_WRITE_ONLY 154 | READ_ONLY = C.CL_MEM_READ_ONLY 155 | USE_HOST_PTR = C.CL_MEM_USE_HOST_PTR 156 | ALLOC_HOST_PTR = C.CL_MEM_ALLOC_HOST_PTR 157 | COPY_HOST_PTR = C.CL_MEM_COPY_HOST_PTR 158 | ) 159 | 160 | // CreateBuffer creates an OpenCL buffer with the specified flags and source data. 161 | func CreateBuffer[E any](runner *OpenCLRunner, flags C.cl_mem_flags, source []E) (*Buffer, error) { 162 | if len(source) == 0 { 163 | return nil, fmt.Errorf("clCreateBuffer Err: source is empty") 164 | } 165 | var err C.cl_int 166 | size := C.size_t(int(unsafe.Sizeof(source[0])) * len(source)) 167 | host_ptr := unsafe.Pointer(&source[0]) 168 | cl_mem := C.clCreateBuffer(runner.Context, flags, size, host_ptr, &err) 169 | if err != C.CL_SUCCESS { 170 | return nil, fmt.Errorf("clCreateBuffer Err: %v", err) 171 | } 172 | 173 | buffer := &Buffer{cl_mem} 174 | runner.Buffers = append(runner.Buffers, buffer) 175 | return buffer, nil 176 | } 177 | 178 | // CreateEmptyBuffer creates an empty OpenCL buffer with the specified flags and size. 179 | func (runner *OpenCLRunner) CreateEmptyBuffer(flags C.cl_mem_flags, size int) (*Buffer, error) { 180 | var err C.cl_int 181 | cl_mem := C.clCreateBuffer(runner.Context, flags, C.size_t(size), nil, &err) 182 | if err != C.CL_SUCCESS { 183 | return nil, fmt.Errorf("clCreateBuffer Err: %v", err) 184 | } 185 | buffer := &Buffer{cl_mem} 186 | runner.Buffers = append(runner.Buffers, buffer) 187 | return buffer, nil 188 | } 189 | 190 | // ReadBuffer reads data from an OpenCL buffer into the target slice. 191 | func ReadBuffer[E any](runner *OpenCLRunner, offset int, buffer *Buffer, target []E) error { 192 | if len(target) == 0 { 193 | return fmt.Errorf("clEnqueueReadBuffer Err: target is nil") 194 | } 195 | err := C.clEnqueueReadBuffer(runner.CommandQueue, buffer.buffer, C.CL_TRUE, C.size_t(offset), 196 | C.size_t(int(unsafe.Sizeof(target[0]))*len(target)), 197 | unsafe.Pointer(&target[0]), 0, nil, nil) 198 | if err != C.CL_SUCCESS { 199 | return fmt.Errorf("clEnqueueReadBuffer Err: %v", err) 200 | } 201 | return nil 202 | } 203 | 204 | // WriteBuffer writes data from the source slice to an OpenCL buffer. 205 | func WriteBuffer[E any](runner *OpenCLRunner, offset int, buffer *Buffer, source []E, blocking bool) error { 206 | if len(source) == 0 { 207 | return fmt.Errorf("clEnqueueWriteBuffer Err: source is empty") 208 | } 209 | var _blocking C.cl_bool = C.CL_FALSE 210 | if blocking { 211 | _blocking = C.CL_TRUE 212 | } 213 | err := C.clEnqueueWriteBuffer(runner.CommandQueue, buffer.buffer, _blocking, C.size_t(offset), 214 | C.size_t(int(unsafe.Sizeof(source[0]))*len(source)), unsafe.Pointer(&source[0]), 0, nil, nil) 215 | if err != C.CL_SUCCESS { 216 | return fmt.Errorf("clEnqueueWriteBuffer Err: %v", err) 217 | } 218 | return nil 219 | } 220 | 221 | // ReleaseBuffer releases the specified OpenCL buffer. 222 | func (runner *OpenCLRunner) ReleaseBuffer(buffer *Buffer) error { 223 | err := C.clReleaseMemObject(buffer.buffer) 224 | if err != C.CL_SUCCESS { 225 | return fmt.Errorf("clReleaseMemObject Err: %v", err) 226 | } 227 | return nil 228 | } 229 | 230 | // map_size_t converts a slice of uint64 to a slice of C.size_t. 231 | func map_size_t[E uint64](slice []E) []C.size_t { 232 | size_t_slice := make([]C.size_t, len(slice), len(slice)) 233 | for i, v := range slice { 234 | size_t_slice[i] = C.size_t(v) 235 | } 236 | return size_t_slice 237 | } 238 | 239 | // KernelParam represents a parameter for an OpenCL kernel. 240 | type KernelParam struct { 241 | Size uintptr 242 | Pointer unsafe.Pointer 243 | } 244 | 245 | // BufferParam creates a KernelParam for an OpenCL buffer. 246 | func BufferParam(v *Buffer) KernelParam { 247 | return KernelParam{Size: unsafe.Sizeof(v.buffer), Pointer: unsafe.Pointer(&v.buffer)} 248 | } 249 | 250 | // Param creates a KernelParam for a value. 251 | func Param[E any](v *E) KernelParam { 252 | return KernelParam{Size: unsafe.Sizeof(*v), Pointer: unsafe.Pointer(v)} 253 | } 254 | 255 | // SetKernelArgs sets the arguments for a specific OpenCL kernel. 256 | func (runner *OpenCLRunner) SetKernelArgs(kernelName string, args []KernelParam) error { 257 | var kernel = runner.Kernels[kernelName] 258 | var err C.cl_int 259 | for i, arg := range args { 260 | err = C.clSetKernelArg(kernel, C.cl_uint(i), C.size_t(arg.Size), arg.Pointer) 261 | if err != C.CL_SUCCESS { 262 | return fmt.Errorf("clSetKernelArg Err: %v", err) 263 | } 264 | } 265 | return nil 266 | } 267 | 268 | // RunKernel runs an OpenCL kernel with the specified work dimensions, work sizes, and arguments. 269 | func (runner *OpenCLRunner) RunKernel(kernelName string, work_dim int, 270 | global_work_offset []uint64, global_work_size []uint64, local_work_size []uint64, args []KernelParam, wait bool) error { 271 | var kernel = runner.Kernels[kernelName] 272 | var err C.cl_int 273 | for i, arg := range args { 274 | err = C.clSetKernelArg(kernel, C.cl_uint(i), C.size_t(arg.Size), arg.Pointer) 275 | if err != C.CL_SUCCESS { 276 | return fmt.Errorf("clSetKernelArg Err: %v", err) 277 | } 278 | } 279 | 280 | var global_work_offset_ptr, global_work_size_ptr, local_work_size_ptr *C.size_t = nil, nil, nil 281 | 282 | if len(global_work_offset) != 0 { 283 | _global_work_offset := map_size_t(global_work_offset) 284 | global_work_offset_ptr = &_global_work_offset[0] 285 | } 286 | 287 | if len(global_work_size) != 0 { 288 | _global_work_size := map_size_t(global_work_size) 289 | global_work_size_ptr = &_global_work_size[0] 290 | } 291 | 292 | if len(local_work_size) != 0 { 293 | _local_work_size := map_size_t(local_work_size) 294 | local_work_size_ptr = &_local_work_size[0] 295 | } 296 | 297 | var evt *C.cl_event = nil 298 | if wait { 299 | var evt_obj C.cl_event 300 | evt = &evt_obj 301 | defer C.clReleaseEvent(evt_obj) 302 | } 303 | err = C.clEnqueueNDRangeKernel(runner.CommandQueue, kernel, C.cl_uint(work_dim), 304 | global_work_offset_ptr, global_work_size_ptr, local_work_size_ptr, 0, nil, evt) 305 | if err != C.CL_SUCCESS { 306 | return fmt.Errorf("clEnqueueNDRangeKernel Err: %v", err) 307 | } 308 | 309 | if wait { 310 | err = C.clWaitForEvents(1, evt) 311 | if err != C.CL_SUCCESS { 312 | return fmt.Errorf("clWaitForEvents Err: %v", err) 313 | } 314 | } 315 | 316 | return nil 317 | } 318 | -------------------------------------------------------------------------------- /runner_test.go: -------------------------------------------------------------------------------- 1 | // Package opencl provides a Go interface for interacting with OpenCL devices. 2 | package opencl 3 | 4 | import ( 5 | "slices" 6 | "testing" 7 | "unsafe" 8 | ) 9 | 10 | // TestRunner is a test function that tests the functionality of the OpenCL runner. 11 | func TestRunner(t *testing.T) { 12 | // Step 1: Get OpenCL device information 13 | info, _ := Info() 14 | 15 | if len(info.Platforms) < 1 { 16 | t.Skipf("No OpenCL Devices") 17 | } 18 | if len(info.Platforms[0].Devices) < 1 { 19 | t.Skipf("No OpenCL Devices") 20 | } 21 | 22 | // Step 2: Initialize the OpenCL runner 23 | device := info.Platforms[0].Devices[0] 24 | runner, err := device.InitRunner() 25 | if err != nil { 26 | t.Fatal("InitRunner err:", err) 27 | } 28 | defer runner.Free() 29 | 30 | // Step 3: Compile the OpenCL kernels 31 | code := `__kernel void helloworld(__global int* in, __global int* out) 32 | { 33 | int num = get_global_id(0); 34 | out[num] = in[num] * in[num]; 35 | }` 36 | codes := []string{code} 37 | kernelNameList := []string{"helloworld"} 38 | err = runner.CompileKernels(codes, kernelNameList, "") 39 | if err != nil { 40 | t.Fatal("CompileKernels err:", err) 41 | } 42 | 43 | // Step 4: Create kernel parameters 44 | /* buffer 1 param */ 45 | input := []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 46 | itemSize := int(unsafe.Sizeof(input[0])) 47 | itemCount := len(input) 48 | 49 | input_buf, err := CreateBuffer(runner, READ_ONLY|COPY_HOST_PTR, input) 50 | if err != nil { 51 | t.Fatal("CreateBuffer err:", err) 52 | } 53 | /* buffer 2 param */ 54 | output_buf, err := runner.CreateEmptyBuffer(WRITE_ONLY, itemCount*itemSize) 55 | if err != nil { 56 | t.Fatal("CreateEmptyBuffer err:", err) 57 | } 58 | 59 | // Step 5: Run the OpenCL kernel 60 | err = runner.RunKernel("helloworld", 1, nil, []uint64{uint64(itemCount)}, nil, []KernelParam{ 61 | BufferParam(input_buf), 62 | BufferParam(output_buf), 63 | }, true) 64 | if err != nil { 65 | t.Fatal("RunKernel err:", err) 66 | } 67 | 68 | // Step 6: Read the output buffer 69 | result := make([]int32, itemCount) 70 | err = ReadBuffer(runner, 0, output_buf, result) 71 | if err != nil { 72 | t.Fatal("ReadBuffer err:", err) 73 | } 74 | 75 | // Step 7: Check the result 76 | expected_result := make([]int32, itemCount, itemCount) 77 | for i, v := range input { 78 | expected_result[i] = v * v 79 | } 80 | if !slices.Equal(result, expected_result) { 81 | t.Fatal("result error:", result) 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /types.go: -------------------------------------------------------------------------------- 1 | package opencl 2 | 3 | // #include "cl.h" 4 | import "C" 5 | 6 | type PCIBusInfo struct { 7 | Domain C.cl_uint 8 | Bus C.cl_uint 9 | Device C.cl_uint 10 | Function C.cl_uint 11 | } 12 | 13 | type OpenCLDevice struct { 14 | Device_id C.cl_device_id 15 | Platform_id C.cl_platform_id 16 | 17 | Device_type C.cl_device_type 18 | Name string 19 | Profile string 20 | Version string 21 | Vendor string 22 | Driver_version string 23 | 24 | Max_clock_frequency C.cl_uint 25 | Max_mem_alloc_size C.cl_ulong 26 | Global_mem_size C.cl_ulong 27 | Max_compute_units C.cl_uint 28 | Max_work_group_size C.size_t 29 | 30 | Max_work_item_dimensions C.cl_uint 31 | Max_work_item_sizes []C.size_t 32 | 33 | PCIInfo PCIBusInfo 34 | } 35 | 36 | type OpenCLPlatform struct { 37 | Platform_id C.cl_platform_id 38 | Device_count C.cl_uint 39 | Name string 40 | Profile string 41 | Version string 42 | Vendor string 43 | Devices []*OpenCLDevice 44 | } 45 | 46 | type OpenCLInfo struct { 47 | Platform_count C.cl_uint 48 | Platforms []*OpenCLPlatform 49 | } 50 | --------------------------------------------------------------------------------