1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* Copyright © 2016 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __CL_DRIVER_H__
#define __CL_DRIVER_H__
#include "CL/cl.h"
#include "cl_kernel.h"
/* We put a header to identify each object. This will make the programmer life
* easy if objects are wrongly used in the API
*/
#define CL_MAGIC_PLATFORM_HEADER 0xaacdbb00123ccd85LL
#define CL_MAGIC_DEVICE_HEADER 0x0acaddcca8853c52LL
#define CL_MAGIC_KERNEL_HEADER 0x1234567890abcdefLL
#define CL_MAGIC_CONTEXT_HEADER 0x0ab123456789cdefLL
#define CL_MAGIC_PROGRAM_HEADER 0x34560ab12789cdefLL
#define CL_MAGIC_QUEUE_HEADER 0x83650a12b79ce4dfLL
#define CL_MAGIC_SAMPLER_HEADER 0x686a0ecba79ce33fLL
#define CL_MAGIC_EVENT_HEADER 0x8324a9c810ebf90fLL
#define CL_MAGIC_MEM_HEADER 0x381a27b9ce6504dfLL
#define CL_MAGIC_DEAD_HEADER 0xdeaddeaddeaddeadLL
typedef struct _cl_driver {
cl_int version_major;
cl_int (*init)(cl_platform_id platform);
cl_int (*deinit)(void);
cl_int (*get_device_ids)(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries,
cl_device_id *devices, cl_uint *num_devices);
cl_int (*create_context)(cl_context context, const cl_device_id device);
cl_int (*release_context)(cl_context context, const cl_device_id device);
cl_int (*create_command_queue)(cl_command_queue queue);
cl_int (*release_command_queue)(cl_command_queue queue);
cl_int (*build_program)(cl_program program, const cl_device_id device);
cl_int (*release_program)(cl_program program, const cl_device_id device);
cl_int (*get_program_kernel_names)(cl_program program, const cl_device_id device, char *names,
cl_uint name_sz, cl_uint* ret_sz, cl_uint* ker_num);
cl_int (*create_kernel)(cl_kernel kernel, const cl_device_id device);
cl_int (*release_kernel)(cl_kernel kernel, const cl_device_id device);
cl_int (*get_arg_num)(cl_kernel kernel, const cl_device_id device, cl_uint* ret_num);
cl_int (*get_arg_name)(cl_kernel kernel, const cl_device_id device, cl_uint index,
char *name, cl_uint name_sz, cl_uint* ret_sz);
cl_int (*get_arg_type_name)(cl_kernel kernel, const cl_device_id device, cl_uint index,
char *type_name, cl_uint name_sz, cl_uint* ret_sz);
cl_int (*get_arg_info)(cl_kernel kernel, const cl_device_id device, cl_uint index, size_t* size,
cl_kernel_arg_type *type, cl_kernel_arg_address_qualifier *qualifier,
cl_kernel_arg_access_qualifier *access, cl_kernel_arg_type_qualifier *type_qualifier);
cl_int (*create_buffer)(cl_mem mem, const cl_device_id device);
cl_int (*release_mem)(cl_mem mem, const cl_device_id device);
cl_int (*compile_program)(cl_program program, const cl_device_id device, const char *options,
cl_uint num_input_headers, const cl_program *input_headers, const char **header_include_names);
cl_int (*create_program_with_binary)(cl_program program, const cl_device_id device, size_t length, const unsigned char *binaries);
cl_int (*link_program)(cl_program program, const cl_device_id device, const char *options,
cl_uint num_input_programs, const cl_program *input_programs);
// cl_int (*create_sub_devices)(cl_device_id in_device, const cl_device_partition_property *properties,
// cl_uint num_devices, cl_device_id *out_devices, cl_uint *num_devices_ret);
// cl_int (*retain_device)(cl_device_id device);
// cl_int (*release_device)(cl_device_id device);
cl_int (*create_sampler)(cl_sampler sampler, const cl_device_id device, cl_bool normalized,
cl_addressing_mode addressing, cl_filter_mode filter);
cl_int (*release_sampler)(cl_sampler sampler, const cl_device_id device);
cl_int (*create_subbuffer)(cl_mem subbuffer, const cl_device_id device, cl_mem buffer,
cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info);
cl_int (*create_image)(cl_mem image, const cl_device_id device, cl_context context, cl_mem_flags flags,
const cl_image_format *image_format, const cl_image_desc *image_desc, void *host_ptr);
} _cl_driver;
typedef struct _cl_driver* cl_driver;
#endif /* End of __CL_DRIVER_H_*/
|