parenchyma 0.0.33

A high-performance computing (HPC) framework
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
//! Provides the foreign function interface for OpenCL.

#![allow(dead_code, non_camel_case_types, non_snake_case, non_upper_case_globals)]
#![allow(missing_docs)]

use libc;
use std::fmt;
use std::os::raw;

/* Opaque types */
pub type cl_platform_id     = *mut raw::c_void;
pub type cl_device_id       = *mut raw::c_void;
pub type cl_context         = *mut raw::c_void;
pub type cl_command_queue   = *mut raw::c_void;
pub type cl_mem             = *mut raw::c_void;
pub type cl_program         = *mut raw::c_void;
pub type cl_kernel          = *mut raw::c_void;
pub type cl_event           = *mut raw::c_void;
pub type cl_sampler         = *mut raw::c_void;

/* Scalar types */
pub type cl_char    = i8;
pub type cl_uchar   = u8;
pub type cl_short   = i16;
pub type cl_ushort  = u16;
pub type cl_int     = i32;
pub type cl_uint    = u32;
pub type cl_long    = i64;
pub type cl_ulong   = u64;

pub type cl_half    = u16;
pub type cl_float   = f32;
pub type cl_double  = f64;

pub type cl_bool                        = cl_uint;
pub type cl_bitfield                    = cl_ulong;
pub type cl_device_type                 = cl_bitfield;
pub type cl_platform_info               = cl_uint;
pub type cl_device_info                 = cl_uint;
pub type cl_device_fp_config            = cl_bitfield;
pub type cl_device_mem_cache_type       = cl_uint;
pub type cl_device_local_mem_type       = cl_uint;
pub type cl_device_exec_capabilities    = cl_bitfield;
pub type cl_command_queue_properties    = cl_bitfield;

pub type cl_context_properties          = libc::intptr_t;
pub type cl_context_info                = cl_uint;
pub type cl_command_queue_info          = cl_uint;
pub type cl_channel_order               = cl_uint;
pub type cl_channel_type                = cl_uint;
pub type cl_mem_flags                   = cl_bitfield;
pub type cl_mem_object_type             = cl_uint;
pub type cl_mem_info                    = cl_uint;
pub type cl_image_info                  = cl_uint;
pub type cl_buffer_create_type          = cl_uint;
pub type cl_addressing_mode             = cl_uint;
pub type cl_filter_mode                 = cl_uint;
pub type cl_sampler_info                = cl_uint;
pub type cl_map_flags                   = cl_bitfield;
pub type cl_program_info                = cl_uint;
pub type cl_program_build_info          = cl_uint;
pub type cl_build_status                = cl_int;
pub type cl_kernel_info                 = cl_uint;
pub type cl_kernel_work_group_info      = cl_uint;
pub type cl_event_info                  = cl_uint;
pub type cl_command_type                = cl_uint;
pub type cl_profiling_info              = cl_uint;

#[derive(Debug)]
#[repr(C)]
pub struct cl_image_format {
    image_channel_order:        cl_channel_order,
    image_channel_data_type:    cl_channel_type
}

#[derive(Debug)]
pub struct cl_buffer_region {
    origin:     libc::size_t,
    size:       libc::size_t
}


enum_from_primitive! {
/// OpenCL error codes.
#[derive(PartialEq, Debug)]
#[repr(C)]
pub enum CLStatus {
    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_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_PLATFORM_NOT_FOUND_KHR = -1001,
}
}

impl CLStatus {

    pub fn new(n: i32) -> Option<Self> {
        use enum_primitive::FromPrimitive;
        Self::from_i32(n)
    }
}

impl fmt::Display for CLStatus {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{:?}", self)
    }
}

/* OpenCL Version */
pub static CL_VERSION_1_0:                               cl_bool = 1;
pub static CL_VERSION_1_1:                               cl_bool = 1;

/* cl_bool */
pub static CL_FALSE:                                     cl_bool = 0;
pub static CL_TRUE:                                      cl_bool = 1;

/* cl_platform_info */
pub static CL_PLATFORM_PROFILE:                          cl_uint = 0x0900;
pub static CL_PLATFORM_VERSION:                          cl_uint = 0x0901;
pub static CL_PLATFORM_NAME:                             cl_uint = 0x0902;
pub static CL_PLATFORM_VENDOR:                           cl_uint = 0x0903;
pub static CL_PLATFORM_EXTENSIONS:                       cl_uint = 0x0904;

/* cl_device_type - bitfield */
pub const CL_DEVICE_TYPE_DEFAULT:                       cl_bitfield = 1 << 0;
pub const CL_DEVICE_TYPE_CPU:                           cl_bitfield = 1 << 1;
pub const CL_DEVICE_TYPE_GPU:                           cl_bitfield = 1 << 2;
pub const CL_DEVICE_TYPE_ACCELERATOR:                   cl_bitfield = 1 << 3;
pub const CL_DEVICE_TYPE_CUSTOM:                        cl_bitfield = 1 << 4;
pub const CL_DEVICE_TYPE_ALL:                           cl_bitfield = 0xFFFFFFFF;

