File: conv.c

package info (click to toggle)
libhdf4 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 30,288 kB
  • sloc: ansic: 128,699; sh: 15,015; fortran: 12,444; java: 5,863; xml: 1,205; makefile: 790; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (766 lines) | stat: -rw-r--r-- 35,259 bytes parent folder | download | duplicates (4)
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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF copyright notice, including       *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
   FILE
   conv.c
   Test HDF Number-Type conversion routines

   REMARKS

   DESIGN

   BUGS/LIMITATIONS

   EXPORTED ROUTINES

   AUTHOR
   Quincey Koziol

   MODIFICATION HISTORY
   10/27/93 - Started coding.
 */

#include "tproto.h"
#include <time.h>

/* last ditch attempt do define this value... */
#ifndef UINT_MAX
#define UINT_MAX (unsigned)(-1)
#endif

/* Substitute bogus value if CLOCKS_PER_SEC is unavailable */
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC -1
#endif
#ifndef RAND_MAX
#define RAND_MAX (UINT_MAX)
#endif

#define TEST_SIZE 100001

#define SOURCE_STRIDE 2 /* space out the strides for source & dest. */
#define DEST_STRIDE   3

/* define aliases for random number generation */
#define RAND    rand
#define SEED(a) srand((unsigned)(a))

#ifdef NO_TIMING
#define clock() (0)
#endif

extern int Verbocity;

/* Local variables */
static int32       test_type[] = {0, DFNT_LITEND, DFNT_NATIVE};
static const char *test_name[] = {"Big-Endian", "Little-Endian", "Native"};

