├── .gitignore
├── .project
├── AndroidManifest.xml
├── README.md
├── assets
└── kernels.cl
├── build.xml
├── ic_launcher-web.png
├── jni
├── Android.mk
├── Application.mk
├── include
│ └── CL
│ │ ├── cl.h
│ │ ├── cl.hpp
│ │ ├── cl_ext.h
│ │ ├── cl_gl.h
│ │ ├── cl_gl_ext.h
│ │ ├── cl_platform.h
│ │ └── opencl.h
├── processor.cpp
└── processor.h
├── local.properties
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── drawable-xxhdpi
│ └── ic_launcher.png
├── layout
│ └── activity_live_feature.xml
├── menu
│ └── live_feature.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
├── values-w820dp
│ └── dimens.xml
└── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── src
└── com
└── example
├── CameraPreview.java
├── Constants.java
└── LiveFeatureActivity.java
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | gen/
3 | libs/
4 | obj/
5 | .classpath
6 | .settings/
7 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | androidcl
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | androidcl
2 | =======
3 |
4 | Sample app that runs OpenCL kernels to process camera feed on Android devices
5 |
6 |
7 | File Structure
8 | --------------
9 |
10 | * assets (contains the opencl kernels source file)
11 | * jni (JNI source code that helps run opencl kernels and the necessary native c/c++ code)
12 | * src (java source files)
13 |
14 |
15 | How to build the native code?
16 | -----------------------------
17 |
18 | Run the command `ndk-build` from android application project root folder. If you found any issues with code, you are welcome to submit a fix or let us know so that we can fix it. Thank you.
19 |
20 |
21 | How to build java code?
22 | -----------------------
23 |
24 | If you are aware of ant build tool, run the command `ant debug install` with your testing mobile device attached to your development machine. That should do a debug build and install it on to your testing device.
25 |
26 | If you are not aware of `ant`, you can export this entire droidcl repository as an application in eclipse that has the capability to develop android applications. Rest of it is similar to how you build any other app on eclipse.
27 |
--------------------------------------------------------------------------------
/assets/kernels.cl:
--------------------------------------------------------------------------------
1 | #define BLK_SIZE 16
2 | //prefix D for decoding
3 | #define DSHRD_LEN (BLK_SIZE/2)
4 | #define DSHRD_SIZE (2*DSHRD_LEN*DSHRD_LEN)
5 |
6 | uchar4 convertYVUtoRGBA(int y, int u, int v)
7 | {
8 | uchar4 ret;
9 | y-=16;
10 | u-=128;
11 | v-=128;
12 | int b = y + (int)(1.772f*u);
13 | int g = y - (int)(0.344f*u + 0.714f*v);
14 | int r = y + (int)(1.402f*v);
15 | ret.x = r>255? 255 : r<0 ? 0 : r;
16 | ret.y = g>255? 255 : g<0 ? 0 : g;
17 | ret.z = b>255? 255 : b<0 ? 0 : b;
18 | ret.w = 255;
19 | return ret;
20 | }
21 |
22 | __kernel void nv21torgba( __global uchar4* out,
23 | __global uchar* in,
24 | int im_width,
25 | int im_height)
26 | {
27 | __local uchar uvShrd[DSHRD_SIZE];
28 | int gx = get_global_id(0);
29 | int gy = get_global_id(1);
30 | int lx = get_local_id(0);
31 | int ly = get_local_id(1);
32 | int off = im_width*im_height;
33 | // every thread whose
34 | // both x,y indices are divisible
35 | // by 2 move the u,v corresponding
36 | // to the 2x2 block into shared mem
37 | int inIdx= gy*im_width+gx;
38 | int uvIdx= off + (gy/2)*im_width + (gx & ~1);
39 | int shlx = lx/2;
40 | int shly = ly/2;
41 | int shIdx= 2*(shlx+shly*DSHRD_LEN);
42 | if( gx%2==0 && gy%2==0 ) {
43 | uvShrd[shIdx+0] = in[uvIdx+0];
44 | uvShrd[shIdx+1] = in[uvIdx+1];
45 | }
46 | // do some work while others copy
47 | // uv to shared memory
48 | int y = (0xFF & ((int)in[inIdx]));
49 | if( y < 16 ) y=16;
50 | barrier(CLK_LOCAL_MEM_FENCE);
51 | // return invalid threads
52 | if( gx >= im_width || gy >= im_height )
53 | return;
54 | // convert color space
55 | int v = (0xFF & ((int)uvShrd[shIdx+0]));
56 | int u = (0xFF & ((int)uvShrd[shIdx+1]));
57 | // write output to image
58 | out[inIdx] = convertYVUtoRGBA(y,u,v);
59 | }
60 |
61 | //prefix L for laplacian
62 | #define LHALO 1
63 | #define LPADDING (2*LHALO)
64 | #define LSBLK_LEN (BLK_SIZE+LPADDING)
65 | #define LSBLK_SIZE (LSBLK_LEN*LSBLK_LEN)
66 |
67 | #define globIdx(x,y) ((y)*dim0 + (x))
68 | #define shrdIdx(x,y) ((y)*LSBLK_LEN+ (x))
69 |
70 | #define LOAD_TO_LOCALMEM(_gx,_gy,_lx,_ly) \
71 | int gx_ = clamp((_gx),0,(int)dim0-1);\
72 | int gy_ = clamp((_gy),0,(int)dim1-1);\
73 | localMem[ shrdIdx(_lx,_ly) ] = in[ globIdx(gx_,gy_) ];
74 |
75 | __kernel void laplacian(__global uchar4* out,
76 | __global uchar4* in,
77 | int dim0,
78 | int dim1)
79 | {
80 | // 0 as fast moving dimension
81 | // 1 as slow moving dimension
82 | __local uchar4 localMem[LSBLK_SIZE];
83 | // global indices
84 | int gx = get_global_id(0);
85 | int gy = get_global_id(1);
86 | // local indices
87 | int lx = get_local_id(0);
88 | int ly = get_local_id(1);
89 | // offset values for pulling image to local memory
90 | int lx2 = lx + BLK_SIZE;
91 | int ly2 = ly + BLK_SIZE;
92 | int gx2 = gx + BLK_SIZE;
93 | int gy2 = gy + BLK_SIZE;
94 | int i = lx + LHALO;
95 | int j = ly + LHALO;
96 | // pull image to local memory
97 | LOAD_TO_LOCALMEM(gx-LHALO,gy-LHALO,lx,ly);
98 | if (lx < LPADDING) { LOAD_TO_LOCALMEM(gx2-LHALO,gy-LHALO,lx2,ly); }
99 | if (ly < LPADDING) { LOAD_TO_LOCALMEM(gx-LHALO,gy2-LHALO,lx,ly2); }
100 | if (lx < LPADDING && ly < LPADDING) {
101 | LOAD_TO_LOCALMEM(gx2-LHALO,gy2-LHALO,lx2,ly2);
102 | }
103 | barrier(CLK_LOCAL_MEM_FENCE);
104 | float4 C = convert_float4( localMem[ shrdIdx(i ,j ) ] );
105 | float4 N = convert_float4( localMem[ shrdIdx(i ,j-1) ] );
106 | float4 NW = convert_float4( localMem[ shrdIdx(i-1,j-1) ] );
107 | float4 W = convert_float4( localMem[ shrdIdx(i-1,j ) ] );
108 | float4 SW = convert_float4( localMem[ shrdIdx(i-1,j+1) ] );
109 | float4 S = convert_float4( localMem[ shrdIdx(i ,j+1) ] );
110 | float4 SE = convert_float4( localMem[ shrdIdx(i+1,j+1) ] );
111 | float4 E = convert_float4( localMem[ shrdIdx(i+1,j ) ] );
112 | float4 NE = convert_float4( localMem[ shrdIdx(i+1,j-1) ] );
113 |
114 | float4 acc = (float4)0.0f;
115 | acc = 8*C-N-NW-W-SW-S-SE-E-NE;
116 | acc.w = 255.0f;
117 |
118 | if( gx < dim0 && gy < dim1 ) {
119 | out[gy*dim0+gx] = convert_uchar4(acc);
120 | }
121 | }
122 |
123 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
49 |
50 |
51 |
52 |
56 |
57 |
69 |
70 |
71 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arrayfire/androidcl/2cc91765a6bf4e2312137e946480022c370c89db/ic_launcher-web.png
--------------------------------------------------------------------------------
/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | LOCAL_MODULE := JNIProcessor
4 | LOCAL_ARM_MODE := arm
5 | LOCAL_SRC_FILES := processor.cpp
6 | LOCAL_CPPFLAGS := -DARM -DOS_LNX -DARCH_32 -fexceptions
7 | LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/include
8 | LOCAL_CPPFLAGS += -fexceptions
9 | LOCAL_LDLIBS := -ljnigraphics -llog $(LOCAL_PATH)/libs/libOpenCL.so
10 | include $(BUILD_SHARED_LIBRARY)
11 |
--------------------------------------------------------------------------------
/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_OPTIM := release
2 | APP_STL := gnustl_static
3 | APP_PLATFORM:= android-14
4 |
--------------------------------------------------------------------------------
/jni/include/CL/cl.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | ******************************************************************************/
23 |
24 | #ifndef __OPENCL_CL_H
25 | #define __OPENCL_CL_H
26 |
27 | #ifdef __APPLE__
28 | #include
29 | #else
30 | #include
31 | #endif
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /******************************************************************************/
38 |
39 | typedef struct _cl_platform_id * cl_platform_id;
40 | typedef struct _cl_device_id * cl_device_id;
41 | typedef struct _cl_context * cl_context;
42 | typedef struct _cl_command_queue * cl_command_queue;
43 | typedef struct _cl_mem * cl_mem;
44 | typedef struct _cl_program * cl_program;
45 | typedef struct _cl_kernel * cl_kernel;
46 | typedef struct _cl_event * cl_event;
47 | typedef struct _cl_sampler * cl_sampler;
48 |
49 | typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
50 | typedef cl_ulong cl_bitfield;
51 | typedef cl_bitfield cl_device_type;
52 | typedef cl_uint cl_platform_info;
53 | typedef cl_uint cl_device_info;
54 | typedef cl_bitfield cl_device_fp_config;
55 | typedef cl_uint cl_device_mem_cache_type;
56 | typedef cl_uint cl_device_local_mem_type;
57 | typedef cl_bitfield cl_device_exec_capabilities;
58 | typedef cl_bitfield cl_command_queue_properties;
59 | typedef intptr_t cl_device_partition_property;
60 | typedef cl_bitfield cl_device_affinity_domain;
61 |
62 | typedef intptr_t cl_context_properties;
63 | typedef cl_uint cl_context_info;
64 | typedef cl_uint cl_command_queue_info;
65 | typedef cl_uint cl_channel_order;
66 | typedef cl_uint cl_channel_type;
67 | typedef cl_bitfield cl_mem_flags;
68 | typedef cl_uint cl_mem_object_type;
69 | typedef cl_uint cl_mem_info;
70 | typedef cl_bitfield cl_mem_migration_flags;
71 | typedef cl_uint cl_image_info;
72 | typedef cl_uint cl_buffer_create_type;
73 | typedef cl_uint cl_addressing_mode;
74 | typedef cl_uint cl_filter_mode;
75 | typedef cl_uint cl_sampler_info;
76 | typedef cl_bitfield cl_map_flags;
77 | typedef cl_uint cl_program_info;
78 | typedef cl_uint cl_program_build_info;
79 | typedef cl_uint cl_program_binary_type;
80 | typedef cl_int cl_build_status;
81 | typedef cl_uint cl_kernel_info;
82 | typedef cl_uint cl_kernel_arg_info;
83 | typedef cl_uint cl_kernel_arg_address_qualifier;
84 | typedef cl_uint cl_kernel_arg_access_qualifier;
85 | typedef cl_bitfield cl_kernel_arg_type_qualifier;
86 | typedef cl_uint cl_kernel_work_group_info;
87 | typedef cl_uint cl_event_info;
88 | typedef cl_uint cl_command_type;
89 | typedef cl_uint cl_profiling_info;
90 |
91 |
92 | typedef struct _cl_image_format {
93 | cl_channel_order image_channel_order;
94 | cl_channel_type image_channel_data_type;
95 | } cl_image_format;
96 |
97 | typedef struct _cl_image_desc {
98 | cl_mem_object_type image_type;
99 | size_t image_width;
100 | size_t image_height;
101 | size_t image_depth;
102 | size_t image_array_size;
103 | size_t image_row_pitch;
104 | size_t image_slice_pitch;
105 | cl_uint num_mip_levels;
106 | cl_uint num_samples;
107 | cl_mem buffer;
108 | } cl_image_desc;
109 |
110 | typedef struct _cl_buffer_region {
111 | size_t origin;
112 | size_t size;
113 | } cl_buffer_region;
114 |
115 |
116 | /******************************************************************************/
117 |
118 | /* Error Codes */
119 | #define CL_SUCCESS 0
120 | #define CL_DEVICE_NOT_FOUND -1
121 | #define CL_DEVICE_NOT_AVAILABLE -2
122 | #define CL_COMPILER_NOT_AVAILABLE -3
123 | #define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
124 | #define CL_OUT_OF_RESOURCES -5
125 | #define CL_OUT_OF_HOST_MEMORY -6
126 | #define CL_PROFILING_INFO_NOT_AVAILABLE -7
127 | #define CL_MEM_COPY_OVERLAP -8
128 | #define CL_IMAGE_FORMAT_MISMATCH -9
129 | #define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
130 | #define CL_BUILD_PROGRAM_FAILURE -11
131 | #define CL_MAP_FAILURE -12
132 | #define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
133 | #define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
134 | #define CL_COMPILE_PROGRAM_FAILURE -15
135 | #define CL_LINKER_NOT_AVAILABLE -16
136 | #define CL_LINK_PROGRAM_FAILURE -17
137 | #define CL_DEVICE_PARTITION_FAILED -18
138 | #define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19
139 |
140 | #define CL_INVALID_VALUE -30
141 | #define CL_INVALID_DEVICE_TYPE -31
142 | #define CL_INVALID_PLATFORM -32
143 | #define CL_INVALID_DEVICE -33
144 | #define CL_INVALID_CONTEXT -34
145 | #define CL_INVALID_QUEUE_PROPERTIES -35
146 | #define CL_INVALID_COMMAND_QUEUE -36
147 | #define CL_INVALID_HOST_PTR -37
148 | #define CL_INVALID_MEM_OBJECT -38
149 | #define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
150 | #define CL_INVALID_IMAGE_SIZE -40
151 | #define CL_INVALID_SAMPLER -41
152 | #define CL_INVALID_BINARY -42
153 | #define CL_INVALID_BUILD_OPTIONS -43
154 | #define CL_INVALID_PROGRAM -44
155 | #define CL_INVALID_PROGRAM_EXECUTABLE -45
156 | #define CL_INVALID_KERNEL_NAME -46
157 | #define CL_INVALID_KERNEL_DEFINITION -47
158 | #define CL_INVALID_KERNEL -48
159 | #define CL_INVALID_ARG_INDEX -49
160 | #define CL_INVALID_ARG_VALUE -50
161 | #define CL_INVALID_ARG_SIZE -51
162 | #define CL_INVALID_KERNEL_ARGS -52
163 | #define CL_INVALID_WORK_DIMENSION -53
164 | #define CL_INVALID_WORK_GROUP_SIZE -54
165 | #define CL_INVALID_WORK_ITEM_SIZE -55
166 | #define CL_INVALID_GLOBAL_OFFSET -56
167 | #define CL_INVALID_EVENT_WAIT_LIST -57
168 | #define CL_INVALID_EVENT -58
169 | #define CL_INVALID_OPERATION -59
170 | #define CL_INVALID_GL_OBJECT -60
171 | #define CL_INVALID_BUFFER_SIZE -61
172 | #define CL_INVALID_MIP_LEVEL -62
173 | #define CL_INVALID_GLOBAL_WORK_SIZE -63
174 | #define CL_INVALID_PROPERTY -64
175 | #define CL_INVALID_IMAGE_DESCRIPTOR -65
176 | #define CL_INVALID_COMPILER_OPTIONS -66
177 | #define CL_INVALID_LINKER_OPTIONS -67
178 | #define CL_INVALID_DEVICE_PARTITION_COUNT -68
179 |
180 | /* OpenCL Version */
181 | #define CL_VERSION_1_0 1
182 | #define CL_VERSION_1_1 1
183 | #define CL_VERSION_1_2 1
184 |
185 | /* cl_bool */
186 | #define CL_FALSE 0
187 | #define CL_TRUE 1
188 | #define CL_BLOCKING CL_TRUE
189 | #define CL_NON_BLOCKING CL_FALSE
190 |
191 | /* cl_platform_info */
192 | #define CL_PLATFORM_PROFILE 0x0900
193 | #define CL_PLATFORM_VERSION 0x0901
194 | #define CL_PLATFORM_NAME 0x0902
195 | #define CL_PLATFORM_VENDOR 0x0903
196 | #define CL_PLATFORM_EXTENSIONS 0x0904
197 |
198 | /* cl_device_type - bitfield */
199 | #define CL_DEVICE_TYPE_DEFAULT (1 << 0)
200 | #define CL_DEVICE_TYPE_CPU (1 << 1)
201 | #define CL_DEVICE_TYPE_GPU (1 << 2)
202 | #define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
203 | #define CL_DEVICE_TYPE_CUSTOM (1 << 4)
204 | #define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
205 |
206 | /* cl_device_info */
207 | #define CL_DEVICE_TYPE 0x1000
208 | #define CL_DEVICE_VENDOR_ID 0x1001
209 | #define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
210 | #define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
211 | #define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
212 | #define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
213 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
214 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
215 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
216 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
217 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
218 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
219 | #define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
220 | #define CL_DEVICE_ADDRESS_BITS 0x100D
221 | #define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
222 | #define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
223 | #define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
224 | #define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
225 | #define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
226 | #define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
227 | #define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
228 | #define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
229 | #define CL_DEVICE_IMAGE_SUPPORT 0x1016
230 | #define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
231 | #define CL_DEVICE_MAX_SAMPLERS 0x1018
232 | #define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
233 | #define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
234 | #define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
235 | #define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
236 | #define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
237 | #define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
238 | #define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
239 | #define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
240 | #define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
241 | #define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
242 | #define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
243 | #define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
244 | #define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
245 | #define CL_DEVICE_ENDIAN_LITTLE 0x1026
246 | #define CL_DEVICE_AVAILABLE 0x1027
247 | #define CL_DEVICE_COMPILER_AVAILABLE 0x1028
248 | #define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
249 | #define CL_DEVICE_QUEUE_PROPERTIES 0x102A
250 | #define CL_DEVICE_NAME 0x102B
251 | #define CL_DEVICE_VENDOR 0x102C
252 | #define CL_DRIVER_VERSION 0x102D
253 | #define CL_DEVICE_PROFILE 0x102E
254 | #define CL_DEVICE_VERSION 0x102F
255 | #define CL_DEVICE_EXTENSIONS 0x1030
256 | #define CL_DEVICE_PLATFORM 0x1031
257 | #define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
258 | /* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */
259 | #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
260 | #define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035
261 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
262 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
263 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
264 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
265 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
266 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
267 | #define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
268 | #define CL_DEVICE_OPENCL_C_VERSION 0x103D
269 | #define CL_DEVICE_LINKER_AVAILABLE 0x103E
270 | #define CL_DEVICE_BUILT_IN_KERNELS 0x103F
271 | #define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040
272 | #define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041
273 | #define CL_DEVICE_PARENT_DEVICE 0x1042
274 | #define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043
275 | #define CL_DEVICE_PARTITION_PROPERTIES 0x1044
276 | #define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045
277 | #define CL_DEVICE_PARTITION_TYPE 0x1046
278 | #define CL_DEVICE_REFERENCE_COUNT 0x1047
279 | #define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048
280 | #define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049
281 |
282 | /* cl_device_fp_config - bitfield */
283 | #define CL_FP_DENORM (1 << 0)
284 | #define CL_FP_INF_NAN (1 << 1)
285 | #define CL_FP_ROUND_TO_NEAREST (1 << 2)
286 | #define CL_FP_ROUND_TO_ZERO (1 << 3)
287 | #define CL_FP_ROUND_TO_INF (1 << 4)
288 | #define CL_FP_FMA (1 << 5)
289 | #define CL_FP_SOFT_FLOAT (1 << 6)
290 | #define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7)
291 |
292 | /* cl_device_mem_cache_type */
293 | #define CL_NONE 0x0
294 | #define CL_READ_ONLY_CACHE 0x1
295 | #define CL_READ_WRITE_CACHE 0x2
296 |
297 | /* cl_device_local_mem_type */
298 | #define CL_LOCAL 0x1
299 | #define CL_GLOBAL 0x2
300 |
301 | /* cl_device_exec_capabilities - bitfield */
302 | #define CL_EXEC_KERNEL (1 << 0)
303 | #define CL_EXEC_NATIVE_KERNEL (1 << 1)
304 |
305 | /* cl_command_queue_properties - bitfield */
306 | #define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
307 | #define CL_QUEUE_PROFILING_ENABLE (1 << 1)
308 |
309 | /* cl_context_info */
310 | #define CL_CONTEXT_REFERENCE_COUNT 0x1080
311 | #define CL_CONTEXT_DEVICES 0x1081
312 | #define CL_CONTEXT_PROPERTIES 0x1082
313 | #define CL_CONTEXT_NUM_DEVICES 0x1083
314 |
315 | /* cl_context_properties */
316 | #define CL_CONTEXT_PLATFORM 0x1084
317 | #define CL_CONTEXT_INTEROP_USER_SYNC 0x1085
318 |
319 | /* cl_device_partition_property */
320 | #define CL_DEVICE_PARTITION_EQUALLY 0x1086
321 | #define CL_DEVICE_PARTITION_BY_COUNTS 0x1087
322 | #define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0
323 | #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088
324 |
325 | /* cl_device_affinity_domain */
326 | #define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0)
327 | #define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1)
328 | #define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2)
329 | #define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3)
330 | #define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4)
331 | #define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5)
332 |
333 | /* cl_command_queue_info */
334 | #define CL_QUEUE_CONTEXT 0x1090
335 | #define CL_QUEUE_DEVICE 0x1091
336 | #define CL_QUEUE_REFERENCE_COUNT 0x1092
337 | #define CL_QUEUE_PROPERTIES 0x1093
338 |
339 | /* cl_mem_flags - bitfield */
340 | #define CL_MEM_READ_WRITE (1 << 0)
341 | #define CL_MEM_WRITE_ONLY (1 << 1)
342 | #define CL_MEM_READ_ONLY (1 << 2)
343 | #define CL_MEM_USE_HOST_PTR (1 << 3)
344 | #define CL_MEM_ALLOC_HOST_PTR (1 << 4)
345 | #define CL_MEM_COPY_HOST_PTR (1 << 5)
346 | // reserved (1 << 6)
347 | #define CL_MEM_HOST_WRITE_ONLY (1 << 7)
348 | #define CL_MEM_HOST_READ_ONLY (1 << 8)
349 | #define CL_MEM_HOST_NO_ACCESS (1 << 9)
350 |
351 | /* cl_mem_migration_flags - bitfield */
352 | #define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0)
353 | #define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1)
354 |
355 | /* cl_channel_order */
356 | #define CL_R 0x10B0
357 | #define CL_A 0x10B1
358 | #define CL_RG 0x10B2
359 | #define CL_RA 0x10B3
360 | #define CL_RGB 0x10B4
361 | #define CL_RGBA 0x10B5
362 | #define CL_BGRA 0x10B6
363 | #define CL_ARGB 0x10B7
364 | #define CL_INTENSITY 0x10B8
365 | #define CL_LUMINANCE 0x10B9
366 | #define CL_Rx 0x10BA
367 | #define CL_RGx 0x10BB
368 | #define CL_RGBx 0x10BC
369 |
370 | /* cl_channel_type */
371 | #define CL_SNORM_INT8 0x10D0
372 | #define CL_SNORM_INT16 0x10D1
373 | #define CL_UNORM_INT8 0x10D2
374 | #define CL_UNORM_INT16 0x10D3
375 | #define CL_UNORM_SHORT_565 0x10D4
376 | #define CL_UNORM_SHORT_555 0x10D5
377 | #define CL_UNORM_INT_101010 0x10D6
378 | #define CL_SIGNED_INT8 0x10D7
379 | #define CL_SIGNED_INT16 0x10D8
380 | #define CL_SIGNED_INT32 0x10D9
381 | #define CL_UNSIGNED_INT8 0x10DA
382 | #define CL_UNSIGNED_INT16 0x10DB
383 | #define CL_UNSIGNED_INT32 0x10DC
384 | #define CL_HALF_FLOAT 0x10DD
385 | #define CL_FLOAT 0x10DE
386 |
387 | /* cl_mem_object_type */
388 | #define CL_MEM_OBJECT_BUFFER 0x10F0
389 | #define CL_MEM_OBJECT_IMAGE2D 0x10F1
390 | #define CL_MEM_OBJECT_IMAGE3D 0x10F2
391 | #define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
392 | #define CL_MEM_OBJECT_IMAGE1D 0x10F4
393 | #define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
394 | #define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
395 |
396 | /* cl_mem_info */
397 | #define CL_MEM_TYPE 0x1100
398 | #define CL_MEM_FLAGS 0x1101
399 | #define CL_MEM_SIZE 0x1102
400 | #define CL_MEM_HOST_PTR 0x1103
401 | #define CL_MEM_MAP_COUNT 0x1104
402 | #define CL_MEM_REFERENCE_COUNT 0x1105
403 | #define CL_MEM_CONTEXT 0x1106
404 | #define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107
405 | #define CL_MEM_OFFSET 0x1108
406 |
407 | /* cl_image_info */
408 | #define CL_IMAGE_FORMAT 0x1110
409 | #define CL_IMAGE_ELEMENT_SIZE 0x1111
410 | #define CL_IMAGE_ROW_PITCH 0x1112
411 | #define CL_IMAGE_SLICE_PITCH 0x1113
412 | #define CL_IMAGE_WIDTH 0x1114
413 | #define CL_IMAGE_HEIGHT 0x1115
414 | #define CL_IMAGE_DEPTH 0x1116
415 | #define CL_IMAGE_ARRAY_SIZE 0x1117
416 | #define CL_IMAGE_BUFFER 0x1118
417 | #define CL_IMAGE_NUM_MIP_LEVELS 0x1119
418 | #define CL_IMAGE_NUM_SAMPLES 0x111A
419 |
420 | /* cl_addressing_mode */
421 | #define CL_ADDRESS_NONE 0x1130
422 | #define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
423 | #define CL_ADDRESS_CLAMP 0x1132
424 | #define CL_ADDRESS_REPEAT 0x1133
425 | #define CL_ADDRESS_MIRRORED_REPEAT 0x1134
426 |
427 | /* cl_filter_mode */
428 | #define CL_FILTER_NEAREST 0x1140
429 | #define CL_FILTER_LINEAR 0x1141
430 |
431 | /* cl_sampler_info */
432 | #define CL_SAMPLER_REFERENCE_COUNT 0x1150
433 | #define CL_SAMPLER_CONTEXT 0x1151
434 | #define CL_SAMPLER_NORMALIZED_COORDS 0x1152
435 | #define CL_SAMPLER_ADDRESSING_MODE 0x1153
436 | #define CL_SAMPLER_FILTER_MODE 0x1154
437 |
438 | /* cl_map_flags - bitfield */
439 | #define CL_MAP_READ (1 << 0)
440 | #define CL_MAP_WRITE (1 << 1)
441 | #define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2)
442 |
443 | /* cl_program_info */
444 | #define CL_PROGRAM_REFERENCE_COUNT 0x1160
445 | #define CL_PROGRAM_CONTEXT 0x1161
446 | #define CL_PROGRAM_NUM_DEVICES 0x1162
447 | #define CL_PROGRAM_DEVICES 0x1163
448 | #define CL_PROGRAM_SOURCE 0x1164
449 | #define CL_PROGRAM_BINARY_SIZES 0x1165
450 | #define CL_PROGRAM_BINARIES 0x1166
451 | #define CL_PROGRAM_NUM_KERNELS 0x1167
452 | #define CL_PROGRAM_KERNEL_NAMES 0x1168
453 |
454 | /* cl_program_build_info */
455 | #define CL_PROGRAM_BUILD_STATUS 0x1181
456 | #define CL_PROGRAM_BUILD_OPTIONS 0x1182
457 | #define CL_PROGRAM_BUILD_LOG 0x1183
458 | #define CL_PROGRAM_BINARY_TYPE 0x1184
459 |
460 | /* cl_program_binary_type */
461 | #define CL_PROGRAM_BINARY_TYPE_NONE 0x0
462 | #define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1
463 | #define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2
464 | #define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4
465 |
466 | /* cl_build_status */
467 | #define CL_BUILD_SUCCESS 0
468 | #define CL_BUILD_NONE -1
469 | #define CL_BUILD_ERROR -2
470 | #define CL_BUILD_IN_PROGRESS -3
471 |
472 | /* cl_kernel_info */
473 | #define CL_KERNEL_FUNCTION_NAME 0x1190
474 | #define CL_KERNEL_NUM_ARGS 0x1191
475 | #define CL_KERNEL_REFERENCE_COUNT 0x1192
476 | #define CL_KERNEL_CONTEXT 0x1193
477 | #define CL_KERNEL_PROGRAM 0x1194
478 | #define CL_KERNEL_ATTRIBUTES 0x1195
479 |
480 | /* cl_kernel_arg_info */
481 | #define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196
482 | #define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197
483 | #define CL_KERNEL_ARG_TYPE_NAME 0x1198
484 | #define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199
485 | #define CL_KERNEL_ARG_NAME 0x119A
486 |
487 | /* cl_kernel_arg_address_qualifier */
488 | #define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B
489 | #define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C
490 | #define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D
491 | #define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E
492 |
493 | /* cl_kernel_arg_access_qualifier */
494 | #define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0
495 | #define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1
496 | #define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2
497 | #define CL_KERNEL_ARG_ACCESS_NONE 0x11A3
498 |
499 | /* cl_kernel_arg_type_qualifer */
500 | #define CL_KERNEL_ARG_TYPE_NONE 0
501 | #define CL_KERNEL_ARG_TYPE_CONST (1 << 0)
502 | #define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1)
503 | #define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2)
504 |
505 | /* cl_kernel_work_group_info */
506 | #define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
507 | #define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
508 | #define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
509 | #define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3
510 | #define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4
511 | #define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5
512 |
513 | /* cl_event_info */
514 | #define CL_EVENT_COMMAND_QUEUE 0x11D0
515 | #define CL_EVENT_COMMAND_TYPE 0x11D1
516 | #define CL_EVENT_REFERENCE_COUNT 0x11D2
517 | #define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
518 | #define CL_EVENT_CONTEXT 0x11D4
519 |
520 | /* cl_command_type */
521 | #define CL_COMMAND_NDRANGE_KERNEL 0x11F0
522 | #define CL_COMMAND_TASK 0x11F1
523 | #define CL_COMMAND_NATIVE_KERNEL 0x11F2
524 | #define CL_COMMAND_READ_BUFFER 0x11F3
525 | #define CL_COMMAND_WRITE_BUFFER 0x11F4
526 | #define CL_COMMAND_COPY_BUFFER 0x11F5
527 | #define CL_COMMAND_READ_IMAGE 0x11F6
528 | #define CL_COMMAND_WRITE_IMAGE 0x11F7
529 | #define CL_COMMAND_COPY_IMAGE 0x11F8
530 | #define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
531 | #define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
532 | #define CL_COMMAND_MAP_BUFFER 0x11FB
533 | #define CL_COMMAND_MAP_IMAGE 0x11FC
534 | #define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
535 | #define CL_COMMAND_MARKER 0x11FE
536 | #define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
537 | #define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
538 | #define CL_COMMAND_READ_BUFFER_RECT 0x1201
539 | #define CL_COMMAND_WRITE_BUFFER_RECT 0x1202
540 | #define CL_COMMAND_COPY_BUFFER_RECT 0x1203
541 | #define CL_COMMAND_USER 0x1204
542 | #define CL_COMMAND_BARRIER 0x1205
543 | #define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206
544 | #define CL_COMMAND_FILL_BUFFER 0x1207
545 | #define CL_COMMAND_FILL_IMAGE 0x1208
546 |
547 | /* command execution status */
548 | #define CL_COMPLETE 0x0
549 | #define CL_RUNNING 0x1
550 | #define CL_SUBMITTED 0x2
551 | #define CL_QUEUED 0x3
552 |
553 | /* cl_buffer_create_type */
554 | #define CL_BUFFER_CREATE_TYPE_REGION 0x1220
555 |
556 | /* cl_profiling_info */
557 | #define CL_PROFILING_COMMAND_QUEUED 0x1280
558 | #define CL_PROFILING_COMMAND_SUBMIT 0x1281
559 | #define CL_PROFILING_COMMAND_START 0x1282
560 | #define CL_PROFILING_COMMAND_END 0x1283
561 |
562 | /********************************************************************************************************/
563 |
564 | /* Platform API */
565 | extern CL_API_ENTRY cl_int CL_API_CALL
566 | clGetPlatformIDs(cl_uint /* num_entries */,
567 | cl_platform_id * /* platforms */,
568 | cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0;
569 |
570 | extern CL_API_ENTRY cl_int CL_API_CALL
571 | clGetPlatformInfo(cl_platform_id /* platform */,
572 | cl_platform_info /* param_name */,
573 | size_t /* param_value_size */,
574 | void * /* param_value */,
575 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
576 |
577 | /* Device APIs */
578 | extern CL_API_ENTRY cl_int CL_API_CALL
579 | clGetDeviceIDs(cl_platform_id /* platform */,
580 | cl_device_type /* device_type */,
581 | cl_uint /* num_entries */,
582 | cl_device_id * /* devices */,
583 | cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
584 |
585 | extern CL_API_ENTRY cl_int CL_API_CALL
586 | clGetDeviceInfo(cl_device_id /* device */,
587 | cl_device_info /* param_name */,
588 | size_t /* param_value_size */,
589 | void * /* param_value */,
590 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
591 |
592 | extern CL_API_ENTRY cl_int CL_API_CALL
593 | clCreateSubDevices(cl_device_id /* in_device */,
594 | const cl_device_partition_property * /* properties */,
595 | cl_uint /* num_devices */,
596 | cl_device_id * /* out_devices */,
597 | cl_uint * /* num_devices_ret */) CL_API_SUFFIX__VERSION_1_2;
598 |
599 | extern CL_API_ENTRY cl_int CL_API_CALL
600 | clRetainDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2;
601 |
602 | extern CL_API_ENTRY cl_int CL_API_CALL
603 | clReleaseDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2;
604 |
605 | /* Context APIs */
606 | extern CL_API_ENTRY cl_context CL_API_CALL
607 | clCreateContext(const cl_context_properties * /* properties */,
608 | cl_uint /* num_devices */,
609 | const cl_device_id * /* devices */,
610 | void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *),
611 | void * /* user_data */,
612 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
613 |
614 | extern CL_API_ENTRY cl_context CL_API_CALL
615 | clCreateContextFromType(const cl_context_properties * /* properties */,
616 | cl_device_type /* device_type */,
617 | void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *),
618 | void * /* user_data */,
619 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
620 |
621 | extern CL_API_ENTRY cl_int CL_API_CALL
622 | clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
623 |
624 | extern CL_API_ENTRY cl_int CL_API_CALL
625 | clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
626 |
627 | extern CL_API_ENTRY cl_int CL_API_CALL
628 | clGetContextInfo(cl_context /* context */,
629 | cl_context_info /* param_name */,
630 | size_t /* param_value_size */,
631 | void * /* param_value */,
632 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
633 |
634 | /* Command Queue APIs */
635 | extern CL_API_ENTRY cl_command_queue CL_API_CALL
636 | clCreateCommandQueue(cl_context /* context */,
637 | cl_device_id /* device */,
638 | cl_command_queue_properties /* properties */,
639 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
640 |
641 | extern CL_API_ENTRY cl_int CL_API_CALL
642 | clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
643 |
644 | extern CL_API_ENTRY cl_int CL_API_CALL
645 | clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
646 |
647 | extern CL_API_ENTRY cl_int CL_API_CALL
648 | clGetCommandQueueInfo(cl_command_queue /* command_queue */,
649 | cl_command_queue_info /* param_name */,
650 | size_t /* param_value_size */,
651 | void * /* param_value */,
652 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
653 |
654 | /* Memory Object APIs */
655 | extern CL_API_ENTRY cl_mem CL_API_CALL
656 | clCreateBuffer(cl_context /* context */,
657 | cl_mem_flags /* flags */,
658 | size_t /* size */,
659 | void * /* host_ptr */,
660 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
661 |
662 | extern CL_API_ENTRY cl_mem CL_API_CALL
663 | clCreateSubBuffer(cl_mem /* buffer */,
664 | cl_mem_flags /* flags */,
665 | cl_buffer_create_type /* buffer_create_type */,
666 | const void * /* buffer_create_info */,
667 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
668 |
669 | extern CL_API_ENTRY cl_mem CL_API_CALL
670 | clCreateImage(cl_context /* context */,
671 | cl_mem_flags /* flags */,
672 | const cl_image_format * /* image_format */,
673 | const cl_image_desc * /* image_desc */,
674 | void * /* host_ptr */,
675 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
676 |
677 | extern CL_API_ENTRY cl_int CL_API_CALL
678 | clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
679 |
680 | extern CL_API_ENTRY cl_int CL_API_CALL
681 | clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
682 |
683 | extern CL_API_ENTRY cl_int CL_API_CALL
684 | clGetSupportedImageFormats(cl_context /* context */,
685 | cl_mem_flags /* flags */,
686 | cl_mem_object_type /* image_type */,
687 | cl_uint /* num_entries */,
688 | cl_image_format * /* image_formats */,
689 | cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0;
690 |
691 | extern CL_API_ENTRY cl_int CL_API_CALL
692 | clGetMemObjectInfo(cl_mem /* memobj */,
693 | cl_mem_info /* param_name */,
694 | size_t /* param_value_size */,
695 | void * /* param_value */,
696 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
697 |
698 | extern CL_API_ENTRY cl_int CL_API_CALL
699 | clGetImageInfo(cl_mem /* image */,
700 | cl_image_info /* param_name */,
701 | size_t /* param_value_size */,
702 | void * /* param_value */,
703 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
704 |
705 | extern CL_API_ENTRY cl_int CL_API_CALL
706 | clSetMemObjectDestructorCallback( cl_mem /* memobj */,
707 | void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
708 | void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1;
709 |
710 | /* Sampler APIs */
711 | extern CL_API_ENTRY cl_sampler CL_API_CALL
712 | clCreateSampler(cl_context /* context */,
713 | cl_bool /* normalized_coords */,
714 | cl_addressing_mode /* addressing_mode */,
715 | cl_filter_mode /* filter_mode */,
716 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
717 |
718 | extern CL_API_ENTRY cl_int CL_API_CALL
719 | clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
720 |
721 | extern CL_API_ENTRY cl_int CL_API_CALL
722 | clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
723 |
724 | extern CL_API_ENTRY cl_int CL_API_CALL
725 | clGetSamplerInfo(cl_sampler /* sampler */,
726 | cl_sampler_info /* param_name */,
727 | size_t /* param_value_size */,
728 | void * /* param_value */,
729 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
730 |
731 | /* Program Object APIs */
732 | extern CL_API_ENTRY cl_program CL_API_CALL
733 | clCreateProgramWithSource(cl_context /* context */,
734 | cl_uint /* count */,
735 | const char ** /* strings */,
736 | const size_t * /* lengths */,
737 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
738 |
739 | extern CL_API_ENTRY cl_program CL_API_CALL
740 | clCreateProgramWithBinary(cl_context /* context */,
741 | cl_uint /* num_devices */,
742 | const cl_device_id * /* device_list */,
743 | const size_t * /* lengths */,
744 | const unsigned char ** /* binaries */,
745 | cl_int * /* binary_status */,
746 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
747 |
748 | extern CL_API_ENTRY cl_program CL_API_CALL
749 | clCreateProgramWithBuiltInKernels(cl_context /* context */,
750 | cl_uint /* num_devices */,
751 | const cl_device_id * /* device_list */,
752 | const char * /* kernel_names */,
753 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
754 |
755 | extern CL_API_ENTRY cl_int CL_API_CALL
756 | clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
757 |
758 | extern CL_API_ENTRY cl_int CL_API_CALL
759 | clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
760 |
761 | extern CL_API_ENTRY cl_int CL_API_CALL
762 | clBuildProgram(cl_program /* program */,
763 | cl_uint /* num_devices */,
764 | const cl_device_id * /* device_list */,
765 | const char * /* options */,
766 | void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
767 | void * /* user_data */) CL_API_SUFFIX__VERSION_1_0;
768 |
769 | extern CL_API_ENTRY cl_int CL_API_CALL
770 | clCompileProgram(cl_program /* program */,
771 | cl_uint /* num_devices */,
772 | const cl_device_id * /* device_list */,
773 | const char * /* options */,
774 | cl_uint /* num_input_headers */,
775 | const cl_program * /* input_headers */,
776 | const char ** /* header_include_names */,
777 | void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
778 | void * /* user_data */) CL_API_SUFFIX__VERSION_1_2;
779 |
780 | extern CL_API_ENTRY cl_program CL_API_CALL
781 | clLinkProgram(cl_context /* context */,
782 | cl_uint /* num_devices */,
783 | const cl_device_id * /* device_list */,
784 | const char * /* options */,
785 | cl_uint /* num_input_programs */,
786 | const cl_program * /* input_programs */,
787 | void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
788 | void * /* user_data */,
789 | cl_int * /* errcode_ret */ ) CL_API_SUFFIX__VERSION_1_2;
790 |
791 |
792 | extern CL_API_ENTRY cl_int CL_API_CALL
793 | clUnloadPlatformCompiler(cl_platform_id /* platform */) CL_API_SUFFIX__VERSION_1_2;
794 |
795 | extern CL_API_ENTRY cl_int CL_API_CALL
796 | clGetProgramInfo(cl_program /* program */,
797 | cl_program_info /* param_name */,
798 | size_t /* param_value_size */,
799 | void * /* param_value */,
800 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
801 |
802 | extern CL_API_ENTRY cl_int CL_API_CALL
803 | clGetProgramBuildInfo(cl_program /* program */,
804 | cl_device_id /* device */,
805 | cl_program_build_info /* param_name */,
806 | size_t /* param_value_size */,
807 | void * /* param_value */,
808 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
809 |
810 | /* Kernel Object APIs */
811 | extern CL_API_ENTRY cl_kernel CL_API_CALL
812 | clCreateKernel(cl_program /* program */,
813 | const char * /* kernel_name */,
814 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
815 |
816 | extern CL_API_ENTRY cl_int CL_API_CALL
817 | clCreateKernelsInProgram(cl_program /* program */,
818 | cl_uint /* num_kernels */,
819 | cl_kernel * /* kernels */,
820 | cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0;
821 |
822 | extern CL_API_ENTRY cl_int CL_API_CALL
823 | clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
824 |
825 | extern CL_API_ENTRY cl_int CL_API_CALL
826 | clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
827 |
828 | extern CL_API_ENTRY cl_int CL_API_CALL
829 | clSetKernelArg(cl_kernel /* kernel */,
830 | cl_uint /* arg_index */,
831 | size_t /* arg_size */,
832 | const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0;
833 |
834 | extern CL_API_ENTRY cl_int CL_API_CALL
835 | clGetKernelInfo(cl_kernel /* kernel */,
836 | cl_kernel_info /* param_name */,
837 | size_t /* param_value_size */,
838 | void * /* param_value */,
839 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
840 |
841 | extern CL_API_ENTRY cl_int CL_API_CALL
842 | clGetKernelArgInfo(cl_kernel /* kernel */,
843 | cl_uint /* arg_indx */,
844 | cl_kernel_arg_info /* param_name */,
845 | size_t /* param_value_size */,
846 | void * /* param_value */,
847 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_2;
848 |
849 | extern CL_API_ENTRY cl_int CL_API_CALL
850 | clGetKernelWorkGroupInfo(cl_kernel /* kernel */,
851 | cl_device_id /* device */,
852 | cl_kernel_work_group_info /* param_name */,
853 | size_t /* param_value_size */,
854 | void * /* param_value */,
855 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
856 |
857 | /* Event Object APIs */
858 | extern CL_API_ENTRY cl_int CL_API_CALL
859 | clWaitForEvents(cl_uint /* num_events */,
860 | const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
861 |
862 | extern CL_API_ENTRY cl_int CL_API_CALL
863 | clGetEventInfo(cl_event /* event */,
864 | cl_event_info /* param_name */,
865 | size_t /* param_value_size */,
866 | void * /* param_value */,
867 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
868 |
869 | extern CL_API_ENTRY cl_event CL_API_CALL
870 | clCreateUserEvent(cl_context /* context */,
871 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
872 |
873 | extern CL_API_ENTRY cl_int CL_API_CALL
874 | clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
875 |
876 | extern CL_API_ENTRY cl_int CL_API_CALL
877 | clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
878 |
879 | extern CL_API_ENTRY cl_int CL_API_CALL
880 | clSetUserEventStatus(cl_event /* event */,
881 | cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1;
882 |
883 | extern CL_API_ENTRY cl_int CL_API_CALL
884 | clSetEventCallback( cl_event /* event */,
885 | cl_int /* command_exec_callback_type */,
886 | void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *),
887 | void * /* user_data */) CL_API_SUFFIX__VERSION_1_1;
888 |
889 | /* Profiling APIs */
890 | extern CL_API_ENTRY cl_int CL_API_CALL
891 | clGetEventProfilingInfo(cl_event /* event */,
892 | cl_profiling_info /* param_name */,
893 | size_t /* param_value_size */,
894 | void * /* param_value */,
895 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
896 |
897 | /* Flush and Finish APIs */
898 | extern CL_API_ENTRY cl_int CL_API_CALL
899 | clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
900 |
901 | extern CL_API_ENTRY cl_int CL_API_CALL
902 | clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
903 |
904 | /* Enqueued Commands APIs */
905 | extern CL_API_ENTRY cl_int CL_API_CALL
906 | clEnqueueReadBuffer(cl_command_queue /* command_queue */,
907 | cl_mem /* buffer */,
908 | cl_bool /* blocking_read */,
909 | size_t /* offset */,
910 | size_t /* size */,
911 | void * /* ptr */,
912 | cl_uint /* num_events_in_wait_list */,
913 | const cl_event * /* event_wait_list */,
914 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
915 |
916 | extern CL_API_ENTRY cl_int CL_API_CALL
917 | clEnqueueReadBufferRect(cl_command_queue /* command_queue */,
918 | cl_mem /* buffer */,
919 | cl_bool /* blocking_read */,
920 | const size_t * /* buffer_offset */,
921 | const size_t * /* host_offset */,
922 | const size_t * /* region */,
923 | size_t /* buffer_row_pitch */,
924 | size_t /* buffer_slice_pitch */,
925 | size_t /* host_row_pitch */,
926 | size_t /* host_slice_pitch */,
927 | void * /* ptr */,
928 | cl_uint /* num_events_in_wait_list */,
929 | const cl_event * /* event_wait_list */,
930 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
931 |
932 | extern CL_API_ENTRY cl_int CL_API_CALL
933 | clEnqueueWriteBuffer(cl_command_queue /* command_queue */,
934 | cl_mem /* buffer */,
935 | cl_bool /* blocking_write */,
936 | size_t /* offset */,
937 | size_t /* size */,
938 | const void * /* ptr */,
939 | cl_uint /* num_events_in_wait_list */,
940 | const cl_event * /* event_wait_list */,
941 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
942 |
943 | extern CL_API_ENTRY cl_int CL_API_CALL
944 | clEnqueueWriteBufferRect(cl_command_queue /* command_queue */,
945 | cl_mem /* buffer */,
946 | cl_bool /* blocking_write */,
947 | const size_t * /* buffer_offset */,
948 | const size_t * /* host_offset */,
949 | const size_t * /* region */,
950 | size_t /* buffer_row_pitch */,
951 | size_t /* buffer_slice_pitch */,
952 | size_t /* host_row_pitch */,
953 | size_t /* host_slice_pitch */,
954 | const void * /* ptr */,
955 | cl_uint /* num_events_in_wait_list */,
956 | const cl_event * /* event_wait_list */,
957 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
958 |
959 | extern CL_API_ENTRY cl_int CL_API_CALL
960 | clEnqueueFillBuffer(cl_command_queue /* command_queue */,
961 | cl_mem /* buffer */,
962 | const void * /* pattern */,
963 | size_t /* pattern_size */,
964 | size_t /* offset */,
965 | size_t /* size */,
966 | cl_uint /* num_events_in_wait_list */,
967 | const cl_event * /* event_wait_list */,
968 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
969 |
970 | extern CL_API_ENTRY cl_int CL_API_CALL
971 | clEnqueueCopyBuffer(cl_command_queue /* command_queue */,
972 | cl_mem /* src_buffer */,
973 | cl_mem /* dst_buffer */,
974 | size_t /* src_offset */,
975 | size_t /* dst_offset */,
976 | size_t /* size */,
977 | cl_uint /* num_events_in_wait_list */,
978 | const cl_event * /* event_wait_list */,
979 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
980 |
981 | extern CL_API_ENTRY cl_int CL_API_CALL
982 | clEnqueueCopyBufferRect(cl_command_queue /* command_queue */,
983 | cl_mem /* src_buffer */,
984 | cl_mem /* dst_buffer */,
985 | const size_t * /* src_origin */,
986 | const size_t * /* dst_origin */,
987 | const size_t * /* region */,
988 | size_t /* src_row_pitch */,
989 | size_t /* src_slice_pitch */,
990 | size_t /* dst_row_pitch */,
991 | size_t /* dst_slice_pitch */,
992 | cl_uint /* num_events_in_wait_list */,
993 | const cl_event * /* event_wait_list */,
994 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
995 |
996 | extern CL_API_ENTRY cl_int CL_API_CALL
997 | clEnqueueReadImage(cl_command_queue /* command_queue */,
998 | cl_mem /* image */,
999 | cl_bool /* blocking_read */,
1000 | const size_t * /* origin[3] */,
1001 | const size_t * /* region[3] */,
1002 | size_t /* row_pitch */,
1003 | size_t /* slice_pitch */,
1004 | void * /* ptr */,
1005 | cl_uint /* num_events_in_wait_list */,
1006 | const cl_event * /* event_wait_list */,
1007 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1008 |
1009 | extern CL_API_ENTRY cl_int CL_API_CALL
1010 | clEnqueueWriteImage(cl_command_queue /* command_queue */,
1011 | cl_mem /* image */,
1012 | cl_bool /* blocking_write */,
1013 | const size_t * /* origin[3] */,
1014 | const size_t * /* region[3] */,
1015 | size_t /* input_row_pitch */,
1016 | size_t /* input_slice_pitch */,
1017 | const void * /* ptr */,
1018 | cl_uint /* num_events_in_wait_list */,
1019 | const cl_event * /* event_wait_list */,
1020 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1021 |
1022 | extern CL_API_ENTRY cl_int CL_API_CALL
1023 | clEnqueueFillImage(cl_command_queue /* command_queue */,
1024 | cl_mem /* image */,
1025 | const void * /* fill_color */,
1026 | const size_t * /* origin[3] */,
1027 | const size_t * /* region[3] */,
1028 | cl_uint /* num_events_in_wait_list */,
1029 | const cl_event * /* event_wait_list */,
1030 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
1031 |
1032 | extern CL_API_ENTRY cl_int CL_API_CALL
1033 | clEnqueueCopyImage(cl_command_queue /* command_queue */,
1034 | cl_mem /* src_image */,
1035 | cl_mem /* dst_image */,
1036 | const size_t * /* src_origin[3] */,
1037 | const size_t * /* dst_origin[3] */,
1038 | const size_t * /* region[3] */,
1039 | cl_uint /* num_events_in_wait_list */,
1040 | const cl_event * /* event_wait_list */,
1041 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1042 |
1043 | extern CL_API_ENTRY cl_int CL_API_CALL
1044 | clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */,
1045 | cl_mem /* src_image */,
1046 | cl_mem /* dst_buffer */,
1047 | const size_t * /* src_origin[3] */,
1048 | const size_t * /* region[3] */,
1049 | size_t /* dst_offset */,
1050 | cl_uint /* num_events_in_wait_list */,
1051 | const cl_event * /* event_wait_list */,
1052 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1053 |
1054 | extern CL_API_ENTRY cl_int CL_API_CALL
1055 | clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */,
1056 | cl_mem /* src_buffer */,
1057 | cl_mem /* dst_image */,
1058 | size_t /* src_offset */,
1059 | const size_t * /* dst_origin[3] */,
1060 | const size_t * /* region[3] */,
1061 | cl_uint /* num_events_in_wait_list */,
1062 | const cl_event * /* event_wait_list */,
1063 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1064 |
1065 | extern CL_API_ENTRY void * CL_API_CALL
1066 | clEnqueueMapBuffer(cl_command_queue /* command_queue */,
1067 | cl_mem /* buffer */,
1068 | cl_bool /* blocking_map */,
1069 | cl_map_flags /* map_flags */,
1070 | size_t /* offset */,
1071 | size_t /* size */,
1072 | cl_uint /* num_events_in_wait_list */,
1073 | const cl_event * /* event_wait_list */,
1074 | cl_event * /* event */,
1075 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
1076 |
1077 | extern CL_API_ENTRY void * CL_API_CALL
1078 | clEnqueueMapImage(cl_command_queue /* command_queue */,
1079 | cl_mem /* image */,
1080 | cl_bool /* blocking_map */,
1081 | cl_map_flags /* map_flags */,
1082 | const size_t * /* origin[3] */,
1083 | const size_t * /* region[3] */,
1084 | size_t * /* image_row_pitch */,
1085 | size_t * /* image_slice_pitch */,
1086 | cl_uint /* num_events_in_wait_list */,
1087 | const cl_event * /* event_wait_list */,
1088 | cl_event * /* event */,
1089 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
1090 |
1091 | extern CL_API_ENTRY cl_int CL_API_CALL
1092 | clEnqueueUnmapMemObject(cl_command_queue /* command_queue */,
1093 | cl_mem /* memobj */,
1094 | void * /* mapped_ptr */,
1095 | cl_uint /* num_events_in_wait_list */,
1096 | const cl_event * /* event_wait_list */,
1097 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1098 |
1099 | extern CL_API_ENTRY cl_int CL_API_CALL
1100 | clEnqueueMigrateMemObjects(cl_command_queue /* command_queue */,
1101 | cl_uint /* num_mem_objects */,
1102 | const cl_mem * /* mem_objects */,
1103 | cl_mem_migration_flags /* flags */,
1104 | cl_uint /* num_events_in_wait_list */,
1105 | const cl_event * /* event_wait_list */,
1106 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
1107 |
1108 | extern CL_API_ENTRY cl_int CL_API_CALL
1109 | clEnqueueNDRangeKernel(cl_command_queue /* command_queue */,
1110 | cl_kernel /* kernel */,
1111 | cl_uint /* work_dim */,
1112 | const size_t * /* global_work_offset */,
1113 | const size_t * /* global_work_size */,
1114 | const size_t * /* local_work_size */,
1115 | cl_uint /* num_events_in_wait_list */,
1116 | const cl_event * /* event_wait_list */,
1117 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1118 |
1119 | extern CL_API_ENTRY cl_int CL_API_CALL
1120 | clEnqueueTask(cl_command_queue /* command_queue */,
1121 | cl_kernel /* kernel */,
1122 | cl_uint /* num_events_in_wait_list */,
1123 | const cl_event * /* event_wait_list */,
1124 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1125 |
1126 | extern CL_API_ENTRY cl_int CL_API_CALL
1127 | clEnqueueNativeKernel(cl_command_queue /* command_queue */,
1128 | void (CL_CALLBACK * /*user_func*/)(void *),
1129 | void * /* args */,
1130 | size_t /* cb_args */,
1131 | cl_uint /* num_mem_objects */,
1132 | const cl_mem * /* mem_list */,
1133 | const void ** /* args_mem_loc */,
1134 | cl_uint /* num_events_in_wait_list */,
1135 | const cl_event * /* event_wait_list */,
1136 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
1137 |
1138 | extern CL_API_ENTRY cl_int CL_API_CALL
1139 | clEnqueueMarkerWithWaitList(cl_command_queue /* command_queue */,
1140 | cl_uint /* num_events_in_wait_list */,
1141 | const cl_event * /* event_wait_list */,
1142 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
1143 |
1144 | extern CL_API_ENTRY cl_int CL_API_CALL
1145 | clEnqueueBarrierWithWaitList(cl_command_queue /* command_queue */,
1146 | cl_uint /* num_events_in_wait_list */,
1147 | const cl_event * /* event_wait_list */,
1148 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
1149 |
1150 | extern CL_API_ENTRY cl_int CL_API_CALL
1151 | clSetPrintfCallback(cl_context /* context */,
1152 | void (CL_CALLBACK * /* pfn_notify */)(cl_context /* program */,
1153 | cl_uint /*printf_data_len */,
1154 | char * /* printf_data_ptr */,
1155 | void * /* user_data */),
1156 | void * /* user_data */) CL_API_SUFFIX__VERSION_1_2;
1157 |
1158 |
1159 |
1160 | /* Extension function access
1161 | *
1162 | * Returns the extension function address for the given function name,
1163 | * or NULL if a valid function can not be found. The client must
1164 | * check to make sure the address is not NULL, before using or
1165 | * calling the returned function address.
1166 | */
1167 | extern CL_API_ENTRY void * CL_API_CALL
1168 | clGetExtensionFunctionAddressForPlatform(cl_platform_id /* platform */,
1169 | const char * /* func_name */) CL_API_SUFFIX__VERSION_1_2;
1170 |
1171 |
1172 | #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
1173 | #warning CL_USE_DEPRECATED_OPENCL_1_0_APIS is defined. These APIs are unsupported and untested in OpenCL 1.1!
1174 | /*
1175 | * WARNING:
1176 | * This API introduces mutable state into the OpenCL implementation. It has been REMOVED
1177 | * to better facilitate thread safety. The 1.0 API is not thread safe. It is not tested by the
1178 | * OpenCL 1.1 conformance test, and consequently may not work or may not work dependably.
1179 | * It is likely to be non-performant. Use of this API is not advised. Use at your own risk.
1180 | *
1181 | * Software developers previously relying on this API are instructed to set the command queue
1182 | * properties when creating the queue, instead.
1183 | */
1184 | extern CL_API_ENTRY cl_int CL_API_CALL
1185 | clSetCommandQueueProperty(cl_command_queue /* command_queue */,
1186 | cl_command_queue_properties /* properties */,
1187 | cl_bool /* enable */,
1188 | cl_command_queue_properties * /* old_properties */) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED;
1189 | #endif /* CL_USE_DEPRECATED_OPENCL_1_0_APIS */
1190 |
1191 |
1192 | #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
1193 | extern CL_API_ENTRY cl_mem CL_API_CALL
1194 | clCreateImage2D(cl_context /* context */,
1195 | cl_mem_flags /* flags */,
1196 | const cl_image_format * /* image_format */,
1197 | size_t /* image_width */,
1198 | size_t /* image_height */,
1199 | size_t /* image_row_pitch */,
1200 | void * /* host_ptr */,
1201 | cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1202 |
1203 | extern CL_API_ENTRY cl_mem CL_API_CALL
1204 | clCreateImage3D(cl_context /* context */,
1205 | cl_mem_flags /* flags */,
1206 | const cl_image_format * /* image_format */,
1207 | size_t /* image_width */,
1208 | size_t /* image_height */,
1209 | size_t /* image_depth */,
1210 | size_t /* image_row_pitch */,
1211 | size_t /* image_slice_pitch */,
1212 | void * /* host_ptr */,
1213 | cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1214 |
1215 | extern CL_API_ENTRY cl_int CL_API_CALL
1216 | clEnqueueMarker(cl_command_queue /* command_queue */,
1217 | cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1218 |
1219 | extern CL_API_ENTRY cl_int CL_API_CALL
1220 | clEnqueueWaitForEvents(cl_command_queue /* command_queue */,
1221 | cl_uint /* num_events */,
1222 | const cl_event * /* event_list */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1223 |
1224 | extern CL_API_ENTRY cl_int CL_API_CALL
1225 | clEnqueueBarrier(cl_command_queue /* command_queue */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1226 |
1227 | extern CL_API_ENTRY cl_int CL_API_CALL
1228 | clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1229 |
1230 | extern CL_API_ENTRY void * CL_API_CALL
1231 | clGetExtensionFunctionAddress(const char * /* func_name */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1232 | #endif /* CL_USE_DEPRECATED_OPENCL_1_2_APIS */
1233 |
1234 | #ifdef __cplusplus
1235 | }
1236 | #endif
1237 |
1238 | #endif /* __OPENCL_CL_H */
1239 |
1240 |
--------------------------------------------------------------------------------
/jni/include/CL/cl_ext.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2008-2010 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | ******************************************************************************/
23 |
24 |
25 | /* cl_ext.h contains OpenCL extensions which don't have external */
26 | /* (OpenGL, D3D) dependencies. */
27 |
28 | #ifndef __CL_EXT_H
29 | #define __CL_EXT_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | #ifdef __APPLE__
36 | #include
37 | #include
38 | #else
39 | #include
40 | #endif
41 |
42 | /* cl_khr_fp64 extension - no extension #define since it has no functions */
43 | #define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
44 |
45 | /* cl_khr_fp16 extension - no extension #define since it has no functions */
46 | #define CL_DEVICE_HALF_FP_CONFIG 0x1033
47 |
48 | /* Memory object destruction
49 | *
50 | * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
51 | *
52 | * Registers a user callback function that will be called when the memory object is deleted and its resources
53 | * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
54 | * stack associated with memobj. The registered user callback functions are called in the reverse order in
55 | * which they were registered. The user callback functions are called and then the memory object is deleted
56 | * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
57 | * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
58 | * the storage bits for the memory object, can be reused or freed.
59 | *
60 | * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
61 | *
62 | * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
63 | * before using.
64 | */
65 | #define cl_APPLE_SetMemObjectDestructor 1
66 | cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
67 | void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
68 | void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
69 |
70 |
71 | /* Context Logging Functions
72 | *
73 | * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
74 | * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
75 | * before using.
76 | *
77 | * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
78 | */
79 | #define cl_APPLE_ContextLoggingFunctions 1
80 | extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
81 | const void * /* private_info */,
82 | size_t /* cb */,
83 | void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
84 |
85 | /* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
86 | extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
87 | const void * /* private_info */,
88 | size_t /* cb */,
89 | void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
90 |
91 | /* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
92 | extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
93 | const void * /* private_info */,
94 | size_t /* cb */,
95 | void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
96 |
97 |
98 | /************************
99 | * cl_khr_icd extension *
100 | ************************/
101 | #define cl_khr_icd 1
102 |
103 | /* cl_platform_info */
104 | #define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
105 |
106 | /* Additional Error Codes */
107 | #define CL_PLATFORM_NOT_FOUND_KHR -1001
108 |
109 | extern CL_API_ENTRY cl_int CL_API_CALL
110 | clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
111 | cl_platform_id * /* platforms */,
112 | cl_uint * /* num_platforms */);
113 |
114 | typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
115 | cl_uint /* num_entries */,
116 | cl_platform_id * /* platforms */,
117 | cl_uint * /* num_platforms */);
118 |
119 |
120 | /******************************************
121 | * cl_nv_device_attribute_query extension *
122 | ******************************************/
123 | /* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
124 | #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
125 | #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
126 | #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
127 | #define CL_DEVICE_WARP_SIZE_NV 0x4003
128 | #define CL_DEVICE_GPU_OVERLAP_NV 0x4004
129 | #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
130 | #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
131 |
132 |
133 | /*********************************
134 | * cl_amd_device_attribute_query *
135 | *********************************/
136 | #define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
137 |
138 |
139 | #ifdef CL_VERSION_1_1
140 | /***********************************
141 | * cl_ext_device_fission extension *
142 | ***********************************/
143 | #define cl_ext_device_fission 1
144 |
145 | extern CL_API_ENTRY cl_int CL_API_CALL
146 | clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
147 |
148 | typedef CL_API_ENTRY cl_int
149 | (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
150 |
151 | extern CL_API_ENTRY cl_int CL_API_CALL
152 | clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
153 |
154 | typedef CL_API_ENTRY cl_int
155 | (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
156 |
157 | typedef cl_ulong cl_device_partition_property_ext;
158 | extern CL_API_ENTRY cl_int CL_API_CALL
159 | clCreateSubDevicesEXT( cl_device_id /*in_device*/,
160 | const cl_device_partition_property_ext * /* properties */,
161 | cl_uint /*num_entries*/,
162 | cl_device_id * /*out_devices*/,
163 | cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
164 |
165 | typedef CL_API_ENTRY cl_int
166 | ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
167 | const cl_device_partition_property_ext * /* properties */,
168 | cl_uint /*num_entries*/,
169 | cl_device_id * /*out_devices*/,
170 | cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
171 |
172 | /* cl_device_partition_property_ext */
173 | #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
174 | #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
175 | #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
176 | #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
177 |
178 | /* clDeviceGetInfo selectors */
179 | #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
180 | #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
181 | #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
182 | #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
183 | #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
184 |
185 | /* error codes */
186 | #define CL_DEVICE_PARTITION_FAILED_EXT -1057
187 | #define CL_INVALID_PARTITION_COUNT_EXT -1058
188 | #define CL_INVALID_PARTITION_NAME_EXT -1059
189 |
190 | /* CL_AFFINITY_DOMAINs */
191 | #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
192 | #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
193 | #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
194 | #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
195 | #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
196 | #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
197 |
198 | /* cl_device_partition_property_ext list terminators */
199 | #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
200 | #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
201 | #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
202 |
203 |
204 |
205 | #endif /* CL_VERSION_1_1 */
206 |
207 | #ifdef __cplusplus
208 | }
209 | #endif
210 |
211 |
212 | #endif /* __CL_EXT_H */
213 |
--------------------------------------------------------------------------------
/jni/include/CL/cl_gl.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************************
2 | * Copyright (c) 2011 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | **********************************************************************************/
23 |
24 | #ifndef __OPENCL_CL_GL_H
25 | #define __OPENCL_CL_GL_H
26 |
27 | #ifdef __APPLE__
28 | #include
29 | #else
30 | #include
31 | #endif
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | typedef cl_uint cl_gl_object_type;
38 | typedef cl_uint cl_gl_texture_info;
39 | typedef cl_uint cl_gl_platform_info;
40 | typedef struct __GLsync *cl_GLsync;
41 |
42 | /* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */
43 | #define CL_GL_OBJECT_BUFFER 0x2000
44 | #define CL_GL_OBJECT_TEXTURE2D 0x2001
45 | #define CL_GL_OBJECT_TEXTURE3D 0x2002
46 | #define CL_GL_OBJECT_RENDERBUFFER 0x2003
47 | #define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E
48 | #define CL_GL_OBJECT_TEXTURE1D 0x200F
49 | #define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010
50 | #define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011
51 |
52 | /* cl_gl_texture_info */
53 | #define CL_GL_TEXTURE_TARGET 0x2004
54 | #define CL_GL_MIPMAP_LEVEL 0x2005
55 |
56 |
57 | extern CL_API_ENTRY cl_mem CL_API_CALL
58 | clCreateFromGLBuffer(cl_context /* context */,
59 | cl_mem_flags /* flags */,
60 | cl_GLuint /* bufobj */,
61 | int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
62 |
63 | extern CL_API_ENTRY cl_mem CL_API_CALL
64 | clCreateFromGLTexture(cl_context /* context */,
65 | cl_mem_flags /* flags */,
66 | cl_GLenum /* target */,
67 | cl_GLint /* miplevel */,
68 | cl_GLuint /* texture */,
69 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
70 |
71 | extern CL_API_ENTRY cl_mem CL_API_CALL
72 | clCreateFromGLRenderbuffer(cl_context /* context */,
73 | cl_mem_flags /* flags */,
74 | cl_GLuint /* renderbuffer */,
75 | cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
76 |
77 | extern CL_API_ENTRY cl_int CL_API_CALL
78 | clGetGLObjectInfo(cl_mem /* memobj */,
79 | cl_gl_object_type * /* gl_object_type */,
80 | cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
81 |
82 | extern CL_API_ENTRY cl_int CL_API_CALL
83 | clGetGLTextureInfo(cl_mem /* memobj */,
84 | cl_gl_texture_info /* param_name */,
85 | size_t /* param_value_size */,
86 | void * /* param_value */,
87 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
88 |
89 | extern CL_API_ENTRY cl_int CL_API_CALL
90 | clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
91 | cl_uint /* num_objects */,
92 | const cl_mem * /* mem_objects */,
93 | cl_uint /* num_events_in_wait_list */,
94 | const cl_event * /* event_wait_list */,
95 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
96 |
97 | extern CL_API_ENTRY cl_int CL_API_CALL
98 | clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
99 | cl_uint /* num_objects */,
100 | const cl_mem * /* mem_objects */,
101 | cl_uint /* num_events_in_wait_list */,
102 | const cl_event * /* event_wait_list */,
103 | cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
104 |
105 |
106 | #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
107 | extern CL_API_ENTRY cl_mem CL_API_CALL
108 | clCreateFromGLTexture2D(cl_context /* context */,
109 | cl_mem_flags /* flags */,
110 | cl_GLenum /* target */,
111 | cl_GLint /* miplevel */,
112 | cl_GLuint /* texture */,
113 | cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
114 |
115 | extern CL_API_ENTRY cl_mem CL_API_CALL
116 | clCreateFromGLTexture3D(cl_context /* context */,
117 | cl_mem_flags /* flags */,
118 | cl_GLenum /* target */,
119 | cl_GLint /* miplevel */,
120 | cl_GLuint /* texture */,
121 | cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
122 | #endif /* CL_USE_DEPRECATED_OPENCL_1_2_APIS */
123 |
124 | /* cl_khr_gl_sharing extension */
125 |
126 | #define cl_khr_gl_sharing 1
127 |
128 | typedef cl_uint cl_gl_context_info;
129 |
130 | /* Additional Error Codes */
131 | #define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
132 |
133 | /* cl_gl_context_info */
134 | #define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006
135 | #define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007
136 |
137 | /* Additional cl_context_properties */
138 | #define CL_GL_CONTEXT_KHR 0x2008
139 | #define CL_EGL_DISPLAY_KHR 0x2009
140 | #define CL_GLX_DISPLAY_KHR 0x200A
141 | #define CL_WGL_HDC_KHR 0x200B
142 | #define CL_CGL_SHAREGROUP_KHR 0x200C
143 |
144 | extern CL_API_ENTRY cl_int CL_API_CALL
145 | clGetGLContextInfoKHR(const cl_context_properties * /* properties */,
146 | cl_gl_context_info /* param_name */,
147 | size_t /* param_value_size */,
148 | void * /* param_value */,
149 | size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
150 |
151 | typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
152 | const cl_context_properties * properties,
153 | cl_gl_context_info param_name,
154 | size_t param_value_size,
155 | void * param_value,
156 | size_t * param_value_size_ret);
157 |
158 | #ifdef __cplusplus
159 | }
160 | #endif
161 |
162 | #endif /* __OPENCL_CL_GL_H */
163 |
--------------------------------------------------------------------------------
/jni/include/CL/cl_gl_ext.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************************
2 | * Copyright (c) 2008-2010 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | **********************************************************************************/
23 |
24 |
25 | /* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */
26 | /* OpenGL dependencies. */
27 |
28 | #ifndef __OPENCL_CL_GL_EXT_H
29 | #define __OPENCL_CL_GL_EXT_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | #ifdef __APPLE__
36 | #include
37 | #else
38 | #include
39 | #endif
40 |
41 | /*
42 | * For each extension, follow this template
43 | * cl_VEN_extname extension */
44 | /* #define cl_VEN_extname 1
45 | * ... define new types, if any
46 | * ... define new tokens, if any
47 | * ... define new APIs, if any
48 | *
49 | * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header
50 | * This allows us to avoid having to decide whether to include GL headers or GLES here.
51 | */
52 |
53 | /*
54 | * cl_khr_gl_event extension
55 | * See section 9.9 in the OpenCL 1.1 spec for more information
56 | */
57 | #define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
58 |
59 | extern CL_API_ENTRY cl_event CL_API_CALL
60 | clCreateEventFromGLsyncKHR(cl_context /* context */,
61 | cl_GLsync /* cl_GLsync */,
62 | cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1;
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 |
68 | #endif /* __OPENCL_CL_GL_EXT_H */
69 |
--------------------------------------------------------------------------------
/jni/include/CL/cl_platform.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************************
2 | * Copyright (c) 2008-2010 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | **********************************************************************************/
23 |
24 |
25 | #ifndef __CL_PLATFORM_H
26 | #define __CL_PLATFORM_H
27 |
28 | #ifdef __APPLE__
29 | /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
30 | #include
31 | #endif
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | #if defined(_WIN32)
38 | #define CL_API_ENTRY
39 | #define CL_API_CALL __stdcall
40 | #define CL_CALLBACK __stdcall
41 | #else
42 | #define CL_API_ENTRY
43 | #define CL_API_CALL
44 | #define CL_CALLBACK
45 | #endif
46 |
47 | #ifdef __APPLE__
48 | #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
49 | #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
50 | #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
51 | #define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
52 | #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
53 | #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
54 | #else
55 | #define CL_EXTENSION_WEAK_LINK
56 | #define CL_API_SUFFIX__VERSION_1_0
57 | #define CL_EXT_SUFFIX__VERSION_1_0
58 | #define CL_API_SUFFIX__VERSION_1_1
59 | #define CL_EXT_SUFFIX__VERSION_1_1
60 | #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
61 | #define CL_API_SUFFIX__VERSION_1_2
62 | #define CL_EXT_SUFFIX__VERSION_1_2
63 | #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
64 | #endif
65 |
66 | #if (defined (_WIN32) && defined(_MSC_VER))
67 |
68 | /* scalar types */
69 | typedef signed __int8 cl_char;
70 | typedef unsigned __int8 cl_uchar;
71 | typedef signed __int16 cl_short;
72 | typedef unsigned __int16 cl_ushort;
73 | typedef signed __int32 cl_int;
74 | typedef unsigned __int32 cl_uint;
75 | typedef signed __int64 cl_long;
76 | typedef unsigned __int64 cl_ulong;
77 |
78 | typedef unsigned __int16 cl_half;
79 | typedef float cl_float;
80 | typedef double cl_double;
81 |
82 | /* Macro names and corresponding values defined by OpenCL */
83 | #define CL_CHAR_BIT 8
84 | #define CL_SCHAR_MAX 127
85 | #define CL_SCHAR_MIN (-127-1)
86 | #define CL_CHAR_MAX CL_SCHAR_MAX
87 | #define CL_CHAR_MIN CL_SCHAR_MIN
88 | #define CL_UCHAR_MAX 255
89 | #define CL_SHRT_MAX 32767
90 | #define CL_SHRT_MIN (-32767-1)
91 | #define CL_USHRT_MAX 65535
92 | #define CL_INT_MAX 2147483647
93 | #define CL_INT_MIN (-2147483647-1)
94 | #define CL_UINT_MAX 0xffffffffU
95 | #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
96 | #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
97 | #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
98 |
99 | #define CL_FLT_DIG 6
100 | #define CL_FLT_MANT_DIG 24
101 | #define CL_FLT_MAX_10_EXP +38
102 | #define CL_FLT_MAX_EXP +128
103 | #define CL_FLT_MIN_10_EXP -37
104 | #define CL_FLT_MIN_EXP -125
105 | #define CL_FLT_RADIX 2
106 | #define CL_FLT_MAX 340282346638528859811704183484516925440.0f
107 | #define CL_FLT_MIN 1.175494350822287507969e-38f
108 | #define CL_FLT_EPSILON 1.1920928955078125E-7f /*0x1.0p-23f*/
109 |
110 | #define CL_DBL_DIG 15
111 | #define CL_DBL_MANT_DIG 53
112 | #define CL_DBL_MAX_10_EXP +308
113 | #define CL_DBL_MAX_EXP +1024
114 | #define CL_DBL_MIN_10_EXP -307
115 | #define CL_DBL_MIN_EXP -1021
116 | #define CL_DBL_RADIX 2
117 | #define CL_DBL_MAX 1.797693134862315708145e308
118 | #define CL_DBL_MIN 2.225073858507201383090e-308
119 | #define CL_DBL_EPSILON 2.220446049250313080847e-16
120 |
121 | #define CL_M_E 2.718281828459045090796
122 | #define CL_M_LOG2E 1.442695040888963387005
123 | #define CL_M_LOG10E 0.434294481903251816668
124 | #define CL_M_LN2 0.693147180559945286227
125 | #define CL_M_LN10 2.302585092994045901094
126 | #define CL_M_PI 3.141592653589793115998
127 | #define CL_M_PI_2 1.570796326794896557999
128 | #define CL_M_PI_4 0.785398163397448278999
129 | #define CL_M_1_PI 0.318309886183790691216
130 | #define CL_M_2_PI 0.636619772367581382433
131 | #define CL_M_2_SQRTPI 1.128379167095512558561
132 | #define CL_M_SQRT2 1.414213562373095145475
133 | #define CL_M_SQRT1_2 0.707106781186547572737
134 |
135 | #define CL_M_E_F 2.71828174591064f
136 | #define CL_M_LOG2E_F 1.44269502162933f
137 | #define CL_M_LOG10E_F 0.43429449200630f
138 | #define CL_M_LN2_F 0.69314718246460f
139 | #define CL_M_LN10_F 2.30258512496948f
140 | #define CL_M_PI_F 3.14159274101257f
141 | #define CL_M_PI_2_F 1.57079637050629f
142 | #define CL_M_PI_4_F 0.78539818525314f
143 | #define CL_M_1_PI_F 0.31830987334251f
144 | #define CL_M_2_PI_F 0.63661974668503f
145 | #define CL_M_2_SQRTPI_F 1.12837922573090f
146 | #define CL_M_SQRT2_F 1.41421353816986f
147 | #define CL_M_SQRT1_2_F 0.70710676908493f
148 |
149 | #define CL_NAN (CL_INFINITY - CL_INFINITY)
150 | #define CL_HUGE_VALF ((cl_float) 1e50)
151 | #define CL_HUGE_VAL ((cl_double) 1e500)
152 | #define CL_MAXFLOAT CL_FLT_MAX
153 | #define CL_INFINITY CL_HUGE_VALF
154 |
155 | #else
156 |
157 | #include
158 |
159 | /* scalar types */
160 | typedef int8_t cl_char;
161 | typedef uint8_t cl_uchar;
162 | typedef int16_t cl_short __attribute__((aligned(2)));
163 | typedef uint16_t cl_ushort __attribute__((aligned(2)));
164 | typedef int32_t cl_int __attribute__((aligned(4)));
165 | typedef uint32_t cl_uint __attribute__((aligned(4)));
166 | typedef int64_t cl_long __attribute__((aligned(8)));
167 | typedef uint64_t cl_ulong __attribute__((aligned(8)));
168 |
169 | typedef uint16_t cl_half __attribute__((aligned(2)));
170 | typedef float cl_float __attribute__((aligned(4)));
171 | typedef double cl_double __attribute__((aligned(8)));
172 |
173 | /* Macro names and corresponding values defined by OpenCL */
174 | #define CL_CHAR_BIT 8
175 | #define CL_SCHAR_MAX 127
176 | #define CL_SCHAR_MIN (-127-1)
177 | #define CL_CHAR_MAX CL_SCHAR_MAX
178 | #define CL_CHAR_MIN CL_SCHAR_MIN
179 | #define CL_UCHAR_MAX 255
180 | #define CL_SHRT_MAX 32767
181 | #define CL_SHRT_MIN (-32767-1)
182 | #define CL_USHRT_MAX 65535
183 | #define CL_INT_MAX 2147483647
184 | #define CL_INT_MIN (-2147483647-1)
185 | #define CL_UINT_MAX 0xffffffffU
186 | #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
187 | #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
188 | #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
189 |
190 | #define CL_FLT_DIG 6
191 | #define CL_FLT_MANT_DIG 24
192 | #define CL_FLT_MAX_10_EXP +38
193 | #define CL_FLT_MAX_EXP +128
194 | #define CL_FLT_MIN_10_EXP -37
195 | #define CL_FLT_MIN_EXP -125
196 | #define CL_FLT_RADIX 2
197 | #define CL_FLT_MAX 0x1.fffffep127f
198 | #define CL_FLT_MIN 0x1.0p-126f
199 | #define CL_FLT_EPSILON 0x1.0p-23f
200 |
201 | #define CL_DBL_DIG 15
202 | #define CL_DBL_MANT_DIG 53
203 | #define CL_DBL_MAX_10_EXP +308
204 | #define CL_DBL_MAX_EXP +1024
205 | #define CL_DBL_MIN_10_EXP -307
206 | #define CL_DBL_MIN_EXP -1021
207 | #define CL_DBL_RADIX 2
208 | #define CL_DBL_MAX 0x1.fffffffffffffp1023
209 | #define CL_DBL_MIN 0x1.0p-1022
210 | #define CL_DBL_EPSILON 0x1.0p-52
211 |
212 | #define CL_M_E 2.718281828459045090796
213 | #define CL_M_LOG2E 1.442695040888963387005
214 | #define CL_M_LOG10E 0.434294481903251816668
215 | #define CL_M_LN2 0.693147180559945286227
216 | #define CL_M_LN10 2.302585092994045901094
217 | #define CL_M_PI 3.141592653589793115998
218 | #define CL_M_PI_2 1.570796326794896557999
219 | #define CL_M_PI_4 0.785398163397448278999
220 | #define CL_M_1_PI 0.318309886183790691216
221 | #define CL_M_2_PI 0.636619772367581382433
222 | #define CL_M_2_SQRTPI 1.128379167095512558561
223 | #define CL_M_SQRT2 1.414213562373095145475
224 | #define CL_M_SQRT1_2 0.707106781186547572737
225 |
226 | #define CL_M_E_F 2.71828174591064f
227 | #define CL_M_LOG2E_F 1.44269502162933f
228 | #define CL_M_LOG10E_F 0.43429449200630f
229 | #define CL_M_LN2_F 0.69314718246460f
230 | #define CL_M_LN10_F 2.30258512496948f
231 | #define CL_M_PI_F 3.14159274101257f
232 | #define CL_M_PI_2_F 1.57079637050629f
233 | #define CL_M_PI_4_F 0.78539818525314f
234 | #define CL_M_1_PI_F 0.31830987334251f
235 | #define CL_M_2_PI_F 0.63661974668503f
236 | #define CL_M_2_SQRTPI_F 1.12837922573090f
237 | #define CL_M_SQRT2_F 1.41421353816986f
238 | #define CL_M_SQRT1_2_F 0.70710676908493f
239 |
240 | #if defined( __GNUC__ )
241 | #define CL_HUGE_VALF __builtin_huge_valf()
242 | #define CL_HUGE_VAL __builtin_huge_val()
243 | #define CL_NAN __builtin_nanf( "" )
244 | #else
245 | #define CL_HUGE_VALF ((cl_float) 1e50)
246 | #define CL_HUGE_VAL ((cl_double) 1e500)
247 | float nanf( const char * );
248 | #define CL_NAN nanf( "" )
249 | #endif
250 | #define CL_MAXFLOAT CL_FLT_MAX
251 | #define CL_INFINITY CL_HUGE_VALF
252 |
253 | #endif
254 |
255 | #include
256 |
257 | /* Mirror types to GL types. Mirror types allow us to avoid deciding which headers to load based on whether we are using GL or GLES here. */
258 | typedef unsigned int cl_GLuint;
259 | typedef int cl_GLint;
260 | typedef unsigned int cl_GLenum;
261 |
262 | /*
263 | * Vector types
264 | *
265 | * Note: OpenCL requires that all types be naturally aligned.
266 | * This means that vector types must be naturally aligned.
267 | * For example, a vector of four floats must be aligned to
268 | * a 16 byte boundary (calculated as 4 * the natural 4-byte
269 | * alignment of the float). The alignment qualifiers here
270 | * will only function properly if your compiler supports them
271 | * and if you don't actively work to defeat them. For example,
272 | * in order for a cl_float4 to be 16 byte aligned in a struct,
273 | * the start of the struct must itself be 16-byte aligned.
274 | *
275 | * Maintaining proper alignment is the user's responsibility.
276 | */
277 |
278 | /* Define basic vector types */
279 | #if defined( __VEC__ )
280 | #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
281 | typedef vector unsigned char __cl_uchar16;
282 | typedef vector signed char __cl_char16;
283 | typedef vector unsigned short __cl_ushort8;
284 | typedef vector signed short __cl_short8;
285 | typedef vector unsigned int __cl_uint4;
286 | typedef vector signed int __cl_int4;
287 | typedef vector float __cl_float4;
288 | #define __CL_UCHAR16__ 1
289 | #define __CL_CHAR16__ 1
290 | #define __CL_USHORT8__ 1
291 | #define __CL_SHORT8__ 1
292 | #define __CL_UINT4__ 1
293 | #define __CL_INT4__ 1
294 | #define __CL_FLOAT4__ 1
295 | #endif
296 |
297 | #if defined( __SSE__ )
298 | #if defined( __MINGW64__ )
299 | #include
300 | #else
301 | #include
302 | #endif
303 | #if defined( __GNUC__ )
304 | typedef float __cl_float4 __attribute__((vector_size(16)));
305 | #else
306 | typedef __m128 __cl_float4;
307 | #endif
308 | #define __CL_FLOAT4__ 1
309 | #endif
310 |
311 | #if defined( __SSE2__ )
312 | #if defined( __MINGW64__ )
313 | #include
314 | #else
315 | #include
316 | #endif
317 | #if defined( __GNUC__ )
318 | typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16)));
319 | typedef cl_char __cl_char16 __attribute__((vector_size(16)));
320 | typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16)));
321 | typedef cl_short __cl_short8 __attribute__((vector_size(16)));
322 | typedef cl_uint __cl_uint4 __attribute__((vector_size(16)));
323 | typedef cl_int __cl_int4 __attribute__((vector_size(16)));
324 | typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16)));
325 | typedef cl_long __cl_long2 __attribute__((vector_size(16)));
326 | typedef cl_double __cl_double2 __attribute__((vector_size(16)));
327 | #else
328 | typedef __m128i __cl_uchar16;
329 | typedef __m128i __cl_char16;
330 | typedef __m128i __cl_ushort8;
331 | typedef __m128i __cl_short8;
332 | typedef __m128i __cl_uint4;
333 | typedef __m128i __cl_int4;
334 | typedef __m128i __cl_ulong2;
335 | typedef __m128i __cl_long2;
336 | typedef __m128d __cl_double2;
337 | #endif
338 | #define __CL_UCHAR16__ 1
339 | #define __CL_CHAR16__ 1
340 | #define __CL_USHORT8__ 1
341 | #define __CL_SHORT8__ 1
342 | #define __CL_INT4__ 1
343 | #define __CL_UINT4__ 1
344 | #define __CL_ULONG2__ 1
345 | #define __CL_LONG2__ 1
346 | #define __CL_DOUBLE2__ 1
347 | #endif
348 |
349 | #if defined( __MMX__ )
350 | #include
351 | #if defined( __GNUC__ )
352 | typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8)));
353 | typedef cl_char __cl_char8 __attribute__((vector_size(8)));
354 | typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8)));
355 | typedef cl_short __cl_short4 __attribute__((vector_size(8)));
356 | typedef cl_uint __cl_uint2 __attribute__((vector_size(8)));
357 | typedef cl_int __cl_int2 __attribute__((vector_size(8)));
358 | typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8)));
359 | typedef cl_long __cl_long1 __attribute__((vector_size(8)));
360 | typedef cl_float __cl_float2 __attribute__((vector_size(8)));
361 | #else
362 | typedef __m64 __cl_uchar8;
363 | typedef __m64 __cl_char8;
364 | typedef __m64 __cl_ushort4;
365 | typedef __m64 __cl_short4;
366 | typedef __m64 __cl_uint2;
367 | typedef __m64 __cl_int2;
368 | typedef __m64 __cl_ulong1;
369 | typedef __m64 __cl_long1;
370 | typedef __m64 __cl_float2;
371 | #endif
372 | #define __CL_UCHAR8__ 1
373 | #define __CL_CHAR8__ 1
374 | #define __CL_USHORT4__ 1
375 | #define __CL_SHORT4__ 1
376 | #define __CL_INT2__ 1
377 | #define __CL_UINT2__ 1
378 | #define __CL_ULONG1__ 1
379 | #define __CL_LONG1__ 1
380 | #define __CL_FLOAT2__ 1
381 | #endif
382 |
383 | #if defined( __AVX__ )
384 | #if defined( __MINGW64__ )
385 | #include
386 | #else
387 | #include
388 | #endif
389 | #if defined( __GNUC__ )
390 | typedef cl_float __cl_float8 __attribute__((vector_size(32)));
391 | typedef cl_double __cl_double4 __attribute__((vector_size(32)));
392 | #else
393 | typedef __m256 __cl_float8;
394 | typedef __m256d __cl_double4;
395 | #endif
396 | #define __CL_FLOAT8__ 1
397 | #define __CL_DOUBLE4__ 1
398 | #endif
399 |
400 | /* Define alignment keys */
401 | #if defined( __GNUC__ )
402 | #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
403 | #elif defined( _WIN32) && (_MSC_VER)
404 | /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
405 | /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
406 | /* #include */
407 | /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
408 | #define CL_ALIGNED(_x)
409 | #else
410 | #warning Need to implement some method to align data here
411 | #define CL_ALIGNED(_x)
412 | #endif
413 |
414 | /* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
415 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
416 | /* .xyzw and .s0123...{f|F} are supported */
417 | #define CL_HAS_NAMED_VECTOR_FIELDS 1
418 | /* .hi and .lo are supported */
419 | #define CL_HAS_HI_LO_VECTOR_FIELDS 1
420 | #endif
421 |
422 | /* Define cl_vector types */
423 |
424 | /* ---- cl_charn ---- */
425 | typedef union
426 | {
427 | cl_char CL_ALIGNED(2) s[2];
428 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
429 | __extension__ struct{ cl_char x, y; };
430 | __extension__ struct{ cl_char s0, s1; };
431 | __extension__ struct{ cl_char lo, hi; };
432 | #endif
433 | #if defined( __CL_CHAR2__)
434 | __cl_char2 v2;
435 | #endif
436 | }cl_char2;
437 |
438 | typedef union
439 | {
440 | cl_char CL_ALIGNED(4) s[4];
441 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
442 | __extension__ struct{ cl_char x, y, z, w; };
443 | __extension__ struct{ cl_char s0, s1, s2, s3; };
444 | __extension__ struct{ cl_char2 lo, hi; };
445 | #endif
446 | #if defined( __CL_CHAR2__)
447 | __cl_char2 v2[2];
448 | #endif
449 | #if defined( __CL_CHAR4__)
450 | __cl_char4 v4;
451 | #endif
452 | }cl_char4;
453 |
454 | /* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
455 | typedef cl_char4 cl_char3;
456 |
457 | typedef union
458 | {
459 | cl_char CL_ALIGNED(8) s[8];
460 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
461 | __extension__ struct{ cl_char x, y, z, w; };
462 | __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
463 | __extension__ struct{ cl_char4 lo, hi; };
464 | #endif
465 | #if defined( __CL_CHAR2__)
466 | __cl_char2 v2[4];
467 | #endif
468 | #if defined( __CL_CHAR4__)
469 | __cl_char4 v4[2];
470 | #endif
471 | #if defined( __CL_CHAR8__ )
472 | __cl_char8 v8;
473 | #endif
474 | }cl_char8;
475 |
476 | typedef union
477 | {
478 | cl_char CL_ALIGNED(16) s[16];
479 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
480 | __extension__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
481 | __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
482 | __extension__ struct{ cl_char8 lo, hi; };
483 | #endif
484 | #if defined( __CL_CHAR2__)
485 | __cl_char2 v2[8];
486 | #endif
487 | #if defined( __CL_CHAR4__)
488 | __cl_char4 v4[4];
489 | #endif
490 | #if defined( __CL_CHAR8__ )
491 | __cl_char8 v8[2];
492 | #endif
493 | #if defined( __CL_CHAR16__ )
494 | __cl_char16 v16;
495 | #endif
496 | }cl_char16;
497 |
498 |
499 | /* ---- cl_ucharn ---- */
500 | typedef union
501 | {
502 | cl_uchar CL_ALIGNED(2) s[2];
503 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
504 | __extension__ struct{ cl_uchar x, y; };
505 | __extension__ struct{ cl_uchar s0, s1; };
506 | __extension__ struct{ cl_uchar lo, hi; };
507 | #endif
508 | #if defined( __cl_uchar2__)
509 | __cl_uchar2 v2;
510 | #endif
511 | }cl_uchar2;
512 |
513 | typedef union
514 | {
515 | cl_uchar CL_ALIGNED(4) s[4];
516 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
517 | __extension__ struct{ cl_uchar x, y, z, w; };
518 | __extension__ struct{ cl_uchar s0, s1, s2, s3; };
519 | __extension__ struct{ cl_uchar2 lo, hi; };
520 | #endif
521 | #if defined( __CL_UCHAR2__)
522 | __cl_uchar2 v2[2];
523 | #endif
524 | #if defined( __CL_UCHAR4__)
525 | __cl_uchar4 v4;
526 | #endif
527 | }cl_uchar4;
528 |
529 | /* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
530 | typedef cl_uchar4 cl_uchar3;
531 |
532 | typedef union
533 | {
534 | cl_uchar CL_ALIGNED(8) s[8];
535 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
536 | __extension__ struct{ cl_uchar x, y, z, w; };
537 | __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
538 | __extension__ struct{ cl_uchar4 lo, hi; };
539 | #endif
540 | #if defined( __CL_UCHAR2__)
541 | __cl_uchar2 v2[4];
542 | #endif
543 | #if defined( __CL_UCHAR4__)
544 | __cl_uchar4 v4[2];
545 | #endif
546 | #if defined( __CL_UCHAR8__ )
547 | __cl_uchar8 v8;
548 | #endif
549 | }cl_uchar8;
550 |
551 | typedef union
552 | {
553 | cl_uchar CL_ALIGNED(16) s[16];
554 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
555 | __extension__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
556 | __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
557 | __extension__ struct{ cl_uchar8 lo, hi; };
558 | #endif
559 | #if defined( __CL_UCHAR2__)
560 | __cl_uchar2 v2[8];
561 | #endif
562 | #if defined( __CL_UCHAR4__)
563 | __cl_uchar4 v4[4];
564 | #endif
565 | #if defined( __CL_UCHAR8__ )
566 | __cl_uchar8 v8[2];
567 | #endif
568 | #if defined( __CL_UCHAR16__ )
569 | __cl_uchar16 v16;
570 | #endif
571 | }cl_uchar16;
572 |
573 |
574 | /* ---- cl_shortn ---- */
575 | typedef union
576 | {
577 | cl_short CL_ALIGNED(4) s[2];
578 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
579 | __extension__ struct{ cl_short x, y; };
580 | __extension__ struct{ cl_short s0, s1; };
581 | __extension__ struct{ cl_short lo, hi; };
582 | #endif
583 | #if defined( __CL_SHORT2__)
584 | __cl_short2 v2;
585 | #endif
586 | }cl_short2;
587 |
588 | typedef union
589 | {
590 | cl_short CL_ALIGNED(8) s[4];
591 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
592 | __extension__ struct{ cl_short x, y, z, w; };
593 | __extension__ struct{ cl_short s0, s1, s2, s3; };
594 | __extension__ struct{ cl_short2 lo, hi; };
595 | #endif
596 | #if defined( __CL_SHORT2__)
597 | __cl_short2 v2[2];
598 | #endif
599 | #if defined( __CL_SHORT4__)
600 | __cl_short4 v4;
601 | #endif
602 | }cl_short4;
603 |
604 | /* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
605 | typedef cl_short4 cl_short3;
606 |
607 | typedef union
608 | {
609 | cl_short CL_ALIGNED(16) s[8];
610 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
611 | __extension__ struct{ cl_short x, y, z, w; };
612 | __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
613 | __extension__ struct{ cl_short4 lo, hi; };
614 | #endif
615 | #if defined( __CL_SHORT2__)
616 | __cl_short2 v2[4];
617 | #endif
618 | #if defined( __CL_SHORT4__)
619 | __cl_short4 v4[2];
620 | #endif
621 | #if defined( __CL_SHORT8__ )
622 | __cl_short8 v8;
623 | #endif
624 | }cl_short8;
625 |
626 | typedef union
627 | {
628 | cl_short CL_ALIGNED(32) s[16];
629 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
630 | __extension__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
631 | __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
632 | __extension__ struct{ cl_short8 lo, hi; };
633 | #endif
634 | #if defined( __CL_SHORT2__)
635 | __cl_short2 v2[8];
636 | #endif
637 | #if defined( __CL_SHORT4__)
638 | __cl_short4 v4[4];
639 | #endif
640 | #if defined( __CL_SHORT8__ )
641 | __cl_short8 v8[2];
642 | #endif
643 | #if defined( __CL_SHORT16__ )
644 | __cl_short16 v16;
645 | #endif
646 | }cl_short16;
647 |
648 |
649 | /* ---- cl_ushortn ---- */
650 | typedef union
651 | {
652 | cl_ushort CL_ALIGNED(4) s[2];
653 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
654 | __extension__ struct{ cl_ushort x, y; };
655 | __extension__ struct{ cl_ushort s0, s1; };
656 | __extension__ struct{ cl_ushort lo, hi; };
657 | #endif
658 | #if defined( __CL_USHORT2__)
659 | __cl_ushort2 v2;
660 | #endif
661 | }cl_ushort2;
662 |
663 | typedef union
664 | {
665 | cl_ushort CL_ALIGNED(8) s[4];
666 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
667 | __extension__ struct{ cl_ushort x, y, z, w; };
668 | __extension__ struct{ cl_ushort s0, s1, s2, s3; };
669 | __extension__ struct{ cl_ushort2 lo, hi; };
670 | #endif
671 | #if defined( __CL_USHORT2__)
672 | __cl_ushort2 v2[2];
673 | #endif
674 | #if defined( __CL_USHORT4__)
675 | __cl_ushort4 v4;
676 | #endif
677 | }cl_ushort4;
678 |
679 | /* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
680 | typedef cl_ushort4 cl_ushort3;
681 |
682 | typedef union
683 | {
684 | cl_ushort CL_ALIGNED(16) s[8];
685 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
686 | __extension__ struct{ cl_ushort x, y, z, w; };
687 | __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
688 | __extension__ struct{ cl_ushort4 lo, hi; };
689 | #endif
690 | #if defined( __CL_USHORT2__)
691 | __cl_ushort2 v2[4];
692 | #endif
693 | #if defined( __CL_USHORT4__)
694 | __cl_ushort4 v4[2];
695 | #endif
696 | #if defined( __CL_USHORT8__ )
697 | __cl_ushort8 v8;
698 | #endif
699 | }cl_ushort8;
700 |
701 | typedef union
702 | {
703 | cl_ushort CL_ALIGNED(32) s[16];
704 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
705 | __extension__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
706 | __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
707 | __extension__ struct{ cl_ushort8 lo, hi; };
708 | #endif
709 | #if defined( __CL_USHORT2__)
710 | __cl_ushort2 v2[8];
711 | #endif
712 | #if defined( __CL_USHORT4__)
713 | __cl_ushort4 v4[4];
714 | #endif
715 | #if defined( __CL_USHORT8__ )
716 | __cl_ushort8 v8[2];
717 | #endif
718 | #if defined( __CL_USHORT16__ )
719 | __cl_ushort16 v16;
720 | #endif
721 | }cl_ushort16;
722 |
723 | /* ---- cl_intn ---- */
724 | typedef union
725 | {
726 | cl_int CL_ALIGNED(8) s[2];
727 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
728 | __extension__ struct{ cl_int x, y; };
729 | __extension__ struct{ cl_int s0, s1; };
730 | __extension__ struct{ cl_int lo, hi; };
731 | #endif
732 | #if defined( __CL_INT2__)
733 | __cl_int2 v2;
734 | #endif
735 | }cl_int2;
736 |
737 | typedef union
738 | {
739 | cl_int CL_ALIGNED(16) s[4];
740 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
741 | __extension__ struct{ cl_int x, y, z, w; };
742 | __extension__ struct{ cl_int s0, s1, s2, s3; };
743 | __extension__ struct{ cl_int2 lo, hi; };
744 | #endif
745 | #if defined( __CL_INT2__)
746 | __cl_int2 v2[2];
747 | #endif
748 | #if defined( __CL_INT4__)
749 | __cl_int4 v4;
750 | #endif
751 | }cl_int4;
752 |
753 | /* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
754 | typedef cl_int4 cl_int3;
755 |
756 | typedef union
757 | {
758 | cl_int CL_ALIGNED(32) s[8];
759 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
760 | __extension__ struct{ cl_int x, y, z, w; };
761 | __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
762 | __extension__ struct{ cl_int4 lo, hi; };
763 | #endif
764 | #if defined( __CL_INT2__)
765 | __cl_int2 v2[4];
766 | #endif
767 | #if defined( __CL_INT4__)
768 | __cl_int4 v4[2];
769 | #endif
770 | #if defined( __CL_INT8__ )
771 | __cl_int8 v8;
772 | #endif
773 | }cl_int8;
774 |
775 | typedef union
776 | {
777 | cl_int CL_ALIGNED(64) s[16];
778 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
779 | __extension__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
780 | __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
781 | __extension__ struct{ cl_int8 lo, hi; };
782 | #endif
783 | #if defined( __CL_INT2__)
784 | __cl_int2 v2[8];
785 | #endif
786 | #if defined( __CL_INT4__)
787 | __cl_int4 v4[4];
788 | #endif
789 | #if defined( __CL_INT8__ )
790 | __cl_int8 v8[2];
791 | #endif
792 | #if defined( __CL_INT16__ )
793 | __cl_int16 v16;
794 | #endif
795 | }cl_int16;
796 |
797 |
798 | /* ---- cl_uintn ---- */
799 | typedef union
800 | {
801 | cl_uint CL_ALIGNED(8) s[2];
802 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
803 | __extension__ struct{ cl_uint x, y; };
804 | __extension__ struct{ cl_uint s0, s1; };
805 | __extension__ struct{ cl_uint lo, hi; };
806 | #endif
807 | #if defined( __CL_UINT2__)
808 | __cl_uint2 v2;
809 | #endif
810 | }cl_uint2;
811 |
812 | typedef union
813 | {
814 | cl_uint CL_ALIGNED(16) s[4];
815 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
816 | __extension__ struct{ cl_uint x, y, z, w; };
817 | __extension__ struct{ cl_uint s0, s1, s2, s3; };
818 | __extension__ struct{ cl_uint2 lo, hi; };
819 | #endif
820 | #if defined( __CL_UINT2__)
821 | __cl_uint2 v2[2];
822 | #endif
823 | #if defined( __CL_UINT4__)
824 | __cl_uint4 v4;
825 | #endif
826 | }cl_uint4;
827 |
828 | /* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
829 | typedef cl_uint4 cl_uint3;
830 |
831 | typedef union
832 | {
833 | cl_uint CL_ALIGNED(32) s[8];
834 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
835 | __extension__ struct{ cl_uint x, y, z, w; };
836 | __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
837 | __extension__ struct{ cl_uint4 lo, hi; };
838 | #endif
839 | #if defined( __CL_UINT2__)
840 | __cl_uint2 v2[4];
841 | #endif
842 | #if defined( __CL_UINT4__)
843 | __cl_uint4 v4[2];
844 | #endif
845 | #if defined( __CL_UINT8__ )
846 | __cl_uint8 v8;
847 | #endif
848 | }cl_uint8;
849 |
850 | typedef union
851 | {
852 | cl_uint CL_ALIGNED(64) s[16];
853 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
854 | __extension__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
855 | __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
856 | __extension__ struct{ cl_uint8 lo, hi; };
857 | #endif
858 | #if defined( __CL_UINT2__)
859 | __cl_uint2 v2[8];
860 | #endif
861 | #if defined( __CL_UINT4__)
862 | __cl_uint4 v4[4];
863 | #endif
864 | #if defined( __CL_UINT8__ )
865 | __cl_uint8 v8[2];
866 | #endif
867 | #if defined( __CL_UINT16__ )
868 | __cl_uint16 v16;
869 | #endif
870 | }cl_uint16;
871 |
872 | /* ---- cl_longn ---- */
873 | typedef union
874 | {
875 | cl_long CL_ALIGNED(16) s[2];
876 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
877 | __extension__ struct{ cl_long x, y; };
878 | __extension__ struct{ cl_long s0, s1; };
879 | __extension__ struct{ cl_long lo, hi; };
880 | #endif
881 | #if defined( __CL_LONG2__)
882 | __cl_long2 v2;
883 | #endif
884 | }cl_long2;
885 |
886 | typedef union
887 | {
888 | cl_long CL_ALIGNED(32) s[4];
889 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
890 | __extension__ struct{ cl_long x, y, z, w; };
891 | __extension__ struct{ cl_long s0, s1, s2, s3; };
892 | __extension__ struct{ cl_long2 lo, hi; };
893 | #endif
894 | #if defined( __CL_LONG2__)
895 | __cl_long2 v2[2];
896 | #endif
897 | #if defined( __CL_LONG4__)
898 | __cl_long4 v4;
899 | #endif
900 | }cl_long4;
901 |
902 | /* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
903 | typedef cl_long4 cl_long3;
904 |
905 | typedef union
906 | {
907 | cl_long CL_ALIGNED(64) s[8];
908 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
909 | __extension__ struct{ cl_long x, y, z, w; };
910 | __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
911 | __extension__ struct{ cl_long4 lo, hi; };
912 | #endif
913 | #if defined( __CL_LONG2__)
914 | __cl_long2 v2[4];
915 | #endif
916 | #if defined( __CL_LONG4__)
917 | __cl_long4 v4[2];
918 | #endif
919 | #if defined( __CL_LONG8__ )
920 | __cl_long8 v8;
921 | #endif
922 | }cl_long8;
923 |
924 | typedef union
925 | {
926 | cl_long CL_ALIGNED(128) s[16];
927 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
928 | __extension__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
929 | __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
930 | __extension__ struct{ cl_long8 lo, hi; };
931 | #endif
932 | #if defined( __CL_LONG2__)
933 | __cl_long2 v2[8];
934 | #endif
935 | #if defined( __CL_LONG4__)
936 | __cl_long4 v4[4];
937 | #endif
938 | #if defined( __CL_LONG8__ )
939 | __cl_long8 v8[2];
940 | #endif
941 | #if defined( __CL_LONG16__ )
942 | __cl_long16 v16;
943 | #endif
944 | }cl_long16;
945 |
946 |
947 | /* ---- cl_ulongn ---- */
948 | typedef union
949 | {
950 | cl_ulong CL_ALIGNED(16) s[2];
951 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
952 | __extension__ struct{ cl_ulong x, y; };
953 | __extension__ struct{ cl_ulong s0, s1; };
954 | __extension__ struct{ cl_ulong lo, hi; };
955 | #endif
956 | #if defined( __CL_ULONG2__)
957 | __cl_ulong2 v2;
958 | #endif
959 | }cl_ulong2;
960 |
961 | typedef union
962 | {
963 | cl_ulong CL_ALIGNED(32) s[4];
964 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
965 | __extension__ struct{ cl_ulong x, y, z, w; };
966 | __extension__ struct{ cl_ulong s0, s1, s2, s3; };
967 | __extension__ struct{ cl_ulong2 lo, hi; };
968 | #endif
969 | #if defined( __CL_ULONG2__)
970 | __cl_ulong2 v2[2];
971 | #endif
972 | #if defined( __CL_ULONG4__)
973 | __cl_ulong4 v4;
974 | #endif
975 | }cl_ulong4;
976 |
977 | /* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
978 | typedef cl_ulong4 cl_ulong3;
979 |
980 | typedef union
981 | {
982 | cl_ulong CL_ALIGNED(64) s[8];
983 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
984 | __extension__ struct{ cl_ulong x, y, z, w; };
985 | __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
986 | __extension__ struct{ cl_ulong4 lo, hi; };
987 | #endif
988 | #if defined( __CL_ULONG2__)
989 | __cl_ulong2 v2[4];
990 | #endif
991 | #if defined( __CL_ULONG4__)
992 | __cl_ulong4 v4[2];
993 | #endif
994 | #if defined( __CL_ULONG8__ )
995 | __cl_ulong8 v8;
996 | #endif
997 | }cl_ulong8;
998 |
999 | typedef union
1000 | {
1001 | cl_ulong CL_ALIGNED(128) s[16];
1002 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1003 | __extension__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1004 | __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1005 | __extension__ struct{ cl_ulong8 lo, hi; };
1006 | #endif
1007 | #if defined( __CL_ULONG2__)
1008 | __cl_ulong2 v2[8];
1009 | #endif
1010 | #if defined( __CL_ULONG4__)
1011 | __cl_ulong4 v4[4];
1012 | #endif
1013 | #if defined( __CL_ULONG8__ )
1014 | __cl_ulong8 v8[2];
1015 | #endif
1016 | #if defined( __CL_ULONG16__ )
1017 | __cl_ulong16 v16;
1018 | #endif
1019 | }cl_ulong16;
1020 |
1021 |
1022 | /* --- cl_floatn ---- */
1023 |
1024 | typedef union
1025 | {
1026 | cl_float CL_ALIGNED(8) s[2];
1027 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1028 | __extension__ struct{ cl_float x, y; };
1029 | __extension__ struct{ cl_float s0, s1; };
1030 | __extension__ struct{ cl_float lo, hi; };
1031 | #endif
1032 | #if defined( __CL_FLOAT2__)
1033 | __cl_float2 v2;
1034 | #endif
1035 | }cl_float2;
1036 |
1037 | typedef union
1038 | {
1039 | cl_float CL_ALIGNED(16) s[4];
1040 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1041 | __extension__ struct{ cl_float x, y, z, w; };
1042 | __extension__ struct{ cl_float s0, s1, s2, s3; };
1043 | __extension__ struct{ cl_float2 lo, hi; };
1044 | #endif
1045 | #if defined( __CL_FLOAT2__)
1046 | __cl_float2 v2[2];
1047 | #endif
1048 | #if defined( __CL_FLOAT4__)
1049 | __cl_float4 v4;
1050 | #endif
1051 | }cl_float4;
1052 |
1053 | /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
1054 | typedef cl_float4 cl_float3;
1055 |
1056 | typedef union
1057 | {
1058 | cl_float CL_ALIGNED(32) s[8];
1059 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1060 | __extension__ struct{ cl_float x, y, z, w; };
1061 | __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
1062 | __extension__ struct{ cl_float4 lo, hi; };
1063 | #endif
1064 | #if defined( __CL_FLOAT2__)
1065 | __cl_float2 v2[4];
1066 | #endif
1067 | #if defined( __CL_FLOAT4__)
1068 | __cl_float4 v4[2];
1069 | #endif
1070 | #if defined( __CL_FLOAT8__ )
1071 | __cl_float8 v8;
1072 | #endif
1073 | }cl_float8;
1074 |
1075 | typedef union
1076 | {
1077 | cl_float CL_ALIGNED(64) s[16];
1078 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1079 | __extension__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1080 | __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1081 | __extension__ struct{ cl_float8 lo, hi; };
1082 | #endif
1083 | #if defined( __CL_FLOAT2__)
1084 | __cl_float2 v2[8];
1085 | #endif
1086 | #if defined( __CL_FLOAT4__)
1087 | __cl_float4 v4[4];
1088 | #endif
1089 | #if defined( __CL_FLOAT8__ )
1090 | __cl_float8 v8[2];
1091 | #endif
1092 | #if defined( __CL_FLOAT16__ )
1093 | __cl_float16 v16;
1094 | #endif
1095 | }cl_float16;
1096 |
1097 | /* --- cl_doublen ---- */
1098 |
1099 | typedef union
1100 | {
1101 | cl_double CL_ALIGNED(16) s[2];
1102 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1103 | __extension__ struct{ cl_double x, y; };
1104 | __extension__ struct{ cl_double s0, s1; };
1105 | __extension__ struct{ cl_double lo, hi; };
1106 | #endif
1107 | #if defined( __CL_DOUBLE2__)
1108 | __cl_double2 v2;
1109 | #endif
1110 | }cl_double2;
1111 |
1112 | typedef union
1113 | {
1114 | cl_double CL_ALIGNED(32) s[4];
1115 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1116 | __extension__ struct{ cl_double x, y, z, w; };
1117 | __extension__ struct{ cl_double s0, s1, s2, s3; };
1118 | __extension__ struct{ cl_double2 lo, hi; };
1119 | #endif
1120 | #if defined( __CL_DOUBLE2__)
1121 | __cl_double2 v2[2];
1122 | #endif
1123 | #if defined( __CL_DOUBLE4__)
1124 | __cl_double4 v4;
1125 | #endif
1126 | }cl_double4;
1127 |
1128 | /* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
1129 | typedef cl_double4 cl_double3;
1130 |
1131 | typedef union
1132 | {
1133 | cl_double CL_ALIGNED(64) s[8];
1134 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1135 | __extension__ struct{ cl_double x, y, z, w; };
1136 | __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
1137 | __extension__ struct{ cl_double4 lo, hi; };
1138 | #endif
1139 | #if defined( __CL_DOUBLE2__)
1140 | __cl_double2 v2[4];
1141 | #endif
1142 | #if defined( __CL_DOUBLE4__)
1143 | __cl_double4 v4[2];
1144 | #endif
1145 | #if defined( __CL_DOUBLE8__ )
1146 | __cl_double8 v8;
1147 | #endif
1148 | }cl_double8;
1149 |
1150 | typedef union
1151 | {
1152 | cl_double CL_ALIGNED(128) s[16];
1153 | #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1154 | __extension__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1155 | __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1156 | __extension__ struct{ cl_double8 lo, hi; };
1157 | #endif
1158 | #if defined( __CL_DOUBLE2__)
1159 | __cl_double2 v2[8];
1160 | #endif
1161 | #if defined( __CL_DOUBLE4__)
1162 | __cl_double4 v4[4];
1163 | #endif
1164 | #if defined( __CL_DOUBLE8__ )
1165 | __cl_double8 v8[2];
1166 | #endif
1167 | #if defined( __CL_DOUBLE16__ )
1168 | __cl_double16 v16;
1169 | #endif
1170 | }cl_double16;
1171 |
1172 | /* Macro to facilitate debugging
1173 | * Usage:
1174 | * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
1175 | * The first line ends with: CL_PROGRAM_STRING_BEGIN \"
1176 | * Each line thereafter of OpenCL C source must end with: \n\
1177 | * The last line ends in ";
1178 | *
1179 | * Example:
1180 | *
1181 | * const char *my_program = CL_PROGRAM_STRING_BEGIN "\
1182 | * kernel void foo( int a, float * b ) \n\
1183 | * { \n\
1184 | * // my comment \n\
1185 | * *b[ get_global_id(0)] = a; \n\
1186 | * } \n\
1187 | * ";
1188 | *
1189 | * This should correctly set up the line, (column) and file information for your source
1190 | * string so you can do source level debugging.
1191 | */
1192 | #define __CL_STRINGIFY( _x ) # _x
1193 | #define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
1194 | #define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
1195 |
1196 | #ifdef __cplusplus
1197 | }
1198 | #endif
1199 |
1200 | #endif /* __CL_PLATFORM_H */
1201 |
--------------------------------------------------------------------------------
/jni/include/CL/opencl.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2008-2010 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | ******************************************************************************/
23 |
24 |
25 | #ifndef __OPENCL_H
26 | #define __OPENCL_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #ifdef __APPLE__
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #else
40 |
41 | #include
42 | #include
43 | #include
44 | #include
45 |
46 | #endif
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif /* __OPENCL_H */
53 |
54 |
--------------------------------------------------------------------------------
/jni/processor.cpp:
--------------------------------------------------------------------------------
1 | #define __CL_ENABLE_EXCEPTIONS
2 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
3 |
4 | #include "processor.h"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | static cl::Context gContext;
14 | static cl::CommandQueue gQueue;
15 | static cl::Kernel gNV21Kernel;
16 | static cl::Kernel gLaplacianK;
17 |
18 | char *file_contents(const char *filename, int *length)
19 | {
20 | FILE *f = fopen(filename, "r");
21 | void *buffer;
22 |
23 | if (!f) {
24 | LOGE("Unable to open %s for reading\n", filename);
25 | return NULL;
26 | }
27 |
28 | fseek(f, 0, SEEK_END);
29 | *length = ftell(f);
30 | fseek(f, 0, SEEK_SET);
31 |
32 | buffer = malloc(*length+1);
33 | *length = fread(buffer, 1, *length, f);
34 | fclose(f);
35 | ((char*)buffer)[*length] = '\0';
36 |
37 | return (char*)buffer;
38 | }
39 |
40 | bool throwJavaException(JNIEnv *env,std::string method_name,std::string exception_msg, int errorCode=0)
41 | {
42 | char buf[8];
43 | sprintf(buf,"%d",errorCode);
44 | std::string code(buf);
45 |
46 | std::string msg = "@" + method_name + ": " + exception_msg + " ";
47 | if(errorCode!=0) msg += code;
48 |
49 | jclass generalExp = env->FindClass("java/lang/Exception");
50 | if (generalExp != 0) {
51 | env->ThrowNew(generalExp, msg.c_str());
52 | return true;
53 | }
54 | return false;
55 | }
56 |
57 | void cb(cl_program p,void* data)
58 | {
59 | clRetainProgram(p);
60 | cl_device_id devid[1];
61 | clGetProgramInfo(p,CL_PROGRAM_DEVICES,sizeof(cl_device_id),(void*)devid,NULL);
62 | char bug[65536];
63 | clGetProgramBuildInfo(p,devid[0],CL_PROGRAM_BUILD_LOG,65536*sizeof(char),bug,NULL);
64 | clReleaseProgram(p);
65 | LOGE("Build log \n %s\n",bug);
66 | }
67 |
68 | JNIEXPORT jboolean JNICALL Java_com_example_LiveFeatureActivity_compileKernels(JNIEnv *env, jclass clazz)
69 | {
70 | // Find OCL devices and compile kernels
71 | cl_int err = CL_SUCCESS;
72 | try {
73 | std::vector platforms;
74 | cl::Platform::get(&platforms);
75 | if (platforms.size() == 0) {
76 | return false;
77 | }
78 | cl_context_properties properties[] =
79 | { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0};
80 | gContext = cl::Context(CL_DEVICE_TYPE_GPU, properties);
81 | std::vector devices = gContext.getInfo();
82 | gQueue = cl::CommandQueue(gContext, devices[0], 0, &err);
83 | int src_length = 0;
84 | const char* src = file_contents("/data/data/com.example/app_execdir/kernels.cl",&src_length);
85 | cl::Program::Sources sources(1,std::make_pair(src, src_length) );
86 | cl::Program program(gContext, sources);
87 | program.build(devices,NULL,cb);
88 | while(program.getBuildInfo(devices[0]) != CL_BUILD_SUCCESS);
89 | gNV21Kernel = cl::Kernel(program, "nv21torgba", &err);
90 | gLaplacianK = cl::Kernel(program, "laplacian", &err);
91 | return true;
92 | }
93 | catch (cl::Error e) {
94 | if( !throwJavaException(env,"decode",e.what(),e.err()) )
95 | LOGI("@decode: %s \n",e.what());
96 | return false;
97 | }
98 | }
99 |
100 | void helper(uint32_t* out, int osize, uint8_t* in, int isize, int w, int h, int choice)
101 | {
102 | try {
103 | cl::Buffer bufferIn = cl::Buffer(gContext, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
104 | isize*sizeof(cl_uchar), in, NULL);
105 | cl::Buffer bufferOut = cl::Buffer(gContext, CL_MEM_READ_WRITE, osize*sizeof(cl_uchar4));
106 | cl::Buffer bufferOut2= cl::Buffer(gContext, CL_MEM_READ_WRITE, osize*sizeof(cl_uchar4));
107 | gNV21Kernel.setArg(2,w);
108 | gNV21Kernel.setArg(3,h);
109 | gNV21Kernel.setArg(1,bufferIn);
110 | gNV21Kernel.setArg(0,bufferOut);
111 | gQueue.enqueueNDRangeKernel(gNV21Kernel,
112 | cl::NullRange,
113 | cl::NDRange( (int)ceil((float)w/16.0f)*16,(int)ceil((float)h/16.0f)*16),
114 | cl::NDRange(16,16),
115 | NULL,
116 | NULL);
117 | if (choice>0) {
118 | gLaplacianK.setArg(2,w);
119 | gLaplacianK.setArg(3,h);
120 | gLaplacianK.setArg(1,bufferOut);
121 | gLaplacianK.setArg(0,bufferOut2);
122 | gQueue.enqueueNDRangeKernel(gLaplacianK,
123 | cl::NullRange,
124 | cl::NDRange( (int)ceil((float)w/16.0f)*16,(int)ceil((float)h/16.0f)*16),
125 | cl::NDRange(16,16),
126 | NULL,
127 | NULL);
128 | }
129 | gQueue.enqueueReadBuffer(bufferOut2, CL_TRUE, 0, osize*sizeof(cl_uchar4), out);
130 | }
131 | catch (cl::Error e) {
132 | LOGI("@oclDecoder: %s %d \n",e.what(),e.err());
133 | }
134 | }
135 |
136 | JNIEXPORT void JNICALL Java_com_example_CameraPreview_runfilter(
137 | JNIEnv *env,
138 | jclass clazz,
139 | jobject outBmp,
140 | jbyteArray inData,
141 | jint width,
142 | jint height,
143 | jint choice)
144 | {
145 | int outsz = width*height;
146 | int insz = outsz + outsz/2;
147 | AndroidBitmapInfo bmpInfo;
148 | if (AndroidBitmap_getInfo(env, outBmp, &bmpInfo) < 0) {
149 | throwJavaException(env,"gaussianBlur","Error retrieving bitmap meta data");
150 | return;
151 | }
152 | if (bmpInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
153 | throwJavaException(env,"gaussianBlur","Expecting RGBA_8888 format");
154 | return;
155 | }
156 | uint32_t* bmpContent;
157 | if (AndroidBitmap_lockPixels(env, outBmp,(void**)&bmpContent) < 0) {
158 | throwJavaException(env,"gaussianBlur","Unable to lock bitmap pixels");
159 | return;
160 | }
161 | jbyte* inPtr = (jbyte*)env->GetPrimitiveArrayCritical(inData, 0);
162 | if (inPtr == NULL) {
163 | throwJavaException(env,"gaussianBlur","NV21 byte stream getPointer returned NULL");
164 | return;
165 | }
166 | // call helper for processing frame
167 | helper(bmpContent,outsz,(uint8_t*)inPtr,insz,width,height,choice);
168 | // This is absolutely neccessary before calling any other JNI function
169 | env->ReleasePrimitiveArrayCritical(inData,inPtr,0);
170 | AndroidBitmap_unlockPixels(env, outBmp);
171 | }
172 |
--------------------------------------------------------------------------------
/jni/processor.h:
--------------------------------------------------------------------------------
1 | #ifndef __JNI_H__
2 | #define __JNI_H__
3 | #ifdef __cplusplus
4 |
5 | #include
6 | #include
7 |
8 | #define app_name "JNIProcessor"
9 | #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, app_name, __VA_ARGS__))
10 | #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, app_name, __VA_ARGS__))
11 | #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, app_name, __VA_ARGS__))
12 | extern "C" {
13 | #endif
14 |
15 | #define DECLARE_NOPARAMS(returnType,fullClassName,func) \
16 | JNIEXPORT returnType JNICALL Java_##fullClassName##_##func(JNIEnv *env, jclass clazz);
17 |
18 | #define DECLARE_WITHPARAMS(returnType,fullClassName,func,...) \
19 | JNIEXPORT returnType JNICALL Java_##fullClassName##_##func(JNIEnv *env, jclass clazz,__VA_ARGS__);
20 |
21 | DECLARE_NOPARAMS(jboolean,com_example_LiveFeatureActivity,compileKernels)
22 |
23 | DECLARE_WITHPARAMS(void,com_example_CameraPreview,runfilter,jobject outBmp, jbyteArray inData, jint width, jint height, jint choice)
24 |
25 | #ifdef __cplusplus
26 | }
27 | #endif
28 |
29 | #endif //__JNI_H__
30 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/opt/android-sdk
11 |
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-14
15 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arrayfire/androidcl/2cc91765a6bf4e2312137e946480022c370c89db/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arrayfire/androidcl/2cc91765a6bf4e2312137e946480022c370c89db/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arrayfire/androidcl/2cc91765a6bf4e2312137e946480022c370c89db/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arrayfire/androidcl/2cc91765a6bf4e2312137e946480022c370c89db/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/activity_live_feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/res/menu/live_feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | droidcl
4 | LiveFeatureActivity
5 | NV21 Decoding
6 | Decoding+Laplacian
7 |
8 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/com/example/CameraPreview.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import java.io.IOException;
4 |
5 | import android.content.Context;
6 | import android.graphics.Bitmap;
7 | import android.graphics.Canvas;
8 | import android.graphics.ImageFormat;
9 | import android.graphics.Paint;
10 | import android.graphics.PixelFormat;
11 | import android.graphics.Rect;
12 | import android.hardware.Camera;
13 | import android.util.Log;
14 | import android.view.SurfaceHolder;
15 | import android.view.SurfaceView;
16 |
17 | public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback, Camera.PreviewCallback {
18 | static {
19 | System.loadLibrary("JNIProcessor");
20 | }
21 |
22 | private static final String TAG = "CameraPreview";
23 |
24 | private Camera mCamera;
25 | private byte[] mVideoSource;
26 | private Bitmap mBackBuffer;
27 | private int[] mImgDims;
28 | private Paint mPaint;
29 | private Rect mSrcRect;
30 | private Rect mTrgtRect;
31 | private int mChoice;
32 | private String mDisplayStr;
33 |
34 | native private void runfilter(Bitmap out, byte[] in, int width, int height, int choice);
35 |
36 | public CameraPreview(Context context) {
37 | super(context);
38 | getHolder().addCallback(this);
39 | setWillNotDraw(false);
40 | mImgDims = new int[3];
41 | mImgDims[2] = 4;
42 | mPaint = new Paint();
43 | mPaint.setTextSize(64);
44 | mPaint.setColor(0xFFFF0000);
45 | mDisplayStr = new String("nv21 to rgba8888");
46 | }
47 |
48 | public void surfaceCreated(SurfaceHolder pHolder) {
49 | try {
50 | mCamera = Camera.open(0);
51 | Camera.Parameters params = mCamera.getParameters();
52 | params.setPreviewFormat(ImageFormat.NV21);
53 | params.setPreviewSize(Constants.MAX_DISP_IMG_WIDTH,
54 | Constants.MAX_DISP_IMG_HEIGHT);
55 | params.setPreviewFpsRange(Constants.MIN_FPS,Constants.MAX_FPS);
56 | mCamera.setParameters(params);
57 | mCamera.setDisplayOrientation(0);
58 | mCamera.setPreviewDisplay(null);
59 | mCamera.setPreviewCallbackWithBuffer(this);
60 | } catch (IOException eIOException) {
61 | Log.i(TAG, "Error setting camera preview: " + eIOException.getMessage());
62 | throw new IllegalStateException();
63 | }
64 | catch (Exception e) {
65 | Log.i(TAG, e.getMessage());
66 | }
67 | }
68 |
69 | public void surfaceChanged(SurfaceHolder pHolder, int pFormat, int pW, int pH) {
70 |
71 | if (pHolder.getSurface() == null) {
72 | Log.i(TAG,"No proper holder");
73 | return;
74 | }
75 | try {
76 | mCamera.stopPreview();
77 | } catch (Exception e) {
78 | Log.i(TAG,"tried to stop a non-existent preview");
79 | return;
80 | }
81 | PixelFormat pxlFrmt = new PixelFormat();
82 | PixelFormat.getPixelFormatInfo(mCamera.getParameters().getPreviewFormat(), pxlFrmt);
83 | int srcSize = Constants.MAX_DISP_IMG_WIDTH * Constants.MAX_DISP_IMG_HEIGHT * pxlFrmt.bitsPerPixel/8;
84 | mVideoSource = new byte[srcSize];
85 | mBackBuffer = Bitmap.createBitmap(Constants.MAX_DISP_IMG_WIDTH,
86 | Constants.MAX_DISP_IMG_HEIGHT,Bitmap.Config.ARGB_8888);
87 | Camera.Parameters camParams = mCamera.getParameters();
88 | camParams.setPreviewSize(Constants.MAX_DISP_IMG_WIDTH,
89 | Constants.MAX_DISP_IMG_HEIGHT);
90 | camParams.setPreviewFormat(ImageFormat.NV21);
91 | camParams.setPreviewFpsRange(Constants.MIN_FPS,Constants.MAX_FPS);
92 | mCamera.setParameters(camParams);
93 |
94 | mImgDims[0] = Constants.MAX_DISP_IMG_WIDTH;
95 | mImgDims[1] = Constants.MAX_DISP_IMG_HEIGHT;
96 |
97 | mSrcRect = new Rect(0,0,mImgDims[0],mImgDims[1]);
98 | mTrgtRect = pHolder.getSurfaceFrame();
99 |
100 | mCamera.addCallbackBuffer(mVideoSource);
101 |
102 | try {
103 | mCamera.setPreviewDisplay(pHolder);
104 | mCamera.startPreview();
105 | } catch (Exception e){
106 | Log.d(TAG, "@SurfaceChanged:Error starting camera preview: " + e.getMessage());
107 | }
108 | }
109 |
110 | public void setProcessedPreview(int choice) {
111 | mChoice = choice;
112 | if (choice==0)
113 | mDisplayStr = "nv21 to rgba8888";
114 | else if (choice==1)
115 | mDisplayStr = "Decode & Laplacian operator";
116 | }
117 |
118 | public void onPreviewFrame(byte[] data, Camera camera) {
119 | try {
120 | runfilter(mBackBuffer,data,mImgDims[0],mImgDims[1],mChoice);
121 | } catch(Exception e) {
122 | Log.i(TAG, e.getMessage());
123 | }
124 | invalidate();
125 | }
126 |
127 | @Override
128 | protected void onDraw(Canvas pCanvas) {
129 | if( mCamera != null ) {
130 | if( mBackBuffer!=null ) {
131 | pCanvas.drawBitmap(mBackBuffer, mSrcRect, mTrgtRect, null);
132 | pCanvas.drawText(mDisplayStr, 64, 64, mPaint);
133 | }
134 | mCamera.addCallbackBuffer(mVideoSource);
135 | }
136 | }
137 |
138 | private void releaseCamera(){
139 | if (mCamera != null){
140 | mCamera.release();
141 | mCamera = null;
142 | }
143 | }
144 |
145 | public void surfaceDestroyed(SurfaceHolder holder) {
146 | if (mCamera != null) {
147 | mCamera.stopPreview();
148 | mCamera.setPreviewCallback(null);
149 | releaseCamera();
150 | mVideoSource = null;
151 | mBackBuffer = null;
152 | }
153 | }
154 |
155 | }
156 |
--------------------------------------------------------------------------------
/src/com/example/Constants.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | public class Constants {
4 | public static final int MAX_DISP_IMG_WIDTH = 1280;
5 | public static final int MAX_DISP_IMG_HEIGHT = 720;
6 | public static final int MAX_FPS = 30000;
7 | public static final int MIN_FPS = 24000;
8 | }
9 |
--------------------------------------------------------------------------------
/src/com/example/LiveFeatureActivity.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.OutputStream;
8 |
9 | import android.app.Activity;
10 | import android.os.Bundle;
11 | import android.util.Log;
12 | import android.view.Menu;
13 | import android.view.MenuItem;
14 | import android.widget.FrameLayout;
15 |
16 | public class LiveFeatureActivity extends Activity {
17 |
18 | static {
19 | System.loadLibrary("JNIProcessor");
20 | }
21 |
22 | private final String TAG="LiveFeature";
23 | private CameraPreview mPreview;
24 |
25 | native private boolean compileKernels();
26 |
27 | private void copyFile(final String f) {
28 | InputStream in;
29 | try {
30 | in = getAssets().open(f);
31 | final File of = new File(getDir("execdir",MODE_PRIVATE), f);
32 |
33 | final OutputStream out = new FileOutputStream(of);
34 |
35 | final byte b[] = new byte[65535];
36 | int sz = 0;
37 | while ((sz = in.read(b)) > 0) {
38 | out.write(b, 0, sz);
39 | }
40 | in.close();
41 | out.close();
42 | } catch (IOException e) {
43 | e.printStackTrace();
44 | }
45 | }
46 |
47 | @Override
48 | protected void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | setContentView(R.layout.activity_live_feature);
51 | copyFile("kernels.cl");
52 |
53 | if( compileKernels() == false )
54 | Log.i(TAG,"Kernel compilation failed");
55 |
56 | mPreview = new CameraPreview(this);
57 | FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
58 | preview.addView(mPreview);
59 | }
60 |
61 | @Override
62 | public boolean onCreateOptionsMenu(Menu menu) {
63 | getMenuInflater().inflate(R.menu.live_feature, menu);
64 | return true;
65 | }
66 |
67 | @Override
68 | public boolean onOptionsItemSelected(MenuItem item) {
69 | switch (item.getItemId()) {
70 | case R.id.iFeed:
71 | mPreview.setProcessedPreview(0);
72 | return true;
73 | case R.id.eFeed:
74 | mPreview.setProcessedPreview(1);
75 | return true;
76 | default:
77 | return super.onOptionsItemSelected(item);
78 | }
79 | }
80 |
81 | @Override
82 | protected void onPause() {
83 | super.onPause();
84 | }
85 |
86 | @Override
87 | protected void onResume() {
88 | super.onResume();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------