/* cl_device_info */
pub static CL_DEVICE_TYPE:                               cl_uint = 0x1000;
pub static CL_DEVICE_VENDOR_ID:                          cl_uint = 0x1001;
pub static CL_DEVICE_MAX_COMPUTE_UNITS:                  cl_uint = 0x1002;
pub static CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:           cl_uint = 0x1003;
pub static CL_DEVICE_MAX_WORK_GROUP_SIZE:                cl_uint = 0x1004;
pub static CL_DEVICE_MAX_WORK_ITEM_SIZES:                cl_uint = 0x1005;
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR:        cl_uint = 0x1006;
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT:       cl_uint = 0x1007;
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT:         cl_uint = 0x1008;
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG:        cl_uint = 0x1009;
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT:       cl_uint = 0x100A;
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:      cl_uint = 0x100B;
pub static CL_DEVICE_MAX_CLOCK_FREQUENCY:                cl_uint = 0x100C;
pub static CL_DEVICE_ADDRESS_BITS:                       cl_uint = 0x100D;
pub static CL_DEVICE_MAX_READ_IMAGE_ARGS:                cl_uint = 0x100E;
pub static CL_DEVICE_MAX_WRITE_IMAGE_ARGS:               cl_uint = 0x100F;
pub static CL_DEVICE_MAX_MEM_ALLOC_SIZE:                 cl_uint = 0x1010;
pub static CL_DEVICE_IMAGE2D_MAX_WIDTH:                  cl_uint = 0x1011;
pub static CL_DEVICE_IMAGE2D_MAX_HEIGHT:                 cl_uint = 0x1012;
pub static CL_DEVICE_IMAGE3D_MAX_WIDTH:                  cl_uint = 0x1013;
pub static CL_DEVICE_IMAGE3D_MAX_HEIGHT:                 cl_uint = 0x1014;
pub static CL_DEVICE_IMAGE3D_MAX_DEPTH:                  cl_uint = 0x1015;
pub static CL_DEVICE_IMAGE_SUPPORT:                      cl_uint = 0x1016;
pub static CL_DEVICE_MAX_PARAMETER_SIZE:                 cl_uint = 0x1017;
pub static CL_DEVICE_MAX_SAMPLERS:                       cl_uint = 0x1018;
pub static CL_DEVICE_MEM_BASE_ADDR_ALIGN:                cl_uint = 0x1019;
pub static CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE:           cl_uint = 0x101A;
pub static CL_DEVICE_SINGLE_FP_CONFIG:                   cl_uint = 0x101B;
pub static CL_DEVICE_GLOBAL_MEM_CACHE_TYPE:              cl_uint = 0x101C;
pub static CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE:          cl_uint = 0x101D;
pub static CL_DEVICE_GLOBAL_MEM_CACHE_SIZE:              cl_uint = 0x101E;
pub static CL_DEVICE_GLOBAL_MEM_SIZE:                    cl_uint = 0x101F;
pub static CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:           cl_uint = 0x1020;
pub static CL_DEVICE_MAX_CONSTANT_ARGS:                  cl_uint = 0x1021;
pub static CL_DEVICE_LOCAL_MEM_TYPE:                     cl_uint = 0x1022;
pub static CL_DEVICE_LOCAL_MEM_SIZE:                     cl_uint = 0x1023;
pub static CL_DEVICE_ERROR_CORRECTION_SUPPORT:           cl_uint = 0x1024;
pub static CL_DEVICE_PROFILING_TIMER_RESOLUTION:         cl_uint = 0x1025;
pub static CL_DEVICE_ENDIAN_LITTLE:                      cl_uint = 0x1026;
pub static CL_DEVICE_AVAILABLE:                          cl_uint = 0x1027;
pub static CL_DEVICE_COMPILER_AVAILABLE:                 cl_uint = 0x1028;
pub static CL_DEVICE_EXECUTION_CAPABILITIES:             cl_uint = 0x1029;
pub static CL_DEVICE_QUEUE_PROPERTIES:                   cl_uint = 0x102A;
pub static CL_DEVICE_NAME:                               cl_uint = 0x102B;
pub static CL_DEVICE_VENDOR:                             cl_uint = 0x102C;
pub static CL_DRIVER_VERSION:                            cl_uint = 0x102D;
pub static CL_DEVICE_PROFILE:                            cl_uint = 0x102E;
pub static CL_DEVICE_VERSION:                            cl_uint = 0x102F;
pub static CL_DEVICE_EXTENSIONS:                         cl_uint = 0x1030;
pub static CL_DEVICE_PLATFORM:                           cl_uint = 0x1031;
/* 0x1032 reserved for CL_DEVICE_DOUBLE_FP_CONFIG */
/* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */
pub static CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:        cl_uint = 0x1034;
pub static CL_DEVICE_HOST_UNIFIED_MEMORY:                cl_uint = 0x1035;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR:           cl_uint = 0x1036;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT:          cl_uint = 0x1037;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_INT:            cl_uint = 0x1038;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG:           cl_uint = 0x1039;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT:          cl_uint = 0x103A;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:         cl_uint = 0x103B;
pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:           cl_uint = 0x103C;
pub static CL_DEVICE_OPENCL_C_VERSION:                   cl_uint = 0x103D;

/* cl_device_fp_config - bitfield */
pub static CL_FP_DENORM:                                 cl_bitfield = 1 << 0;
pub static CL_FP_INF_NAN:                                cl_bitfield = 1 << 1;
pub static CL_FP_ROUND_TO_NEAREST:                       cl_bitfield = 1 << 2;
pub static CL_FP_ROUND_TO_ZERO:                          cl_bitfield = 1 << 3;
pub static CL_FP_ROUND_TO_INF:                           cl_bitfield = 1 << 4;
pub static CL_FP_FMA:                                    cl_bitfield = 1 << 5;
pub static CL_FP_SOFT_FLOAT:                             cl_bitfield = 1 << 6;

