Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dlopencl.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2011-2020 darktable developers.
4
5 darktable is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 darktable is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with darktable. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#pragma once
20
21#ifdef HAVE_OPENCL
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <CL/cl.h>
28
29typedef cl_int (*dt_clGetPlatformIDs_t)(cl_uint, cl_platform_id *, cl_uint *);
30typedef cl_int (*dt_clGetPlatformInfo_t)(cl_platform_id, cl_platform_info, size_t, void *, size_t *);
31typedef cl_int (*dt_clGetDeviceIDs_t)(cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
32typedef cl_int (*dt_clGetDeviceInfo_t)(cl_device_id, cl_device_info, size_t, void *, size_t *);
33typedef cl_context (*dt_clCreateContext_t)(const cl_context_properties *, cl_uint, const cl_device_id *,
34 void (*)(const char *, const void *, size_t, void *), void *,
35 cl_int *);
36typedef cl_context (*dt_clCreateContextFromType_t)(const cl_context_properties *, cl_device_type,
37 void (*)(const char *, const void *, size_t, void *),
38 void *, cl_int *);
39typedef cl_int (*dt_clRetainContext_t)(cl_context);
40typedef cl_int (*dt_clReleaseContext_t)(cl_context);
41typedef cl_int (*dt_clGetContextInfo_t)(cl_context, cl_context_info, size_t, void *, size_t *);
42typedef cl_command_queue (*dt_clCreateCommandQueue_t)(cl_context, cl_device_id, cl_command_queue_properties,
43 cl_int *);
44typedef cl_int (*dt_clRetainCommandQueue_t)(cl_command_queue);
45typedef cl_int (*dt_clReleaseCommandQueue_t)(cl_command_queue);
46typedef cl_int (*dt_clGetCommandQueueInfo_t)(cl_command_queue, cl_command_queue_info, size_t, void *,
47 size_t *);
48typedef cl_int (*dt_clSetCommandQueueProperty_t)(cl_command_queue, cl_command_queue_properties, cl_bool,
49 cl_command_queue_properties *);
50typedef cl_mem (*dt_clCreateBuffer_t)(cl_context, cl_mem_flags, size_t, void *, cl_int *);
51typedef cl_mem (*dt_clCreateSubBuffer_t)(cl_mem, cl_mem_flags, cl_buffer_create_type, const void *, cl_int *);
52typedef cl_mem (*dt_clCreateImage2D_t)(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t,
53 size_t, void *, cl_int *);
54typedef cl_mem (*dt_clCreateImage3D_t)(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t,
55 size_t, size_t, size_t, void *, cl_int *);
56typedef cl_int (*dt_clRetainMemObject_t)(cl_mem);
57typedef cl_int (*dt_clReleaseMemObject_t)(cl_mem);
58typedef cl_int (*dt_clGetSupportedImageFormats_t)(cl_context, cl_mem_flags, cl_mem_object_type, cl_uint,
59 cl_image_format *, cl_uint *);
60typedef cl_int (*dt_clGetMemObjectInfo_t)(cl_mem, cl_mem_info, size_t, void *, size_t *);
61typedef cl_int (*dt_clGetImageInfo_t)(cl_mem, cl_image_info, size_t, void *, size_t *);
62typedef cl_int (*dt_clSetMemObjectDestructorCallback_t)(cl_mem, void(*), void *);
63typedef cl_sampler (*dt_clCreateSampler_t)(cl_context, cl_bool, cl_addressing_mode, cl_filter_mode, cl_int *);
64typedef cl_int (*dt_clRetainSampler_t)(cl_sampler);
65typedef cl_int (*dt_clReleaseSampler_t)(cl_sampler);
66typedef cl_int (*dt_clGetSamplerInfo_t)(cl_sampler, cl_sampler_info, size_t, void *, size_t *);
67typedef cl_program (*dt_clCreateProgramWithSource_t)(cl_context, cl_uint, const char **, const size_t *,
68 cl_int *);
69typedef cl_program (*dt_clCreateProgramWithBinary_t)(cl_context, cl_uint, const cl_device_id *,
70 const size_t *, const unsigned char **, cl_int *,
71 cl_int *);
72typedef cl_int (*dt_clRetainProgram_t)(cl_program);
73typedef cl_int (*dt_clReleaseProgram_t)(cl_program);
74typedef cl_int (*dt_clBuildProgram_t)(cl_program, cl_uint, const cl_device_id *, const char *, void(*),
75 void *);
76typedef cl_int (*dt_clUnloadCompiler_t)(void);
77typedef cl_int (*dt_clGetProgramInfo_t)(cl_program, cl_program_info, size_t, void *, size_t *);
78typedef cl_int (*dt_clGetProgramBuildInfo_t)(cl_program, cl_device_id, cl_program_build_info, size_t, void *,
79 size_t *);
80typedef cl_kernel (*dt_clCreateKernel_t)(cl_program, const char *, cl_int *);
81typedef cl_int (*dt_clCreateKernelsInProgram_t)(cl_program, cl_uint, cl_kernel *, cl_uint *);
82typedef cl_int (*dt_clRetainKernel_t)(cl_kernel);
83typedef cl_int (*dt_clReleaseKernel_t)(cl_kernel);
84typedef cl_int (*dt_clSetKernelArg_t)(cl_kernel, cl_uint, size_t, const void *);
85typedef cl_int (*dt_clGetKernelInfo_t)(cl_kernel, cl_kernel_info, size_t, void *, size_t *);
86typedef cl_int (*dt_clGetKernelWorkGroupInfo_t)(cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t,
87 void *, size_t *);
88typedef cl_int (*dt_clWaitForEvents_t)(cl_uint, const cl_event *);
89typedef cl_int (*dt_clGetEventInfo_t)(cl_event, cl_event_info, size_t, void *, size_t *);
90typedef cl_event (*dt_clCreateUserEvent_t)(cl_context, cl_int *);
91typedef cl_int (*dt_clRetainEvent_t)(cl_event);
92typedef cl_int (*dt_clReleaseEvent_t)(cl_event);
93typedef cl_int (*dt_clSetUserEventStatus_t)(cl_event, cl_int);
94typedef cl_int (*dt_clSetEventCallback_t)(cl_event, cl_int, void (*)(cl_event, cl_int, void *), void *);
95typedef cl_int (*dt_clGetEventProfilingInfo_t)(cl_event, cl_profiling_info, size_t, void *, size_t *);
96typedef cl_int (*dt_clFlush_t)(cl_command_queue);
97typedef cl_int (*dt_clFinish_t)(cl_command_queue);
98typedef cl_int (*dt_clEnqueueReadBuffer_t)(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint,
99 const cl_event *, cl_event *);
100typedef cl_int (*dt_clEnqueueReadBufferRect_t)(cl_command_queue, cl_mem, cl_bool, const size_t *,
101 const size_t *, const size_t *, size_t, size_t, size_t, size_t,
102 void *, cl_uint, const cl_event *, cl_event *);
103typedef cl_int (*dt_clEnqueueWriteBuffer_t)(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *,
104 cl_uint, const cl_event *, cl_event *);
105typedef cl_int (*dt_clEnqueueWriteBufferRect_t)(cl_command_queue, cl_mem, cl_bool, const size_t *,
106 const size_t *, const size_t *, size_t, size_t, size_t,
107 size_t, const void *, cl_uint, const cl_event *, cl_event *);
108typedef cl_int (*dt_clEnqueueCopyBuffer_t)(cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint,
109 const cl_event *, cl_event *);
110typedef cl_int (*dt_clEnqueueCopyBufferRect_t)(cl_command_queue, cl_mem, cl_mem, const size_t *,
111 const size_t *, const size_t *, size_t, size_t, size_t, size_t,
112 cl_uint, const cl_event *, cl_event *);
113typedef cl_int (*dt_clEnqueueReadImage_t)(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *,
114 size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
115typedef cl_int (*dt_clEnqueueWriteImage_t)(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *,
116 size_t, size_t, const void *, cl_uint, const cl_event *,
117 cl_event *);
118typedef cl_int (*dt_clEnqueueCopyImage_t)(cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *,
119 const size_t *, cl_uint, const cl_event *, cl_event *);
120typedef cl_int (*dt_clEnqueueCopyImageToBuffer_t)(cl_command_queue, cl_mem, cl_mem, const size_t *,
121 const size_t *, size_t, cl_uint, const cl_event *,
122 cl_event *);
123typedef cl_int (*dt_clEnqueueCopyBufferToImage_t)(cl_command_queue, cl_mem, cl_mem, size_t, const size_t *,
124 const size_t *, cl_uint, const cl_event *, cl_event *);
125typedef void *(*dt_clEnqueueMapBuffer_t)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t,
126 cl_uint, const cl_event *, cl_event *, cl_int *);
127typedef void *(*dt_clEnqueueMapImage_t)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t *,
128 const size_t *, size_t *, size_t *, cl_uint, const cl_event *,
129 cl_event *, cl_int *);
130typedef cl_int (*dt_clEnqueueUnmapMemObject_t)(cl_command_queue, cl_mem, void *, cl_uint, const cl_event *,
131 cl_event *);
132typedef cl_int (*dt_clEnqueueNDRangeKernel_t)(cl_command_queue, cl_kernel, cl_uint, const size_t *,
133 const size_t *, const size_t *, cl_uint, const cl_event *,
134 cl_event *);
135typedef cl_int (*dt_clEnqueueTask_t)(cl_command_queue, cl_kernel, cl_uint, const cl_event *, cl_event *);
136typedef cl_int (*dt_clEnqueueNativeKernel_t)(cl_command_queue, void (*user_func)(void *), void *, size_t,
137 cl_uint, const cl_mem *, const void **, cl_uint,
138 const cl_event *, cl_event *);
139typedef cl_int (*dt_clEnqueueMarker_t)(cl_command_queue, cl_event *);
140typedef cl_int (*dt_clEnqueueWaitForEvents_t)(cl_command_queue, cl_uint, const cl_event *);
141typedef cl_int (*dt_clEnqueueBarrier_t)(cl_command_queue);
142
143typedef struct dt_dlopencl_symbols_t
144{
145 dt_clGetPlatformIDs_t dt_clGetPlatformIDs;
146 dt_clGetPlatformInfo_t dt_clGetPlatformInfo;
147 dt_clGetDeviceIDs_t dt_clGetDeviceIDs;
148 dt_clGetDeviceInfo_t dt_clGetDeviceInfo;
149 dt_clCreateContext_t dt_clCreateContext;
150 dt_clCreateContextFromType_t dt_clCreateContextFromType;
151 dt_clRetainContext_t dt_clRetainContext;
152 dt_clReleaseContext_t dt_clReleaseContext;
153 dt_clGetContextInfo_t dt_clGetContextInfo;
154 dt_clCreateCommandQueue_t dt_clCreateCommandQueue;
155 dt_clRetainCommandQueue_t dt_clRetainCommandQueue;
156 dt_clReleaseCommandQueue_t dt_clReleaseCommandQueue;
157 dt_clGetCommandQueueInfo_t dt_clGetCommandQueueInfo;
158 dt_clSetCommandQueueProperty_t dt_clSetCommandQueueProperty;
159 dt_clCreateBuffer_t dt_clCreateBuffer;
160 dt_clCreateSubBuffer_t dt_clCreateSubBuffer;
161 dt_clCreateImage2D_t dt_clCreateImage2D;
162 dt_clCreateImage3D_t dt_clCreateImage3D;
163 dt_clRetainMemObject_t dt_clRetainMemObject;
164 dt_clReleaseMemObject_t dt_clReleaseMemObject;
165 dt_clGetSupportedImageFormats_t dt_clGetSupportedImageFormats;
166 dt_clGetMemObjectInfo_t dt_clGetMemObjectInfo;
167 dt_clGetImageInfo_t dt_clGetImageInfo;
168 dt_clSetMemObjectDestructorCallback_t dt_clSetMemObjectDestructorCallback;
169 dt_clCreateSampler_t dt_clCreateSampler;
170 dt_clRetainSampler_t dt_clRetainSampler;
171 dt_clReleaseSampler_t dt_clReleaseSampler;
172 dt_clGetSamplerInfo_t dt_clGetSamplerInfo;
173 dt_clCreateProgramWithSource_t dt_clCreateProgramWithSource;
174 dt_clCreateProgramWithBinary_t dt_clCreateProgramWithBinary;
175 dt_clRetainProgram_t dt_clRetainProgram;
176 dt_clReleaseProgram_t dt_clReleaseProgram;
177 dt_clBuildProgram_t dt_clBuildProgram;
178 dt_clUnloadCompiler_t dt_clUnloadCompiler;
179 dt_clGetProgramInfo_t dt_clGetProgramInfo;
180 dt_clGetProgramBuildInfo_t dt_clGetProgramBuildInfo;
181 dt_clCreateKernel_t dt_clCreateKernel;
182 dt_clCreateKernelsInProgram_t dt_clCreateKernelsInProgram;
183 dt_clRetainKernel_t dt_clRetainKernel;
184 dt_clReleaseKernel_t dt_clReleaseKernel;
185 dt_clSetKernelArg_t dt_clSetKernelArg;
186 dt_clGetKernelInfo_t dt_clGetKernelInfo;
187 dt_clGetKernelWorkGroupInfo_t dt_clGetKernelWorkGroupInfo;
188 dt_clWaitForEvents_t dt_clWaitForEvents;
189 dt_clGetEventInfo_t dt_clGetEventInfo;
190 dt_clCreateUserEvent_t dt_clCreateUserEvent;
191 dt_clRetainEvent_t dt_clRetainEvent;
192 dt_clReleaseEvent_t dt_clReleaseEvent;
193 dt_clSetUserEventStatus_t dt_clSetUserEventStatus;
194 dt_clSetEventCallback_t dt_clSetEventCallback;
195 dt_clGetEventProfilingInfo_t dt_clGetEventProfilingInfo;
196 dt_clFlush_t dt_clFlush;
197 dt_clFinish_t dt_clFinish;
198 dt_clEnqueueReadBuffer_t dt_clEnqueueReadBuffer;
199 dt_clEnqueueReadBufferRect_t dt_clEnqueueReadBufferRect;
200 dt_clEnqueueWriteBuffer_t dt_clEnqueueWriteBuffer;
201 dt_clEnqueueWriteBufferRect_t dt_clEnqueueWriteBufferRect;
202 dt_clEnqueueCopyBuffer_t dt_clEnqueueCopyBuffer;
203 dt_clEnqueueCopyBufferRect_t dt_clEnqueueCopyBufferRect;
204 dt_clEnqueueReadImage_t dt_clEnqueueReadImage;
205 dt_clEnqueueWriteImage_t dt_clEnqueueWriteImage;
206 dt_clEnqueueCopyImage_t dt_clEnqueueCopyImage;
207 dt_clEnqueueCopyImageToBuffer_t dt_clEnqueueCopyImageToBuffer;
208 dt_clEnqueueCopyBufferToImage_t dt_clEnqueueCopyBufferToImage;
209 dt_clEnqueueMapBuffer_t dt_clEnqueueMapBuffer;
210 dt_clEnqueueMapImage_t dt_clEnqueueMapImage;
211 dt_clEnqueueUnmapMemObject_t dt_clEnqueueUnmapMemObject;
212 dt_clEnqueueNDRangeKernel_t dt_clEnqueueNDRangeKernel;
213 dt_clEnqueueTask_t dt_clEnqueueTask;
214 dt_clEnqueueNativeKernel_t dt_clEnqueueNativeKernel;
215 dt_clEnqueueMarker_t dt_clEnqueueMarker;
216 dt_clEnqueueWaitForEvents_t dt_clEnqueueWaitForEvents;
217 dt_clEnqueueBarrier_t dt_clEnqueueBarrier;
218} dt_dlopencl_symbols_t;
219
220
221
222typedef struct dt_dlopencl_t
223{
224 int have_opencl;
225 dt_dlopencl_symbols_t *symbols;
226 char *library;
227} dt_dlopencl_t;
228
229/* default noop function for all unassigned function pointers */
230void dt_dlopencl_noop(void);
231
232/* dynamically load OpenCL library and bind needed functions */
233dt_dlopencl_t *dt_dlopencl_init(const char *);
234
235#endif // HAVE_OPENCL
236
237// clang-format off
238// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
239// vim: shiftwidth=2 expandtab tabstop=2 cindent
240// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
241// clang-format on
242
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))