/* for those machines with imprecise IEEE<-> conversions, this should be */
/* close enough */
#define EPS64 ((float64)1.0E-14)
#define EPS32 ((float32)1.0E-7)
void
test_conv(void)
{
    clock_t  c1, c2, c3, c4;
    uint8   *src_uint8, *dst_uint8, *dst2_uint8;
    uint16  *src_uint16, *dst_uint16, *dst2_uint16;
    uint32  *src_uint32, *dst_uint32, *dst2_uint32;
    int8    *src_int8, *dst_int8, *dst2_int8;
    int16   *src_int16, *dst_int16, *dst2_int16;
    int32   *src_int32, *dst_int32, *dst2_int32;
    float32 *src_float32, *dst_float32, *dst2_float32;
    float64 *src_float64, *dst_float64, *dst2_float64;
    intn     i, r;
    intn     t;
    int32    ret;

    SEED((int)time(NULL)); /* seed with effectively random number */

    for (t = 0; (size_t)t < sizeof(test_type) / sizeof(int32); t++) {
        MESSAGE(5, printf("Testing %s Number-Types\n", test_name[t]););
        MESSAGE(6, printf("seeding int8 array\n"););

        /* allocate arrays */
        src_int8 = (int8 *)malloc(TEST_SIZE * sizeof(int8));
        if (src_int8 == NULL) {
            CHECK_VOID(src_int8, NULL, "malloc");
            return;
        } /* end if */
        dst_int8 = (int8 *)malloc(TEST_SIZE * sizeof(int8));
        if (dst_int8 == NULL) {
            CHECK_VOID(dst_int8, NULL, "malloc");
            return;
        } /* end if */
        dst2_int8 = (int8 *)malloc(TEST_SIZE * sizeof(int8));
        if (dst2_int8 == NULL) {
            CHECK_VOID(dst2_int8, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++)
            src_int8[i] = (int8)(RAND() - RAND_MAX / 2);

        MESSAGE(6, printf("converting %s int8 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_int8, (void *)dst_int8, test_type[t] | DFNT_INT8, TEST_SIZE, DFACC_WRITE,
                         0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int8 values\n", (int)(c2 - c1), (int)CLOCKS_PER_SEC,
                          (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s int8 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_int8, (void *)dst2_int8, test_type[t] | DFNT_INT8, TEST_SIZE, DFACC_READ,
                         0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int8 values\n", (int)(c4 - c3), (int)CLOCKS_PER_SEC,
                          (int)TEST_SIZE, test_name[t]););
        if (memcmp(src_int8, dst2_int8, TEST_SIZE * sizeof(int8))) {
            printf("Error converting %s int8 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_int8, 0xae, TEST_SIZE * sizeof(int8));
        memset(dst_int8, 0xae, TEST_SIZE * sizeof(int8));
        memset(dst2_int8, 0xae, TEST_SIZE * sizeof(int8));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE)
            src_int8[i] = (int8)(RAND() - RAND_MAX / 2);

        MESSAGE(6, printf("converting %s int8 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_int8, (void *)dst_int8, test_type[t] | DFNT_INT8, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(int8), DEST_STRIDE * sizeof(int8));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int8 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s int8 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c3  = clock();
        ret = DFKconvert((void *)dst_int8, (void *)dst2_int8, test_type[t] | DFNT_INT8, TEST_SIZE / 4,
                         DFACC_READ, DEST_STRIDE * sizeof(int8), SOURCE_STRIDE * sizeof(int8));
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int8 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_int8, dst2_int8, (TEST_SIZE / 2) * sizeof(int8))) {
            printf("Error converting %s int8 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_int8);
        free(dst_int8);
        free(dst2_int8);

        MESSAGE(6, printf("seeding %s uint8 array\n", test_name[t]););
        src_uint8 = (uint8 *)malloc(TEST_SIZE * sizeof(uint8));
        if (src_uint8 == NULL) {
            CHECK_VOID(src_uint8, NULL, "malloc");
            return;
        } /* end if */
        dst_uint8 = (uint8 *)malloc(TEST_SIZE * sizeof(uint8));
        if (dst_uint8 == NULL) {
            CHECK_VOID(dst_uint8, NULL, "malloc");
            return;
        } /* end if */
        dst2_uint8 = (uint8 *)malloc(TEST_SIZE * sizeof(uint8));
        if (dst2_uint8 == NULL) {
            CHECK_VOID(dst2_uint8, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++)
            src_uint8[i] = (uint8)RAND();

        MESSAGE(6, printf("converting %s uint8 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_uint8, (void *)dst_uint8, test_type[t] | DFNT_UINT8, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint8 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s uint8 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_uint8, (void *)dst2_uint8, test_type[t] | DFNT_UINT8, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint8 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););
        if (memcmp(src_uint8, dst2_uint8, TEST_SIZE * sizeof(uint8))) {
            printf("Error converting %s uint8 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_uint8, 0xae, TEST_SIZE * sizeof(uint8));
        memset(dst_uint8, 0xae, TEST_SIZE * sizeof(uint8));
        memset(dst2_uint8, 0xae, TEST_SIZE * sizeof(uint8));

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE)
            src_uint8[i] = (uint8)RAND();

        MESSAGE(6, printf("converting %s uint8 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_uint8, (void *)dst_uint8, test_type[t] | DFNT_UINT8, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(uint8), DEST_STRIDE * sizeof(uint8));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint8 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s uint8 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3  = clock();
        ret = DFKconvert((void *)dst_uint8, (void *)dst2_uint8, test_type[t] | DFNT_UINT8, TEST_SIZE / 4,
                         DFACC_READ, DEST_STRIDE * sizeof(uint8), SOURCE_STRIDE * sizeof(uint8));
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint8 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_uint8, dst2_uint8, (TEST_SIZE / 2) * sizeof(uint8))) {
            printf("Error converting %s uint8 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_uint8);
        free(dst_uint8);
        free(dst2_uint8);

        MESSAGE(6, printf("seeding %s int16 array\n", test_name[t]););
        src_int16 = (int16 *)malloc(TEST_SIZE * sizeof(int16));
        if (src_int16 == NULL) {
            CHECK_VOID(src_int16, NULL, "malloc");
            return;
        } /* end if */
        dst_int16 = (int16 *)malloc(TEST_SIZE * sizeof(int16));
        if (dst_int16 == NULL) {
            CHECK_VOID(dst_int16, NULL, "malloc");
            return;
        } /* end if */
        dst2_int16 = (int16 *)malloc(TEST_SIZE * sizeof(int16));
        if (dst2_int16 == NULL) {
            CHECK_VOID(dst2_int16, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++)
            src_int16[i] = (int16)(RAND() - RAND_MAX / 2);

        MESSAGE(6, printf("converting %s int16 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_int16, (void *)dst_int16, test_type[t] | DFNT_INT16, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int16 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s int16 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_int16, (void *)dst2_int16, test_type[t] | DFNT_INT16, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int16 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););
        if (memcmp(src_int16, dst2_int16, TEST_SIZE * sizeof(int16))) {
            printf("Error converting %s int16 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_int16, 0xae, TEST_SIZE * sizeof(int16));
        memset(dst_int16, 0xae, TEST_SIZE * sizeof(int16));
        memset(dst2_int16, 0xae, TEST_SIZE * sizeof(int16));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE)
            src_int16[i] = (int16)(RAND() - RAND_MAX / 2);

        MESSAGE(6, printf("converting %s int16 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_int16, (void *)dst_int16, test_type[t] | DFNT_INT16, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(int16), DEST_STRIDE * sizeof(int16));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int16 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s int16 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3  = clock();
        ret = DFKconvert((void *)dst_int16, (void *)dst2_int16, test_type[t] | DFNT_INT16, TEST_SIZE / 4,
                         DFACC_READ, DEST_STRIDE * sizeof(int16), SOURCE_STRIDE * sizeof(int16));
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int16 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_int16, dst2_int16, (TEST_SIZE / 2) * sizeof(int16))) {
            printf("Error converting %s int16 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        free(src_int16);
        free(dst_int16);
        free(dst2_int16);

        MESSAGE(6, printf("seeding %s uint16 array\n", test_name[t]););
        src_uint16 = (uint16 *)malloc(TEST_SIZE * sizeof(uint16));
        if (src_uint16 == NULL) {
            CHECK_VOID(src_uint16, NULL, "malloc");
            return;
        } /* end if */
        dst_uint16 = (uint16 *)malloc(TEST_SIZE * sizeof(uint16));
        if (dst_uint16 == NULL) {
            CHECK_VOID(dst_uint16, NULL, "malloc");
            return;
        } /* end if */
        dst2_uint16 = (uint16 *)malloc(TEST_SIZE * sizeof(uint16));
        if (dst2_uint16 == NULL) {
            CHECK_VOID(dst2_uint16, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++)
            src_uint16[i] = (uint16)RAND();

        MESSAGE(6, printf("converting %s uint16 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_uint16, (void *)dst_uint16, test_type[t] | DFNT_UINT16, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint16 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s uint16 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_uint16, (void *)dst2_uint16, test_type[t] | DFNT_UINT16, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint16 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););
        if (memcmp(src_uint16, dst2_uint16, TEST_SIZE * sizeof(uint16))) {
            printf("Error converting %s uint16 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_uint16, 0xae, TEST_SIZE * sizeof(uint16));
        memset(dst_uint16, 0xae, TEST_SIZE * sizeof(uint16));
        memset(dst2_uint16, 0xae, TEST_SIZE * sizeof(uint16));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE)
            src_uint16[i] = (uint16)RAND();

        MESSAGE(6, printf("converting %s uint16 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_uint16, (void *)dst_uint16, test_type[t] | DFNT_UINT16, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(uint16), DEST_STRIDE * sizeof(uint16));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint16 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s uint16 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3  = clock();
        ret = DFKconvert((void *)dst_uint16, (void *)dst2_uint16, test_type[t] | DFNT_UINT16, TEST_SIZE / 4,
                         DFACC_READ, DEST_STRIDE * sizeof(uint16), SOURCE_STRIDE * sizeof(uint16));
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint16 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_uint16, dst2_uint16, (TEST_SIZE / 2) * sizeof(uint16))) {
            printf("Error converting %s uint16 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_uint16);
        free(dst_uint16);
        free(dst2_uint16);

        MESSAGE(6, printf("seeding %s int32 array\n", test_name[t]););
        src_int32 = (int32 *)malloc(TEST_SIZE * sizeof(int32));
        if (src_int32 == NULL) {
            CHECK_VOID(src_int32, NULL, "malloc");
            return;
        } /* end if */
        dst_int32 = (int32 *)malloc(TEST_SIZE * sizeof(int32));
        if (dst_int32 == NULL) {
            CHECK_VOID(dst_int32, NULL, "malloc");
            return;
        } /* end if */
        dst2_int32 = (int32 *)malloc(TEST_SIZE * sizeof(int32));
        if (dst2_int32 == NULL) {
            CHECK_VOID(dst2_int32, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++)
            src_int32[i] = (int32)(RAND() - RAND_MAX / 2);

        MESSAGE(6, printf("converting %s int32 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_int32, (void *)dst_int32, test_type[t] | DFNT_INT32, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int32 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s int32 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_int32, (void *)dst2_int32, test_type[t] | DFNT_INT32, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int32 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););
        if (memcmp(src_int32, dst2_int32, TEST_SIZE * sizeof(int32))) {
            printf("Error converting %s int32 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_int32, 0xae, TEST_SIZE * sizeof(int32));
        memset(dst_int32, 0xae, TEST_SIZE * sizeof(int32));
        memset(dst2_int32, 0xae, TEST_SIZE * sizeof(int32));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE)
            src_int32[i] = (int32)(RAND() - RAND_MAX / 2);

        MESSAGE(6, printf("converting %s int32 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_int32, (void *)dst_int32, test_type[t] | DFNT_INT32, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(int32), DEST_STRIDE * sizeof(int32));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int32 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s int32 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3  = clock();
        ret = DFKconvert((void *)dst_int32, (void *)dst2_int32, test_type[t] | DFNT_INT32, TEST_SIZE / 4,
                         DFACC_READ, DEST_STRIDE * sizeof(int32), SOURCE_STRIDE * sizeof(int32));
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s int32 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_int32, dst2_int32, (TEST_SIZE / 2) * sizeof(int32))) {
            printf("Error converting %s int32 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_int32);
        free(dst_int32);
        free(dst2_int32);

        MESSAGE(6, printf("seeding %s uint32 array\n", test_name[t]););
        src_uint32 = (uint32 *)malloc(TEST_SIZE * sizeof(uint32));
        if (src_uint32 == NULL) {
            CHECK_VOID(src_uint32, NULL, "malloc");
            return;
        } /* end if */
        dst_uint32 = (uint32 *)malloc(TEST_SIZE * sizeof(uint32));
        if (dst_uint32 == NULL) {
            CHECK_VOID(dst_uint32, NULL, "malloc");
            return;
        } /* end if */
        dst2_uint32 = (uint32 *)malloc(TEST_SIZE * sizeof(uint32));
        if (dst2_uint32 == NULL) {
            CHECK_VOID(dst2_uint32, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++)
            src_uint32[i] = (uint32)RAND();

        MESSAGE(6, printf("converting %s uint32 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_uint32, (void *)dst_uint32, test_type[t] | DFNT_UINT32, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint32 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s uint32 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_uint32, (void *)dst2_uint32, test_type[t] | DFNT_UINT32, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint32 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););
        if (memcmp(src_uint32, dst2_uint32, TEST_SIZE * sizeof(uint32))) {
            printf("Error converting %s uint32 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_uint32, 0xae, TEST_SIZE * sizeof(uint32));
        memset(dst_uint32, 0xae, TEST_SIZE * sizeof(uint32));
        memset(dst2_uint32, 0xae, TEST_SIZE * sizeof(uint32));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE)
            src_uint32[i] = (uint32)RAND();

        MESSAGE(6, printf("converting %s uint32 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_uint32, (void *)dst_uint32, test_type[t] | DFNT_UINT32, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(uint32), DEST_STRIDE * sizeof(uint32));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint32 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s uint32 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3  = clock();
        ret = DFKconvert((void *)dst_uint32, (void *)dst2_uint32, test_type[t] | DFNT_UINT32, TEST_SIZE / 4,
                         DFACC_READ, DEST_STRIDE * sizeof(uint32), SOURCE_STRIDE * sizeof(uint32));
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s uint32 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_uint32, dst2_uint32, (TEST_SIZE / 2) * sizeof(uint32))) {
            printf("Error converting %s uint32 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_uint32);
        free(dst_uint32);
        free(dst2_uint32);

        MESSAGE(6, printf("seeding %s float32 array\n", test_name[t]););
        src_float32 = (float32 *)malloc(TEST_SIZE * sizeof(float32));
        if (src_float32 == NULL) {
            CHECK_VOID(src_float32, NULL, "malloc");
            return;
        } /* end if */
        dst_float32 = (float32 *)malloc(TEST_SIZE * sizeof(float32));
        if (dst_float32 == NULL) {
            CHECK_VOID(dst_float32, NULL, "malloc");
            return;
        } /* end if */
        dst2_float32 = (float32 *)malloc(TEST_SIZE * sizeof(float32));
        if (dst2_float32 == NULL) {
            CHECK_VOID(dst2_float32, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++) {
            src_float32[i] = (float32)(RAND() - RAND_MAX / 2);
            while ((r = RAND()) == 0) /* don't divide by zero */
                r = RAND();
            src_float32[i] /= (float32)r;
        } /* end for */

        MESSAGE(6, printf("converting %s float32 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_float32, (void *)dst_float32, test_type[t] | DFNT_FLOAT32, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float32 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s float32 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_float32, (void *)dst2_float32, test_type[t] | DFNT_FLOAT32, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float32 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        if (memcmp(src_float32, dst2_float32, TEST_SIZE * sizeof(float32))) {
            printf("Error converting %s float32 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_float32, 0xae, TEST_SIZE * sizeof(float32));
        memset(dst_float32, 0xae, TEST_SIZE * sizeof(float32));
        memset(dst2_float32, 0xae, TEST_SIZE * sizeof(float32));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE) {
            src_float32[i] = (float32)(RAND() - RAND_MAX / 2);
            while ((r = RAND()) == 0) /* don't divide by zero */
                r = RAND();
            src_float32[i] /= (float32)r;
        } /* end for */

        MESSAGE(6, printf("converting %s float32 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_float32, (void *)dst_float32, test_type[t] | DFNT_FLOAT32, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(float32), DEST_STRIDE * sizeof(float32));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float32 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s float32 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3 = clock();
        ret =
            DFKconvert((void *)dst_float32, (void *)dst2_float32, test_type[t] | DFNT_FLOAT32, TEST_SIZE / 4,
                       DFACC_READ, DEST_STRIDE * sizeof(float32), SOURCE_STRIDE * sizeof(float32));
        c4 = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float32 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););

        if (memcmp(src_float32, dst2_float32, (TEST_SIZE / 2) * sizeof(float32))) {
            printf("Error converting %s float32 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_float32);
        free(dst_float32);
        free(dst2_float32);

        MESSAGE(6, printf("seeding %s float64 array\n", test_name[t]););
        src_float64 = (float64 *)malloc(TEST_SIZE * sizeof(float64));
        if (src_float64 == NULL) {
            CHECK_VOID(src_float64, NULL, "malloc");
            return;
        } /* end if */
        dst_float64 = (float64 *)malloc(TEST_SIZE * sizeof(float64));
        if (dst_float64 == NULL) {
            CHECK_VOID(dst_float64, NULL, "malloc");
            return;
        } /* end if */
        dst2_float64 = (float64 *)malloc(TEST_SIZE * sizeof(float64));
        if (dst2_float64 == NULL) {
            CHECK_VOID(dst2_float64, NULL, "malloc");
            return;
        } /* end if */

        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i++) {
            src_float64[i] = (float64)(RAND() - RAND_MAX / 2);
            while ((r = RAND()) == 0) /* don't divide by zero */
                r = RAND();
            src_float64[i] /= (float64)r;
        } /* end for */

        MESSAGE(6, printf("converting %s float64 array\n", test_name[t]););
        c1  = clock();
        ret = DFKconvert((void *)src_float64, (void *)dst_float64, test_type[t] | DFNT_FLOAT64, TEST_SIZE,
                         DFACC_WRITE, 0, 0);
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float64 values\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        MESSAGE(6, printf("re-converting %s float64 array\n", test_name[t]););
        c3  = clock();
        ret = DFKconvert((void *)dst_float64, (void *)dst2_float64, test_type[t] | DFNT_FLOAT64, TEST_SIZE,
                         DFACC_READ, 0, 0);
        c4  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float64 values\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t]););

        if (memcmp(src_float64, dst2_float64, TEST_SIZE * sizeof(float64))) {
            printf("Error converting %s float64 values!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        } /* end if */

        /* clear arrays for next test */
        memset(src_float64, 0xae, TEST_SIZE * sizeof(float64));
        memset(dst_float64, 0xae, TEST_SIZE * sizeof(float64));
        memset(dst2_float64, 0xae, TEST_SIZE * sizeof(float64));
        /* Seed arrays with random values */
        for (i = 0; i < TEST_SIZE; i += SOURCE_STRIDE) {
            src_float64[i] = (float64)(RAND() - RAND_MAX / 2);
            while ((r = RAND()) == 0) /* don't divide by zero */
                r = RAND();
            src_float64[i] /= (float64)r;
        } /* end for */

        MESSAGE(6, printf("converting %s float64 array with %d/%d stride\n", test_name[t], SOURCE_STRIDE,
                          DEST_STRIDE););
        c1  = clock();
        ret = DFKconvert((void *)src_float64, (void *)dst_float64, test_type[t] | DFNT_FLOAT64, TEST_SIZE / 4,
                         DFACC_WRITE, SOURCE_STRIDE * sizeof(float64), DEST_STRIDE * sizeof(float64));
        c2  = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float64 values with %d/%d stride\n", (int)(c2 - c1),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], SOURCE_STRIDE, DEST_STRIDE););

        MESSAGE(6, printf("re-converting %s float64 array with %d/%d stride\n", test_name[t], DEST_STRIDE,
                          SOURCE_STRIDE););
        c3 = clock();
        ret =
            DFKconvert((void *)dst_float64, (void *)dst2_float64, test_type[t] | DFNT_FLOAT64, TEST_SIZE / 4,
                       DFACC_READ, DEST_STRIDE * sizeof(float64), SOURCE_STRIDE * sizeof(float64));
        c4 = clock();
        RESULT("DFKconvert");
        MESSAGE(6, printf("%d/%d seconds to convert %d %s float64 values with %d/%d stride\n", (int)(c4 - c3),
                          (int)CLOCKS_PER_SEC, (int)TEST_SIZE, test_name[t], DEST_STRIDE, SOURCE_STRIDE););
        if (memcmp(src_float64, dst2_float64, (TEST_SIZE / 2) * sizeof(float64))) {
            printf("Error converting %s float64 values with strides!\n", test_name[t]);
            HEprint(stdout, 0);
            num_errs++;
        }

        free(src_float64);
        free(dst_float64);
        free(dst2_float64);
    } /* end for */

} /* end test_conv() */