/* cl_device_mem_cache_type */
pub static CL_NONE:                                      cl_uint = 0x0;
pub static CL_READ_ONLY_CACHE:                           cl_uint = 0x1;
pub static CL_READ_WRITE_CACHE:                          cl_uint = 0x2;

/* cl_device_local_mem_type */
pub static CL_LOCAL:                                     cl_uint = 0x1;
pub static CL_GLOBAL:                                    cl_uint = 0x2;

/* cl_device_exec_capabilities - bitfield */
pub static CL_EXEC_KERNEL:                               cl_bitfield = 1 << 0;
pub static CL_EXEC_NATIVE_KERNEL:                        cl_bitfield = 1 << 1;

/* cl_command_queue_properties - bitfield */
pub static CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE:       cl_bitfield = 1 << 0;
pub static CL_QUEUE_PROFILING_ENABLE:                    cl_bitfield = 1 << 1;

/* cl_context_info  */
pub static CL_CONTEXT_REFERENCE_COUNT:                   cl_uint = 0x1080;
pub static CL_CONTEXT_DEVICES:                           cl_uint = 0x1081;
pub static CL_CONTEXT_PROPERTIES:                        cl_uint = 0x1082;
pub static CL_CONTEXT_NUM_DEVICES:                       cl_uint = 0x1083;

/* cl_context_info + cl_context_properties */
pub static CL_CONTEXT_PLATFORM:                          libc::intptr_t = 0x1084;

/* cl_command_queue_info */
pub static CL_QUEUE_CONTEXT:                             cl_uint = 0x1090;
pub static CL_QUEUE_DEVICE:                              cl_uint = 0x1091;
pub static CL_QUEUE_REFERENCE_COUNT:                     cl_uint = 0x1092;
pub static CL_QUEUE_PROPERTIES:                          cl_uint = 0x1093;

/* cl_mem_flags - bitfield */
pub static CL_MEM_READ_WRITE:                            cl_bitfield = 1 << 0;
pub static CL_MEM_WRITE_ONLY:                            cl_bitfield = 1 << 1;
pub static CL_MEM_READ_ONLY:                             cl_bitfield = 1 << 2;
pub static CL_MEM_USE_HOST_PTR:                          cl_bitfield = 1 << 3;
pub static CL_MEM_ALLOC_HOST_PTR:                        cl_bitfield = 1 << 4;
pub static CL_MEM_COPY_HOST_PTR:                         cl_bitfield = 1 << 5;

/* cl_channel_order */
pub static CL_R:                                         cl_uint = 0x10B0;
pub static CL_A:                                         cl_uint = 0x10B1;
pub static CL_RG:                                        cl_uint = 0x10B2;
pub static CL_RA:                                        cl_uint = 0x10B3;
pub static CL_RGB:                                       cl_uint = 0x10B4;
pub static CL_RGBA:                                      cl_uint = 0x10B5;
pub static CL_BGRA:                                      cl_uint = 0x10B6;
pub static CL_ARGB:                                      cl_uint = 0x10B7;
pub static CL_INTENSITY:                                 cl_uint = 0x10B8;
pub static CL_LUMINANCE:                                 cl_uint = 0x10B9;
pub static CL_Rx:                                        cl_uint = 0x10BA;
pub static CL_RGx:                                       cl_uint = 0x10BB;
pub static CL_RGBx:                                      cl_uint = 0x10BC;

/* cl_channel_type */
pub static CL_SNORM_INT8:                                cl_uint = 0x10D0;
pub static CL_SNORM_INT16:                               cl_uint = 0x10D1;
pub static CL_UNORM_INT8:                                cl_uint = 0x10D2;
pub static CL_UNORM_INT16:                               cl_uint = 0x10D3;
pub static CL_UNORM_SHORT_565:                           cl_uint = 0x10D4;
pub static CL_UNORM_SHORT_555:                           cl_uint = 0x10D5;
pub static CL_UNORM_INT_101010:                          cl_uint = 0x10D6;
pub static CL_SIGNED_INT8:                               cl_uint = 0x10D7;
pub static CL_SIGNED_INT16:                              cl_uint = 0x10D8;
pub static CL_SIGNED_INT32:                              cl_uint = 0x10D9;
pub static CL_UNSIGNED_INT8:                             cl_uint = 0x10DA;
pub static CL_UNSIGNED_INT16:                            cl_uint = 0x10DB;
pub static CL_UNSIGNED_INT32:                            cl_uint = 0x10DC;
pub static CL_HALF_FLOAT:                                cl_uint = 0x10DD;
pub static CL_FLOAT:                                     cl_uint = 0x10DE;

/* cl_mem_object_type */
pub static CL_MEM_OBJECT_BUFFER:                         cl_uint = 0x10F0;
pub static CL_MEM_OBJECT_IMAGE2D:                        cl_uint = 0x10F1;
pub static CL_MEM_OBJECT_IMAGE3D:                        cl_uint = 0x10F2;

