summaryrefslogtreecommitdiff
path: root/tests/test_headers.c
blob: 460a182dcc4def29941a80a1e562b20800018f6d (plain)
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
//
// Copyright (c) 2020-2022 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

/*
Some versions of inttypes.h required defining the macro __STDC_FORMAT_MACROS to
use the format macros for C++ compiles, but not all.  To improve robustness we
will use inttypes.h for C compiles and cinttypes for C++ compiles.
*/
#if defined(__cplusplus)
#include <cinttypes>
#else
#include <inttypes.h>
#endif

#include <stdio.h>

#include "CL/cl.h"

int test_char()
{
/* char */
    /* Constructor */
    cl_char a = 0;
    cl_char2 a2 = {{ 0, 1 }};
    cl_char4 a4 = {{ 0, 1, 2, 3 }};
    cl_char8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_char16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_char    b = a;
    cl_char2   b2 = a2;
    cl_char4   b4 = a4;
    cl_char8   b8 = a8;
    cl_char16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %d\n", b );
    printf("b2:  %d %d \n", b2.s[0], b2.s[1] );
    printf("b4:  %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_CHAR2__ )
    __cl_char2 v2 = b2.v2;
    printf("__cl_char2:  %d %d \n", ((cl_char*)&v2)[0], ((cl_char*)&v2)[1] );
#else
    printf( "__cl_char2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_CHAR4__ )
    __cl_char4 v4 = b4.v4;
    printf("__cl_char4:  %d %d %d %d \n", ((cl_char*)&v4)[0], ((cl_char*)&v4)[1], ((cl_char*)&v4)[2], ((cl_char*)&v4)[3] );
#else
    printf( "__cl_char4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_CHAR8__ )
    __cl_char8 v8 = b8.v8;
    printf("__cl_char8:  %d %d %d %d %d %d %d %d \n", ((cl_char*)&v8)[0], ((cl_char*)&v8)[1], ((cl_char*)&v8)[2], ((cl_char*)&v8)[3], ((cl_char*)&v8)[4], ((cl_char*)&v8)[5], ((cl_char*)&v8)[6], ((cl_char*)&v8)[7] );
#else
    printf( "__cl_char8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_CHAR16__ )
    __cl_char16 v16 = b16.v16;
    printf("__cl_char16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_char*)&v16)[0], ((cl_char*)&v16)[1], ((cl_char*)&v16)[2], ((cl_char*)&v16)[3], ((cl_char*)&v16)[4], ((cl_char*)&v16)[5], ((cl_char*)&v16)[6], ((cl_char*)&v16)[7],
                                                                      ((cl_char*)&v16)[8], ((cl_char*)&v16)[9], ((cl_char*)&v16)[10], ((cl_char*)&v16)[11], ((cl_char*)&v16)[12], ((cl_char*)&v16)[13], ((cl_char*)&v16)[14], ((cl_char*)&v16)[15]);
#else
    printf( "__cl_char16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_uchar()
{
/* uchar */
    /* Constructor */
    cl_uchar a = 0;
    cl_uchar2 a2 = {{ 0, 1 }};
    cl_uchar4 a4 = {{ 0, 1, 2, 3 }};
    cl_uchar8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_uchar16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_uchar    b = a;
    cl_uchar2   b2 = a2;
    cl_uchar4   b4 = a4;
    cl_uchar8   b8 = a8;
    cl_uchar16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %d\n", b );
    printf("b2:  %d %d \n", b2.s[0], b2.s[1] );
    printf("b4:  %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_UCHAR2__ )
    __cl_uchar2 v2 = b2.v2;
    printf("__cl_uchar2:  %d %d \n", ((uchar*)&v2)[0], ((cl_uchar*)&v2)[1] );
#else
    printf( "__cl_uchar2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_UCHAR4__ )
    __cl_uchar4 v4 = b4.v4;
    printf("__cl_uchar4:  %d %d %d %d \n", ((uchar*)&v4)[0], ((cl_uchar*)&v4)[1], ((cl_uchar*)&v4)[2], ((cl_uchar*)&v4)[3] );
#else
    printf( "__cl_uchar4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_UCHAR8__ )
    __cl_uchar8 v8 = b8.v8;
    printf("__cl_uchar8:  %d %d %d %d %d %d %d %d \n", ((cl_uchar*)&v8)[0], ((cl_uchar*)&v8)[1], ((cl_uchar*)&v8)[2], ((cl_uchar*)&v8)[3], ((cl_uchar*)&v8)[4], ((cl_uchar*)&v8)[5], ((cl_uchar*)&v8)[6], ((cl_uchar*)&v8)[7] );
#else
    printf( "__cl_uchar8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_UCHAR16__ )
    __cl_uchar16 v16 = b16.v16;
    printf("__cl_uchar16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_uchar*)&v16)[0], ((cl_uchar*)&v16)[1], ((cl_uchar*)&v16)[2], ((cl_uchar*)&v16)[3], ((cl_uchar*)&v16)[4], ((cl_uchar*)&v16)[5], ((cl_uchar*)&v16)[6], ((cl_uchar*)&v16)[7],
                                                                      ((cl_uchar*)&v16)[8], ((cl_uchar*)&v16)[9], ((cl_uchar*)&v16)[10], ((cl_uchar*)&v16)[11], ((cl_uchar*)&v16)[12], ((cl_uchar*)&v16)[13], ((cl_uchar*)&v16)[14], ((cl_uchar*)&v16)[15]);
#else
    printf( "__cl_uchar16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_short()
{
/* short */
    /* Constructor */
    cl_short a = 0;
    cl_short2 a2 = {{ 0, 1 }};
    cl_short4 a4 = {{ 0, 1, 2, 3 }};
    cl_short8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_short16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_short    b = a;
    cl_short2   b2 = a2;
    cl_short4   b4 = a4;
    cl_short8   b8 = a8;
    cl_short16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %d\n", b );
    printf("b2:  %d %d \n", b2.s[0], b2.s[1] );
    printf("b4:  %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_SHORT2__ )
    __cl_short2 v2 = b2.v2;
    printf("__cl_short2:  %d %d \n", ((cl_short*)&v2)[0], ((cl_short*)&v2)[1] );
#else
    printf( "__cl_short2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_SHORT4__ )
    __cl_short4 v4 = b4.v4;
    printf("__cl_short4:  %d %d %d %d \n", ((cl_short*)&v4)[0], ((cl_short*)&v4)[1], ((cl_short*)&v4)[2], ((cl_short*)&v4)[3] );
#else
    printf( "__cl_short4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_SHORT8__ )
    __cl_short8 v8 = b8.v8;
    printf("__cl_short8:  %d %d %d %d %d %d %d %d \n", ((cl_short*)&v8)[0], ((cl_short*)&v8)[1], ((cl_short*)&v8)[2], ((cl_short*)&v8)[3], ((cl_short*)&v8)[4], ((cl_short*)&v8)[5], ((cl_short*)&v8)[6], ((cl_short*)&v8)[7] );
#else
    printf( "__cl_short8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_SHORT16__ )
    __cl_short16 v16 = b16.v16;
    printf("__cl_short16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_short*)&v16)[0], ((cl_short*)&v16)[1], ((cl_short*)&v16)[2], ((cl_short*)&v16)[3], ((cl_short*)&v16)[4], ((cl_short*)&v16)[5], ((cl_short*)&v16)[6], ((cl_short*)&v16)[7],
                                                                      ((cl_short*)&v16)[8], ((cl_short*)&v16)[9], ((cl_short*)&v16)[10], ((cl_short*)&v16)[11], ((cl_short*)&v16)[12], ((cl_short*)&v16)[13], ((cl_short*)&v16)[14], ((cl_short*)&v16)[15]);
#else
    printf( "__cl_short16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_ushort()
{
/* ushort */
    /* Constructor */
    cl_ushort a = 0;
    cl_ushort2 a2 = {{ 0, 1 }};
    cl_ushort4 a4 = {{ 0, 1, 2, 3 }};
    cl_ushort8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_ushort16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_ushort    b = a;
    cl_ushort2   b2 = a2;
    cl_ushort4   b4 = a4;
    cl_ushort8   b8 = a8;
    cl_ushort16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %d\n", b );
    printf("b2:  %d %d \n", b2.s[0], b2.s[1] );
    printf("b4:  %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_USHORT2__ )
    __cl_ushort2 v2 = b2.v2;
    printf("__cl_ushort2:  %d %d \n", ((unsigned short*)&v2)[0], ((unsigned short*)&v2)[1] );
#else
    printf( "__cl_ushort2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_USHORT4__ )
    __cl_ushort4 v4 = b4.v4;
    printf("__cl_ushort4:  %d %d %d %d \n", ((unsigned short*)&v4)[0], ((unsigned short*)&v4)[1], ((unsigned short*)&v4)[2], ((unsigned short*)&v4)[3] );
#else
    printf( "__cl_ushort4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_USHORT8__ )
    __cl_ushort8 v8 = b8.v8;
    printf("__cl_ushort8:  %d %d %d %d %d %d %d %d \n", ((unsigned short*)&v8)[0], ((unsigned short*)&v8)[1], ((unsigned short*)&v8)[2], ((unsigned short*)&v8)[3], ((unsigned short*)&v8)[4], ((unsigned short*)&v8)[5], ((unsigned short*)&v8)[6], ((unsigned short*)&v8)[7] );
#else
    printf( "__cl_ushort8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_USHORT16__ )
    __cl_ushort16 v16 = b16.v16;
    printf("__cl_ushort16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((unsigned short*)&v16)[0], ((unsigned short*)&v16)[1], ((unsigned short*)&v16)[2], ((unsigned short*)&v16)[3], ((unsigned short*)&v16)[4], ((unsigned short*)&v16)[5], ((unsigned short*)&v16)[6], ((unsigned short*)&v16)[7],
                                                                      ((unsigned short*)&v16)[8], ((unsigned short*)&v16)[9], ((unsigned short*)&v16)[10], ((unsigned short*)&v16)[11], ((unsigned short*)&v16)[12], ((unsigned short*)&v16)[13], ((unsigned short*)&v16)[14], ((unsigned short*)&v16)[15]);
#else
    printf( "__cl_ushort16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_int()
{
/* int */
    /* Constructor */
    cl_int a = 0;
    cl_int2 a2 = {{ 0, 1 }};
    cl_int4 a4 = {{ 0, 1, 2, 3 }};
    cl_int8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_int16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_int    b = a;
    cl_int2   b2 = a2;
    cl_int4   b4 = a4;
    cl_int8   b8 = a8;
    cl_int16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %d\n", b );
    printf("b2:  %d %d \n", b2.s[0], b2.s[1] );
    printf("b4:  %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_INT2__ )
    __cl_int2 v2 = b2.v2;
    printf("__cl_int2:  %d %d \n", ((cl_int*)&v2)[0], ((cl_int*)&v2)[1] );
#else
    printf( "__cl_int2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_INT4__ )
    __cl_int4 v4 = b4.v4;
    printf("__cl_int4:  %d %d %d %d \n", ((cl_int*)&v4)[0], ((cl_int*)&v4)[1], ((cl_int*)&v4)[2], ((cl_int*)&v4)[3] );
#else
    printf( "__cl_int4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_INT8__ )
    __cl_int8 v8 = b8.v8;
    printf("__cl_int8:  %d %d %d %d %d %d %d %d \n", ((cl_int*)&v8)[0], ((cl_int*)&v8)[1], ((cl_int*)&v8)[2], ((cl_int*)&v8)[3], ((cl_int*)&v8)[4], ((cl_int*)&v8)[5], ((cl_int*)&v8)[6], ((cl_int*)&v8)[7] );
#else
    printf( "__cl_int8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_INT16__ )
    __cl_int16 v16 = b16.v16;
    printf("__cl_int16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_int*)&v16)[0], ((cl_int*)&v16)[1], ((cl_int*)&v16)[2], ((cl_int*)&v16)[3], ((cl_int*)&v16)[4], ((cl_int*)&v16)[5], ((cl_int*)&v16)[6], ((cl_int*)&v16)[7],
                                                                      ((cl_int*)&v16)[8], ((cl_int*)&v16)[9], ((cl_int*)&v16)[10], ((cl_int*)&v16)[11], ((cl_int*)&v16)[12], ((cl_int*)&v16)[13], ((cl_int*)&v16)[14], ((cl_int*)&v16)[15]);
#else
    printf( "__cl_int16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_uint()
{
/* uint */
    /* Constructor */
    cl_uint a = 0;
    cl_uint2 a2 = {{ 0, 1 }};
    cl_uint4 a4 = {{ 0, 1, 2, 3 }};
    cl_uint8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_uint16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_uint    b = a;
    cl_uint2   b2 = a2;
    cl_uint4   b4 = a4;
    cl_uint8   b8 = a8;
    cl_uint16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %d\n", b );
    printf("b2:  %d %d \n", b2.s[0], b2.s[1] );
    printf("b4:  %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_UINT2__ )
    __cl_uint2 v2 = b2.v2;
    printf("__cl_uint2:  %d %d \n", ((cl_uint*)&v2)[0], ((cl_uint*)&v2)[1] );
#else
    printf( "__cl_uint2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_UINT4__ )
    __cl_uint4 v4 = b4.v4;
    printf("__cl_uint4:  %d %d %d %d \n", ((cl_uint*)&v4)[0], ((cl_uint*)&v4)[1], ((cl_uint*)&v4)[2], ((cl_uint*)&v4)[3] );
#else
    printf( "__cl_uint4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_UINT8__ )
    __cl_uint8 v8 = b8.v8;
    printf("__cl_uint8:  %d %d %d %d %d %d %d %d \n", ((cl_uint*)&v8)[0], ((cl_uint*)&v8)[1], ((cl_uint*)&v8)[2], ((cl_uint*)&v8)[3], ((cl_uint*)&v8)[4], ((cl_uint*)&v8)[5], ((cl_uint*)&v8)[6], ((cl_uint*)&v8)[7] );
#else
    printf( "__cl_uint8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_UINT16__ )
    __cl_uint16 v16 = b16.v16;
    printf("__cl_uint16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_uint*)&v16)[0], ((cl_uint*)&v16)[1], ((cl_uint*)&v16)[2], ((cl_uint*)&v16)[3], ((cl_uint*)&v16)[4], ((cl_uint*)&v16)[5], ((cl_uint*)&v16)[6], ((cl_uint*)&v16)[7],
                                                                      ((cl_uint*)&v16)[8], ((cl_uint*)&v16)[9], ((cl_uint*)&v16)[10], ((cl_uint*)&v16)[11], ((cl_uint*)&v16)[12], ((cl_uint*)&v16)[13], ((cl_uint*)&v16)[14], ((cl_uint*)&v16)[15]);
#else
    printf( "__cl_uint16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_long()
{
/* long */
    /* Constructor */
    cl_long a = 0;
    cl_long2 a2 = {{ 0, 1 }};
    cl_long4 a4 = {{ 0, 1, 2, 3 }};
    cl_long8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_long16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_long    b = a;
    cl_long2   b2 = a2;
    cl_long4   b4 = a4;
    cl_long8   b8 = a8;
    cl_long16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %" PRId64 "\n", b );
    printf("b2:  %" PRId64 " %" PRId64 " \n", b2.s[0], b2.s[1] );
    printf("b4:  %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 "\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 "\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 "\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_LONG2__ )
    __cl_long2 v2 = b2.v2;
    printf("__cl_long2:  %" PRId64 " %" PRId64 " \n", ((cl_long*)&v2)[0], ((cl_long*)&v2)[1] );
#else
    printf( "__cl_long2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_LONG4__ )
    __cl_long4 v4 = b4.v4;
    printf("__cl_long4:  %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " \n", ((cl_long*)&v4)[0], ((cl_long*)&v4)[1], ((cl_long*)&v4)[2], ((cl_long*)&v4)[3] );
#else
    printf( "__cl_long4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_LONG8__ )
    __cl_long8 v8 = b8.v8;
    printf("__cl_long8:  %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " \n", ((cl_long*)&v8)[0], ((cl_long*)&v8)[1], ((cl_long*)&v8)[2], ((cl_long*)&v8)[3], ((cl_long*)&v8)[4], ((cl_long*)&v8)[5], ((cl_long*)&v8)[6], ((cl_long*)&v8)[7] );
#else
    printf( "__cl_long8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_LONG16__ )
    __cl_long16 v16 = b16.v16;
    printf("__cl_long16: %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " \n", ((cl_long*)&v16)[0], ((cl_long*)&v16)[1], ((cl_long*)&v16)[2], ((cl_long*)&v16)[3], ((cl_long*)&v16)[4], ((cl_long*)&v16)[5], ((cl_long*)&v16)[6], ((cl_long*)&v16)[7],
                                                                      ((cl_long*)&v16)[8], ((cl_long*)&v16)[9], ((cl_long*)&v16)[10], ((cl_long*)&v16)[11], ((cl_long*)&v16)[12], ((cl_long*)&v16)[13], ((cl_long*)&v16)[14], ((cl_long*)&v16)[15]);
#else
    printf( "__cl_long16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_ulong()
{
/* ulong */
    /* Constructor */
    cl_ulong a = 0;
    cl_ulong2 a2 = {{ 0, 1 }};
    cl_ulong4 a4 = {{ 0, 1, 2, 3 }};
    cl_ulong8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
    cl_ulong16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};

    /* assignment */
    cl_ulong    b = a;
    cl_ulong2   b2 = a2;
    cl_ulong4   b4 = a4;
    cl_ulong8   b8 = a8;
    cl_ulong16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %" PRIu64 "\n", b );
    printf("b2:  %" PRIu64 " %" PRIu64 " \n", b2.s[0], b2.s[1] );
    printf("b4:  %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_ULONG2__ )
    __cl_ulong2 v2 = b2.v2;
    printf("__cl_ulong2:  %" PRIu64 " %" PRIu64 " \n", ((cl_ulong*)&v2)[0], ((cl_ulong*)&v2)[1] );
#else
    printf( "__cl_ulong2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_ULONG4__ )
    __cl_ulong4 v4 = b4.v4;
    printf("__cl_ulong4:  %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " \n", ((cl_ulong*)&v4)[0], ((cl_ulong*)&v4)[1], ((cl_ulong*)&v4)[2], ((cl_ulong*)&v4)[3] );
#else
    printf( "__cl_ulong4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_ULONG8__ )
    __cl_ulong8 v8 = b8.v8;
    printf("__cl_ulong8:  %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " \n", ((cl_ulong*)&v8)[0], ((cl_ulong*)&v8)[1], ((cl_ulong*)&v8)[2], ((cl_ulong*)&v8)[3], ((cl_ulong*)&v8)[4], ((cl_ulong*)&v8)[5], ((cl_ulong*)&v8)[6], ((cl_ulong*)&v8)[7] );
#else
    printf( "__cl_ulong8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_ULONG16__ )
    __cl_ulong16 v16 = b16.v16;
    printf("__cl_ulong16: %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " \n", ((cl_ulong*)&v16)[0], ((cl_ulong*)&v16)[1], ((cl_ulong*)&v16)[2], ((cl_ulong*)&v16)[3], ((cl_ulong*)&v16)[4], ((cl_ulong*)&v16)[5], ((cl_ulong*)&v16)[6], ((cl_ulong*)&v16)[7],
                                                                      ((cl_ulong*)&v16)[8], ((cl_ulong*)&v16)[9], ((cl_ulong*)&v16)[10], ((cl_ulong*)&v16)[11], ((cl_ulong*)&v16)[12], ((cl_ulong*)&v16)[13], ((cl_ulong*)&v16)[14], ((cl_ulong*)&v16)[15]);
#else
    printf( "__cl_ulong16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_float()
{
/* float */
    /* Constructor */
    cl_float a = 0.0f;
    cl_float2 a2 = {{ 0.0f, 1.0f }};
    cl_float4 a4 = {{ 0.0f, 1.0f, 2.0f, 3.0f }};
    cl_float8 a8 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }};
    cl_float16 a16 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }};

    /* assignment */
    cl_float    b = a;
    cl_float2   b2 = a2;
    cl_float4   b4 = a4;
    cl_float8   b8 = a8;
    cl_float16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %f\n", b );
    printf("b2:  %f %f \n", b2.s[0], b2.s[1] );
    printf("b4:  %f %f %f %f\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %f %f %f %f %f %f %f %f\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_FLOAT2__ )
    __cl_float2 v2 = b2.v2;
    printf("__cl_float2:  %f %f \n", ((cl_float*)&v2)[0], ((cl_float*)&v2)[1] );
#else
    printf( "__cl_float2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_FLOAT4__ )
    {
        __cl_float4 v4 = b4.v4;
        printf("__cl_float4:  %f %f %f %f \n", ((cl_float*)&v4)[0], ((cl_float*)&v4)[1], ((cl_float*)&v4)[2], ((cl_float*)&v4)[3] );
    }
#else
    printf( "__cl_float4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_FLOAT8__ )
    __cl_float8 v8 = b8.v8;
    printf("__cl_float8:  %f %f %f %f %f %f %f %f \n", ((cl_float*)&v8)[0], ((cl_float*)&v8)[1], ((cl_float*)&v8)[2], ((cl_float*)&v8)[3], ((cl_float*)&v8)[4], ((cl_float*)&v8)[5], ((cl_float*)&v8)[6], ((cl_float*)&v8)[7] );
#else
    printf( "__cl_float8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_FLOAT16__ )
    __cl_float16 v16 = b16.v16;
    printf("__cl_float16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n", ((cl_float*)&v16)[0], ((cl_float*)&v16)[1], ((cl_float*)&v16)[2], ((cl_float*)&v16)[3], ((cl_float*)&v16)[4], ((cl_float*)&v16)[5], ((cl_float*)&v16)[6], ((cl_float*)&v16)[7],
                                                                      ((cl_float*)&v16)[8], ((cl_float*)&v16)[9], ((cl_float*)&v16)[10], ((cl_float*)&v16)[11], ((cl_float*)&v16)[12], ((cl_float*)&v16)[13], ((cl_float*)&v16)[14], ((cl_float*)&v16)[15]);
#else
    printf( "__cl_float16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int test_double()
{
/* double */
    /* Constructor */
    cl_double a = 0.0f;
    cl_double2 a2 = {{ 0.0f, 1.0f }};
    cl_double4 a4 = {{ 0.0f, 1.0f, 2.0f, 3.0f }};
    cl_double8 a8 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }};
    cl_double16 a16 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }};

    /* assignment */
    cl_double    b = a;
    cl_double2   b2 = a2;
    cl_double4   b4 = a4;
    cl_double8   b8 = a8;
    cl_double16  b16 = a16;

    printf("\nVerifying assignment:\n" );
    printf("b:   %f\n", b );
    printf("b2:  %f %f \n", b2.s[0], b2.s[1] );
    printf("b4:  %f %f %f %f\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
    printf("b8:  %f %f %f %f %f %f %f %f\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
    printf("b16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
                                                                     b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);

    /* vector access */
    printf("\nVerifying vector access:\n" );
#if defined( __CL_DOUBLE2__ )
    __cl_double2 v2 = b2.v2;
    printf("__cl_double2:  %f %f \n", ((cl_double*)&v2)[0], ((cl_double*)&v2)[1] );
#else
    printf( "__cl_double2 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_DOUBLE4__ )
    __cl_double4 v4 = b4.v4;
    printf("__cl_double4:  %f %f %f %f \n", ((cl_double*)&v4)[0], ((cl_double*)&v4)[1], ((cl_double*)&v4)[2], ((cl_double*)&v4)[3] );
#else
    printf( "__cl_double4 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_DOUBLE8__ )
    __cl_double8 v8 = b8.v8;
    printf("__cl_double8:  %f %f %f %f %f %f %f %f \n", ((cl_double*)&v8)[0], ((cl_double*)&v8)[1], ((cl_double*)&v8)[2], ((cl_double*)&v8)[3], ((cl_double*)&v8)[4], ((cl_double*)&v8)[5], ((cl_double*)&v8)[6], ((cl_double*)&v8)[7] );
#else
    printf( "__cl_double8 SIMD vectors not supported on this architecture.\n" );
#endif

#if defined( __CL_DOUBLE16__ )
    __cl_double16 v16 = b16.v16;
    printf("__cl_double16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n", ((cl_double*)&v16)[0], ((cl_double*)&v16)[1], ((cl_double*)&v16)[2], ((cl_double*)&v16)[3], ((cl_double*)&v16)[4], ((cl_double*)&v16)[5], ((cl_double*)&v16)[6], ((cl_double*)&v16)[7],
                                                                      ((cl_double*)&v16)[8], ((cl_double*)&v16)[9], ((cl_double*)&v16)[10], ((cl_double*)&v16)[11], ((cl_double*)&v16)[12], ((cl_double*)&v16)[13], ((cl_double*)&v16)[14], ((cl_double*)&v16)[15]);
#else
    printf( "__cl_double16 SIMD vectors not supported on this architecture.\n" );
#endif

    printf( "\n" );
    return 0;
}

int main(void)
{
  printf( "\nChecking operations on cl_types.\nNumbers, where presented, should walk upward from 0, with step of 1:\n" );

  test_char();
  test_uchar();
  test_short();
  test_ushort();
  test_long();
  test_ulong();
  test_float();
  test_double();

  return 0;
}