| /* |
| * Copyright (C) 2015 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| // Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh. |
| |
| package android.renderscript.cts; |
| |
| import android.renderscript.Allocation; |
| import android.renderscript.RSRuntimeException; |
| import android.renderscript.Element; |
| |
| public class TestMin extends RSBaseCompute { |
| |
| private ScriptC_TestMin script; |
| private ScriptC_TestMinRelaxed scriptRelaxed; |
| |
| @Override |
| protected void setUp() throws Exception { |
| super.setUp(); |
| script = new ScriptC_TestMin(mRS); |
| scriptRelaxed = new ScriptC_TestMinRelaxed(mRS); |
| } |
| |
| public class ArgumentsFloatFloatFloat { |
| public float inA; |
| public float inB; |
| public Target.Floaty out; |
| } |
| |
| private void checkMinFloatFloatFloat() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdad0b097121573el, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdad0b097121573fl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinFloatFloatFloat(inA, out); |
| verifyResultsMinFloatFloatFloat(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinFloatFloatFloat(inA, out); |
| verifyResultsMinFloatFloatFloat(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| float[] arrayInA = new float[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| float[] arrayInB = new float[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| float[] arrayOut = new float[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMin(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 1 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (!args.out.couldBe(arrayOut[i * 1 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinFloatFloatFloat" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinFloat2Float2Float2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2f1cc4b149b4e454l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2f1cc4b149b4e455l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinFloat2Float2Float2(inA, out); |
| verifyResultsMinFloat2Float2Float2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinFloat2Float2Float2(inA, out); |
| verifyResultsMinFloat2Float2Float2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| float[] arrayInA = new float[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| float[] arrayInB = new float[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMin(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinFloat2Float2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinFloat3Float3Float3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8381a2d14b92e5f5l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8381a2d14b92e5f6l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinFloat3Float3Float3(inA, out); |
| verifyResultsMinFloat3Float3Float3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinFloat3Float3Float3(inA, out); |
| verifyResultsMinFloat3Float3Float3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| float[] arrayInA = new float[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| float[] arrayInB = new float[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMin(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinFloat3Float3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinFloat4Float4Float4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd7e680f14d70e796l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd7e680f14d70e797l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinFloat4Float4Float4(inA, out); |
| verifyResultsMinFloat4Float4Float4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinFloat4Float4Float4(inA, out); |
| verifyResultsMinFloat4Float4Float4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| float[] arrayInA = new float[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| float[] arrayInB = new float[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMin(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinFloat4Float4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharCharChar { |
| public byte inA; |
| public byte inB; |
| public byte out; |
| } |
| |
| private void checkMinCharCharChar() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x78bd3bd20e8196e0l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x78bd3bd20e8196e1l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinCharCharChar(inA, out); |
| verifyResultsMinCharCharChar(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinCharCharChar(inA, out); |
| verifyResultsMinCharCharChar(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinCharCharChar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharCharChar args = new ArgumentsCharCharChar(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinCharCharChar" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinChar2Char2Char2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x29373baac8ef5ae2l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x29373baac8ef5ae3l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinChar2Char2Char2(inA, out); |
| verifyResultsMinChar2Char2Char2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinChar2Char2Char2(inA, out); |
| verifyResultsMinChar2Char2Char2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinChar2Char2Char2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharCharChar args = new ArgumentsCharCharChar(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinChar2Char2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinChar3Char3Char3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4eebbb94278e6bb1l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4eebbb94278e6bb2l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinChar3Char3Char3(inA, out); |
| verifyResultsMinChar3Char3Char3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinChar3Char3Char3(inA, out); |
| verifyResultsMinChar3Char3Char3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinChar3Char3Char3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharCharChar args = new ArgumentsCharCharChar(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinChar3Char3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinChar4Char4Char4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x74a03b7d862d7c80l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x74a03b7d862d7c81l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinChar4Char4Char4(inA, out); |
| verifyResultsMinChar4Char4Char4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinChar4Char4Char4(inA, out); |
| verifyResultsMinChar4Char4Char4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinChar4Char4Char4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharCharChar args = new ArgumentsCharCharChar(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinChar4Char4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharUcharUchar { |
| public byte inA; |
| public byte inB; |
| public byte out; |
| } |
| |
| private void checkMinUcharUcharUchar() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x1469cbe93445490bl, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x1469cbe93445490cl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUcharUcharUchar(inA, out); |
| verifyResultsMinUcharUcharUchar(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUcharUcharUchar(inA, out); |
| verifyResultsMinUcharUcharUchar(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUcharUcharUchar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUcharUcharUchar" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUchar2Uchar2Uchar2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x3c36fd71caf0b355l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x3c36fd71caf0b356l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUchar2Uchar2Uchar2(inA, out); |
| verifyResultsMinUchar2Uchar2Uchar2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUchar2Uchar2Uchar2(inA, out); |
| verifyResultsMinUchar2Uchar2Uchar2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUchar2Uchar2Uchar2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUchar2Uchar2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUchar3Uchar3Uchar3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x909bdb91ccceb4f6l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x909bdb91ccceb4f7l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUchar3Uchar3Uchar3(inA, out); |
| verifyResultsMinUchar3Uchar3Uchar3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUchar3Uchar3Uchar3(inA, out); |
| verifyResultsMinUchar3Uchar3Uchar3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUchar3Uchar3Uchar3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUchar3Uchar3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUchar4Uchar4Uchar4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe500b9b1ceacb697l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe500b9b1ceacb698l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUchar4Uchar4Uchar4(inA, out); |
| verifyResultsMinUchar4Uchar4Uchar4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUchar4Uchar4Uchar4(inA, out); |
| verifyResultsMinUchar4Uchar4Uchar4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUchar4Uchar4Uchar4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| byte[] arrayInA = new byte[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| byte[] arrayInB = new byte[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUchar4Uchar4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortShortShort { |
| public short inA; |
| public short inB; |
| public short out; |
| } |
| |
| private void checkMinShortShortShort() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x265d6881f2c0a572l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x265d6881f2c0a573l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinShortShortShort(inA, out); |
| verifyResultsMinShortShortShort(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinShortShortShort(inA, out); |
| verifyResultsMinShortShortShort(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinShortShortShort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShortShort args = new ArgumentsShortShortShort(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinShortShortShort" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinShort2Short2Short2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xac037aa769f3c358l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xac037aa769f3c359l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinShort2Short2Short2(inA, out); |
| verifyResultsMinShort2Short2Short2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinShort2Short2Short2(inA, out); |
| verifyResultsMinShort2Short2Short2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinShort2Short2Short2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShortShort args = new ArgumentsShortShortShort(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinShort2Short2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinShort3Short3Short3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6858c76bd1c4f9l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6858c76bd1c4fal, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinShort3Short3Short3(inA, out); |
| verifyResultsMinShort3Short3Short3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinShort3Short3Short3(inA, out); |
| verifyResultsMinShort3Short3Short3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinShort3Short3Short3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShortShort args = new ArgumentsShortShortShort(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinShort3Short3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinShort4Short4Short4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x54cd36e76dafc69al, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x54cd36e76dafc69bl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinShort4Short4Short4(inA, out); |
| verifyResultsMinShort4Short4Short4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinShort4Short4Short4(inA, out); |
| verifyResultsMinShort4Short4Short4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinShort4Short4Short4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShortShort args = new ArgumentsShortShortShort(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinShort4Short4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortUshortUshort { |
| public short inA; |
| public short inB; |
| public short out; |
| } |
| |
| private void checkMinUshortUshortUshort() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf8a042afcc4e79c5l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf8a042afcc4e79c6l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUshortUshortUshort(inA, out); |
| verifyResultsMinUshortUshortUshort(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUshortUshortUshort(inA, out); |
| verifyResultsMinUshortUshortUshort(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUshortUshortUshort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUshortUshortUshort" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUshort2Ushort2Ushort2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2743846f878f4ca3l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2743846f878f4ca4l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUshort2Ushort2Ushort2(inA, out); |
| verifyResultsMinUshort2Ushort2Ushort2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUshort2Ushort2Ushort2(inA, out); |
| verifyResultsMinUshort2Ushort2Ushort2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUshort2Ushort2Ushort2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUshort2Ushort2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUshort3Ushort3Ushort3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xa7331d68d0743e3al, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xa7331d68d0743e3bl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUshort3Ushort3Ushort3(inA, out); |
| verifyResultsMinUshort3Ushort3Ushort3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUshort3Ushort3Ushort3(inA, out); |
| verifyResultsMinUshort3Ushort3Ushort3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUshort3Ushort3Ushort3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUshort3Ushort3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUshort4Ushort4Ushort4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2722b66219592fd1l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2722b66219592fd2l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUshort4Ushort4Ushort4(inA, out); |
| verifyResultsMinUshort4Ushort4Ushort4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUshort4Ushort4Ushort4(inA, out); |
| verifyResultsMinUshort4Ushort4Ushort4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUshort4Ushort4Ushort4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| short[] arrayInA = new short[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| short[] arrayInB = new short[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUshort4Ushort4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntIntInt { |
| public int inA; |
| public int inB; |
| public int out; |
| } |
| |
| private void checkMinIntIntInt() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfb5d72ade703dfd7l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfb5d72ade703dfd8l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinIntIntInt(inA, out); |
| verifyResultsMinIntIntInt(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinIntIntInt(inA, out); |
| verifyResultsMinIntIntInt(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinIntIntInt(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntIntInt args = new ArgumentsIntIntInt(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinIntIntInt" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinInt2Int2Int2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4bc6c69713df0b41l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4bc6c69713df0b42l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinInt2Int2Int2(inA, out); |
| verifyResultsMinInt2Int2Int2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinInt2Int2Int2(inA, out); |
| verifyResultsMinInt2Int2Int2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinInt2Int2Int2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntIntInt args = new ArgumentsIntIntInt(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinInt2Int2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinInt3Int3Int3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x58ac4a91deb4532al, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x58ac4a91deb4532bl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinInt3Int3Int3(inA, out); |
| verifyResultsMinInt3Int3Int3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinInt3Int3Int3(inA, out); |
| verifyResultsMinInt3Int3Int3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinInt3Int3Int3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntIntInt args = new ArgumentsIntIntInt(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinInt3Int3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinInt4Int4Int4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x6591ce8ca9899b13l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x6591ce8ca9899b14l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinInt4Int4Int4(inA, out); |
| verifyResultsMinInt4Int4Int4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinInt4Int4Int4(inA, out); |
| verifyResultsMinInt4Int4Int4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinInt4Int4Int4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntIntInt args = new ArgumentsIntIntInt(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinInt4Int4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintUintUint { |
| public int inA; |
| public int inB; |
| public int out; |
| } |
| |
| private void checkMinUintUintUint() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xe66a5218de387ca0l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xe66a5218de387ca1l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUintUintUint(inA, out); |
| verifyResultsMinUintUintUint(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUintUintUint(inA, out); |
| verifyResultsMinUintUintUint(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUintUintUint(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUintUint args = new ArgumentsUintUintUint(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUintUintUint" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUint2Uint2Uint2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x51b17a26bd9009a2l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x51b17a26bd9009a3l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUint2Uint2Uint2(inA, out); |
| verifyResultsMinUint2Uint2Uint2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUint2Uint2Uint2(inA, out); |
| verifyResultsMinUint2Uint2Uint2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUint2Uint2Uint2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUintUint args = new ArgumentsUintUintUint(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUint2Uint2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUint3Uint3Uint3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x7765fa101c2f1a71l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x7765fa101c2f1a72l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUint3Uint3Uint3(inA, out); |
| verifyResultsMinUint3Uint3Uint3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUint3Uint3Uint3(inA, out); |
| verifyResultsMinUint3Uint3Uint3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUint3Uint3Uint3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUintUint args = new ArgumentsUintUintUint(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUint3Uint3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUint4Uint4Uint4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9d1a79f97ace2b40l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9d1a79f97ace2b41l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUint4Uint4Uint4(inA, out); |
| verifyResultsMinUint4Uint4Uint4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUint4Uint4Uint4(inA, out); |
| verifyResultsMinUint4Uint4Uint4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUint4Uint4Uint4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| int[] arrayInA = new int[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| int[] arrayInB = new int[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUintUint args = new ArgumentsUintUintUint(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUint4Uint4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongLongLong { |
| public long inA; |
| public long inB; |
| public long out; |
| } |
| |
| private void checkMinLongLongLong() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x1e87c507de2e29eel, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x1e87c507de2e29efl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinLongLongLong(inA, out); |
| verifyResultsMinLongLongLong(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinLongLongLong(inA, out); |
| verifyResultsMinLongLongLong(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinLongLongLong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLongLong args = new ArgumentsLongLongLong(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinLongLongLong" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinLong2Long2Long2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x5a1aed657154fcb8l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x5a1aed657154fcb9l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinLong2Long2Long2(inA, out); |
| verifyResultsMinLong2Long2Long2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinLong2Long2Long2(inA, out); |
| verifyResultsMinLong2Long2Long2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinLong2Long2Long2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLongLong args = new ArgumentsLongLongLong(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinLong2Long2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinLong3Long3Long3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7fcf6d4ecff40d87l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7fcf6d4ecff40d88l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinLong3Long3Long3(inA, out); |
| verifyResultsMinLong3Long3Long3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinLong3Long3Long3(inA, out); |
| verifyResultsMinLong3Long3Long3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinLong3Long3Long3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLongLong args = new ArgumentsLongLongLong(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinLong3Long3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinLong4Long4Long4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xa583ed382e931e56l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xa583ed382e931e57l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinLong4Long4Long4(inA, out); |
| verifyResultsMinLong4Long4Long4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinLong4Long4Long4(inA, out); |
| verifyResultsMinLong4Long4Long4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinLong4Long4Long4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLongLong args = new ArgumentsLongLongLong(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinLong4Long4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongUlongUlong { |
| public long inA; |
| public long inB; |
| public long out; |
| } |
| |
| private void checkMinUlongUlongUlong() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x21750b943e23ed8dl, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x21750b943e23ed8el, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUlongUlongUlong(inA, out); |
| verifyResultsMinUlongUlongUlong(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUlongUlongUlong(inA, out); |
| verifyResultsMinUlongUlongUlong(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUlongUlongUlong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 1]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 1]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); |
| args.inA = arrayInA[i]; |
| args.inB = arrayInB[i]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 1 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 1 + j]); |
| if (args.out != arrayOut[i * 1 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUlongUlongUlong" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUlong2Ulong2Ulong2() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xd739efe16c4dc5dfl, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xd739efe16c4dc5e0l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUlong2Ulong2Ulong2(inA, out); |
| verifyResultsMinUlong2Ulong2Ulong2(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUlong2Ulong2Ulong2(inA, out); |
| verifyResultsMinUlong2Ulong2Ulong2(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUlong2Ulong2Ulong2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 2]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 2]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); |
| args.inA = arrayInA[i * 2 + j]; |
| args.inB = arrayInB[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUlong2Ulong2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUlong3Ulong3Ulong3() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2b9ece016e2bc780l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2b9ece016e2bc781l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUlong3Ulong3Ulong3(inA, out); |
| verifyResultsMinUlong3Ulong3Ulong3(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUlong3Ulong3Ulong3(inA, out); |
| verifyResultsMinUlong3Ulong3Ulong3(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUlong3Ulong3Ulong3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUlong3Ulong3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMinUlong4Ulong4Ulong4() { |
| Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x8003ac217009c921l, false); |
| Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x8003ac217009c922l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.set_gAllocInB(inB); |
| script.forEach_testMinUlong4Ulong4Ulong4(inA, out); |
| verifyResultsMinUlong4Ulong4Ulong4(inA, inB, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInB(inB); |
| scriptRelaxed.forEach_testMinUlong4Ulong4Ulong4(inA, out); |
| verifyResultsMinUlong4Ulong4Ulong4(inA, inB, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMinUlong4Ulong4Ulong4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { |
| long[] arrayInA = new long[INPUTSIZE * 4]; |
| inA.copyTo(arrayInA); |
| long[] arrayInB = new long[INPUTSIZE * 4]; |
| inB.copyTo(arrayInB); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); |
| args.inA = arrayInA[i * 4 + j]; |
| args.inB = arrayInB[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeMin(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inA: "); |
| appendVariableToMessage(message, args.inA); |
| message.append("\n"); |
| message.append("Input inB: "); |
| appendVariableToMessage(message, args.inB); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMinUlong4Ulong4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public void testMin() { |
| checkMinFloatFloatFloat(); |
| checkMinFloat2Float2Float2(); |
| checkMinFloat3Float3Float3(); |
| checkMinFloat4Float4Float4(); |
| checkMinCharCharChar(); |
| checkMinChar2Char2Char2(); |
| checkMinChar3Char3Char3(); |
| checkMinChar4Char4Char4(); |
| checkMinUcharUcharUchar(); |
| checkMinUchar2Uchar2Uchar2(); |
| checkMinUchar3Uchar3Uchar3(); |
| checkMinUchar4Uchar4Uchar4(); |
| checkMinShortShortShort(); |
| checkMinShort2Short2Short2(); |
| checkMinShort3Short3Short3(); |
| checkMinShort4Short4Short4(); |
| checkMinUshortUshortUshort(); |
| checkMinUshort2Ushort2Ushort2(); |
| checkMinUshort3Ushort3Ushort3(); |
| checkMinUshort4Ushort4Ushort4(); |
| checkMinIntIntInt(); |
| checkMinInt2Int2Int2(); |
| checkMinInt3Int3Int3(); |
| checkMinInt4Int4Int4(); |
| checkMinUintUintUint(); |
| checkMinUint2Uint2Uint2(); |
| checkMinUint3Uint3Uint3(); |
| checkMinUint4Uint4Uint4(); |
| checkMinLongLongLong(); |
| checkMinLong2Long2Long2(); |
| checkMinLong3Long3Long3(); |
| checkMinLong4Long4Long4(); |
| checkMinUlongUlongUlong(); |
| checkMinUlong2Ulong2Ulong2(); |
| checkMinUlong3Ulong3Ulong3(); |
| checkMinUlong4Ulong4Ulong4(); |
| } |
| } |