/* cl_mem_info */
pub static CL_MEM_TYPE:                                  cl_uint = 0x1100;
pub static CL_MEM_FLAGS:                                 cl_uint = 0x1101;
pub static CL_MEM_SIZE:                                  cl_uint = 0x1102;
pub static CL_MEM_HOST_PTR:                              cl_uint = 0x1103;
pub static CL_MEM_MAP_COUNT:                             cl_uint = 0x1104;
pub static CL_MEM_REFERENCE_COUNT:                       cl_uint = 0x1105;
pub static CL_MEM_CONTEXT:                               cl_uint = 0x1106;
pub static CL_MEM_ASSOCIATED_MEMOBJECT:                  cl_uint = 0x1107;
pub static CL_MEM_OFFSET:                                cl_uint = 0x1108;

/* cl_image_info */
pub static CL_IMAGE_FORMAT:                              cl_uint = 0x1110;
pub static CL_IMAGE_ELEMENT_SIZE:                        cl_uint = 0x1111;
pub static CL_IMAGE_ROW_PITCH:                           cl_uint = 0x1112;
pub static CL_IMAGE_SLICE_PITCH:                         cl_uint = 0x1113;
pub static CL_IMAGE_WIDTH:                               cl_uint = 0x1114;
pub static CL_IMAGE_HEIGHT:                              cl_uint = 0x1115;
pub static CL_IMAGE_DEPTH:                               cl_uint = 0x1116;

/* cl_addressing_mode */
pub static CL_ADDRESS_NONE:                              cl_uint = 0x1130;
pub static CL_ADDRESS_CLAMP_TO_EDGE:                     cl_uint = 0x1131;
pub static CL_ADDRESS_CLAMP:                             cl_uint = 0x1132;
pub static CL_ADDRESS_REPEAT:                            cl_uint = 0x1133;
pub static CL_ADDRESS_MIRRORED_REPEAT:                   cl_uint = 0x1134;

/* cl_filter_mode */
pub static CL_FILTER_NEAREST:                            cl_uint = 0x1140;
pub static CL_FILTER_LINEAR:                             cl_uint = 0x1141;

/* cl_sampler_info */
pub static CL_SAMPLER_REFERENCE_COUNT:                   cl_uint = 0x1150;
pub static CL_SAMPLER_CONTEXT:                           cl_uint = 0x1151;
pub static CL_SAMPLER_NORMALIZED_COORDS:                 cl_uint = 0x1152;
pub static CL_SAMPLER_ADDRESSING_MODE:                   cl_uint = 0x1153;
pub static CL_SAMPLER_FILTER_MODE:                       cl_uint = 0x1154;

/* cl_map_flags - bitfield */
pub static CL_MAP_READ:                                  cl_bitfield = 1 << 0;
pub static CL_MAP_WRITE:                                 cl_bitfield = 1 << 1;

/* cl_program_info */
pub static CL_PROGRAM_REFERENCE_COUNT:                   cl_uint = 0x1160;
pub static CL_PROGRAM_CONTEXT:                           cl_uint = 0x1161;
pub static CL_PROGRAM_NUM_DEVICES:                       cl_uint = 0x1162;
pub static CL_PROGRAM_DEVICES:                           cl_uint = 0x1163;
pub static CL_PROGRAM_SOURCE:                            cl_uint = 0x1164;
pub static CL_PROGRAM_BINARY_SIZES:                      cl_uint = 0x1165;
pub static CL_PROGRAM_BINARIES:                          cl_uint = 0x1166;

/* cl_program_build_info */
pub static CL_PROGRAM_BUILD_STATUS:                      cl_uint = 0x1181;
pub static CL_PROGRAM_BUILD_OPTIONS:                     cl_uint = 0x1182;
pub static CL_PROGRAM_BUILD_LOG:                         cl_uint = 0x1183;

/* cl_build_status */
pub static CL_BUILD_SUCCESS:                             cl_uint = 0;
pub static CL_BUILD_NONE:                                cl_uint = (-1isize) as cl_uint;
pub static CL_BUILD_ERROR:                               cl_uint = -2isize as cl_uint;
pub static CL_BUILD_IN_PROGRESS:                         cl_uint = -3isize as cl_uint;

/* cl_kernel_info */
pub static CL_KERNEL_FUNCTION_NAME:                      cl_uint = 0x1190;
pub static CL_KERNEL_NUM_ARGS:                           cl_uint = 0x1191;
pub static CL_KERNEL_REFERENCE_COUNT:                    cl_uint = 0x1192;
pub static CL_KERNEL_CONTEXT:                            cl_uint = 0x1193;
pub static CL_KERNEL_PROGRAM:                            cl_uint = 0x1194;

/* cl_kernel_work_group_info */
pub static CL_KERNEL_WORK_GROUP_SIZE:                    cl_uint = 0x11B0;
pub static CL_KERNEL_COMPILE_WORK_GROUP_SIZE:            cl_uint = 0x11B1;
pub static CL_KERNEL_LOCAL_MEM_SIZE:                     cl_uint = 0x11B2;
pub static CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: cl_uint = 0x11B3;
pub static CL_KERNEL_PRIVATE_MEM_SIZE:                   cl_uint = 0x11B4;

/* cl_event_info  */
pub static CL_EVENT_COMMAND_QUEUE:                       cl_uint = 0x11D0;
pub static CL_EVENT_COMMAND_TYPE:                        cl_uint = 0x11D1;
pub static CL_EVENT_REFERENCE_COUNT:                     cl_uint = 0x11D2;
pub static CL_EVENT_COMMAND_EXECUTION_STATUS:            cl_uint = 0x11D3;
pub static CL_EVENT_CONTEXT:                             cl_uint = 0x11D4;

