1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //    http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #include "mt19937.h"
17 #include <stdio.h>
18 
main(void)19 int main(void)
20 {
21     MTdata d = init_genrand(42);
22     int i;
23     const cl_uint reference[16] = {
24         0x5fe1dc66, 0x8b255210, 0x0380b0c8, 0xc87d2ce4, 0x55c31f24, 0x8bcd21ab,
25         0x14d5fef5, 0x9416d2b6, 0xdf875de9, 0x00517d76, 0xd861c944, 0xa7676404,
26         0x5491aff4, 0x67616209, 0xc368b3fb, 0x929dfc92
27     };
28     int errcount = 0;
29 
30     for (i = 0; i < 65536; i++)
31     {
32         cl_uint u = genrand_int32(d);
33         if (0 == (i & 4095))
34         {
35             if (u != reference[i >> 12])
36             {
37                 printf("ERROR: expected *0x%8.8x at %d.  Got 0x%8.8x\n",
38                        reference[i >> 12], i, u);
39                 errcount++;
40             }
41         }
42     }
43 
44     free_mtdata(d);
45 
46     if (errcount)
47         printf("mt19937 test failed.\n");
48     else
49         printf("mt19937 test passed.\n");
50 
51 
52     return 0;
53 }