()
| 29 | public class LoadClTest { |
| 30 | |
| 31 | @Test |
| 32 | public void test() { |
| 33 | final int size = 32; |
| 34 | final float[] in = new float[size]; |
| 35 | |
| 36 | for (int i = 0; i < size; i++) { |
| 37 | in[i] = i; |
| 38 | } |
| 39 | |
| 40 | final float[] squares = new float[size]; |
| 41 | final float[] quads = new float[size]; |
| 42 | final Range range = Range.create(size); |
| 43 | |
| 44 | final Device device = KernelManager.instance().bestDevice(); |
| 45 | |
| 46 | if (device instanceof OpenCLDevice) { |
| 47 | final OpenCLDevice openclDevice = (OpenCLDevice) device; |
| 48 | |
| 49 | final Squarer squarer = openclDevice.bind(Squarer.class); |
| 50 | squarer.square(range, in, squares); |
| 51 | |
| 52 | for (int i = 0; i < size; i++) { |
| 53 | assertTrue("in[" + i + "] * in[" + i + "] = in[" + i + "]^2", in[i] * in[i] == squares[i]); |
| 54 | } |
| 55 | |
| 56 | squarer.square(range, squares, quads); |
| 57 | |
| 58 | for (int i = 0; i < size; i++) { |
| 59 | assertTrue("in[" + i + "]^2 * in[" + i + "]^2 = in[" + i + "]^4", in[i] * in[i] * in[i] * in[i] == quads[i]); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | @Resource("squarer.cl") |
| 65 | interface Squarer extends OpenCL<Squarer> { |
nothing calls this directly
no test coverage detected