diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2012-03-07 15:53:18 -0500 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2012-03-07 15:53:18 -0500 |
commit | aa88e1e8aafe3467d77c6ce0003fc3e9ce32281f (patch) | |
tree | b8e6f408c01ed2d754307623ca06458de2559f0c | |
parent | ccce1755276f22ce1e67a70a6b7be2c61986ea12 (diff) |
Add more modulo tests
-rw-r--r-- | mod_four.cl | 5 | ||||
-rw-r--r-- | mod_nine.cl | 5 | ||||
-rw-r--r-- | run_tests.sh | 15 |
3 files changed, 24 insertions, 1 deletions
diff --git a/mod_four.cl b/mod_four.cl new file mode 100644 index 0000000..4ef7583 --- /dev/null +++ b/mod_four.cl @@ -0,0 +1,5 @@ + +__kernel void mod_four(__global int * out, int arg0, int arg1) +{ + out[0] = arg0 % 4; +} diff --git a/mod_nine.cl b/mod_nine.cl new file mode 100644 index 0000000..46672a1 --- /dev/null +++ b/mod_nine.cl @@ -0,0 +1,5 @@ + +__kernel void mod_nine(__global int * out, int arg0, int arg1) +{ + out[0] = arg0 % 9; +} diff --git a/run_tests.sh b/run_tests.sh index ea83e92..b26b9c4 100644 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,5 +1,5 @@ MAX_SINT="2147483647" -MIN_SING="-2147483648" +MIN_SINT="-2147483648" (( FAIL = 0 )) (( PASS = 0 )) @@ -88,5 +88,18 @@ run_test "./math-int mod 16 -3 1" run_test "./math-int mod ${MAX_SINT} 12345 9172" #Test arg1 = MIN_SINT (In the real world MIN_SING % 476 = 348) run_test "./math-int mod ${MIN_SINT} 476 -128" +#Test arg0 < arg1 +run_test "./math-int mod 10 20 10" + +#Test division paths with a constant divisor that are optimized with shifts +#(The second argument to these tests is ignored) +#Constant non-power of two divisor, modulo is zero +run_test "./math-int mod_nine 18 9 0" +#Constant non-power of two divisor, modulo is non-zero +run_test "./math-int mod_nine 23 9 5" +#Constant power of two divisor, modulo is zero +run_test "./math-int mod_four 20 4 0" +#Constant power of two divisor, modulo is non-zero +run_test "./math-int mod_four 5 4 1" echo "$PASS passes, $FAIL fails" |