/* cl_command_type */
pub static CL_COMMAND_NDRANGE_KERNEL:                    cl_uint = 0x11F0;
pub static CL_COMMAND_TASK:                              cl_uint = 0x11F1;
pub static CL_COMMAND_NATIVE_KERNEL:                     cl_uint = 0x11F2;
pub static CL_COMMAND_READ_BUFFER:                       cl_uint = 0x11F3;
pub static CL_COMMAND_WRITE_BUFFER:                      cl_uint = 0x11F4;
pub static CL_COMMAND_COPY_BUFFER:                       cl_uint = 0x11F5;
pub static CL_COMMAND_READ_IMAGE:                        cl_uint = 0x11F6;
pub static CL_COMMAND_WRITE_IMAGE:                       cl_uint = 0x11F7;
pub static CL_COMMAND_COPY_IMAGE:                        cl_uint = 0x11F8;
pub static CL_COMMAND_COPY_IMAGE_TO_BUFFER:              cl_uint = 0x11F9;
pub static CL_COMMAND_COPY_BUFFER_TO_IMAGE:              cl_uint = 0x11FA;
pub static CL_COMMAND_MAP_BUFFER:                        cl_uint = 0x11FB;
pub static CL_COMMAND_MAP_IMAGE:                         cl_uint = 0x11FC;
pub static CL_COMMAND_UNMAP_MEM_OBJECT:                  cl_uint = 0x11FD;
pub static CL_COMMAND_MARKER:                            cl_uint = 0x11FE;
pub static CL_COMMAND_ACQUIRE_GL_OBJECTS:                cl_uint = 0x11FF;
pub static CL_COMMAND_RELEASE_GL_OBJECTS:                cl_uint = 0x1200;
pub static CL_COMMAND_READ_BUFFER_RECT:                  cl_uint = 0x1201;
pub static CL_COMMAND_WRITE_BUFFER_RECT:                 cl_uint = 0x1202;
pub static CL_COMMAND_COPY_BUFFER_RECT:                  cl_uint = 0x1203;
pub static CL_COMMAND_USER:                              cl_uint = 0x1204;

/* command execution status */
pub static CL_COMPLETE:                                  cl_uint = 0x0;
pub static CL_RUNNING:                                   cl_uint = 0x1;
pub static CL_SUBMITTED:                                 cl_uint = 0x2;
pub static CL_QUEUED:                                    cl_uint = 0x3;

/* cl_buffer_create_type  */
pub static CL_BUFFER_CREATE_TYPE_REGION:                 cl_uint = 0x1220;

/* cl_profiling_info  */
pub static CL_PROFILING_COMMAND_QUEUED:                  cl_uint = 0x1280;
pub static CL_PROFILING_COMMAND_SUBMIT:                  cl_uint = 0x1281;
pub static CL_PROFILING_COMMAND_START:                   cl_uint = 0x1282;
pub static CL_PROFILING_COMMAND_END:                     cl_uint = 0x1283;

// dynamic_extern! {
//     #[link="OpenCL"]

#[link(name = "OpenCL", kind = "framework")]
#[cfg(target_os = "macos")]
extern { }

