private void checkMixFloat4Float4FloatFloat4() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x64e44bb30a701d3dl, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb4f372e0715beb33l, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf258b71221bfbc69l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloat4Float4FloatFloat4(inStart, out); verifyResultsMixFloat4Float4FloatFloat4(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat4Float4FloatFloat4: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloat4Float4FloatFloat4(inStart, out); verifyResultsMixFloat4Float4FloatFloat4(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat4Float4FloatFloat4: " + e.toString()); } }
private void checkMixFloat2Float2FloatFloat2() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf811b2d52bd1d7c3l, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x17a127e13c8dd1c5l, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaaf909cdbd2a10ebl, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloat2Float2FloatFloat2(inStart, out); verifyResultsMixFloat2Float2FloatFloat2(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat2Float2FloatFloat2: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloat2Float2FloatFloat2(inStart, out); verifyResultsMixFloat2Float2FloatFloat2(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat2Float2FloatFloat2: " + e.toString()); } }
private void checkMixFloat3Float3FloatFloat3() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xae7aff441b20fa80l, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe64a4d60d6f4de7cl, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4ea8e06fef74e6aal, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloat3Float3FloatFloat3(inStart, out); verifyResultsMixFloat3Float3FloatFloat3(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat3Float3FloatFloat3: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloat3Float3FloatFloat3(inStart, out); verifyResultsMixFloat3Float3FloatFloat3(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat3Float3FloatFloat3: " + e.toString()); } }
private void checkMixFloat4Float4Float4Float4() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd818b19f433276a1l, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c186362f5a7e15fl, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4c25d5bfaa64c035l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloat4Float4Float4Float4(inStart, out); verifyResultsMixFloat4Float4Float4Float4(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat4Float4Float4Float4: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloat4Float4Float4Float4(inStart, out); verifyResultsMixFloat4Float4Float4Float4(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat4Float4Float4Float4: " + e.toString()); } }
private void checkMixFloatFloatFloatFloat() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f4beff6471d6db1l, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6ede0b88b4422e8fl, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc1c14e5d52dc3fe5l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloatFloatFloatFloat(inStart, out); verifyResultsMixFloatFloatFloatFloat(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloatFloatFloatFloat: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloatFloatFloatFloat(inStart, out); verifyResultsMixFloatFloatFloatFloat(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloatFloatFloatFloat: " + e.toString()); } }
private void checkMixFloat2Float2Float2Float2() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x45502e8f0a2d9ce9l, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xba2b8a035395e837l, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa477d20616942e4dl, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloat2Float2Float2Float2(inStart, out); verifyResultsMixFloat2Float2Float2Float2(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat2Float2Float2Float2: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloat2Float2Float2Float2(inStart, out); verifyResultsMixFloat2Float2Float2Float2(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat2Float2Float2Float2: " + e.toString()); } }
private void checkMixFloat3Float3Float3Float3() { Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xeb4701726b009c5l, false); Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9b21f6b3249ee4cbl, false); Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x784ed3e2e07c7741l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); script.set_gAllocInStop(inStop); script.set_gAllocInAmount(inAmount); script.forEach_testMixFloat3Float3Float3Float3(inStart, out); verifyResultsMixFloat3Float3Float3Float3(inStart, inStop, inAmount, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat3Float3Float3Float3: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); scriptRelaxed.set_gAllocInStop(inStop); scriptRelaxed.set_gAllocInAmount(inAmount); scriptRelaxed.forEach_testMixFloat3Float3Float3Float3(inStart, out); verifyResultsMixFloat3Float3Float3Float3(inStart, inStop, inAmount, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testMixFloat3Float3Float3Float3: " + e.toString()); } }
private void float4input(long seed, int testId) { Allocation mAllocationIn = Allocation.createSized(mRS, Element.F32_4(mRS), INPUTSIZE); Allocation mAllocationOut = Allocation.createSized(mRS, Element.U8_4(mRS), INPUTSIZE); float[] inArray = new float[INPUTSIZE * 4]; byte[] outArray = new byte[INPUTSIZE * 4]; byte[] refArray = new byte[INPUTSIZE * 4]; RSUtils.genRandom(seed, 1, 0, inArray); mAllocationIn.copy1DRangeFrom(0, INPUTSIZE, inArray); try { RSUtils.forEach(this, testId, mAllocationIn, mAllocationOut); } catch (RSRuntimeException e) { } mAllocationOut.copyTo(outArray); for (int i = 0; i < outArray.length; i += 4) { int offset = i; Float4 inValues = new Float4( inArray[offset], inArray[offset + 1], inArray[offset + 2], inArray[offset + 3]); byte[] cValue = rs_PackColorTo8888(inValues); refArray[i] = cValue[0]; refArray[i + 1] = cValue[1]; refArray[i + 2] = cValue[2]; refArray[i + 3] = cValue[3]; for (int j = 0; j < 4; j++) { assertEquals(refArray[i + j] & 0xff, outArray[i + j] & 0xff); } } }
protected void createWalk(int vsize) { // We do a random copy order to attempt to get multiple threads // reading and writing the same cache line // We could do this as a simple walk but that would likely miss // some caching issues. final int tw = gCount / vsize; int tmp[] = new int[tw]; boolean b[] = new boolean[tw]; int toCopy = tw; int i = 0; while (toCopy > 0) { int x = random.nextInt(tw); while ((x < tw) && b[x]) { x++; if (x >= tw) { x = 0; } } b[x] = true; toCopy--; // android.util.Log.v("rs", "walk " + i + ", " + x); tmp[i++] = x; } walkAlloc = Allocation.createSized(mRS, Element.I32(mRS), tw); walkAlloc.copy1DRangeFrom(0, tw, tmp); }
public void convert(byte[] mYUVData, int imageWidth, int imageHeight, Allocation mOutAllocation) { set_imageHeight(imageHeight); set_imageWidth(imageWidth); try { yuvAllocation.copyFrom(mYUVData); } catch (Throwable t) { yuvAllocation = Allocation.createSized(mRS, Element.I8(mRS), mYUVData.length); yuvAllocation.copyFrom(mYUVData); } set_yuvData(yuvAllocation); invoke_convert(this, mOutAllocation, mOutAllocation); }
private void checkSinpiFloatFloat() { Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdfd6b42cl, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); script.forEach_testSinpiFloatFloat(inV, out); verifyResultsSinpiFloatFloat(inV, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testSinpiFloatFloat: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); scriptRelaxed.forEach_testSinpiFloatFloat(inV, out); verifyResultsSinpiFloatFloat(inV, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testSinpiFloatFloat: " + e.toString()); } }
private void checkCeilFloat4Float4() { Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2f4b6b34l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); script.forEach_testCeilFloat4Float4(inV, out); verifyResultsCeilFloat4Float4(inV, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testCeilFloat4Float4: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); scriptRelaxed.forEach_testCeilFloat4Float4(inV, out); verifyResultsCeilFloat4Float4(inV, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testCeilFloat4Float4: " + e.toString()); } }
private void checkIlogbFloat3Int3() { Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9b3a97l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); script.forEach_testIlogbFloat3Int3(inV, out); verifyResultsIlogbFloat3Int3(inV, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testIlogbFloat3Int3: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); scriptRelaxed.forEach_testIlogbFloat3Int3(inV, out); verifyResultsIlogbFloat3Int3(inV, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testIlogbFloat3Int3: " + e.toString()); } }
private void checkNativeAcospiFloat3Float3() { Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6f03ab89l, -1, 1); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); script.forEach_testNativeAcospiFloat3Float3(inV, out); verifyResultsNativeAcospiFloat3Float3(inV, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testNativeAcospiFloat3Float3: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); scriptRelaxed.forEach_testNativeAcospiFloat3Float3(inV, out); verifyResultsNativeAcospiFloat3Float3(inV, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testNativeAcospiFloat3Float3: " + e.toString()); } }
private void checkExpm1Float3Float3() { Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5916473e315c8b90l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); script.forEach_testExpm1Float3Float3(in, out); verifyResultsExpm1Float3Float3(in, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testExpm1Float3Float3: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); scriptRelaxed.forEach_testExpm1Float3Float3(in, out); verifyResultsExpm1Float3Float3(in, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testExpm1Float3Float3: " + e.toString()); } }
private void checkRootnFloatIntFloat() { Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4daae0ccl, false); Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x4daae0c4l, false); try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); script.set_gAllocInN(inN); script.forEach_testRootnFloatIntFloat(inV, out); verifyResultsRootnFloatIntFloat(inV, inN, out, false); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testRootnFloatIntFloat: " + e.toString()); } try { Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); scriptRelaxed.set_gAllocInN(inN); scriptRelaxed.forEach_testRootnFloatIntFloat(inV, out); verifyResultsRootnFloatIntFloat(inV, inN, out, true); } catch (Exception e) { throw new RSRuntimeException( "RenderScript. Can't invoke forEach_testRootnFloatIntFloat: " + e.toString()); } }