1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh. 18 19 package android.renderscript.cts; 20 21 import android.renderscript.Allocation; 22 import android.renderscript.RSRuntimeException; 23 import android.renderscript.Element; 24 import android.renderscript.cts.Target; 25 26 import java.util.Arrays; 27 28 public class TestMin extends RSBaseCompute { 29 30 private ScriptC_TestMin script; 31 private ScriptC_TestMinRelaxed scriptRelaxed; 32 33 @Override setUp()34 protected void setUp() throws Exception { 35 super.setUp(); 36 script = new ScriptC_TestMin(mRS); 37 scriptRelaxed = new ScriptC_TestMinRelaxed(mRS); 38 } 39 40 public class ArgumentsFloatFloatFloat { 41 public float inA; 42 public float inB; 43 public Target.Floaty out; 44 } 45 checkMinFloatFloatFloat()46 private void checkMinFloatFloatFloat() { 47 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7121573el, false); 48 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7121573fl, false); 49 try { 50 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); 51 script.set_gAllocInB(inB); 52 script.forEach_testMinFloatFloatFloat(inA, out); 53 verifyResultsMinFloatFloatFloat(inA, inB, out, false); 54 } catch (Exception e) { 55 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString()); 56 } 57 try { 58 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); 59 scriptRelaxed.set_gAllocInB(inB); 60 scriptRelaxed.forEach_testMinFloatFloatFloat(inA, out); 61 verifyResultsMinFloatFloatFloat(inA, inB, out, true); 62 } catch (Exception e) { 63 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString()); 64 } 65 } 66 verifyResultsMinFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed)67 private void verifyResultsMinFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 68 float[] arrayInA = new float[INPUTSIZE * 1]; 69 Arrays.fill(arrayInA, (float) 42); 70 inA.copyTo(arrayInA); 71 float[] arrayInB = new float[INPUTSIZE * 1]; 72 Arrays.fill(arrayInB, (float) 42); 73 inB.copyTo(arrayInB); 74 float[] arrayOut = new float[INPUTSIZE * 1]; 75 Arrays.fill(arrayOut, (float) 42); 76 out.copyTo(arrayOut); 77 StringBuilder message = new StringBuilder(); 78 boolean errorFound = false; 79 for (int i = 0; i < INPUTSIZE; i++) { 80 for (int j = 0; j < 1 ; j++) { 81 // Extract the inputs. 82 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 83 args.inA = arrayInA[i]; 84 args.inB = arrayInB[i]; 85 // Figure out what the outputs should have been. 86 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 87 CoreMathVerifier.computeMin(args, target); 88 // Validate the outputs. 89 boolean valid = true; 90 if (!args.out.couldBe(arrayOut[i * 1 + j])) { 91 valid = false; 92 } 93 if (!valid) { 94 if (!errorFound) { 95 errorFound = true; 96 message.append("Input inA: "); 97 appendVariableToMessage(message, args.inA); 98 message.append("\n"); 99 message.append("Input inB: "); 100 appendVariableToMessage(message, args.inB); 101 message.append("\n"); 102 message.append("Expected output out: "); 103 appendVariableToMessage(message, args.out); 104 message.append("\n"); 105 message.append("Actual output out: "); 106 appendVariableToMessage(message, arrayOut[i * 1 + j]); 107 if (!args.out.couldBe(arrayOut[i * 1 + j])) { 108 message.append(" FAIL"); 109 } 110 message.append("\n"); 111 message.append("Errors at"); 112 } 113 message.append(" ["); 114 message.append(Integer.toString(i)); 115 message.append(", "); 116 message.append(Integer.toString(j)); 117 message.append("]"); 118 } 119 } 120 } 121 assertFalse("Incorrect output for checkMinFloatFloatFloat" + 122 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 123 } 124 checkMinFloat2Float2Float2()125 private void checkMinFloat2Float2Float2() { 126 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49b4e454l, false); 127 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49b4e455l, false); 128 try { 129 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 130 script.set_gAllocInB(inB); 131 script.forEach_testMinFloat2Float2Float2(inA, out); 132 verifyResultsMinFloat2Float2Float2(inA, inB, out, false); 133 } catch (Exception e) { 134 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString()); 135 } 136 try { 137 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 138 scriptRelaxed.set_gAllocInB(inB); 139 scriptRelaxed.forEach_testMinFloat2Float2Float2(inA, out); 140 verifyResultsMinFloat2Float2Float2(inA, inB, out, true); 141 } catch (Exception e) { 142 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString()); 143 } 144 } 145 verifyResultsMinFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)146 private void verifyResultsMinFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 147 float[] arrayInA = new float[INPUTSIZE * 2]; 148 Arrays.fill(arrayInA, (float) 42); 149 inA.copyTo(arrayInA); 150 float[] arrayInB = new float[INPUTSIZE * 2]; 151 Arrays.fill(arrayInB, (float) 42); 152 inB.copyTo(arrayInB); 153 float[] arrayOut = new float[INPUTSIZE * 2]; 154 Arrays.fill(arrayOut, (float) 42); 155 out.copyTo(arrayOut); 156 StringBuilder message = new StringBuilder(); 157 boolean errorFound = false; 158 for (int i = 0; i < INPUTSIZE; i++) { 159 for (int j = 0; j < 2 ; j++) { 160 // Extract the inputs. 161 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 162 args.inA = arrayInA[i * 2 + j]; 163 args.inB = arrayInB[i * 2 + j]; 164 // Figure out what the outputs should have been. 165 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 166 CoreMathVerifier.computeMin(args, target); 167 // Validate the outputs. 168 boolean valid = true; 169 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 170 valid = false; 171 } 172 if (!valid) { 173 if (!errorFound) { 174 errorFound = true; 175 message.append("Input inA: "); 176 appendVariableToMessage(message, args.inA); 177 message.append("\n"); 178 message.append("Input inB: "); 179 appendVariableToMessage(message, args.inB); 180 message.append("\n"); 181 message.append("Expected output out: "); 182 appendVariableToMessage(message, args.out); 183 message.append("\n"); 184 message.append("Actual output out: "); 185 appendVariableToMessage(message, arrayOut[i * 2 + j]); 186 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 187 message.append(" FAIL"); 188 } 189 message.append("\n"); 190 message.append("Errors at"); 191 } 192 message.append(" ["); 193 message.append(Integer.toString(i)); 194 message.append(", "); 195 message.append(Integer.toString(j)); 196 message.append("]"); 197 } 198 } 199 } 200 assertFalse("Incorrect output for checkMinFloat2Float2Float2" + 201 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 202 } 203 checkMinFloat3Float3Float3()204 private void checkMinFloat3Float3Float3() { 205 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4b92e5f5l, false); 206 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4b92e5f6l, false); 207 try { 208 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 209 script.set_gAllocInB(inB); 210 script.forEach_testMinFloat3Float3Float3(inA, out); 211 verifyResultsMinFloat3Float3Float3(inA, inB, out, false); 212 } catch (Exception e) { 213 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString()); 214 } 215 try { 216 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 217 scriptRelaxed.set_gAllocInB(inB); 218 scriptRelaxed.forEach_testMinFloat3Float3Float3(inA, out); 219 verifyResultsMinFloat3Float3Float3(inA, inB, out, true); 220 } catch (Exception e) { 221 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString()); 222 } 223 } 224 verifyResultsMinFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)225 private void verifyResultsMinFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 226 float[] arrayInA = new float[INPUTSIZE * 4]; 227 Arrays.fill(arrayInA, (float) 42); 228 inA.copyTo(arrayInA); 229 float[] arrayInB = new float[INPUTSIZE * 4]; 230 Arrays.fill(arrayInB, (float) 42); 231 inB.copyTo(arrayInB); 232 float[] arrayOut = new float[INPUTSIZE * 4]; 233 Arrays.fill(arrayOut, (float) 42); 234 out.copyTo(arrayOut); 235 StringBuilder message = new StringBuilder(); 236 boolean errorFound = false; 237 for (int i = 0; i < INPUTSIZE; i++) { 238 for (int j = 0; j < 3 ; j++) { 239 // Extract the inputs. 240 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 241 args.inA = arrayInA[i * 4 + j]; 242 args.inB = arrayInB[i * 4 + j]; 243 // Figure out what the outputs should have been. 244 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 245 CoreMathVerifier.computeMin(args, target); 246 // Validate the outputs. 247 boolean valid = true; 248 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 249 valid = false; 250 } 251 if (!valid) { 252 if (!errorFound) { 253 errorFound = true; 254 message.append("Input inA: "); 255 appendVariableToMessage(message, args.inA); 256 message.append("\n"); 257 message.append("Input inB: "); 258 appendVariableToMessage(message, args.inB); 259 message.append("\n"); 260 message.append("Expected output out: "); 261 appendVariableToMessage(message, args.out); 262 message.append("\n"); 263 message.append("Actual output out: "); 264 appendVariableToMessage(message, arrayOut[i * 4 + j]); 265 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 266 message.append(" FAIL"); 267 } 268 message.append("\n"); 269 message.append("Errors at"); 270 } 271 message.append(" ["); 272 message.append(Integer.toString(i)); 273 message.append(", "); 274 message.append(Integer.toString(j)); 275 message.append("]"); 276 } 277 } 278 } 279 assertFalse("Incorrect output for checkMinFloat3Float3Float3" + 280 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 281 } 282 checkMinFloat4Float4Float4()283 private void checkMinFloat4Float4Float4() { 284 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d70e796l, false); 285 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d70e797l, false); 286 try { 287 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 288 script.set_gAllocInB(inB); 289 script.forEach_testMinFloat4Float4Float4(inA, out); 290 verifyResultsMinFloat4Float4Float4(inA, inB, out, false); 291 } catch (Exception e) { 292 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString()); 293 } 294 try { 295 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 296 scriptRelaxed.set_gAllocInB(inB); 297 scriptRelaxed.forEach_testMinFloat4Float4Float4(inA, out); 298 verifyResultsMinFloat4Float4Float4(inA, inB, out, true); 299 } catch (Exception e) { 300 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString()); 301 } 302 } 303 verifyResultsMinFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)304 private void verifyResultsMinFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 305 float[] arrayInA = new float[INPUTSIZE * 4]; 306 Arrays.fill(arrayInA, (float) 42); 307 inA.copyTo(arrayInA); 308 float[] arrayInB = new float[INPUTSIZE * 4]; 309 Arrays.fill(arrayInB, (float) 42); 310 inB.copyTo(arrayInB); 311 float[] arrayOut = new float[INPUTSIZE * 4]; 312 Arrays.fill(arrayOut, (float) 42); 313 out.copyTo(arrayOut); 314 StringBuilder message = new StringBuilder(); 315 boolean errorFound = false; 316 for (int i = 0; i < INPUTSIZE; i++) { 317 for (int j = 0; j < 4 ; j++) { 318 // Extract the inputs. 319 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 320 args.inA = arrayInA[i * 4 + j]; 321 args.inB = arrayInB[i * 4 + j]; 322 // Figure out what the outputs should have been. 323 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 324 CoreMathVerifier.computeMin(args, target); 325 // Validate the outputs. 326 boolean valid = true; 327 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 328 valid = false; 329 } 330 if (!valid) { 331 if (!errorFound) { 332 errorFound = true; 333 message.append("Input inA: "); 334 appendVariableToMessage(message, args.inA); 335 message.append("\n"); 336 message.append("Input inB: "); 337 appendVariableToMessage(message, args.inB); 338 message.append("\n"); 339 message.append("Expected output out: "); 340 appendVariableToMessage(message, args.out); 341 message.append("\n"); 342 message.append("Actual output out: "); 343 appendVariableToMessage(message, arrayOut[i * 4 + j]); 344 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 345 message.append(" FAIL"); 346 } 347 message.append("\n"); 348 message.append("Errors at"); 349 } 350 message.append(" ["); 351 message.append(Integer.toString(i)); 352 message.append(", "); 353 message.append(Integer.toString(j)); 354 message.append("]"); 355 } 356 } 357 } 358 assertFalse("Incorrect output for checkMinFloat4Float4Float4" + 359 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 360 } 361 362 public class ArgumentsHalfHalfHalf { 363 public short inA; 364 public double inADouble; 365 public short inB; 366 public double inBDouble; 367 public Target.Floaty out; 368 } 369 checkMinHalfHalfHalf()370 private void checkMinHalfHalfHalf() { 371 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf239c45l, false); 372 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf239c46l, false); 373 try { 374 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE); 375 script.set_gAllocInB(inB); 376 script.forEach_testMinHalfHalfHalf(inA, out); 377 verifyResultsMinHalfHalfHalf(inA, inB, out, false); 378 } catch (Exception e) { 379 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalfHalfHalf: " + e.toString()); 380 } 381 try { 382 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE); 383 scriptRelaxed.set_gAllocInB(inB); 384 scriptRelaxed.forEach_testMinHalfHalfHalf(inA, out); 385 verifyResultsMinHalfHalfHalf(inA, inB, out, true); 386 } catch (Exception e) { 387 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalfHalfHalf: " + e.toString()); 388 } 389 } 390 verifyResultsMinHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed)391 private void verifyResultsMinHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 392 short[] arrayInA = new short[INPUTSIZE * 1]; 393 Arrays.fill(arrayInA, (short) 42); 394 inA.copyTo(arrayInA); 395 short[] arrayInB = new short[INPUTSIZE * 1]; 396 Arrays.fill(arrayInB, (short) 42); 397 inB.copyTo(arrayInB); 398 short[] arrayOut = new short[INPUTSIZE * 1]; 399 Arrays.fill(arrayOut, (short) 42); 400 out.copyTo(arrayOut); 401 StringBuilder message = new StringBuilder(); 402 boolean errorFound = false; 403 for (int i = 0; i < INPUTSIZE; i++) { 404 for (int j = 0; j < 1 ; j++) { 405 // Extract the inputs. 406 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 407 args.inA = arrayInA[i]; 408 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 409 args.inB = arrayInB[i]; 410 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 411 // Figure out what the outputs should have been. 412 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 413 CoreMathVerifier.computeMin(args, target); 414 // Validate the outputs. 415 boolean valid = true; 416 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 1 + j]))) { 417 valid = false; 418 } 419 if (!valid) { 420 if (!errorFound) { 421 errorFound = true; 422 message.append("Input inA: "); 423 appendVariableToMessage(message, args.inA); 424 message.append("\n"); 425 message.append("Input inB: "); 426 appendVariableToMessage(message, args.inB); 427 message.append("\n"); 428 message.append("Expected output out: "); 429 appendVariableToMessage(message, args.out); 430 message.append("\n"); 431 message.append("Actual output out: "); 432 appendVariableToMessage(message, arrayOut[i * 1 + j]); 433 message.append("\n"); 434 message.append("Actual output out (in double): "); 435 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 1 + j])); 436 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 1 + j]))) { 437 message.append(" FAIL"); 438 } 439 message.append("\n"); 440 message.append("Errors at"); 441 } 442 message.append(" ["); 443 message.append(Integer.toString(i)); 444 message.append(", "); 445 message.append(Integer.toString(j)); 446 message.append("]"); 447 } 448 } 449 } 450 assertFalse("Incorrect output for checkMinHalfHalfHalf" + 451 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 452 } 453 checkMinHalf2Half2Half2()454 private void checkMinHalf2Half2Half2() { 455 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa8079b33l, false); 456 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa8079b34l, false); 457 try { 458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 459 script.set_gAllocInB(inB); 460 script.forEach_testMinHalf2Half2Half2(inA, out); 461 verifyResultsMinHalf2Half2Half2(inA, inB, out, false); 462 } catch (Exception e) { 463 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2Half2Half2: " + e.toString()); 464 } 465 try { 466 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 467 scriptRelaxed.set_gAllocInB(inB); 468 scriptRelaxed.forEach_testMinHalf2Half2Half2(inA, out); 469 verifyResultsMinHalf2Half2Half2(inA, inB, out, true); 470 } catch (Exception e) { 471 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2Half2Half2: " + e.toString()); 472 } 473 } 474 verifyResultsMinHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)475 private void verifyResultsMinHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 476 short[] arrayInA = new short[INPUTSIZE * 2]; 477 Arrays.fill(arrayInA, (short) 42); 478 inA.copyTo(arrayInA); 479 short[] arrayInB = new short[INPUTSIZE * 2]; 480 Arrays.fill(arrayInB, (short) 42); 481 inB.copyTo(arrayInB); 482 short[] arrayOut = new short[INPUTSIZE * 2]; 483 Arrays.fill(arrayOut, (short) 42); 484 out.copyTo(arrayOut); 485 StringBuilder message = new StringBuilder(); 486 boolean errorFound = false; 487 for (int i = 0; i < INPUTSIZE; i++) { 488 for (int j = 0; j < 2 ; j++) { 489 // Extract the inputs. 490 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 491 args.inA = arrayInA[i * 2 + j]; 492 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 493 args.inB = arrayInB[i * 2 + j]; 494 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 495 // Figure out what the outputs should have been. 496 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 497 CoreMathVerifier.computeMin(args, target); 498 // Validate the outputs. 499 boolean valid = true; 500 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 501 valid = false; 502 } 503 if (!valid) { 504 if (!errorFound) { 505 errorFound = true; 506 message.append("Input inA: "); 507 appendVariableToMessage(message, args.inA); 508 message.append("\n"); 509 message.append("Input inB: "); 510 appendVariableToMessage(message, args.inB); 511 message.append("\n"); 512 message.append("Expected output out: "); 513 appendVariableToMessage(message, args.out); 514 message.append("\n"); 515 message.append("Actual output out: "); 516 appendVariableToMessage(message, arrayOut[i * 2 + j]); 517 message.append("\n"); 518 message.append("Actual output out (in double): "); 519 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 520 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 521 message.append(" FAIL"); 522 } 523 message.append("\n"); 524 message.append("Errors at"); 525 } 526 message.append(" ["); 527 message.append(Integer.toString(i)); 528 message.append(", "); 529 message.append(Integer.toString(j)); 530 message.append("]"); 531 } 532 } 533 } 534 assertFalse("Incorrect output for checkMinHalf2Half2Half2" + 535 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 536 } 537 checkMinHalf3Half3Half3()538 private void checkMinHalf3Half3Half3() { 539 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6a6ac02l, false); 540 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6a6ac03l, false); 541 try { 542 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 543 script.set_gAllocInB(inB); 544 script.forEach_testMinHalf3Half3Half3(inA, out); 545 verifyResultsMinHalf3Half3Half3(inA, inB, out, false); 546 } catch (Exception e) { 547 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3Half3Half3: " + e.toString()); 548 } 549 try { 550 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 551 scriptRelaxed.set_gAllocInB(inB); 552 scriptRelaxed.forEach_testMinHalf3Half3Half3(inA, out); 553 verifyResultsMinHalf3Half3Half3(inA, inB, out, true); 554 } catch (Exception e) { 555 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3Half3Half3: " + e.toString()); 556 } 557 } 558 verifyResultsMinHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)559 private void verifyResultsMinHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 560 short[] arrayInA = new short[INPUTSIZE * 4]; 561 Arrays.fill(arrayInA, (short) 42); 562 inA.copyTo(arrayInA); 563 short[] arrayInB = new short[INPUTSIZE * 4]; 564 Arrays.fill(arrayInB, (short) 42); 565 inB.copyTo(arrayInB); 566 short[] arrayOut = new short[INPUTSIZE * 4]; 567 Arrays.fill(arrayOut, (short) 42); 568 out.copyTo(arrayOut); 569 StringBuilder message = new StringBuilder(); 570 boolean errorFound = false; 571 for (int i = 0; i < INPUTSIZE; i++) { 572 for (int j = 0; j < 3 ; j++) { 573 // Extract the inputs. 574 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 575 args.inA = arrayInA[i * 4 + j]; 576 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 577 args.inB = arrayInB[i * 4 + j]; 578 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 579 // Figure out what the outputs should have been. 580 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 581 CoreMathVerifier.computeMin(args, target); 582 // Validate the outputs. 583 boolean valid = true; 584 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 585 valid = false; 586 } 587 if (!valid) { 588 if (!errorFound) { 589 errorFound = true; 590 message.append("Input inA: "); 591 appendVariableToMessage(message, args.inA); 592 message.append("\n"); 593 message.append("Input inB: "); 594 appendVariableToMessage(message, args.inB); 595 message.append("\n"); 596 message.append("Expected output out: "); 597 appendVariableToMessage(message, args.out); 598 message.append("\n"); 599 message.append("Actual output out: "); 600 appendVariableToMessage(message, arrayOut[i * 4 + j]); 601 message.append("\n"); 602 message.append("Actual output out (in double): "); 603 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 604 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 605 message.append(" FAIL"); 606 } 607 message.append("\n"); 608 message.append("Errors at"); 609 } 610 message.append(" ["); 611 message.append(Integer.toString(i)); 612 message.append(", "); 613 message.append(Integer.toString(j)); 614 message.append("]"); 615 } 616 } 617 } 618 assertFalse("Incorrect output for checkMinHalf3Half3Half3" + 619 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 620 } 621 checkMinHalf4Half4Half4()622 private void checkMinHalf4Half4Half4() { 623 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6545bcd1l, false); 624 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6545bcd2l, false); 625 try { 626 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 627 script.set_gAllocInB(inB); 628 script.forEach_testMinHalf4Half4Half4(inA, out); 629 verifyResultsMinHalf4Half4Half4(inA, inB, out, false); 630 } catch (Exception e) { 631 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4Half4Half4: " + e.toString()); 632 } 633 try { 634 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 635 scriptRelaxed.set_gAllocInB(inB); 636 scriptRelaxed.forEach_testMinHalf4Half4Half4(inA, out); 637 verifyResultsMinHalf4Half4Half4(inA, inB, out, true); 638 } catch (Exception e) { 639 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4Half4Half4: " + e.toString()); 640 } 641 } 642 verifyResultsMinHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)643 private void verifyResultsMinHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 644 short[] arrayInA = new short[INPUTSIZE * 4]; 645 Arrays.fill(arrayInA, (short) 42); 646 inA.copyTo(arrayInA); 647 short[] arrayInB = new short[INPUTSIZE * 4]; 648 Arrays.fill(arrayInB, (short) 42); 649 inB.copyTo(arrayInB); 650 short[] arrayOut = new short[INPUTSIZE * 4]; 651 Arrays.fill(arrayOut, (short) 42); 652 out.copyTo(arrayOut); 653 StringBuilder message = new StringBuilder(); 654 boolean errorFound = false; 655 for (int i = 0; i < INPUTSIZE; i++) { 656 for (int j = 0; j < 4 ; j++) { 657 // Extract the inputs. 658 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 659 args.inA = arrayInA[i * 4 + j]; 660 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 661 args.inB = arrayInB[i * 4 + j]; 662 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 663 // Figure out what the outputs should have been. 664 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 665 CoreMathVerifier.computeMin(args, target); 666 // Validate the outputs. 667 boolean valid = true; 668 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 669 valid = false; 670 } 671 if (!valid) { 672 if (!errorFound) { 673 errorFound = true; 674 message.append("Input inA: "); 675 appendVariableToMessage(message, args.inA); 676 message.append("\n"); 677 message.append("Input inB: "); 678 appendVariableToMessage(message, args.inB); 679 message.append("\n"); 680 message.append("Expected output out: "); 681 appendVariableToMessage(message, args.out); 682 message.append("\n"); 683 message.append("Actual output out: "); 684 appendVariableToMessage(message, arrayOut[i * 4 + j]); 685 message.append("\n"); 686 message.append("Actual output out (in double): "); 687 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 688 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 689 message.append(" FAIL"); 690 } 691 message.append("\n"); 692 message.append("Errors at"); 693 } 694 message.append(" ["); 695 message.append(Integer.toString(i)); 696 message.append(", "); 697 message.append(Integer.toString(j)); 698 message.append("]"); 699 } 700 } 701 } 702 assertFalse("Incorrect output for checkMinHalf4Half4Half4" + 703 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 704 } 705 checkMinFloat2FloatFloat2()706 private void checkMinFloat2FloatFloat2() { 707 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x503b89a6l, false); 708 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x503b89a7l, false); 709 try { 710 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 711 script.set_gAllocInB(inB); 712 script.forEach_testMinFloat2FloatFloat2(inA, out); 713 verifyResultsMinFloat2FloatFloat2(inA, inB, out, false); 714 } catch (Exception e) { 715 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2FloatFloat2: " + e.toString()); 716 } 717 try { 718 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 719 scriptRelaxed.set_gAllocInB(inB); 720 scriptRelaxed.forEach_testMinFloat2FloatFloat2(inA, out); 721 verifyResultsMinFloat2FloatFloat2(inA, inB, out, true); 722 } catch (Exception e) { 723 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2FloatFloat2: " + e.toString()); 724 } 725 } 726 verifyResultsMinFloat2FloatFloat2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)727 private void verifyResultsMinFloat2FloatFloat2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 728 float[] arrayInA = new float[INPUTSIZE * 2]; 729 Arrays.fill(arrayInA, (float) 42); 730 inA.copyTo(arrayInA); 731 float[] arrayInB = new float[INPUTSIZE * 1]; 732 Arrays.fill(arrayInB, (float) 42); 733 inB.copyTo(arrayInB); 734 float[] arrayOut = new float[INPUTSIZE * 2]; 735 Arrays.fill(arrayOut, (float) 42); 736 out.copyTo(arrayOut); 737 StringBuilder message = new StringBuilder(); 738 boolean errorFound = false; 739 for (int i = 0; i < INPUTSIZE; i++) { 740 for (int j = 0; j < 2 ; j++) { 741 // Extract the inputs. 742 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 743 args.inA = arrayInA[i * 2 + j]; 744 args.inB = arrayInB[i]; 745 // Figure out what the outputs should have been. 746 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 747 CoreMathVerifier.computeMin(args, target); 748 // Validate the outputs. 749 boolean valid = true; 750 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 751 valid = false; 752 } 753 if (!valid) { 754 if (!errorFound) { 755 errorFound = true; 756 message.append("Input inA: "); 757 appendVariableToMessage(message, args.inA); 758 message.append("\n"); 759 message.append("Input inB: "); 760 appendVariableToMessage(message, args.inB); 761 message.append("\n"); 762 message.append("Expected output out: "); 763 appendVariableToMessage(message, args.out); 764 message.append("\n"); 765 message.append("Actual output out: "); 766 appendVariableToMessage(message, arrayOut[i * 2 + j]); 767 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 768 message.append(" FAIL"); 769 } 770 message.append("\n"); 771 message.append("Errors at"); 772 } 773 message.append(" ["); 774 message.append(Integer.toString(i)); 775 message.append(", "); 776 message.append(Integer.toString(j)); 777 message.append("]"); 778 } 779 } 780 } 781 assertFalse("Incorrect output for checkMinFloat2FloatFloat2" + 782 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 783 } 784 checkMinFloat3FloatFloat3()785 private void checkMinFloat3FloatFloat3() { 786 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3ea67e02l, false); 787 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3ea67e03l, false); 788 try { 789 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 790 script.set_gAllocInB(inB); 791 script.forEach_testMinFloat3FloatFloat3(inA, out); 792 verifyResultsMinFloat3FloatFloat3(inA, inB, out, false); 793 } catch (Exception e) { 794 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3FloatFloat3: " + e.toString()); 795 } 796 try { 797 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 798 scriptRelaxed.set_gAllocInB(inB); 799 scriptRelaxed.forEach_testMinFloat3FloatFloat3(inA, out); 800 verifyResultsMinFloat3FloatFloat3(inA, inB, out, true); 801 } catch (Exception e) { 802 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3FloatFloat3: " + e.toString()); 803 } 804 } 805 verifyResultsMinFloat3FloatFloat3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)806 private void verifyResultsMinFloat3FloatFloat3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 807 float[] arrayInA = new float[INPUTSIZE * 4]; 808 Arrays.fill(arrayInA, (float) 42); 809 inA.copyTo(arrayInA); 810 float[] arrayInB = new float[INPUTSIZE * 1]; 811 Arrays.fill(arrayInB, (float) 42); 812 inB.copyTo(arrayInB); 813 float[] arrayOut = new float[INPUTSIZE * 4]; 814 Arrays.fill(arrayOut, (float) 42); 815 out.copyTo(arrayOut); 816 StringBuilder message = new StringBuilder(); 817 boolean errorFound = false; 818 for (int i = 0; i < INPUTSIZE; i++) { 819 for (int j = 0; j < 3 ; j++) { 820 // Extract the inputs. 821 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 822 args.inA = arrayInA[i * 4 + j]; 823 args.inB = arrayInB[i]; 824 // Figure out what the outputs should have been. 825 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 826 CoreMathVerifier.computeMin(args, target); 827 // Validate the outputs. 828 boolean valid = true; 829 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 830 valid = false; 831 } 832 if (!valid) { 833 if (!errorFound) { 834 errorFound = true; 835 message.append("Input inA: "); 836 appendVariableToMessage(message, args.inA); 837 message.append("\n"); 838 message.append("Input inB: "); 839 appendVariableToMessage(message, args.inB); 840 message.append("\n"); 841 message.append("Expected output out: "); 842 appendVariableToMessage(message, args.out); 843 message.append("\n"); 844 message.append("Actual output out: "); 845 appendVariableToMessage(message, arrayOut[i * 4 + j]); 846 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 847 message.append(" FAIL"); 848 } 849 message.append("\n"); 850 message.append("Errors at"); 851 } 852 message.append(" ["); 853 message.append(Integer.toString(i)); 854 message.append(", "); 855 message.append(Integer.toString(j)); 856 message.append("]"); 857 } 858 } 859 } 860 assertFalse("Incorrect output for checkMinFloat3FloatFloat3" + 861 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 862 } 863 checkMinFloat4FloatFloat4()864 private void checkMinFloat4FloatFloat4() { 865 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2d11725el, false); 866 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2d11725fl, false); 867 try { 868 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 869 script.set_gAllocInB(inB); 870 script.forEach_testMinFloat4FloatFloat4(inA, out); 871 verifyResultsMinFloat4FloatFloat4(inA, inB, out, false); 872 } catch (Exception e) { 873 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4FloatFloat4: " + e.toString()); 874 } 875 try { 876 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 877 scriptRelaxed.set_gAllocInB(inB); 878 scriptRelaxed.forEach_testMinFloat4FloatFloat4(inA, out); 879 verifyResultsMinFloat4FloatFloat4(inA, inB, out, true); 880 } catch (Exception e) { 881 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4FloatFloat4: " + e.toString()); 882 } 883 } 884 verifyResultsMinFloat4FloatFloat4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)885 private void verifyResultsMinFloat4FloatFloat4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 886 float[] arrayInA = new float[INPUTSIZE * 4]; 887 Arrays.fill(arrayInA, (float) 42); 888 inA.copyTo(arrayInA); 889 float[] arrayInB = new float[INPUTSIZE * 1]; 890 Arrays.fill(arrayInB, (float) 42); 891 inB.copyTo(arrayInB); 892 float[] arrayOut = new float[INPUTSIZE * 4]; 893 Arrays.fill(arrayOut, (float) 42); 894 out.copyTo(arrayOut); 895 StringBuilder message = new StringBuilder(); 896 boolean errorFound = false; 897 for (int i = 0; i < INPUTSIZE; i++) { 898 for (int j = 0; j < 4 ; j++) { 899 // Extract the inputs. 900 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 901 args.inA = arrayInA[i * 4 + j]; 902 args.inB = arrayInB[i]; 903 // Figure out what the outputs should have been. 904 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 905 CoreMathVerifier.computeMin(args, target); 906 // Validate the outputs. 907 boolean valid = true; 908 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 909 valid = false; 910 } 911 if (!valid) { 912 if (!errorFound) { 913 errorFound = true; 914 message.append("Input inA: "); 915 appendVariableToMessage(message, args.inA); 916 message.append("\n"); 917 message.append("Input inB: "); 918 appendVariableToMessage(message, args.inB); 919 message.append("\n"); 920 message.append("Expected output out: "); 921 appendVariableToMessage(message, args.out); 922 message.append("\n"); 923 message.append("Actual output out: "); 924 appendVariableToMessage(message, arrayOut[i * 4 + j]); 925 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 926 message.append(" FAIL"); 927 } 928 message.append("\n"); 929 message.append("Errors at"); 930 } 931 message.append(" ["); 932 message.append(Integer.toString(i)); 933 message.append(", "); 934 message.append(Integer.toString(j)); 935 message.append("]"); 936 } 937 } 938 } 939 assertFalse("Incorrect output for checkMinFloat4FloatFloat4" + 940 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 941 } 942 checkMinHalf2HalfHalf2()943 private void checkMinHalf2HalfHalf2() { 944 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x64f79509l, false); 945 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x64f7950al, false); 946 try { 947 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 948 script.set_gAllocInB(inB); 949 script.forEach_testMinHalf2HalfHalf2(inA, out); 950 verifyResultsMinHalf2HalfHalf2(inA, inB, out, false); 951 } catch (Exception e) { 952 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2HalfHalf2: " + e.toString()); 953 } 954 try { 955 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 956 scriptRelaxed.set_gAllocInB(inB); 957 scriptRelaxed.forEach_testMinHalf2HalfHalf2(inA, out); 958 verifyResultsMinHalf2HalfHalf2(inA, inB, out, true); 959 } catch (Exception e) { 960 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2HalfHalf2: " + e.toString()); 961 } 962 } 963 verifyResultsMinHalf2HalfHalf2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)964 private void verifyResultsMinHalf2HalfHalf2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 965 short[] arrayInA = new short[INPUTSIZE * 2]; 966 Arrays.fill(arrayInA, (short) 42); 967 inA.copyTo(arrayInA); 968 short[] arrayInB = new short[INPUTSIZE * 1]; 969 Arrays.fill(arrayInB, (short) 42); 970 inB.copyTo(arrayInB); 971 short[] arrayOut = new short[INPUTSIZE * 2]; 972 Arrays.fill(arrayOut, (short) 42); 973 out.copyTo(arrayOut); 974 StringBuilder message = new StringBuilder(); 975 boolean errorFound = false; 976 for (int i = 0; i < INPUTSIZE; i++) { 977 for (int j = 0; j < 2 ; j++) { 978 // Extract the inputs. 979 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 980 args.inA = arrayInA[i * 2 + j]; 981 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 982 args.inB = arrayInB[i]; 983 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 984 // Figure out what the outputs should have been. 985 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 986 CoreMathVerifier.computeMin(args, target); 987 // Validate the outputs. 988 boolean valid = true; 989 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 990 valid = false; 991 } 992 if (!valid) { 993 if (!errorFound) { 994 errorFound = true; 995 message.append("Input inA: "); 996 appendVariableToMessage(message, args.inA); 997 message.append("\n"); 998 message.append("Input inB: "); 999 appendVariableToMessage(message, args.inB); 1000 message.append("\n"); 1001 message.append("Expected output out: "); 1002 appendVariableToMessage(message, args.out); 1003 message.append("\n"); 1004 message.append("Actual output out: "); 1005 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1006 message.append("\n"); 1007 message.append("Actual output out (in double): "); 1008 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 1009 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 1010 message.append(" FAIL"); 1011 } 1012 message.append("\n"); 1013 message.append("Errors at"); 1014 } 1015 message.append(" ["); 1016 message.append(Integer.toString(i)); 1017 message.append(", "); 1018 message.append(Integer.toString(j)); 1019 message.append("]"); 1020 } 1021 } 1022 } 1023 assertFalse("Incorrect output for checkMinHalf2HalfHalf2" + 1024 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1025 } 1026 checkMinHalf3HalfHalf3()1027 private void checkMinHalf3HalfHalf3() { 1028 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x179126adl, false); 1029 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x179126ael, false); 1030 try { 1031 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 1032 script.set_gAllocInB(inB); 1033 script.forEach_testMinHalf3HalfHalf3(inA, out); 1034 verifyResultsMinHalf3HalfHalf3(inA, inB, out, false); 1035 } catch (Exception e) { 1036 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3HalfHalf3: " + e.toString()); 1037 } 1038 try { 1039 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 1040 scriptRelaxed.set_gAllocInB(inB); 1041 scriptRelaxed.forEach_testMinHalf3HalfHalf3(inA, out); 1042 verifyResultsMinHalf3HalfHalf3(inA, inB, out, true); 1043 } catch (Exception e) { 1044 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3HalfHalf3: " + e.toString()); 1045 } 1046 } 1047 verifyResultsMinHalf3HalfHalf3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1048 private void verifyResultsMinHalf3HalfHalf3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1049 short[] arrayInA = new short[INPUTSIZE * 4]; 1050 Arrays.fill(arrayInA, (short) 42); 1051 inA.copyTo(arrayInA); 1052 short[] arrayInB = new short[INPUTSIZE * 1]; 1053 Arrays.fill(arrayInB, (short) 42); 1054 inB.copyTo(arrayInB); 1055 short[] arrayOut = new short[INPUTSIZE * 4]; 1056 Arrays.fill(arrayOut, (short) 42); 1057 out.copyTo(arrayOut); 1058 StringBuilder message = new StringBuilder(); 1059 boolean errorFound = false; 1060 for (int i = 0; i < INPUTSIZE; i++) { 1061 for (int j = 0; j < 3 ; j++) { 1062 // Extract the inputs. 1063 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 1064 args.inA = arrayInA[i * 4 + j]; 1065 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 1066 args.inB = arrayInB[i]; 1067 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 1068 // Figure out what the outputs should have been. 1069 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 1070 CoreMathVerifier.computeMin(args, target); 1071 // Validate the outputs. 1072 boolean valid = true; 1073 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 1074 valid = false; 1075 } 1076 if (!valid) { 1077 if (!errorFound) { 1078 errorFound = true; 1079 message.append("Input inA: "); 1080 appendVariableToMessage(message, args.inA); 1081 message.append("\n"); 1082 message.append("Input inB: "); 1083 appendVariableToMessage(message, args.inB); 1084 message.append("\n"); 1085 message.append("Expected output out: "); 1086 appendVariableToMessage(message, args.out); 1087 message.append("\n"); 1088 message.append("Actual output out: "); 1089 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1090 message.append("\n"); 1091 message.append("Actual output out (in double): "); 1092 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 1093 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 1094 message.append(" FAIL"); 1095 } 1096 message.append("\n"); 1097 message.append("Errors at"); 1098 } 1099 message.append(" ["); 1100 message.append(Integer.toString(i)); 1101 message.append(", "); 1102 message.append(Integer.toString(j)); 1103 message.append("]"); 1104 } 1105 } 1106 } 1107 assertFalse("Incorrect output for checkMinHalf3HalfHalf3" + 1108 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1109 } 1110 checkMinHalf4HalfHalf4()1111 private void checkMinHalf4HalfHalf4() { 1112 Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xca2ab851l, false); 1113 Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xca2ab852l, false); 1114 try { 1115 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 1116 script.set_gAllocInB(inB); 1117 script.forEach_testMinHalf4HalfHalf4(inA, out); 1118 verifyResultsMinHalf4HalfHalf4(inA, inB, out, false); 1119 } catch (Exception e) { 1120 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4HalfHalf4: " + e.toString()); 1121 } 1122 try { 1123 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 1124 scriptRelaxed.set_gAllocInB(inB); 1125 scriptRelaxed.forEach_testMinHalf4HalfHalf4(inA, out); 1126 verifyResultsMinHalf4HalfHalf4(inA, inB, out, true); 1127 } catch (Exception e) { 1128 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4HalfHalf4: " + e.toString()); 1129 } 1130 } 1131 verifyResultsMinHalf4HalfHalf4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1132 private void verifyResultsMinHalf4HalfHalf4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1133 short[] arrayInA = new short[INPUTSIZE * 4]; 1134 Arrays.fill(arrayInA, (short) 42); 1135 inA.copyTo(arrayInA); 1136 short[] arrayInB = new short[INPUTSIZE * 1]; 1137 Arrays.fill(arrayInB, (short) 42); 1138 inB.copyTo(arrayInB); 1139 short[] arrayOut = new short[INPUTSIZE * 4]; 1140 Arrays.fill(arrayOut, (short) 42); 1141 out.copyTo(arrayOut); 1142 StringBuilder message = new StringBuilder(); 1143 boolean errorFound = false; 1144 for (int i = 0; i < INPUTSIZE; i++) { 1145 for (int j = 0; j < 4 ; j++) { 1146 // Extract the inputs. 1147 ArgumentsHalfHalfHalf args = new ArgumentsHalfHalfHalf(); 1148 args.inA = arrayInA[i * 4 + j]; 1149 args.inADouble = Float16Utils.convertFloat16ToDouble(args.inA); 1150 args.inB = arrayInB[i]; 1151 args.inBDouble = Float16Utils.convertFloat16ToDouble(args.inB); 1152 // Figure out what the outputs should have been. 1153 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 1154 CoreMathVerifier.computeMin(args, target); 1155 // Validate the outputs. 1156 boolean valid = true; 1157 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 1158 valid = false; 1159 } 1160 if (!valid) { 1161 if (!errorFound) { 1162 errorFound = true; 1163 message.append("Input inA: "); 1164 appendVariableToMessage(message, args.inA); 1165 message.append("\n"); 1166 message.append("Input inB: "); 1167 appendVariableToMessage(message, args.inB); 1168 message.append("\n"); 1169 message.append("Expected output out: "); 1170 appendVariableToMessage(message, args.out); 1171 message.append("\n"); 1172 message.append("Actual output out: "); 1173 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1174 message.append("\n"); 1175 message.append("Actual output out (in double): "); 1176 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 1177 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 1178 message.append(" FAIL"); 1179 } 1180 message.append("\n"); 1181 message.append("Errors at"); 1182 } 1183 message.append(" ["); 1184 message.append(Integer.toString(i)); 1185 message.append(", "); 1186 message.append(Integer.toString(j)); 1187 message.append("]"); 1188 } 1189 } 1190 } 1191 assertFalse("Incorrect output for checkMinHalf4HalfHalf4" + 1192 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1193 } 1194 1195 public class ArgumentsCharCharChar { 1196 public byte inA; 1197 public byte inB; 1198 public byte out; 1199 } 1200 checkMinCharCharChar()1201 private void checkMinCharCharChar() { 1202 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xe8196e0l, false); 1203 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xe8196e1l, false); 1204 try { 1205 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE); 1206 script.set_gAllocInB(inB); 1207 script.forEach_testMinCharCharChar(inA, out); 1208 verifyResultsMinCharCharChar(inA, inB, out, false); 1209 } catch (Exception e) { 1210 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString()); 1211 } 1212 try { 1213 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE); 1214 scriptRelaxed.set_gAllocInB(inB); 1215 scriptRelaxed.forEach_testMinCharCharChar(inA, out); 1216 verifyResultsMinCharCharChar(inA, inB, out, true); 1217 } catch (Exception e) { 1218 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString()); 1219 } 1220 } 1221 verifyResultsMinCharCharChar(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1222 private void verifyResultsMinCharCharChar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1223 byte[] arrayInA = new byte[INPUTSIZE * 1]; 1224 Arrays.fill(arrayInA, (byte) 42); 1225 inA.copyTo(arrayInA); 1226 byte[] arrayInB = new byte[INPUTSIZE * 1]; 1227 Arrays.fill(arrayInB, (byte) 42); 1228 inB.copyTo(arrayInB); 1229 byte[] arrayOut = new byte[INPUTSIZE * 1]; 1230 Arrays.fill(arrayOut, (byte) 42); 1231 out.copyTo(arrayOut); 1232 StringBuilder message = new StringBuilder(); 1233 boolean errorFound = false; 1234 for (int i = 0; i < INPUTSIZE; i++) { 1235 for (int j = 0; j < 1 ; j++) { 1236 // Extract the inputs. 1237 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 1238 args.inA = arrayInA[i]; 1239 args.inB = arrayInB[i]; 1240 // Figure out what the outputs should have been. 1241 CoreMathVerifier.computeMin(args); 1242 // Validate the outputs. 1243 boolean valid = true; 1244 if (args.out != arrayOut[i * 1 + j]) { 1245 valid = false; 1246 } 1247 if (!valid) { 1248 if (!errorFound) { 1249 errorFound = true; 1250 message.append("Input inA: "); 1251 appendVariableToMessage(message, args.inA); 1252 message.append("\n"); 1253 message.append("Input inB: "); 1254 appendVariableToMessage(message, args.inB); 1255 message.append("\n"); 1256 message.append("Expected output out: "); 1257 appendVariableToMessage(message, args.out); 1258 message.append("\n"); 1259 message.append("Actual output out: "); 1260 appendVariableToMessage(message, arrayOut[i * 1 + j]); 1261 if (args.out != arrayOut[i * 1 + j]) { 1262 message.append(" FAIL"); 1263 } 1264 message.append("\n"); 1265 message.append("Errors at"); 1266 } 1267 message.append(" ["); 1268 message.append(Integer.toString(i)); 1269 message.append(", "); 1270 message.append(Integer.toString(j)); 1271 message.append("]"); 1272 } 1273 } 1274 } 1275 assertFalse("Incorrect output for checkMinCharCharChar" + 1276 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1277 } 1278 checkMinChar2Char2Char2()1279 private void checkMinChar2Char2Char2() { 1280 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc8ef5ae2l, false); 1281 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc8ef5ae3l, false); 1282 try { 1283 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1284 script.set_gAllocInB(inB); 1285 script.forEach_testMinChar2Char2Char2(inA, out); 1286 verifyResultsMinChar2Char2Char2(inA, inB, out, false); 1287 } catch (Exception e) { 1288 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString()); 1289 } 1290 try { 1291 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1292 scriptRelaxed.set_gAllocInB(inB); 1293 scriptRelaxed.forEach_testMinChar2Char2Char2(inA, out); 1294 verifyResultsMinChar2Char2Char2(inA, inB, out, true); 1295 } catch (Exception e) { 1296 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString()); 1297 } 1298 } 1299 verifyResultsMinChar2Char2Char2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1300 private void verifyResultsMinChar2Char2Char2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1301 byte[] arrayInA = new byte[INPUTSIZE * 2]; 1302 Arrays.fill(arrayInA, (byte) 42); 1303 inA.copyTo(arrayInA); 1304 byte[] arrayInB = new byte[INPUTSIZE * 2]; 1305 Arrays.fill(arrayInB, (byte) 42); 1306 inB.copyTo(arrayInB); 1307 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1308 Arrays.fill(arrayOut, (byte) 42); 1309 out.copyTo(arrayOut); 1310 StringBuilder message = new StringBuilder(); 1311 boolean errorFound = false; 1312 for (int i = 0; i < INPUTSIZE; i++) { 1313 for (int j = 0; j < 2 ; j++) { 1314 // Extract the inputs. 1315 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 1316 args.inA = arrayInA[i * 2 + j]; 1317 args.inB = arrayInB[i * 2 + j]; 1318 // Figure out what the outputs should have been. 1319 CoreMathVerifier.computeMin(args); 1320 // Validate the outputs. 1321 boolean valid = true; 1322 if (args.out != arrayOut[i * 2 + j]) { 1323 valid = false; 1324 } 1325 if (!valid) { 1326 if (!errorFound) { 1327 errorFound = true; 1328 message.append("Input inA: "); 1329 appendVariableToMessage(message, args.inA); 1330 message.append("\n"); 1331 message.append("Input inB: "); 1332 appendVariableToMessage(message, args.inB); 1333 message.append("\n"); 1334 message.append("Expected output out: "); 1335 appendVariableToMessage(message, args.out); 1336 message.append("\n"); 1337 message.append("Actual output out: "); 1338 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1339 if (args.out != arrayOut[i * 2 + j]) { 1340 message.append(" FAIL"); 1341 } 1342 message.append("\n"); 1343 message.append("Errors at"); 1344 } 1345 message.append(" ["); 1346 message.append(Integer.toString(i)); 1347 message.append(", "); 1348 message.append(Integer.toString(j)); 1349 message.append("]"); 1350 } 1351 } 1352 } 1353 assertFalse("Incorrect output for checkMinChar2Char2Char2" + 1354 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1355 } 1356 checkMinChar3Char3Char3()1357 private void checkMinChar3Char3Char3() { 1358 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x278e6bb1l, false); 1359 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x278e6bb2l, false); 1360 try { 1361 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1362 script.set_gAllocInB(inB); 1363 script.forEach_testMinChar3Char3Char3(inA, out); 1364 verifyResultsMinChar3Char3Char3(inA, inB, out, false); 1365 } catch (Exception e) { 1366 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString()); 1367 } 1368 try { 1369 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1370 scriptRelaxed.set_gAllocInB(inB); 1371 scriptRelaxed.forEach_testMinChar3Char3Char3(inA, out); 1372 verifyResultsMinChar3Char3Char3(inA, inB, out, true); 1373 } catch (Exception e) { 1374 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString()); 1375 } 1376 } 1377 verifyResultsMinChar3Char3Char3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1378 private void verifyResultsMinChar3Char3Char3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1379 byte[] arrayInA = new byte[INPUTSIZE * 4]; 1380 Arrays.fill(arrayInA, (byte) 42); 1381 inA.copyTo(arrayInA); 1382 byte[] arrayInB = new byte[INPUTSIZE * 4]; 1383 Arrays.fill(arrayInB, (byte) 42); 1384 inB.copyTo(arrayInB); 1385 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1386 Arrays.fill(arrayOut, (byte) 42); 1387 out.copyTo(arrayOut); 1388 StringBuilder message = new StringBuilder(); 1389 boolean errorFound = false; 1390 for (int i = 0; i < INPUTSIZE; i++) { 1391 for (int j = 0; j < 3 ; j++) { 1392 // Extract the inputs. 1393 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 1394 args.inA = arrayInA[i * 4 + j]; 1395 args.inB = arrayInB[i * 4 + j]; 1396 // Figure out what the outputs should have been. 1397 CoreMathVerifier.computeMin(args); 1398 // Validate the outputs. 1399 boolean valid = true; 1400 if (args.out != arrayOut[i * 4 + j]) { 1401 valid = false; 1402 } 1403 if (!valid) { 1404 if (!errorFound) { 1405 errorFound = true; 1406 message.append("Input inA: "); 1407 appendVariableToMessage(message, args.inA); 1408 message.append("\n"); 1409 message.append("Input inB: "); 1410 appendVariableToMessage(message, args.inB); 1411 message.append("\n"); 1412 message.append("Expected output out: "); 1413 appendVariableToMessage(message, args.out); 1414 message.append("\n"); 1415 message.append("Actual output out: "); 1416 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1417 if (args.out != arrayOut[i * 4 + j]) { 1418 message.append(" FAIL"); 1419 } 1420 message.append("\n"); 1421 message.append("Errors at"); 1422 } 1423 message.append(" ["); 1424 message.append(Integer.toString(i)); 1425 message.append(", "); 1426 message.append(Integer.toString(j)); 1427 message.append("]"); 1428 } 1429 } 1430 } 1431 assertFalse("Incorrect output for checkMinChar3Char3Char3" + 1432 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1433 } 1434 checkMinChar4Char4Char4()1435 private void checkMinChar4Char4Char4() { 1436 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x862d7c80l, false); 1437 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x862d7c81l, false); 1438 try { 1439 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1440 script.set_gAllocInB(inB); 1441 script.forEach_testMinChar4Char4Char4(inA, out); 1442 verifyResultsMinChar4Char4Char4(inA, inB, out, false); 1443 } catch (Exception e) { 1444 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString()); 1445 } 1446 try { 1447 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1448 scriptRelaxed.set_gAllocInB(inB); 1449 scriptRelaxed.forEach_testMinChar4Char4Char4(inA, out); 1450 verifyResultsMinChar4Char4Char4(inA, inB, out, true); 1451 } catch (Exception e) { 1452 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString()); 1453 } 1454 } 1455 verifyResultsMinChar4Char4Char4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1456 private void verifyResultsMinChar4Char4Char4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1457 byte[] arrayInA = new byte[INPUTSIZE * 4]; 1458 Arrays.fill(arrayInA, (byte) 42); 1459 inA.copyTo(arrayInA); 1460 byte[] arrayInB = new byte[INPUTSIZE * 4]; 1461 Arrays.fill(arrayInB, (byte) 42); 1462 inB.copyTo(arrayInB); 1463 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1464 Arrays.fill(arrayOut, (byte) 42); 1465 out.copyTo(arrayOut); 1466 StringBuilder message = new StringBuilder(); 1467 boolean errorFound = false; 1468 for (int i = 0; i < INPUTSIZE; i++) { 1469 for (int j = 0; j < 4 ; j++) { 1470 // Extract the inputs. 1471 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 1472 args.inA = arrayInA[i * 4 + j]; 1473 args.inB = arrayInB[i * 4 + j]; 1474 // Figure out what the outputs should have been. 1475 CoreMathVerifier.computeMin(args); 1476 // Validate the outputs. 1477 boolean valid = true; 1478 if (args.out != arrayOut[i * 4 + j]) { 1479 valid = false; 1480 } 1481 if (!valid) { 1482 if (!errorFound) { 1483 errorFound = true; 1484 message.append("Input inA: "); 1485 appendVariableToMessage(message, args.inA); 1486 message.append("\n"); 1487 message.append("Input inB: "); 1488 appendVariableToMessage(message, args.inB); 1489 message.append("\n"); 1490 message.append("Expected output out: "); 1491 appendVariableToMessage(message, args.out); 1492 message.append("\n"); 1493 message.append("Actual output out: "); 1494 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1495 if (args.out != arrayOut[i * 4 + j]) { 1496 message.append(" FAIL"); 1497 } 1498 message.append("\n"); 1499 message.append("Errors at"); 1500 } 1501 message.append(" ["); 1502 message.append(Integer.toString(i)); 1503 message.append(", "); 1504 message.append(Integer.toString(j)); 1505 message.append("]"); 1506 } 1507 } 1508 } 1509 assertFalse("Incorrect output for checkMinChar4Char4Char4" + 1510 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1511 } 1512 1513 public class ArgumentsUcharUcharUchar { 1514 public byte inA; 1515 public byte inB; 1516 public byte out; 1517 } 1518 checkMinUcharUcharUchar()1519 private void checkMinUcharUcharUchar() { 1520 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x3445490bl, false); 1521 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x3445490cl, false); 1522 try { 1523 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE); 1524 script.set_gAllocInB(inB); 1525 script.forEach_testMinUcharUcharUchar(inA, out); 1526 verifyResultsMinUcharUcharUchar(inA, inB, out, false); 1527 } catch (Exception e) { 1528 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString()); 1529 } 1530 try { 1531 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE); 1532 scriptRelaxed.set_gAllocInB(inB); 1533 scriptRelaxed.forEach_testMinUcharUcharUchar(inA, out); 1534 verifyResultsMinUcharUcharUchar(inA, inB, out, true); 1535 } catch (Exception e) { 1536 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString()); 1537 } 1538 } 1539 verifyResultsMinUcharUcharUchar(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1540 private void verifyResultsMinUcharUcharUchar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1541 byte[] arrayInA = new byte[INPUTSIZE * 1]; 1542 Arrays.fill(arrayInA, (byte) 42); 1543 inA.copyTo(arrayInA); 1544 byte[] arrayInB = new byte[INPUTSIZE * 1]; 1545 Arrays.fill(arrayInB, (byte) 42); 1546 inB.copyTo(arrayInB); 1547 byte[] arrayOut = new byte[INPUTSIZE * 1]; 1548 Arrays.fill(arrayOut, (byte) 42); 1549 out.copyTo(arrayOut); 1550 StringBuilder message = new StringBuilder(); 1551 boolean errorFound = false; 1552 for (int i = 0; i < INPUTSIZE; i++) { 1553 for (int j = 0; j < 1 ; j++) { 1554 // Extract the inputs. 1555 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 1556 args.inA = arrayInA[i]; 1557 args.inB = arrayInB[i]; 1558 // Figure out what the outputs should have been. 1559 CoreMathVerifier.computeMin(args); 1560 // Validate the outputs. 1561 boolean valid = true; 1562 if (args.out != arrayOut[i * 1 + j]) { 1563 valid = false; 1564 } 1565 if (!valid) { 1566 if (!errorFound) { 1567 errorFound = true; 1568 message.append("Input inA: "); 1569 appendVariableToMessage(message, args.inA); 1570 message.append("\n"); 1571 message.append("Input inB: "); 1572 appendVariableToMessage(message, args.inB); 1573 message.append("\n"); 1574 message.append("Expected output out: "); 1575 appendVariableToMessage(message, args.out); 1576 message.append("\n"); 1577 message.append("Actual output out: "); 1578 appendVariableToMessage(message, arrayOut[i * 1 + j]); 1579 if (args.out != arrayOut[i * 1 + j]) { 1580 message.append(" FAIL"); 1581 } 1582 message.append("\n"); 1583 message.append("Errors at"); 1584 } 1585 message.append(" ["); 1586 message.append(Integer.toString(i)); 1587 message.append(", "); 1588 message.append(Integer.toString(j)); 1589 message.append("]"); 1590 } 1591 } 1592 } 1593 assertFalse("Incorrect output for checkMinUcharUcharUchar" + 1594 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1595 } 1596 checkMinUchar2Uchar2Uchar2()1597 private void checkMinUchar2Uchar2Uchar2() { 1598 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xcaf0b355l, false); 1599 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xcaf0b356l, false); 1600 try { 1601 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 1602 script.set_gAllocInB(inB); 1603 script.forEach_testMinUchar2Uchar2Uchar2(inA, out); 1604 verifyResultsMinUchar2Uchar2Uchar2(inA, inB, out, false); 1605 } catch (Exception e) { 1606 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString()); 1607 } 1608 try { 1609 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 1610 scriptRelaxed.set_gAllocInB(inB); 1611 scriptRelaxed.forEach_testMinUchar2Uchar2Uchar2(inA, out); 1612 verifyResultsMinUchar2Uchar2Uchar2(inA, inB, out, true); 1613 } catch (Exception e) { 1614 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString()); 1615 } 1616 } 1617 verifyResultsMinUchar2Uchar2Uchar2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1618 private void verifyResultsMinUchar2Uchar2Uchar2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1619 byte[] arrayInA = new byte[INPUTSIZE * 2]; 1620 Arrays.fill(arrayInA, (byte) 42); 1621 inA.copyTo(arrayInA); 1622 byte[] arrayInB = new byte[INPUTSIZE * 2]; 1623 Arrays.fill(arrayInB, (byte) 42); 1624 inB.copyTo(arrayInB); 1625 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1626 Arrays.fill(arrayOut, (byte) 42); 1627 out.copyTo(arrayOut); 1628 StringBuilder message = new StringBuilder(); 1629 boolean errorFound = false; 1630 for (int i = 0; i < INPUTSIZE; i++) { 1631 for (int j = 0; j < 2 ; j++) { 1632 // Extract the inputs. 1633 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 1634 args.inA = arrayInA[i * 2 + j]; 1635 args.inB = arrayInB[i * 2 + j]; 1636 // Figure out what the outputs should have been. 1637 CoreMathVerifier.computeMin(args); 1638 // Validate the outputs. 1639 boolean valid = true; 1640 if (args.out != arrayOut[i * 2 + j]) { 1641 valid = false; 1642 } 1643 if (!valid) { 1644 if (!errorFound) { 1645 errorFound = true; 1646 message.append("Input inA: "); 1647 appendVariableToMessage(message, args.inA); 1648 message.append("\n"); 1649 message.append("Input inB: "); 1650 appendVariableToMessage(message, args.inB); 1651 message.append("\n"); 1652 message.append("Expected output out: "); 1653 appendVariableToMessage(message, args.out); 1654 message.append("\n"); 1655 message.append("Actual output out: "); 1656 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1657 if (args.out != arrayOut[i * 2 + j]) { 1658 message.append(" FAIL"); 1659 } 1660 message.append("\n"); 1661 message.append("Errors at"); 1662 } 1663 message.append(" ["); 1664 message.append(Integer.toString(i)); 1665 message.append(", "); 1666 message.append(Integer.toString(j)); 1667 message.append("]"); 1668 } 1669 } 1670 } 1671 assertFalse("Incorrect output for checkMinUchar2Uchar2Uchar2" + 1672 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1673 } 1674 checkMinUchar3Uchar3Uchar3()1675 private void checkMinUchar3Uchar3Uchar3() { 1676 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xccceb4f6l, false); 1677 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xccceb4f7l, false); 1678 try { 1679 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 1680 script.set_gAllocInB(inB); 1681 script.forEach_testMinUchar3Uchar3Uchar3(inA, out); 1682 verifyResultsMinUchar3Uchar3Uchar3(inA, inB, out, false); 1683 } catch (Exception e) { 1684 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString()); 1685 } 1686 try { 1687 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 1688 scriptRelaxed.set_gAllocInB(inB); 1689 scriptRelaxed.forEach_testMinUchar3Uchar3Uchar3(inA, out); 1690 verifyResultsMinUchar3Uchar3Uchar3(inA, inB, out, true); 1691 } catch (Exception e) { 1692 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString()); 1693 } 1694 } 1695 verifyResultsMinUchar3Uchar3Uchar3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1696 private void verifyResultsMinUchar3Uchar3Uchar3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1697 byte[] arrayInA = new byte[INPUTSIZE * 4]; 1698 Arrays.fill(arrayInA, (byte) 42); 1699 inA.copyTo(arrayInA); 1700 byte[] arrayInB = new byte[INPUTSIZE * 4]; 1701 Arrays.fill(arrayInB, (byte) 42); 1702 inB.copyTo(arrayInB); 1703 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1704 Arrays.fill(arrayOut, (byte) 42); 1705 out.copyTo(arrayOut); 1706 StringBuilder message = new StringBuilder(); 1707 boolean errorFound = false; 1708 for (int i = 0; i < INPUTSIZE; i++) { 1709 for (int j = 0; j < 3 ; j++) { 1710 // Extract the inputs. 1711 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 1712 args.inA = arrayInA[i * 4 + j]; 1713 args.inB = arrayInB[i * 4 + j]; 1714 // Figure out what the outputs should have been. 1715 CoreMathVerifier.computeMin(args); 1716 // Validate the outputs. 1717 boolean valid = true; 1718 if (args.out != arrayOut[i * 4 + j]) { 1719 valid = false; 1720 } 1721 if (!valid) { 1722 if (!errorFound) { 1723 errorFound = true; 1724 message.append("Input inA: "); 1725 appendVariableToMessage(message, args.inA); 1726 message.append("\n"); 1727 message.append("Input inB: "); 1728 appendVariableToMessage(message, args.inB); 1729 message.append("\n"); 1730 message.append("Expected output out: "); 1731 appendVariableToMessage(message, args.out); 1732 message.append("\n"); 1733 message.append("Actual output out: "); 1734 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1735 if (args.out != arrayOut[i * 4 + j]) { 1736 message.append(" FAIL"); 1737 } 1738 message.append("\n"); 1739 message.append("Errors at"); 1740 } 1741 message.append(" ["); 1742 message.append(Integer.toString(i)); 1743 message.append(", "); 1744 message.append(Integer.toString(j)); 1745 message.append("]"); 1746 } 1747 } 1748 } 1749 assertFalse("Incorrect output for checkMinUchar3Uchar3Uchar3" + 1750 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1751 } 1752 checkMinUchar4Uchar4Uchar4()1753 private void checkMinUchar4Uchar4Uchar4() { 1754 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xceacb697l, false); 1755 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xceacb698l, false); 1756 try { 1757 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 1758 script.set_gAllocInB(inB); 1759 script.forEach_testMinUchar4Uchar4Uchar4(inA, out); 1760 verifyResultsMinUchar4Uchar4Uchar4(inA, inB, out, false); 1761 } catch (Exception e) { 1762 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString()); 1763 } 1764 try { 1765 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 1766 scriptRelaxed.set_gAllocInB(inB); 1767 scriptRelaxed.forEach_testMinUchar4Uchar4Uchar4(inA, out); 1768 verifyResultsMinUchar4Uchar4Uchar4(inA, inB, out, true); 1769 } catch (Exception e) { 1770 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString()); 1771 } 1772 } 1773 verifyResultsMinUchar4Uchar4Uchar4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1774 private void verifyResultsMinUchar4Uchar4Uchar4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1775 byte[] arrayInA = new byte[INPUTSIZE * 4]; 1776 Arrays.fill(arrayInA, (byte) 42); 1777 inA.copyTo(arrayInA); 1778 byte[] arrayInB = new byte[INPUTSIZE * 4]; 1779 Arrays.fill(arrayInB, (byte) 42); 1780 inB.copyTo(arrayInB); 1781 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1782 Arrays.fill(arrayOut, (byte) 42); 1783 out.copyTo(arrayOut); 1784 StringBuilder message = new StringBuilder(); 1785 boolean errorFound = false; 1786 for (int i = 0; i < INPUTSIZE; i++) { 1787 for (int j = 0; j < 4 ; j++) { 1788 // Extract the inputs. 1789 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 1790 args.inA = arrayInA[i * 4 + j]; 1791 args.inB = arrayInB[i * 4 + j]; 1792 // Figure out what the outputs should have been. 1793 CoreMathVerifier.computeMin(args); 1794 // Validate the outputs. 1795 boolean valid = true; 1796 if (args.out != arrayOut[i * 4 + j]) { 1797 valid = false; 1798 } 1799 if (!valid) { 1800 if (!errorFound) { 1801 errorFound = true; 1802 message.append("Input inA: "); 1803 appendVariableToMessage(message, args.inA); 1804 message.append("\n"); 1805 message.append("Input inB: "); 1806 appendVariableToMessage(message, args.inB); 1807 message.append("\n"); 1808 message.append("Expected output out: "); 1809 appendVariableToMessage(message, args.out); 1810 message.append("\n"); 1811 message.append("Actual output out: "); 1812 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1813 if (args.out != arrayOut[i * 4 + j]) { 1814 message.append(" FAIL"); 1815 } 1816 message.append("\n"); 1817 message.append("Errors at"); 1818 } 1819 message.append(" ["); 1820 message.append(Integer.toString(i)); 1821 message.append(", "); 1822 message.append(Integer.toString(j)); 1823 message.append("]"); 1824 } 1825 } 1826 } 1827 assertFalse("Incorrect output for checkMinUchar4Uchar4Uchar4" + 1828 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1829 } 1830 1831 public class ArgumentsShortShortShort { 1832 public short inA; 1833 public short inB; 1834 public short out; 1835 } 1836 checkMinShortShortShort()1837 private void checkMinShortShortShort() { 1838 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xf2c0a572l, false); 1839 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xf2c0a573l, false); 1840 try { 1841 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE); 1842 script.set_gAllocInB(inB); 1843 script.forEach_testMinShortShortShort(inA, out); 1844 verifyResultsMinShortShortShort(inA, inB, out, false); 1845 } catch (Exception e) { 1846 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString()); 1847 } 1848 try { 1849 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE); 1850 scriptRelaxed.set_gAllocInB(inB); 1851 scriptRelaxed.forEach_testMinShortShortShort(inA, out); 1852 verifyResultsMinShortShortShort(inA, inB, out, true); 1853 } catch (Exception e) { 1854 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString()); 1855 } 1856 } 1857 verifyResultsMinShortShortShort(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1858 private void verifyResultsMinShortShortShort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1859 short[] arrayInA = new short[INPUTSIZE * 1]; 1860 Arrays.fill(arrayInA, (short) 42); 1861 inA.copyTo(arrayInA); 1862 short[] arrayInB = new short[INPUTSIZE * 1]; 1863 Arrays.fill(arrayInB, (short) 42); 1864 inB.copyTo(arrayInB); 1865 short[] arrayOut = new short[INPUTSIZE * 1]; 1866 Arrays.fill(arrayOut, (short) 42); 1867 out.copyTo(arrayOut); 1868 StringBuilder message = new StringBuilder(); 1869 boolean errorFound = false; 1870 for (int i = 0; i < INPUTSIZE; i++) { 1871 for (int j = 0; j < 1 ; j++) { 1872 // Extract the inputs. 1873 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 1874 args.inA = arrayInA[i]; 1875 args.inB = arrayInB[i]; 1876 // Figure out what the outputs should have been. 1877 CoreMathVerifier.computeMin(args); 1878 // Validate the outputs. 1879 boolean valid = true; 1880 if (args.out != arrayOut[i * 1 + j]) { 1881 valid = false; 1882 } 1883 if (!valid) { 1884 if (!errorFound) { 1885 errorFound = true; 1886 message.append("Input inA: "); 1887 appendVariableToMessage(message, args.inA); 1888 message.append("\n"); 1889 message.append("Input inB: "); 1890 appendVariableToMessage(message, args.inB); 1891 message.append("\n"); 1892 message.append("Expected output out: "); 1893 appendVariableToMessage(message, args.out); 1894 message.append("\n"); 1895 message.append("Actual output out: "); 1896 appendVariableToMessage(message, arrayOut[i * 1 + j]); 1897 if (args.out != arrayOut[i * 1 + j]) { 1898 message.append(" FAIL"); 1899 } 1900 message.append("\n"); 1901 message.append("Errors at"); 1902 } 1903 message.append(" ["); 1904 message.append(Integer.toString(i)); 1905 message.append(", "); 1906 message.append(Integer.toString(j)); 1907 message.append("]"); 1908 } 1909 } 1910 } 1911 assertFalse("Incorrect output for checkMinShortShortShort" + 1912 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1913 } 1914 checkMinShort2Short2Short2()1915 private void checkMinShort2Short2Short2() { 1916 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69f3c358l, false); 1917 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69f3c359l, false); 1918 try { 1919 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 1920 script.set_gAllocInB(inB); 1921 script.forEach_testMinShort2Short2Short2(inA, out); 1922 verifyResultsMinShort2Short2Short2(inA, inB, out, false); 1923 } catch (Exception e) { 1924 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString()); 1925 } 1926 try { 1927 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 1928 scriptRelaxed.set_gAllocInB(inB); 1929 scriptRelaxed.forEach_testMinShort2Short2Short2(inA, out); 1930 verifyResultsMinShort2Short2Short2(inA, inB, out, true); 1931 } catch (Exception e) { 1932 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString()); 1933 } 1934 } 1935 verifyResultsMinShort2Short2Short2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)1936 private void verifyResultsMinShort2Short2Short2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 1937 short[] arrayInA = new short[INPUTSIZE * 2]; 1938 Arrays.fill(arrayInA, (short) 42); 1939 inA.copyTo(arrayInA); 1940 short[] arrayInB = new short[INPUTSIZE * 2]; 1941 Arrays.fill(arrayInB, (short) 42); 1942 inB.copyTo(arrayInB); 1943 short[] arrayOut = new short[INPUTSIZE * 2]; 1944 Arrays.fill(arrayOut, (short) 42); 1945 out.copyTo(arrayOut); 1946 StringBuilder message = new StringBuilder(); 1947 boolean errorFound = false; 1948 for (int i = 0; i < INPUTSIZE; i++) { 1949 for (int j = 0; j < 2 ; j++) { 1950 // Extract the inputs. 1951 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 1952 args.inA = arrayInA[i * 2 + j]; 1953 args.inB = arrayInB[i * 2 + j]; 1954 // Figure out what the outputs should have been. 1955 CoreMathVerifier.computeMin(args); 1956 // Validate the outputs. 1957 boolean valid = true; 1958 if (args.out != arrayOut[i * 2 + j]) { 1959 valid = false; 1960 } 1961 if (!valid) { 1962 if (!errorFound) { 1963 errorFound = true; 1964 message.append("Input inA: "); 1965 appendVariableToMessage(message, args.inA); 1966 message.append("\n"); 1967 message.append("Input inB: "); 1968 appendVariableToMessage(message, args.inB); 1969 message.append("\n"); 1970 message.append("Expected output out: "); 1971 appendVariableToMessage(message, args.out); 1972 message.append("\n"); 1973 message.append("Actual output out: "); 1974 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1975 if (args.out != arrayOut[i * 2 + j]) { 1976 message.append(" FAIL"); 1977 } 1978 message.append("\n"); 1979 message.append("Errors at"); 1980 } 1981 message.append(" ["); 1982 message.append(Integer.toString(i)); 1983 message.append(", "); 1984 message.append(Integer.toString(j)); 1985 message.append("]"); 1986 } 1987 } 1988 } 1989 assertFalse("Incorrect output for checkMinShort2Short2Short2" + 1990 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1991 } 1992 checkMinShort3Short3Short3()1993 private void checkMinShort3Short3Short3() { 1994 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6bd1c4f9l, false); 1995 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6bd1c4fal, false); 1996 try { 1997 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 1998 script.set_gAllocInB(inB); 1999 script.forEach_testMinShort3Short3Short3(inA, out); 2000 verifyResultsMinShort3Short3Short3(inA, inB, out, false); 2001 } catch (Exception e) { 2002 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString()); 2003 } 2004 try { 2005 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 2006 scriptRelaxed.set_gAllocInB(inB); 2007 scriptRelaxed.forEach_testMinShort3Short3Short3(inA, out); 2008 verifyResultsMinShort3Short3Short3(inA, inB, out, true); 2009 } catch (Exception e) { 2010 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString()); 2011 } 2012 } 2013 verifyResultsMinShort3Short3Short3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2014 private void verifyResultsMinShort3Short3Short3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2015 short[] arrayInA = new short[INPUTSIZE * 4]; 2016 Arrays.fill(arrayInA, (short) 42); 2017 inA.copyTo(arrayInA); 2018 short[] arrayInB = new short[INPUTSIZE * 4]; 2019 Arrays.fill(arrayInB, (short) 42); 2020 inB.copyTo(arrayInB); 2021 short[] arrayOut = new short[INPUTSIZE * 4]; 2022 Arrays.fill(arrayOut, (short) 42); 2023 out.copyTo(arrayOut); 2024 StringBuilder message = new StringBuilder(); 2025 boolean errorFound = false; 2026 for (int i = 0; i < INPUTSIZE; i++) { 2027 for (int j = 0; j < 3 ; j++) { 2028 // Extract the inputs. 2029 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 2030 args.inA = arrayInA[i * 4 + j]; 2031 args.inB = arrayInB[i * 4 + j]; 2032 // Figure out what the outputs should have been. 2033 CoreMathVerifier.computeMin(args); 2034 // Validate the outputs. 2035 boolean valid = true; 2036 if (args.out != arrayOut[i * 4 + j]) { 2037 valid = false; 2038 } 2039 if (!valid) { 2040 if (!errorFound) { 2041 errorFound = true; 2042 message.append("Input inA: "); 2043 appendVariableToMessage(message, args.inA); 2044 message.append("\n"); 2045 message.append("Input inB: "); 2046 appendVariableToMessage(message, args.inB); 2047 message.append("\n"); 2048 message.append("Expected output out: "); 2049 appendVariableToMessage(message, args.out); 2050 message.append("\n"); 2051 message.append("Actual output out: "); 2052 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2053 if (args.out != arrayOut[i * 4 + j]) { 2054 message.append(" FAIL"); 2055 } 2056 message.append("\n"); 2057 message.append("Errors at"); 2058 } 2059 message.append(" ["); 2060 message.append(Integer.toString(i)); 2061 message.append(", "); 2062 message.append(Integer.toString(j)); 2063 message.append("]"); 2064 } 2065 } 2066 } 2067 assertFalse("Incorrect output for checkMinShort3Short3Short3" + 2068 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2069 } 2070 checkMinShort4Short4Short4()2071 private void checkMinShort4Short4Short4() { 2072 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x6dafc69al, false); 2073 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x6dafc69bl, false); 2074 try { 2075 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 2076 script.set_gAllocInB(inB); 2077 script.forEach_testMinShort4Short4Short4(inA, out); 2078 verifyResultsMinShort4Short4Short4(inA, inB, out, false); 2079 } catch (Exception e) { 2080 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString()); 2081 } 2082 try { 2083 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 2084 scriptRelaxed.set_gAllocInB(inB); 2085 scriptRelaxed.forEach_testMinShort4Short4Short4(inA, out); 2086 verifyResultsMinShort4Short4Short4(inA, inB, out, true); 2087 } catch (Exception e) { 2088 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString()); 2089 } 2090 } 2091 verifyResultsMinShort4Short4Short4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2092 private void verifyResultsMinShort4Short4Short4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2093 short[] arrayInA = new short[INPUTSIZE * 4]; 2094 Arrays.fill(arrayInA, (short) 42); 2095 inA.copyTo(arrayInA); 2096 short[] arrayInB = new short[INPUTSIZE * 4]; 2097 Arrays.fill(arrayInB, (short) 42); 2098 inB.copyTo(arrayInB); 2099 short[] arrayOut = new short[INPUTSIZE * 4]; 2100 Arrays.fill(arrayOut, (short) 42); 2101 out.copyTo(arrayOut); 2102 StringBuilder message = new StringBuilder(); 2103 boolean errorFound = false; 2104 for (int i = 0; i < INPUTSIZE; i++) { 2105 for (int j = 0; j < 4 ; j++) { 2106 // Extract the inputs. 2107 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 2108 args.inA = arrayInA[i * 4 + j]; 2109 args.inB = arrayInB[i * 4 + j]; 2110 // Figure out what the outputs should have been. 2111 CoreMathVerifier.computeMin(args); 2112 // Validate the outputs. 2113 boolean valid = true; 2114 if (args.out != arrayOut[i * 4 + j]) { 2115 valid = false; 2116 } 2117 if (!valid) { 2118 if (!errorFound) { 2119 errorFound = true; 2120 message.append("Input inA: "); 2121 appendVariableToMessage(message, args.inA); 2122 message.append("\n"); 2123 message.append("Input inB: "); 2124 appendVariableToMessage(message, args.inB); 2125 message.append("\n"); 2126 message.append("Expected output out: "); 2127 appendVariableToMessage(message, args.out); 2128 message.append("\n"); 2129 message.append("Actual output out: "); 2130 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2131 if (args.out != arrayOut[i * 4 + j]) { 2132 message.append(" FAIL"); 2133 } 2134 message.append("\n"); 2135 message.append("Errors at"); 2136 } 2137 message.append(" ["); 2138 message.append(Integer.toString(i)); 2139 message.append(", "); 2140 message.append(Integer.toString(j)); 2141 message.append("]"); 2142 } 2143 } 2144 } 2145 assertFalse("Incorrect output for checkMinShort4Short4Short4" + 2146 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2147 } 2148 2149 public class ArgumentsUshortUshortUshort { 2150 public short inA; 2151 public short inB; 2152 public short out; 2153 } 2154 checkMinUshortUshortUshort()2155 private void checkMinUshortUshortUshort() { 2156 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xcc4e79c5l, false); 2157 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xcc4e79c6l, false); 2158 try { 2159 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE); 2160 script.set_gAllocInB(inB); 2161 script.forEach_testMinUshortUshortUshort(inA, out); 2162 verifyResultsMinUshortUshortUshort(inA, inB, out, false); 2163 } catch (Exception e) { 2164 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString()); 2165 } 2166 try { 2167 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE); 2168 scriptRelaxed.set_gAllocInB(inB); 2169 scriptRelaxed.forEach_testMinUshortUshortUshort(inA, out); 2170 verifyResultsMinUshortUshortUshort(inA, inB, out, true); 2171 } catch (Exception e) { 2172 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString()); 2173 } 2174 } 2175 verifyResultsMinUshortUshortUshort(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2176 private void verifyResultsMinUshortUshortUshort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2177 short[] arrayInA = new short[INPUTSIZE * 1]; 2178 Arrays.fill(arrayInA, (short) 42); 2179 inA.copyTo(arrayInA); 2180 short[] arrayInB = new short[INPUTSIZE * 1]; 2181 Arrays.fill(arrayInB, (short) 42); 2182 inB.copyTo(arrayInB); 2183 short[] arrayOut = new short[INPUTSIZE * 1]; 2184 Arrays.fill(arrayOut, (short) 42); 2185 out.copyTo(arrayOut); 2186 StringBuilder message = new StringBuilder(); 2187 boolean errorFound = false; 2188 for (int i = 0; i < INPUTSIZE; i++) { 2189 for (int j = 0; j < 1 ; j++) { 2190 // Extract the inputs. 2191 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 2192 args.inA = arrayInA[i]; 2193 args.inB = arrayInB[i]; 2194 // Figure out what the outputs should have been. 2195 CoreMathVerifier.computeMin(args); 2196 // Validate the outputs. 2197 boolean valid = true; 2198 if (args.out != arrayOut[i * 1 + j]) { 2199 valid = false; 2200 } 2201 if (!valid) { 2202 if (!errorFound) { 2203 errorFound = true; 2204 message.append("Input inA: "); 2205 appendVariableToMessage(message, args.inA); 2206 message.append("\n"); 2207 message.append("Input inB: "); 2208 appendVariableToMessage(message, args.inB); 2209 message.append("\n"); 2210 message.append("Expected output out: "); 2211 appendVariableToMessage(message, args.out); 2212 message.append("\n"); 2213 message.append("Actual output out: "); 2214 appendVariableToMessage(message, arrayOut[i * 1 + j]); 2215 if (args.out != arrayOut[i * 1 + j]) { 2216 message.append(" FAIL"); 2217 } 2218 message.append("\n"); 2219 message.append("Errors at"); 2220 } 2221 message.append(" ["); 2222 message.append(Integer.toString(i)); 2223 message.append(", "); 2224 message.append(Integer.toString(j)); 2225 message.append("]"); 2226 } 2227 } 2228 } 2229 assertFalse("Incorrect output for checkMinUshortUshortUshort" + 2230 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2231 } 2232 checkMinUshort2Ushort2Ushort2()2233 private void checkMinUshort2Ushort2Ushort2() { 2234 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x878f4ca3l, false); 2235 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x878f4ca4l, false); 2236 try { 2237 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 2238 script.set_gAllocInB(inB); 2239 script.forEach_testMinUshort2Ushort2Ushort2(inA, out); 2240 verifyResultsMinUshort2Ushort2Ushort2(inA, inB, out, false); 2241 } catch (Exception e) { 2242 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString()); 2243 } 2244 try { 2245 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 2246 scriptRelaxed.set_gAllocInB(inB); 2247 scriptRelaxed.forEach_testMinUshort2Ushort2Ushort2(inA, out); 2248 verifyResultsMinUshort2Ushort2Ushort2(inA, inB, out, true); 2249 } catch (Exception e) { 2250 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString()); 2251 } 2252 } 2253 verifyResultsMinUshort2Ushort2Ushort2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2254 private void verifyResultsMinUshort2Ushort2Ushort2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2255 short[] arrayInA = new short[INPUTSIZE * 2]; 2256 Arrays.fill(arrayInA, (short) 42); 2257 inA.copyTo(arrayInA); 2258 short[] arrayInB = new short[INPUTSIZE * 2]; 2259 Arrays.fill(arrayInB, (short) 42); 2260 inB.copyTo(arrayInB); 2261 short[] arrayOut = new short[INPUTSIZE * 2]; 2262 Arrays.fill(arrayOut, (short) 42); 2263 out.copyTo(arrayOut); 2264 StringBuilder message = new StringBuilder(); 2265 boolean errorFound = false; 2266 for (int i = 0; i < INPUTSIZE; i++) { 2267 for (int j = 0; j < 2 ; j++) { 2268 // Extract the inputs. 2269 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 2270 args.inA = arrayInA[i * 2 + j]; 2271 args.inB = arrayInB[i * 2 + j]; 2272 // Figure out what the outputs should have been. 2273 CoreMathVerifier.computeMin(args); 2274 // Validate the outputs. 2275 boolean valid = true; 2276 if (args.out != arrayOut[i * 2 + j]) { 2277 valid = false; 2278 } 2279 if (!valid) { 2280 if (!errorFound) { 2281 errorFound = true; 2282 message.append("Input inA: "); 2283 appendVariableToMessage(message, args.inA); 2284 message.append("\n"); 2285 message.append("Input inB: "); 2286 appendVariableToMessage(message, args.inB); 2287 message.append("\n"); 2288 message.append("Expected output out: "); 2289 appendVariableToMessage(message, args.out); 2290 message.append("\n"); 2291 message.append("Actual output out: "); 2292 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2293 if (args.out != arrayOut[i * 2 + j]) { 2294 message.append(" FAIL"); 2295 } 2296 message.append("\n"); 2297 message.append("Errors at"); 2298 } 2299 message.append(" ["); 2300 message.append(Integer.toString(i)); 2301 message.append(", "); 2302 message.append(Integer.toString(j)); 2303 message.append("]"); 2304 } 2305 } 2306 } 2307 assertFalse("Incorrect output for checkMinUshort2Ushort2Ushort2" + 2308 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2309 } 2310 checkMinUshort3Ushort3Ushort3()2311 private void checkMinUshort3Ushort3Ushort3() { 2312 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd0743e3al, false); 2313 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd0743e3bl, false); 2314 try { 2315 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 2316 script.set_gAllocInB(inB); 2317 script.forEach_testMinUshort3Ushort3Ushort3(inA, out); 2318 verifyResultsMinUshort3Ushort3Ushort3(inA, inB, out, false); 2319 } catch (Exception e) { 2320 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString()); 2321 } 2322 try { 2323 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 2324 scriptRelaxed.set_gAllocInB(inB); 2325 scriptRelaxed.forEach_testMinUshort3Ushort3Ushort3(inA, out); 2326 verifyResultsMinUshort3Ushort3Ushort3(inA, inB, out, true); 2327 } catch (Exception e) { 2328 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString()); 2329 } 2330 } 2331 verifyResultsMinUshort3Ushort3Ushort3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2332 private void verifyResultsMinUshort3Ushort3Ushort3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2333 short[] arrayInA = new short[INPUTSIZE * 4]; 2334 Arrays.fill(arrayInA, (short) 42); 2335 inA.copyTo(arrayInA); 2336 short[] arrayInB = new short[INPUTSIZE * 4]; 2337 Arrays.fill(arrayInB, (short) 42); 2338 inB.copyTo(arrayInB); 2339 short[] arrayOut = new short[INPUTSIZE * 4]; 2340 Arrays.fill(arrayOut, (short) 42); 2341 out.copyTo(arrayOut); 2342 StringBuilder message = new StringBuilder(); 2343 boolean errorFound = false; 2344 for (int i = 0; i < INPUTSIZE; i++) { 2345 for (int j = 0; j < 3 ; j++) { 2346 // Extract the inputs. 2347 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 2348 args.inA = arrayInA[i * 4 + j]; 2349 args.inB = arrayInB[i * 4 + j]; 2350 // Figure out what the outputs should have been. 2351 CoreMathVerifier.computeMin(args); 2352 // Validate the outputs. 2353 boolean valid = true; 2354 if (args.out != arrayOut[i * 4 + j]) { 2355 valid = false; 2356 } 2357 if (!valid) { 2358 if (!errorFound) { 2359 errorFound = true; 2360 message.append("Input inA: "); 2361 appendVariableToMessage(message, args.inA); 2362 message.append("\n"); 2363 message.append("Input inB: "); 2364 appendVariableToMessage(message, args.inB); 2365 message.append("\n"); 2366 message.append("Expected output out: "); 2367 appendVariableToMessage(message, args.out); 2368 message.append("\n"); 2369 message.append("Actual output out: "); 2370 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2371 if (args.out != arrayOut[i * 4 + j]) { 2372 message.append(" FAIL"); 2373 } 2374 message.append("\n"); 2375 message.append("Errors at"); 2376 } 2377 message.append(" ["); 2378 message.append(Integer.toString(i)); 2379 message.append(", "); 2380 message.append(Integer.toString(j)); 2381 message.append("]"); 2382 } 2383 } 2384 } 2385 assertFalse("Incorrect output for checkMinUshort3Ushort3Ushort3" + 2386 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2387 } 2388 checkMinUshort4Ushort4Ushort4()2389 private void checkMinUshort4Ushort4Ushort4() { 2390 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19592fd1l, false); 2391 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19592fd2l, false); 2392 try { 2393 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 2394 script.set_gAllocInB(inB); 2395 script.forEach_testMinUshort4Ushort4Ushort4(inA, out); 2396 verifyResultsMinUshort4Ushort4Ushort4(inA, inB, out, false); 2397 } catch (Exception e) { 2398 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString()); 2399 } 2400 try { 2401 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 2402 scriptRelaxed.set_gAllocInB(inB); 2403 scriptRelaxed.forEach_testMinUshort4Ushort4Ushort4(inA, out); 2404 verifyResultsMinUshort4Ushort4Ushort4(inA, inB, out, true); 2405 } catch (Exception e) { 2406 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString()); 2407 } 2408 } 2409 verifyResultsMinUshort4Ushort4Ushort4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2410 private void verifyResultsMinUshort4Ushort4Ushort4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2411 short[] arrayInA = new short[INPUTSIZE * 4]; 2412 Arrays.fill(arrayInA, (short) 42); 2413 inA.copyTo(arrayInA); 2414 short[] arrayInB = new short[INPUTSIZE * 4]; 2415 Arrays.fill(arrayInB, (short) 42); 2416 inB.copyTo(arrayInB); 2417 short[] arrayOut = new short[INPUTSIZE * 4]; 2418 Arrays.fill(arrayOut, (short) 42); 2419 out.copyTo(arrayOut); 2420 StringBuilder message = new StringBuilder(); 2421 boolean errorFound = false; 2422 for (int i = 0; i < INPUTSIZE; i++) { 2423 for (int j = 0; j < 4 ; j++) { 2424 // Extract the inputs. 2425 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 2426 args.inA = arrayInA[i * 4 + j]; 2427 args.inB = arrayInB[i * 4 + j]; 2428 // Figure out what the outputs should have been. 2429 CoreMathVerifier.computeMin(args); 2430 // Validate the outputs. 2431 boolean valid = true; 2432 if (args.out != arrayOut[i * 4 + j]) { 2433 valid = false; 2434 } 2435 if (!valid) { 2436 if (!errorFound) { 2437 errorFound = true; 2438 message.append("Input inA: "); 2439 appendVariableToMessage(message, args.inA); 2440 message.append("\n"); 2441 message.append("Input inB: "); 2442 appendVariableToMessage(message, args.inB); 2443 message.append("\n"); 2444 message.append("Expected output out: "); 2445 appendVariableToMessage(message, args.out); 2446 message.append("\n"); 2447 message.append("Actual output out: "); 2448 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2449 if (args.out != arrayOut[i * 4 + j]) { 2450 message.append(" FAIL"); 2451 } 2452 message.append("\n"); 2453 message.append("Errors at"); 2454 } 2455 message.append(" ["); 2456 message.append(Integer.toString(i)); 2457 message.append(", "); 2458 message.append(Integer.toString(j)); 2459 message.append("]"); 2460 } 2461 } 2462 } 2463 assertFalse("Incorrect output for checkMinUshort4Ushort4Ushort4" + 2464 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2465 } 2466 2467 public class ArgumentsIntIntInt { 2468 public int inA; 2469 public int inB; 2470 public int out; 2471 } 2472 checkMinIntIntInt()2473 private void checkMinIntIntInt() { 2474 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe703dfd7l, false); 2475 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe703dfd8l, false); 2476 try { 2477 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE); 2478 script.set_gAllocInB(inB); 2479 script.forEach_testMinIntIntInt(inA, out); 2480 verifyResultsMinIntIntInt(inA, inB, out, false); 2481 } catch (Exception e) { 2482 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString()); 2483 } 2484 try { 2485 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE); 2486 scriptRelaxed.set_gAllocInB(inB); 2487 scriptRelaxed.forEach_testMinIntIntInt(inA, out); 2488 verifyResultsMinIntIntInt(inA, inB, out, true); 2489 } catch (Exception e) { 2490 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString()); 2491 } 2492 } 2493 verifyResultsMinIntIntInt(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2494 private void verifyResultsMinIntIntInt(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2495 int[] arrayInA = new int[INPUTSIZE * 1]; 2496 Arrays.fill(arrayInA, (int) 42); 2497 inA.copyTo(arrayInA); 2498 int[] arrayInB = new int[INPUTSIZE * 1]; 2499 Arrays.fill(arrayInB, (int) 42); 2500 inB.copyTo(arrayInB); 2501 int[] arrayOut = new int[INPUTSIZE * 1]; 2502 Arrays.fill(arrayOut, (int) 42); 2503 out.copyTo(arrayOut); 2504 StringBuilder message = new StringBuilder(); 2505 boolean errorFound = false; 2506 for (int i = 0; i < INPUTSIZE; i++) { 2507 for (int j = 0; j < 1 ; j++) { 2508 // Extract the inputs. 2509 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 2510 args.inA = arrayInA[i]; 2511 args.inB = arrayInB[i]; 2512 // Figure out what the outputs should have been. 2513 CoreMathVerifier.computeMin(args); 2514 // Validate the outputs. 2515 boolean valid = true; 2516 if (args.out != arrayOut[i * 1 + j]) { 2517 valid = false; 2518 } 2519 if (!valid) { 2520 if (!errorFound) { 2521 errorFound = true; 2522 message.append("Input inA: "); 2523 appendVariableToMessage(message, args.inA); 2524 message.append("\n"); 2525 message.append("Input inB: "); 2526 appendVariableToMessage(message, args.inB); 2527 message.append("\n"); 2528 message.append("Expected output out: "); 2529 appendVariableToMessage(message, args.out); 2530 message.append("\n"); 2531 message.append("Actual output out: "); 2532 appendVariableToMessage(message, arrayOut[i * 1 + j]); 2533 if (args.out != arrayOut[i * 1 + j]) { 2534 message.append(" FAIL"); 2535 } 2536 message.append("\n"); 2537 message.append("Errors at"); 2538 } 2539 message.append(" ["); 2540 message.append(Integer.toString(i)); 2541 message.append(", "); 2542 message.append(Integer.toString(j)); 2543 message.append("]"); 2544 } 2545 } 2546 } 2547 assertFalse("Incorrect output for checkMinIntIntInt" + 2548 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2549 } 2550 checkMinInt2Int2Int2()2551 private void checkMinInt2Int2Int2() { 2552 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x13df0b41l, false); 2553 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x13df0b42l, false); 2554 try { 2555 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 2556 script.set_gAllocInB(inB); 2557 script.forEach_testMinInt2Int2Int2(inA, out); 2558 verifyResultsMinInt2Int2Int2(inA, inB, out, false); 2559 } catch (Exception e) { 2560 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString()); 2561 } 2562 try { 2563 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 2564 scriptRelaxed.set_gAllocInB(inB); 2565 scriptRelaxed.forEach_testMinInt2Int2Int2(inA, out); 2566 verifyResultsMinInt2Int2Int2(inA, inB, out, true); 2567 } catch (Exception e) { 2568 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString()); 2569 } 2570 } 2571 verifyResultsMinInt2Int2Int2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2572 private void verifyResultsMinInt2Int2Int2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2573 int[] arrayInA = new int[INPUTSIZE * 2]; 2574 Arrays.fill(arrayInA, (int) 42); 2575 inA.copyTo(arrayInA); 2576 int[] arrayInB = new int[INPUTSIZE * 2]; 2577 Arrays.fill(arrayInB, (int) 42); 2578 inB.copyTo(arrayInB); 2579 int[] arrayOut = new int[INPUTSIZE * 2]; 2580 Arrays.fill(arrayOut, (int) 42); 2581 out.copyTo(arrayOut); 2582 StringBuilder message = new StringBuilder(); 2583 boolean errorFound = false; 2584 for (int i = 0; i < INPUTSIZE; i++) { 2585 for (int j = 0; j < 2 ; j++) { 2586 // Extract the inputs. 2587 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 2588 args.inA = arrayInA[i * 2 + j]; 2589 args.inB = arrayInB[i * 2 + j]; 2590 // Figure out what the outputs should have been. 2591 CoreMathVerifier.computeMin(args); 2592 // Validate the outputs. 2593 boolean valid = true; 2594 if (args.out != arrayOut[i * 2 + j]) { 2595 valid = false; 2596 } 2597 if (!valid) { 2598 if (!errorFound) { 2599 errorFound = true; 2600 message.append("Input inA: "); 2601 appendVariableToMessage(message, args.inA); 2602 message.append("\n"); 2603 message.append("Input inB: "); 2604 appendVariableToMessage(message, args.inB); 2605 message.append("\n"); 2606 message.append("Expected output out: "); 2607 appendVariableToMessage(message, args.out); 2608 message.append("\n"); 2609 message.append("Actual output out: "); 2610 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2611 if (args.out != arrayOut[i * 2 + j]) { 2612 message.append(" FAIL"); 2613 } 2614 message.append("\n"); 2615 message.append("Errors at"); 2616 } 2617 message.append(" ["); 2618 message.append(Integer.toString(i)); 2619 message.append(", "); 2620 message.append(Integer.toString(j)); 2621 message.append("]"); 2622 } 2623 } 2624 } 2625 assertFalse("Incorrect output for checkMinInt2Int2Int2" + 2626 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2627 } 2628 checkMinInt3Int3Int3()2629 private void checkMinInt3Int3Int3() { 2630 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdeb4532al, false); 2631 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdeb4532bl, false); 2632 try { 2633 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 2634 script.set_gAllocInB(inB); 2635 script.forEach_testMinInt3Int3Int3(inA, out); 2636 verifyResultsMinInt3Int3Int3(inA, inB, out, false); 2637 } catch (Exception e) { 2638 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString()); 2639 } 2640 try { 2641 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 2642 scriptRelaxed.set_gAllocInB(inB); 2643 scriptRelaxed.forEach_testMinInt3Int3Int3(inA, out); 2644 verifyResultsMinInt3Int3Int3(inA, inB, out, true); 2645 } catch (Exception e) { 2646 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString()); 2647 } 2648 } 2649 verifyResultsMinInt3Int3Int3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2650 private void verifyResultsMinInt3Int3Int3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2651 int[] arrayInA = new int[INPUTSIZE * 4]; 2652 Arrays.fill(arrayInA, (int) 42); 2653 inA.copyTo(arrayInA); 2654 int[] arrayInB = new int[INPUTSIZE * 4]; 2655 Arrays.fill(arrayInB, (int) 42); 2656 inB.copyTo(arrayInB); 2657 int[] arrayOut = new int[INPUTSIZE * 4]; 2658 Arrays.fill(arrayOut, (int) 42); 2659 out.copyTo(arrayOut); 2660 StringBuilder message = new StringBuilder(); 2661 boolean errorFound = false; 2662 for (int i = 0; i < INPUTSIZE; i++) { 2663 for (int j = 0; j < 3 ; j++) { 2664 // Extract the inputs. 2665 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 2666 args.inA = arrayInA[i * 4 + j]; 2667 args.inB = arrayInB[i * 4 + j]; 2668 // Figure out what the outputs should have been. 2669 CoreMathVerifier.computeMin(args); 2670 // Validate the outputs. 2671 boolean valid = true; 2672 if (args.out != arrayOut[i * 4 + j]) { 2673 valid = false; 2674 } 2675 if (!valid) { 2676 if (!errorFound) { 2677 errorFound = true; 2678 message.append("Input inA: "); 2679 appendVariableToMessage(message, args.inA); 2680 message.append("\n"); 2681 message.append("Input inB: "); 2682 appendVariableToMessage(message, args.inB); 2683 message.append("\n"); 2684 message.append("Expected output out: "); 2685 appendVariableToMessage(message, args.out); 2686 message.append("\n"); 2687 message.append("Actual output out: "); 2688 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2689 if (args.out != arrayOut[i * 4 + j]) { 2690 message.append(" FAIL"); 2691 } 2692 message.append("\n"); 2693 message.append("Errors at"); 2694 } 2695 message.append(" ["); 2696 message.append(Integer.toString(i)); 2697 message.append(", "); 2698 message.append(Integer.toString(j)); 2699 message.append("]"); 2700 } 2701 } 2702 } 2703 assertFalse("Incorrect output for checkMinInt3Int3Int3" + 2704 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2705 } 2706 checkMinInt4Int4Int4()2707 private void checkMinInt4Int4Int4() { 2708 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa9899b13l, false); 2709 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa9899b14l, false); 2710 try { 2711 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 2712 script.set_gAllocInB(inB); 2713 script.forEach_testMinInt4Int4Int4(inA, out); 2714 verifyResultsMinInt4Int4Int4(inA, inB, out, false); 2715 } catch (Exception e) { 2716 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString()); 2717 } 2718 try { 2719 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 2720 scriptRelaxed.set_gAllocInB(inB); 2721 scriptRelaxed.forEach_testMinInt4Int4Int4(inA, out); 2722 verifyResultsMinInt4Int4Int4(inA, inB, out, true); 2723 } catch (Exception e) { 2724 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString()); 2725 } 2726 } 2727 verifyResultsMinInt4Int4Int4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2728 private void verifyResultsMinInt4Int4Int4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2729 int[] arrayInA = new int[INPUTSIZE * 4]; 2730 Arrays.fill(arrayInA, (int) 42); 2731 inA.copyTo(arrayInA); 2732 int[] arrayInB = new int[INPUTSIZE * 4]; 2733 Arrays.fill(arrayInB, (int) 42); 2734 inB.copyTo(arrayInB); 2735 int[] arrayOut = new int[INPUTSIZE * 4]; 2736 Arrays.fill(arrayOut, (int) 42); 2737 out.copyTo(arrayOut); 2738 StringBuilder message = new StringBuilder(); 2739 boolean errorFound = false; 2740 for (int i = 0; i < INPUTSIZE; i++) { 2741 for (int j = 0; j < 4 ; j++) { 2742 // Extract the inputs. 2743 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 2744 args.inA = arrayInA[i * 4 + j]; 2745 args.inB = arrayInB[i * 4 + j]; 2746 // Figure out what the outputs should have been. 2747 CoreMathVerifier.computeMin(args); 2748 // Validate the outputs. 2749 boolean valid = true; 2750 if (args.out != arrayOut[i * 4 + j]) { 2751 valid = false; 2752 } 2753 if (!valid) { 2754 if (!errorFound) { 2755 errorFound = true; 2756 message.append("Input inA: "); 2757 appendVariableToMessage(message, args.inA); 2758 message.append("\n"); 2759 message.append("Input inB: "); 2760 appendVariableToMessage(message, args.inB); 2761 message.append("\n"); 2762 message.append("Expected output out: "); 2763 appendVariableToMessage(message, args.out); 2764 message.append("\n"); 2765 message.append("Actual output out: "); 2766 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2767 if (args.out != arrayOut[i * 4 + j]) { 2768 message.append(" FAIL"); 2769 } 2770 message.append("\n"); 2771 message.append("Errors at"); 2772 } 2773 message.append(" ["); 2774 message.append(Integer.toString(i)); 2775 message.append(", "); 2776 message.append(Integer.toString(j)); 2777 message.append("]"); 2778 } 2779 } 2780 } 2781 assertFalse("Incorrect output for checkMinInt4Int4Int4" + 2782 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2783 } 2784 2785 public class ArgumentsUintUintUint { 2786 public int inA; 2787 public int inB; 2788 public int out; 2789 } 2790 checkMinUintUintUint()2791 private void checkMinUintUintUint() { 2792 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xde387ca0l, false); 2793 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xde387ca1l, false); 2794 try { 2795 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE); 2796 script.set_gAllocInB(inB); 2797 script.forEach_testMinUintUintUint(inA, out); 2798 verifyResultsMinUintUintUint(inA, inB, out, false); 2799 } catch (Exception e) { 2800 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString()); 2801 } 2802 try { 2803 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE); 2804 scriptRelaxed.set_gAllocInB(inB); 2805 scriptRelaxed.forEach_testMinUintUintUint(inA, out); 2806 verifyResultsMinUintUintUint(inA, inB, out, true); 2807 } catch (Exception e) { 2808 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString()); 2809 } 2810 } 2811 verifyResultsMinUintUintUint(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2812 private void verifyResultsMinUintUintUint(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2813 int[] arrayInA = new int[INPUTSIZE * 1]; 2814 Arrays.fill(arrayInA, (int) 42); 2815 inA.copyTo(arrayInA); 2816 int[] arrayInB = new int[INPUTSIZE * 1]; 2817 Arrays.fill(arrayInB, (int) 42); 2818 inB.copyTo(arrayInB); 2819 int[] arrayOut = new int[INPUTSIZE * 1]; 2820 Arrays.fill(arrayOut, (int) 42); 2821 out.copyTo(arrayOut); 2822 StringBuilder message = new StringBuilder(); 2823 boolean errorFound = false; 2824 for (int i = 0; i < INPUTSIZE; i++) { 2825 for (int j = 0; j < 1 ; j++) { 2826 // Extract the inputs. 2827 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 2828 args.inA = arrayInA[i]; 2829 args.inB = arrayInB[i]; 2830 // Figure out what the outputs should have been. 2831 CoreMathVerifier.computeMin(args); 2832 // Validate the outputs. 2833 boolean valid = true; 2834 if (args.out != arrayOut[i * 1 + j]) { 2835 valid = false; 2836 } 2837 if (!valid) { 2838 if (!errorFound) { 2839 errorFound = true; 2840 message.append("Input inA: "); 2841 appendVariableToMessage(message, args.inA); 2842 message.append("\n"); 2843 message.append("Input inB: "); 2844 appendVariableToMessage(message, args.inB); 2845 message.append("\n"); 2846 message.append("Expected output out: "); 2847 appendVariableToMessage(message, args.out); 2848 message.append("\n"); 2849 message.append("Actual output out: "); 2850 appendVariableToMessage(message, arrayOut[i * 1 + j]); 2851 if (args.out != arrayOut[i * 1 + j]) { 2852 message.append(" FAIL"); 2853 } 2854 message.append("\n"); 2855 message.append("Errors at"); 2856 } 2857 message.append(" ["); 2858 message.append(Integer.toString(i)); 2859 message.append(", "); 2860 message.append(Integer.toString(j)); 2861 message.append("]"); 2862 } 2863 } 2864 } 2865 assertFalse("Incorrect output for checkMinUintUintUint" + 2866 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2867 } 2868 checkMinUint2Uint2Uint2()2869 private void checkMinUint2Uint2Uint2() { 2870 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd9009a2l, false); 2871 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd9009a3l, false); 2872 try { 2873 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 2874 script.set_gAllocInB(inB); 2875 script.forEach_testMinUint2Uint2Uint2(inA, out); 2876 verifyResultsMinUint2Uint2Uint2(inA, inB, out, false); 2877 } catch (Exception e) { 2878 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString()); 2879 } 2880 try { 2881 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 2882 scriptRelaxed.set_gAllocInB(inB); 2883 scriptRelaxed.forEach_testMinUint2Uint2Uint2(inA, out); 2884 verifyResultsMinUint2Uint2Uint2(inA, inB, out, true); 2885 } catch (Exception e) { 2886 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString()); 2887 } 2888 } 2889 verifyResultsMinUint2Uint2Uint2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2890 private void verifyResultsMinUint2Uint2Uint2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2891 int[] arrayInA = new int[INPUTSIZE * 2]; 2892 Arrays.fill(arrayInA, (int) 42); 2893 inA.copyTo(arrayInA); 2894 int[] arrayInB = new int[INPUTSIZE * 2]; 2895 Arrays.fill(arrayInB, (int) 42); 2896 inB.copyTo(arrayInB); 2897 int[] arrayOut = new int[INPUTSIZE * 2]; 2898 Arrays.fill(arrayOut, (int) 42); 2899 out.copyTo(arrayOut); 2900 StringBuilder message = new StringBuilder(); 2901 boolean errorFound = false; 2902 for (int i = 0; i < INPUTSIZE; i++) { 2903 for (int j = 0; j < 2 ; j++) { 2904 // Extract the inputs. 2905 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 2906 args.inA = arrayInA[i * 2 + j]; 2907 args.inB = arrayInB[i * 2 + j]; 2908 // Figure out what the outputs should have been. 2909 CoreMathVerifier.computeMin(args); 2910 // Validate the outputs. 2911 boolean valid = true; 2912 if (args.out != arrayOut[i * 2 + j]) { 2913 valid = false; 2914 } 2915 if (!valid) { 2916 if (!errorFound) { 2917 errorFound = true; 2918 message.append("Input inA: "); 2919 appendVariableToMessage(message, args.inA); 2920 message.append("\n"); 2921 message.append("Input inB: "); 2922 appendVariableToMessage(message, args.inB); 2923 message.append("\n"); 2924 message.append("Expected output out: "); 2925 appendVariableToMessage(message, args.out); 2926 message.append("\n"); 2927 message.append("Actual output out: "); 2928 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2929 if (args.out != arrayOut[i * 2 + j]) { 2930 message.append(" FAIL"); 2931 } 2932 message.append("\n"); 2933 message.append("Errors at"); 2934 } 2935 message.append(" ["); 2936 message.append(Integer.toString(i)); 2937 message.append(", "); 2938 message.append(Integer.toString(j)); 2939 message.append("]"); 2940 } 2941 } 2942 } 2943 assertFalse("Incorrect output for checkMinUint2Uint2Uint2" + 2944 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2945 } 2946 checkMinUint3Uint3Uint3()2947 private void checkMinUint3Uint3Uint3() { 2948 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1c2f1a71l, false); 2949 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1c2f1a72l, false); 2950 try { 2951 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 2952 script.set_gAllocInB(inB); 2953 script.forEach_testMinUint3Uint3Uint3(inA, out); 2954 verifyResultsMinUint3Uint3Uint3(inA, inB, out, false); 2955 } catch (Exception e) { 2956 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString()); 2957 } 2958 try { 2959 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 2960 scriptRelaxed.set_gAllocInB(inB); 2961 scriptRelaxed.forEach_testMinUint3Uint3Uint3(inA, out); 2962 verifyResultsMinUint3Uint3Uint3(inA, inB, out, true); 2963 } catch (Exception e) { 2964 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString()); 2965 } 2966 } 2967 verifyResultsMinUint3Uint3Uint3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)2968 private void verifyResultsMinUint3Uint3Uint3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 2969 int[] arrayInA = new int[INPUTSIZE * 4]; 2970 Arrays.fill(arrayInA, (int) 42); 2971 inA.copyTo(arrayInA); 2972 int[] arrayInB = new int[INPUTSIZE * 4]; 2973 Arrays.fill(arrayInB, (int) 42); 2974 inB.copyTo(arrayInB); 2975 int[] arrayOut = new int[INPUTSIZE * 4]; 2976 Arrays.fill(arrayOut, (int) 42); 2977 out.copyTo(arrayOut); 2978 StringBuilder message = new StringBuilder(); 2979 boolean errorFound = false; 2980 for (int i = 0; i < INPUTSIZE; i++) { 2981 for (int j = 0; j < 3 ; j++) { 2982 // Extract the inputs. 2983 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 2984 args.inA = arrayInA[i * 4 + j]; 2985 args.inB = arrayInB[i * 4 + j]; 2986 // Figure out what the outputs should have been. 2987 CoreMathVerifier.computeMin(args); 2988 // Validate the outputs. 2989 boolean valid = true; 2990 if (args.out != arrayOut[i * 4 + j]) { 2991 valid = false; 2992 } 2993 if (!valid) { 2994 if (!errorFound) { 2995 errorFound = true; 2996 message.append("Input inA: "); 2997 appendVariableToMessage(message, args.inA); 2998 message.append("\n"); 2999 message.append("Input inB: "); 3000 appendVariableToMessage(message, args.inB); 3001 message.append("\n"); 3002 message.append("Expected output out: "); 3003 appendVariableToMessage(message, args.out); 3004 message.append("\n"); 3005 message.append("Actual output out: "); 3006 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3007 if (args.out != arrayOut[i * 4 + j]) { 3008 message.append(" FAIL"); 3009 } 3010 message.append("\n"); 3011 message.append("Errors at"); 3012 } 3013 message.append(" ["); 3014 message.append(Integer.toString(i)); 3015 message.append(", "); 3016 message.append(Integer.toString(j)); 3017 message.append("]"); 3018 } 3019 } 3020 } 3021 assertFalse("Incorrect output for checkMinUint3Uint3Uint3" + 3022 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3023 } 3024 checkMinUint4Uint4Uint4()3025 private void checkMinUint4Uint4Uint4() { 3026 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x7ace2b40l, false); 3027 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x7ace2b41l, false); 3028 try { 3029 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 3030 script.set_gAllocInB(inB); 3031 script.forEach_testMinUint4Uint4Uint4(inA, out); 3032 verifyResultsMinUint4Uint4Uint4(inA, inB, out, false); 3033 } catch (Exception e) { 3034 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString()); 3035 } 3036 try { 3037 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 3038 scriptRelaxed.set_gAllocInB(inB); 3039 scriptRelaxed.forEach_testMinUint4Uint4Uint4(inA, out); 3040 verifyResultsMinUint4Uint4Uint4(inA, inB, out, true); 3041 } catch (Exception e) { 3042 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString()); 3043 } 3044 } 3045 verifyResultsMinUint4Uint4Uint4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3046 private void verifyResultsMinUint4Uint4Uint4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3047 int[] arrayInA = new int[INPUTSIZE * 4]; 3048 Arrays.fill(arrayInA, (int) 42); 3049 inA.copyTo(arrayInA); 3050 int[] arrayInB = new int[INPUTSIZE * 4]; 3051 Arrays.fill(arrayInB, (int) 42); 3052 inB.copyTo(arrayInB); 3053 int[] arrayOut = new int[INPUTSIZE * 4]; 3054 Arrays.fill(arrayOut, (int) 42); 3055 out.copyTo(arrayOut); 3056 StringBuilder message = new StringBuilder(); 3057 boolean errorFound = false; 3058 for (int i = 0; i < INPUTSIZE; i++) { 3059 for (int j = 0; j < 4 ; j++) { 3060 // Extract the inputs. 3061 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 3062 args.inA = arrayInA[i * 4 + j]; 3063 args.inB = arrayInB[i * 4 + j]; 3064 // Figure out what the outputs should have been. 3065 CoreMathVerifier.computeMin(args); 3066 // Validate the outputs. 3067 boolean valid = true; 3068 if (args.out != arrayOut[i * 4 + j]) { 3069 valid = false; 3070 } 3071 if (!valid) { 3072 if (!errorFound) { 3073 errorFound = true; 3074 message.append("Input inA: "); 3075 appendVariableToMessage(message, args.inA); 3076 message.append("\n"); 3077 message.append("Input inB: "); 3078 appendVariableToMessage(message, args.inB); 3079 message.append("\n"); 3080 message.append("Expected output out: "); 3081 appendVariableToMessage(message, args.out); 3082 message.append("\n"); 3083 message.append("Actual output out: "); 3084 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3085 if (args.out != arrayOut[i * 4 + j]) { 3086 message.append(" FAIL"); 3087 } 3088 message.append("\n"); 3089 message.append("Errors at"); 3090 } 3091 message.append(" ["); 3092 message.append(Integer.toString(i)); 3093 message.append(", "); 3094 message.append(Integer.toString(j)); 3095 message.append("]"); 3096 } 3097 } 3098 } 3099 assertFalse("Incorrect output for checkMinUint4Uint4Uint4" + 3100 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3101 } 3102 3103 public class ArgumentsLongLongLong { 3104 public long inA; 3105 public long inB; 3106 public long out; 3107 } 3108 checkMinLongLongLong()3109 private void checkMinLongLongLong() { 3110 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xde2e29eel, false); 3111 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xde2e29efl, false); 3112 try { 3113 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE); 3114 script.set_gAllocInB(inB); 3115 script.forEach_testMinLongLongLong(inA, out); 3116 verifyResultsMinLongLongLong(inA, inB, out, false); 3117 } catch (Exception e) { 3118 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString()); 3119 } 3120 try { 3121 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE); 3122 scriptRelaxed.set_gAllocInB(inB); 3123 scriptRelaxed.forEach_testMinLongLongLong(inA, out); 3124 verifyResultsMinLongLongLong(inA, inB, out, true); 3125 } catch (Exception e) { 3126 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString()); 3127 } 3128 } 3129 verifyResultsMinLongLongLong(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3130 private void verifyResultsMinLongLongLong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3131 long[] arrayInA = new long[INPUTSIZE * 1]; 3132 Arrays.fill(arrayInA, (long) 42); 3133 inA.copyTo(arrayInA); 3134 long[] arrayInB = new long[INPUTSIZE * 1]; 3135 Arrays.fill(arrayInB, (long) 42); 3136 inB.copyTo(arrayInB); 3137 long[] arrayOut = new long[INPUTSIZE * 1]; 3138 Arrays.fill(arrayOut, (long) 42); 3139 out.copyTo(arrayOut); 3140 StringBuilder message = new StringBuilder(); 3141 boolean errorFound = false; 3142 for (int i = 0; i < INPUTSIZE; i++) { 3143 for (int j = 0; j < 1 ; j++) { 3144 // Extract the inputs. 3145 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 3146 args.inA = arrayInA[i]; 3147 args.inB = arrayInB[i]; 3148 // Figure out what the outputs should have been. 3149 CoreMathVerifier.computeMin(args); 3150 // Validate the outputs. 3151 boolean valid = true; 3152 if (args.out != arrayOut[i * 1 + j]) { 3153 valid = false; 3154 } 3155 if (!valid) { 3156 if (!errorFound) { 3157 errorFound = true; 3158 message.append("Input inA: "); 3159 appendVariableToMessage(message, args.inA); 3160 message.append("\n"); 3161 message.append("Input inB: "); 3162 appendVariableToMessage(message, args.inB); 3163 message.append("\n"); 3164 message.append("Expected output out: "); 3165 appendVariableToMessage(message, args.out); 3166 message.append("\n"); 3167 message.append("Actual output out: "); 3168 appendVariableToMessage(message, arrayOut[i * 1 + j]); 3169 if (args.out != arrayOut[i * 1 + j]) { 3170 message.append(" FAIL"); 3171 } 3172 message.append("\n"); 3173 message.append("Errors at"); 3174 } 3175 message.append(" ["); 3176 message.append(Integer.toString(i)); 3177 message.append(", "); 3178 message.append(Integer.toString(j)); 3179 message.append("]"); 3180 } 3181 } 3182 } 3183 assertFalse("Incorrect output for checkMinLongLongLong" + 3184 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3185 } 3186 checkMinLong2Long2Long2()3187 private void checkMinLong2Long2Long2() { 3188 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7154fcb8l, false); 3189 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7154fcb9l, false); 3190 try { 3191 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 3192 script.set_gAllocInB(inB); 3193 script.forEach_testMinLong2Long2Long2(inA, out); 3194 verifyResultsMinLong2Long2Long2(inA, inB, out, false); 3195 } catch (Exception e) { 3196 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString()); 3197 } 3198 try { 3199 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 3200 scriptRelaxed.set_gAllocInB(inB); 3201 scriptRelaxed.forEach_testMinLong2Long2Long2(inA, out); 3202 verifyResultsMinLong2Long2Long2(inA, inB, out, true); 3203 } catch (Exception e) { 3204 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString()); 3205 } 3206 } 3207 verifyResultsMinLong2Long2Long2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3208 private void verifyResultsMinLong2Long2Long2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3209 long[] arrayInA = new long[INPUTSIZE * 2]; 3210 Arrays.fill(arrayInA, (long) 42); 3211 inA.copyTo(arrayInA); 3212 long[] arrayInB = new long[INPUTSIZE * 2]; 3213 Arrays.fill(arrayInB, (long) 42); 3214 inB.copyTo(arrayInB); 3215 long[] arrayOut = new long[INPUTSIZE * 2]; 3216 Arrays.fill(arrayOut, (long) 42); 3217 out.copyTo(arrayOut); 3218 StringBuilder message = new StringBuilder(); 3219 boolean errorFound = false; 3220 for (int i = 0; i < INPUTSIZE; i++) { 3221 for (int j = 0; j < 2 ; j++) { 3222 // Extract the inputs. 3223 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 3224 args.inA = arrayInA[i * 2 + j]; 3225 args.inB = arrayInB[i * 2 + j]; 3226 // Figure out what the outputs should have been. 3227 CoreMathVerifier.computeMin(args); 3228 // Validate the outputs. 3229 boolean valid = true; 3230 if (args.out != arrayOut[i * 2 + j]) { 3231 valid = false; 3232 } 3233 if (!valid) { 3234 if (!errorFound) { 3235 errorFound = true; 3236 message.append("Input inA: "); 3237 appendVariableToMessage(message, args.inA); 3238 message.append("\n"); 3239 message.append("Input inB: "); 3240 appendVariableToMessage(message, args.inB); 3241 message.append("\n"); 3242 message.append("Expected output out: "); 3243 appendVariableToMessage(message, args.out); 3244 message.append("\n"); 3245 message.append("Actual output out: "); 3246 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3247 if (args.out != arrayOut[i * 2 + j]) { 3248 message.append(" FAIL"); 3249 } 3250 message.append("\n"); 3251 message.append("Errors at"); 3252 } 3253 message.append(" ["); 3254 message.append(Integer.toString(i)); 3255 message.append(", "); 3256 message.append(Integer.toString(j)); 3257 message.append("]"); 3258 } 3259 } 3260 } 3261 assertFalse("Incorrect output for checkMinLong2Long2Long2" + 3262 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3263 } 3264 checkMinLong3Long3Long3()3265 private void checkMinLong3Long3Long3() { 3266 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcff40d87l, false); 3267 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcff40d88l, false); 3268 try { 3269 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 3270 script.set_gAllocInB(inB); 3271 script.forEach_testMinLong3Long3Long3(inA, out); 3272 verifyResultsMinLong3Long3Long3(inA, inB, out, false); 3273 } catch (Exception e) { 3274 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString()); 3275 } 3276 try { 3277 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 3278 scriptRelaxed.set_gAllocInB(inB); 3279 scriptRelaxed.forEach_testMinLong3Long3Long3(inA, out); 3280 verifyResultsMinLong3Long3Long3(inA, inB, out, true); 3281 } catch (Exception e) { 3282 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString()); 3283 } 3284 } 3285 verifyResultsMinLong3Long3Long3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3286 private void verifyResultsMinLong3Long3Long3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3287 long[] arrayInA = new long[INPUTSIZE * 4]; 3288 Arrays.fill(arrayInA, (long) 42); 3289 inA.copyTo(arrayInA); 3290 long[] arrayInB = new long[INPUTSIZE * 4]; 3291 Arrays.fill(arrayInB, (long) 42); 3292 inB.copyTo(arrayInB); 3293 long[] arrayOut = new long[INPUTSIZE * 4]; 3294 Arrays.fill(arrayOut, (long) 42); 3295 out.copyTo(arrayOut); 3296 StringBuilder message = new StringBuilder(); 3297 boolean errorFound = false; 3298 for (int i = 0; i < INPUTSIZE; i++) { 3299 for (int j = 0; j < 3 ; j++) { 3300 // Extract the inputs. 3301 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 3302 args.inA = arrayInA[i * 4 + j]; 3303 args.inB = arrayInB[i * 4 + j]; 3304 // Figure out what the outputs should have been. 3305 CoreMathVerifier.computeMin(args); 3306 // Validate the outputs. 3307 boolean valid = true; 3308 if (args.out != arrayOut[i * 4 + j]) { 3309 valid = false; 3310 } 3311 if (!valid) { 3312 if (!errorFound) { 3313 errorFound = true; 3314 message.append("Input inA: "); 3315 appendVariableToMessage(message, args.inA); 3316 message.append("\n"); 3317 message.append("Input inB: "); 3318 appendVariableToMessage(message, args.inB); 3319 message.append("\n"); 3320 message.append("Expected output out: "); 3321 appendVariableToMessage(message, args.out); 3322 message.append("\n"); 3323 message.append("Actual output out: "); 3324 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3325 if (args.out != arrayOut[i * 4 + j]) { 3326 message.append(" FAIL"); 3327 } 3328 message.append("\n"); 3329 message.append("Errors at"); 3330 } 3331 message.append(" ["); 3332 message.append(Integer.toString(i)); 3333 message.append(", "); 3334 message.append(Integer.toString(j)); 3335 message.append("]"); 3336 } 3337 } 3338 } 3339 assertFalse("Incorrect output for checkMinLong3Long3Long3" + 3340 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3341 } 3342 checkMinLong4Long4Long4()3343 private void checkMinLong4Long4Long4() { 3344 Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x2e931e56l, false); 3345 Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x2e931e57l, false); 3346 try { 3347 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 3348 script.set_gAllocInB(inB); 3349 script.forEach_testMinLong4Long4Long4(inA, out); 3350 verifyResultsMinLong4Long4Long4(inA, inB, out, false); 3351 } catch (Exception e) { 3352 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString()); 3353 } 3354 try { 3355 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 3356 scriptRelaxed.set_gAllocInB(inB); 3357 scriptRelaxed.forEach_testMinLong4Long4Long4(inA, out); 3358 verifyResultsMinLong4Long4Long4(inA, inB, out, true); 3359 } catch (Exception e) { 3360 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString()); 3361 } 3362 } 3363 verifyResultsMinLong4Long4Long4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3364 private void verifyResultsMinLong4Long4Long4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3365 long[] arrayInA = new long[INPUTSIZE * 4]; 3366 Arrays.fill(arrayInA, (long) 42); 3367 inA.copyTo(arrayInA); 3368 long[] arrayInB = new long[INPUTSIZE * 4]; 3369 Arrays.fill(arrayInB, (long) 42); 3370 inB.copyTo(arrayInB); 3371 long[] arrayOut = new long[INPUTSIZE * 4]; 3372 Arrays.fill(arrayOut, (long) 42); 3373 out.copyTo(arrayOut); 3374 StringBuilder message = new StringBuilder(); 3375 boolean errorFound = false; 3376 for (int i = 0; i < INPUTSIZE; i++) { 3377 for (int j = 0; j < 4 ; j++) { 3378 // Extract the inputs. 3379 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 3380 args.inA = arrayInA[i * 4 + j]; 3381 args.inB = arrayInB[i * 4 + j]; 3382 // Figure out what the outputs should have been. 3383 CoreMathVerifier.computeMin(args); 3384 // Validate the outputs. 3385 boolean valid = true; 3386 if (args.out != arrayOut[i * 4 + j]) { 3387 valid = false; 3388 } 3389 if (!valid) { 3390 if (!errorFound) { 3391 errorFound = true; 3392 message.append("Input inA: "); 3393 appendVariableToMessage(message, args.inA); 3394 message.append("\n"); 3395 message.append("Input inB: "); 3396 appendVariableToMessage(message, args.inB); 3397 message.append("\n"); 3398 message.append("Expected output out: "); 3399 appendVariableToMessage(message, args.out); 3400 message.append("\n"); 3401 message.append("Actual output out: "); 3402 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3403 if (args.out != arrayOut[i * 4 + j]) { 3404 message.append(" FAIL"); 3405 } 3406 message.append("\n"); 3407 message.append("Errors at"); 3408 } 3409 message.append(" ["); 3410 message.append(Integer.toString(i)); 3411 message.append(", "); 3412 message.append(Integer.toString(j)); 3413 message.append("]"); 3414 } 3415 } 3416 } 3417 assertFalse("Incorrect output for checkMinLong4Long4Long4" + 3418 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3419 } 3420 3421 public class ArgumentsUlongUlongUlong { 3422 public long inA; 3423 public long inB; 3424 public long out; 3425 } 3426 checkMinUlongUlongUlong()3427 private void checkMinUlongUlongUlong() { 3428 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x3e23ed8dl, false); 3429 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x3e23ed8el, false); 3430 try { 3431 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE); 3432 script.set_gAllocInB(inB); 3433 script.forEach_testMinUlongUlongUlong(inA, out); 3434 verifyResultsMinUlongUlongUlong(inA, inB, out, false); 3435 } catch (Exception e) { 3436 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString()); 3437 } 3438 try { 3439 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE); 3440 scriptRelaxed.set_gAllocInB(inB); 3441 scriptRelaxed.forEach_testMinUlongUlongUlong(inA, out); 3442 verifyResultsMinUlongUlongUlong(inA, inB, out, true); 3443 } catch (Exception e) { 3444 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString()); 3445 } 3446 } 3447 verifyResultsMinUlongUlongUlong(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3448 private void verifyResultsMinUlongUlongUlong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3449 long[] arrayInA = new long[INPUTSIZE * 1]; 3450 Arrays.fill(arrayInA, (long) 42); 3451 inA.copyTo(arrayInA); 3452 long[] arrayInB = new long[INPUTSIZE * 1]; 3453 Arrays.fill(arrayInB, (long) 42); 3454 inB.copyTo(arrayInB); 3455 long[] arrayOut = new long[INPUTSIZE * 1]; 3456 Arrays.fill(arrayOut, (long) 42); 3457 out.copyTo(arrayOut); 3458 StringBuilder message = new StringBuilder(); 3459 boolean errorFound = false; 3460 for (int i = 0; i < INPUTSIZE; i++) { 3461 for (int j = 0; j < 1 ; j++) { 3462 // Extract the inputs. 3463 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 3464 args.inA = arrayInA[i]; 3465 args.inB = arrayInB[i]; 3466 // Figure out what the outputs should have been. 3467 CoreMathVerifier.computeMin(args); 3468 // Validate the outputs. 3469 boolean valid = true; 3470 if (args.out != arrayOut[i * 1 + j]) { 3471 valid = false; 3472 } 3473 if (!valid) { 3474 if (!errorFound) { 3475 errorFound = true; 3476 message.append("Input inA: "); 3477 appendVariableToMessage(message, args.inA); 3478 message.append("\n"); 3479 message.append("Input inB: "); 3480 appendVariableToMessage(message, args.inB); 3481 message.append("\n"); 3482 message.append("Expected output out: "); 3483 appendVariableToMessage(message, args.out); 3484 message.append("\n"); 3485 message.append("Actual output out: "); 3486 appendVariableToMessage(message, arrayOut[i * 1 + j]); 3487 if (args.out != arrayOut[i * 1 + j]) { 3488 message.append(" FAIL"); 3489 } 3490 message.append("\n"); 3491 message.append("Errors at"); 3492 } 3493 message.append(" ["); 3494 message.append(Integer.toString(i)); 3495 message.append(", "); 3496 message.append(Integer.toString(j)); 3497 message.append("]"); 3498 } 3499 } 3500 } 3501 assertFalse("Incorrect output for checkMinUlongUlongUlong" + 3502 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3503 } 3504 checkMinUlong2Ulong2Ulong2()3505 private void checkMinUlong2Ulong2Ulong2() { 3506 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6c4dc5dfl, false); 3507 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6c4dc5e0l, false); 3508 try { 3509 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 3510 script.set_gAllocInB(inB); 3511 script.forEach_testMinUlong2Ulong2Ulong2(inA, out); 3512 verifyResultsMinUlong2Ulong2Ulong2(inA, inB, out, false); 3513 } catch (Exception e) { 3514 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString()); 3515 } 3516 try { 3517 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 3518 scriptRelaxed.set_gAllocInB(inB); 3519 scriptRelaxed.forEach_testMinUlong2Ulong2Ulong2(inA, out); 3520 verifyResultsMinUlong2Ulong2Ulong2(inA, inB, out, true); 3521 } catch (Exception e) { 3522 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString()); 3523 } 3524 } 3525 verifyResultsMinUlong2Ulong2Ulong2(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3526 private void verifyResultsMinUlong2Ulong2Ulong2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3527 long[] arrayInA = new long[INPUTSIZE * 2]; 3528 Arrays.fill(arrayInA, (long) 42); 3529 inA.copyTo(arrayInA); 3530 long[] arrayInB = new long[INPUTSIZE * 2]; 3531 Arrays.fill(arrayInB, (long) 42); 3532 inB.copyTo(arrayInB); 3533 long[] arrayOut = new long[INPUTSIZE * 2]; 3534 Arrays.fill(arrayOut, (long) 42); 3535 out.copyTo(arrayOut); 3536 StringBuilder message = new StringBuilder(); 3537 boolean errorFound = false; 3538 for (int i = 0; i < INPUTSIZE; i++) { 3539 for (int j = 0; j < 2 ; j++) { 3540 // Extract the inputs. 3541 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 3542 args.inA = arrayInA[i * 2 + j]; 3543 args.inB = arrayInB[i * 2 + j]; 3544 // Figure out what the outputs should have been. 3545 CoreMathVerifier.computeMin(args); 3546 // Validate the outputs. 3547 boolean valid = true; 3548 if (args.out != arrayOut[i * 2 + j]) { 3549 valid = false; 3550 } 3551 if (!valid) { 3552 if (!errorFound) { 3553 errorFound = true; 3554 message.append("Input inA: "); 3555 appendVariableToMessage(message, args.inA); 3556 message.append("\n"); 3557 message.append("Input inB: "); 3558 appendVariableToMessage(message, args.inB); 3559 message.append("\n"); 3560 message.append("Expected output out: "); 3561 appendVariableToMessage(message, args.out); 3562 message.append("\n"); 3563 message.append("Actual output out: "); 3564 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3565 if (args.out != arrayOut[i * 2 + j]) { 3566 message.append(" FAIL"); 3567 } 3568 message.append("\n"); 3569 message.append("Errors at"); 3570 } 3571 message.append(" ["); 3572 message.append(Integer.toString(i)); 3573 message.append(", "); 3574 message.append(Integer.toString(j)); 3575 message.append("]"); 3576 } 3577 } 3578 } 3579 assertFalse("Incorrect output for checkMinUlong2Ulong2Ulong2" + 3580 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3581 } 3582 checkMinUlong3Ulong3Ulong3()3583 private void checkMinUlong3Ulong3Ulong3() { 3584 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6e2bc780l, false); 3585 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6e2bc781l, false); 3586 try { 3587 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 3588 script.set_gAllocInB(inB); 3589 script.forEach_testMinUlong3Ulong3Ulong3(inA, out); 3590 verifyResultsMinUlong3Ulong3Ulong3(inA, inB, out, false); 3591 } catch (Exception e) { 3592 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString()); 3593 } 3594 try { 3595 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 3596 scriptRelaxed.set_gAllocInB(inB); 3597 scriptRelaxed.forEach_testMinUlong3Ulong3Ulong3(inA, out); 3598 verifyResultsMinUlong3Ulong3Ulong3(inA, inB, out, true); 3599 } catch (Exception e) { 3600 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString()); 3601 } 3602 } 3603 verifyResultsMinUlong3Ulong3Ulong3(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3604 private void verifyResultsMinUlong3Ulong3Ulong3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3605 long[] arrayInA = new long[INPUTSIZE * 4]; 3606 Arrays.fill(arrayInA, (long) 42); 3607 inA.copyTo(arrayInA); 3608 long[] arrayInB = new long[INPUTSIZE * 4]; 3609 Arrays.fill(arrayInB, (long) 42); 3610 inB.copyTo(arrayInB); 3611 long[] arrayOut = new long[INPUTSIZE * 4]; 3612 Arrays.fill(arrayOut, (long) 42); 3613 out.copyTo(arrayOut); 3614 StringBuilder message = new StringBuilder(); 3615 boolean errorFound = false; 3616 for (int i = 0; i < INPUTSIZE; i++) { 3617 for (int j = 0; j < 3 ; j++) { 3618 // Extract the inputs. 3619 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 3620 args.inA = arrayInA[i * 4 + j]; 3621 args.inB = arrayInB[i * 4 + j]; 3622 // Figure out what the outputs should have been. 3623 CoreMathVerifier.computeMin(args); 3624 // Validate the outputs. 3625 boolean valid = true; 3626 if (args.out != arrayOut[i * 4 + j]) { 3627 valid = false; 3628 } 3629 if (!valid) { 3630 if (!errorFound) { 3631 errorFound = true; 3632 message.append("Input inA: "); 3633 appendVariableToMessage(message, args.inA); 3634 message.append("\n"); 3635 message.append("Input inB: "); 3636 appendVariableToMessage(message, args.inB); 3637 message.append("\n"); 3638 message.append("Expected output out: "); 3639 appendVariableToMessage(message, args.out); 3640 message.append("\n"); 3641 message.append("Actual output out: "); 3642 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3643 if (args.out != arrayOut[i * 4 + j]) { 3644 message.append(" FAIL"); 3645 } 3646 message.append("\n"); 3647 message.append("Errors at"); 3648 } 3649 message.append(" ["); 3650 message.append(Integer.toString(i)); 3651 message.append(", "); 3652 message.append(Integer.toString(j)); 3653 message.append("]"); 3654 } 3655 } 3656 } 3657 assertFalse("Incorrect output for checkMinUlong3Ulong3Ulong3" + 3658 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3659 } 3660 checkMinUlong4Ulong4Ulong4()3661 private void checkMinUlong4Ulong4Ulong4() { 3662 Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x7009c921l, false); 3663 Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x7009c922l, false); 3664 try { 3665 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 3666 script.set_gAllocInB(inB); 3667 script.forEach_testMinUlong4Ulong4Ulong4(inA, out); 3668 verifyResultsMinUlong4Ulong4Ulong4(inA, inB, out, false); 3669 } catch (Exception e) { 3670 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString()); 3671 } 3672 try { 3673 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 3674 scriptRelaxed.set_gAllocInB(inB); 3675 scriptRelaxed.forEach_testMinUlong4Ulong4Ulong4(inA, out); 3676 verifyResultsMinUlong4Ulong4Ulong4(inA, inB, out, true); 3677 } catch (Exception e) { 3678 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString()); 3679 } 3680 } 3681 verifyResultsMinUlong4Ulong4Ulong4(Allocation inA, Allocation inB, Allocation out, boolean relaxed)3682 private void verifyResultsMinUlong4Ulong4Ulong4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) { 3683 long[] arrayInA = new long[INPUTSIZE * 4]; 3684 Arrays.fill(arrayInA, (long) 42); 3685 inA.copyTo(arrayInA); 3686 long[] arrayInB = new long[INPUTSIZE * 4]; 3687 Arrays.fill(arrayInB, (long) 42); 3688 inB.copyTo(arrayInB); 3689 long[] arrayOut = new long[INPUTSIZE * 4]; 3690 Arrays.fill(arrayOut, (long) 42); 3691 out.copyTo(arrayOut); 3692 StringBuilder message = new StringBuilder(); 3693 boolean errorFound = false; 3694 for (int i = 0; i < INPUTSIZE; i++) { 3695 for (int j = 0; j < 4 ; j++) { 3696 // Extract the inputs. 3697 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 3698 args.inA = arrayInA[i * 4 + j]; 3699 args.inB = arrayInB[i * 4 + j]; 3700 // Figure out what the outputs should have been. 3701 CoreMathVerifier.computeMin(args); 3702 // Validate the outputs. 3703 boolean valid = true; 3704 if (args.out != arrayOut[i * 4 + j]) { 3705 valid = false; 3706 } 3707 if (!valid) { 3708 if (!errorFound) { 3709 errorFound = true; 3710 message.append("Input inA: "); 3711 appendVariableToMessage(message, args.inA); 3712 message.append("\n"); 3713 message.append("Input inB: "); 3714 appendVariableToMessage(message, args.inB); 3715 message.append("\n"); 3716 message.append("Expected output out: "); 3717 appendVariableToMessage(message, args.out); 3718 message.append("\n"); 3719 message.append("Actual output out: "); 3720 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3721 if (args.out != arrayOut[i * 4 + j]) { 3722 message.append(" FAIL"); 3723 } 3724 message.append("\n"); 3725 message.append("Errors at"); 3726 } 3727 message.append(" ["); 3728 message.append(Integer.toString(i)); 3729 message.append(", "); 3730 message.append(Integer.toString(j)); 3731 message.append("]"); 3732 } 3733 } 3734 } 3735 assertFalse("Incorrect output for checkMinUlong4Ulong4Ulong4" + 3736 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3737 } 3738 testMin()3739 public void testMin() { 3740 checkMinFloatFloatFloat(); 3741 checkMinFloat2Float2Float2(); 3742 checkMinFloat3Float3Float3(); 3743 checkMinFloat4Float4Float4(); 3744 checkMinHalfHalfHalf(); 3745 checkMinHalf2Half2Half2(); 3746 checkMinHalf3Half3Half3(); 3747 checkMinHalf4Half4Half4(); 3748 checkMinFloat2FloatFloat2(); 3749 checkMinFloat3FloatFloat3(); 3750 checkMinFloat4FloatFloat4(); 3751 checkMinHalf2HalfHalf2(); 3752 checkMinHalf3HalfHalf3(); 3753 checkMinHalf4HalfHalf4(); 3754 checkMinCharCharChar(); 3755 checkMinChar2Char2Char2(); 3756 checkMinChar3Char3Char3(); 3757 checkMinChar4Char4Char4(); 3758 checkMinUcharUcharUchar(); 3759 checkMinUchar2Uchar2Uchar2(); 3760 checkMinUchar3Uchar3Uchar3(); 3761 checkMinUchar4Uchar4Uchar4(); 3762 checkMinShortShortShort(); 3763 checkMinShort2Short2Short2(); 3764 checkMinShort3Short3Short3(); 3765 checkMinShort4Short4Short4(); 3766 checkMinUshortUshortUshort(); 3767 checkMinUshort2Ushort2Ushort2(); 3768 checkMinUshort3Ushort3Ushort3(); 3769 checkMinUshort4Ushort4Ushort4(); 3770 checkMinIntIntInt(); 3771 checkMinInt2Int2Int2(); 3772 checkMinInt3Int3Int3(); 3773 checkMinInt4Int4Int4(); 3774 checkMinUintUintUint(); 3775 checkMinUint2Uint2Uint2(); 3776 checkMinUint3Uint3Uint3(); 3777 checkMinUint4Uint4Uint4(); 3778 checkMinLongLongLong(); 3779 checkMinLong2Long2Long2(); 3780 checkMinLong3Long3Long3(); 3781 checkMinLong4Long4Long4(); 3782 checkMinUlongUlongUlong(); 3783 checkMinUlong2Ulong2Ulong2(); 3784 checkMinUlong3Ulong3Ulong3(); 3785 checkMinUlong4Ulong4Ulong4(); 3786 } 3787 } 3788