-
Notifications
You must be signed in to change notification settings - Fork 10
Error Handling
There is only one error handling in Cekirdekler API. That is the kernel compiling part. Opencl kernel compiling takes place in initialization part of ClNumberCruncher
and if compiler returns any error then it writes error message to console before disposing resources:
ClNumberCruncher cr = new ClNumberCruncher(AcceleratorType.GPU, kernelString);
even then, it can explicitly be checked for kernel compile errors as
if(cr.errorCode()!=0)
{ Console.WriteLine(cr.errorMessage());}
To test if the API works in a computer, there is a Tester
class which includes various tests that try all features of the API. After each sub-test, it outputs " ... ok" to console. Here is an example:
Tester.buffers();
Tester.nBody();
Tester.stream_C_equals_A_plus_B_1M_elements();
and its output is:
ClArray<byte>: ok
ClArray<char>: ok
ClArray<int>: ok
ClArray<uint>: ok
ClArray<float>: ok
ClArray<double>: ok
ClArray<long>: ok
buffers on host: ok
1 cores are chosen for compute(equals to device partition cores).
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 823,3025 milliseconds, compute range: 4096 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 158,8537 milliseconds, compute range: 4096 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 622,7168 milliseconds, compute range: 3264 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 45,0568 milliseconds, compute range: 4928 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 565,9713 milliseconds, compute range: 2368 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 63,2615 milliseconds, compute range: 5824 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 358,5663 milliseconds, compute range: 1792 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 42,8148 milliseconds, compute range: 6400 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 289,4351 milliseconds, compute range: 1344 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 31,0793 milliseconds, compute range: 6848 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 210,2 milliseconds, compute range: 1024 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 46,5224 milliseconds, compute range: 7168 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 198,6732 milliseconds, compute range: 768 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 36,9323 milliseconds, compute range: 7424 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 148,7996 milliseconds, compute range: 576 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 57,3093 milliseconds, compute range: 7616 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 99,2876 milliseconds, compute range: 448 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 42,5536 milliseconds, compute range: 7744 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 72,7152 milliseconds, compute range: 384 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 53,0231 milliseconds, compute range: 7808 workitems
Nbody force: fx[0]=15,73707 fxCl[0]=15,73707
fy[0]=15,73707 fyCl[0]=15,73707
Nbody force: fx[1000]=-116,9371 fxCl[1000]=-116,9371
fy[1000]=-116,9371 fyCl[1000]=-116,9371
Nbody force: fx[2000]=-21,3874 fxCl[2000]=-21,3874
fy[2000]=-21,3874 fyCl[2000]=-21,3874
Nbody force: fx[3000]=-19,55867 fxCl[3000]=-19,55867
fy[3000]=-19,55867 fyCl[3000]=-19,55867
Nbody force: fx[4000]=24,85364 fxCl[4000]=24,85365
fy[4000]=24,85364 fyCl[4000]=24,85365
Nbody force: fx[5000]=46,26453 fxCl[5000]=46,26453
fy[5000]=46,26453 fyCl[5000]=46,26453
Nbody force: fx[6000]=-26,38706 fxCl[6000]=-26,38706
fy[6000]=-26,38706 fyCl[6000]=-26,38706
Nbody force: fx[7000]=28,82827 fxCl[7000]=28,82827
fy[7000]=28,82827 fyCl[7000]=28,82827
Nbody force: fx[8000]=-51,25406 fxCl[8000]=-51,25406
fy[8000]=-51,25406 fyCl[8000]=-51,25406
releasing nbody resources
nbody: ok
1 cores are chosen for compute(equals to device partition cores).
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 61,2089 milliseconds, compute range: 524288 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 69,4627 milliseconds, compute range: 524288 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 25,3352 milliseconds, compute range: 534528 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 23,5777 milliseconds, compute range: 514048 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 25,7025 milliseconds, compute range: 528384 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 18,7513 milliseconds, compute range: 520192 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 69,9068 milliseconds, compute range: 503808 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 73,7373 milliseconds, compute range: 544768 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 4,1274 milliseconds, compute range: 507904 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 20,5593 milliseconds, compute range: 540672 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 9,3014 milliseconds, compute range: 614400 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 41,1046 milliseconds, compute range: 434176 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 10,7657 milliseconds, compute range: 700416 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 25,7102 milliseconds, compute range: 348160 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 11,345 milliseconds, compute range: 751616 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 28,8732 milliseconds, compute range: 296960 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 7,4242 milliseconds, compute range: 798720 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 16,1169 milliseconds, compute range: 249856 workitems
Device 0(system-RAM): Intel(R) Celeron(R) CPU N3060 @ 1.60GHz, compute time: 8,1813 milliseconds, compute range: 833536 workitems
Device 1(system-RAM): Intel(R) HD Graphics 400, compute time: 22,2701 milliseconds, compute range: 215040 workitems
Streaming c[i]=a[i]+b[i]: ok
when Tester
methods receive an un-finished result, they return 1, otherwise they return 0 as an "ok".
This way, at least implementation defined errors are ruled-out. Other errors such as using wrong buffer size or wrong global workitem size or wrong array type or anything wrong, can have thousands of combinations to generate an error like an access violation or a fatal error.