blob: 9151fd186c101f710310e9b305691dba93691a40 [file] [log] [blame]
/*
* 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;
import java.util.Arrays;
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, 0x7121573el, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7121573fl, 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];
Arrays.fill(arrayInA, (float) 42);
inA.copyTo(arrayInA);
float[] arrayInB = new float[INPUTSIZE * 1];
Arrays.fill(arrayInB, (float) 42);
inB.copyTo(arrayInB);
float[] arrayOut = new float[INPUTSIZE * 1];
Arrays.fill(arrayOut, (float) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinFloatFloatFloat" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinFloat2Float2Float2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49b4e454l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49b4e455l, 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];
Arrays.fill(arrayInA, (float) 42);
inA.copyTo(arrayInA);
float[] arrayInB = new float[INPUTSIZE * 2];
Arrays.fill(arrayInB, (float) 42);
inB.copyTo(arrayInB);
float[] arrayOut = new float[INPUTSIZE * 2];
Arrays.fill(arrayOut, (float) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinFloat2Float2Float2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinFloat3Float3Float3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4b92e5f5l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4b92e5f6l, 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];
Arrays.fill(arrayInA, (float) 42);
inA.copyTo(arrayInA);
float[] arrayInB = new float[INPUTSIZE * 4];
Arrays.fill(arrayInB, (float) 42);
inB.copyTo(arrayInB);
float[] arrayOut = new float[INPUTSIZE * 4];
Arrays.fill(arrayOut, (float) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinFloat3Float3Float3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinFloat4Float4Float4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d70e796l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d70e797l, 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];
Arrays.fill(arrayInA, (float) 42);
inA.copyTo(arrayInA);
float[] arrayInB = new float[INPUTSIZE * 4];
Arrays.fill(arrayInB, (float) 42);
inB.copyTo(arrayInB);
float[] arrayOut = new float[INPUTSIZE * 4];
Arrays.fill(arrayOut, (float) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinFloat4Float4Float4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsCharCharChar {
public byte inA;
public byte inB;
public byte out;
}
private void checkMinCharCharChar() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xe8196e0l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xe8196e1l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 1];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 1];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinCharCharChar" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinChar2Char2Char2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc8ef5ae2l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc8ef5ae3l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 2];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 2];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinChar2Char2Char2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinChar3Char3Char3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x278e6bb1l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x278e6bb2l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 4];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 4];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinChar3Char3Char3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinChar4Char4Char4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x862d7c80l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x862d7c81l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 4];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 4];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinChar4Char4Char4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsUcharUcharUchar {
public byte inA;
public byte inB;
public byte out;
}
private void checkMinUcharUcharUchar() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x3445490bl, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x3445490cl, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 1];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 1];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUcharUcharUchar" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUchar2Uchar2Uchar2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xcaf0b355l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xcaf0b356l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 2];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 2];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUchar2Uchar2Uchar2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUchar3Uchar3Uchar3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xccceb4f6l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xccceb4f7l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 4];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 4];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUchar3Uchar3Uchar3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUchar4Uchar4Uchar4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xceacb697l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xceacb698l, 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];
Arrays.fill(arrayInA, (byte) 42);
inA.copyTo(arrayInA);
byte[] arrayInB = new byte[INPUTSIZE * 4];
Arrays.fill(arrayInB, (byte) 42);
inB.copyTo(arrayInB);
byte[] arrayOut = new byte[INPUTSIZE * 4];
Arrays.fill(arrayOut, (byte) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUchar4Uchar4Uchar4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsShortShortShort {
public short inA;
public short inB;
public short out;
}
private void checkMinShortShortShort() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xf2c0a572l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xf2c0a573l, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 1];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 1];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinShortShortShort" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinShort2Short2Short2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69f3c358l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69f3c359l, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 2];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 2];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinShort2Short2Short2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinShort3Short3Short3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6bd1c4f9l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6bd1c4fal, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 4];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 4];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinShort3Short3Short3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinShort4Short4Short4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x6dafc69al, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x6dafc69bl, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 4];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 4];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinShort4Short4Short4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsUshortUshortUshort {
public short inA;
public short inB;
public short out;
}
private void checkMinUshortUshortUshort() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xcc4e79c5l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xcc4e79c6l, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 1];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 1];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUshortUshortUshort" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUshort2Ushort2Ushort2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x878f4ca3l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x878f4ca4l, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 2];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 2];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUshort2Ushort2Ushort2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUshort3Ushort3Ushort3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd0743e3al, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd0743e3bl, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 4];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 4];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUshort3Ushort3Ushort3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUshort4Ushort4Ushort4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19592fd1l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19592fd2l, 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];
Arrays.fill(arrayInA, (short) 42);
inA.copyTo(arrayInA);
short[] arrayInB = new short[INPUTSIZE * 4];
Arrays.fill(arrayInB, (short) 42);
inB.copyTo(arrayInB);
short[] arrayOut = new short[INPUTSIZE * 4];
Arrays.fill(arrayOut, (short) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUshort4Ushort4Ushort4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsIntIntInt {
public int inA;
public int inB;
public int out;
}
private void checkMinIntIntInt() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe703dfd7l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe703dfd8l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 1];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 1];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinIntIntInt" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinInt2Int2Int2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x13df0b41l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x13df0b42l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 2];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 2];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinInt2Int2Int2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinInt3Int3Int3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdeb4532al, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdeb4532bl, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 4];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 4];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinInt3Int3Int3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinInt4Int4Int4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa9899b13l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa9899b14l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 4];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 4];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinInt4Int4Int4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsUintUintUint {
public int inA;
public int inB;
public int out;
}
private void checkMinUintUintUint() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xde387ca0l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xde387ca1l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 1];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 1];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUintUintUint" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUint2Uint2Uint2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd9009a2l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd9009a3l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 2];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 2];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUint2Uint2Uint2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUint3Uint3Uint3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1c2f1a71l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1c2f1a72l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 4];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 4];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUint3Uint3Uint3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUint4Uint4Uint4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x7ace2b40l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x7ace2b41l, 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];
Arrays.fill(arrayInA, (int) 42);
inA.copyTo(arrayInA);
int[] arrayInB = new int[INPUTSIZE * 4];
Arrays.fill(arrayInB, (int) 42);
inB.copyTo(arrayInB);
int[] arrayOut = new int[INPUTSIZE * 4];
Arrays.fill(arrayOut, (int) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUint4Uint4Uint4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsLongLongLong {
public long inA;
public long inB;
public long out;
}
private void checkMinLongLongLong() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xde2e29eel, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xde2e29efl, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 1];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 1];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinLongLongLong" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinLong2Long2Long2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7154fcb8l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7154fcb9l, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 2];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 2];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinLong2Long2Long2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinLong3Long3Long3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcff40d87l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcff40d88l, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 4];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 4];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinLong3Long3Long3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinLong4Long4Long4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x2e931e56l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x2e931e57l, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 4];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 4];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinLong4Long4Long4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
public class ArgumentsUlongUlongUlong {
public long inA;
public long inB;
public long out;
}
private void checkMinUlongUlongUlong() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x3e23ed8dl, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x3e23ed8el, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 1];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 1];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUlongUlongUlong" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUlong2Ulong2Ulong2() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6c4dc5dfl, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6c4dc5e0l, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 2];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 2];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUlong2Ulong2Ulong2" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUlong3Ulong3Ulong3() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6e2bc780l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6e2bc781l, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 4];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 4];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUlong3Ulong3Ulong3" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
private void checkMinUlong4Ulong4Ulong4() {
Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x7009c921l, false);
Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x7009c922l, 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];
Arrays.fill(arrayInA, (long) 42);
inA.copyTo(arrayInA);
long[] arrayInB = new long[INPUTSIZE * 4];
Arrays.fill(arrayInB, (long) 42);
inB.copyTo(arrayInB);
long[] arrayOut = new long[INPUTSIZE * 4];
Arrays.fill(arrayOut, (long) 42);
out.copyTo(arrayOut);
StringBuilder message = new StringBuilder();
boolean errorFound = false;
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) {
if (!errorFound) {
errorFound = true;
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");
message.append("Errors at");
}
message.append(" [");
message.append(Integer.toString(i));
message.append(", ");
message.append(Integer.toString(j));
message.append("]");
}
}
}
assertFalse("Incorrect output for checkMinUlong4Ulong4Ulong4" +
(relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
}
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();
}
}