1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
#[macro_use] extern crate bitflags;
#[macro_use] extern crate enum_primitive;
extern crate libc;
extern crate rand;
extern crate num;
#[cfg(feature = "ocl-core-vector")]
extern crate ocl_core_vector as vector;
pub extern crate cl_sys as ffi;
#[cfg(test)] mod tests;
mod functions;
pub mod types;
pub mod error;
pub mod util;
pub use self::error::{Error, Result};
pub use self::types::abs::{ClWaitListPtr, ClNullEventPtr, ClEventPtrRef, ClPlatformIdPtr,
ClDeviceIdPtr, ClContextPtr, EventRefWrapper, PlatformId, DeviceId, Context, CommandQueue, Mem,
Program, Kernel, Event, Sampler, ClVersions, AsMem, MemCmdRw, MemCmdAll, MemMap};
pub use self::types::structs::{self, OpenclVersion, ContextProperties, ImageFormatParseError,
ImageFormatParseResult, ImageFormat, ImageDescriptor, BufferRegion, ContextPropertyValue};
pub use self::types::enums::{EmptyInfoResult, KernelArg, PlatformInfoResult, DeviceInfoResult,
ContextInfoResult, CommandQueueInfoResult, MemInfoResult, ImageInfoResult, SamplerInfoResult,
ProgramInfoResult, ProgramBuildInfoResult, KernelInfoResult, KernelArgInfoResult,
KernelWorkGroupInfoResult, EventInfoResult, ProfilingInfoResult};
pub use self::functions::{get_platform_ids, get_platform_info, get_device_ids, get_device_info,
create_sub_devices, retain_device, release_device, create_context, create_context_from_type,
retain_context, release_context, get_context_info, create_command_queue, retain_command_queue,
release_command_queue, get_command_queue_info, create_buffer, create_sub_buffer, create_image,
retain_mem_object, release_mem_object, get_supported_image_formats, get_mem_object_info,
get_image_info, set_mem_object_destructor_callback, create_sampler, retain_sampler,
release_sampler, get_sampler_info, create_program_with_source, create_program_with_binary,
create_program_with_built_in_kernels, retain_program, release_program, build_program,
compile_program, link_program, create_build_program, get_program_info, get_program_build_info,
create_kernel, create_kernels_in_program, retain_kernel, release_kernel, set_kernel_arg,
get_kernel_info, get_kernel_arg_info, get_kernel_work_group_info, wait_for_events,
get_event_info, create_user_event, retain_event, release_event, set_user_event_status,
set_event_callback, get_event_profiling_info, flush, finish, enqueue_read_buffer,
enqueue_read_buffer_rect, enqueue_write_buffer, enqueue_write_buffer_rect, enqueue_copy_buffer,
create_from_gl_buffer, create_from_gl_renderbuffer, create_from_gl_texture,
create_from_gl_texture_2d, create_from_gl_texture_3d, enqueue_acquire_gl_buffer,
enqueue_release_gl_buffer, enqueue_fill_buffer, enqueue_copy_buffer_rect, enqueue_read_image,
enqueue_write_image, enqueue_fill_image, enqueue_copy_image, enqueue_copy_image_to_buffer,
enqueue_copy_buffer_to_image, enqueue_map_buffer, enqueue_map_image, enqueue_unmap_mem_object,
enqueue_migrate_mem_objects, enqueue_kernel, enqueue_task, enqueue_native_kernel,
enqueue_marker_with_wait_list, enqueue_barrier_with_wait_list,
get_extension_function_address_for_platform, wait_for_event, event_status,
default_platform_idx, program_build_err, verify_context, default_platform, default_device_type,
device_versions, event_is_complete, _dummy_event_callback, _complete_user_event,
get_context_platform};
pub use traits::{OclPrm, OclNum, OclScl};
#[cfg(feature = "ocl-core-vector")]
pub use self::vector::{
Char, Char2, Char3, Char4, Char8, Char16,
Uchar, Uchar2, Uchar3, Uchar4, Uchar8, Uchar16,
Short, Short2, Short3, Short4, Short8, Short16,
Ushort, Ushort2, Ushort3, Ushort4, Ushort8, Ushort16,
Int, Int2, Int3, Int4, Int8, Int16,
Uint, Uint2, Uint3, Uint4, Uint8, Uint16,
Long, Long2, Long3, Long4, Long8, Long16,
Ulong, Ulong2, Ulong3, Ulong4, Ulong8, Ulong16,
Float, Float2, Float3, Float4, Float8, Float16,
Double, Double2, Double3, Double4, Double8, Double16,
};
#[cfg(feature = "ocl-core-vector")]
pub use traits::OclVec;
#[cfg(feature = "opencl_version_2_1")]
pub use self::functions::{create_program_with_il};
pub const DEVICES_MAX: u32 = 64;
pub type EventCallbackFn = extern "C" fn (ffi::cl_event, i32, *mut libc::c_void);
pub type CreateContextCallbackFn = extern "C" fn (*const libc::c_char, *const libc::c_void,
libc::size_t, *mut libc::c_void);
pub type BuildProgramCallbackFn = extern "C" fn (*mut libc::c_void, *mut libc::c_void);
pub type UserDataPtr = *mut libc::c_void;
mod traits {
use std::fmt::{Display, Debug};
use std::ops::*;
use std::iter::{Sum, Product};
use num::{NumCast, FromPrimitive, ToPrimitive, Zero, One};
use rand::distributions::range::SampleRange;
macro_rules! impl_unsafe {
($trt:ident: $( $ty:ident ),+) => {
$( unsafe impl $trt for $ty {} )+
}
}
#[cfg(feature = "ocl-core-vector")]
pub use self::ocl_vec::OclVec;
pub unsafe trait OclPrm: Debug + Clone + Copy + Default + PartialEq + 'static {}
impl_unsafe!(OclPrm: u8, i8, u16, i16, u32, i32, u64, i64, usize, isize, f32, f64);
pub unsafe trait OclNum: Debug + Display + Clone + Copy + Default + PartialOrd +
Zero<Output=Self> + One<Output=Self> + Add<Self, Output=Self> + Sub<Self, Output=Self> +
Mul<Self, Output=Self> + Div<Self, Output=Self> + Rem<Self, Output=Self> + PartialEq<Self>
+ AddAssign<Self> + SubAssign<Self> + MulAssign<Self> + DivAssign<Self> + RemAssign<Self> +
Sum<Self> + Product<Self> + 'static {}
impl_unsafe!(OclNum: u8, i8, u16, i16, u32, i32, u64, i64, usize, isize, f32, f64);
pub unsafe trait OclScl: OclPrm + OclNum + NumCast + FromPrimitive + ToPrimitive +
SampleRange {}
impl_unsafe!(OclScl: u8, i8, u16, i16, u32, i32, u64, i64, usize, isize, f32, f64);
#[cfg(feature = "ocl-core-vector")]
mod ocl_vec {
use traits::{OclPrm, OclNum};
pub unsafe trait OclVec: OclPrm + OclNum {}
use vector::{
Char, Char2, Char3, Char4, Char8, Char16,
Uchar, Uchar2, Uchar3, Uchar4, Uchar8, Uchar16,
Short, Short2, Short3, Short4, Short8, Short16,
Ushort, Ushort2, Ushort3, Ushort4, Ushort8, Ushort16,
Int, Int2, Int3, Int4, Int8, Int16,
Uint, Uint2, Uint3, Uint4, Uint8, Uint16,
Long, Long2, Long3, Long4, Long8, Long16,
Ulong, Ulong2, Ulong3, Ulong4, Ulong8, Ulong16,
Float, Float2, Float3, Float4, Float8, Float16,
Double, Double2, Double3, Double4, Double8, Double16
};
impl_unsafe!(OclNum:
Char, Char2, Char3, Char4, Char8, Char16,
Uchar, Uchar2, Uchar3, Uchar4, Uchar8, Uchar16,
Short, Short2, Short3, Short4, Short8, Short16,
Ushort, Ushort2, Ushort3, Ushort4, Ushort8, Ushort16,
Int, Int2, Int3, Int4, Int8, Int16,
Uint, Uint2, Uint3, Uint4, Uint8, Uint16,
Long, Long2, Long3, Long4, Long8, Long16,
Ulong, Ulong2, Ulong3, Ulong4, Ulong8, Ulong16,
Float, Float2, Float3, Float4, Float8, Float16,
Double, Double2, Double3, Double4, Double8, Double16
);
impl_unsafe!(OclPrm:
Char, Char2, Char3, Char4, Char8, Char16,
Uchar, Uchar2, Uchar3, Uchar4, Uchar8, Uchar16,
Short, Short2, Short3, Short4, Short8, Short16,
Ushort, Ushort2, Ushort3, Ushort4, Ushort8, Ushort16,
Int, Int2, Int3, Int4, Int8, Int16,
Uint, Uint2, Uint3, Uint4, Uint8, Uint16,
Long, Long2, Long3, Long4, Long8, Long16,
Ulong, Ulong2, Ulong3, Ulong4, Ulong8, Ulong16,
Float, Float2, Float3, Float4, Float8, Float16,
Double, Double2, Double3, Double4, Double8, Double16
);
impl_unsafe!(OclVec:
Char, Char2, Char3, Char4, Char8, Char16,
Uchar, Uchar2, Uchar3, Uchar4, Uchar8, Uchar16,
Short, Short2, Short3, Short4, Short8, Short16,
Ushort, Ushort2, Ushort3, Ushort4, Ushort8, Ushort16,
Int, Int2, Int3, Int4, Int8, Int16,
Uint, Uint2, Uint3, Uint4, Uint8, Uint16,
Long, Long2, Long3, Long4, Long8, Long16,
Ulong, Ulong2, Ulong3, Ulong4, Ulong8, Ulong16,
Float, Float2, Float3, Float4, Float8, Float16,
Double, Double2, Double3, Double4, Double8, Double16
);
}
}
bitflags! {
pub flags DeviceType: u64 {
const DEVICE_TYPE_DEFAULT = 1 << 0,
const DEVICE_TYPE_CPU = 1 << 1,
const DEVICE_TYPE_GPU = 1 << 2,
const DEVICE_TYPE_ACCELERATOR = 1 << 3,
const DEVICE_TYPE_CUSTOM = 1 << 4,
const DEVICE_TYPE_ALL = 0xFFFFFFFF,
}
}
impl DeviceType {
#[inline] pub fn new() -> DeviceType { DeviceType::empty() }
#[inline] pub fn system_default(self) -> DeviceType { self | DEVICE_TYPE_DEFAULT }
#[inline] pub fn cpu(self) -> DeviceType { self | DEVICE_TYPE_CPU }
#[inline] pub fn gpu(self) -> DeviceType { self | DEVICE_TYPE_GPU }
#[inline] pub fn accelerator(self) -> DeviceType { self | DEVICE_TYPE_ACCELERATOR }
#[inline] pub fn custom(self) -> DeviceType { self | DEVICE_TYPE_CUSTOM }
}
impl Default for DeviceType {
#[inline] fn default() -> DeviceType { DEVICE_TYPE_ALL }
}
bitflags! {
pub flags DeviceFpConfig: u64 {
const FP_DENORM = 1 << 0,
const FP_INF_NAN = 1 << 1,
const FP_ROUND_TO_NEAREST = 1 << 2,
const FP_ROUND_TO_ZERO = 1 << 3,
const FP_ROUND_TO_INF = 1 << 4,
const FP_FMA = 1 << 5,
const FP_SOFT_FLOAT = 1 << 6,
const FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = 1 << 7,
}
}
bitflags! {
pub flags DeviceExecCapabilities: u64 {
const EXEC_KERNEL = 1 << 0,
const EXEC_NATIVE_KERNEL = 1 << 1,
}
}
bitflags! {
pub flags CommandQueueProperties: u64 {
const QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = 1 << 0,
const QUEUE_PROFILING_ENABLE = 1 << 1,
const QUEUE_ON_DEVICE = 1 << 2,
const QUEUE_ON_DEVICE_DEFAULT = 1 << 3,
}
}
impl CommandQueueProperties {
#[inline] pub fn new() -> CommandQueueProperties { CommandQueueProperties::empty() }
#[inline] pub fn out_of_order(self) -> CommandQueueProperties { self | QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE }
#[inline] pub fn profiling(self) -> CommandQueueProperties { self | QUEUE_PROFILING_ENABLE }
}
impl Default for CommandQueueProperties {
#[inline] fn default() -> CommandQueueProperties { CommandQueueProperties::empty() }
}
bitflags! {
pub flags DeviceAffinityDomain: u64 {
const DEVICE_AFFINITY_DOMAIN_NUMA = 1 << 0,
const DEVICE_AFFINITY_DOMAIN_L4_CACHE = 1 << 1,
const DEVICE_AFFINITY_DOMAIN_L3_CACHE = 1 << 2,
const DEVICE_AFFINITY_DOMAIN_L2_CACHE = 1 << 3,
const DEVICE_AFFINITY_DOMAIN_L1_CACHE = 1 << 4,
const DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = 1 << 5,
}
}
bitflags! {
pub flags MemFlags: u64 {
const MEM_READ_WRITE = 1 << 0,
const MEM_WRITE_ONLY = 1 << 1,
const MEM_READ_ONLY = 1 << 2,
const MEM_USE_HOST_PTR = 1 << 3,
const MEM_ALLOC_HOST_PTR = 1 << 4,
const MEM_COPY_HOST_PTR = 1 << 5,
const MEM_HOST_WRITE_ONLY = 1 << 7,
const MEM_HOST_READ_ONLY = 1 << 8,
const MEM_HOST_NO_ACCESS = 1 << 9,
}
}
impl MemFlags {
#[inline] pub fn new() -> MemFlags { MemFlags::empty() }
#[inline] pub fn read_write(self) -> MemFlags { self | MEM_READ_WRITE }
#[inline] pub fn write_only(self) -> MemFlags { self | MEM_WRITE_ONLY }
#[inline] pub fn read_only(self) -> MemFlags { self | MEM_READ_ONLY }
#[inline] pub fn use_host_ptr(self) -> MemFlags { self | MEM_USE_HOST_PTR }
#[inline] pub fn alloc_host_ptr(self) -> MemFlags { self | MEM_ALLOC_HOST_PTR }
#[inline] pub fn copy_host_ptr(self) -> MemFlags { self | MEM_COPY_HOST_PTR }
#[inline] pub fn host_write_only(self) -> MemFlags { self | MEM_HOST_WRITE_ONLY }
#[inline] pub fn host_read_only(self) -> MemFlags { self | MEM_HOST_READ_ONLY }
#[inline] pub fn host_no_access(self) -> MemFlags { self | MEM_HOST_NO_ACCESS }
}
impl Default for MemFlags {
#[inline] fn default() -> MemFlags { MEM_READ_WRITE }
}
bitflags! {
pub flags MemMigrationFlags: u64 {
const MIGRATE_MEM_OBJECT_HOST = 1 << 0,
const MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = 1 << 1,
}
}
bitflags! {
pub flags MapFlags: u64 {
const MAP_READ = 1 << 0,
const MAP_WRITE = 1 << 1,
const MAP_WRITE_INVALIDATE_REGION = 1 << 2,
}
}
impl MapFlags {
#[inline] pub fn new() -> MapFlags { MapFlags::empty() }
#[inline] pub fn read(self) -> MapFlags { self | MAP_READ }
#[inline] pub fn write(self) -> MapFlags { self | MAP_WRITE }
#[inline] pub fn write_invalidate_region(self) -> MapFlags { self | MAP_WRITE_INVALIDATE_REGION }
}
impl Default for MapFlags {
#[inline] fn default() -> MapFlags { MapFlags::empty() }
}
bitflags! {
pub flags ProgramBinaryType: u32 {
const PROGRAM_BINARY_TYPE_NONE = 0x0,
const PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1,
const PROGRAM_BINARY_TYPE_LIBRARY = 0x2,
const PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4,
}
}
bitflags! {
pub flags KernelArgTypeQualifier: u64 {
const KERNEL_ARG_TYPE_NONE = 0,
const KERNEL_ARG_TYPE_CONST = 1 << 0,
const KERNEL_ARG_TYPE_RESTRICT = 1 << 1,
const KERNEL_ARG_TYPE_VOLATILE = 1 << 2,
}
}
enum_from_primitive! {
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Debug, PartialEq, Clone)]
pub enum Status {
CL_SUCCESS = 0,
CL_DEVICE_NOT_FOUND = -1,
CL_DEVICE_NOT_AVAILABLE = -2,
CL_COMPILER_NOT_AVAILABLE = -3,
CL_MEM_OBJECT_ALLOCATION_FAILURE = -4,
CL_OUT_OF_RESOURCES = -5,
CL_OUT_OF_HOST_MEMORY = -6,
CL_PROFILING_INFO_NOT_AVAILABLE = -7,
CL_MEM_COPY_OVERLAP = -8,
CL_IMAGE_FORMAT_MISMATCH = -9,
CL_IMAGE_FORMAT_NOT_SUPPORTED = -10,
CL_BUILD_PROGRAM_FAILURE = -11,
CL_MAP_FAILURE = -12,
CL_MISALIGNED_SUB_BUFFER_OFFSET = -13,
CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14,
CL_COMPILE_PROGRAM_FAILURE = -15,
CL_LINKER_NOT_AVAILABLE = -16,
CL_LINK_PROGRAM_FAILURE = -17,
CL_DEVICE_PARTITION_FAILED = -18,
CL_KERNEL_ARG_INFO_NOT_AVAILABLE = -19,
CL_INVALID_VALUE = -30,
CL_INVALID_DEVICE_TYPE = -31,
CL_INVALID_PLATFORM = -32,
CL_INVALID_DEVICE = -33,
CL_INVALID_CONTEXT = -34,
CL_INVALID_QUEUE_PROPERTIES = -35,
CL_INVALID_COMMAND_QUEUE = -36,
CL_INVALID_HOST_PTR = -37,
CL_INVALID_MEM_OBJECT = -38,
CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39,
CL_INVALID_IMAGE_SIZE = -40,
CL_INVALID_SAMPLER = -41,
CL_INVALID_BINARY = -42,
CL_INVALID_BUILD_OPTIONS = -43,
CL_INVALID_PROGRAM = -44,
CL_INVALID_PROGRAM_EXECUTABLE = -45,
CL_INVALID_KERNEL_NAME = -46,
CL_INVALID_KERNEL_DEFINITION = -47,
CL_INVALID_KERNEL = -48,
CL_INVALID_ARG_INDEX = -49,
CL_INVALID_ARG_VALUE = -50,
CL_INVALID_ARG_SIZE = -51,
CL_INVALID_KERNEL_ARGS = -52,
CL_INVALID_WORK_DIMENSION = -53,
CL_INVALID_WORK_GROUP_SIZE = -54,
CL_INVALID_WORK_ITEM_SIZE = -55,
CL_INVALID_GLOBAL_OFFSET = -56,
CL_INVALID_EVENT_WAIT_LIST = -57,
CL_INVALID_EVENT = -58,
CL_INVALID_OPERATION = -59,
CL_INVALID_GL_OBJECT = -60,
CL_INVALID_BUFFER_SIZE = -61,
CL_INVALID_MIP_LEVEL = -62,
CL_INVALID_GLOBAL_WORK_SIZE = -63,
CL_INVALID_PROPERTY = -64,
CL_INVALID_IMAGE_DESCRIPTOR = -65,
CL_INVALID_COMPILER_OPTIONS = -66,
CL_INVALID_LINKER_OPTIONS = -67,
CL_INVALID_DEVICE_PARTITION_COUNT = -68,
CL_INVALID_PIPE_SIZE = -69,
CL_INVALID_DEVICE_QUEUE = -70,
CL_PLATFORM_NOT_FOUND_KHR = -1001,
CL_NV_INVALID_MEM_ACCESS = -9999,
}
}
impl std::fmt::Display for Status {
fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(fmtr, "{:?}", self)
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GlTextureTarget {
GlTexture1d = ffi::GL_TEXTURE_1D as isize,
GlTexture1dArray = ffi::GL_TEXTURE_1D_ARRAY as isize,
GlTextureBuffer = ffi::GL_TEXTURE_BUFFER as isize,
GlTexture2d = ffi::GL_TEXTURE_2D as isize,
GlTexture2dArray = ffi::GL_TEXTURE_2D_ARRAY as isize,
GlTexture3d = ffi::GL_TEXTURE_3D as isize,
GlTextureCubeMapPositiveX = ffi::GL_TEXTURE_CUBE_MAP_POSITIVE_X as isize,
GlTextureCubeMapPositiveY = ffi::GL_TEXTURE_CUBE_MAP_POSITIVE_Y as isize,
GlTextureCubeMapPositiveZ = ffi::GL_TEXTURE_CUBE_MAP_POSITIVE_Z as isize,
GlTextureCubeMapNegativeX = ffi::GL_TEXTURE_CUBE_MAP_NEGATIVE_X as isize,
GlTextureCubeMapNegativeY = ffi::GL_TEXTURE_CUBE_MAP_NEGATIVE_Y as isize,
GlTextureCubeMapNegativeZ = ffi::GL_TEXTURE_CUBE_MAP_NEGATIVE_Z as isize,
GlTextureRectangle = ffi::GL_TEXTURE_RECTANGLE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Debug, PartialEq, Clone)]
pub enum ClGlObjectType {
ClGlObjectBuffer = ffi::CL_GL_OBJECT_BUFFER as isize,
ClGlObjectTexture2D = ffi::CL_GL_OBJECT_TEXTURE2D as isize,
ClGlObjectTexture3D = ffi::CL_GL_OBJECT_TEXTURE3D as isize,
ClGlObjectRenderbuffer = ffi::CL_GL_OBJECT_RENDERBUFFER as isize,
ClGlObjectTexture2DArray = ffi::CL_GL_OBJECT_TEXTURE2D_ARRAY as isize,
ClGlObjectTexture1D = ffi::CL_GL_OBJECT_TEXTURE1D as isize,
ClGlObjectTexture1DArray = ffi::CL_GL_OBJECT_TEXTURE1D_ARRAY as isize,
ClGlObjectTextureBuffer = ffi::CL_GL_OBJECT_TEXTURE_BUFFER as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ImageChannelOrder {
R = ffi::CL_R as isize,
A = ffi::CL_A as isize,
Rg = ffi::CL_RG as isize,
Ra = ffi::CL_RA as isize,
Rgb = ffi::CL_RGB as isize,
Rgba = ffi::CL_RGBA as isize,
Bgra = ffi::CL_BGRA as isize,
Argb = ffi::CL_ARGB as isize,
Intensity = ffi::CL_INTENSITY as isize,
Luminance = ffi::CL_LUMINANCE as isize,
Rx = ffi::CL_Rx as isize,
Rgx = ffi::CL_RGx as isize,
Rgbx = ffi::CL_RGBx as isize,
Depth = ffi::CL_DEPTH as isize,
DepthStencil = ffi::CL_DEPTH_STENCIL as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ImageChannelDataType {
SnormInt8 = ffi::CL_SNORM_INT8 as isize,
SnormInt16 = ffi::CL_SNORM_INT16 as isize,
UnormInt8 = ffi::CL_UNORM_INT8 as isize,
UnormInt16 = ffi::CL_UNORM_INT16 as isize,
UnormShort565 = ffi::CL_UNORM_SHORT_565 as isize,
UnormShort555 = ffi::CL_UNORM_SHORT_555 as isize,
UnormInt101010 = ffi::CL_UNORM_INT_101010 as isize,
SignedInt8 = ffi::CL_SIGNED_INT8 as isize,
SignedInt16 = ffi::CL_SIGNED_INT16 as isize,
SignedInt32 = ffi::CL_SIGNED_INT32 as isize,
UnsignedInt8 = ffi::CL_UNSIGNED_INT8 as isize,
UnsignedInt16 = ffi::CL_UNSIGNED_INT16 as isize,
UnsignedInt32 = ffi::CL_UNSIGNED_INT32 as isize,
HalfFloat = ffi::CL_HALF_FLOAT as isize,
Float = ffi::CL_FLOAT as isize,
UnormInt24 = ffi::CL_UNORM_INT24 as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Cbool {
False = ffi::CL_FALSE as isize,
True = ffi::CL_TRUE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Polling {
Blocking = ffi::CL_BLOCKING as isize,
NonBlocking = ffi::CL_NON_BLOCKING as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PlatformInfo {
Profile = ffi::CL_PLATFORM_PROFILE as isize,
Version = ffi::CL_PLATFORM_VERSION as isize,
Name = ffi::CL_PLATFORM_NAME as isize,
Vendor = ffi::CL_PLATFORM_VENDOR as isize,
Extensions = ffi::CL_PLATFORM_EXTENSIONS as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DeviceInfo {
Type = ffi::CL_DEVICE_TYPE as isize,
VendorId = ffi::CL_DEVICE_VENDOR_ID as isize,
MaxComputeUnits = ffi::CL_DEVICE_MAX_COMPUTE_UNITS as isize,
MaxWorkItemDimensions = ffi::CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS as isize,
MaxWorkGroupSize = ffi::CL_DEVICE_MAX_WORK_GROUP_SIZE as isize,
MaxWorkItemSizes = ffi::CL_DEVICE_MAX_WORK_ITEM_SIZES as isize,
PreferredVectorWidthChar = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR as isize,
PreferredVectorWidthShort = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT as isize,
PreferredVectorWidthInt = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT as isize,
PreferredVectorWidthLong = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG as isize,
PreferredVectorWidthFloat = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT as isize,
PreferredVectorWidthDouble = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE as isize,
MaxClockFrequency = ffi::CL_DEVICE_MAX_CLOCK_FREQUENCY as isize,
AddressBits = ffi::CL_DEVICE_ADDRESS_BITS as isize,
MaxReadImageArgs = ffi::CL_DEVICE_MAX_READ_IMAGE_ARGS as isize,
MaxWriteImageArgs = ffi::CL_DEVICE_MAX_WRITE_IMAGE_ARGS as isize,
MaxMemAllocSize = ffi::CL_DEVICE_MAX_MEM_ALLOC_SIZE as isize,
Image2dMaxWidth = ffi::CL_DEVICE_IMAGE2D_MAX_WIDTH as isize,
Image2dMaxHeight = ffi::CL_DEVICE_IMAGE2D_MAX_HEIGHT as isize,
Image3dMaxWidth = ffi::CL_DEVICE_IMAGE3D_MAX_WIDTH as isize,
Image3dMaxHeight = ffi::CL_DEVICE_IMAGE3D_MAX_HEIGHT as isize,
Image3dMaxDepth = ffi::CL_DEVICE_IMAGE3D_MAX_DEPTH as isize,
ImageSupport = ffi::CL_DEVICE_IMAGE_SUPPORT as isize,
MaxParameterSize = ffi::CL_DEVICE_MAX_PARAMETER_SIZE as isize,
MaxSamplers = ffi::CL_DEVICE_MAX_SAMPLERS as isize,
MemBaseAddrAlign = ffi::CL_DEVICE_MEM_BASE_ADDR_ALIGN as isize,
MinDataTypeAlignSize = ffi::CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE as isize,
SingleFpConfig = ffi::CL_DEVICE_SINGLE_FP_CONFIG as isize,
GlobalMemCacheType = ffi::CL_DEVICE_GLOBAL_MEM_CACHE_TYPE as isize,
GlobalMemCachelineSize = ffi::CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE as isize,
GlobalMemCacheSize = ffi::CL_DEVICE_GLOBAL_MEM_CACHE_SIZE as isize,
GlobalMemSize = ffi::CL_DEVICE_GLOBAL_MEM_SIZE as isize,
MaxConstantBufferSize = ffi::CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE as isize,
MaxConstantArgs = ffi::CL_DEVICE_MAX_CONSTANT_ARGS as isize,
LocalMemType = ffi::CL_DEVICE_LOCAL_MEM_TYPE as isize,
LocalMemSize = ffi::CL_DEVICE_LOCAL_MEM_SIZE as isize,
ErrorCorrectionSupport = ffi::CL_DEVICE_ERROR_CORRECTION_SUPPORT as isize,
ProfilingTimerResolution = ffi::CL_DEVICE_PROFILING_TIMER_RESOLUTION as isize,
EndianLittle = ffi::CL_DEVICE_ENDIAN_LITTLE as isize,
Available = ffi::CL_DEVICE_AVAILABLE as isize,
CompilerAvailable = ffi::CL_DEVICE_COMPILER_AVAILABLE as isize,
ExecutionCapabilities = ffi::CL_DEVICE_EXECUTION_CAPABILITIES as isize,
QueueProperties = ffi::CL_DEVICE_QUEUE_PROPERTIES as isize,
Name = ffi::CL_DEVICE_NAME as isize,
Vendor = ffi::CL_DEVICE_VENDOR as isize,
DriverVersion = ffi::CL_DRIVER_VERSION as isize,
Profile = ffi::CL_DEVICE_PROFILE as isize,
Version = ffi::CL_DEVICE_VERSION as isize,
Extensions = ffi::CL_DEVICE_EXTENSIONS as isize,
Platform = ffi::CL_DEVICE_PLATFORM as isize,
DoubleFpConfig = ffi::CL_DEVICE_DOUBLE_FP_CONFIG as isize,
HalfFpConfig = ffi::CL_DEVICE_HALF_FP_CONFIG as isize,
PreferredVectorWidthHalf = ffi::CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF as isize,
HostUnifiedMemory = ffi::CL_DEVICE_HOST_UNIFIED_MEMORY as isize,
NativeVectorWidthChar = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR as isize,
NativeVectorWidthShort = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT as isize,
NativeVectorWidthInt = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_INT as isize,
NativeVectorWidthLong = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG as isize,
NativeVectorWidthFloat = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT as isize,
NativeVectorWidthDouble = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE as isize,
NativeVectorWidthHalf = ffi::CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF as isize,
OpenclCVersion = ffi::CL_DEVICE_OPENCL_C_VERSION as isize,
LinkerAvailable = ffi::CL_DEVICE_LINKER_AVAILABLE as isize,
BuiltInKernels = ffi::CL_DEVICE_BUILT_IN_KERNELS as isize,
ImageMaxBufferSize = ffi::CL_DEVICE_IMAGE_MAX_BUFFER_SIZE as isize,
ImageMaxArraySize = ffi::CL_DEVICE_IMAGE_MAX_ARRAY_SIZE as isize,
ParentDevice = ffi::CL_DEVICE_PARENT_DEVICE as isize,
PartitionMaxSubDevices = ffi::CL_DEVICE_PARTITION_MAX_SUB_DEVICES as isize,
PartitionProperties = ffi::CL_DEVICE_PARTITION_PROPERTIES as isize,
PartitionAffinityDomain = ffi::CL_DEVICE_PARTITION_AFFINITY_DOMAIN as isize,
PartitionType = ffi::CL_DEVICE_PARTITION_TYPE as isize,
ReferenceCount = ffi::CL_DEVICE_REFERENCE_COUNT as isize,
PreferredInteropUserSync = ffi::CL_DEVICE_PREFERRED_INTEROP_USER_SYNC as isize,
PrintfBufferSize = ffi::CL_DEVICE_PRINTF_BUFFER_SIZE as isize,
ImagePitchAlignment = ffi::CL_DEVICE_IMAGE_PITCH_ALIGNMENT as isize,
ImageBaseAddressAlignment = ffi::CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DeviceMemCacheType {
None = ffi::CL_NONE as isize,
ReadOnlyCache = ffi::CL_READ_ONLY_CACHE as isize,
ReadWriteCache = ffi::CL_READ_WRITE_CACHE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DeviceLocalMemType {
None = ffi::CL_NONE as isize,
Local = ffi::CL_LOCAL as isize,
Global = ffi::CL_GLOBAL as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ContextInfo {
ReferenceCount = ffi::CL_CONTEXT_REFERENCE_COUNT as isize,
Devices = ffi::CL_CONTEXT_DEVICES as isize,
Properties = ffi::CL_CONTEXT_PROPERTIES as isize,
NumDevices = ffi::CL_CONTEXT_NUM_DEVICES as isize,
}
}
#[cfg(target_os = "macos")]
const CL_CGL_SHAREGROUP_KHR_OS_SPECIFIC: isize = ffi::CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE;
#[cfg(not(target_os = "macos"))]
const CL_CGL_SHAREGROUP_KHR_OS_SPECIFIC: isize = ffi::CL_CGL_SHAREGROUP_KHR;
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ContextProperty {
Platform = ffi::CL_CONTEXT_PLATFORM as isize,
InteropUserSync = ffi::CL_CONTEXT_INTEROP_USER_SYNC as isize,
D3d10DeviceKhr = ffi::CL_CONTEXT_D3D10_DEVICE_KHR as isize,
GlContextKhr = ffi::CL_GL_CONTEXT_KHR as isize,
EglDisplayKhr = ffi::CL_EGL_DISPLAY_KHR as isize,
GlxDisplayKhr = ffi::CL_GLX_DISPLAY_KHR as isize,
CglSharegroupKhr = CL_CGL_SHAREGROUP_KHR_OS_SPECIFIC,
WglHdcKhr = ffi::CL_WGL_HDC_KHR as isize,
AdapterD3d9Khr = ffi::CL_CONTEXT_ADAPTER_D3D9_KHR as isize,
AdapterD3d9exKhr = ffi::CL_CONTEXT_ADAPTER_D3D9EX_KHR as isize,
AdapterDxvaKhr = ffi::CL_CONTEXT_ADAPTER_DXVA_KHR as isize,
D3d11DeviceKhr = ffi::CL_CONTEXT_D3D11_DEVICE_KHR as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ContextInfoOrPropertiesPointerType {
Platform = ffi::CL_CONTEXT_PLATFORM as isize,
InteropUserSync = ffi::CL_CONTEXT_INTEROP_USER_SYNC as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DevicePartitionProperty {
Equally = ffi::CL_DEVICE_PARTITION_EQUALLY as isize,
ByCounts = ffi::CL_DEVICE_PARTITION_BY_COUNTS as isize,
ByCountsListEnd = ffi::CL_DEVICE_PARTITION_BY_COUNTS_LIST_END as isize,
ByAffinityDomain = ffi::CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CommandQueueInfo {
Context = ffi::CL_QUEUE_CONTEXT as isize,
Device = ffi::CL_QUEUE_DEVICE as isize,
ReferenceCount = ffi::CL_QUEUE_REFERENCE_COUNT as isize,
Properties = ffi::CL_QUEUE_PROPERTIES as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ChannelType {
SnormInt8 = ffi::CL_SNORM_INT8 as isize,
SnormInt16 = ffi::CL_SNORM_INT16 as isize,
UnormInt8 = ffi::CL_UNORM_INT8 as isize,
UnormInt16 = ffi::CL_UNORM_INT16 as isize,
UnormShort565 = ffi::CL_UNORM_SHORT_565 as isize,
UnormShort555 = ffi::CL_UNORM_SHORT_555 as isize,
UnormInt101010 = ffi::CL_UNORM_INT_101010 as isize,
SignedInt8 = ffi::CL_SIGNED_INT8 as isize,
SignedInt16 = ffi::CL_SIGNED_INT16 as isize,
SignedInt32 = ffi::CL_SIGNED_INT32 as isize,
UnsignedInt8 = ffi::CL_UNSIGNED_INT8 as isize,
UnsignedInt16 = ffi::CL_UNSIGNED_INT16 as isize,
UnsignedInt32 = ffi::CL_UNSIGNED_INT32 as isize,
HalfFloat = ffi::CL_HALF_FLOAT as isize,
Float = ffi::CL_FLOAT as isize,
UnormInt24 = ffi::CL_UNORM_INT24 as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MemObjectType {
Buffer = ffi::CL_MEM_OBJECT_BUFFER as isize,
Image2d = ffi::CL_MEM_OBJECT_IMAGE2D as isize,
Image3d = ffi::CL_MEM_OBJECT_IMAGE3D as isize,
Image2dArray = ffi::CL_MEM_OBJECT_IMAGE2D_ARRAY as isize,
Image1d = ffi::CL_MEM_OBJECT_IMAGE1D as isize,
Image1dArray = ffi::CL_MEM_OBJECT_IMAGE1D_ARRAY as isize,
Image1dBuffer = ffi::CL_MEM_OBJECT_IMAGE1D_BUFFER as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MemInfo {
Type = ffi::CL_MEM_TYPE as isize,
Flags = ffi::CL_MEM_FLAGS as isize,
Size = ffi::CL_MEM_SIZE as isize,
HostPtr = ffi::CL_MEM_HOST_PTR as isize,
MapCount = ffi::CL_MEM_MAP_COUNT as isize,
ReferenceCount = ffi::CL_MEM_REFERENCE_COUNT as isize,
Context = ffi::CL_MEM_CONTEXT as isize,
AssociatedMemobject = ffi::CL_MEM_ASSOCIATED_MEMOBJECT as isize,
Offset = ffi::CL_MEM_OFFSET as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ImageInfo {
Format = ffi::CL_IMAGE_FORMAT as isize,
ElementSize = ffi::CL_IMAGE_ELEMENT_SIZE as isize,
RowPitch = ffi::CL_IMAGE_ROW_PITCH as isize,
SlicePitch = ffi::CL_IMAGE_SLICE_PITCH as isize,
Width = ffi::CL_IMAGE_WIDTH as isize,
Height = ffi::CL_IMAGE_HEIGHT as isize,
Depth = ffi::CL_IMAGE_DEPTH as isize,
ArraySize = ffi::CL_IMAGE_ARRAY_SIZE as isize,
Buffer = ffi::CL_IMAGE_BUFFER as isize,
NumMipLevels = ffi::CL_IMAGE_NUM_MIP_LEVELS as isize,
NumSamples = ffi::CL_IMAGE_NUM_SAMPLES as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum AddressingMode {
None = ffi::CL_ADDRESS_NONE as isize,
ClampToEdge = ffi::CL_ADDRESS_CLAMP_TO_EDGE as isize,
Clamp = ffi::CL_ADDRESS_CLAMP as isize,
Repeat = ffi::CL_ADDRESS_REPEAT as isize,
MirroredRepeat = ffi::CL_ADDRESS_MIRRORED_REPEAT as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum FilterMode {
Nearest = ffi::CL_FILTER_NEAREST as isize,
Linear = ffi::CL_FILTER_LINEAR as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SamplerInfo {
ReferenceCount = ffi::CL_SAMPLER_REFERENCE_COUNT as isize,
Context = ffi::CL_SAMPLER_CONTEXT as isize,
NormalizedCoords = ffi::CL_SAMPLER_NORMALIZED_COORDS as isize,
AddressingMode = ffi::CL_SAMPLER_ADDRESSING_MODE as isize,
FilterMode = ffi::CL_SAMPLER_FILTER_MODE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ProgramInfo {
ReferenceCount = ffi::CL_PROGRAM_REFERENCE_COUNT as isize,
Context = ffi::CL_PROGRAM_CONTEXT as isize,
NumDevices = ffi::CL_PROGRAM_NUM_DEVICES as isize,
Devices = ffi::CL_PROGRAM_DEVICES as isize,
Source = ffi::CL_PROGRAM_SOURCE as isize,
BinarySizes = ffi::CL_PROGRAM_BINARY_SIZES as isize,
Binaries = ffi::CL_PROGRAM_BINARIES as isize,
NumKernels = ffi::CL_PROGRAM_NUM_KERNELS as isize,
KernelNames = ffi::CL_PROGRAM_KERNEL_NAMES as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ProgramBuildInfo {
BuildStatus = ffi::CL_PROGRAM_BUILD_STATUS as isize,
BuildOptions = ffi::CL_PROGRAM_BUILD_OPTIONS as isize,
BuildLog = ffi::CL_PROGRAM_BUILD_LOG as isize,
BinaryType = ffi::CL_PROGRAM_BINARY_TYPE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ProgramBuildStatus {
Success = ffi::CL_BUILD_SUCCESS as isize,
None = ffi::CL_BUILD_NONE as isize,
Error = ffi::CL_BUILD_ERROR as isize,
InProgress = ffi::CL_BUILD_IN_PROGRESS as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum KernelInfo {
FunctionName = ffi::CL_KERNEL_FUNCTION_NAME as isize,
NumArgs = ffi::CL_KERNEL_NUM_ARGS as isize,
ReferenceCount = ffi::CL_KERNEL_REFERENCE_COUNT as isize,
Context = ffi::CL_KERNEL_CONTEXT as isize,
Program = ffi::CL_KERNEL_PROGRAM as isize,
Attributes = ffi::CL_KERNEL_ATTRIBUTES as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum KernelArgInfo {
AddressQualifier = ffi::CL_KERNEL_ARG_ADDRESS_QUALIFIER as isize,
AccessQualifier = ffi::CL_KERNEL_ARG_ACCESS_QUALIFIER as isize,
TypeName = ffi::CL_KERNEL_ARG_TYPE_NAME as isize,
TypeQualifier = ffi::CL_KERNEL_ARG_TYPE_QUALIFIER as isize,
Name = ffi::CL_KERNEL_ARG_NAME as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum KernelArgAddressQualifier {
Global = ffi::CL_KERNEL_ARG_ADDRESS_GLOBAL as isize,
Local = ffi::CL_KERNEL_ARG_ADDRESS_LOCAL as isize,
Constant = ffi::CL_KERNEL_ARG_ADDRESS_CONSTANT as isize,
Private = ffi::CL_KERNEL_ARG_ADDRESS_PRIVATE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum KernelArgAccessQualifier {
ReadOnly = ffi::CL_KERNEL_ARG_ACCESS_READ_ONLY as isize,
WriteOnly = ffi::CL_KERNEL_ARG_ACCESS_WRITE_ONLY as isize,
ReadWrite = ffi::CL_KERNEL_ARG_ACCESS_READ_WRITE as isize,
None = ffi::CL_KERNEL_ARG_ACCESS_NONE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum KernelWorkGroupInfo {
WorkGroupSize = ffi::CL_KERNEL_WORK_GROUP_SIZE as isize,
CompileWorkGroupSize = ffi::CL_KERNEL_COMPILE_WORK_GROUP_SIZE as isize,
LocalMemSize = ffi::CL_KERNEL_LOCAL_MEM_SIZE as isize,
PreferredWorkGroupSizeMultiple = ffi::CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE as isize,
PrivateMemSize = ffi::CL_KERNEL_PRIVATE_MEM_SIZE as isize,
GlobalWorkSize = ffi::CL_KERNEL_GLOBAL_WORK_SIZE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EventInfo {
CommandQueue = ffi::CL_EVENT_COMMAND_QUEUE as isize,
CommandType = ffi::CL_EVENT_COMMAND_TYPE as isize,
ReferenceCount = ffi::CL_EVENT_REFERENCE_COUNT as isize,
CommandExecutionStatus = ffi::CL_EVENT_COMMAND_EXECUTION_STATUS as isize,
Context = ffi::CL_EVENT_CONTEXT as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CommandType {
NdrangeKernel = ffi::CL_COMMAND_NDRANGE_KERNEL as isize,
Task = ffi::CL_COMMAND_TASK as isize,
NativeKernel = ffi::CL_COMMAND_NATIVE_KERNEL as isize,
ReadBuffer = ffi::CL_COMMAND_READ_BUFFER as isize,
WriteBuffer = ffi::CL_COMMAND_WRITE_BUFFER as isize,
CopyBuffer = ffi::CL_COMMAND_COPY_BUFFER as isize,
ReadImage = ffi::CL_COMMAND_READ_IMAGE as isize,
WriteImage = ffi::CL_COMMAND_WRITE_IMAGE as isize,
CopyImage = ffi::CL_COMMAND_COPY_IMAGE as isize,
CopyImageToBuffer = ffi::CL_COMMAND_COPY_IMAGE_TO_BUFFER as isize,
CopyBufferToImage = ffi::CL_COMMAND_COPY_BUFFER_TO_IMAGE as isize,
MapBuffer = ffi::CL_COMMAND_MAP_BUFFER as isize,
MapImage = ffi::CL_COMMAND_MAP_IMAGE as isize,
UnmapMemObject = ffi::CL_COMMAND_UNMAP_MEM_OBJECT as isize,
Marker = ffi::CL_COMMAND_MARKER as isize,
AcquireGlObjects = ffi::CL_COMMAND_ACQUIRE_GL_OBJECTS as isize,
ReleaseGlObjects = ffi::CL_COMMAND_RELEASE_GL_OBJECTS as isize,
ReadBufferRect = ffi::CL_COMMAND_READ_BUFFER_RECT as isize,
WriteBufferRect = ffi::CL_COMMAND_WRITE_BUFFER_RECT as isize,
CopyBufferRect = ffi::CL_COMMAND_COPY_BUFFER_RECT as isize,
User = ffi::CL_COMMAND_USER as isize,
Barrier = ffi::CL_COMMAND_BARRIER as isize,
MigrateMemObjects = ffi::CL_COMMAND_MIGRATE_MEM_OBJECTS as isize,
FillBuffer = ffi::CL_COMMAND_FILL_BUFFER as isize,
FillImage = ffi::CL_COMMAND_FILL_IMAGE as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CommandExecutionStatus {
Complete = ffi::CL_COMPLETE as isize,
Running = ffi::CL_RUNNING as isize,
Submitted = ffi::CL_SUBMITTED as isize,
Queued = ffi::CL_QUEUED as isize,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BufferCreateType {
Region = ffi::CL_BUFFER_CREATE_TYPE_REGION as isize,
__DUMMY,
}
}
enum_from_primitive! {
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ProfilingInfo {
Queued = ffi::CL_PROFILING_COMMAND_QUEUED as isize,
Submit = ffi::CL_PROFILING_COMMAND_SUBMIT as isize,
Start = ffi::CL_PROFILING_COMMAND_START as isize,
End = ffi::CL_PROFILING_COMMAND_END as isize,
}
}