#[link(name = "OpenCL")]
#[cfg(target_os = "linux")]
extern { }

    extern "C" {
        
      /* Platform APIs */
      pub fn clGetPlatformIDs(num_entries:   cl_uint,
                              platforms:     *mut cl_platform_id,
                              num_platforms: *mut cl_uint) -> CLStatus;
      pub fn clGetPlatformInfo(platform: cl_platform_id,
                               param_name: cl_platform_info,
                               param_value_size: libc::size_t,
                               param_value: *mut raw::c_void,
                               param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Device APIs */
      pub fn clGetDeviceIDs(platform: cl_platform_id,
                        device_type: cl_device_type,
                        num_entries: cl_uint,
                        devices: *mut cl_device_id,
                        num_devices: *mut cl_uint) -> CLStatus;
      pub fn clGetDeviceInfo(device: cl_device_id,
                         param_name: cl_device_info,
                         param_value_size: libc::size_t,
                         param_value: *mut raw::c_void,
                         param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Context APIs */
      pub fn clCreateContext(properties: *const cl_context_properties,
                         num_devices: cl_uint,
                         devices: *const cl_device_id,
                         pfn_notify: extern fn (*const libc::c_char, *const raw::c_void, libc::size_t, *mut raw::c_void),
                         user_data: *mut raw::c_void,
                         errcode_ret: *mut cl_int) -> cl_context;
      pub fn clCreateContextFromType(properties: *mut cl_context_properties,
                                 device_type: cl_device_type,
                                 pfn_notify: extern fn (*mut libc::c_char, *mut raw::c_void, libc::size_t, *mut raw::c_void),
                                 user_data: *mut raw::c_void,
                                 errcode_ret: *mut cl_int) -> cl_context;
      pub fn clRetainContext(context: cl_context) -> CLStatus;
      pub fn clReleaseContext(context: cl_context) -> CLStatus;
      pub fn clGetContextInfo(context: cl_context,
                          param_name: cl_context_info,
                          param_value_size: libc::size_t,
                          param_value: *mut raw::c_void,
                          param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Command Queue APIs */
      pub fn clCreateCommandQueue(context: cl_context,
                              device: cl_device_id,
                              properties: cl_command_queue_properties,
                              errcode_ret: *mut cl_int) -> cl_command_queue;
      pub fn clRetainCommandQueue(command_queue: cl_command_queue) -> CLStatus;
      pub fn clReleaseCommandQueue(command_queue: cl_command_queue) -> CLStatus;
      pub fn clGetCommandQueueInfo(command_queue: cl_command_queue,
                               param_name: cl_command_queue_info,
                               param_value_size: libc::size_t,
                               param_value: *mut raw::c_void,
                               param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Memory Object APIs */
      pub fn clCreateBuffer(context: cl_context,
                        flags: cl_mem_flags,
                        size: libc::size_t,
                        host_ptr: *mut raw::c_void,
                        errcode_ret: *mut cl_int) -> cl_mem;
      pub fn clCreateSubBuffer(buffer: cl_mem,
                          flags: cl_mem_flags,
                          buffer_create_type: cl_buffer_create_type,
                          buffer_create_info: *mut raw::c_void,
                          errcode_ret: *mut cl_int) -> cl_mem;
      pub fn clCreateImage2D(context: cl_context,
                         flags: cl_mem_flags,
                         image_format: *mut cl_image_format,
                         image_width: libc::size_t,
                         image_height: libc::size_t,
                         image_row_pitch: libc::size_t,
                         host_ptr: *mut raw::c_void,
                         errcode_ret: *mut cl_int) -> cl_mem;
      pub fn clCreateImage3D(context: cl_context,
                         flags: cl_mem_flags,
                         image_format: *mut cl_image_format,
                         image_width: libc::size_t,
                         image_height: libc::size_t,
                         image_depth: libc::size_t,
                         image_row_pitch: libc::size_t,
                         image_slice_pitch: libc::size_t,
                         host_ptr: *mut raw::c_void,
                         errcode_ret: *mut cl_int) -> cl_mem;
      pub fn clRetainMemObject(memobj: cl_mem) -> CLStatus;
      pub fn clReleaseMemObject(memobj: cl_mem) -> CLStatus;
      pub fn clGetSupportedImageFormats(context: cl_context,
                                    flags: cl_mem_flags,
                                    image_type: cl_mem_object_type,
                                    num_entries: cl_uint,
                                    image_formats: *mut cl_image_format,
                                    num_image_formats: *mut cl_uint) -> CLStatus;
      pub fn clGetMemObjectInfo(memobj: cl_mem,
                            param_name: cl_mem_info,
                            param_value_size: libc::size_t,
                            param_value: *mut raw::c_void,
                            param_value_size_ret: *mut libc::size_t) -> CLStatus;
      pub fn clGetImageInfo(image: cl_mem,
                        param_name: cl_image_info,
                        param_value_size: libc::size_t,
                        param_value: *mut raw::c_void,
                        param_value_size_ret: *mut libc::size_t) -> CLStatus;
      pub fn clSetMemObjectDestructorCallback(memobj: cl_mem,
                                          pfn_notify: extern fn (cl_mem, *mut raw::c_void),
                                          user_data: *mut raw::c_void) -> CLStatus;

      /*mut * Sampler APIs */
      pub fn clCreateSampler(context: cl_context,
                         normalize_coords: cl_bool,
                         addressing_mode: cl_addressing_mode,
                         filter_mode: cl_filter_mode,
                         errcode_ret: *mut cl_int) -> cl_sampler;
      pub fn clRetainSampler(sampler: cl_sampler) -> CLStatus;
      pub fn clReleaseSampler(sampler: cl_sampler) ->cl_int;
      pub fn clGetSamplerInfo(sampler: cl_sampler,
                          param_name: cl_sampler_info,
                          param_value_size: libc::size_t,
                          param_value: *mut raw::c_void,
                          param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Program Object APIs */
      pub fn clCreateProgramWithSource(context: cl_context,
                                   count: cl_uint,
                                   strings: *const *const libc::c_char,
                                   lengths: *const libc::size_t,
                                   errcode_ret: *mut cl_int) -> cl_program;
      pub fn clCreateProgramWithBinary(context: cl_context,
                                   num_devices: cl_uint,
                                   device_list: *const cl_device_id,
                                   lengths: *const libc::size_t,
                                   binaries: *const *const libc::c_uchar,
                                   binary_status: *mut cl_int,
                                   errcode_ret: *mut cl_int) -> cl_program;
      pub fn clRetainProgram(program: cl_program) -> CLStatus;
      pub fn clReleaseProgram(program: cl_program) -> CLStatus;
      pub fn clBuildProgram(program: cl_program,
                        num_devices: cl_uint,
                        device_list: *const cl_device_id,
                        options: *const libc::c_char,
                        pfn_notify: extern fn (cl_program, *mut raw::c_void),
                        user_data: *mut raw::c_void) -> CLStatus;
      pub fn clUnloadCompiler() -> CLStatus;
      pub fn clGetProgramInfo(program: cl_program,
                          param_name: cl_program_info,
                          param_value_size: libc::size_t,
                          param_value: *mut raw::c_void,
                          param_value_size_ret: *mut libc::size_t) -> CLStatus;
      pub fn clGetProgramBuildInfo(program: cl_program,
                               device: cl_device_id,
                               param_name: cl_program_info,
                               param_value_size: libc::size_t,
                               param_value: *mut raw::c_void,
                               param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Kernel Object APIs */
      pub fn clCreateKernel(program: cl_program,
                        kernel_name: *const libc::c_char,
                        errcode_ret: *mut cl_int) -> cl_kernel;
      pub fn clCreateKernelsInProgram(program: cl_program,
                                  num_kernels: cl_uint,
                                  kernels: *mut cl_kernel,
                                  num_kernels_ret: *mut cl_uint) -> CLStatus;
      pub fn clRetainKernel(kernel: cl_kernel) -> CLStatus;
      pub fn clReleaseKernel(kernel: cl_kernel) -> CLStatus;
      pub fn clSetKernelArg(kernel: cl_kernel,
                        arg_index: cl_uint,
                        arg_size: libc::size_t,
                        arg_value: *const raw::c_void) -> CLStatus;
      pub fn clGetKernelInfo(kernel: cl_kernel,
                         param_name: cl_kernel_info,
                         param_value_size: libc::size_t,
                         param_value: *mut raw::c_void,
                         param_value_size_ret: *mut libc::size_t) -> CLStatus;
      pub fn clGetKernelWorkGroupInfo(kernel: cl_kernel,
                                  device: cl_device_id,
                                  param_name: cl_kernel_work_group_info,
                                  param_value_size: libc::size_t,
                                  param_value: *mut raw::c_void,
                                  param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Event Object APIs */
      pub fn clWaitForEvents(num_events: cl_uint,
                         event_list: *const cl_event) -> CLStatus;
      pub fn clGetEventInfo(event: cl_event,
                        param_name: cl_event_info,
                        param_value_size: libc::size_t,
                        param_value: *mut raw::c_void,
                        param_value_size_ret: *mut libc::size_t) -> CLStatus;
      pub fn clCreateUserEvent(context: cl_context,
                           errcode_ret: *mut cl_int) -> cl_event;
      pub fn clRetainEvent(event: cl_event) -> CLStatus;
      pub fn clReleaseEvent(event: cl_event) -> CLStatus;
      pub fn clSetUserEventStatus(event: cl_event,
                              execution_status: cl_int) -> CLStatus;
      pub fn clSetEventCallback(event: cl_event,
                            command_exec_callback_type: cl_int,
                            pfn_notify: extern fn (cl_event, cl_int, *mut raw::c_void),
                            user_data: *mut raw::c_void) -> CLStatus;

      /* Profiling APIs */
      pub fn clGetEventProfilingInfo(event: cl_event,
                                 param_name: cl_profiling_info,
                                 param_value_size: libc::size_t,
                                 param_value: *mut raw::c_void,
                                 param_value_size_ret: *mut libc::size_t) -> CLStatus;

      /* Flush and Finish APIs */
      pub fn clFlush(command_queue: cl_command_queue) -> CLStatus;
      pub fn clFinish(command_queue: cl_command_queue) -> CLStatus;

      /* Enqueued Commands APIs */
      pub fn clEnqueueReadBuffer(command_queue: cl_command_queue,
                             buffer: cl_mem,
                             blocking_read: cl_bool,
                             offset: libc::size_t,
                             cb: libc::size_t,
                             ptr: *mut raw::c_void,
                             num_events_in_wait_list: cl_uint,
                             event_wait_list: *const cl_event,
                             event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueReadBufferRect(command_queue: cl_command_queue,
                                 buffer: cl_mem,
                                 blocking_read: cl_bool,
                                 buffer_origin: *mut libc::size_t,
                                 host_origin: *mut libc::size_t,
                                 region: *mut libc::size_t,
                                 buffer_row_pitch: libc::size_t,
                                 buffer_slice_pitch: libc::size_t,
                                 host_row_pitch: libc::size_t,
                                 host_slice_pitch: libc::size_t,
                                 ptr: *mut raw::c_void,
                                 num_events_in_wait_list: cl_uint,
                                 event_wait_list: *const cl_event,
                                 event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueWriteBuffer(command_queue: cl_command_queue,
                              buffer: cl_mem,
                              blocking_write: cl_bool,
                              offset: libc::size_t,
                              cb: libc::size_t,
                              ptr: *const raw::c_void,
                              num_events_in_wait_list: cl_uint,
                              event_wait_list: *const cl_event,
                              event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueWriteBufferRect(command_queue: cl_command_queue,
                                  blocking_write: cl_bool,
                                  buffer_origin: *mut libc::size_t,
                                  host_origin: *mut libc::size_t,
                                  region: *mut libc::size_t,
                                  buffer_row_pitch: libc::size_t,
                                  buffer_slice_pitch: libc::size_t,
                                  host_row_pitch: libc::size_t,
                                  host_slice_pitch: libc::size_t,
                                  ptr: *mut raw::c_void,
                                  num_events_in_wait_list: cl_uint,
                                  event_wait_list: *const cl_event,
                                  event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueCopyBuffer(command_queue: cl_command_queue,
                             src_buffer: cl_mem,
                             dst_buffer: cl_mem,
                             src_offset: libc::size_t,
                             dst_offset: libc::size_t,
                             cb: libc::size_t,
                             num_events_in_wait_list: cl_uint,
                             event_wait_list: *const cl_event,
                             event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueCopyBufferRect(command_queue: cl_command_queue,
                                 src_buffer: cl_mem,
                                 dst_buffer: cl_mem,
                                 src_origin: *mut libc::size_t,
                                 dst_origin: *mut libc::size_t,
                                 region: *mut libc::size_t,
                                 src_row_pitch: libc::size_t,
                                 src_slice_pitch: libc::size_t,
                                 dst_row_pitch: libc::size_t,
                                 dst_slice_pitch: libc::size_t,
                                 num_events_in_wait_list: cl_uint,
                                 event_wait_list: *const cl_event,
                                 event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueReadImage(command_queue: cl_command_queue,
                            image: cl_mem,
                            blocking_read: cl_bool,
                            origin: *mut libc::size_t,
                            region: *mut libc::size_t,
                            row_pitch: libc::size_t,
                            slice_pitch: libc::size_t,
                            ptr: *mut raw::c_void,
                            num_events_in_wait_list: cl_uint,
                            event_wait_list: *const cl_event,
                            event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueWriteImage(command_queue: cl_command_queue,
                             image: cl_mem,
                             blocking_write: cl_bool,
                             origin: *mut libc::size_t,
                             region: *mut libc::size_t,
                             input_row_pitch: libc::size_t,
                             input_slice_pitch: libc::size_t,
                             ptr: *mut raw::c_void,
                             num_events_in_wait_list: cl_uint,
                             event_wait_list: *const cl_event,
                             event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueCopyImage(command_queue: cl_command_queue,
                            src_image: cl_mem,
                            dst_image: cl_mem,
                            src_origin: *mut libc::size_t,
                            dst_origin: *mut libc::size_t,
                            region: *mut libc::size_t,
                            num_events_in_wait_list: cl_uint,
                            event_wait_list: *const cl_event,
                            event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueCopyImageToBuffer(command_queue: cl_command_queue,
                                    src_image: cl_mem,
                                    dst_buffer: cl_mem,
                                    src_origin: *mut libc::size_t,
                                    region: *mut libc::size_t,
                                    dst_offset: libc::size_t,
                                    num_events_in_wait_list: cl_uint,
                                    event_wait_list: *const cl_event,
                                    event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueCopyBufferToImage(command_queue: cl_command_queue,
                                    src_buffer: cl_mem,
                                    dst_image: cl_mem,
                                    src_offset: libc::size_t,
                                    dst_origin: *mut libc::size_t,
                                    region: *mut libc::size_t,
                                    num_events_in_wait_list: cl_uint,
                                    event_wait_list: *const cl_event,
                                    event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueMapBuffer(command_queue: cl_command_queue,
                            buffer: cl_mem,
                            blocking_map: cl_bool,
                            map_flags: cl_map_flags,
                            offset: libc::size_t,
                            cb: libc::size_t,
                            num_events_in_wait_list: cl_uint,
                            event_wait_list: *const cl_event,
                            event: *mut cl_event,
                            errorcode_ret: *mut cl_int);
      pub fn clEnqueueMapImage(command_queue: cl_command_queue,
                           image: cl_mem,
                           blocking_map: cl_bool,
                           map_flags: cl_map_flags,
                           origin: *mut libc::size_t,
                           region: *mut libc::size_t,
                           image_row_pitch: libc::size_t,
                           image_slice_pitch: libc::size_t,
                           num_events_in_wait_list: cl_uint,
                           event_wait_list: *const cl_event,
                           event: *mut cl_event,
                           errorcode_ret: *mut cl_int);
      pub fn clEnqueueUnmapMemObject(command_queue: cl_command_queue,
                                 memobj: cl_mem,
                                 mapped_ptr: *mut raw::c_void,
                                 num_events_in_wait_list: cl_uint,
                                 event_wait_list: *const cl_event,
                                 event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueNDRangeKernel(command_queue: cl_command_queue,
                                kernel: cl_kernel,
                                work_dim: cl_uint,
                                global_work_offset: *const libc::size_t,
                                global_work_size: *const libc::size_t,
                                local_work_size: *const libc::size_t,
                                num_events_in_wait_list: cl_uint,
                                event_wait_list: *const cl_event,
                                event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueTask(command_queue: cl_command_queue,
                       kernel: cl_kernel,
                       num_events_in_wait_list: cl_uint,
                       event_wait_list: *const cl_event,
                       event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueNativeKernel(command_queue: cl_command_queue,
                               user_func: extern fn (*mut raw::c_void),
                               args: *mut raw::c_void,
                               cb_args: libc::size_t,
                               num_mem_objects: cl_uint,
                               mem_list: *const cl_mem,
                               args_mem_loc: *const *const raw::c_void,
                               num_events_in_wait_list: cl_uint,
                               event_wait_list: *const cl_event,
                               event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueMarker(command_queue: cl_command_queue,
                         event: *mut cl_event) -> CLStatus;
      pub fn clEnqueueWaitForEvents(command_queue: cl_command_queue,
                                num_events: cl_uint,
                                event_list: *mut cl_event) -> CLStatus;
      pub fn clEnqueueBarrier(command_queue: cl_command_queue) -> CLStatus;

      /* Extension function access
       *
       * Returns the extension function address for the given function name,
       * or NULL if a valid function can not be found. The client must
       * check to make sure the address is not NULL, before using or
       * or calling the returned function address.
       */
      pub fn clGetExtensionFunctionAddress(func_name: *const libc::c_char) -> *mut raw::c_void;
    }
//}