1 /* 2 * Copyright (C) 2014 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/gen_runtime. 18 19 package android.renderscript.cts; 20 21 import android.renderscript.Allocation; 22 import android.renderscript.RSRuntimeException; 23 import android.renderscript.Element; 24 25 public class TestMin extends RSBaseCompute { 26 27 private ScriptC_TestMin script; 28 private ScriptC_TestMinRelaxed scriptRelaxed; 29 30 @Override 31 protected void setUp() throws Exception { 32 super.setUp(); 33 script = new ScriptC_TestMin(mRS); 34 scriptRelaxed = new ScriptC_TestMinRelaxed(mRS); 35 } 36 37 public class ArgumentsFloatFloatFloat { 38 public float in; 39 public float in1; 40 public Target.Floaty out; 41 } 42 43 private void checkMinFloatFloatFloat() { 44 Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x816f2fe273bf4977l, false); 45 Allocation in1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdad0b097121572el, false); 46 try { 47 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); 48 script.set_gAllocIn1(in1); 49 script.forEach_testMinFloatFloatFloat(in, out); 50 verifyResultsMinFloatFloatFloat(in, in1, out, false); 51 } catch (Exception e) { 52 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString()); 53 } 54 try { 55 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); 56 scriptRelaxed.set_gAllocIn1(in1); 57 scriptRelaxed.forEach_testMinFloatFloatFloat(in, out); 58 verifyResultsMinFloatFloatFloat(in, in1, out, true); 59 } catch (Exception e) { 60 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString()); 61 } 62 } 63 64 private void verifyResultsMinFloatFloatFloat(Allocation in, Allocation in1, Allocation out, boolean relaxed) { 65 float[] arrayIn = new float[INPUTSIZE * 1]; 66 in.copyTo(arrayIn); 67 float[] arrayIn1 = new float[INPUTSIZE * 1]; 68 in1.copyTo(arrayIn1); 69 float[] arrayOut = new float[INPUTSIZE * 1]; 70 out.copyTo(arrayOut); 71 for (int i = 0; i < INPUTSIZE; i++) { 72 for (int j = 0; j < 1 ; j++) { 73 // Extract the inputs. 74 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 75 args.in = arrayIn[i]; 76 args.in1 = arrayIn1[i]; 77 // Figure out what the outputs should have been. 78 Target target = new Target(relaxed); 79 CoreMathVerifier.computeMin(args, target); 80 // Validate the outputs. 81 boolean valid = true; 82 if (!args.out.couldBe(arrayOut[i * 1 + j])) { 83 valid = false; 84 } 85 if (!valid) { 86 StringBuilder message = new StringBuilder(); 87 message.append("Input in: "); 88 message.append(String.format("%14.8g {%8x} %15a", 89 args.in, Float.floatToRawIntBits(args.in), args.in)); 90 message.append("\n"); 91 message.append("Input in1: "); 92 message.append(String.format("%14.8g {%8x} %15a", 93 args.in1, Float.floatToRawIntBits(args.in1), args.in1)); 94 message.append("\n"); 95 message.append("Expected output out: "); 96 message.append(args.out.toString()); 97 message.append("\n"); 98 message.append("Actual output out: "); 99 message.append(String.format("%14.8g {%8x} %15a", 100 arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j])); 101 if (!args.out.couldBe(arrayOut[i * 1 + j])) { 102 message.append(" FAIL"); 103 } 104 message.append("\n"); 105 assertTrue("Incorrect output for checkMinFloatFloatFloat" + 106 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 107 } 108 } 109 } 110 } 111 112 private void checkMinFloat2Float2Float2() { 113 Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe354049301b6cfb9l, false); 114 Allocation in1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2f1cc4b149b4e444l, false); 115 try { 116 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 117 script.set_gAllocIn1(in1); 118 script.forEach_testMinFloat2Float2Float2(in, out); 119 verifyResultsMinFloat2Float2Float2(in, in1, out, false); 120 } catch (Exception e) { 121 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString()); 122 } 123 try { 124 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 125 scriptRelaxed.set_gAllocIn1(in1); 126 scriptRelaxed.forEach_testMinFloat2Float2Float2(in, out); 127 verifyResultsMinFloat2Float2Float2(in, in1, out, true); 128 } catch (Exception e) { 129 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString()); 130 } 131 } 132 133 private void verifyResultsMinFloat2Float2Float2(Allocation in, Allocation in1, Allocation out, boolean relaxed) { 134 float[] arrayIn = new float[INPUTSIZE * 2]; 135 in.copyTo(arrayIn); 136 float[] arrayIn1 = new float[INPUTSIZE * 2]; 137 in1.copyTo(arrayIn1); 138 float[] arrayOut = new float[INPUTSIZE * 2]; 139 out.copyTo(arrayOut); 140 for (int i = 0; i < INPUTSIZE; i++) { 141 for (int j = 0; j < 2 ; j++) { 142 // Extract the inputs. 143 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 144 args.in = arrayIn[i * 2 + j]; 145 args.in1 = arrayIn1[i * 2 + j]; 146 // Figure out what the outputs should have been. 147 Target target = new Target(relaxed); 148 CoreMathVerifier.computeMin(args, target); 149 // Validate the outputs. 150 boolean valid = true; 151 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 152 valid = false; 153 } 154 if (!valid) { 155 StringBuilder message = new StringBuilder(); 156 message.append("Input in: "); 157 message.append(String.format("%14.8g {%8x} %15a", 158 args.in, Float.floatToRawIntBits(args.in), args.in)); 159 message.append("\n"); 160 message.append("Input in1: "); 161 message.append(String.format("%14.8g {%8x} %15a", 162 args.in1, Float.floatToRawIntBits(args.in1), args.in1)); 163 message.append("\n"); 164 message.append("Expected output out: "); 165 message.append(args.out.toString()); 166 message.append("\n"); 167 message.append("Actual output out: "); 168 message.append(String.format("%14.8g {%8x} %15a", 169 arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j])); 170 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 171 message.append(" FAIL"); 172 } 173 message.append("\n"); 174 assertTrue("Incorrect output for checkMinFloat2Float2Float2" + 175 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 176 } 177 } 178 } 179 } 180 181 private void checkMinFloat3Float3Float3() { 182 Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x38a3c24c4f27231cl, false); 183 Allocation in1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8381a2d14b92e5e5l, false); 184 try { 185 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 186 script.set_gAllocIn1(in1); 187 script.forEach_testMinFloat3Float3Float3(in, out); 188 verifyResultsMinFloat3Float3Float3(in, in1, out, false); 189 } catch (Exception e) { 190 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString()); 191 } 192 try { 193 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 194 scriptRelaxed.set_gAllocIn1(in1); 195 scriptRelaxed.forEach_testMinFloat3Float3Float3(in, out); 196 verifyResultsMinFloat3Float3Float3(in, in1, out, true); 197 } catch (Exception e) { 198 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString()); 199 } 200 } 201 202 private void verifyResultsMinFloat3Float3Float3(Allocation in, Allocation in1, Allocation out, boolean relaxed) { 203 float[] arrayIn = new float[INPUTSIZE * 4]; 204 in.copyTo(arrayIn); 205 float[] arrayIn1 = new float[INPUTSIZE * 4]; 206 in1.copyTo(arrayIn1); 207 float[] arrayOut = new float[INPUTSIZE * 4]; 208 out.copyTo(arrayOut); 209 for (int i = 0; i < INPUTSIZE; i++) { 210 for (int j = 0; j < 3 ; j++) { 211 // Extract the inputs. 212 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 213 args.in = arrayIn[i * 4 + j]; 214 args.in1 = arrayIn1[i * 4 + j]; 215 // Figure out what the outputs should have been. 216 Target target = new Target(relaxed); 217 CoreMathVerifier.computeMin(args, target); 218 // Validate the outputs. 219 boolean valid = true; 220 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 221 valid = false; 222 } 223 if (!valid) { 224 StringBuilder message = new StringBuilder(); 225 message.append("Input in: "); 226 message.append(String.format("%14.8g {%8x} %15a", 227 args.in, Float.floatToRawIntBits(args.in), args.in)); 228 message.append("\n"); 229 message.append("Input in1: "); 230 message.append(String.format("%14.8g {%8x} %15a", 231 args.in1, Float.floatToRawIntBits(args.in1), args.in1)); 232 message.append("\n"); 233 message.append("Expected output out: "); 234 message.append(args.out.toString()); 235 message.append("\n"); 236 message.append("Actual output out: "); 237 message.append(String.format("%14.8g {%8x} %15a", 238 arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j])); 239 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 240 message.append(" FAIL"); 241 } 242 message.append("\n"); 243 assertTrue("Incorrect output for checkMinFloat3Float3Float3" + 244 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 245 } 246 } 247 } 248 } 249 250 private void checkMinFloat4Float4Float4() { 251 Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8df380059c97767fl, false); 252 Allocation in1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd7e680f14d70e786l, false); 253 try { 254 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 255 script.set_gAllocIn1(in1); 256 script.forEach_testMinFloat4Float4Float4(in, out); 257 verifyResultsMinFloat4Float4Float4(in, in1, out, false); 258 } catch (Exception e) { 259 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString()); 260 } 261 try { 262 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 263 scriptRelaxed.set_gAllocIn1(in1); 264 scriptRelaxed.forEach_testMinFloat4Float4Float4(in, out); 265 verifyResultsMinFloat4Float4Float4(in, in1, out, true); 266 } catch (Exception e) { 267 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString()); 268 } 269 } 270 271 private void verifyResultsMinFloat4Float4Float4(Allocation in, Allocation in1, Allocation out, boolean relaxed) { 272 float[] arrayIn = new float[INPUTSIZE * 4]; 273 in.copyTo(arrayIn); 274 float[] arrayIn1 = new float[INPUTSIZE * 4]; 275 in1.copyTo(arrayIn1); 276 float[] arrayOut = new float[INPUTSIZE * 4]; 277 out.copyTo(arrayOut); 278 for (int i = 0; i < INPUTSIZE; i++) { 279 for (int j = 0; j < 4 ; j++) { 280 // Extract the inputs. 281 ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat(); 282 args.in = arrayIn[i * 4 + j]; 283 args.in1 = arrayIn1[i * 4 + j]; 284 // Figure out what the outputs should have been. 285 Target target = new Target(relaxed); 286 CoreMathVerifier.computeMin(args, target); 287 // Validate the outputs. 288 boolean valid = true; 289 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 290 valid = false; 291 } 292 if (!valid) { 293 StringBuilder message = new StringBuilder(); 294 message.append("Input in: "); 295 message.append(String.format("%14.8g {%8x} %15a", 296 args.in, Float.floatToRawIntBits(args.in), args.in)); 297 message.append("\n"); 298 message.append("Input in1: "); 299 message.append(String.format("%14.8g {%8x} %15a", 300 args.in1, Float.floatToRawIntBits(args.in1), args.in1)); 301 message.append("\n"); 302 message.append("Expected output out: "); 303 message.append(args.out.toString()); 304 message.append("\n"); 305 message.append("Actual output out: "); 306 message.append(String.format("%14.8g {%8x} %15a", 307 arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j])); 308 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 309 message.append(" FAIL"); 310 } 311 message.append("\n"); 312 assertTrue("Incorrect output for checkMinFloat4Float4Float4" + 313 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 314 } 315 } 316 } 317 } 318 319 public class ArgumentsCharCharChar { 320 public byte inV1; 321 public byte inV2; 322 public byte out; 323 } 324 325 private void checkMinCharCharChar() { 326 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x47c90c486fc45b58l, false); 327 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x47c90c486fc45b59l, false); 328 try { 329 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE); 330 script.set_gAllocInV2(inV2); 331 script.forEach_testMinCharCharChar(inV1, out); 332 verifyResultsMinCharCharChar(inV1, inV2, out, false); 333 } catch (Exception e) { 334 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString()); 335 } 336 try { 337 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE); 338 scriptRelaxed.set_gAllocInV2(inV2); 339 scriptRelaxed.forEach_testMinCharCharChar(inV1, out); 340 verifyResultsMinCharCharChar(inV1, inV2, out, true); 341 } catch (Exception e) { 342 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString()); 343 } 344 } 345 346 private void verifyResultsMinCharCharChar(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 347 byte[] arrayInV1 = new byte[INPUTSIZE * 1]; 348 inV1.copyTo(arrayInV1); 349 byte[] arrayInV2 = new byte[INPUTSIZE * 1]; 350 inV2.copyTo(arrayInV2); 351 byte[] arrayOut = new byte[INPUTSIZE * 1]; 352 out.copyTo(arrayOut); 353 for (int i = 0; i < INPUTSIZE; i++) { 354 for (int j = 0; j < 1 ; j++) { 355 // Extract the inputs. 356 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 357 args.inV1 = arrayInV1[i]; 358 args.inV2 = arrayInV2[i]; 359 // Figure out what the outputs should have been. 360 CoreMathVerifier.computeMin(args); 361 // Validate the outputs. 362 boolean valid = true; 363 if (args.out != arrayOut[i * 1 + j]) { 364 valid = false; 365 } 366 if (!valid) { 367 StringBuilder message = new StringBuilder(); 368 message.append("Input inV1: "); 369 message.append(String.format("%d", args.inV1)); 370 message.append("\n"); 371 message.append("Input inV2: "); 372 message.append(String.format("%d", args.inV2)); 373 message.append("\n"); 374 message.append("Expected output out: "); 375 message.append(String.format("%d", args.out)); 376 message.append("\n"); 377 message.append("Actual output out: "); 378 message.append(String.format("%d", arrayOut[i * 1 + j])); 379 if (args.out != arrayOut[i * 1 + j]) { 380 message.append(" FAIL"); 381 } 382 message.append("\n"); 383 assertTrue("Incorrect output for checkMinCharCharChar" + 384 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 385 } 386 } 387 } 388 } 389 390 private void checkMinChar2Char2Char2() { 391 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xec4705afc03447ael, false); 392 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xec4705afc03447afl, false); 393 try { 394 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 395 script.set_gAllocInV2(inV2); 396 script.forEach_testMinChar2Char2Char2(inV1, out); 397 verifyResultsMinChar2Char2Char2(inV1, inV2, out, false); 398 } catch (Exception e) { 399 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString()); 400 } 401 try { 402 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 403 scriptRelaxed.set_gAllocInV2(inV2); 404 scriptRelaxed.forEach_testMinChar2Char2Char2(inV1, out); 405 verifyResultsMinChar2Char2Char2(inV1, inV2, out, true); 406 } catch (Exception e) { 407 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString()); 408 } 409 } 410 411 private void verifyResultsMinChar2Char2Char2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 412 byte[] arrayInV1 = new byte[INPUTSIZE * 2]; 413 inV1.copyTo(arrayInV1); 414 byte[] arrayInV2 = new byte[INPUTSIZE * 2]; 415 inV2.copyTo(arrayInV2); 416 byte[] arrayOut = new byte[INPUTSIZE * 2]; 417 out.copyTo(arrayOut); 418 for (int i = 0; i < INPUTSIZE; i++) { 419 for (int j = 0; j < 2 ; j++) { 420 // Extract the inputs. 421 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 422 args.inV1 = arrayInV1[i * 2 + j]; 423 args.inV2 = arrayInV2[i * 2 + j]; 424 // Figure out what the outputs should have been. 425 CoreMathVerifier.computeMin(args); 426 // Validate the outputs. 427 boolean valid = true; 428 if (args.out != arrayOut[i * 2 + j]) { 429 valid = false; 430 } 431 if (!valid) { 432 StringBuilder message = new StringBuilder(); 433 message.append("Input inV1: "); 434 message.append(String.format("%d", args.inV1)); 435 message.append("\n"); 436 message.append("Input inV2: "); 437 message.append(String.format("%d", args.inV2)); 438 message.append("\n"); 439 message.append("Expected output out: "); 440 message.append(String.format("%d", args.out)); 441 message.append("\n"); 442 message.append("Actual output out: "); 443 message.append(String.format("%d", arrayOut[i * 2 + j])); 444 if (args.out != arrayOut[i * 2 + j]) { 445 message.append(" FAIL"); 446 } 447 message.append("\n"); 448 assertTrue("Incorrect output for checkMinChar2Char2Char2" + 449 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 450 } 451 } 452 } 453 } 454 455 private void checkMinChar3Char3Char3() { 456 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x419881e2a4ec1a73l, false); 457 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x419881e2a4ec1a74l, false); 458 try { 459 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 460 script.set_gAllocInV2(inV2); 461 script.forEach_testMinChar3Char3Char3(inV1, out); 462 verifyResultsMinChar3Char3Char3(inV1, inV2, out, false); 463 } catch (Exception e) { 464 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString()); 465 } 466 try { 467 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 468 scriptRelaxed.set_gAllocInV2(inV2); 469 scriptRelaxed.forEach_testMinChar3Char3Char3(inV1, out); 470 verifyResultsMinChar3Char3Char3(inV1, inV2, out, true); 471 } catch (Exception e) { 472 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString()); 473 } 474 } 475 476 private void verifyResultsMinChar3Char3Char3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 477 byte[] arrayInV1 = new byte[INPUTSIZE * 4]; 478 inV1.copyTo(arrayInV1); 479 byte[] arrayInV2 = new byte[INPUTSIZE * 4]; 480 inV2.copyTo(arrayInV2); 481 byte[] arrayOut = new byte[INPUTSIZE * 4]; 482 out.copyTo(arrayOut); 483 for (int i = 0; i < INPUTSIZE; i++) { 484 for (int j = 0; j < 3 ; j++) { 485 // Extract the inputs. 486 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 487 args.inV1 = arrayInV1[i * 4 + j]; 488 args.inV2 = arrayInV2[i * 4 + j]; 489 // Figure out what the outputs should have been. 490 CoreMathVerifier.computeMin(args); 491 // Validate the outputs. 492 boolean valid = true; 493 if (args.out != arrayOut[i * 4 + j]) { 494 valid = false; 495 } 496 if (!valid) { 497 StringBuilder message = new StringBuilder(); 498 message.append("Input inV1: "); 499 message.append(String.format("%d", args.inV1)); 500 message.append("\n"); 501 message.append("Input inV2: "); 502 message.append(String.format("%d", args.inV2)); 503 message.append("\n"); 504 message.append("Expected output out: "); 505 message.append(String.format("%d", args.out)); 506 message.append("\n"); 507 message.append("Actual output out: "); 508 message.append(String.format("%d", arrayOut[i * 4 + j])); 509 if (args.out != arrayOut[i * 4 + j]) { 510 message.append(" FAIL"); 511 } 512 message.append("\n"); 513 assertTrue("Incorrect output for checkMinChar3Char3Char3" + 514 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 515 } 516 } 517 } 518 } 519 520 private void checkMinChar4Char4Char4() { 521 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x96e9fe1589a3ed38l, false); 522 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x96e9fe1589a3ed39l, false); 523 try { 524 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 525 script.set_gAllocInV2(inV2); 526 script.forEach_testMinChar4Char4Char4(inV1, out); 527 verifyResultsMinChar4Char4Char4(inV1, inV2, out, false); 528 } catch (Exception e) { 529 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString()); 530 } 531 try { 532 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 533 scriptRelaxed.set_gAllocInV2(inV2); 534 scriptRelaxed.forEach_testMinChar4Char4Char4(inV1, out); 535 verifyResultsMinChar4Char4Char4(inV1, inV2, out, true); 536 } catch (Exception e) { 537 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString()); 538 } 539 } 540 541 private void verifyResultsMinChar4Char4Char4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 542 byte[] arrayInV1 = new byte[INPUTSIZE * 4]; 543 inV1.copyTo(arrayInV1); 544 byte[] arrayInV2 = new byte[INPUTSIZE * 4]; 545 inV2.copyTo(arrayInV2); 546 byte[] arrayOut = new byte[INPUTSIZE * 4]; 547 out.copyTo(arrayOut); 548 for (int i = 0; i < INPUTSIZE; i++) { 549 for (int j = 0; j < 4 ; j++) { 550 // Extract the inputs. 551 ArgumentsCharCharChar args = new ArgumentsCharCharChar(); 552 args.inV1 = arrayInV1[i * 4 + j]; 553 args.inV2 = arrayInV2[i * 4 + j]; 554 // Figure out what the outputs should have been. 555 CoreMathVerifier.computeMin(args); 556 // Validate the outputs. 557 boolean valid = true; 558 if (args.out != arrayOut[i * 4 + j]) { 559 valid = false; 560 } 561 if (!valid) { 562 StringBuilder message = new StringBuilder(); 563 message.append("Input inV1: "); 564 message.append(String.format("%d", args.inV1)); 565 message.append("\n"); 566 message.append("Input inV2: "); 567 message.append(String.format("%d", args.inV2)); 568 message.append("\n"); 569 message.append("Expected output out: "); 570 message.append(String.format("%d", args.out)); 571 message.append("\n"); 572 message.append("Actual output out: "); 573 message.append(String.format("%d", arrayOut[i * 4 + j])); 574 if (args.out != arrayOut[i * 4 + j]) { 575 message.append(" FAIL"); 576 } 577 message.append("\n"); 578 assertTrue("Incorrect output for checkMinChar4Char4Char4" + 579 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 580 } 581 } 582 } 583 } 584 585 public class ArgumentsUcharUcharUchar { 586 public byte inV1; 587 public byte inV2; 588 public byte out; 589 } 590 591 private void checkMinUcharUcharUchar() { 592 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x6dc5402bc7a34891l, false); 593 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x6dc5402bc7a34892l, false); 594 try { 595 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE); 596 script.set_gAllocInV2(inV2); 597 script.forEach_testMinUcharUcharUchar(inV1, out); 598 verifyResultsMinUcharUcharUchar(inV1, inV2, out, false); 599 } catch (Exception e) { 600 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString()); 601 } 602 try { 603 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE); 604 scriptRelaxed.set_gAllocInV2(inV2); 605 scriptRelaxed.forEach_testMinUcharUcharUchar(inV1, out); 606 verifyResultsMinUcharUcharUchar(inV1, inV2, out, true); 607 } catch (Exception e) { 608 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString()); 609 } 610 } 611 612 private void verifyResultsMinUcharUcharUchar(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 613 byte[] arrayInV1 = new byte[INPUTSIZE * 1]; 614 inV1.copyTo(arrayInV1); 615 byte[] arrayInV2 = new byte[INPUTSIZE * 1]; 616 inV2.copyTo(arrayInV2); 617 byte[] arrayOut = new byte[INPUTSIZE * 1]; 618 out.copyTo(arrayOut); 619 for (int i = 0; i < INPUTSIZE; i++) { 620 for (int j = 0; j < 1 ; j++) { 621 // Extract the inputs. 622 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 623 args.inV1 = arrayInV1[i]; 624 args.inV2 = arrayInV2[i]; 625 // Figure out what the outputs should have been. 626 CoreMathVerifier.computeMin(args); 627 // Validate the outputs. 628 boolean valid = true; 629 if (args.out != arrayOut[i * 1 + j]) { 630 valid = false; 631 } 632 if (!valid) { 633 StringBuilder message = new StringBuilder(); 634 message.append("Input inV1: "); 635 message.append(String.format("0x%x", args.inV1)); 636 message.append("\n"); 637 message.append("Input inV2: "); 638 message.append(String.format("0x%x", args.inV2)); 639 message.append("\n"); 640 message.append("Expected output out: "); 641 message.append(String.format("0x%x", args.out)); 642 message.append("\n"); 643 message.append("Actual output out: "); 644 message.append(String.format("0x%x", arrayOut[i * 1 + j])); 645 if (args.out != arrayOut[i * 1 + j]) { 646 message.append(" FAIL"); 647 } 648 message.append("\n"); 649 assertTrue("Incorrect output for checkMinUcharUcharUchar" + 650 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 651 } 652 } 653 } 654 } 655 656 private void checkMinUchar2Uchar2Uchar2() { 657 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x1d3c921d166e22ffl, false); 658 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x1d3c921d166e2300l, false); 659 try { 660 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 661 script.set_gAllocInV2(inV2); 662 script.forEach_testMinUchar2Uchar2Uchar2(inV1, out); 663 verifyResultsMinUchar2Uchar2Uchar2(inV1, inV2, out, false); 664 } catch (Exception e) { 665 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString()); 666 } 667 try { 668 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 669 scriptRelaxed.set_gAllocInV2(inV2); 670 scriptRelaxed.forEach_testMinUchar2Uchar2Uchar2(inV1, out); 671 verifyResultsMinUchar2Uchar2Uchar2(inV1, inV2, out, true); 672 } catch (Exception e) { 673 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString()); 674 } 675 } 676 677 private void verifyResultsMinUchar2Uchar2Uchar2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 678 byte[] arrayInV1 = new byte[INPUTSIZE * 2]; 679 inV1.copyTo(arrayInV1); 680 byte[] arrayInV2 = new byte[INPUTSIZE * 2]; 681 inV2.copyTo(arrayInV2); 682 byte[] arrayOut = new byte[INPUTSIZE * 2]; 683 out.copyTo(arrayOut); 684 for (int i = 0; i < INPUTSIZE; i++) { 685 for (int j = 0; j < 2 ; j++) { 686 // Extract the inputs. 687 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 688 args.inV1 = arrayInV1[i * 2 + j]; 689 args.inV2 = arrayInV2[i * 2 + j]; 690 // Figure out what the outputs should have been. 691 CoreMathVerifier.computeMin(args); 692 // Validate the outputs. 693 boolean valid = true; 694 if (args.out != arrayOut[i * 2 + j]) { 695 valid = false; 696 } 697 if (!valid) { 698 StringBuilder message = new StringBuilder(); 699 message.append("Input inV1: "); 700 message.append(String.format("0x%x", args.inV1)); 701 message.append("\n"); 702 message.append("Input inV2: "); 703 message.append(String.format("0x%x", args.inV2)); 704 message.append("\n"); 705 message.append("Expected output out: "); 706 message.append(String.format("0x%x", args.out)); 707 message.append("\n"); 708 message.append("Actual output out: "); 709 message.append(String.format("0x%x", arrayOut[i * 2 + j])); 710 if (args.out != arrayOut[i * 2 + j]) { 711 message.append(" FAIL"); 712 } 713 message.append("\n"); 714 assertTrue("Incorrect output for checkMinUchar2Uchar2Uchar2" + 715 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 716 } 717 } 718 } 719 } 720 721 private void checkMinUchar3Uchar3Uchar3() { 722 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x4a2de17d66b8690al, false); 723 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x4a2de17d66b8690bl, false); 724 try { 725 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 726 script.set_gAllocInV2(inV2); 727 script.forEach_testMinUchar3Uchar3Uchar3(inV1, out); 728 verifyResultsMinUchar3Uchar3Uchar3(inV1, inV2, out, false); 729 } catch (Exception e) { 730 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString()); 731 } 732 try { 733 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 734 scriptRelaxed.set_gAllocInV2(inV2); 735 scriptRelaxed.forEach_testMinUchar3Uchar3Uchar3(inV1, out); 736 verifyResultsMinUchar3Uchar3Uchar3(inV1, inV2, out, true); 737 } catch (Exception e) { 738 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString()); 739 } 740 } 741 742 private void verifyResultsMinUchar3Uchar3Uchar3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 743 byte[] arrayInV1 = new byte[INPUTSIZE * 4]; 744 inV1.copyTo(arrayInV1); 745 byte[] arrayInV2 = new byte[INPUTSIZE * 4]; 746 inV2.copyTo(arrayInV2); 747 byte[] arrayOut = new byte[INPUTSIZE * 4]; 748 out.copyTo(arrayOut); 749 for (int i = 0; i < INPUTSIZE; i++) { 750 for (int j = 0; j < 3 ; j++) { 751 // Extract the inputs. 752 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 753 args.inV1 = arrayInV1[i * 4 + j]; 754 args.inV2 = arrayInV2[i * 4 + j]; 755 // Figure out what the outputs should have been. 756 CoreMathVerifier.computeMin(args); 757 // Validate the outputs. 758 boolean valid = true; 759 if (args.out != arrayOut[i * 4 + j]) { 760 valid = false; 761 } 762 if (!valid) { 763 StringBuilder message = new StringBuilder(); 764 message.append("Input inV1: "); 765 message.append(String.format("0x%x", args.inV1)); 766 message.append("\n"); 767 message.append("Input inV2: "); 768 message.append(String.format("0x%x", args.inV2)); 769 message.append("\n"); 770 message.append("Expected output out: "); 771 message.append(String.format("0x%x", args.out)); 772 message.append("\n"); 773 message.append("Actual output out: "); 774 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 775 if (args.out != arrayOut[i * 4 + j]) { 776 message.append(" FAIL"); 777 } 778 message.append("\n"); 779 assertTrue("Incorrect output for checkMinUchar3Uchar3Uchar3" + 780 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 781 } 782 } 783 } 784 } 785 786 private void checkMinUchar4Uchar4Uchar4() { 787 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x771f30ddb702af15l, false); 788 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x771f30ddb702af16l, false); 789 try { 790 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 791 script.set_gAllocInV2(inV2); 792 script.forEach_testMinUchar4Uchar4Uchar4(inV1, out); 793 verifyResultsMinUchar4Uchar4Uchar4(inV1, inV2, out, false); 794 } catch (Exception e) { 795 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString()); 796 } 797 try { 798 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 799 scriptRelaxed.set_gAllocInV2(inV2); 800 scriptRelaxed.forEach_testMinUchar4Uchar4Uchar4(inV1, out); 801 verifyResultsMinUchar4Uchar4Uchar4(inV1, inV2, out, true); 802 } catch (Exception e) { 803 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString()); 804 } 805 } 806 807 private void verifyResultsMinUchar4Uchar4Uchar4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 808 byte[] arrayInV1 = new byte[INPUTSIZE * 4]; 809 inV1.copyTo(arrayInV1); 810 byte[] arrayInV2 = new byte[INPUTSIZE * 4]; 811 inV2.copyTo(arrayInV2); 812 byte[] arrayOut = new byte[INPUTSIZE * 4]; 813 out.copyTo(arrayOut); 814 for (int i = 0; i < INPUTSIZE; i++) { 815 for (int j = 0; j < 4 ; j++) { 816 // Extract the inputs. 817 ArgumentsUcharUcharUchar args = new ArgumentsUcharUcharUchar(); 818 args.inV1 = arrayInV1[i * 4 + j]; 819 args.inV2 = arrayInV2[i * 4 + j]; 820 // Figure out what the outputs should have been. 821 CoreMathVerifier.computeMin(args); 822 // Validate the outputs. 823 boolean valid = true; 824 if (args.out != arrayOut[i * 4 + j]) { 825 valid = false; 826 } 827 if (!valid) { 828 StringBuilder message = new StringBuilder(); 829 message.append("Input inV1: "); 830 message.append(String.format("0x%x", args.inV1)); 831 message.append("\n"); 832 message.append("Input inV2: "); 833 message.append(String.format("0x%x", args.inV2)); 834 message.append("\n"); 835 message.append("Expected output out: "); 836 message.append(String.format("0x%x", args.out)); 837 message.append("\n"); 838 message.append("Actual output out: "); 839 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 840 if (args.out != arrayOut[i * 4 + j]) { 841 message.append(" FAIL"); 842 } 843 message.append("\n"); 844 assertTrue("Incorrect output for checkMinUchar4Uchar4Uchar4" + 845 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 846 } 847 } 848 } 849 } 850 851 public class ArgumentsShortShortShort { 852 public short inV1; 853 public short inV2; 854 public short out; 855 } 856 857 private void checkMinShortShortShort() { 858 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x71b08dd3c65bcddel, false); 859 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x71b08dd3c65bcddfl, false); 860 try { 861 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE); 862 script.set_gAllocInV2(inV2); 863 script.forEach_testMinShortShortShort(inV1, out); 864 verifyResultsMinShortShortShort(inV1, inV2, out, false); 865 } catch (Exception e) { 866 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString()); 867 } 868 try { 869 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE); 870 scriptRelaxed.set_gAllocInV2(inV2); 871 scriptRelaxed.forEach_testMinShortShortShort(inV1, out); 872 verifyResultsMinShortShortShort(inV1, inV2, out, true); 873 } catch (Exception e) { 874 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString()); 875 } 876 } 877 878 private void verifyResultsMinShortShortShort(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 879 short[] arrayInV1 = new short[INPUTSIZE * 1]; 880 inV1.copyTo(arrayInV1); 881 short[] arrayInV2 = new short[INPUTSIZE * 1]; 882 inV2.copyTo(arrayInV2); 883 short[] arrayOut = new short[INPUTSIZE * 1]; 884 out.copyTo(arrayOut); 885 for (int i = 0; i < INPUTSIZE; i++) { 886 for (int j = 0; j < 1 ; j++) { 887 // Extract the inputs. 888 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 889 args.inV1 = arrayInV1[i]; 890 args.inV2 = arrayInV2[i]; 891 // Figure out what the outputs should have been. 892 CoreMathVerifier.computeMin(args); 893 // Validate the outputs. 894 boolean valid = true; 895 if (args.out != arrayOut[i * 1 + j]) { 896 valid = false; 897 } 898 if (!valid) { 899 StringBuilder message = new StringBuilder(); 900 message.append("Input inV1: "); 901 message.append(String.format("%d", args.inV1)); 902 message.append("\n"); 903 message.append("Input inV2: "); 904 message.append(String.format("%d", args.inV2)); 905 message.append("\n"); 906 message.append("Expected output out: "); 907 message.append(String.format("%d", args.out)); 908 message.append("\n"); 909 message.append("Actual output out: "); 910 message.append(String.format("%d", arrayOut[i * 1 + j])); 911 if (args.out != arrayOut[i * 1 + j]) { 912 message.append(" FAIL"); 913 } 914 message.append("\n"); 915 assertTrue("Incorrect output for checkMinShortShortShort" + 916 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 917 } 918 } 919 } 920 } 921 922 private void checkMinShort2Short2Short2() { 923 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xe4959a1ecbf1d380l, false); 924 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xe4959a1ecbf1d381l, false); 925 try { 926 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 927 script.set_gAllocInV2(inV2); 928 script.forEach_testMinShort2Short2Short2(inV1, out); 929 verifyResultsMinShort2Short2Short2(inV1, inV2, out, false); 930 } catch (Exception e) { 931 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString()); 932 } 933 try { 934 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 935 scriptRelaxed.set_gAllocInV2(inV2); 936 scriptRelaxed.forEach_testMinShort2Short2Short2(inV1, out); 937 verifyResultsMinShort2Short2Short2(inV1, inV2, out, true); 938 } catch (Exception e) { 939 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString()); 940 } 941 } 942 943 private void verifyResultsMinShort2Short2Short2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 944 short[] arrayInV1 = new short[INPUTSIZE * 2]; 945 inV1.copyTo(arrayInV1); 946 short[] arrayInV2 = new short[INPUTSIZE * 2]; 947 inV2.copyTo(arrayInV2); 948 short[] arrayOut = new short[INPUTSIZE * 2]; 949 out.copyTo(arrayOut); 950 for (int i = 0; i < INPUTSIZE; i++) { 951 for (int j = 0; j < 2 ; j++) { 952 // Extract the inputs. 953 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 954 args.inV1 = arrayInV1[i * 2 + j]; 955 args.inV2 = arrayInV2[i * 2 + j]; 956 // Figure out what the outputs should have been. 957 CoreMathVerifier.computeMin(args); 958 // Validate the outputs. 959 boolean valid = true; 960 if (args.out != arrayOut[i * 2 + j]) { 961 valid = false; 962 } 963 if (!valid) { 964 StringBuilder message = new StringBuilder(); 965 message.append("Input inV1: "); 966 message.append(String.format("%d", args.inV1)); 967 message.append("\n"); 968 message.append("Input inV2: "); 969 message.append(String.format("%d", args.inV2)); 970 message.append("\n"); 971 message.append("Expected output out: "); 972 message.append(String.format("%d", args.out)); 973 message.append("\n"); 974 message.append("Actual output out: "); 975 message.append(String.format("%d", arrayOut[i * 2 + j])); 976 if (args.out != arrayOut[i * 2 + j]) { 977 message.append(" FAIL"); 978 } 979 message.append("\n"); 980 assertTrue("Incorrect output for checkMinShort2Short2Short2" + 981 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 982 } 983 } 984 } 985 } 986 987 private void checkMinShort3Short3Short3() { 988 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x1186e97f1c3c198bl, false); 989 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x1186e97f1c3c198cl, false); 990 try { 991 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 992 script.set_gAllocInV2(inV2); 993 script.forEach_testMinShort3Short3Short3(inV1, out); 994 verifyResultsMinShort3Short3Short3(inV1, inV2, out, false); 995 } catch (Exception e) { 996 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString()); 997 } 998 try { 999 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 1000 scriptRelaxed.set_gAllocInV2(inV2); 1001 scriptRelaxed.forEach_testMinShort3Short3Short3(inV1, out); 1002 verifyResultsMinShort3Short3Short3(inV1, inV2, out, true); 1003 } catch (Exception e) { 1004 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString()); 1005 } 1006 } 1007 1008 private void verifyResultsMinShort3Short3Short3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1009 short[] arrayInV1 = new short[INPUTSIZE * 4]; 1010 inV1.copyTo(arrayInV1); 1011 short[] arrayInV2 = new short[INPUTSIZE * 4]; 1012 inV2.copyTo(arrayInV2); 1013 short[] arrayOut = new short[INPUTSIZE * 4]; 1014 out.copyTo(arrayOut); 1015 for (int i = 0; i < INPUTSIZE; i++) { 1016 for (int j = 0; j < 3 ; j++) { 1017 // Extract the inputs. 1018 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 1019 args.inV1 = arrayInV1[i * 4 + j]; 1020 args.inV2 = arrayInV2[i * 4 + j]; 1021 // Figure out what the outputs should have been. 1022 CoreMathVerifier.computeMin(args); 1023 // Validate the outputs. 1024 boolean valid = true; 1025 if (args.out != arrayOut[i * 4 + j]) { 1026 valid = false; 1027 } 1028 if (!valid) { 1029 StringBuilder message = new StringBuilder(); 1030 message.append("Input inV1: "); 1031 message.append(String.format("%d", args.inV1)); 1032 message.append("\n"); 1033 message.append("Input inV2: "); 1034 message.append(String.format("%d", args.inV2)); 1035 message.append("\n"); 1036 message.append("Expected output out: "); 1037 message.append(String.format("%d", args.out)); 1038 message.append("\n"); 1039 message.append("Actual output out: "); 1040 message.append(String.format("%d", arrayOut[i * 4 + j])); 1041 if (args.out != arrayOut[i * 4 + j]) { 1042 message.append(" FAIL"); 1043 } 1044 message.append("\n"); 1045 assertTrue("Incorrect output for checkMinShort3Short3Short3" + 1046 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1047 } 1048 } 1049 } 1050 } 1051 1052 private void checkMinShort4Short4Short4() { 1053 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x3e7838df6c865f96l, false); 1054 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x3e7838df6c865f97l, false); 1055 try { 1056 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 1057 script.set_gAllocInV2(inV2); 1058 script.forEach_testMinShort4Short4Short4(inV1, out); 1059 verifyResultsMinShort4Short4Short4(inV1, inV2, out, false); 1060 } catch (Exception e) { 1061 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString()); 1062 } 1063 try { 1064 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 1065 scriptRelaxed.set_gAllocInV2(inV2); 1066 scriptRelaxed.forEach_testMinShort4Short4Short4(inV1, out); 1067 verifyResultsMinShort4Short4Short4(inV1, inV2, out, true); 1068 } catch (Exception e) { 1069 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString()); 1070 } 1071 } 1072 1073 private void verifyResultsMinShort4Short4Short4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1074 short[] arrayInV1 = new short[INPUTSIZE * 4]; 1075 inV1.copyTo(arrayInV1); 1076 short[] arrayInV2 = new short[INPUTSIZE * 4]; 1077 inV2.copyTo(arrayInV2); 1078 short[] arrayOut = new short[INPUTSIZE * 4]; 1079 out.copyTo(arrayOut); 1080 for (int i = 0; i < INPUTSIZE; i++) { 1081 for (int j = 0; j < 4 ; j++) { 1082 // Extract the inputs. 1083 ArgumentsShortShortShort args = new ArgumentsShortShortShort(); 1084 args.inV1 = arrayInV1[i * 4 + j]; 1085 args.inV2 = arrayInV2[i * 4 + j]; 1086 // Figure out what the outputs should have been. 1087 CoreMathVerifier.computeMin(args); 1088 // Validate the outputs. 1089 boolean valid = true; 1090 if (args.out != arrayOut[i * 4 + j]) { 1091 valid = false; 1092 } 1093 if (!valid) { 1094 StringBuilder message = new StringBuilder(); 1095 message.append("Input inV1: "); 1096 message.append(String.format("%d", args.inV1)); 1097 message.append("\n"); 1098 message.append("Input inV2: "); 1099 message.append(String.format("%d", args.inV2)); 1100 message.append("\n"); 1101 message.append("Expected output out: "); 1102 message.append(String.format("%d", args.out)); 1103 message.append("\n"); 1104 message.append("Actual output out: "); 1105 message.append(String.format("%d", arrayOut[i * 4 + j])); 1106 if (args.out != arrayOut[i * 4 + j]) { 1107 message.append(" FAIL"); 1108 } 1109 message.append("\n"); 1110 assertTrue("Incorrect output for checkMinShort4Short4Short4" + 1111 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1112 } 1113 } 1114 } 1115 } 1116 1117 public class ArgumentsUshortUshortUshort { 1118 public short inV1; 1119 public short inV2; 1120 public short out; 1121 } 1122 1123 private void checkMinUshortUshortUshort() { 1124 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xc2eb3387512e77cfl, false); 1125 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xc2eb3387512e77d0l, false); 1126 try { 1127 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE); 1128 script.set_gAllocInV2(inV2); 1129 script.forEach_testMinUshortUshortUshort(inV1, out); 1130 verifyResultsMinUshortUshortUshort(inV1, inV2, out, false); 1131 } catch (Exception e) { 1132 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString()); 1133 } 1134 try { 1135 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE); 1136 scriptRelaxed.set_gAllocInV2(inV2); 1137 scriptRelaxed.forEach_testMinUshortUshortUshort(inV1, out); 1138 verifyResultsMinUshortUshortUshort(inV1, inV2, out, true); 1139 } catch (Exception e) { 1140 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString()); 1141 } 1142 } 1143 1144 private void verifyResultsMinUshortUshortUshort(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1145 short[] arrayInV1 = new short[INPUTSIZE * 1]; 1146 inV1.copyTo(arrayInV1); 1147 short[] arrayInV2 = new short[INPUTSIZE * 1]; 1148 inV2.copyTo(arrayInV2); 1149 short[] arrayOut = new short[INPUTSIZE * 1]; 1150 out.copyTo(arrayOut); 1151 for (int i = 0; i < INPUTSIZE; i++) { 1152 for (int j = 0; j < 1 ; j++) { 1153 // Extract the inputs. 1154 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 1155 args.inV1 = arrayInV1[i]; 1156 args.inV2 = arrayInV2[i]; 1157 // Figure out what the outputs should have been. 1158 CoreMathVerifier.computeMin(args); 1159 // Validate the outputs. 1160 boolean valid = true; 1161 if (args.out != arrayOut[i * 1 + j]) { 1162 valid = false; 1163 } 1164 if (!valid) { 1165 StringBuilder message = new StringBuilder(); 1166 message.append("Input inV1: "); 1167 message.append(String.format("0x%x", args.inV1)); 1168 message.append("\n"); 1169 message.append("Input inV2: "); 1170 message.append(String.format("0x%x", args.inV2)); 1171 message.append("\n"); 1172 message.append("Expected output out: "); 1173 message.append(String.format("0x%x", args.out)); 1174 message.append("\n"); 1175 message.append("Actual output out: "); 1176 message.append(String.format("0x%x", arrayOut[i * 1 + j])); 1177 if (args.out != arrayOut[i * 1 + j]) { 1178 message.append(" FAIL"); 1179 } 1180 message.append("\n"); 1181 assertTrue("Incorrect output for checkMinUshortUshortUshort" + 1182 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1183 } 1184 } 1185 } 1186 } 1187 1188 private void checkMinUshort2Ushort2Ushort2() { 1189 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x98573ebbc511e319l, false); 1190 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x98573ebbc511e31al, false); 1191 try { 1192 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 1193 script.set_gAllocInV2(inV2); 1194 script.forEach_testMinUshort2Ushort2Ushort2(inV1, out); 1195 verifyResultsMinUshort2Ushort2Ushort2(inV1, inV2, out, false); 1196 } catch (Exception e) { 1197 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString()); 1198 } 1199 try { 1200 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 1201 scriptRelaxed.set_gAllocInV2(inV2); 1202 scriptRelaxed.forEach_testMinUshort2Ushort2Ushort2(inV1, out); 1203 verifyResultsMinUshort2Ushort2Ushort2(inV1, inV2, out, true); 1204 } catch (Exception e) { 1205 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString()); 1206 } 1207 } 1208 1209 private void verifyResultsMinUshort2Ushort2Ushort2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1210 short[] arrayInV1 = new short[INPUTSIZE * 2]; 1211 inV1.copyTo(arrayInV1); 1212 short[] arrayInV2 = new short[INPUTSIZE * 2]; 1213 inV2.copyTo(arrayInV2); 1214 short[] arrayOut = new short[INPUTSIZE * 2]; 1215 out.copyTo(arrayOut); 1216 for (int i = 0; i < INPUTSIZE; i++) { 1217 for (int j = 0; j < 2 ; j++) { 1218 // Extract the inputs. 1219 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 1220 args.inV1 = arrayInV1[i * 2 + j]; 1221 args.inV2 = arrayInV2[i * 2 + j]; 1222 // Figure out what the outputs should have been. 1223 CoreMathVerifier.computeMin(args); 1224 // Validate the outputs. 1225 boolean valid = true; 1226 if (args.out != arrayOut[i * 2 + j]) { 1227 valid = false; 1228 } 1229 if (!valid) { 1230 StringBuilder message = new StringBuilder(); 1231 message.append("Input inV1: "); 1232 message.append(String.format("0x%x", args.inV1)); 1233 message.append("\n"); 1234 message.append("Input inV2: "); 1235 message.append(String.format("0x%x", args.inV2)); 1236 message.append("\n"); 1237 message.append("Expected output out: "); 1238 message.append(String.format("0x%x", args.out)); 1239 message.append("\n"); 1240 message.append("Actual output out: "); 1241 message.append(String.format("0x%x", arrayOut[i * 2 + j])); 1242 if (args.out != arrayOut[i * 2 + j]) { 1243 message.append(" FAIL"); 1244 } 1245 message.append("\n"); 1246 assertTrue("Incorrect output for checkMinUshort2Ushort2Ushort2" + 1247 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1248 } 1249 } 1250 } 1251 } 1252 1253 private void checkMinUshort3Ushort3Ushort3() { 1254 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x1595f09b03867776l, false); 1255 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x1595f09b03867777l, false); 1256 try { 1257 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 1258 script.set_gAllocInV2(inV2); 1259 script.forEach_testMinUshort3Ushort3Ushort3(inV1, out); 1260 verifyResultsMinUshort3Ushort3Ushort3(inV1, inV2, out, false); 1261 } catch (Exception e) { 1262 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString()); 1263 } 1264 try { 1265 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 1266 scriptRelaxed.set_gAllocInV2(inV2); 1267 scriptRelaxed.forEach_testMinUshort3Ushort3Ushort3(inV1, out); 1268 verifyResultsMinUshort3Ushort3Ushort3(inV1, inV2, out, true); 1269 } catch (Exception e) { 1270 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString()); 1271 } 1272 } 1273 1274 private void verifyResultsMinUshort3Ushort3Ushort3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1275 short[] arrayInV1 = new short[INPUTSIZE * 4]; 1276 inV1.copyTo(arrayInV1); 1277 short[] arrayInV2 = new short[INPUTSIZE * 4]; 1278 inV2.copyTo(arrayInV2); 1279 short[] arrayOut = new short[INPUTSIZE * 4]; 1280 out.copyTo(arrayOut); 1281 for (int i = 0; i < INPUTSIZE; i++) { 1282 for (int j = 0; j < 3 ; j++) { 1283 // Extract the inputs. 1284 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 1285 args.inV1 = arrayInV1[i * 4 + j]; 1286 args.inV2 = arrayInV2[i * 4 + j]; 1287 // Figure out what the outputs should have been. 1288 CoreMathVerifier.computeMin(args); 1289 // Validate the outputs. 1290 boolean valid = true; 1291 if (args.out != arrayOut[i * 4 + j]) { 1292 valid = false; 1293 } 1294 if (!valid) { 1295 StringBuilder message = new StringBuilder(); 1296 message.append("Input inV1: "); 1297 message.append(String.format("0x%x", args.inV1)); 1298 message.append("\n"); 1299 message.append("Input inV2: "); 1300 message.append(String.format("0x%x", args.inV2)); 1301 message.append("\n"); 1302 message.append("Expected output out: "); 1303 message.append(String.format("0x%x", args.out)); 1304 message.append("\n"); 1305 message.append("Actual output out: "); 1306 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 1307 if (args.out != arrayOut[i * 4 + j]) { 1308 message.append(" FAIL"); 1309 } 1310 message.append("\n"); 1311 assertTrue("Incorrect output for checkMinUshort3Ushort3Ushort3" + 1312 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1313 } 1314 } 1315 } 1316 } 1317 1318 private void checkMinUshort4Ushort4Ushort4() { 1319 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x92d4a27a41fb0bd3l, false); 1320 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x92d4a27a41fb0bd4l, false); 1321 try { 1322 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 1323 script.set_gAllocInV2(inV2); 1324 script.forEach_testMinUshort4Ushort4Ushort4(inV1, out); 1325 verifyResultsMinUshort4Ushort4Ushort4(inV1, inV2, out, false); 1326 } catch (Exception e) { 1327 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString()); 1328 } 1329 try { 1330 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 1331 scriptRelaxed.set_gAllocInV2(inV2); 1332 scriptRelaxed.forEach_testMinUshort4Ushort4Ushort4(inV1, out); 1333 verifyResultsMinUshort4Ushort4Ushort4(inV1, inV2, out, true); 1334 } catch (Exception e) { 1335 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString()); 1336 } 1337 } 1338 1339 private void verifyResultsMinUshort4Ushort4Ushort4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1340 short[] arrayInV1 = new short[INPUTSIZE * 4]; 1341 inV1.copyTo(arrayInV1); 1342 short[] arrayInV2 = new short[INPUTSIZE * 4]; 1343 inV2.copyTo(arrayInV2); 1344 short[] arrayOut = new short[INPUTSIZE * 4]; 1345 out.copyTo(arrayOut); 1346 for (int i = 0; i < INPUTSIZE; i++) { 1347 for (int j = 0; j < 4 ; j++) { 1348 // Extract the inputs. 1349 ArgumentsUshortUshortUshort args = new ArgumentsUshortUshortUshort(); 1350 args.inV1 = arrayInV1[i * 4 + j]; 1351 args.inV2 = arrayInV2[i * 4 + j]; 1352 // Figure out what the outputs should have been. 1353 CoreMathVerifier.computeMin(args); 1354 // Validate the outputs. 1355 boolean valid = true; 1356 if (args.out != arrayOut[i * 4 + j]) { 1357 valid = false; 1358 } 1359 if (!valid) { 1360 StringBuilder message = new StringBuilder(); 1361 message.append("Input inV1: "); 1362 message.append(String.format("0x%x", args.inV1)); 1363 message.append("\n"); 1364 message.append("Input inV2: "); 1365 message.append(String.format("0x%x", args.inV2)); 1366 message.append("\n"); 1367 message.append("Expected output out: "); 1368 message.append(String.format("0x%x", args.out)); 1369 message.append("\n"); 1370 message.append("Actual output out: "); 1371 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 1372 if (args.out != arrayOut[i * 4 + j]) { 1373 message.append(" FAIL"); 1374 } 1375 message.append("\n"); 1376 assertTrue("Incorrect output for checkMinUshort4Ushort4Ushort4" + 1377 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1378 } 1379 } 1380 } 1381 } 1382 1383 public class ArgumentsIntIntInt { 1384 public int inV1; 1385 public int inV2; 1386 public int out; 1387 } 1388 1389 private void checkMinIntIntInt() { 1390 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x38b24335cda69cd5l, false); 1391 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x38b24335cda69cd6l, false); 1392 try { 1393 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE); 1394 script.set_gAllocInV2(inV2); 1395 script.forEach_testMinIntIntInt(inV1, out); 1396 verifyResultsMinIntIntInt(inV1, inV2, out, false); 1397 } catch (Exception e) { 1398 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString()); 1399 } 1400 try { 1401 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE); 1402 scriptRelaxed.set_gAllocInV2(inV2); 1403 scriptRelaxed.forEach_testMinIntIntInt(inV1, out); 1404 verifyResultsMinIntIntInt(inV1, inV2, out, true); 1405 } catch (Exception e) { 1406 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString()); 1407 } 1408 } 1409 1410 private void verifyResultsMinIntIntInt(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1411 int[] arrayInV1 = new int[INPUTSIZE * 1]; 1412 inV1.copyTo(arrayInV1); 1413 int[] arrayInV2 = new int[INPUTSIZE * 1]; 1414 inV2.copyTo(arrayInV2); 1415 int[] arrayOut = new int[INPUTSIZE * 1]; 1416 out.copyTo(arrayOut); 1417 for (int i = 0; i < INPUTSIZE; i++) { 1418 for (int j = 0; j < 1 ; j++) { 1419 // Extract the inputs. 1420 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 1421 args.inV1 = arrayInV1[i]; 1422 args.inV2 = arrayInV2[i]; 1423 // Figure out what the outputs should have been. 1424 CoreMathVerifier.computeMin(args); 1425 // Validate the outputs. 1426 boolean valid = true; 1427 if (args.out != arrayOut[i * 1 + j]) { 1428 valid = false; 1429 } 1430 if (!valid) { 1431 StringBuilder message = new StringBuilder(); 1432 message.append("Input inV1: "); 1433 message.append(String.format("%d", args.inV1)); 1434 message.append("\n"); 1435 message.append("Input inV2: "); 1436 message.append(String.format("%d", args.inV2)); 1437 message.append("\n"); 1438 message.append("Expected output out: "); 1439 message.append(String.format("%d", args.out)); 1440 message.append("\n"); 1441 message.append("Actual output out: "); 1442 message.append(String.format("%d", arrayOut[i * 1 + j])); 1443 if (args.out != arrayOut[i * 1 + j]) { 1444 message.append(" FAIL"); 1445 } 1446 message.append("\n"); 1447 assertTrue("Incorrect output for checkMinIntIntInt" + 1448 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1449 } 1450 } 1451 } 1452 } 1453 1454 private void checkMinInt2Int2Int2() { 1455 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xba635b605676e7a3l, false); 1456 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xba635b605676e7a4l, false); 1457 try { 1458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 1459 script.set_gAllocInV2(inV2); 1460 script.forEach_testMinInt2Int2Int2(inV1, out); 1461 verifyResultsMinInt2Int2Int2(inV1, inV2, out, false); 1462 } catch (Exception e) { 1463 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString()); 1464 } 1465 try { 1466 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 1467 scriptRelaxed.set_gAllocInV2(inV2); 1468 scriptRelaxed.forEach_testMinInt2Int2Int2(inV1, out); 1469 verifyResultsMinInt2Int2Int2(inV1, inV2, out, true); 1470 } catch (Exception e) { 1471 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString()); 1472 } 1473 } 1474 1475 private void verifyResultsMinInt2Int2Int2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1476 int[] arrayInV1 = new int[INPUTSIZE * 2]; 1477 inV1.copyTo(arrayInV1); 1478 int[] arrayInV2 = new int[INPUTSIZE * 2]; 1479 inV2.copyTo(arrayInV2); 1480 int[] arrayOut = new int[INPUTSIZE * 2]; 1481 out.copyTo(arrayOut); 1482 for (int i = 0; i < INPUTSIZE; i++) { 1483 for (int j = 0; j < 2 ; j++) { 1484 // Extract the inputs. 1485 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 1486 args.inV1 = arrayInV1[i * 2 + j]; 1487 args.inV2 = arrayInV2[i * 2 + j]; 1488 // Figure out what the outputs should have been. 1489 CoreMathVerifier.computeMin(args); 1490 // Validate the outputs. 1491 boolean valid = true; 1492 if (args.out != arrayOut[i * 2 + j]) { 1493 valid = false; 1494 } 1495 if (!valid) { 1496 StringBuilder message = new StringBuilder(); 1497 message.append("Input inV1: "); 1498 message.append(String.format("%d", args.inV1)); 1499 message.append("\n"); 1500 message.append("Input inV2: "); 1501 message.append(String.format("%d", args.inV2)); 1502 message.append("\n"); 1503 message.append("Expected output out: "); 1504 message.append(String.format("%d", args.out)); 1505 message.append("\n"); 1506 message.append("Actual output out: "); 1507 message.append(String.format("%d", arrayOut[i * 2 + j])); 1508 if (args.out != arrayOut[i * 2 + j]) { 1509 message.append(" FAIL"); 1510 } 1511 message.append("\n"); 1512 assertTrue("Incorrect output for checkMinInt2Int2Int2" + 1513 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1514 } 1515 } 1516 } 1517 } 1518 1519 private void checkMinInt3Int3Int3() { 1520 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xe4f086806849fbc6l, false); 1521 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xe4f086806849fbc7l, false); 1522 try { 1523 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 1524 script.set_gAllocInV2(inV2); 1525 script.forEach_testMinInt3Int3Int3(inV1, out); 1526 verifyResultsMinInt3Int3Int3(inV1, inV2, out, false); 1527 } catch (Exception e) { 1528 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString()); 1529 } 1530 try { 1531 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 1532 scriptRelaxed.set_gAllocInV2(inV2); 1533 scriptRelaxed.forEach_testMinInt3Int3Int3(inV1, out); 1534 verifyResultsMinInt3Int3Int3(inV1, inV2, out, true); 1535 } catch (Exception e) { 1536 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString()); 1537 } 1538 } 1539 1540 private void verifyResultsMinInt3Int3Int3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1541 int[] arrayInV1 = new int[INPUTSIZE * 4]; 1542 inV1.copyTo(arrayInV1); 1543 int[] arrayInV2 = new int[INPUTSIZE * 4]; 1544 inV2.copyTo(arrayInV2); 1545 int[] arrayOut = new int[INPUTSIZE * 4]; 1546 out.copyTo(arrayOut); 1547 for (int i = 0; i < INPUTSIZE; i++) { 1548 for (int j = 0; j < 3 ; j++) { 1549 // Extract the inputs. 1550 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 1551 args.inV1 = arrayInV1[i * 4 + j]; 1552 args.inV2 = arrayInV2[i * 4 + j]; 1553 // Figure out what the outputs should have been. 1554 CoreMathVerifier.computeMin(args); 1555 // Validate the outputs. 1556 boolean valid = true; 1557 if (args.out != arrayOut[i * 4 + j]) { 1558 valid = false; 1559 } 1560 if (!valid) { 1561 StringBuilder message = new StringBuilder(); 1562 message.append("Input inV1: "); 1563 message.append(String.format("%d", args.inV1)); 1564 message.append("\n"); 1565 message.append("Input inV2: "); 1566 message.append(String.format("%d", args.inV2)); 1567 message.append("\n"); 1568 message.append("Expected output out: "); 1569 message.append(String.format("%d", args.out)); 1570 message.append("\n"); 1571 message.append("Actual output out: "); 1572 message.append(String.format("%d", arrayOut[i * 4 + j])); 1573 if (args.out != arrayOut[i * 4 + j]) { 1574 message.append(" FAIL"); 1575 } 1576 message.append("\n"); 1577 assertTrue("Incorrect output for checkMinInt3Int3Int3" + 1578 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1579 } 1580 } 1581 } 1582 } 1583 1584 private void checkMinInt4Int4Int4() { 1585 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xf7db1a07a1d0fe9l, false); 1586 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xf7db1a07a1d0feal, false); 1587 try { 1588 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 1589 script.set_gAllocInV2(inV2); 1590 script.forEach_testMinInt4Int4Int4(inV1, out); 1591 verifyResultsMinInt4Int4Int4(inV1, inV2, out, false); 1592 } catch (Exception e) { 1593 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString()); 1594 } 1595 try { 1596 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 1597 scriptRelaxed.set_gAllocInV2(inV2); 1598 scriptRelaxed.forEach_testMinInt4Int4Int4(inV1, out); 1599 verifyResultsMinInt4Int4Int4(inV1, inV2, out, true); 1600 } catch (Exception e) { 1601 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString()); 1602 } 1603 } 1604 1605 private void verifyResultsMinInt4Int4Int4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1606 int[] arrayInV1 = new int[INPUTSIZE * 4]; 1607 inV1.copyTo(arrayInV1); 1608 int[] arrayInV2 = new int[INPUTSIZE * 4]; 1609 inV2.copyTo(arrayInV2); 1610 int[] arrayOut = new int[INPUTSIZE * 4]; 1611 out.copyTo(arrayOut); 1612 for (int i = 0; i < INPUTSIZE; i++) { 1613 for (int j = 0; j < 4 ; j++) { 1614 // Extract the inputs. 1615 ArgumentsIntIntInt args = new ArgumentsIntIntInt(); 1616 args.inV1 = arrayInV1[i * 4 + j]; 1617 args.inV2 = arrayInV2[i * 4 + j]; 1618 // Figure out what the outputs should have been. 1619 CoreMathVerifier.computeMin(args); 1620 // Validate the outputs. 1621 boolean valid = true; 1622 if (args.out != arrayOut[i * 4 + j]) { 1623 valid = false; 1624 } 1625 if (!valid) { 1626 StringBuilder message = new StringBuilder(); 1627 message.append("Input inV1: "); 1628 message.append(String.format("%d", args.inV1)); 1629 message.append("\n"); 1630 message.append("Input inV2: "); 1631 message.append(String.format("%d", args.inV2)); 1632 message.append("\n"); 1633 message.append("Expected output out: "); 1634 message.append(String.format("%d", args.out)); 1635 message.append("\n"); 1636 message.append("Actual output out: "); 1637 message.append(String.format("%d", arrayOut[i * 4 + j])); 1638 if (args.out != arrayOut[i * 4 + j]) { 1639 message.append(" FAIL"); 1640 } 1641 message.append("\n"); 1642 assertTrue("Incorrect output for checkMinInt4Int4Int4" + 1643 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1644 } 1645 } 1646 } 1647 } 1648 1649 public class ArgumentsUintUintUint { 1650 public int inV1; 1651 public int inV2; 1652 public int out; 1653 } 1654 1655 private void checkMinUintUintUint() { 1656 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xb3dbca2d537cf298l, false); 1657 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xb3dbca2d537cf299l, false); 1658 try { 1659 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE); 1660 script.set_gAllocInV2(inV2); 1661 script.forEach_testMinUintUintUint(inV1, out); 1662 verifyResultsMinUintUintUint(inV1, inV2, out, false); 1663 } catch (Exception e) { 1664 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString()); 1665 } 1666 try { 1667 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE); 1668 scriptRelaxed.set_gAllocInV2(inV2); 1669 scriptRelaxed.forEach_testMinUintUintUint(inV1, out); 1670 verifyResultsMinUintUintUint(inV1, inV2, out, true); 1671 } catch (Exception e) { 1672 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString()); 1673 } 1674 } 1675 1676 private void verifyResultsMinUintUintUint(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1677 int[] arrayInV1 = new int[INPUTSIZE * 1]; 1678 inV1.copyTo(arrayInV1); 1679 int[] arrayInV2 = new int[INPUTSIZE * 1]; 1680 inV2.copyTo(arrayInV2); 1681 int[] arrayOut = new int[INPUTSIZE * 1]; 1682 out.copyTo(arrayOut); 1683 for (int i = 0; i < INPUTSIZE; i++) { 1684 for (int j = 0; j < 1 ; j++) { 1685 // Extract the inputs. 1686 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 1687 args.inV1 = arrayInV1[i]; 1688 args.inV2 = arrayInV2[i]; 1689 // Figure out what the outputs should have been. 1690 CoreMathVerifier.computeMin(args); 1691 // Validate the outputs. 1692 boolean valid = true; 1693 if (args.out != arrayOut[i * 1 + j]) { 1694 valid = false; 1695 } 1696 if (!valid) { 1697 StringBuilder message = new StringBuilder(); 1698 message.append("Input inV1: "); 1699 message.append(String.format("0x%x", args.inV1)); 1700 message.append("\n"); 1701 message.append("Input inV2: "); 1702 message.append(String.format("0x%x", args.inV2)); 1703 message.append("\n"); 1704 message.append("Expected output out: "); 1705 message.append(String.format("0x%x", args.out)); 1706 message.append("\n"); 1707 message.append("Actual output out: "); 1708 message.append(String.format("0x%x", arrayOut[i * 1 + j])); 1709 if (args.out != arrayOut[i * 1 + j]) { 1710 message.append(" FAIL"); 1711 } 1712 message.append("\n"); 1713 assertTrue("Incorrect output for checkMinUintUintUint" + 1714 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1715 } 1716 } 1717 } 1718 } 1719 1720 private void checkMinUint2Uint2Uint2() { 1721 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb8cf8481d731a1eel, false); 1722 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb8cf8481d731a1efl, false); 1723 try { 1724 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 1725 script.set_gAllocInV2(inV2); 1726 script.forEach_testMinUint2Uint2Uint2(inV1, out); 1727 verifyResultsMinUint2Uint2Uint2(inV1, inV2, out, false); 1728 } catch (Exception e) { 1729 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString()); 1730 } 1731 try { 1732 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 1733 scriptRelaxed.set_gAllocInV2(inV2); 1734 scriptRelaxed.forEach_testMinUint2Uint2Uint2(inV1, out); 1735 verifyResultsMinUint2Uint2Uint2(inV1, inV2, out, true); 1736 } catch (Exception e) { 1737 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString()); 1738 } 1739 } 1740 1741 private void verifyResultsMinUint2Uint2Uint2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1742 int[] arrayInV1 = new int[INPUTSIZE * 2]; 1743 inV1.copyTo(arrayInV1); 1744 int[] arrayInV2 = new int[INPUTSIZE * 2]; 1745 inV2.copyTo(arrayInV2); 1746 int[] arrayOut = new int[INPUTSIZE * 2]; 1747 out.copyTo(arrayOut); 1748 for (int i = 0; i < INPUTSIZE; i++) { 1749 for (int j = 0; j < 2 ; j++) { 1750 // Extract the inputs. 1751 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 1752 args.inV1 = arrayInV1[i * 2 + j]; 1753 args.inV2 = arrayInV2[i * 2 + j]; 1754 // Figure out what the outputs should have been. 1755 CoreMathVerifier.computeMin(args); 1756 // Validate the outputs. 1757 boolean valid = true; 1758 if (args.out != arrayOut[i * 2 + j]) { 1759 valid = false; 1760 } 1761 if (!valid) { 1762 StringBuilder message = new StringBuilder(); 1763 message.append("Input inV1: "); 1764 message.append(String.format("0x%x", args.inV1)); 1765 message.append("\n"); 1766 message.append("Input inV2: "); 1767 message.append(String.format("0x%x", args.inV2)); 1768 message.append("\n"); 1769 message.append("Expected output out: "); 1770 message.append(String.format("0x%x", args.out)); 1771 message.append("\n"); 1772 message.append("Actual output out: "); 1773 message.append(String.format("0x%x", arrayOut[i * 2 + j])); 1774 if (args.out != arrayOut[i * 2 + j]) { 1775 message.append(" FAIL"); 1776 } 1777 message.append("\n"); 1778 assertTrue("Incorrect output for checkMinUint2Uint2Uint2" + 1779 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1780 } 1781 } 1782 } 1783 } 1784 1785 private void checkMinUint3Uint3Uint3() { 1786 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe2100b4bbe974b3l, false); 1787 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe2100b4bbe974b4l, false); 1788 try { 1789 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 1790 script.set_gAllocInV2(inV2); 1791 script.forEach_testMinUint3Uint3Uint3(inV1, out); 1792 verifyResultsMinUint3Uint3Uint3(inV1, inV2, out, false); 1793 } catch (Exception e) { 1794 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString()); 1795 } 1796 try { 1797 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 1798 scriptRelaxed.set_gAllocInV2(inV2); 1799 scriptRelaxed.forEach_testMinUint3Uint3Uint3(inV1, out); 1800 verifyResultsMinUint3Uint3Uint3(inV1, inV2, out, true); 1801 } catch (Exception e) { 1802 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString()); 1803 } 1804 } 1805 1806 private void verifyResultsMinUint3Uint3Uint3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1807 int[] arrayInV1 = new int[INPUTSIZE * 4]; 1808 inV1.copyTo(arrayInV1); 1809 int[] arrayInV2 = new int[INPUTSIZE * 4]; 1810 inV2.copyTo(arrayInV2); 1811 int[] arrayOut = new int[INPUTSIZE * 4]; 1812 out.copyTo(arrayOut); 1813 for (int i = 0; i < INPUTSIZE; i++) { 1814 for (int j = 0; j < 3 ; j++) { 1815 // Extract the inputs. 1816 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 1817 args.inV1 = arrayInV1[i * 4 + j]; 1818 args.inV2 = arrayInV2[i * 4 + j]; 1819 // Figure out what the outputs should have been. 1820 CoreMathVerifier.computeMin(args); 1821 // Validate the outputs. 1822 boolean valid = true; 1823 if (args.out != arrayOut[i * 4 + j]) { 1824 valid = false; 1825 } 1826 if (!valid) { 1827 StringBuilder message = new StringBuilder(); 1828 message.append("Input inV1: "); 1829 message.append(String.format("0x%x", args.inV1)); 1830 message.append("\n"); 1831 message.append("Input inV2: "); 1832 message.append(String.format("0x%x", args.inV2)); 1833 message.append("\n"); 1834 message.append("Expected output out: "); 1835 message.append(String.format("0x%x", args.out)); 1836 message.append("\n"); 1837 message.append("Actual output out: "); 1838 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 1839 if (args.out != arrayOut[i * 4 + j]) { 1840 message.append(" FAIL"); 1841 } 1842 message.append("\n"); 1843 assertTrue("Incorrect output for checkMinUint3Uint3Uint3" + 1844 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1845 } 1846 } 1847 } 1848 } 1849 1850 private void checkMinUint4Uint4Uint4() { 1851 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x63727ce7a0a14778l, false); 1852 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x63727ce7a0a14779l, false); 1853 try { 1854 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 1855 script.set_gAllocInV2(inV2); 1856 script.forEach_testMinUint4Uint4Uint4(inV1, out); 1857 verifyResultsMinUint4Uint4Uint4(inV1, inV2, out, false); 1858 } catch (Exception e) { 1859 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString()); 1860 } 1861 try { 1862 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 1863 scriptRelaxed.set_gAllocInV2(inV2); 1864 scriptRelaxed.forEach_testMinUint4Uint4Uint4(inV1, out); 1865 verifyResultsMinUint4Uint4Uint4(inV1, inV2, out, true); 1866 } catch (Exception e) { 1867 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString()); 1868 } 1869 } 1870 1871 private void verifyResultsMinUint4Uint4Uint4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1872 int[] arrayInV1 = new int[INPUTSIZE * 4]; 1873 inV1.copyTo(arrayInV1); 1874 int[] arrayInV2 = new int[INPUTSIZE * 4]; 1875 inV2.copyTo(arrayInV2); 1876 int[] arrayOut = new int[INPUTSIZE * 4]; 1877 out.copyTo(arrayOut); 1878 for (int i = 0; i < INPUTSIZE; i++) { 1879 for (int j = 0; j < 4 ; j++) { 1880 // Extract the inputs. 1881 ArgumentsUintUintUint args = new ArgumentsUintUintUint(); 1882 args.inV1 = arrayInV1[i * 4 + j]; 1883 args.inV2 = arrayInV2[i * 4 + j]; 1884 // Figure out what the outputs should have been. 1885 CoreMathVerifier.computeMin(args); 1886 // Validate the outputs. 1887 boolean valid = true; 1888 if (args.out != arrayOut[i * 4 + j]) { 1889 valid = false; 1890 } 1891 if (!valid) { 1892 StringBuilder message = new StringBuilder(); 1893 message.append("Input inV1: "); 1894 message.append(String.format("0x%x", args.inV1)); 1895 message.append("\n"); 1896 message.append("Input inV2: "); 1897 message.append(String.format("0x%x", args.inV2)); 1898 message.append("\n"); 1899 message.append("Expected output out: "); 1900 message.append(String.format("0x%x", args.out)); 1901 message.append("\n"); 1902 message.append("Actual output out: "); 1903 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 1904 if (args.out != arrayOut[i * 4 + j]) { 1905 message.append(" FAIL"); 1906 } 1907 message.append("\n"); 1908 assertTrue("Incorrect output for checkMinUint4Uint4Uint4" + 1909 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1910 } 1911 } 1912 } 1913 } 1914 1915 public class ArgumentsLongLongLong { 1916 public long inV1; 1917 public long inV2; 1918 public long out; 1919 } 1920 1921 private void checkMinLongLongLong() { 1922 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x20ce185251c10eb2l, false); 1923 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x20ce185251c10eb3l, false); 1924 try { 1925 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE); 1926 script.set_gAllocInV2(inV2); 1927 script.forEach_testMinLongLongLong(inV1, out); 1928 verifyResultsMinLongLongLong(inV1, inV2, out, false); 1929 } catch (Exception e) { 1930 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString()); 1931 } 1932 try { 1933 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE); 1934 scriptRelaxed.set_gAllocInV2(inV2); 1935 scriptRelaxed.forEach_testMinLongLongLong(inV1, out); 1936 verifyResultsMinLongLongLong(inV1, inV2, out, true); 1937 } catch (Exception e) { 1938 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString()); 1939 } 1940 } 1941 1942 private void verifyResultsMinLongLongLong(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 1943 long[] arrayInV1 = new long[INPUTSIZE * 1]; 1944 inV1.copyTo(arrayInV1); 1945 long[] arrayInV2 = new long[INPUTSIZE * 1]; 1946 inV2.copyTo(arrayInV2); 1947 long[] arrayOut = new long[INPUTSIZE * 1]; 1948 out.copyTo(arrayOut); 1949 for (int i = 0; i < INPUTSIZE; i++) { 1950 for (int j = 0; j < 1 ; j++) { 1951 // Extract the inputs. 1952 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 1953 args.inV1 = arrayInV1[i]; 1954 args.inV2 = arrayInV2[i]; 1955 // Figure out what the outputs should have been. 1956 CoreMathVerifier.computeMin(args); 1957 // Validate the outputs. 1958 boolean valid = true; 1959 if (args.out != arrayOut[i * 1 + j]) { 1960 valid = false; 1961 } 1962 if (!valid) { 1963 StringBuilder message = new StringBuilder(); 1964 message.append("Input inV1: "); 1965 message.append(String.format("%d", args.inV1)); 1966 message.append("\n"); 1967 message.append("Input inV2: "); 1968 message.append(String.format("%d", args.inV2)); 1969 message.append("\n"); 1970 message.append("Expected output out: "); 1971 message.append(String.format("%d", args.out)); 1972 message.append("\n"); 1973 message.append("Actual output out: "); 1974 message.append(String.format("%d", arrayOut[i * 1 + j])); 1975 if (args.out != arrayOut[i * 1 + j]) { 1976 message.append(" FAIL"); 1977 } 1978 message.append("\n"); 1979 assertTrue("Incorrect output for checkMinLongLongLong" + 1980 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 1981 } 1982 } 1983 } 1984 } 1985 1986 private void checkMinLong2Long2Long2() { 1987 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x2285e00a094676a0l, false); 1988 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x2285e00a094676a1l, false); 1989 try { 1990 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 1991 script.set_gAllocInV2(inV2); 1992 script.forEach_testMinLong2Long2Long2(inV1, out); 1993 verifyResultsMinLong2Long2Long2(inV1, inV2, out, false); 1994 } catch (Exception e) { 1995 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString()); 1996 } 1997 try { 1998 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 1999 scriptRelaxed.set_gAllocInV2(inV2); 2000 scriptRelaxed.forEach_testMinLong2Long2Long2(inV1, out); 2001 verifyResultsMinLong2Long2Long2(inV1, inV2, out, true); 2002 } catch (Exception e) { 2003 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString()); 2004 } 2005 } 2006 2007 private void verifyResultsMinLong2Long2Long2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2008 long[] arrayInV1 = new long[INPUTSIZE * 2]; 2009 inV1.copyTo(arrayInV1); 2010 long[] arrayInV2 = new long[INPUTSIZE * 2]; 2011 inV2.copyTo(arrayInV2); 2012 long[] arrayOut = new long[INPUTSIZE * 2]; 2013 out.copyTo(arrayOut); 2014 for (int i = 0; i < INPUTSIZE; i++) { 2015 for (int j = 0; j < 2 ; j++) { 2016 // Extract the inputs. 2017 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 2018 args.inV1 = arrayInV1[i * 2 + j]; 2019 args.inV2 = arrayInV2[i * 2 + j]; 2020 // Figure out what the outputs should have been. 2021 CoreMathVerifier.computeMin(args); 2022 // Validate the outputs. 2023 boolean valid = true; 2024 if (args.out != arrayOut[i * 2 + j]) { 2025 valid = false; 2026 } 2027 if (!valid) { 2028 StringBuilder message = new StringBuilder(); 2029 message.append("Input inV1: "); 2030 message.append(String.format("%d", args.inV1)); 2031 message.append("\n"); 2032 message.append("Input inV2: "); 2033 message.append(String.format("%d", args.inV2)); 2034 message.append("\n"); 2035 message.append("Expected output out: "); 2036 message.append(String.format("%d", args.out)); 2037 message.append("\n"); 2038 message.append("Actual output out: "); 2039 message.append(String.format("%d", arrayOut[i * 2 + j])); 2040 if (args.out != arrayOut[i * 2 + j]) { 2041 message.append(" FAIL"); 2042 } 2043 message.append("\n"); 2044 assertTrue("Incorrect output for checkMinLong2Long2Long2" + 2045 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2046 } 2047 } 2048 } 2049 } 2050 2051 private void checkMinLong3Long3Long3() { 2052 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x77d75c3cedfe4965l, false); 2053 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x77d75c3cedfe4966l, false); 2054 try { 2055 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 2056 script.set_gAllocInV2(inV2); 2057 script.forEach_testMinLong3Long3Long3(inV1, out); 2058 verifyResultsMinLong3Long3Long3(inV1, inV2, out, false); 2059 } catch (Exception e) { 2060 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString()); 2061 } 2062 try { 2063 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 2064 scriptRelaxed.set_gAllocInV2(inV2); 2065 scriptRelaxed.forEach_testMinLong3Long3Long3(inV1, out); 2066 verifyResultsMinLong3Long3Long3(inV1, inV2, out, true); 2067 } catch (Exception e) { 2068 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString()); 2069 } 2070 } 2071 2072 private void verifyResultsMinLong3Long3Long3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2073 long[] arrayInV1 = new long[INPUTSIZE * 4]; 2074 inV1.copyTo(arrayInV1); 2075 long[] arrayInV2 = new long[INPUTSIZE * 4]; 2076 inV2.copyTo(arrayInV2); 2077 long[] arrayOut = new long[INPUTSIZE * 4]; 2078 out.copyTo(arrayOut); 2079 for (int i = 0; i < INPUTSIZE; i++) { 2080 for (int j = 0; j < 3 ; j++) { 2081 // Extract the inputs. 2082 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 2083 args.inV1 = arrayInV1[i * 4 + j]; 2084 args.inV2 = arrayInV2[i * 4 + j]; 2085 // Figure out what the outputs should have been. 2086 CoreMathVerifier.computeMin(args); 2087 // Validate the outputs. 2088 boolean valid = true; 2089 if (args.out != arrayOut[i * 4 + j]) { 2090 valid = false; 2091 } 2092 if (!valid) { 2093 StringBuilder message = new StringBuilder(); 2094 message.append("Input inV1: "); 2095 message.append(String.format("%d", args.inV1)); 2096 message.append("\n"); 2097 message.append("Input inV2: "); 2098 message.append(String.format("%d", args.inV2)); 2099 message.append("\n"); 2100 message.append("Expected output out: "); 2101 message.append(String.format("%d", args.out)); 2102 message.append("\n"); 2103 message.append("Actual output out: "); 2104 message.append(String.format("%d", arrayOut[i * 4 + j])); 2105 if (args.out != arrayOut[i * 4 + j]) { 2106 message.append(" FAIL"); 2107 } 2108 message.append("\n"); 2109 assertTrue("Incorrect output for checkMinLong3Long3Long3" + 2110 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2111 } 2112 } 2113 } 2114 } 2115 2116 private void checkMinLong4Long4Long4() { 2117 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xcd28d86fd2b61c2al, false); 2118 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xcd28d86fd2b61c2bl, false); 2119 try { 2120 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 2121 script.set_gAllocInV2(inV2); 2122 script.forEach_testMinLong4Long4Long4(inV1, out); 2123 verifyResultsMinLong4Long4Long4(inV1, inV2, out, false); 2124 } catch (Exception e) { 2125 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString()); 2126 } 2127 try { 2128 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 2129 scriptRelaxed.set_gAllocInV2(inV2); 2130 scriptRelaxed.forEach_testMinLong4Long4Long4(inV1, out); 2131 verifyResultsMinLong4Long4Long4(inV1, inV2, out, true); 2132 } catch (Exception e) { 2133 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString()); 2134 } 2135 } 2136 2137 private void verifyResultsMinLong4Long4Long4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2138 long[] arrayInV1 = new long[INPUTSIZE * 4]; 2139 inV1.copyTo(arrayInV1); 2140 long[] arrayInV2 = new long[INPUTSIZE * 4]; 2141 inV2.copyTo(arrayInV2); 2142 long[] arrayOut = new long[INPUTSIZE * 4]; 2143 out.copyTo(arrayOut); 2144 for (int i = 0; i < INPUTSIZE; i++) { 2145 for (int j = 0; j < 4 ; j++) { 2146 // Extract the inputs. 2147 ArgumentsLongLongLong args = new ArgumentsLongLongLong(); 2148 args.inV1 = arrayInV1[i * 4 + j]; 2149 args.inV2 = arrayInV2[i * 4 + j]; 2150 // Figure out what the outputs should have been. 2151 CoreMathVerifier.computeMin(args); 2152 // Validate the outputs. 2153 boolean valid = true; 2154 if (args.out != arrayOut[i * 4 + j]) { 2155 valid = false; 2156 } 2157 if (!valid) { 2158 StringBuilder message = new StringBuilder(); 2159 message.append("Input inV1: "); 2160 message.append(String.format("%d", args.inV1)); 2161 message.append("\n"); 2162 message.append("Input inV2: "); 2163 message.append(String.format("%d", args.inV2)); 2164 message.append("\n"); 2165 message.append("Expected output out: "); 2166 message.append(String.format("%d", args.out)); 2167 message.append("\n"); 2168 message.append("Actual output out: "); 2169 message.append(String.format("%d", arrayOut[i * 4 + j])); 2170 if (args.out != arrayOut[i * 4 + j]) { 2171 message.append(" FAIL"); 2172 } 2173 message.append("\n"); 2174 assertTrue("Incorrect output for checkMinLong4Long4Long4" + 2175 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2176 } 2177 } 2178 } 2179 } 2180 2181 public class ArgumentsUlongUlongUlong { 2182 public long inV1; 2183 public long inV2; 2184 public long out; 2185 } 2186 2187 private void checkMinUlongUlongUlong() { 2188 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x9ea8f1e67008ea67l, false); 2189 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x9ea8f1e67008ea68l, false); 2190 try { 2191 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE); 2192 script.set_gAllocInV2(inV2); 2193 script.forEach_testMinUlongUlongUlong(inV1, out); 2194 verifyResultsMinUlongUlongUlong(inV1, inV2, out, false); 2195 } catch (Exception e) { 2196 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString()); 2197 } 2198 try { 2199 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE); 2200 scriptRelaxed.set_gAllocInV2(inV2); 2201 scriptRelaxed.forEach_testMinUlongUlongUlong(inV1, out); 2202 verifyResultsMinUlongUlongUlong(inV1, inV2, out, true); 2203 } catch (Exception e) { 2204 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString()); 2205 } 2206 } 2207 2208 private void verifyResultsMinUlongUlongUlong(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2209 long[] arrayInV1 = new long[INPUTSIZE * 1]; 2210 inV1.copyTo(arrayInV1); 2211 long[] arrayInV2 = new long[INPUTSIZE * 1]; 2212 inV2.copyTo(arrayInV2); 2213 long[] arrayOut = new long[INPUTSIZE * 1]; 2214 out.copyTo(arrayOut); 2215 for (int i = 0; i < INPUTSIZE; i++) { 2216 for (int j = 0; j < 1 ; j++) { 2217 // Extract the inputs. 2218 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 2219 args.inV1 = arrayInV1[i]; 2220 args.inV2 = arrayInV2[i]; 2221 // Figure out what the outputs should have been. 2222 CoreMathVerifier.computeMin(args); 2223 // Validate the outputs. 2224 boolean valid = true; 2225 if (args.out != arrayOut[i * 1 + j]) { 2226 valid = false; 2227 } 2228 if (!valid) { 2229 StringBuilder message = new StringBuilder(); 2230 message.append("Input inV1: "); 2231 message.append(String.format("0x%x", args.inV1)); 2232 message.append("\n"); 2233 message.append("Input inV2: "); 2234 message.append(String.format("0x%x", args.inV2)); 2235 message.append("\n"); 2236 message.append("Expected output out: "); 2237 message.append(String.format("0x%x", args.out)); 2238 message.append("\n"); 2239 message.append("Actual output out: "); 2240 message.append(String.format("0x%x", arrayOut[i * 1 + j])); 2241 if (args.out != arrayOut[i * 1 + j]) { 2242 message.append(" FAIL"); 2243 } 2244 message.append("\n"); 2245 assertTrue("Incorrect output for checkMinUlongUlongUlong" + 2246 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2247 } 2248 } 2249 } 2250 } 2251 2252 private void checkMinUlong2Ulong2Ulong2() { 2253 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x26bb4add3110402dl, false); 2254 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x26bb4add3110402el, false); 2255 try { 2256 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 2257 script.set_gAllocInV2(inV2); 2258 script.forEach_testMinUlong2Ulong2Ulong2(inV1, out); 2259 verifyResultsMinUlong2Ulong2Ulong2(inV1, inV2, out, false); 2260 } catch (Exception e) { 2261 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString()); 2262 } 2263 try { 2264 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 2265 scriptRelaxed.set_gAllocInV2(inV2); 2266 scriptRelaxed.forEach_testMinUlong2Ulong2Ulong2(inV1, out); 2267 verifyResultsMinUlong2Ulong2Ulong2(inV1, inV2, out, true); 2268 } catch (Exception e) { 2269 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString()); 2270 } 2271 } 2272 2273 private void verifyResultsMinUlong2Ulong2Ulong2(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2274 long[] arrayInV1 = new long[INPUTSIZE * 2]; 2275 inV1.copyTo(arrayInV1); 2276 long[] arrayInV2 = new long[INPUTSIZE * 2]; 2277 inV2.copyTo(arrayInV2); 2278 long[] arrayOut = new long[INPUTSIZE * 2]; 2279 out.copyTo(arrayOut); 2280 for (int i = 0; i < INPUTSIZE; i++) { 2281 for (int j = 0; j < 2 ; j++) { 2282 // Extract the inputs. 2283 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 2284 args.inV1 = arrayInV1[i * 2 + j]; 2285 args.inV2 = arrayInV2[i * 2 + j]; 2286 // Figure out what the outputs should have been. 2287 CoreMathVerifier.computeMin(args); 2288 // Validate the outputs. 2289 boolean valid = true; 2290 if (args.out != arrayOut[i * 2 + j]) { 2291 valid = false; 2292 } 2293 if (!valid) { 2294 StringBuilder message = new StringBuilder(); 2295 message.append("Input inV1: "); 2296 message.append(String.format("0x%x", args.inV1)); 2297 message.append("\n"); 2298 message.append("Input inV2: "); 2299 message.append(String.format("0x%x", args.inV2)); 2300 message.append("\n"); 2301 message.append("Expected output out: "); 2302 message.append(String.format("0x%x", args.out)); 2303 message.append("\n"); 2304 message.append("Actual output out: "); 2305 message.append(String.format("0x%x", arrayOut[i * 2 + j])); 2306 if (args.out != arrayOut[i * 2 + j]) { 2307 message.append(" FAIL"); 2308 } 2309 message.append("\n"); 2310 assertTrue("Incorrect output for checkMinUlong2Ulong2Ulong2" + 2311 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2312 } 2313 } 2314 } 2315 } 2316 2317 private void checkMinUlong3Ulong3Ulong3() { 2318 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x53ac9a3d815a8638l, false); 2319 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x53ac9a3d815a8639l, false); 2320 try { 2321 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 2322 script.set_gAllocInV2(inV2); 2323 script.forEach_testMinUlong3Ulong3Ulong3(inV1, out); 2324 verifyResultsMinUlong3Ulong3Ulong3(inV1, inV2, out, false); 2325 } catch (Exception e) { 2326 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString()); 2327 } 2328 try { 2329 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 2330 scriptRelaxed.set_gAllocInV2(inV2); 2331 scriptRelaxed.forEach_testMinUlong3Ulong3Ulong3(inV1, out); 2332 verifyResultsMinUlong3Ulong3Ulong3(inV1, inV2, out, true); 2333 } catch (Exception e) { 2334 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString()); 2335 } 2336 } 2337 2338 private void verifyResultsMinUlong3Ulong3Ulong3(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2339 long[] arrayInV1 = new long[INPUTSIZE * 4]; 2340 inV1.copyTo(arrayInV1); 2341 long[] arrayInV2 = new long[INPUTSIZE * 4]; 2342 inV2.copyTo(arrayInV2); 2343 long[] arrayOut = new long[INPUTSIZE * 4]; 2344 out.copyTo(arrayOut); 2345 for (int i = 0; i < INPUTSIZE; i++) { 2346 for (int j = 0; j < 3 ; j++) { 2347 // Extract the inputs. 2348 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 2349 args.inV1 = arrayInV1[i * 4 + j]; 2350 args.inV2 = arrayInV2[i * 4 + j]; 2351 // Figure out what the outputs should have been. 2352 CoreMathVerifier.computeMin(args); 2353 // Validate the outputs. 2354 boolean valid = true; 2355 if (args.out != arrayOut[i * 4 + j]) { 2356 valid = false; 2357 } 2358 if (!valid) { 2359 StringBuilder message = new StringBuilder(); 2360 message.append("Input inV1: "); 2361 message.append(String.format("0x%x", args.inV1)); 2362 message.append("\n"); 2363 message.append("Input inV2: "); 2364 message.append(String.format("0x%x", args.inV2)); 2365 message.append("\n"); 2366 message.append("Expected output out: "); 2367 message.append(String.format("0x%x", args.out)); 2368 message.append("\n"); 2369 message.append("Actual output out: "); 2370 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 2371 if (args.out != arrayOut[i * 4 + j]) { 2372 message.append(" FAIL"); 2373 } 2374 message.append("\n"); 2375 assertTrue("Incorrect output for checkMinUlong3Ulong3Ulong3" + 2376 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2377 } 2378 } 2379 } 2380 } 2381 2382 private void checkMinUlong4Ulong4Ulong4() { 2383 Allocation inV1 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x809de99dd1a4cc43l, false); 2384 Allocation inV2 = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x809de99dd1a4cc44l, false); 2385 try { 2386 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 2387 script.set_gAllocInV2(inV2); 2388 script.forEach_testMinUlong4Ulong4Ulong4(inV1, out); 2389 verifyResultsMinUlong4Ulong4Ulong4(inV1, inV2, out, false); 2390 } catch (Exception e) { 2391 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString()); 2392 } 2393 try { 2394 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 2395 scriptRelaxed.set_gAllocInV2(inV2); 2396 scriptRelaxed.forEach_testMinUlong4Ulong4Ulong4(inV1, out); 2397 verifyResultsMinUlong4Ulong4Ulong4(inV1, inV2, out, true); 2398 } catch (Exception e) { 2399 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString()); 2400 } 2401 } 2402 2403 private void verifyResultsMinUlong4Ulong4Ulong4(Allocation inV1, Allocation inV2, Allocation out, boolean relaxed) { 2404 long[] arrayInV1 = new long[INPUTSIZE * 4]; 2405 inV1.copyTo(arrayInV1); 2406 long[] arrayInV2 = new long[INPUTSIZE * 4]; 2407 inV2.copyTo(arrayInV2); 2408 long[] arrayOut = new long[INPUTSIZE * 4]; 2409 out.copyTo(arrayOut); 2410 for (int i = 0; i < INPUTSIZE; i++) { 2411 for (int j = 0; j < 4 ; j++) { 2412 // Extract the inputs. 2413 ArgumentsUlongUlongUlong args = new ArgumentsUlongUlongUlong(); 2414 args.inV1 = arrayInV1[i * 4 + j]; 2415 args.inV2 = arrayInV2[i * 4 + j]; 2416 // Figure out what the outputs should have been. 2417 CoreMathVerifier.computeMin(args); 2418 // Validate the outputs. 2419 boolean valid = true; 2420 if (args.out != arrayOut[i * 4 + j]) { 2421 valid = false; 2422 } 2423 if (!valid) { 2424 StringBuilder message = new StringBuilder(); 2425 message.append("Input inV1: "); 2426 message.append(String.format("0x%x", args.inV1)); 2427 message.append("\n"); 2428 message.append("Input inV2: "); 2429 message.append(String.format("0x%x", args.inV2)); 2430 message.append("\n"); 2431 message.append("Expected output out: "); 2432 message.append(String.format("0x%x", args.out)); 2433 message.append("\n"); 2434 message.append("Actual output out: "); 2435 message.append(String.format("0x%x", arrayOut[i * 4 + j])); 2436 if (args.out != arrayOut[i * 4 + j]) { 2437 message.append(" FAIL"); 2438 } 2439 message.append("\n"); 2440 assertTrue("Incorrect output for checkMinUlong4Ulong4Ulong4" + 2441 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); 2442 } 2443 } 2444 } 2445 } 2446 2447 public void testMin() { 2448 checkMinFloatFloatFloat(); 2449 checkMinFloat2Float2Float2(); 2450 checkMinFloat3Float3Float3(); 2451 checkMinFloat4Float4Float4(); 2452 checkMinCharCharChar(); 2453 checkMinChar2Char2Char2(); 2454 checkMinChar3Char3Char3(); 2455 checkMinChar4Char4Char4(); 2456 checkMinUcharUcharUchar(); 2457 checkMinUchar2Uchar2Uchar2(); 2458 checkMinUchar3Uchar3Uchar3(); 2459 checkMinUchar4Uchar4Uchar4(); 2460 checkMinShortShortShort(); 2461 checkMinShort2Short2Short2(); 2462 checkMinShort3Short3Short3(); 2463 checkMinShort4Short4Short4(); 2464 checkMinUshortUshortUshort(); 2465 checkMinUshort2Ushort2Ushort2(); 2466 checkMinUshort3Ushort3Ushort3(); 2467 checkMinUshort4Ushort4Ushort4(); 2468 checkMinIntIntInt(); 2469 checkMinInt2Int2Int2(); 2470 checkMinInt3Int3Int3(); 2471 checkMinInt4Int4Int4(); 2472 checkMinUintUintUint(); 2473 checkMinUint2Uint2Uint2(); 2474 checkMinUint3Uint3Uint3(); 2475 checkMinUint4Uint4Uint4(); 2476 checkMinLongLongLong(); 2477 checkMinLong2Long2Long2(); 2478 checkMinLong3Long3Long3(); 2479 checkMinLong4Long4Long4(); 2480 checkMinUlongUlongUlong(); 2481 checkMinUlong2Ulong2Ulong2(); 2482 checkMinUlong3Ulong3Ulong3(); 2483 checkMinUlong4Ulong4Ulong4(); 2484 } 2485 } 2486