1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh. 18 19 package android.renderscript.cts; 20 21 import android.renderscript.Allocation; 22 import android.renderscript.RSRuntimeException; 23 import android.renderscript.Element; 24 import android.renderscript.cts.Target; 25 26 import java.util.Arrays; 27 28 public class TestConvert extends RSBaseCompute { 29 30 private ScriptC_TestConvert script; 31 private ScriptC_TestConvertRelaxed scriptRelaxed; 32 33 @Override 34 protected void setUp() throws Exception { 35 super.setUp(); 36 script = new ScriptC_TestConvert(mRS); 37 scriptRelaxed = new ScriptC_TestConvertRelaxed(mRS); 38 } 39 40 @Override 41 protected void tearDown() throws Exception { 42 script.destroy(); 43 scriptRelaxed.destroy(); 44 super.tearDown(); 45 } 46 47 public class ArgumentsFloatFloat { 48 public float inV; 49 public Target.Floaty out; 50 } 51 52 private void checkConvertFloat2Float2() { 53 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb5215c44e1f6ac6l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 54 try { 55 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 56 script.forEach_testConvertFloat2Float2Float2(inV, out); 57 verifyResultsConvertFloat2Float2(inV, out, false); 58 out.destroy(); 59 } catch (Exception e) { 60 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString()); 61 } 62 try { 63 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 64 scriptRelaxed.forEach_testConvertFloat2Float2Float2(inV, out); 65 verifyResultsConvertFloat2Float2(inV, out, true); 66 out.destroy(); 67 } catch (Exception e) { 68 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString()); 69 } 70 inV.destroy(); 71 } 72 73 private void verifyResultsConvertFloat2Float2(Allocation inV, Allocation out, boolean relaxed) { 74 float[] arrayInV = new float[INPUTSIZE * 2]; 75 Arrays.fill(arrayInV, (float) 42); 76 inV.copyTo(arrayInV); 77 float[] arrayOut = new float[INPUTSIZE * 2]; 78 Arrays.fill(arrayOut, (float) 42); 79 out.copyTo(arrayOut); 80 StringBuilder message = new StringBuilder(); 81 boolean errorFound = false; 82 for (int i = 0; i < INPUTSIZE; i++) { 83 for (int j = 0; j < 2 ; j++) { 84 // Extract the inputs. 85 ArgumentsFloatFloat args = new ArgumentsFloatFloat(); 86 args.inV = arrayInV[i * 2 + j]; 87 // Figure out what the outputs should have been. 88 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 89 CoreMathVerifier.computeConvert(args, target); 90 // Validate the outputs. 91 boolean valid = true; 92 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 93 valid = false; 94 } 95 if (!valid) { 96 if (!errorFound) { 97 errorFound = true; 98 message.append("Input inV: "); 99 appendVariableToMessage(message, args.inV); 100 message.append("\n"); 101 message.append("Expected output out: "); 102 appendVariableToMessage(message, args.out); 103 message.append("\n"); 104 message.append("Actual output out: "); 105 appendVariableToMessage(message, arrayOut[i * 2 + j]); 106 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 107 message.append(" FAIL"); 108 } 109 message.append("\n"); 110 message.append("Errors at"); 111 } 112 message.append(" ["); 113 message.append(Integer.toString(i)); 114 message.append(", "); 115 message.append(Integer.toString(j)); 116 message.append("]"); 117 } 118 } 119 } 120 assertFalse("Incorrect output for checkConvertFloat2Float2" + 121 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 122 } 123 124 private void checkConvertFloat3Float3() { 125 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb53dedf443a8ba4l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 126 try { 127 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 128 script.forEach_testConvertFloat3Float3Float3(inV, out); 129 verifyResultsConvertFloat3Float3(inV, out, false); 130 out.destroy(); 131 } catch (Exception e) { 132 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString()); 133 } 134 try { 135 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 136 scriptRelaxed.forEach_testConvertFloat3Float3Float3(inV, out); 137 verifyResultsConvertFloat3Float3(inV, out, true); 138 out.destroy(); 139 } catch (Exception e) { 140 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString()); 141 } 142 inV.destroy(); 143 } 144 145 private void verifyResultsConvertFloat3Float3(Allocation inV, Allocation out, boolean relaxed) { 146 float[] arrayInV = new float[INPUTSIZE * 4]; 147 Arrays.fill(arrayInV, (float) 42); 148 inV.copyTo(arrayInV); 149 float[] arrayOut = new float[INPUTSIZE * 4]; 150 Arrays.fill(arrayOut, (float) 42); 151 out.copyTo(arrayOut); 152 StringBuilder message = new StringBuilder(); 153 boolean errorFound = false; 154 for (int i = 0; i < INPUTSIZE; i++) { 155 for (int j = 0; j < 3 ; j++) { 156 // Extract the inputs. 157 ArgumentsFloatFloat args = new ArgumentsFloatFloat(); 158 args.inV = arrayInV[i * 4 + j]; 159 // Figure out what the outputs should have been. 160 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 161 CoreMathVerifier.computeConvert(args, target); 162 // Validate the outputs. 163 boolean valid = true; 164 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 165 valid = false; 166 } 167 if (!valid) { 168 if (!errorFound) { 169 errorFound = true; 170 message.append("Input inV: "); 171 appendVariableToMessage(message, args.inV); 172 message.append("\n"); 173 message.append("Expected output out: "); 174 appendVariableToMessage(message, args.out); 175 message.append("\n"); 176 message.append("Actual output out: "); 177 appendVariableToMessage(message, arrayOut[i * 4 + j]); 178 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 179 message.append(" FAIL"); 180 } 181 message.append("\n"); 182 message.append("Errors at"); 183 } 184 message.append(" ["); 185 message.append(Integer.toString(i)); 186 message.append(", "); 187 message.append(Integer.toString(j)); 188 message.append("]"); 189 } 190 } 191 } 192 assertFalse("Incorrect output for checkConvertFloat3Float3" + 193 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 194 } 195 196 private void checkConvertFloat4Float4() { 197 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb55a7fa3a55ac82l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 198 try { 199 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 200 script.forEach_testConvertFloat4Float4Float4(inV, out); 201 verifyResultsConvertFloat4Float4(inV, out, false); 202 out.destroy(); 203 } catch (Exception e) { 204 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString()); 205 } 206 try { 207 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 208 scriptRelaxed.forEach_testConvertFloat4Float4Float4(inV, out); 209 verifyResultsConvertFloat4Float4(inV, out, true); 210 out.destroy(); 211 } catch (Exception e) { 212 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString()); 213 } 214 inV.destroy(); 215 } 216 217 private void verifyResultsConvertFloat4Float4(Allocation inV, Allocation out, boolean relaxed) { 218 float[] arrayInV = new float[INPUTSIZE * 4]; 219 Arrays.fill(arrayInV, (float) 42); 220 inV.copyTo(arrayInV); 221 float[] arrayOut = new float[INPUTSIZE * 4]; 222 Arrays.fill(arrayOut, (float) 42); 223 out.copyTo(arrayOut); 224 StringBuilder message = new StringBuilder(); 225 boolean errorFound = false; 226 for (int i = 0; i < INPUTSIZE; i++) { 227 for (int j = 0; j < 4 ; j++) { 228 // Extract the inputs. 229 ArgumentsFloatFloat args = new ArgumentsFloatFloat(); 230 args.inV = arrayInV[i * 4 + j]; 231 // Figure out what the outputs should have been. 232 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 233 CoreMathVerifier.computeConvert(args, target); 234 // Validate the outputs. 235 boolean valid = true; 236 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 237 valid = false; 238 } 239 if (!valid) { 240 if (!errorFound) { 241 errorFound = true; 242 message.append("Input inV: "); 243 appendVariableToMessage(message, args.inV); 244 message.append("\n"); 245 message.append("Expected output out: "); 246 appendVariableToMessage(message, args.out); 247 message.append("\n"); 248 message.append("Actual output out: "); 249 appendVariableToMessage(message, arrayOut[i * 4 + j]); 250 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 251 message.append(" FAIL"); 252 } 253 message.append("\n"); 254 message.append("Errors at"); 255 } 256 message.append(" ["); 257 message.append(Integer.toString(i)); 258 message.append(", "); 259 message.append(Integer.toString(j)); 260 message.append("]"); 261 } 262 } 263 } 264 assertFalse("Incorrect output for checkConvertFloat4Float4" + 265 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 266 } 267 268 public class ArgumentsCharFloat { 269 public byte inV; 270 public Target.Floaty out; 271 } 272 273 private void checkConvertChar2Float2() { 274 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x5861e2161f489286l, true, 7); 275 try { 276 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 277 script.forEach_testConvertFloat2Char2Float2(inV, out); 278 verifyResultsConvertChar2Float2(inV, out, false); 279 out.destroy(); 280 } catch (Exception e) { 281 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString()); 282 } 283 try { 284 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 285 scriptRelaxed.forEach_testConvertFloat2Char2Float2(inV, out); 286 verifyResultsConvertChar2Float2(inV, out, true); 287 out.destroy(); 288 } catch (Exception e) { 289 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString()); 290 } 291 inV.destroy(); 292 } 293 294 private void verifyResultsConvertChar2Float2(Allocation inV, Allocation out, boolean relaxed) { 295 byte[] arrayInV = new byte[INPUTSIZE * 2]; 296 Arrays.fill(arrayInV, (byte) 42); 297 inV.copyTo(arrayInV); 298 float[] arrayOut = new float[INPUTSIZE * 2]; 299 Arrays.fill(arrayOut, (float) 42); 300 out.copyTo(arrayOut); 301 StringBuilder message = new StringBuilder(); 302 boolean errorFound = false; 303 for (int i = 0; i < INPUTSIZE; i++) { 304 for (int j = 0; j < 2 ; j++) { 305 // Extract the inputs. 306 ArgumentsCharFloat args = new ArgumentsCharFloat(); 307 args.inV = arrayInV[i * 2 + j]; 308 // Figure out what the outputs should have been. 309 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 310 CoreMathVerifier.computeConvert(args, target); 311 // Validate the outputs. 312 boolean valid = true; 313 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 314 valid = false; 315 } 316 if (!valid) { 317 if (!errorFound) { 318 errorFound = true; 319 message.append("Input inV: "); 320 appendVariableToMessage(message, args.inV); 321 message.append("\n"); 322 message.append("Expected output out: "); 323 appendVariableToMessage(message, args.out); 324 message.append("\n"); 325 message.append("Actual output out: "); 326 appendVariableToMessage(message, arrayOut[i * 2 + j]); 327 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 328 message.append(" FAIL"); 329 } 330 message.append("\n"); 331 message.append("Errors at"); 332 } 333 message.append(" ["); 334 message.append(Integer.toString(i)); 335 message.append(", "); 336 message.append(Integer.toString(j)); 337 message.append("]"); 338 } 339 } 340 } 341 assertFalse("Incorrect output for checkConvertChar2Float2" + 342 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 343 } 344 345 private void checkConvertChar3Float3() { 346 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x5863ab311563b364l, true, 7); 347 try { 348 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 349 script.forEach_testConvertFloat3Char3Float3(inV, out); 350 verifyResultsConvertChar3Float3(inV, out, false); 351 out.destroy(); 352 } catch (Exception e) { 353 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString()); 354 } 355 try { 356 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 357 scriptRelaxed.forEach_testConvertFloat3Char3Float3(inV, out); 358 verifyResultsConvertChar3Float3(inV, out, true); 359 out.destroy(); 360 } catch (Exception e) { 361 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString()); 362 } 363 inV.destroy(); 364 } 365 366 private void verifyResultsConvertChar3Float3(Allocation inV, Allocation out, boolean relaxed) { 367 byte[] arrayInV = new byte[INPUTSIZE * 4]; 368 Arrays.fill(arrayInV, (byte) 42); 369 inV.copyTo(arrayInV); 370 float[] arrayOut = new float[INPUTSIZE * 4]; 371 Arrays.fill(arrayOut, (float) 42); 372 out.copyTo(arrayOut); 373 StringBuilder message = new StringBuilder(); 374 boolean errorFound = false; 375 for (int i = 0; i < INPUTSIZE; i++) { 376 for (int j = 0; j < 3 ; j++) { 377 // Extract the inputs. 378 ArgumentsCharFloat args = new ArgumentsCharFloat(); 379 args.inV = arrayInV[i * 4 + j]; 380 // Figure out what the outputs should have been. 381 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 382 CoreMathVerifier.computeConvert(args, target); 383 // Validate the outputs. 384 boolean valid = true; 385 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 386 valid = false; 387 } 388 if (!valid) { 389 if (!errorFound) { 390 errorFound = true; 391 message.append("Input inV: "); 392 appendVariableToMessage(message, args.inV); 393 message.append("\n"); 394 message.append("Expected output out: "); 395 appendVariableToMessage(message, args.out); 396 message.append("\n"); 397 message.append("Actual output out: "); 398 appendVariableToMessage(message, arrayOut[i * 4 + j]); 399 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 400 message.append(" FAIL"); 401 } 402 message.append("\n"); 403 message.append("Errors at"); 404 } 405 message.append(" ["); 406 message.append(Integer.toString(i)); 407 message.append(", "); 408 message.append(Integer.toString(j)); 409 message.append("]"); 410 } 411 } 412 } 413 assertFalse("Incorrect output for checkConvertChar3Float3" + 414 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 415 } 416 417 private void checkConvertChar4Float4() { 418 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5865744c0b7ed442l, true, 7); 419 try { 420 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 421 script.forEach_testConvertFloat4Char4Float4(inV, out); 422 verifyResultsConvertChar4Float4(inV, out, false); 423 out.destroy(); 424 } catch (Exception e) { 425 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString()); 426 } 427 try { 428 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 429 scriptRelaxed.forEach_testConvertFloat4Char4Float4(inV, out); 430 verifyResultsConvertChar4Float4(inV, out, true); 431 out.destroy(); 432 } catch (Exception e) { 433 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString()); 434 } 435 inV.destroy(); 436 } 437 438 private void verifyResultsConvertChar4Float4(Allocation inV, Allocation out, boolean relaxed) { 439 byte[] arrayInV = new byte[INPUTSIZE * 4]; 440 Arrays.fill(arrayInV, (byte) 42); 441 inV.copyTo(arrayInV); 442 float[] arrayOut = new float[INPUTSIZE * 4]; 443 Arrays.fill(arrayOut, (float) 42); 444 out.copyTo(arrayOut); 445 StringBuilder message = new StringBuilder(); 446 boolean errorFound = false; 447 for (int i = 0; i < INPUTSIZE; i++) { 448 for (int j = 0; j < 4 ; j++) { 449 // Extract the inputs. 450 ArgumentsCharFloat args = new ArgumentsCharFloat(); 451 args.inV = arrayInV[i * 4 + j]; 452 // Figure out what the outputs should have been. 453 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 454 CoreMathVerifier.computeConvert(args, target); 455 // Validate the outputs. 456 boolean valid = true; 457 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 458 valid = false; 459 } 460 if (!valid) { 461 if (!errorFound) { 462 errorFound = true; 463 message.append("Input inV: "); 464 appendVariableToMessage(message, args.inV); 465 message.append("\n"); 466 message.append("Expected output out: "); 467 appendVariableToMessage(message, args.out); 468 message.append("\n"); 469 message.append("Actual output out: "); 470 appendVariableToMessage(message, arrayOut[i * 4 + j]); 471 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 472 message.append(" FAIL"); 473 } 474 message.append("\n"); 475 message.append("Errors at"); 476 } 477 message.append(" ["); 478 message.append(Integer.toString(i)); 479 message.append(", "); 480 message.append(Integer.toString(j)); 481 message.append("]"); 482 } 483 } 484 } 485 assertFalse("Incorrect output for checkConvertChar4Float4" + 486 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 487 } 488 489 public class ArgumentsUcharFloat { 490 public byte inV; 491 public Target.Floaty out; 492 } 493 494 private void checkConvertUchar2Float2() { 495 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d30021dbb20ac31l, false, 8); 496 try { 497 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 498 script.forEach_testConvertFloat2Uchar2Float2(inV, out); 499 verifyResultsConvertUchar2Float2(inV, out, false); 500 out.destroy(); 501 } catch (Exception e) { 502 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString()); 503 } 504 try { 505 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 506 scriptRelaxed.forEach_testConvertFloat2Uchar2Float2(inV, out); 507 verifyResultsConvertUchar2Float2(inV, out, true); 508 out.destroy(); 509 } catch (Exception e) { 510 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString()); 511 } 512 inV.destroy(); 513 } 514 515 private void verifyResultsConvertUchar2Float2(Allocation inV, Allocation out, boolean relaxed) { 516 byte[] arrayInV = new byte[INPUTSIZE * 2]; 517 Arrays.fill(arrayInV, (byte) 42); 518 inV.copyTo(arrayInV); 519 float[] arrayOut = new float[INPUTSIZE * 2]; 520 Arrays.fill(arrayOut, (float) 42); 521 out.copyTo(arrayOut); 522 StringBuilder message = new StringBuilder(); 523 boolean errorFound = false; 524 for (int i = 0; i < INPUTSIZE; i++) { 525 for (int j = 0; j < 2 ; j++) { 526 // Extract the inputs. 527 ArgumentsUcharFloat args = new ArgumentsUcharFloat(); 528 args.inV = arrayInV[i * 2 + j]; 529 // Figure out what the outputs should have been. 530 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 531 CoreMathVerifier.computeConvert(args, target); 532 // Validate the outputs. 533 boolean valid = true; 534 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 535 valid = false; 536 } 537 if (!valid) { 538 if (!errorFound) { 539 errorFound = true; 540 message.append("Input inV: "); 541 appendVariableToMessage(message, args.inV); 542 message.append("\n"); 543 message.append("Expected output out: "); 544 appendVariableToMessage(message, args.out); 545 message.append("\n"); 546 message.append("Actual output out: "); 547 appendVariableToMessage(message, arrayOut[i * 2 + j]); 548 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 549 message.append(" FAIL"); 550 } 551 message.append("\n"); 552 message.append("Errors at"); 553 } 554 message.append(" ["); 555 message.append(Integer.toString(i)); 556 message.append(", "); 557 message.append(Integer.toString(j)); 558 message.append("]"); 559 } 560 } 561 } 562 assertFalse("Incorrect output for checkConvertUchar2Float2" + 563 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 564 } 565 566 private void checkConvertUchar3Float3() { 567 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d31cb38b13bcd0fl, false, 8); 568 try { 569 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 570 script.forEach_testConvertFloat3Uchar3Float3(inV, out); 571 verifyResultsConvertUchar3Float3(inV, out, false); 572 out.destroy(); 573 } catch (Exception e) { 574 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString()); 575 } 576 try { 577 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 578 scriptRelaxed.forEach_testConvertFloat3Uchar3Float3(inV, out); 579 verifyResultsConvertUchar3Float3(inV, out, true); 580 out.destroy(); 581 } catch (Exception e) { 582 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString()); 583 } 584 inV.destroy(); 585 } 586 587 private void verifyResultsConvertUchar3Float3(Allocation inV, Allocation out, boolean relaxed) { 588 byte[] arrayInV = new byte[INPUTSIZE * 4]; 589 Arrays.fill(arrayInV, (byte) 42); 590 inV.copyTo(arrayInV); 591 float[] arrayOut = new float[INPUTSIZE * 4]; 592 Arrays.fill(arrayOut, (float) 42); 593 out.copyTo(arrayOut); 594 StringBuilder message = new StringBuilder(); 595 boolean errorFound = false; 596 for (int i = 0; i < INPUTSIZE; i++) { 597 for (int j = 0; j < 3 ; j++) { 598 // Extract the inputs. 599 ArgumentsUcharFloat args = new ArgumentsUcharFloat(); 600 args.inV = arrayInV[i * 4 + j]; 601 // Figure out what the outputs should have been. 602 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 603 CoreMathVerifier.computeConvert(args, target); 604 // Validate the outputs. 605 boolean valid = true; 606 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 607 valid = false; 608 } 609 if (!valid) { 610 if (!errorFound) { 611 errorFound = true; 612 message.append("Input inV: "); 613 appendVariableToMessage(message, args.inV); 614 message.append("\n"); 615 message.append("Expected output out: "); 616 appendVariableToMessage(message, args.out); 617 message.append("\n"); 618 message.append("Actual output out: "); 619 appendVariableToMessage(message, arrayOut[i * 4 + j]); 620 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 621 message.append(" FAIL"); 622 } 623 message.append("\n"); 624 message.append("Errors at"); 625 } 626 message.append(" ["); 627 message.append(Integer.toString(i)); 628 message.append(", "); 629 message.append(Integer.toString(j)); 630 message.append("]"); 631 } 632 } 633 } 634 assertFalse("Incorrect output for checkConvertUchar3Float3" + 635 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 636 } 637 638 private void checkConvertUchar4Float4() { 639 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d339453a756ededl, false, 8); 640 try { 641 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 642 script.forEach_testConvertFloat4Uchar4Float4(inV, out); 643 verifyResultsConvertUchar4Float4(inV, out, false); 644 out.destroy(); 645 } catch (Exception e) { 646 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString()); 647 } 648 try { 649 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 650 scriptRelaxed.forEach_testConvertFloat4Uchar4Float4(inV, out); 651 verifyResultsConvertUchar4Float4(inV, out, true); 652 out.destroy(); 653 } catch (Exception e) { 654 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString()); 655 } 656 inV.destroy(); 657 } 658 659 private void verifyResultsConvertUchar4Float4(Allocation inV, Allocation out, boolean relaxed) { 660 byte[] arrayInV = new byte[INPUTSIZE * 4]; 661 Arrays.fill(arrayInV, (byte) 42); 662 inV.copyTo(arrayInV); 663 float[] arrayOut = new float[INPUTSIZE * 4]; 664 Arrays.fill(arrayOut, (float) 42); 665 out.copyTo(arrayOut); 666 StringBuilder message = new StringBuilder(); 667 boolean errorFound = false; 668 for (int i = 0; i < INPUTSIZE; i++) { 669 for (int j = 0; j < 4 ; j++) { 670 // Extract the inputs. 671 ArgumentsUcharFloat args = new ArgumentsUcharFloat(); 672 args.inV = arrayInV[i * 4 + j]; 673 // Figure out what the outputs should have been. 674 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 675 CoreMathVerifier.computeConvert(args, target); 676 // Validate the outputs. 677 boolean valid = true; 678 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 679 valid = false; 680 } 681 if (!valid) { 682 if (!errorFound) { 683 errorFound = true; 684 message.append("Input inV: "); 685 appendVariableToMessage(message, args.inV); 686 message.append("\n"); 687 message.append("Expected output out: "); 688 appendVariableToMessage(message, args.out); 689 message.append("\n"); 690 message.append("Actual output out: "); 691 appendVariableToMessage(message, arrayOut[i * 4 + j]); 692 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 693 message.append(" FAIL"); 694 } 695 message.append("\n"); 696 message.append("Errors at"); 697 } 698 message.append(" ["); 699 message.append(Integer.toString(i)); 700 message.append(", "); 701 message.append(Integer.toString(j)); 702 message.append("]"); 703 } 704 } 705 } 706 assertFalse("Incorrect output for checkConvertUchar4Float4" + 707 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 708 } 709 710 public class ArgumentsShortFloat { 711 public short inV; 712 public Target.Floaty out; 713 } 714 715 private void checkConvertShort2Float2() { 716 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94ca184eff219172l, true, 15); 717 try { 718 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 719 script.forEach_testConvertFloat2Short2Float2(inV, out); 720 verifyResultsConvertShort2Float2(inV, out, false); 721 out.destroy(); 722 } catch (Exception e) { 723 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString()); 724 } 725 try { 726 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 727 scriptRelaxed.forEach_testConvertFloat2Short2Float2(inV, out); 728 verifyResultsConvertShort2Float2(inV, out, true); 729 out.destroy(); 730 } catch (Exception e) { 731 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString()); 732 } 733 inV.destroy(); 734 } 735 736 private void verifyResultsConvertShort2Float2(Allocation inV, Allocation out, boolean relaxed) { 737 short[] arrayInV = new short[INPUTSIZE * 2]; 738 Arrays.fill(arrayInV, (short) 42); 739 inV.copyTo(arrayInV); 740 float[] arrayOut = new float[INPUTSIZE * 2]; 741 Arrays.fill(arrayOut, (float) 42); 742 out.copyTo(arrayOut); 743 StringBuilder message = new StringBuilder(); 744 boolean errorFound = false; 745 for (int i = 0; i < INPUTSIZE; i++) { 746 for (int j = 0; j < 2 ; j++) { 747 // Extract the inputs. 748 ArgumentsShortFloat args = new ArgumentsShortFloat(); 749 args.inV = arrayInV[i * 2 + j]; 750 // Figure out what the outputs should have been. 751 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 752 CoreMathVerifier.computeConvert(args, target); 753 // Validate the outputs. 754 boolean valid = true; 755 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 756 valid = false; 757 } 758 if (!valid) { 759 if (!errorFound) { 760 errorFound = true; 761 message.append("Input inV: "); 762 appendVariableToMessage(message, args.inV); 763 message.append("\n"); 764 message.append("Expected output out: "); 765 appendVariableToMessage(message, args.out); 766 message.append("\n"); 767 message.append("Actual output out: "); 768 appendVariableToMessage(message, arrayOut[i * 2 + j]); 769 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 770 message.append(" FAIL"); 771 } 772 message.append("\n"); 773 message.append("Errors at"); 774 } 775 message.append(" ["); 776 message.append(Integer.toString(i)); 777 message.append(", "); 778 message.append(Integer.toString(j)); 779 message.append("]"); 780 } 781 } 782 } 783 assertFalse("Incorrect output for checkConvertShort2Float2" + 784 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 785 } 786 787 private void checkConvertShort3Float3() { 788 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cbe169f53cb250l, true, 15); 789 try { 790 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 791 script.forEach_testConvertFloat3Short3Float3(inV, out); 792 verifyResultsConvertShort3Float3(inV, out, false); 793 out.destroy(); 794 } catch (Exception e) { 795 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString()); 796 } 797 try { 798 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 799 scriptRelaxed.forEach_testConvertFloat3Short3Float3(inV, out); 800 verifyResultsConvertShort3Float3(inV, out, true); 801 out.destroy(); 802 } catch (Exception e) { 803 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString()); 804 } 805 inV.destroy(); 806 } 807 808 private void verifyResultsConvertShort3Float3(Allocation inV, Allocation out, boolean relaxed) { 809 short[] arrayInV = new short[INPUTSIZE * 4]; 810 Arrays.fill(arrayInV, (short) 42); 811 inV.copyTo(arrayInV); 812 float[] arrayOut = new float[INPUTSIZE * 4]; 813 Arrays.fill(arrayOut, (float) 42); 814 out.copyTo(arrayOut); 815 StringBuilder message = new StringBuilder(); 816 boolean errorFound = false; 817 for (int i = 0; i < INPUTSIZE; i++) { 818 for (int j = 0; j < 3 ; j++) { 819 // Extract the inputs. 820 ArgumentsShortFloat args = new ArgumentsShortFloat(); 821 args.inV = arrayInV[i * 4 + j]; 822 // Figure out what the outputs should have been. 823 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 824 CoreMathVerifier.computeConvert(args, target); 825 // Validate the outputs. 826 boolean valid = true; 827 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 828 valid = false; 829 } 830 if (!valid) { 831 if (!errorFound) { 832 errorFound = true; 833 message.append("Input inV: "); 834 appendVariableToMessage(message, args.inV); 835 message.append("\n"); 836 message.append("Expected output out: "); 837 appendVariableToMessage(message, args.out); 838 message.append("\n"); 839 message.append("Actual output out: "); 840 appendVariableToMessage(message, arrayOut[i * 4 + j]); 841 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 842 message.append(" FAIL"); 843 } 844 message.append("\n"); 845 message.append("Errors at"); 846 } 847 message.append(" ["); 848 message.append(Integer.toString(i)); 849 message.append(", "); 850 message.append(Integer.toString(j)); 851 message.append("]"); 852 } 853 } 854 } 855 assertFalse("Incorrect output for checkConvertShort3Float3" + 856 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 857 } 858 859 private void checkConvertShort4Float4() { 860 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94cdaa84eb57d32el, true, 15); 861 try { 862 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 863 script.forEach_testConvertFloat4Short4Float4(inV, out); 864 verifyResultsConvertShort4Float4(inV, out, false); 865 out.destroy(); 866 } catch (Exception e) { 867 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString()); 868 } 869 try { 870 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 871 scriptRelaxed.forEach_testConvertFloat4Short4Float4(inV, out); 872 verifyResultsConvertShort4Float4(inV, out, true); 873 out.destroy(); 874 } catch (Exception e) { 875 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString()); 876 } 877 inV.destroy(); 878 } 879 880 private void verifyResultsConvertShort4Float4(Allocation inV, Allocation out, boolean relaxed) { 881 short[] arrayInV = new short[INPUTSIZE * 4]; 882 Arrays.fill(arrayInV, (short) 42); 883 inV.copyTo(arrayInV); 884 float[] arrayOut = new float[INPUTSIZE * 4]; 885 Arrays.fill(arrayOut, (float) 42); 886 out.copyTo(arrayOut); 887 StringBuilder message = new StringBuilder(); 888 boolean errorFound = false; 889 for (int i = 0; i < INPUTSIZE; i++) { 890 for (int j = 0; j < 4 ; j++) { 891 // Extract the inputs. 892 ArgumentsShortFloat args = new ArgumentsShortFloat(); 893 args.inV = arrayInV[i * 4 + j]; 894 // Figure out what the outputs should have been. 895 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 896 CoreMathVerifier.computeConvert(args, target); 897 // Validate the outputs. 898 boolean valid = true; 899 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 900 valid = false; 901 } 902 if (!valid) { 903 if (!errorFound) { 904 errorFound = true; 905 message.append("Input inV: "); 906 appendVariableToMessage(message, args.inV); 907 message.append("\n"); 908 message.append("Expected output out: "); 909 appendVariableToMessage(message, args.out); 910 message.append("\n"); 911 message.append("Actual output out: "); 912 appendVariableToMessage(message, arrayOut[i * 4 + j]); 913 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 914 message.append(" FAIL"); 915 } 916 message.append("\n"); 917 message.append("Errors at"); 918 } 919 message.append(" ["); 920 message.append(Integer.toString(i)); 921 message.append(", "); 922 message.append(Integer.toString(j)); 923 message.append("]"); 924 } 925 } 926 } 927 assertFalse("Incorrect output for checkConvertShort4Float4" + 928 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 929 } 930 931 public class ArgumentsUshortFloat { 932 public short inV; 933 public Target.Floaty out; 934 } 935 936 private void checkConvertUshort2Float2() { 937 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36979962c6de12bl, false, 16); 938 try { 939 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 940 script.forEach_testConvertFloat2Ushort2Float2(inV, out); 941 verifyResultsConvertUshort2Float2(inV, out, false); 942 out.destroy(); 943 } catch (Exception e) { 944 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString()); 945 } 946 try { 947 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 948 scriptRelaxed.forEach_testConvertFloat2Ushort2Float2(inV, out); 949 verifyResultsConvertUshort2Float2(inV, out, true); 950 out.destroy(); 951 } catch (Exception e) { 952 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString()); 953 } 954 inV.destroy(); 955 } 956 957 private void verifyResultsConvertUshort2Float2(Allocation inV, Allocation out, boolean relaxed) { 958 short[] arrayInV = new short[INPUTSIZE * 2]; 959 Arrays.fill(arrayInV, (short) 42); 960 inV.copyTo(arrayInV); 961 float[] arrayOut = new float[INPUTSIZE * 2]; 962 Arrays.fill(arrayOut, (float) 42); 963 out.copyTo(arrayOut); 964 StringBuilder message = new StringBuilder(); 965 boolean errorFound = false; 966 for (int i = 0; i < INPUTSIZE; i++) { 967 for (int j = 0; j < 2 ; j++) { 968 // Extract the inputs. 969 ArgumentsUshortFloat args = new ArgumentsUshortFloat(); 970 args.inV = arrayInV[i * 2 + j]; 971 // Figure out what the outputs should have been. 972 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 973 CoreMathVerifier.computeConvert(args, target); 974 // Validate the outputs. 975 boolean valid = true; 976 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 977 valid = false; 978 } 979 if (!valid) { 980 if (!errorFound) { 981 errorFound = true; 982 message.append("Input inV: "); 983 appendVariableToMessage(message, args.inV); 984 message.append("\n"); 985 message.append("Expected output out: "); 986 appendVariableToMessage(message, args.out); 987 message.append("\n"); 988 message.append("Actual output out: "); 989 appendVariableToMessage(message, arrayOut[i * 2 + j]); 990 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 991 message.append(" FAIL"); 992 } 993 message.append("\n"); 994 message.append("Errors at"); 995 } 996 message.append(" ["); 997 message.append(Integer.toString(i)); 998 message.append(", "); 999 message.append(Integer.toString(j)); 1000 message.append("]"); 1001 } 1002 } 1003 } 1004 assertFalse("Incorrect output for checkConvertUshort2Float2" + 1005 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1006 } 1007 1008 private void checkConvertUshort3Float3() { 1009 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36b42b122890209l, false, 16); 1010 try { 1011 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1012 script.forEach_testConvertFloat3Ushort3Float3(inV, out); 1013 verifyResultsConvertUshort3Float3(inV, out, false); 1014 out.destroy(); 1015 } catch (Exception e) { 1016 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString()); 1017 } 1018 try { 1019 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1020 scriptRelaxed.forEach_testConvertFloat3Ushort3Float3(inV, out); 1021 verifyResultsConvertUshort3Float3(inV, out, true); 1022 out.destroy(); 1023 } catch (Exception e) { 1024 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString()); 1025 } 1026 inV.destroy(); 1027 } 1028 1029 private void verifyResultsConvertUshort3Float3(Allocation inV, Allocation out, boolean relaxed) { 1030 short[] arrayInV = new short[INPUTSIZE * 4]; 1031 Arrays.fill(arrayInV, (short) 42); 1032 inV.copyTo(arrayInV); 1033 float[] arrayOut = new float[INPUTSIZE * 4]; 1034 Arrays.fill(arrayOut, (float) 42); 1035 out.copyTo(arrayOut); 1036 StringBuilder message = new StringBuilder(); 1037 boolean errorFound = false; 1038 for (int i = 0; i < INPUTSIZE; i++) { 1039 for (int j = 0; j < 3 ; j++) { 1040 // Extract the inputs. 1041 ArgumentsUshortFloat args = new ArgumentsUshortFloat(); 1042 args.inV = arrayInV[i * 4 + j]; 1043 // Figure out what the outputs should have been. 1044 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1045 CoreMathVerifier.computeConvert(args, target); 1046 // Validate the outputs. 1047 boolean valid = true; 1048 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1049 valid = false; 1050 } 1051 if (!valid) { 1052 if (!errorFound) { 1053 errorFound = true; 1054 message.append("Input inV: "); 1055 appendVariableToMessage(message, args.inV); 1056 message.append("\n"); 1057 message.append("Expected output out: "); 1058 appendVariableToMessage(message, args.out); 1059 message.append("\n"); 1060 message.append("Actual output out: "); 1061 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1062 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1063 message.append(" FAIL"); 1064 } 1065 message.append("\n"); 1066 message.append("Errors at"); 1067 } 1068 message.append(" ["); 1069 message.append(Integer.toString(i)); 1070 message.append(", "); 1071 message.append(Integer.toString(j)); 1072 message.append("]"); 1073 } 1074 } 1075 } 1076 assertFalse("Incorrect output for checkConvertUshort3Float3" + 1077 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1078 } 1079 1080 private void checkConvertUshort4Float4() { 1081 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36d0bcc18a422e7l, false, 16); 1082 try { 1083 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1084 script.forEach_testConvertFloat4Ushort4Float4(inV, out); 1085 verifyResultsConvertUshort4Float4(inV, out, false); 1086 out.destroy(); 1087 } catch (Exception e) { 1088 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString()); 1089 } 1090 try { 1091 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1092 scriptRelaxed.forEach_testConvertFloat4Ushort4Float4(inV, out); 1093 verifyResultsConvertUshort4Float4(inV, out, true); 1094 out.destroy(); 1095 } catch (Exception e) { 1096 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString()); 1097 } 1098 inV.destroy(); 1099 } 1100 1101 private void verifyResultsConvertUshort4Float4(Allocation inV, Allocation out, boolean relaxed) { 1102 short[] arrayInV = new short[INPUTSIZE * 4]; 1103 Arrays.fill(arrayInV, (short) 42); 1104 inV.copyTo(arrayInV); 1105 float[] arrayOut = new float[INPUTSIZE * 4]; 1106 Arrays.fill(arrayOut, (float) 42); 1107 out.copyTo(arrayOut); 1108 StringBuilder message = new StringBuilder(); 1109 boolean errorFound = false; 1110 for (int i = 0; i < INPUTSIZE; i++) { 1111 for (int j = 0; j < 4 ; j++) { 1112 // Extract the inputs. 1113 ArgumentsUshortFloat args = new ArgumentsUshortFloat(); 1114 args.inV = arrayInV[i * 4 + j]; 1115 // Figure out what the outputs should have been. 1116 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1117 CoreMathVerifier.computeConvert(args, target); 1118 // Validate the outputs. 1119 boolean valid = true; 1120 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1121 valid = false; 1122 } 1123 if (!valid) { 1124 if (!errorFound) { 1125 errorFound = true; 1126 message.append("Input inV: "); 1127 appendVariableToMessage(message, args.inV); 1128 message.append("\n"); 1129 message.append("Expected output out: "); 1130 appendVariableToMessage(message, args.out); 1131 message.append("\n"); 1132 message.append("Actual output out: "); 1133 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1134 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1135 message.append(" FAIL"); 1136 } 1137 message.append("\n"); 1138 message.append("Errors at"); 1139 } 1140 message.append(" ["); 1141 message.append(Integer.toString(i)); 1142 message.append(", "); 1143 message.append(Integer.toString(j)); 1144 message.append("]"); 1145 } 1146 } 1147 } 1148 assertFalse("Incorrect output for checkConvertUshort4Float4" + 1149 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1150 } 1151 1152 public class ArgumentsIntFloat { 1153 public int inV; 1154 public Target.Floaty out; 1155 } 1156 1157 private void checkConvertInt2Float2() { 1158 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a52c7eb7402bfc5l, true, 31); 1159 try { 1160 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1161 script.forEach_testConvertFloat2Int2Float2(inV, out); 1162 verifyResultsConvertInt2Float2(inV, out, false); 1163 out.destroy(); 1164 } catch (Exception e) { 1165 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString()); 1166 } 1167 try { 1168 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1169 scriptRelaxed.forEach_testConvertFloat2Int2Float2(inV, out); 1170 verifyResultsConvertInt2Float2(inV, out, true); 1171 out.destroy(); 1172 } catch (Exception e) { 1173 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString()); 1174 } 1175 inV.destroy(); 1176 } 1177 1178 private void verifyResultsConvertInt2Float2(Allocation inV, Allocation out, boolean relaxed) { 1179 int[] arrayInV = new int[INPUTSIZE * 2]; 1180 Arrays.fill(arrayInV, (int) 42); 1181 inV.copyTo(arrayInV); 1182 float[] arrayOut = new float[INPUTSIZE * 2]; 1183 Arrays.fill(arrayOut, (float) 42); 1184 out.copyTo(arrayOut); 1185 StringBuilder message = new StringBuilder(); 1186 boolean errorFound = false; 1187 for (int i = 0; i < INPUTSIZE; i++) { 1188 for (int j = 0; j < 2 ; j++) { 1189 // Extract the inputs. 1190 ArgumentsIntFloat args = new ArgumentsIntFloat(); 1191 args.inV = arrayInV[i * 2 + j]; 1192 // Figure out what the outputs should have been. 1193 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1194 CoreMathVerifier.computeConvert(args, target); 1195 // Validate the outputs. 1196 boolean valid = true; 1197 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1198 valid = false; 1199 } 1200 if (!valid) { 1201 if (!errorFound) { 1202 errorFound = true; 1203 message.append("Input inV: "); 1204 appendVariableToMessage(message, args.inV); 1205 message.append("\n"); 1206 message.append("Expected output out: "); 1207 appendVariableToMessage(message, args.out); 1208 message.append("\n"); 1209 message.append("Actual output out: "); 1210 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1211 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1212 message.append(" FAIL"); 1213 } 1214 message.append("\n"); 1215 message.append("Errors at"); 1216 } 1217 message.append(" ["); 1218 message.append(Integer.toString(i)); 1219 message.append(", "); 1220 message.append(Integer.toString(j)); 1221 message.append("]"); 1222 } 1223 } 1224 } 1225 assertFalse("Incorrect output for checkConvertInt2Float2" + 1226 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1227 } 1228 1229 private void checkConvertInt3Float3() { 1230 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a5491066a1de0a3l, true, 31); 1231 try { 1232 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1233 script.forEach_testConvertFloat3Int3Float3(inV, out); 1234 verifyResultsConvertInt3Float3(inV, out, false); 1235 out.destroy(); 1236 } catch (Exception e) { 1237 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString()); 1238 } 1239 try { 1240 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1241 scriptRelaxed.forEach_testConvertFloat3Int3Float3(inV, out); 1242 verifyResultsConvertInt3Float3(inV, out, true); 1243 out.destroy(); 1244 } catch (Exception e) { 1245 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString()); 1246 } 1247 inV.destroy(); 1248 } 1249 1250 private void verifyResultsConvertInt3Float3(Allocation inV, Allocation out, boolean relaxed) { 1251 int[] arrayInV = new int[INPUTSIZE * 4]; 1252 Arrays.fill(arrayInV, (int) 42); 1253 inV.copyTo(arrayInV); 1254 float[] arrayOut = new float[INPUTSIZE * 4]; 1255 Arrays.fill(arrayOut, (float) 42); 1256 out.copyTo(arrayOut); 1257 StringBuilder message = new StringBuilder(); 1258 boolean errorFound = false; 1259 for (int i = 0; i < INPUTSIZE; i++) { 1260 for (int j = 0; j < 3 ; j++) { 1261 // Extract the inputs. 1262 ArgumentsIntFloat args = new ArgumentsIntFloat(); 1263 args.inV = arrayInV[i * 4 + j]; 1264 // Figure out what the outputs should have been. 1265 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1266 CoreMathVerifier.computeConvert(args, target); 1267 // Validate the outputs. 1268 boolean valid = true; 1269 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1270 valid = false; 1271 } 1272 if (!valid) { 1273 if (!errorFound) { 1274 errorFound = true; 1275 message.append("Input inV: "); 1276 appendVariableToMessage(message, args.inV); 1277 message.append("\n"); 1278 message.append("Expected output out: "); 1279 appendVariableToMessage(message, args.out); 1280 message.append("\n"); 1281 message.append("Actual output out: "); 1282 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1283 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1284 message.append(" FAIL"); 1285 } 1286 message.append("\n"); 1287 message.append("Errors at"); 1288 } 1289 message.append(" ["); 1290 message.append(Integer.toString(i)); 1291 message.append(", "); 1292 message.append(Integer.toString(j)); 1293 message.append("]"); 1294 } 1295 } 1296 } 1297 assertFalse("Incorrect output for checkConvertInt3Float3" + 1298 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1299 } 1300 1301 private void checkConvertInt4Float4() { 1302 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a565a2160390181l, true, 31); 1303 try { 1304 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1305 script.forEach_testConvertFloat4Int4Float4(inV, out); 1306 verifyResultsConvertInt4Float4(inV, out, false); 1307 out.destroy(); 1308 } catch (Exception e) { 1309 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString()); 1310 } 1311 try { 1312 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1313 scriptRelaxed.forEach_testConvertFloat4Int4Float4(inV, out); 1314 verifyResultsConvertInt4Float4(inV, out, true); 1315 out.destroy(); 1316 } catch (Exception e) { 1317 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString()); 1318 } 1319 inV.destroy(); 1320 } 1321 1322 private void verifyResultsConvertInt4Float4(Allocation inV, Allocation out, boolean relaxed) { 1323 int[] arrayInV = new int[INPUTSIZE * 4]; 1324 Arrays.fill(arrayInV, (int) 42); 1325 inV.copyTo(arrayInV); 1326 float[] arrayOut = new float[INPUTSIZE * 4]; 1327 Arrays.fill(arrayOut, (float) 42); 1328 out.copyTo(arrayOut); 1329 StringBuilder message = new StringBuilder(); 1330 boolean errorFound = false; 1331 for (int i = 0; i < INPUTSIZE; i++) { 1332 for (int j = 0; j < 4 ; j++) { 1333 // Extract the inputs. 1334 ArgumentsIntFloat args = new ArgumentsIntFloat(); 1335 args.inV = arrayInV[i * 4 + j]; 1336 // Figure out what the outputs should have been. 1337 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1338 CoreMathVerifier.computeConvert(args, target); 1339 // Validate the outputs. 1340 boolean valid = true; 1341 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1342 valid = false; 1343 } 1344 if (!valid) { 1345 if (!errorFound) { 1346 errorFound = true; 1347 message.append("Input inV: "); 1348 appendVariableToMessage(message, args.inV); 1349 message.append("\n"); 1350 message.append("Expected output out: "); 1351 appendVariableToMessage(message, args.out); 1352 message.append("\n"); 1353 message.append("Actual output out: "); 1354 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1355 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1356 message.append(" FAIL"); 1357 } 1358 message.append("\n"); 1359 message.append("Errors at"); 1360 } 1361 message.append(" ["); 1362 message.append(Integer.toString(i)); 1363 message.append(", "); 1364 message.append(Integer.toString(j)); 1365 message.append("]"); 1366 } 1367 } 1368 } 1369 assertFalse("Incorrect output for checkConvertInt4Float4" + 1370 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1371 } 1372 1373 public class ArgumentsUintFloat { 1374 public int inV; 1375 public Target.Floaty out; 1376 } 1377 1378 private void checkConvertUint2Float2() { 1379 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e081390684cc46l, false, 32); 1380 try { 1381 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1382 script.forEach_testConvertFloat2Uint2Float2(inV, out); 1383 verifyResultsConvertUint2Float2(inV, out, false); 1384 out.destroy(); 1385 } catch (Exception e) { 1386 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString()); 1387 } 1388 try { 1389 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1390 scriptRelaxed.forEach_testConvertFloat2Uint2Float2(inV, out); 1391 verifyResultsConvertUint2Float2(inV, out, true); 1392 out.destroy(); 1393 } catch (Exception e) { 1394 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString()); 1395 } 1396 inV.destroy(); 1397 } 1398 1399 private void verifyResultsConvertUint2Float2(Allocation inV, Allocation out, boolean relaxed) { 1400 int[] arrayInV = new int[INPUTSIZE * 2]; 1401 Arrays.fill(arrayInV, (int) 42); 1402 inV.copyTo(arrayInV); 1403 float[] arrayOut = new float[INPUTSIZE * 2]; 1404 Arrays.fill(arrayOut, (float) 42); 1405 out.copyTo(arrayOut); 1406 StringBuilder message = new StringBuilder(); 1407 boolean errorFound = false; 1408 for (int i = 0; i < INPUTSIZE; i++) { 1409 for (int j = 0; j < 2 ; j++) { 1410 // Extract the inputs. 1411 ArgumentsUintFloat args = new ArgumentsUintFloat(); 1412 args.inV = arrayInV[i * 2 + j]; 1413 // Figure out what the outputs should have been. 1414 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1415 CoreMathVerifier.computeConvert(args, target); 1416 // Validate the outputs. 1417 boolean valid = true; 1418 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1419 valid = false; 1420 } 1421 if (!valid) { 1422 if (!errorFound) { 1423 errorFound = true; 1424 message.append("Input inV: "); 1425 appendVariableToMessage(message, args.inV); 1426 message.append("\n"); 1427 message.append("Expected output out: "); 1428 appendVariableToMessage(message, args.out); 1429 message.append("\n"); 1430 message.append("Actual output out: "); 1431 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1432 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1433 message.append(" FAIL"); 1434 } 1435 message.append("\n"); 1436 message.append("Errors at"); 1437 } 1438 message.append(" ["); 1439 message.append(Integer.toString(i)); 1440 message.append(", "); 1441 message.append(Integer.toString(j)); 1442 message.append("]"); 1443 } 1444 } 1445 } 1446 assertFalse("Incorrect output for checkConvertUint2Float2" + 1447 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1448 } 1449 1450 private void checkConvertUint3Float3() { 1451 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e24a53fc9fed24l, false, 32); 1452 try { 1453 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1454 script.forEach_testConvertFloat3Uint3Float3(inV, out); 1455 verifyResultsConvertUint3Float3(inV, out, false); 1456 out.destroy(); 1457 } catch (Exception e) { 1458 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString()); 1459 } 1460 try { 1461 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1462 scriptRelaxed.forEach_testConvertFloat3Uint3Float3(inV, out); 1463 verifyResultsConvertUint3Float3(inV, out, true); 1464 out.destroy(); 1465 } catch (Exception e) { 1466 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString()); 1467 } 1468 inV.destroy(); 1469 } 1470 1471 private void verifyResultsConvertUint3Float3(Allocation inV, Allocation out, boolean relaxed) { 1472 int[] arrayInV = new int[INPUTSIZE * 4]; 1473 Arrays.fill(arrayInV, (int) 42); 1474 inV.copyTo(arrayInV); 1475 float[] arrayOut = new float[INPUTSIZE * 4]; 1476 Arrays.fill(arrayOut, (float) 42); 1477 out.copyTo(arrayOut); 1478 StringBuilder message = new StringBuilder(); 1479 boolean errorFound = false; 1480 for (int i = 0; i < INPUTSIZE; i++) { 1481 for (int j = 0; j < 3 ; j++) { 1482 // Extract the inputs. 1483 ArgumentsUintFloat args = new ArgumentsUintFloat(); 1484 args.inV = arrayInV[i * 4 + j]; 1485 // Figure out what the outputs should have been. 1486 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1487 CoreMathVerifier.computeConvert(args, target); 1488 // Validate the outputs. 1489 boolean valid = true; 1490 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1491 valid = false; 1492 } 1493 if (!valid) { 1494 if (!errorFound) { 1495 errorFound = true; 1496 message.append("Input inV: "); 1497 appendVariableToMessage(message, args.inV); 1498 message.append("\n"); 1499 message.append("Expected output out: "); 1500 appendVariableToMessage(message, args.out); 1501 message.append("\n"); 1502 message.append("Actual output out: "); 1503 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1504 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1505 message.append(" FAIL"); 1506 } 1507 message.append("\n"); 1508 message.append("Errors at"); 1509 } 1510 message.append(" ["); 1511 message.append(Integer.toString(i)); 1512 message.append(", "); 1513 message.append(Integer.toString(j)); 1514 message.append("]"); 1515 } 1516 } 1517 } 1518 assertFalse("Incorrect output for checkConvertUint3Float3" + 1519 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1520 } 1521 1522 private void checkConvertUint4Float4() { 1523 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4136ef2bb0e02l, false, 32); 1524 try { 1525 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1526 script.forEach_testConvertFloat4Uint4Float4(inV, out); 1527 verifyResultsConvertUint4Float4(inV, out, false); 1528 out.destroy(); 1529 } catch (Exception e) { 1530 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString()); 1531 } 1532 try { 1533 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1534 scriptRelaxed.forEach_testConvertFloat4Uint4Float4(inV, out); 1535 verifyResultsConvertUint4Float4(inV, out, true); 1536 out.destroy(); 1537 } catch (Exception e) { 1538 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString()); 1539 } 1540 inV.destroy(); 1541 } 1542 1543 private void verifyResultsConvertUint4Float4(Allocation inV, Allocation out, boolean relaxed) { 1544 int[] arrayInV = new int[INPUTSIZE * 4]; 1545 Arrays.fill(arrayInV, (int) 42); 1546 inV.copyTo(arrayInV); 1547 float[] arrayOut = new float[INPUTSIZE * 4]; 1548 Arrays.fill(arrayOut, (float) 42); 1549 out.copyTo(arrayOut); 1550 StringBuilder message = new StringBuilder(); 1551 boolean errorFound = false; 1552 for (int i = 0; i < INPUTSIZE; i++) { 1553 for (int j = 0; j < 4 ; j++) { 1554 // Extract the inputs. 1555 ArgumentsUintFloat args = new ArgumentsUintFloat(); 1556 args.inV = arrayInV[i * 4 + j]; 1557 // Figure out what the outputs should have been. 1558 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1559 CoreMathVerifier.computeConvert(args, target); 1560 // Validate the outputs. 1561 boolean valid = true; 1562 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1563 valid = false; 1564 } 1565 if (!valid) { 1566 if (!errorFound) { 1567 errorFound = true; 1568 message.append("Input inV: "); 1569 appendVariableToMessage(message, args.inV); 1570 message.append("\n"); 1571 message.append("Expected output out: "); 1572 appendVariableToMessage(message, args.out); 1573 message.append("\n"); 1574 message.append("Actual output out: "); 1575 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1576 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1577 message.append(" FAIL"); 1578 } 1579 message.append("\n"); 1580 message.append("Errors at"); 1581 } 1582 message.append(" ["); 1583 message.append(Integer.toString(i)); 1584 message.append(", "); 1585 message.append(Integer.toString(j)); 1586 message.append("]"); 1587 } 1588 } 1589 } 1590 assertFalse("Incorrect output for checkConvertUint4Float4" + 1591 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1592 } 1593 1594 public class ArgumentsFloatChar { 1595 public float inV; 1596 public byte out; 1597 } 1598 1599 private void checkConvertFloat2Char2() { 1600 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb25829789662l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 1601 try { 1602 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1603 script.forEach_testConvertChar2Float2Char2(inV, out); 1604 verifyResultsConvertFloat2Char2(inV, out, false); 1605 out.destroy(); 1606 } catch (Exception e) { 1607 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString()); 1608 } 1609 try { 1610 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1611 scriptRelaxed.forEach_testConvertChar2Float2Char2(inV, out); 1612 verifyResultsConvertFloat2Char2(inV, out, true); 1613 out.destroy(); 1614 } catch (Exception e) { 1615 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString()); 1616 } 1617 inV.destroy(); 1618 } 1619 1620 private void verifyResultsConvertFloat2Char2(Allocation inV, Allocation out, boolean relaxed) { 1621 float[] arrayInV = new float[INPUTSIZE * 2]; 1622 Arrays.fill(arrayInV, (float) 42); 1623 inV.copyTo(arrayInV); 1624 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1625 Arrays.fill(arrayOut, (byte) 42); 1626 out.copyTo(arrayOut); 1627 StringBuilder message = new StringBuilder(); 1628 boolean errorFound = false; 1629 for (int i = 0; i < INPUTSIZE; i++) { 1630 for (int j = 0; j < 2 ; j++) { 1631 // Extract the inputs. 1632 ArgumentsFloatChar args = new ArgumentsFloatChar(); 1633 args.inV = arrayInV[i * 2 + j]; 1634 // Figure out what the outputs should have been. 1635 CoreMathVerifier.computeConvert(args); 1636 // Validate the outputs. 1637 boolean valid = true; 1638 if (args.out != arrayOut[i * 2 + j]) { 1639 valid = false; 1640 } 1641 if (!valid) { 1642 if (!errorFound) { 1643 errorFound = true; 1644 message.append("Input inV: "); 1645 appendVariableToMessage(message, args.inV); 1646 message.append("\n"); 1647 message.append("Expected output out: "); 1648 appendVariableToMessage(message, args.out); 1649 message.append("\n"); 1650 message.append("Actual output out: "); 1651 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1652 if (args.out != arrayOut[i * 2 + j]) { 1653 message.append(" FAIL"); 1654 } 1655 message.append("\n"); 1656 message.append("Errors at"); 1657 } 1658 message.append(" ["); 1659 message.append(Integer.toString(i)); 1660 message.append(", "); 1661 message.append(Integer.toString(j)); 1662 message.append("]"); 1663 } 1664 } 1665 } 1666 assertFalse("Incorrect output for checkConvertFloat2Char2" + 1667 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1668 } 1669 1670 private void checkConvertFloat3Char3() { 1671 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbcf988805b56l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 1672 try { 1673 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1674 script.forEach_testConvertChar3Float3Char3(inV, out); 1675 verifyResultsConvertFloat3Char3(inV, out, false); 1676 out.destroy(); 1677 } catch (Exception e) { 1678 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString()); 1679 } 1680 try { 1681 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1682 scriptRelaxed.forEach_testConvertChar3Float3Char3(inV, out); 1683 verifyResultsConvertFloat3Char3(inV, out, true); 1684 out.destroy(); 1685 } catch (Exception e) { 1686 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString()); 1687 } 1688 inV.destroy(); 1689 } 1690 1691 private void verifyResultsConvertFloat3Char3(Allocation inV, Allocation out, boolean relaxed) { 1692 float[] arrayInV = new float[INPUTSIZE * 4]; 1693 Arrays.fill(arrayInV, (float) 42); 1694 inV.copyTo(arrayInV); 1695 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1696 Arrays.fill(arrayOut, (byte) 42); 1697 out.copyTo(arrayOut); 1698 StringBuilder message = new StringBuilder(); 1699 boolean errorFound = false; 1700 for (int i = 0; i < INPUTSIZE; i++) { 1701 for (int j = 0; j < 3 ; j++) { 1702 // Extract the inputs. 1703 ArgumentsFloatChar args = new ArgumentsFloatChar(); 1704 args.inV = arrayInV[i * 4 + j]; 1705 // Figure out what the outputs should have been. 1706 CoreMathVerifier.computeConvert(args); 1707 // Validate the outputs. 1708 boolean valid = true; 1709 if (args.out != arrayOut[i * 4 + j]) { 1710 valid = false; 1711 } 1712 if (!valid) { 1713 if (!errorFound) { 1714 errorFound = true; 1715 message.append("Input inV: "); 1716 appendVariableToMessage(message, args.inV); 1717 message.append("\n"); 1718 message.append("Expected output out: "); 1719 appendVariableToMessage(message, args.out); 1720 message.append("\n"); 1721 message.append("Actual output out: "); 1722 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1723 if (args.out != arrayOut[i * 4 + j]) { 1724 message.append(" FAIL"); 1725 } 1726 message.append("\n"); 1727 message.append("Errors at"); 1728 } 1729 message.append(" ["); 1730 message.append(Integer.toString(i)); 1731 message.append(", "); 1732 message.append(Integer.toString(j)); 1733 message.append("]"); 1734 } 1735 } 1736 } 1737 assertFalse("Incorrect output for checkConvertFloat3Char3" + 1738 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1739 } 1740 1741 private void checkConvertFloat4Char4() { 1742 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc79ae788204al, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 1743 try { 1744 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1745 script.forEach_testConvertChar4Float4Char4(inV, out); 1746 verifyResultsConvertFloat4Char4(inV, out, false); 1747 out.destroy(); 1748 } catch (Exception e) { 1749 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString()); 1750 } 1751 try { 1752 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1753 scriptRelaxed.forEach_testConvertChar4Float4Char4(inV, out); 1754 verifyResultsConvertFloat4Char4(inV, out, true); 1755 out.destroy(); 1756 } catch (Exception e) { 1757 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString()); 1758 } 1759 inV.destroy(); 1760 } 1761 1762 private void verifyResultsConvertFloat4Char4(Allocation inV, Allocation out, boolean relaxed) { 1763 float[] arrayInV = new float[INPUTSIZE * 4]; 1764 Arrays.fill(arrayInV, (float) 42); 1765 inV.copyTo(arrayInV); 1766 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1767 Arrays.fill(arrayOut, (byte) 42); 1768 out.copyTo(arrayOut); 1769 StringBuilder message = new StringBuilder(); 1770 boolean errorFound = false; 1771 for (int i = 0; i < INPUTSIZE; i++) { 1772 for (int j = 0; j < 4 ; j++) { 1773 // Extract the inputs. 1774 ArgumentsFloatChar args = new ArgumentsFloatChar(); 1775 args.inV = arrayInV[i * 4 + j]; 1776 // Figure out what the outputs should have been. 1777 CoreMathVerifier.computeConvert(args); 1778 // Validate the outputs. 1779 boolean valid = true; 1780 if (args.out != arrayOut[i * 4 + j]) { 1781 valid = false; 1782 } 1783 if (!valid) { 1784 if (!errorFound) { 1785 errorFound = true; 1786 message.append("Input inV: "); 1787 appendVariableToMessage(message, args.inV); 1788 message.append("\n"); 1789 message.append("Expected output out: "); 1790 appendVariableToMessage(message, args.out); 1791 message.append("\n"); 1792 message.append("Actual output out: "); 1793 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1794 if (args.out != arrayOut[i * 4 + j]) { 1795 message.append(" FAIL"); 1796 } 1797 message.append("\n"); 1798 message.append("Errors at"); 1799 } 1800 message.append(" ["); 1801 message.append(Integer.toString(i)); 1802 message.append(", "); 1803 message.append(Integer.toString(j)); 1804 message.append("]"); 1805 } 1806 } 1807 } 1808 assertFalse("Incorrect output for checkConvertFloat4Char4" + 1809 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1810 } 1811 1812 public class ArgumentsCharChar { 1813 public byte inV; 1814 public byte out; 1815 } 1816 1817 private void checkConvertChar2Char2() { 1818 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8618777d5086da2l, true, 7); 1819 try { 1820 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1821 script.forEach_testConvertChar2Char2Char2(inV, out); 1822 verifyResultsConvertChar2Char2(inV, out, false); 1823 out.destroy(); 1824 } catch (Exception e) { 1825 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString()); 1826 } 1827 try { 1828 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1829 scriptRelaxed.forEach_testConvertChar2Char2Char2(inV, out); 1830 verifyResultsConvertChar2Char2(inV, out, true); 1831 out.destroy(); 1832 } catch (Exception e) { 1833 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString()); 1834 } 1835 inV.destroy(); 1836 } 1837 1838 private void verifyResultsConvertChar2Char2(Allocation inV, Allocation out, boolean relaxed) { 1839 byte[] arrayInV = new byte[INPUTSIZE * 2]; 1840 Arrays.fill(arrayInV, (byte) 42); 1841 inV.copyTo(arrayInV); 1842 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1843 Arrays.fill(arrayOut, (byte) 42); 1844 out.copyTo(arrayOut); 1845 StringBuilder message = new StringBuilder(); 1846 boolean errorFound = false; 1847 for (int i = 0; i < INPUTSIZE; i++) { 1848 for (int j = 0; j < 2 ; j++) { 1849 // Extract the inputs. 1850 ArgumentsCharChar args = new ArgumentsCharChar(); 1851 args.inV = arrayInV[i * 2 + j]; 1852 // Figure out what the outputs should have been. 1853 CoreMathVerifier.computeConvert(args); 1854 // Validate the outputs. 1855 boolean valid = true; 1856 if (args.out != arrayOut[i * 2 + j]) { 1857 valid = false; 1858 } 1859 if (!valid) { 1860 if (!errorFound) { 1861 errorFound = true; 1862 message.append("Input inV: "); 1863 appendVariableToMessage(message, args.inV); 1864 message.append("\n"); 1865 message.append("Expected output out: "); 1866 appendVariableToMessage(message, args.out); 1867 message.append("\n"); 1868 message.append("Actual output out: "); 1869 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1870 if (args.out != arrayOut[i * 2 + j]) { 1871 message.append(" FAIL"); 1872 } 1873 message.append("\n"); 1874 message.append("Errors at"); 1875 } 1876 message.append(" ["); 1877 message.append(Integer.toString(i)); 1878 message.append(", "); 1879 message.append(Integer.toString(j)); 1880 message.append("]"); 1881 } 1882 } 1883 } 1884 assertFalse("Incorrect output for checkConvertChar2Char2" + 1885 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1886 } 1887 1888 private void checkConvertChar3Char3() { 1889 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861921934103296l, true, 7); 1890 try { 1891 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1892 script.forEach_testConvertChar3Char3Char3(inV, out); 1893 verifyResultsConvertChar3Char3(inV, out, false); 1894 out.destroy(); 1895 } catch (Exception e) { 1896 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString()); 1897 } 1898 try { 1899 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1900 scriptRelaxed.forEach_testConvertChar3Char3Char3(inV, out); 1901 verifyResultsConvertChar3Char3(inV, out, true); 1902 out.destroy(); 1903 } catch (Exception e) { 1904 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString()); 1905 } 1906 inV.destroy(); 1907 } 1908 1909 private void verifyResultsConvertChar3Char3(Allocation inV, Allocation out, boolean relaxed) { 1910 byte[] arrayInV = new byte[INPUTSIZE * 4]; 1911 Arrays.fill(arrayInV, (byte) 42); 1912 inV.copyTo(arrayInV); 1913 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1914 Arrays.fill(arrayOut, (byte) 42); 1915 out.copyTo(arrayOut); 1916 StringBuilder message = new StringBuilder(); 1917 boolean errorFound = false; 1918 for (int i = 0; i < INPUTSIZE; i++) { 1919 for (int j = 0; j < 3 ; j++) { 1920 // Extract the inputs. 1921 ArgumentsCharChar args = new ArgumentsCharChar(); 1922 args.inV = arrayInV[i * 4 + j]; 1923 // Figure out what the outputs should have been. 1924 CoreMathVerifier.computeConvert(args); 1925 // Validate the outputs. 1926 boolean valid = true; 1927 if (args.out != arrayOut[i * 4 + j]) { 1928 valid = false; 1929 } 1930 if (!valid) { 1931 if (!errorFound) { 1932 errorFound = true; 1933 message.append("Input inV: "); 1934 appendVariableToMessage(message, args.inV); 1935 message.append("\n"); 1936 message.append("Expected output out: "); 1937 appendVariableToMessage(message, args.out); 1938 message.append("\n"); 1939 message.append("Actual output out: "); 1940 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1941 if (args.out != arrayOut[i * 4 + j]) { 1942 message.append(" FAIL"); 1943 } 1944 message.append("\n"); 1945 message.append("Errors at"); 1946 } 1947 message.append(" ["); 1948 message.append(Integer.toString(i)); 1949 message.append(", "); 1950 message.append(Integer.toString(j)); 1951 message.append("]"); 1952 } 1953 } 1954 } 1955 assertFalse("Incorrect output for checkConvertChar3Char3" + 1956 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1957 } 1958 1959 private void checkConvertChar4Char4() { 1960 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619cba9317f78al, true, 7); 1961 try { 1962 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1963 script.forEach_testConvertChar4Char4Char4(inV, out); 1964 verifyResultsConvertChar4Char4(inV, out, false); 1965 out.destroy(); 1966 } catch (Exception e) { 1967 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString()); 1968 } 1969 try { 1970 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1971 scriptRelaxed.forEach_testConvertChar4Char4Char4(inV, out); 1972 verifyResultsConvertChar4Char4(inV, out, true); 1973 out.destroy(); 1974 } catch (Exception e) { 1975 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString()); 1976 } 1977 inV.destroy(); 1978 } 1979 1980 private void verifyResultsConvertChar4Char4(Allocation inV, Allocation out, boolean relaxed) { 1981 byte[] arrayInV = new byte[INPUTSIZE * 4]; 1982 Arrays.fill(arrayInV, (byte) 42); 1983 inV.copyTo(arrayInV); 1984 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1985 Arrays.fill(arrayOut, (byte) 42); 1986 out.copyTo(arrayOut); 1987 StringBuilder message = new StringBuilder(); 1988 boolean errorFound = false; 1989 for (int i = 0; i < INPUTSIZE; i++) { 1990 for (int j = 0; j < 4 ; j++) { 1991 // Extract the inputs. 1992 ArgumentsCharChar args = new ArgumentsCharChar(); 1993 args.inV = arrayInV[i * 4 + j]; 1994 // Figure out what the outputs should have been. 1995 CoreMathVerifier.computeConvert(args); 1996 // Validate the outputs. 1997 boolean valid = true; 1998 if (args.out != arrayOut[i * 4 + j]) { 1999 valid = false; 2000 } 2001 if (!valid) { 2002 if (!errorFound) { 2003 errorFound = true; 2004 message.append("Input inV: "); 2005 appendVariableToMessage(message, args.inV); 2006 message.append("\n"); 2007 message.append("Expected output out: "); 2008 appendVariableToMessage(message, args.out); 2009 message.append("\n"); 2010 message.append("Actual output out: "); 2011 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2012 if (args.out != arrayOut[i * 4 + j]) { 2013 message.append(" FAIL"); 2014 } 2015 message.append("\n"); 2016 message.append("Errors at"); 2017 } 2018 message.append(" ["); 2019 message.append(Integer.toString(i)); 2020 message.append(", "); 2021 message.append(Integer.toString(j)); 2022 message.append("]"); 2023 } 2024 } 2025 } 2026 assertFalse("Incorrect output for checkConvertChar4Char4" + 2027 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2028 } 2029 2030 public class ArgumentsUcharChar { 2031 public byte inV; 2032 public byte out; 2033 } 2034 2035 private void checkConvertUchar2Char2() { 2036 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef40c5678a7a23l, false, 7); 2037 try { 2038 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2039 script.forEach_testConvertChar2Uchar2Char2(inV, out); 2040 verifyResultsConvertUchar2Char2(inV, out, false); 2041 out.destroy(); 2042 } catch (Exception e) { 2043 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString()); 2044 } 2045 try { 2046 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2047 scriptRelaxed.forEach_testConvertChar2Uchar2Char2(inV, out); 2048 verifyResultsConvertUchar2Char2(inV, out, true); 2049 out.destroy(); 2050 } catch (Exception e) { 2051 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString()); 2052 } 2053 inV.destroy(); 2054 } 2055 2056 private void verifyResultsConvertUchar2Char2(Allocation inV, Allocation out, boolean relaxed) { 2057 byte[] arrayInV = new byte[INPUTSIZE * 2]; 2058 Arrays.fill(arrayInV, (byte) 42); 2059 inV.copyTo(arrayInV); 2060 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2061 Arrays.fill(arrayOut, (byte) 42); 2062 out.copyTo(arrayOut); 2063 StringBuilder message = new StringBuilder(); 2064 boolean errorFound = false; 2065 for (int i = 0; i < INPUTSIZE; i++) { 2066 for (int j = 0; j < 2 ; j++) { 2067 // Extract the inputs. 2068 ArgumentsUcharChar args = new ArgumentsUcharChar(); 2069 args.inV = arrayInV[i * 2 + j]; 2070 // Figure out what the outputs should have been. 2071 CoreMathVerifier.computeConvert(args); 2072 // Validate the outputs. 2073 boolean valid = true; 2074 if (args.out != arrayOut[i * 2 + j]) { 2075 valid = false; 2076 } 2077 if (!valid) { 2078 if (!errorFound) { 2079 errorFound = true; 2080 message.append("Input inV: "); 2081 appendVariableToMessage(message, args.inV); 2082 message.append("\n"); 2083 message.append("Expected output out: "); 2084 appendVariableToMessage(message, args.out); 2085 message.append("\n"); 2086 message.append("Actual output out: "); 2087 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2088 if (args.out != arrayOut[i * 2 + j]) { 2089 message.append(" FAIL"); 2090 } 2091 message.append("\n"); 2092 message.append("Errors at"); 2093 } 2094 message.append(" ["); 2095 message.append(Integer.toString(i)); 2096 message.append(", "); 2097 message.append(Integer.toString(j)); 2098 message.append("]"); 2099 } 2100 } 2101 } 2102 assertFalse("Incorrect output for checkConvertUchar2Char2" + 2103 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2104 } 2105 2106 private void checkConvertUchar3Char3() { 2107 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4b66c6923f17l, false, 7); 2108 try { 2109 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2110 script.forEach_testConvertChar3Uchar3Char3(inV, out); 2111 verifyResultsConvertUchar3Char3(inV, out, false); 2112 out.destroy(); 2113 } catch (Exception e) { 2114 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString()); 2115 } 2116 try { 2117 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2118 scriptRelaxed.forEach_testConvertChar3Uchar3Char3(inV, out); 2119 verifyResultsConvertUchar3Char3(inV, out, true); 2120 out.destroy(); 2121 } catch (Exception e) { 2122 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString()); 2123 } 2124 inV.destroy(); 2125 } 2126 2127 private void verifyResultsConvertUchar3Char3(Allocation inV, Allocation out, boolean relaxed) { 2128 byte[] arrayInV = new byte[INPUTSIZE * 4]; 2129 Arrays.fill(arrayInV, (byte) 42); 2130 inV.copyTo(arrayInV); 2131 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2132 Arrays.fill(arrayOut, (byte) 42); 2133 out.copyTo(arrayOut); 2134 StringBuilder message = new StringBuilder(); 2135 boolean errorFound = false; 2136 for (int i = 0; i < INPUTSIZE; i++) { 2137 for (int j = 0; j < 3 ; j++) { 2138 // Extract the inputs. 2139 ArgumentsUcharChar args = new ArgumentsUcharChar(); 2140 args.inV = arrayInV[i * 4 + j]; 2141 // Figure out what the outputs should have been. 2142 CoreMathVerifier.computeConvert(args); 2143 // Validate the outputs. 2144 boolean valid = true; 2145 if (args.out != arrayOut[i * 4 + j]) { 2146 valid = false; 2147 } 2148 if (!valid) { 2149 if (!errorFound) { 2150 errorFound = true; 2151 message.append("Input inV: "); 2152 appendVariableToMessage(message, args.inV); 2153 message.append("\n"); 2154 message.append("Expected output out: "); 2155 appendVariableToMessage(message, args.out); 2156 message.append("\n"); 2157 message.append("Actual output out: "); 2158 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2159 if (args.out != arrayOut[i * 4 + j]) { 2160 message.append(" FAIL"); 2161 } 2162 message.append("\n"); 2163 message.append("Errors at"); 2164 } 2165 message.append(" ["); 2166 message.append(Integer.toString(i)); 2167 message.append(", "); 2168 message.append(Integer.toString(j)); 2169 message.append("]"); 2170 } 2171 } 2172 } 2173 assertFalse("Incorrect output for checkConvertUchar3Char3" + 2174 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2175 } 2176 2177 private void checkConvertUchar4Char4() { 2178 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef5608259a040bl, false, 7); 2179 try { 2180 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2181 script.forEach_testConvertChar4Uchar4Char4(inV, out); 2182 verifyResultsConvertUchar4Char4(inV, out, false); 2183 out.destroy(); 2184 } catch (Exception e) { 2185 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString()); 2186 } 2187 try { 2188 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2189 scriptRelaxed.forEach_testConvertChar4Uchar4Char4(inV, out); 2190 verifyResultsConvertUchar4Char4(inV, out, true); 2191 out.destroy(); 2192 } catch (Exception e) { 2193 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString()); 2194 } 2195 inV.destroy(); 2196 } 2197 2198 private void verifyResultsConvertUchar4Char4(Allocation inV, Allocation out, boolean relaxed) { 2199 byte[] arrayInV = new byte[INPUTSIZE * 4]; 2200 Arrays.fill(arrayInV, (byte) 42); 2201 inV.copyTo(arrayInV); 2202 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2203 Arrays.fill(arrayOut, (byte) 42); 2204 out.copyTo(arrayOut); 2205 StringBuilder message = new StringBuilder(); 2206 boolean errorFound = false; 2207 for (int i = 0; i < INPUTSIZE; i++) { 2208 for (int j = 0; j < 4 ; j++) { 2209 // Extract the inputs. 2210 ArgumentsUcharChar args = new ArgumentsUcharChar(); 2211 args.inV = arrayInV[i * 4 + j]; 2212 // Figure out what the outputs should have been. 2213 CoreMathVerifier.computeConvert(args); 2214 // Validate the outputs. 2215 boolean valid = true; 2216 if (args.out != arrayOut[i * 4 + j]) { 2217 valid = false; 2218 } 2219 if (!valid) { 2220 if (!errorFound) { 2221 errorFound = true; 2222 message.append("Input inV: "); 2223 appendVariableToMessage(message, args.inV); 2224 message.append("\n"); 2225 message.append("Expected output out: "); 2226 appendVariableToMessage(message, args.out); 2227 message.append("\n"); 2228 message.append("Actual output out: "); 2229 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2230 if (args.out != arrayOut[i * 4 + j]) { 2231 message.append(" FAIL"); 2232 } 2233 message.append("\n"); 2234 message.append("Errors at"); 2235 } 2236 message.append(" ["); 2237 message.append(Integer.toString(i)); 2238 message.append(", "); 2239 message.append(Integer.toString(j)); 2240 message.append("]"); 2241 } 2242 } 2243 } 2244 assertFalse("Incorrect output for checkConvertUchar4Char4" + 2245 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2246 } 2247 2248 public class ArgumentsShortChar { 2249 public short inV; 2250 public byte out; 2251 } 2252 2253 private void checkConvertShort2Char2() { 2254 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab650215c60866l, true, 7); 2255 try { 2256 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2257 script.forEach_testConvertChar2Short2Char2(inV, out); 2258 verifyResultsConvertShort2Char2(inV, out, false); 2259 out.destroy(); 2260 } catch (Exception e) { 2261 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString()); 2262 } 2263 try { 2264 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2265 scriptRelaxed.forEach_testConvertChar2Short2Char2(inV, out); 2266 verifyResultsConvertShort2Char2(inV, out, true); 2267 out.destroy(); 2268 } catch (Exception e) { 2269 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString()); 2270 } 2271 inV.destroy(); 2272 } 2273 2274 private void verifyResultsConvertShort2Char2(Allocation inV, Allocation out, boolean relaxed) { 2275 short[] arrayInV = new short[INPUTSIZE * 2]; 2276 Arrays.fill(arrayInV, (short) 42); 2277 inV.copyTo(arrayInV); 2278 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2279 Arrays.fill(arrayOut, (byte) 42); 2280 out.copyTo(arrayOut); 2281 StringBuilder message = new StringBuilder(); 2282 boolean errorFound = false; 2283 for (int i = 0; i < INPUTSIZE; i++) { 2284 for (int j = 0; j < 2 ; j++) { 2285 // Extract the inputs. 2286 ArgumentsShortChar args = new ArgumentsShortChar(); 2287 args.inV = arrayInV[i * 2 + j]; 2288 // Figure out what the outputs should have been. 2289 CoreMathVerifier.computeConvert(args); 2290 // Validate the outputs. 2291 boolean valid = true; 2292 if (args.out != arrayOut[i * 2 + j]) { 2293 valid = false; 2294 } 2295 if (!valid) { 2296 if (!errorFound) { 2297 errorFound = true; 2298 message.append("Input inV: "); 2299 appendVariableToMessage(message, args.inV); 2300 message.append("\n"); 2301 message.append("Expected output out: "); 2302 appendVariableToMessage(message, args.out); 2303 message.append("\n"); 2304 message.append("Actual output out: "); 2305 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2306 if (args.out != arrayOut[i * 2 + j]) { 2307 message.append(" FAIL"); 2308 } 2309 message.append("\n"); 2310 message.append("Errors at"); 2311 } 2312 message.append(" ["); 2313 message.append(Integer.toString(i)); 2314 message.append(", "); 2315 message.append(Integer.toString(j)); 2316 message.append("]"); 2317 } 2318 } 2319 } 2320 assertFalse("Incorrect output for checkConvertShort2Char2" + 2321 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2322 } 2323 2324 private void checkConvertShort3Char3() { 2325 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab6fa374cdcd5al, true, 7); 2326 try { 2327 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2328 script.forEach_testConvertChar3Short3Char3(inV, out); 2329 verifyResultsConvertShort3Char3(inV, out, false); 2330 out.destroy(); 2331 } catch (Exception e) { 2332 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString()); 2333 } 2334 try { 2335 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2336 scriptRelaxed.forEach_testConvertChar3Short3Char3(inV, out); 2337 verifyResultsConvertShort3Char3(inV, out, true); 2338 out.destroy(); 2339 } catch (Exception e) { 2340 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString()); 2341 } 2342 inV.destroy(); 2343 } 2344 2345 private void verifyResultsConvertShort3Char3(Allocation inV, Allocation out, boolean relaxed) { 2346 short[] arrayInV = new short[INPUTSIZE * 4]; 2347 Arrays.fill(arrayInV, (short) 42); 2348 inV.copyTo(arrayInV); 2349 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2350 Arrays.fill(arrayOut, (byte) 42); 2351 out.copyTo(arrayOut); 2352 StringBuilder message = new StringBuilder(); 2353 boolean errorFound = false; 2354 for (int i = 0; i < INPUTSIZE; i++) { 2355 for (int j = 0; j < 3 ; j++) { 2356 // Extract the inputs. 2357 ArgumentsShortChar args = new ArgumentsShortChar(); 2358 args.inV = arrayInV[i * 4 + j]; 2359 // Figure out what the outputs should have been. 2360 CoreMathVerifier.computeConvert(args); 2361 // Validate the outputs. 2362 boolean valid = true; 2363 if (args.out != arrayOut[i * 4 + j]) { 2364 valid = false; 2365 } 2366 if (!valid) { 2367 if (!errorFound) { 2368 errorFound = true; 2369 message.append("Input inV: "); 2370 appendVariableToMessage(message, args.inV); 2371 message.append("\n"); 2372 message.append("Expected output out: "); 2373 appendVariableToMessage(message, args.out); 2374 message.append("\n"); 2375 message.append("Actual output out: "); 2376 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2377 if (args.out != arrayOut[i * 4 + j]) { 2378 message.append(" FAIL"); 2379 } 2380 message.append("\n"); 2381 message.append("Errors at"); 2382 } 2383 message.append(" ["); 2384 message.append(Integer.toString(i)); 2385 message.append(", "); 2386 message.append(Integer.toString(j)); 2387 message.append("]"); 2388 } 2389 } 2390 } 2391 assertFalse("Incorrect output for checkConvertShort3Char3" + 2392 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2393 } 2394 2395 private void checkConvertShort4Char4() { 2396 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7a44d3d5924el, true, 7); 2397 try { 2398 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2399 script.forEach_testConvertChar4Short4Char4(inV, out); 2400 verifyResultsConvertShort4Char4(inV, out, false); 2401 out.destroy(); 2402 } catch (Exception e) { 2403 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString()); 2404 } 2405 try { 2406 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2407 scriptRelaxed.forEach_testConvertChar4Short4Char4(inV, out); 2408 verifyResultsConvertShort4Char4(inV, out, true); 2409 out.destroy(); 2410 } catch (Exception e) { 2411 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString()); 2412 } 2413 inV.destroy(); 2414 } 2415 2416 private void verifyResultsConvertShort4Char4(Allocation inV, Allocation out, boolean relaxed) { 2417 short[] arrayInV = new short[INPUTSIZE * 4]; 2418 Arrays.fill(arrayInV, (short) 42); 2419 inV.copyTo(arrayInV); 2420 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2421 Arrays.fill(arrayOut, (byte) 42); 2422 out.copyTo(arrayOut); 2423 StringBuilder message = new StringBuilder(); 2424 boolean errorFound = false; 2425 for (int i = 0; i < INPUTSIZE; i++) { 2426 for (int j = 0; j < 4 ; j++) { 2427 // Extract the inputs. 2428 ArgumentsShortChar args = new ArgumentsShortChar(); 2429 args.inV = arrayInV[i * 4 + j]; 2430 // Figure out what the outputs should have been. 2431 CoreMathVerifier.computeConvert(args); 2432 // Validate the outputs. 2433 boolean valid = true; 2434 if (args.out != arrayOut[i * 4 + j]) { 2435 valid = false; 2436 } 2437 if (!valid) { 2438 if (!errorFound) { 2439 errorFound = true; 2440 message.append("Input inV: "); 2441 appendVariableToMessage(message, args.inV); 2442 message.append("\n"); 2443 message.append("Expected output out: "); 2444 appendVariableToMessage(message, args.out); 2445 message.append("\n"); 2446 message.append("Actual output out: "); 2447 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2448 if (args.out != arrayOut[i * 4 + j]) { 2449 message.append(" FAIL"); 2450 } 2451 message.append("\n"); 2452 message.append("Errors at"); 2453 } 2454 message.append(" ["); 2455 message.append(Integer.toString(i)); 2456 message.append(", "); 2457 message.append(Integer.toString(j)); 2458 message.append("]"); 2459 } 2460 } 2461 } 2462 assertFalse("Incorrect output for checkConvertShort4Char4" + 2463 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2464 } 2465 2466 public class ArgumentsUshortChar { 2467 public short inV; 2468 public byte out; 2469 } 2470 2471 private void checkConvertUshort2Char2() { 2472 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d798509b19e2211l, false, 7); 2473 try { 2474 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2475 script.forEach_testConvertChar2Ushort2Char2(inV, out); 2476 verifyResultsConvertUshort2Char2(inV, out, false); 2477 out.destroy(); 2478 } catch (Exception e) { 2479 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString()); 2480 } 2481 try { 2482 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2483 scriptRelaxed.forEach_testConvertChar2Ushort2Char2(inV, out); 2484 verifyResultsConvertUshort2Char2(inV, out, true); 2485 out.destroy(); 2486 } catch (Exception e) { 2487 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString()); 2488 } 2489 inV.destroy(); 2490 } 2491 2492 private void verifyResultsConvertUshort2Char2(Allocation inV, Allocation out, boolean relaxed) { 2493 short[] arrayInV = new short[INPUTSIZE * 2]; 2494 Arrays.fill(arrayInV, (short) 42); 2495 inV.copyTo(arrayInV); 2496 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2497 Arrays.fill(arrayOut, (byte) 42); 2498 out.copyTo(arrayOut); 2499 StringBuilder message = new StringBuilder(); 2500 boolean errorFound = false; 2501 for (int i = 0; i < INPUTSIZE; i++) { 2502 for (int j = 0; j < 2 ; j++) { 2503 // Extract the inputs. 2504 ArgumentsUshortChar args = new ArgumentsUshortChar(); 2505 args.inV = arrayInV[i * 2 + j]; 2506 // Figure out what the outputs should have been. 2507 CoreMathVerifier.computeConvert(args); 2508 // Validate the outputs. 2509 boolean valid = true; 2510 if (args.out != arrayOut[i * 2 + j]) { 2511 valid = false; 2512 } 2513 if (!valid) { 2514 if (!errorFound) { 2515 errorFound = true; 2516 message.append("Input inV: "); 2517 appendVariableToMessage(message, args.inV); 2518 message.append("\n"); 2519 message.append("Expected output out: "); 2520 appendVariableToMessage(message, args.out); 2521 message.append("\n"); 2522 message.append("Actual output out: "); 2523 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2524 if (args.out != arrayOut[i * 2 + j]) { 2525 message.append(" FAIL"); 2526 } 2527 message.append("\n"); 2528 message.append("Errors at"); 2529 } 2530 message.append(" ["); 2531 message.append(Integer.toString(i)); 2532 message.append(", "); 2533 message.append(Integer.toString(j)); 2534 message.append("]"); 2535 } 2536 } 2537 } 2538 assertFalse("Incorrect output for checkConvertUshort2Char2" + 2539 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2540 } 2541 2542 private void checkConvertUshort3Char3() { 2543 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d798fab10a5e705l, false, 7); 2544 try { 2545 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2546 script.forEach_testConvertChar3Ushort3Char3(inV, out); 2547 verifyResultsConvertUshort3Char3(inV, out, false); 2548 out.destroy(); 2549 } catch (Exception e) { 2550 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString()); 2551 } 2552 try { 2553 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2554 scriptRelaxed.forEach_testConvertChar3Ushort3Char3(inV, out); 2555 verifyResultsConvertUshort3Char3(inV, out, true); 2556 out.destroy(); 2557 } catch (Exception e) { 2558 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString()); 2559 } 2560 inV.destroy(); 2561 } 2562 2563 private void verifyResultsConvertUshort3Char3(Allocation inV, Allocation out, boolean relaxed) { 2564 short[] arrayInV = new short[INPUTSIZE * 4]; 2565 Arrays.fill(arrayInV, (short) 42); 2566 inV.copyTo(arrayInV); 2567 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2568 Arrays.fill(arrayOut, (byte) 42); 2569 out.copyTo(arrayOut); 2570 StringBuilder message = new StringBuilder(); 2571 boolean errorFound = false; 2572 for (int i = 0; i < INPUTSIZE; i++) { 2573 for (int j = 0; j < 3 ; j++) { 2574 // Extract the inputs. 2575 ArgumentsUshortChar args = new ArgumentsUshortChar(); 2576 args.inV = arrayInV[i * 4 + j]; 2577 // Figure out what the outputs should have been. 2578 CoreMathVerifier.computeConvert(args); 2579 // Validate the outputs. 2580 boolean valid = true; 2581 if (args.out != arrayOut[i * 4 + j]) { 2582 valid = false; 2583 } 2584 if (!valid) { 2585 if (!errorFound) { 2586 errorFound = true; 2587 message.append("Input inV: "); 2588 appendVariableToMessage(message, args.inV); 2589 message.append("\n"); 2590 message.append("Expected output out: "); 2591 appendVariableToMessage(message, args.out); 2592 message.append("\n"); 2593 message.append("Actual output out: "); 2594 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2595 if (args.out != arrayOut[i * 4 + j]) { 2596 message.append(" FAIL"); 2597 } 2598 message.append("\n"); 2599 message.append("Errors at"); 2600 } 2601 message.append(" ["); 2602 message.append(Integer.toString(i)); 2603 message.append(", "); 2604 message.append(Integer.toString(j)); 2605 message.append("]"); 2606 } 2607 } 2608 } 2609 assertFalse("Incorrect output for checkConvertUshort3Char3" + 2610 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2611 } 2612 2613 private void checkConvertUshort4Char4() { 2614 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799a4c6fadabf9l, false, 7); 2615 try { 2616 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2617 script.forEach_testConvertChar4Ushort4Char4(inV, out); 2618 verifyResultsConvertUshort4Char4(inV, out, false); 2619 out.destroy(); 2620 } catch (Exception e) { 2621 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString()); 2622 } 2623 try { 2624 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2625 scriptRelaxed.forEach_testConvertChar4Ushort4Char4(inV, out); 2626 verifyResultsConvertUshort4Char4(inV, out, true); 2627 out.destroy(); 2628 } catch (Exception e) { 2629 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString()); 2630 } 2631 inV.destroy(); 2632 } 2633 2634 private void verifyResultsConvertUshort4Char4(Allocation inV, Allocation out, boolean relaxed) { 2635 short[] arrayInV = new short[INPUTSIZE * 4]; 2636 Arrays.fill(arrayInV, (short) 42); 2637 inV.copyTo(arrayInV); 2638 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2639 Arrays.fill(arrayOut, (byte) 42); 2640 out.copyTo(arrayOut); 2641 StringBuilder message = new StringBuilder(); 2642 boolean errorFound = false; 2643 for (int i = 0; i < INPUTSIZE; i++) { 2644 for (int j = 0; j < 4 ; j++) { 2645 // Extract the inputs. 2646 ArgumentsUshortChar args = new ArgumentsUshortChar(); 2647 args.inV = arrayInV[i * 4 + j]; 2648 // Figure out what the outputs should have been. 2649 CoreMathVerifier.computeConvert(args); 2650 // Validate the outputs. 2651 boolean valid = true; 2652 if (args.out != arrayOut[i * 4 + j]) { 2653 valid = false; 2654 } 2655 if (!valid) { 2656 if (!errorFound) { 2657 errorFound = true; 2658 message.append("Input inV: "); 2659 appendVariableToMessage(message, args.inV); 2660 message.append("\n"); 2661 message.append("Expected output out: "); 2662 appendVariableToMessage(message, args.out); 2663 message.append("\n"); 2664 message.append("Actual output out: "); 2665 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2666 if (args.out != arrayOut[i * 4 + j]) { 2667 message.append(" FAIL"); 2668 } 2669 message.append("\n"); 2670 message.append("Errors at"); 2671 } 2672 message.append(" ["); 2673 message.append(Integer.toString(i)); 2674 message.append(", "); 2675 message.append(Integer.toString(j)); 2676 message.append("]"); 2677 } 2678 } 2679 } 2680 assertFalse("Incorrect output for checkConvertUshort4Char4" + 2681 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2682 } 2683 2684 public class ArgumentsIntChar { 2685 public int inV; 2686 public byte out; 2687 } 2688 2689 private void checkConvertInt2Char2() { 2690 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f5147364256dfl, true, 7); 2691 try { 2692 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2693 script.forEach_testConvertChar2Int2Char2(inV, out); 2694 verifyResultsConvertInt2Char2(inV, out, false); 2695 out.destroy(); 2696 } catch (Exception e) { 2697 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString()); 2698 } 2699 try { 2700 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2701 scriptRelaxed.forEach_testConvertChar2Int2Char2(inV, out); 2702 verifyResultsConvertInt2Char2(inV, out, true); 2703 out.destroy(); 2704 } catch (Exception e) { 2705 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString()); 2706 } 2707 inV.destroy(); 2708 } 2709 2710 private void verifyResultsConvertInt2Char2(Allocation inV, Allocation out, boolean relaxed) { 2711 int[] arrayInV = new int[INPUTSIZE * 2]; 2712 Arrays.fill(arrayInV, (int) 42); 2713 inV.copyTo(arrayInV); 2714 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2715 Arrays.fill(arrayOut, (byte) 42); 2716 out.copyTo(arrayOut); 2717 StringBuilder message = new StringBuilder(); 2718 boolean errorFound = false; 2719 for (int i = 0; i < INPUTSIZE; i++) { 2720 for (int j = 0; j < 2 ; j++) { 2721 // Extract the inputs. 2722 ArgumentsIntChar args = new ArgumentsIntChar(); 2723 args.inV = arrayInV[i * 2 + j]; 2724 // Figure out what the outputs should have been. 2725 CoreMathVerifier.computeConvert(args); 2726 // Validate the outputs. 2727 boolean valid = true; 2728 if (args.out != arrayOut[i * 2 + j]) { 2729 valid = false; 2730 } 2731 if (!valid) { 2732 if (!errorFound) { 2733 errorFound = true; 2734 message.append("Input inV: "); 2735 appendVariableToMessage(message, args.inV); 2736 message.append("\n"); 2737 message.append("Expected output out: "); 2738 appendVariableToMessage(message, args.out); 2739 message.append("\n"); 2740 message.append("Actual output out: "); 2741 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2742 if (args.out != arrayOut[i * 2 + j]) { 2743 message.append(" FAIL"); 2744 } 2745 message.append("\n"); 2746 message.append("Errors at"); 2747 } 2748 message.append(" ["); 2749 message.append(Integer.toString(i)); 2750 message.append(", "); 2751 message.append(Integer.toString(j)); 2752 message.append("]"); 2753 } 2754 } 2755 } 2756 assertFalse("Incorrect output for checkConvertInt2Char2" + 2757 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2758 } 2759 2760 private void checkConvertInt3Char3() { 2761 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5be8954a1bd3l, true, 7); 2762 try { 2763 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2764 script.forEach_testConvertChar3Int3Char3(inV, out); 2765 verifyResultsConvertInt3Char3(inV, out, false); 2766 out.destroy(); 2767 } catch (Exception e) { 2768 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString()); 2769 } 2770 try { 2771 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2772 scriptRelaxed.forEach_testConvertChar3Int3Char3(inV, out); 2773 verifyResultsConvertInt3Char3(inV, out, true); 2774 out.destroy(); 2775 } catch (Exception e) { 2776 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString()); 2777 } 2778 inV.destroy(); 2779 } 2780 2781 private void verifyResultsConvertInt3Char3(Allocation inV, Allocation out, boolean relaxed) { 2782 int[] arrayInV = new int[INPUTSIZE * 4]; 2783 Arrays.fill(arrayInV, (int) 42); 2784 inV.copyTo(arrayInV); 2785 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2786 Arrays.fill(arrayOut, (byte) 42); 2787 out.copyTo(arrayOut); 2788 StringBuilder message = new StringBuilder(); 2789 boolean errorFound = false; 2790 for (int i = 0; i < INPUTSIZE; i++) { 2791 for (int j = 0; j < 3 ; j++) { 2792 // Extract the inputs. 2793 ArgumentsIntChar args = new ArgumentsIntChar(); 2794 args.inV = arrayInV[i * 4 + j]; 2795 // Figure out what the outputs should have been. 2796 CoreMathVerifier.computeConvert(args); 2797 // Validate the outputs. 2798 boolean valid = true; 2799 if (args.out != arrayOut[i * 4 + j]) { 2800 valid = false; 2801 } 2802 if (!valid) { 2803 if (!errorFound) { 2804 errorFound = true; 2805 message.append("Input inV: "); 2806 appendVariableToMessage(message, args.inV); 2807 message.append("\n"); 2808 message.append("Expected output out: "); 2809 appendVariableToMessage(message, args.out); 2810 message.append("\n"); 2811 message.append("Actual output out: "); 2812 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2813 if (args.out != arrayOut[i * 4 + j]) { 2814 message.append(" FAIL"); 2815 } 2816 message.append("\n"); 2817 message.append("Errors at"); 2818 } 2819 message.append(" ["); 2820 message.append(Integer.toString(i)); 2821 message.append(", "); 2822 message.append(Integer.toString(j)); 2823 message.append("]"); 2824 } 2825 } 2826 } 2827 assertFalse("Incorrect output for checkConvertInt3Char3" + 2828 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2829 } 2830 2831 private void checkConvertInt4Char4() { 2832 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f6689f451e0c7l, true, 7); 2833 try { 2834 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2835 script.forEach_testConvertChar4Int4Char4(inV, out); 2836 verifyResultsConvertInt4Char4(inV, out, false); 2837 out.destroy(); 2838 } catch (Exception e) { 2839 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString()); 2840 } 2841 try { 2842 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2843 scriptRelaxed.forEach_testConvertChar4Int4Char4(inV, out); 2844 verifyResultsConvertInt4Char4(inV, out, true); 2845 out.destroy(); 2846 } catch (Exception e) { 2847 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString()); 2848 } 2849 inV.destroy(); 2850 } 2851 2852 private void verifyResultsConvertInt4Char4(Allocation inV, Allocation out, boolean relaxed) { 2853 int[] arrayInV = new int[INPUTSIZE * 4]; 2854 Arrays.fill(arrayInV, (int) 42); 2855 inV.copyTo(arrayInV); 2856 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2857 Arrays.fill(arrayOut, (byte) 42); 2858 out.copyTo(arrayOut); 2859 StringBuilder message = new StringBuilder(); 2860 boolean errorFound = false; 2861 for (int i = 0; i < INPUTSIZE; i++) { 2862 for (int j = 0; j < 4 ; j++) { 2863 // Extract the inputs. 2864 ArgumentsIntChar args = new ArgumentsIntChar(); 2865 args.inV = arrayInV[i * 4 + j]; 2866 // Figure out what the outputs should have been. 2867 CoreMathVerifier.computeConvert(args); 2868 // Validate the outputs. 2869 boolean valid = true; 2870 if (args.out != arrayOut[i * 4 + j]) { 2871 valid = false; 2872 } 2873 if (!valid) { 2874 if (!errorFound) { 2875 errorFound = true; 2876 message.append("Input inV: "); 2877 appendVariableToMessage(message, args.inV); 2878 message.append("\n"); 2879 message.append("Expected output out: "); 2880 appendVariableToMessage(message, args.out); 2881 message.append("\n"); 2882 message.append("Actual output out: "); 2883 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2884 if (args.out != arrayOut[i * 4 + j]) { 2885 message.append(" FAIL"); 2886 } 2887 message.append("\n"); 2888 message.append("Errors at"); 2889 } 2890 message.append(" ["); 2891 message.append(Integer.toString(i)); 2892 message.append(", "); 2893 message.append(Integer.toString(j)); 2894 message.append("]"); 2895 } 2896 } 2897 } 2898 assertFalse("Incorrect output for checkConvertInt4Char4" + 2899 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2900 } 2901 2902 public class ArgumentsUintChar { 2903 public int inV; 2904 public byte out; 2905 } 2906 2907 private void checkConvertUint2Char2() { 2908 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d083133b67ae2l, false, 7); 2909 try { 2910 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2911 script.forEach_testConvertChar2Uint2Char2(inV, out); 2912 verifyResultsConvertUint2Char2(inV, out, false); 2913 out.destroy(); 2914 } catch (Exception e) { 2915 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString()); 2916 } 2917 try { 2918 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2919 scriptRelaxed.forEach_testConvertChar2Uint2Char2(inV, out); 2920 verifyResultsConvertUint2Char2(inV, out, true); 2921 out.destroy(); 2922 } catch (Exception e) { 2923 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString()); 2924 } 2925 inV.destroy(); 2926 } 2927 2928 private void verifyResultsConvertUint2Char2(Allocation inV, Allocation out, boolean relaxed) { 2929 int[] arrayInV = new int[INPUTSIZE * 2]; 2930 Arrays.fill(arrayInV, (int) 42); 2931 inV.copyTo(arrayInV); 2932 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2933 Arrays.fill(arrayOut, (byte) 42); 2934 out.copyTo(arrayOut); 2935 StringBuilder message = new StringBuilder(); 2936 boolean errorFound = false; 2937 for (int i = 0; i < INPUTSIZE; i++) { 2938 for (int j = 0; j < 2 ; j++) { 2939 // Extract the inputs. 2940 ArgumentsUintChar args = new ArgumentsUintChar(); 2941 args.inV = arrayInV[i * 2 + j]; 2942 // Figure out what the outputs should have been. 2943 CoreMathVerifier.computeConvert(args); 2944 // Validate the outputs. 2945 boolean valid = true; 2946 if (args.out != arrayOut[i * 2 + j]) { 2947 valid = false; 2948 } 2949 if (!valid) { 2950 if (!errorFound) { 2951 errorFound = true; 2952 message.append("Input inV: "); 2953 appendVariableToMessage(message, args.inV); 2954 message.append("\n"); 2955 message.append("Expected output out: "); 2956 appendVariableToMessage(message, args.out); 2957 message.append("\n"); 2958 message.append("Actual output out: "); 2959 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2960 if (args.out != arrayOut[i * 2 + j]) { 2961 message.append(" FAIL"); 2962 } 2963 message.append("\n"); 2964 message.append("Errors at"); 2965 } 2966 message.append(" ["); 2967 message.append(Integer.toString(i)); 2968 message.append(", "); 2969 message.append(Integer.toString(j)); 2970 message.append("]"); 2971 } 2972 } 2973 } 2974 assertFalse("Incorrect output for checkConvertUint2Char2" + 2975 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2976 } 2977 2978 private void checkConvertUint3Char3() { 2979 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d12d292be3fd6l, false, 7); 2980 try { 2981 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2982 script.forEach_testConvertChar3Uint3Char3(inV, out); 2983 verifyResultsConvertUint3Char3(inV, out, false); 2984 out.destroy(); 2985 } catch (Exception e) { 2986 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString()); 2987 } 2988 try { 2989 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2990 scriptRelaxed.forEach_testConvertChar3Uint3Char3(inV, out); 2991 verifyResultsConvertUint3Char3(inV, out, true); 2992 out.destroy(); 2993 } catch (Exception e) { 2994 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString()); 2995 } 2996 inV.destroy(); 2997 } 2998 2999 private void verifyResultsConvertUint3Char3(Allocation inV, Allocation out, boolean relaxed) { 3000 int[] arrayInV = new int[INPUTSIZE * 4]; 3001 Arrays.fill(arrayInV, (int) 42); 3002 inV.copyTo(arrayInV); 3003 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3004 Arrays.fill(arrayOut, (byte) 42); 3005 out.copyTo(arrayOut); 3006 StringBuilder message = new StringBuilder(); 3007 boolean errorFound = false; 3008 for (int i = 0; i < INPUTSIZE; i++) { 3009 for (int j = 0; j < 3 ; j++) { 3010 // Extract the inputs. 3011 ArgumentsUintChar args = new ArgumentsUintChar(); 3012 args.inV = arrayInV[i * 4 + j]; 3013 // Figure out what the outputs should have been. 3014 CoreMathVerifier.computeConvert(args); 3015 // Validate the outputs. 3016 boolean valid = true; 3017 if (args.out != arrayOut[i * 4 + j]) { 3018 valid = false; 3019 } 3020 if (!valid) { 3021 if (!errorFound) { 3022 errorFound = true; 3023 message.append("Input inV: "); 3024 appendVariableToMessage(message, args.inV); 3025 message.append("\n"); 3026 message.append("Expected output out: "); 3027 appendVariableToMessage(message, args.out); 3028 message.append("\n"); 3029 message.append("Actual output out: "); 3030 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3031 if (args.out != arrayOut[i * 4 + j]) { 3032 message.append(" FAIL"); 3033 } 3034 message.append("\n"); 3035 message.append("Errors at"); 3036 } 3037 message.append(" ["); 3038 message.append(Integer.toString(i)); 3039 message.append(", "); 3040 message.append(Integer.toString(j)); 3041 message.append("]"); 3042 } 3043 } 3044 } 3045 assertFalse("Incorrect output for checkConvertUint3Char3" + 3046 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3047 } 3048 3049 private void checkConvertUint4Char4() { 3050 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1d73f1c604cal, false, 7); 3051 try { 3052 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 3053 script.forEach_testConvertChar4Uint4Char4(inV, out); 3054 verifyResultsConvertUint4Char4(inV, out, false); 3055 out.destroy(); 3056 } catch (Exception e) { 3057 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString()); 3058 } 3059 try { 3060 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 3061 scriptRelaxed.forEach_testConvertChar4Uint4Char4(inV, out); 3062 verifyResultsConvertUint4Char4(inV, out, true); 3063 out.destroy(); 3064 } catch (Exception e) { 3065 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString()); 3066 } 3067 inV.destroy(); 3068 } 3069 3070 private void verifyResultsConvertUint4Char4(Allocation inV, Allocation out, boolean relaxed) { 3071 int[] arrayInV = new int[INPUTSIZE * 4]; 3072 Arrays.fill(arrayInV, (int) 42); 3073 inV.copyTo(arrayInV); 3074 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3075 Arrays.fill(arrayOut, (byte) 42); 3076 out.copyTo(arrayOut); 3077 StringBuilder message = new StringBuilder(); 3078 boolean errorFound = false; 3079 for (int i = 0; i < INPUTSIZE; i++) { 3080 for (int j = 0; j < 4 ; j++) { 3081 // Extract the inputs. 3082 ArgumentsUintChar args = new ArgumentsUintChar(); 3083 args.inV = arrayInV[i * 4 + j]; 3084 // Figure out what the outputs should have been. 3085 CoreMathVerifier.computeConvert(args); 3086 // Validate the outputs. 3087 boolean valid = true; 3088 if (args.out != arrayOut[i * 4 + j]) { 3089 valid = false; 3090 } 3091 if (!valid) { 3092 if (!errorFound) { 3093 errorFound = true; 3094 message.append("Input inV: "); 3095 appendVariableToMessage(message, args.inV); 3096 message.append("\n"); 3097 message.append("Expected output out: "); 3098 appendVariableToMessage(message, args.out); 3099 message.append("\n"); 3100 message.append("Actual output out: "); 3101 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3102 if (args.out != arrayOut[i * 4 + j]) { 3103 message.append(" FAIL"); 3104 } 3105 message.append("\n"); 3106 message.append("Errors at"); 3107 } 3108 message.append(" ["); 3109 message.append(Integer.toString(i)); 3110 message.append(", "); 3111 message.append(Integer.toString(j)); 3112 message.append("]"); 3113 } 3114 } 3115 } 3116 assertFalse("Incorrect output for checkConvertUint4Char4" + 3117 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3118 } 3119 3120 public class ArgumentsFloatUchar { 3121 public float inV; 3122 public byte out; 3123 } 3124 3125 private void checkConvertFloat2Uchar2() { 3126 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb52b2f4fac15b79l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 3127 try { 3128 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3129 script.forEach_testConvertUchar2Float2Uchar2(inV, out); 3130 verifyResultsConvertFloat2Uchar2(inV, out, false); 3131 out.destroy(); 3132 } catch (Exception e) { 3133 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString()); 3134 } 3135 try { 3136 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3137 scriptRelaxed.forEach_testConvertUchar2Float2Uchar2(inV, out); 3138 verifyResultsConvertFloat2Uchar2(inV, out, true); 3139 out.destroy(); 3140 } catch (Exception e) { 3141 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString()); 3142 } 3143 inV.destroy(); 3144 } 3145 3146 private void verifyResultsConvertFloat2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3147 float[] arrayInV = new float[INPUTSIZE * 2]; 3148 Arrays.fill(arrayInV, (float) 42); 3149 inV.copyTo(arrayInV); 3150 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3151 Arrays.fill(arrayOut, (byte) 42); 3152 out.copyTo(arrayOut); 3153 StringBuilder message = new StringBuilder(); 3154 boolean errorFound = false; 3155 for (int i = 0; i < INPUTSIZE; i++) { 3156 for (int j = 0; j < 2 ; j++) { 3157 // Extract the inputs. 3158 ArgumentsFloatUchar args = new ArgumentsFloatUchar(); 3159 args.inV = arrayInV[i * 2 + j]; 3160 // Figure out what the outputs should have been. 3161 CoreMathVerifier.computeConvert(args); 3162 // Validate the outputs. 3163 boolean valid = true; 3164 if (args.out != arrayOut[i * 2 + j]) { 3165 valid = false; 3166 } 3167 if (!valid) { 3168 if (!errorFound) { 3169 errorFound = true; 3170 message.append("Input inV: "); 3171 appendVariableToMessage(message, args.inV); 3172 message.append("\n"); 3173 message.append("Expected output out: "); 3174 appendVariableToMessage(message, args.out); 3175 message.append("\n"); 3176 message.append("Actual output out: "); 3177 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3178 if (args.out != arrayOut[i * 2 + j]) { 3179 message.append(" FAIL"); 3180 } 3181 message.append("\n"); 3182 message.append("Errors at"); 3183 } 3184 message.append(" ["); 3185 message.append(Integer.toString(i)); 3186 message.append(", "); 3187 message.append(Integer.toString(j)); 3188 message.append("]"); 3189 } 3190 } 3191 } 3192 assertFalse("Incorrect output for checkConvertFloat2Uchar2" + 3193 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3194 } 3195 3196 private void checkConvertFloat3Uchar3() { 3197 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb547c0ff0dc7c57l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 3198 try { 3199 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3200 script.forEach_testConvertUchar3Float3Uchar3(inV, out); 3201 verifyResultsConvertFloat3Uchar3(inV, out, false); 3202 out.destroy(); 3203 } catch (Exception e) { 3204 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString()); 3205 } 3206 try { 3207 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3208 scriptRelaxed.forEach_testConvertUchar3Float3Uchar3(inV, out); 3209 verifyResultsConvertFloat3Uchar3(inV, out, true); 3210 out.destroy(); 3211 } catch (Exception e) { 3212 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString()); 3213 } 3214 inV.destroy(); 3215 } 3216 3217 private void verifyResultsConvertFloat3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3218 float[] arrayInV = new float[INPUTSIZE * 4]; 3219 Arrays.fill(arrayInV, (float) 42); 3220 inV.copyTo(arrayInV); 3221 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3222 Arrays.fill(arrayOut, (byte) 42); 3223 out.copyTo(arrayOut); 3224 StringBuilder message = new StringBuilder(); 3225 boolean errorFound = false; 3226 for (int i = 0; i < INPUTSIZE; i++) { 3227 for (int j = 0; j < 3 ; j++) { 3228 // Extract the inputs. 3229 ArgumentsFloatUchar args = new ArgumentsFloatUchar(); 3230 args.inV = arrayInV[i * 4 + j]; 3231 // Figure out what the outputs should have been. 3232 CoreMathVerifier.computeConvert(args); 3233 // Validate the outputs. 3234 boolean valid = true; 3235 if (args.out != arrayOut[i * 4 + j]) { 3236 valid = false; 3237 } 3238 if (!valid) { 3239 if (!errorFound) { 3240 errorFound = true; 3241 message.append("Input inV: "); 3242 appendVariableToMessage(message, args.inV); 3243 message.append("\n"); 3244 message.append("Expected output out: "); 3245 appendVariableToMessage(message, args.out); 3246 message.append("\n"); 3247 message.append("Actual output out: "); 3248 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3249 if (args.out != arrayOut[i * 4 + j]) { 3250 message.append(" FAIL"); 3251 } 3252 message.append("\n"); 3253 message.append("Errors at"); 3254 } 3255 message.append(" ["); 3256 message.append(Integer.toString(i)); 3257 message.append(", "); 3258 message.append(Integer.toString(j)); 3259 message.append("]"); 3260 } 3261 } 3262 } 3263 assertFalse("Incorrect output for checkConvertFloat3Uchar3" + 3264 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3265 } 3266 3267 private void checkConvertFloat4Uchar4() { 3268 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56452ae6f79d35l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 3269 try { 3270 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3271 script.forEach_testConvertUchar4Float4Uchar4(inV, out); 3272 verifyResultsConvertFloat4Uchar4(inV, out, false); 3273 out.destroy(); 3274 } catch (Exception e) { 3275 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString()); 3276 } 3277 try { 3278 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3279 scriptRelaxed.forEach_testConvertUchar4Float4Uchar4(inV, out); 3280 verifyResultsConvertFloat4Uchar4(inV, out, true); 3281 out.destroy(); 3282 } catch (Exception e) { 3283 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString()); 3284 } 3285 inV.destroy(); 3286 } 3287 3288 private void verifyResultsConvertFloat4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3289 float[] arrayInV = new float[INPUTSIZE * 4]; 3290 Arrays.fill(arrayInV, (float) 42); 3291 inV.copyTo(arrayInV); 3292 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3293 Arrays.fill(arrayOut, (byte) 42); 3294 out.copyTo(arrayOut); 3295 StringBuilder message = new StringBuilder(); 3296 boolean errorFound = false; 3297 for (int i = 0; i < INPUTSIZE; i++) { 3298 for (int j = 0; j < 4 ; j++) { 3299 // Extract the inputs. 3300 ArgumentsFloatUchar args = new ArgumentsFloatUchar(); 3301 args.inV = arrayInV[i * 4 + j]; 3302 // Figure out what the outputs should have been. 3303 CoreMathVerifier.computeConvert(args); 3304 // Validate the outputs. 3305 boolean valid = true; 3306 if (args.out != arrayOut[i * 4 + j]) { 3307 valid = false; 3308 } 3309 if (!valid) { 3310 if (!errorFound) { 3311 errorFound = true; 3312 message.append("Input inV: "); 3313 appendVariableToMessage(message, args.inV); 3314 message.append("\n"); 3315 message.append("Expected output out: "); 3316 appendVariableToMessage(message, args.out); 3317 message.append("\n"); 3318 message.append("Actual output out: "); 3319 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3320 if (args.out != arrayOut[i * 4 + j]) { 3321 message.append(" FAIL"); 3322 } 3323 message.append("\n"); 3324 message.append("Errors at"); 3325 } 3326 message.append(" ["); 3327 message.append(Integer.toString(i)); 3328 message.append(", "); 3329 message.append(Integer.toString(j)); 3330 message.append("]"); 3331 } 3332 } 3333 } 3334 assertFalse("Incorrect output for checkConvertFloat4Uchar4" + 3335 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3336 } 3337 3338 public class ArgumentsCharUchar { 3339 public byte inV; 3340 public byte out; 3341 } 3342 3343 private void checkConvertChar2Uchar2() { 3344 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x58627f46cbea8339l, false, 7); 3345 try { 3346 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3347 script.forEach_testConvertUchar2Char2Uchar2(inV, out); 3348 verifyResultsConvertChar2Uchar2(inV, out, false); 3349 out.destroy(); 3350 } catch (Exception e) { 3351 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString()); 3352 } 3353 try { 3354 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3355 scriptRelaxed.forEach_testConvertUchar2Char2Uchar2(inV, out); 3356 verifyResultsConvertChar2Uchar2(inV, out, true); 3357 out.destroy(); 3358 } catch (Exception e) { 3359 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString()); 3360 } 3361 inV.destroy(); 3362 } 3363 3364 private void verifyResultsConvertChar2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3365 byte[] arrayInV = new byte[INPUTSIZE * 2]; 3366 Arrays.fill(arrayInV, (byte) 42); 3367 inV.copyTo(arrayInV); 3368 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3369 Arrays.fill(arrayOut, (byte) 42); 3370 out.copyTo(arrayOut); 3371 StringBuilder message = new StringBuilder(); 3372 boolean errorFound = false; 3373 for (int i = 0; i < INPUTSIZE; i++) { 3374 for (int j = 0; j < 2 ; j++) { 3375 // Extract the inputs. 3376 ArgumentsCharUchar args = new ArgumentsCharUchar(); 3377 args.inV = arrayInV[i * 2 + j]; 3378 // Figure out what the outputs should have been. 3379 CoreMathVerifier.computeConvert(args); 3380 // Validate the outputs. 3381 boolean valid = true; 3382 if (args.out != arrayOut[i * 2 + j]) { 3383 valid = false; 3384 } 3385 if (!valid) { 3386 if (!errorFound) { 3387 errorFound = true; 3388 message.append("Input inV: "); 3389 appendVariableToMessage(message, args.inV); 3390 message.append("\n"); 3391 message.append("Expected output out: "); 3392 appendVariableToMessage(message, args.out); 3393 message.append("\n"); 3394 message.append("Actual output out: "); 3395 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3396 if (args.out != arrayOut[i * 2 + j]) { 3397 message.append(" FAIL"); 3398 } 3399 message.append("\n"); 3400 message.append("Errors at"); 3401 } 3402 message.append(" ["); 3403 message.append(Integer.toString(i)); 3404 message.append(", "); 3405 message.append(Integer.toString(j)); 3406 message.append("]"); 3407 } 3408 } 3409 } 3410 assertFalse("Incorrect output for checkConvertChar2Uchar2" + 3411 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3412 } 3413 3414 private void checkConvertChar3Uchar3() { 3415 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x58644861c205a417l, false, 7); 3416 try { 3417 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3418 script.forEach_testConvertUchar3Char3Uchar3(inV, out); 3419 verifyResultsConvertChar3Uchar3(inV, out, false); 3420 out.destroy(); 3421 } catch (Exception e) { 3422 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString()); 3423 } 3424 try { 3425 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3426 scriptRelaxed.forEach_testConvertUchar3Char3Uchar3(inV, out); 3427 verifyResultsConvertChar3Uchar3(inV, out, true); 3428 out.destroy(); 3429 } catch (Exception e) { 3430 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString()); 3431 } 3432 inV.destroy(); 3433 } 3434 3435 private void verifyResultsConvertChar3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3436 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3437 Arrays.fill(arrayInV, (byte) 42); 3438 inV.copyTo(arrayInV); 3439 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3440 Arrays.fill(arrayOut, (byte) 42); 3441 out.copyTo(arrayOut); 3442 StringBuilder message = new StringBuilder(); 3443 boolean errorFound = false; 3444 for (int i = 0; i < INPUTSIZE; i++) { 3445 for (int j = 0; j < 3 ; j++) { 3446 // Extract the inputs. 3447 ArgumentsCharUchar args = new ArgumentsCharUchar(); 3448 args.inV = arrayInV[i * 4 + j]; 3449 // Figure out what the outputs should have been. 3450 CoreMathVerifier.computeConvert(args); 3451 // Validate the outputs. 3452 boolean valid = true; 3453 if (args.out != arrayOut[i * 4 + j]) { 3454 valid = false; 3455 } 3456 if (!valid) { 3457 if (!errorFound) { 3458 errorFound = true; 3459 message.append("Input inV: "); 3460 appendVariableToMessage(message, args.inV); 3461 message.append("\n"); 3462 message.append("Expected output out: "); 3463 appendVariableToMessage(message, args.out); 3464 message.append("\n"); 3465 message.append("Actual output out: "); 3466 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3467 if (args.out != arrayOut[i * 4 + j]) { 3468 message.append(" FAIL"); 3469 } 3470 message.append("\n"); 3471 message.append("Errors at"); 3472 } 3473 message.append(" ["); 3474 message.append(Integer.toString(i)); 3475 message.append(", "); 3476 message.append(Integer.toString(j)); 3477 message.append("]"); 3478 } 3479 } 3480 } 3481 assertFalse("Incorrect output for checkConvertChar3Uchar3" + 3482 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3483 } 3484 3485 private void checkConvertChar4Uchar4() { 3486 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5866117cb820c4f5l, false, 7); 3487 try { 3488 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3489 script.forEach_testConvertUchar4Char4Uchar4(inV, out); 3490 verifyResultsConvertChar4Uchar4(inV, out, false); 3491 out.destroy(); 3492 } catch (Exception e) { 3493 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString()); 3494 } 3495 try { 3496 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3497 scriptRelaxed.forEach_testConvertUchar4Char4Uchar4(inV, out); 3498 verifyResultsConvertChar4Uchar4(inV, out, true); 3499 out.destroy(); 3500 } catch (Exception e) { 3501 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString()); 3502 } 3503 inV.destroy(); 3504 } 3505 3506 private void verifyResultsConvertChar4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3507 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3508 Arrays.fill(arrayInV, (byte) 42); 3509 inV.copyTo(arrayInV); 3510 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3511 Arrays.fill(arrayOut, (byte) 42); 3512 out.copyTo(arrayOut); 3513 StringBuilder message = new StringBuilder(); 3514 boolean errorFound = false; 3515 for (int i = 0; i < INPUTSIZE; i++) { 3516 for (int j = 0; j < 4 ; j++) { 3517 // Extract the inputs. 3518 ArgumentsCharUchar args = new ArgumentsCharUchar(); 3519 args.inV = arrayInV[i * 4 + j]; 3520 // Figure out what the outputs should have been. 3521 CoreMathVerifier.computeConvert(args); 3522 // Validate the outputs. 3523 boolean valid = true; 3524 if (args.out != arrayOut[i * 4 + j]) { 3525 valid = false; 3526 } 3527 if (!valid) { 3528 if (!errorFound) { 3529 errorFound = true; 3530 message.append("Input inV: "); 3531 appendVariableToMessage(message, args.inV); 3532 message.append("\n"); 3533 message.append("Expected output out: "); 3534 appendVariableToMessage(message, args.out); 3535 message.append("\n"); 3536 message.append("Actual output out: "); 3537 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3538 if (args.out != arrayOut[i * 4 + j]) { 3539 message.append(" FAIL"); 3540 } 3541 message.append("\n"); 3542 message.append("Errors at"); 3543 } 3544 message.append(" ["); 3545 message.append(Integer.toString(i)); 3546 message.append(", "); 3547 message.append(Integer.toString(j)); 3548 message.append("]"); 3549 } 3550 } 3551 } 3552 assertFalse("Incorrect output for checkConvertChar4Uchar4" + 3553 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3554 } 3555 3556 public class ArgumentsUcharUchar { 3557 public byte inV; 3558 public byte out; 3559 } 3560 3561 private void checkConvertUchar2Uchar2() { 3562 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d309f4e67c29ce4l, false, 8); 3563 try { 3564 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3565 script.forEach_testConvertUchar2Uchar2Uchar2(inV, out); 3566 verifyResultsConvertUchar2Uchar2(inV, out, false); 3567 out.destroy(); 3568 } catch (Exception e) { 3569 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString()); 3570 } 3571 try { 3572 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3573 scriptRelaxed.forEach_testConvertUchar2Uchar2Uchar2(inV, out); 3574 verifyResultsConvertUchar2Uchar2(inV, out, true); 3575 out.destroy(); 3576 } catch (Exception e) { 3577 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString()); 3578 } 3579 inV.destroy(); 3580 } 3581 3582 private void verifyResultsConvertUchar2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3583 byte[] arrayInV = new byte[INPUTSIZE * 2]; 3584 Arrays.fill(arrayInV, (byte) 42); 3585 inV.copyTo(arrayInV); 3586 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3587 Arrays.fill(arrayOut, (byte) 42); 3588 out.copyTo(arrayOut); 3589 StringBuilder message = new StringBuilder(); 3590 boolean errorFound = false; 3591 for (int i = 0; i < INPUTSIZE; i++) { 3592 for (int j = 0; j < 2 ; j++) { 3593 // Extract the inputs. 3594 ArgumentsUcharUchar args = new ArgumentsUcharUchar(); 3595 args.inV = arrayInV[i * 2 + j]; 3596 // Figure out what the outputs should have been. 3597 CoreMathVerifier.computeConvert(args); 3598 // Validate the outputs. 3599 boolean valid = true; 3600 if (args.out != arrayOut[i * 2 + j]) { 3601 valid = false; 3602 } 3603 if (!valid) { 3604 if (!errorFound) { 3605 errorFound = true; 3606 message.append("Input inV: "); 3607 appendVariableToMessage(message, args.inV); 3608 message.append("\n"); 3609 message.append("Expected output out: "); 3610 appendVariableToMessage(message, args.out); 3611 message.append("\n"); 3612 message.append("Actual output out: "); 3613 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3614 if (args.out != arrayOut[i * 2 + j]) { 3615 message.append(" FAIL"); 3616 } 3617 message.append("\n"); 3618 message.append("Errors at"); 3619 } 3620 message.append(" ["); 3621 message.append(Integer.toString(i)); 3622 message.append(", "); 3623 message.append(Integer.toString(j)); 3624 message.append("]"); 3625 } 3626 } 3627 } 3628 assertFalse("Incorrect output for checkConvertUchar2Uchar2" + 3629 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3630 } 3631 3632 private void checkConvertUchar3Uchar3() { 3633 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d3268695dddbdc2l, false, 8); 3634 try { 3635 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3636 script.forEach_testConvertUchar3Uchar3Uchar3(inV, out); 3637 verifyResultsConvertUchar3Uchar3(inV, out, false); 3638 out.destroy(); 3639 } catch (Exception e) { 3640 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString()); 3641 } 3642 try { 3643 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3644 scriptRelaxed.forEach_testConvertUchar3Uchar3Uchar3(inV, out); 3645 verifyResultsConvertUchar3Uchar3(inV, out, true); 3646 out.destroy(); 3647 } catch (Exception e) { 3648 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString()); 3649 } 3650 inV.destroy(); 3651 } 3652 3653 private void verifyResultsConvertUchar3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3654 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3655 Arrays.fill(arrayInV, (byte) 42); 3656 inV.copyTo(arrayInV); 3657 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3658 Arrays.fill(arrayOut, (byte) 42); 3659 out.copyTo(arrayOut); 3660 StringBuilder message = new StringBuilder(); 3661 boolean errorFound = false; 3662 for (int i = 0; i < INPUTSIZE; i++) { 3663 for (int j = 0; j < 3 ; j++) { 3664 // Extract the inputs. 3665 ArgumentsUcharUchar args = new ArgumentsUcharUchar(); 3666 args.inV = arrayInV[i * 4 + j]; 3667 // Figure out what the outputs should have been. 3668 CoreMathVerifier.computeConvert(args); 3669 // Validate the outputs. 3670 boolean valid = true; 3671 if (args.out != arrayOut[i * 4 + j]) { 3672 valid = false; 3673 } 3674 if (!valid) { 3675 if (!errorFound) { 3676 errorFound = true; 3677 message.append("Input inV: "); 3678 appendVariableToMessage(message, args.inV); 3679 message.append("\n"); 3680 message.append("Expected output out: "); 3681 appendVariableToMessage(message, args.out); 3682 message.append("\n"); 3683 message.append("Actual output out: "); 3684 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3685 if (args.out != arrayOut[i * 4 + j]) { 3686 message.append(" FAIL"); 3687 } 3688 message.append("\n"); 3689 message.append("Errors at"); 3690 } 3691 message.append(" ["); 3692 message.append(Integer.toString(i)); 3693 message.append(", "); 3694 message.append(Integer.toString(j)); 3695 message.append("]"); 3696 } 3697 } 3698 } 3699 assertFalse("Incorrect output for checkConvertUchar3Uchar3" + 3700 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3701 } 3702 3703 private void checkConvertUchar4Uchar4() { 3704 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d34318453f8dea0l, false, 8); 3705 try { 3706 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3707 script.forEach_testConvertUchar4Uchar4Uchar4(inV, out); 3708 verifyResultsConvertUchar4Uchar4(inV, out, false); 3709 out.destroy(); 3710 } catch (Exception e) { 3711 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString()); 3712 } 3713 try { 3714 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3715 scriptRelaxed.forEach_testConvertUchar4Uchar4Uchar4(inV, out); 3716 verifyResultsConvertUchar4Uchar4(inV, out, true); 3717 out.destroy(); 3718 } catch (Exception e) { 3719 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString()); 3720 } 3721 inV.destroy(); 3722 } 3723 3724 private void verifyResultsConvertUchar4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3725 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3726 Arrays.fill(arrayInV, (byte) 42); 3727 inV.copyTo(arrayInV); 3728 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3729 Arrays.fill(arrayOut, (byte) 42); 3730 out.copyTo(arrayOut); 3731 StringBuilder message = new StringBuilder(); 3732 boolean errorFound = false; 3733 for (int i = 0; i < INPUTSIZE; i++) { 3734 for (int j = 0; j < 4 ; j++) { 3735 // Extract the inputs. 3736 ArgumentsUcharUchar args = new ArgumentsUcharUchar(); 3737 args.inV = arrayInV[i * 4 + j]; 3738 // Figure out what the outputs should have been. 3739 CoreMathVerifier.computeConvert(args); 3740 // Validate the outputs. 3741 boolean valid = true; 3742 if (args.out != arrayOut[i * 4 + j]) { 3743 valid = false; 3744 } 3745 if (!valid) { 3746 if (!errorFound) { 3747 errorFound = true; 3748 message.append("Input inV: "); 3749 appendVariableToMessage(message, args.inV); 3750 message.append("\n"); 3751 message.append("Expected output out: "); 3752 appendVariableToMessage(message, args.out); 3753 message.append("\n"); 3754 message.append("Actual output out: "); 3755 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3756 if (args.out != arrayOut[i * 4 + j]) { 3757 message.append(" FAIL"); 3758 } 3759 message.append("\n"); 3760 message.append("Errors at"); 3761 } 3762 message.append(" ["); 3763 message.append(Integer.toString(i)); 3764 message.append(", "); 3765 message.append(Integer.toString(j)); 3766 message.append("]"); 3767 } 3768 } 3769 } 3770 assertFalse("Incorrect output for checkConvertUchar4Uchar4" + 3771 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3772 } 3773 3774 public class ArgumentsShortUchar { 3775 public short inV; 3776 public byte out; 3777 } 3778 3779 private void checkConvertShort2Uchar2() { 3780 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94cab57fabc38225l, false, 8); 3781 try { 3782 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3783 script.forEach_testConvertUchar2Short2Uchar2(inV, out); 3784 verifyResultsConvertShort2Uchar2(inV, out, false); 3785 out.destroy(); 3786 } catch (Exception e) { 3787 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString()); 3788 } 3789 try { 3790 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3791 scriptRelaxed.forEach_testConvertUchar2Short2Uchar2(inV, out); 3792 verifyResultsConvertShort2Uchar2(inV, out, true); 3793 out.destroy(); 3794 } catch (Exception e) { 3795 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString()); 3796 } 3797 inV.destroy(); 3798 } 3799 3800 private void verifyResultsConvertShort2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3801 short[] arrayInV = new short[INPUTSIZE * 2]; 3802 Arrays.fill(arrayInV, (short) 42); 3803 inV.copyTo(arrayInV); 3804 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3805 Arrays.fill(arrayOut, (byte) 42); 3806 out.copyTo(arrayOut); 3807 StringBuilder message = new StringBuilder(); 3808 boolean errorFound = false; 3809 for (int i = 0; i < INPUTSIZE; i++) { 3810 for (int j = 0; j < 2 ; j++) { 3811 // Extract the inputs. 3812 ArgumentsShortUchar args = new ArgumentsShortUchar(); 3813 args.inV = arrayInV[i * 2 + j]; 3814 // Figure out what the outputs should have been. 3815 CoreMathVerifier.computeConvert(args); 3816 // Validate the outputs. 3817 boolean valid = true; 3818 if (args.out != arrayOut[i * 2 + j]) { 3819 valid = false; 3820 } 3821 if (!valid) { 3822 if (!errorFound) { 3823 errorFound = true; 3824 message.append("Input inV: "); 3825 appendVariableToMessage(message, args.inV); 3826 message.append("\n"); 3827 message.append("Expected output out: "); 3828 appendVariableToMessage(message, args.out); 3829 message.append("\n"); 3830 message.append("Actual output out: "); 3831 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3832 if (args.out != arrayOut[i * 2 + j]) { 3833 message.append(" FAIL"); 3834 } 3835 message.append("\n"); 3836 message.append("Errors at"); 3837 } 3838 message.append(" ["); 3839 message.append(Integer.toString(i)); 3840 message.append(", "); 3841 message.append(Integer.toString(j)); 3842 message.append("]"); 3843 } 3844 } 3845 } 3846 assertFalse("Incorrect output for checkConvertShort2Uchar2" + 3847 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3848 } 3849 3850 private void checkConvertShort3Uchar3() { 3851 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc7e9aa1dea303l, false, 8); 3852 try { 3853 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3854 script.forEach_testConvertUchar3Short3Uchar3(inV, out); 3855 verifyResultsConvertShort3Uchar3(inV, out, false); 3856 out.destroy(); 3857 } catch (Exception e) { 3858 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString()); 3859 } 3860 try { 3861 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3862 scriptRelaxed.forEach_testConvertUchar3Short3Uchar3(inV, out); 3863 verifyResultsConvertShort3Uchar3(inV, out, true); 3864 out.destroy(); 3865 } catch (Exception e) { 3866 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString()); 3867 } 3868 inV.destroy(); 3869 } 3870 3871 private void verifyResultsConvertShort3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3872 short[] arrayInV = new short[INPUTSIZE * 4]; 3873 Arrays.fill(arrayInV, (short) 42); 3874 inV.copyTo(arrayInV); 3875 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3876 Arrays.fill(arrayOut, (byte) 42); 3877 out.copyTo(arrayOut); 3878 StringBuilder message = new StringBuilder(); 3879 boolean errorFound = false; 3880 for (int i = 0; i < INPUTSIZE; i++) { 3881 for (int j = 0; j < 3 ; j++) { 3882 // Extract the inputs. 3883 ArgumentsShortUchar args = new ArgumentsShortUchar(); 3884 args.inV = arrayInV[i * 4 + j]; 3885 // Figure out what the outputs should have been. 3886 CoreMathVerifier.computeConvert(args); 3887 // Validate the outputs. 3888 boolean valid = true; 3889 if (args.out != arrayOut[i * 4 + j]) { 3890 valid = false; 3891 } 3892 if (!valid) { 3893 if (!errorFound) { 3894 errorFound = true; 3895 message.append("Input inV: "); 3896 appendVariableToMessage(message, args.inV); 3897 message.append("\n"); 3898 message.append("Expected output out: "); 3899 appendVariableToMessage(message, args.out); 3900 message.append("\n"); 3901 message.append("Actual output out: "); 3902 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3903 if (args.out != arrayOut[i * 4 + j]) { 3904 message.append(" FAIL"); 3905 } 3906 message.append("\n"); 3907 message.append("Errors at"); 3908 } 3909 message.append(" ["); 3910 message.append(Integer.toString(i)); 3911 message.append(", "); 3912 message.append(Integer.toString(j)); 3913 message.append("]"); 3914 } 3915 } 3916 } 3917 assertFalse("Incorrect output for checkConvertShort3Uchar3" + 3918 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3919 } 3920 3921 private void checkConvertShort4Uchar4() { 3922 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce47b597f9c3e1l, false, 8); 3923 try { 3924 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3925 script.forEach_testConvertUchar4Short4Uchar4(inV, out); 3926 verifyResultsConvertShort4Uchar4(inV, out, false); 3927 out.destroy(); 3928 } catch (Exception e) { 3929 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString()); 3930 } 3931 try { 3932 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3933 scriptRelaxed.forEach_testConvertUchar4Short4Uchar4(inV, out); 3934 verifyResultsConvertShort4Uchar4(inV, out, true); 3935 out.destroy(); 3936 } catch (Exception e) { 3937 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString()); 3938 } 3939 inV.destroy(); 3940 } 3941 3942 private void verifyResultsConvertShort4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3943 short[] arrayInV = new short[INPUTSIZE * 4]; 3944 Arrays.fill(arrayInV, (short) 42); 3945 inV.copyTo(arrayInV); 3946 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3947 Arrays.fill(arrayOut, (byte) 42); 3948 out.copyTo(arrayOut); 3949 StringBuilder message = new StringBuilder(); 3950 boolean errorFound = false; 3951 for (int i = 0; i < INPUTSIZE; i++) { 3952 for (int j = 0; j < 4 ; j++) { 3953 // Extract the inputs. 3954 ArgumentsShortUchar args = new ArgumentsShortUchar(); 3955 args.inV = arrayInV[i * 4 + j]; 3956 // Figure out what the outputs should have been. 3957 CoreMathVerifier.computeConvert(args); 3958 // Validate the outputs. 3959 boolean valid = true; 3960 if (args.out != arrayOut[i * 4 + j]) { 3961 valid = false; 3962 } 3963 if (!valid) { 3964 if (!errorFound) { 3965 errorFound = true; 3966 message.append("Input inV: "); 3967 appendVariableToMessage(message, args.inV); 3968 message.append("\n"); 3969 message.append("Expected output out: "); 3970 appendVariableToMessage(message, args.out); 3971 message.append("\n"); 3972 message.append("Actual output out: "); 3973 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3974 if (args.out != arrayOut[i * 4 + j]) { 3975 message.append(" FAIL"); 3976 } 3977 message.append("\n"); 3978 message.append("Errors at"); 3979 } 3980 message.append(" ["); 3981 message.append(Integer.toString(i)); 3982 message.append(", "); 3983 message.append(Integer.toString(j)); 3984 message.append("]"); 3985 } 3986 } 3987 } 3988 assertFalse("Incorrect output for checkConvertShort4Uchar4" + 3989 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3990 } 3991 3992 public class ArgumentsUshortUchar { 3993 public short inV; 3994 public byte out; 3995 } 3996 3997 private void checkConvertUshort2Uchar2() { 3998 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a16c6d90fd1del, false, 8); 3999 try { 4000 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4001 script.forEach_testConvertUchar2Ushort2Uchar2(inV, out); 4002 verifyResultsConvertUshort2Uchar2(inV, out, false); 4003 out.destroy(); 4004 } catch (Exception e) { 4005 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString()); 4006 } 4007 try { 4008 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4009 scriptRelaxed.forEach_testConvertUchar2Ushort2Uchar2(inV, out); 4010 verifyResultsConvertUshort2Uchar2(inV, out, true); 4011 out.destroy(); 4012 } catch (Exception e) { 4013 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString()); 4014 } 4015 inV.destroy(); 4016 } 4017 4018 private void verifyResultsConvertUshort2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 4019 short[] arrayInV = new short[INPUTSIZE * 2]; 4020 Arrays.fill(arrayInV, (short) 42); 4021 inV.copyTo(arrayInV); 4022 byte[] arrayOut = new byte[INPUTSIZE * 2]; 4023 Arrays.fill(arrayOut, (byte) 42); 4024 out.copyTo(arrayOut); 4025 StringBuilder message = new StringBuilder(); 4026 boolean errorFound = false; 4027 for (int i = 0; i < INPUTSIZE; i++) { 4028 for (int j = 0; j < 2 ; j++) { 4029 // Extract the inputs. 4030 ArgumentsUshortUchar args = new ArgumentsUshortUchar(); 4031 args.inV = arrayInV[i * 2 + j]; 4032 // Figure out what the outputs should have been. 4033 CoreMathVerifier.computeConvert(args); 4034 // Validate the outputs. 4035 boolean valid = true; 4036 if (args.out != arrayOut[i * 2 + j]) { 4037 valid = false; 4038 } 4039 if (!valid) { 4040 if (!errorFound) { 4041 errorFound = true; 4042 message.append("Input inV: "); 4043 appendVariableToMessage(message, args.inV); 4044 message.append("\n"); 4045 message.append("Expected output out: "); 4046 appendVariableToMessage(message, args.out); 4047 message.append("\n"); 4048 message.append("Actual output out: "); 4049 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4050 if (args.out != arrayOut[i * 2 + j]) { 4051 message.append(" FAIL"); 4052 } 4053 message.append("\n"); 4054 message.append("Errors at"); 4055 } 4056 message.append(" ["); 4057 message.append(Integer.toString(i)); 4058 message.append(", "); 4059 message.append(Integer.toString(j)); 4060 message.append("]"); 4061 } 4062 } 4063 } 4064 assertFalse("Incorrect output for checkConvertUshort2Uchar2" + 4065 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4066 } 4067 4068 private void checkConvertUshort3Uchar3() { 4069 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36bdfe1cf2af2bcl, false, 8); 4070 try { 4071 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4072 script.forEach_testConvertUchar3Ushort3Uchar3(inV, out); 4073 verifyResultsConvertUshort3Uchar3(inV, out, false); 4074 out.destroy(); 4075 } catch (Exception e) { 4076 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString()); 4077 } 4078 try { 4079 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4080 scriptRelaxed.forEach_testConvertUchar3Ushort3Uchar3(inV, out); 4081 verifyResultsConvertUshort3Uchar3(inV, out, true); 4082 out.destroy(); 4083 } catch (Exception e) { 4084 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString()); 4085 } 4086 inV.destroy(); 4087 } 4088 4089 private void verifyResultsConvertUshort3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 4090 short[] arrayInV = new short[INPUTSIZE * 4]; 4091 Arrays.fill(arrayInV, (short) 42); 4092 inV.copyTo(arrayInV); 4093 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4094 Arrays.fill(arrayOut, (byte) 42); 4095 out.copyTo(arrayOut); 4096 StringBuilder message = new StringBuilder(); 4097 boolean errorFound = false; 4098 for (int i = 0; i < INPUTSIZE; i++) { 4099 for (int j = 0; j < 3 ; j++) { 4100 // Extract the inputs. 4101 ArgumentsUshortUchar args = new ArgumentsUshortUchar(); 4102 args.inV = arrayInV[i * 4 + j]; 4103 // Figure out what the outputs should have been. 4104 CoreMathVerifier.computeConvert(args); 4105 // Validate the outputs. 4106 boolean valid = true; 4107 if (args.out != arrayOut[i * 4 + j]) { 4108 valid = false; 4109 } 4110 if (!valid) { 4111 if (!errorFound) { 4112 errorFound = true; 4113 message.append("Input inV: "); 4114 appendVariableToMessage(message, args.inV); 4115 message.append("\n"); 4116 message.append("Expected output out: "); 4117 appendVariableToMessage(message, args.out); 4118 message.append("\n"); 4119 message.append("Actual output out: "); 4120 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4121 if (args.out != arrayOut[i * 4 + j]) { 4122 message.append(" FAIL"); 4123 } 4124 message.append("\n"); 4125 message.append("Errors at"); 4126 } 4127 message.append(" ["); 4128 message.append(Integer.toString(i)); 4129 message.append(", "); 4130 message.append(Integer.toString(j)); 4131 message.append("]"); 4132 } 4133 } 4134 } 4135 assertFalse("Incorrect output for checkConvertUshort3Uchar3" + 4136 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4137 } 4138 4139 private void checkConvertUshort4Uchar4() { 4140 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36da8fcc546139al, false, 8); 4141 try { 4142 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4143 script.forEach_testConvertUchar4Ushort4Uchar4(inV, out); 4144 verifyResultsConvertUshort4Uchar4(inV, out, false); 4145 out.destroy(); 4146 } catch (Exception e) { 4147 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString()); 4148 } 4149 try { 4150 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4151 scriptRelaxed.forEach_testConvertUchar4Ushort4Uchar4(inV, out); 4152 verifyResultsConvertUshort4Uchar4(inV, out, true); 4153 out.destroy(); 4154 } catch (Exception e) { 4155 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString()); 4156 } 4157 inV.destroy(); 4158 } 4159 4160 private void verifyResultsConvertUshort4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 4161 short[] arrayInV = new short[INPUTSIZE * 4]; 4162 Arrays.fill(arrayInV, (short) 42); 4163 inV.copyTo(arrayInV); 4164 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4165 Arrays.fill(arrayOut, (byte) 42); 4166 out.copyTo(arrayOut); 4167 StringBuilder message = new StringBuilder(); 4168 boolean errorFound = false; 4169 for (int i = 0; i < INPUTSIZE; i++) { 4170 for (int j = 0; j < 4 ; j++) { 4171 // Extract the inputs. 4172 ArgumentsUshortUchar args = new ArgumentsUshortUchar(); 4173 args.inV = arrayInV[i * 4 + j]; 4174 // Figure out what the outputs should have been. 4175 CoreMathVerifier.computeConvert(args); 4176 // Validate the outputs. 4177 boolean valid = true; 4178 if (args.out != arrayOut[i * 4 + j]) { 4179 valid = false; 4180 } 4181 if (!valid) { 4182 if (!errorFound) { 4183 errorFound = true; 4184 message.append("Input inV: "); 4185 appendVariableToMessage(message, args.inV); 4186 message.append("\n"); 4187 message.append("Expected output out: "); 4188 appendVariableToMessage(message, args.out); 4189 message.append("\n"); 4190 message.append("Actual output out: "); 4191 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4192 if (args.out != arrayOut[i * 4 + j]) { 4193 message.append(" FAIL"); 4194 } 4195 message.append("\n"); 4196 message.append("Errors at"); 4197 } 4198 message.append(" ["); 4199 message.append(Integer.toString(i)); 4200 message.append(", "); 4201 message.append(Integer.toString(j)); 4202 message.append("]"); 4203 } 4204 } 4205 } 4206 assertFalse("Incorrect output for checkConvertUshort4Uchar4" + 4207 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4208 } 4209 4210 public class ArgumentsIntUchar { 4211 public int inV; 4212 public byte out; 4213 } 4214 4215 private void checkConvertInt2Uchar2() { 4216 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a53651c20a4b078l, false, 8); 4217 try { 4218 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4219 script.forEach_testConvertUchar2Int2Uchar2(inV, out); 4220 verifyResultsConvertInt2Uchar2(inV, out, false); 4221 out.destroy(); 4222 } catch (Exception e) { 4223 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString()); 4224 } 4225 try { 4226 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4227 scriptRelaxed.forEach_testConvertUchar2Int2Uchar2(inV, out); 4228 verifyResultsConvertInt2Uchar2(inV, out, true); 4229 out.destroy(); 4230 } catch (Exception e) { 4231 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString()); 4232 } 4233 inV.destroy(); 4234 } 4235 4236 private void verifyResultsConvertInt2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 4237 int[] arrayInV = new int[INPUTSIZE * 2]; 4238 Arrays.fill(arrayInV, (int) 42); 4239 inV.copyTo(arrayInV); 4240 byte[] arrayOut = new byte[INPUTSIZE * 2]; 4241 Arrays.fill(arrayOut, (byte) 42); 4242 out.copyTo(arrayOut); 4243 StringBuilder message = new StringBuilder(); 4244 boolean errorFound = false; 4245 for (int i = 0; i < INPUTSIZE; i++) { 4246 for (int j = 0; j < 2 ; j++) { 4247 // Extract the inputs. 4248 ArgumentsIntUchar args = new ArgumentsIntUchar(); 4249 args.inV = arrayInV[i * 2 + j]; 4250 // Figure out what the outputs should have been. 4251 CoreMathVerifier.computeConvert(args); 4252 // Validate the outputs. 4253 boolean valid = true; 4254 if (args.out != arrayOut[i * 2 + j]) { 4255 valid = false; 4256 } 4257 if (!valid) { 4258 if (!errorFound) { 4259 errorFound = true; 4260 message.append("Input inV: "); 4261 appendVariableToMessage(message, args.inV); 4262 message.append("\n"); 4263 message.append("Expected output out: "); 4264 appendVariableToMessage(message, args.out); 4265 message.append("\n"); 4266 message.append("Actual output out: "); 4267 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4268 if (args.out != arrayOut[i * 2 + j]) { 4269 message.append(" FAIL"); 4270 } 4271 message.append("\n"); 4272 message.append("Errors at"); 4273 } 4274 message.append(" ["); 4275 message.append(Integer.toString(i)); 4276 message.append(", "); 4277 message.append(Integer.toString(j)); 4278 message.append("]"); 4279 } 4280 } 4281 } 4282 assertFalse("Incorrect output for checkConvertInt2Uchar2" + 4283 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4284 } 4285 4286 private void checkConvertInt3Uchar3() { 4287 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a552e3716bfd156l, false, 8); 4288 try { 4289 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4290 script.forEach_testConvertUchar3Int3Uchar3(inV, out); 4291 verifyResultsConvertInt3Uchar3(inV, out, false); 4292 out.destroy(); 4293 } catch (Exception e) { 4294 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString()); 4295 } 4296 try { 4297 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4298 scriptRelaxed.forEach_testConvertUchar3Int3Uchar3(inV, out); 4299 verifyResultsConvertInt3Uchar3(inV, out, true); 4300 out.destroy(); 4301 } catch (Exception e) { 4302 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString()); 4303 } 4304 inV.destroy(); 4305 } 4306 4307 private void verifyResultsConvertInt3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 4308 int[] arrayInV = new int[INPUTSIZE * 4]; 4309 Arrays.fill(arrayInV, (int) 42); 4310 inV.copyTo(arrayInV); 4311 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4312 Arrays.fill(arrayOut, (byte) 42); 4313 out.copyTo(arrayOut); 4314 StringBuilder message = new StringBuilder(); 4315 boolean errorFound = false; 4316 for (int i = 0; i < INPUTSIZE; i++) { 4317 for (int j = 0; j < 3 ; j++) { 4318 // Extract the inputs. 4319 ArgumentsIntUchar args = new ArgumentsIntUchar(); 4320 args.inV = arrayInV[i * 4 + j]; 4321 // Figure out what the outputs should have been. 4322 CoreMathVerifier.computeConvert(args); 4323 // Validate the outputs. 4324 boolean valid = true; 4325 if (args.out != arrayOut[i * 4 + j]) { 4326 valid = false; 4327 } 4328 if (!valid) { 4329 if (!errorFound) { 4330 errorFound = true; 4331 message.append("Input inV: "); 4332 appendVariableToMessage(message, args.inV); 4333 message.append("\n"); 4334 message.append("Expected output out: "); 4335 appendVariableToMessage(message, args.out); 4336 message.append("\n"); 4337 message.append("Actual output out: "); 4338 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4339 if (args.out != arrayOut[i * 4 + j]) { 4340 message.append(" FAIL"); 4341 } 4342 message.append("\n"); 4343 message.append("Errors at"); 4344 } 4345 message.append(" ["); 4346 message.append(Integer.toString(i)); 4347 message.append(", "); 4348 message.append(Integer.toString(j)); 4349 message.append("]"); 4350 } 4351 } 4352 } 4353 assertFalse("Incorrect output for checkConvertInt3Uchar3" + 4354 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4355 } 4356 4357 private void checkConvertInt4Uchar4() { 4358 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56f7520cdaf234l, false, 8); 4359 try { 4360 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4361 script.forEach_testConvertUchar4Int4Uchar4(inV, out); 4362 verifyResultsConvertInt4Uchar4(inV, out, false); 4363 out.destroy(); 4364 } catch (Exception e) { 4365 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString()); 4366 } 4367 try { 4368 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4369 scriptRelaxed.forEach_testConvertUchar4Int4Uchar4(inV, out); 4370 verifyResultsConvertInt4Uchar4(inV, out, true); 4371 out.destroy(); 4372 } catch (Exception e) { 4373 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString()); 4374 } 4375 inV.destroy(); 4376 } 4377 4378 private void verifyResultsConvertInt4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 4379 int[] arrayInV = new int[INPUTSIZE * 4]; 4380 Arrays.fill(arrayInV, (int) 42); 4381 inV.copyTo(arrayInV); 4382 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4383 Arrays.fill(arrayOut, (byte) 42); 4384 out.copyTo(arrayOut); 4385 StringBuilder message = new StringBuilder(); 4386 boolean errorFound = false; 4387 for (int i = 0; i < INPUTSIZE; i++) { 4388 for (int j = 0; j < 4 ; j++) { 4389 // Extract the inputs. 4390 ArgumentsIntUchar args = new ArgumentsIntUchar(); 4391 args.inV = arrayInV[i * 4 + j]; 4392 // Figure out what the outputs should have been. 4393 CoreMathVerifier.computeConvert(args); 4394 // Validate the outputs. 4395 boolean valid = true; 4396 if (args.out != arrayOut[i * 4 + j]) { 4397 valid = false; 4398 } 4399 if (!valid) { 4400 if (!errorFound) { 4401 errorFound = true; 4402 message.append("Input inV: "); 4403 appendVariableToMessage(message, args.inV); 4404 message.append("\n"); 4405 message.append("Expected output out: "); 4406 appendVariableToMessage(message, args.out); 4407 message.append("\n"); 4408 message.append("Actual output out: "); 4409 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4410 if (args.out != arrayOut[i * 4 + j]) { 4411 message.append(" FAIL"); 4412 } 4413 message.append("\n"); 4414 message.append("Errors at"); 4415 } 4416 message.append(" ["); 4417 message.append(Integer.toString(i)); 4418 message.append(", "); 4419 message.append(Integer.toString(j)); 4420 message.append("]"); 4421 } 4422 } 4423 } 4424 assertFalse("Incorrect output for checkConvertInt4Uchar4" + 4425 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4426 } 4427 4428 public class ArgumentsUintUchar { 4429 public int inV; 4430 public byte out; 4431 } 4432 4433 private void checkConvertUint2Uchar2() { 4434 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e11e69b326bcf9l, false, 8); 4435 try { 4436 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4437 script.forEach_testConvertUchar2Uint2Uchar2(inV, out); 4438 verifyResultsConvertUint2Uchar2(inV, out, false); 4439 out.destroy(); 4440 } catch (Exception e) { 4441 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString()); 4442 } 4443 try { 4444 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4445 scriptRelaxed.forEach_testConvertUchar2Uint2Uchar2(inV, out); 4446 verifyResultsConvertUint2Uchar2(inV, out, true); 4447 out.destroy(); 4448 } catch (Exception e) { 4449 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString()); 4450 } 4451 inV.destroy(); 4452 } 4453 4454 private void verifyResultsConvertUint2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 4455 int[] arrayInV = new int[INPUTSIZE * 2]; 4456 Arrays.fill(arrayInV, (int) 42); 4457 inV.copyTo(arrayInV); 4458 byte[] arrayOut = new byte[INPUTSIZE * 2]; 4459 Arrays.fill(arrayOut, (byte) 42); 4460 out.copyTo(arrayOut); 4461 StringBuilder message = new StringBuilder(); 4462 boolean errorFound = false; 4463 for (int i = 0; i < INPUTSIZE; i++) { 4464 for (int j = 0; j < 2 ; j++) { 4465 // Extract the inputs. 4466 ArgumentsUintUchar args = new ArgumentsUintUchar(); 4467 args.inV = arrayInV[i * 2 + j]; 4468 // Figure out what the outputs should have been. 4469 CoreMathVerifier.computeConvert(args); 4470 // Validate the outputs. 4471 boolean valid = true; 4472 if (args.out != arrayOut[i * 2 + j]) { 4473 valid = false; 4474 } 4475 if (!valid) { 4476 if (!errorFound) { 4477 errorFound = true; 4478 message.append("Input inV: "); 4479 appendVariableToMessage(message, args.inV); 4480 message.append("\n"); 4481 message.append("Expected output out: "); 4482 appendVariableToMessage(message, args.out); 4483 message.append("\n"); 4484 message.append("Actual output out: "); 4485 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4486 if (args.out != arrayOut[i * 2 + j]) { 4487 message.append(" FAIL"); 4488 } 4489 message.append("\n"); 4490 message.append("Errors at"); 4491 } 4492 message.append(" ["); 4493 message.append(Integer.toString(i)); 4494 message.append(", "); 4495 message.append(Integer.toString(j)); 4496 message.append("]"); 4497 } 4498 } 4499 } 4500 assertFalse("Incorrect output for checkConvertUint2Uchar2" + 4501 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4502 } 4503 4504 private void checkConvertUint3Uchar3() { 4505 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2e784a941ddd7l, false, 8); 4506 try { 4507 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4508 script.forEach_testConvertUchar3Uint3Uchar3(inV, out); 4509 verifyResultsConvertUint3Uchar3(inV, out, false); 4510 out.destroy(); 4511 } catch (Exception e) { 4512 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString()); 4513 } 4514 try { 4515 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4516 scriptRelaxed.forEach_testConvertUchar3Uint3Uchar3(inV, out); 4517 verifyResultsConvertUint3Uchar3(inV, out, true); 4518 out.destroy(); 4519 } catch (Exception e) { 4520 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString()); 4521 } 4522 inV.destroy(); 4523 } 4524 4525 private void verifyResultsConvertUint3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 4526 int[] arrayInV = new int[INPUTSIZE * 4]; 4527 Arrays.fill(arrayInV, (int) 42); 4528 inV.copyTo(arrayInV); 4529 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4530 Arrays.fill(arrayOut, (byte) 42); 4531 out.copyTo(arrayOut); 4532 StringBuilder message = new StringBuilder(); 4533 boolean errorFound = false; 4534 for (int i = 0; i < INPUTSIZE; i++) { 4535 for (int j = 0; j < 3 ; j++) { 4536 // Extract the inputs. 4537 ArgumentsUintUchar args = new ArgumentsUintUchar(); 4538 args.inV = arrayInV[i * 4 + j]; 4539 // Figure out what the outputs should have been. 4540 CoreMathVerifier.computeConvert(args); 4541 // Validate the outputs. 4542 boolean valid = true; 4543 if (args.out != arrayOut[i * 4 + j]) { 4544 valid = false; 4545 } 4546 if (!valid) { 4547 if (!errorFound) { 4548 errorFound = true; 4549 message.append("Input inV: "); 4550 appendVariableToMessage(message, args.inV); 4551 message.append("\n"); 4552 message.append("Expected output out: "); 4553 appendVariableToMessage(message, args.out); 4554 message.append("\n"); 4555 message.append("Actual output out: "); 4556 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4557 if (args.out != arrayOut[i * 4 + j]) { 4558 message.append(" FAIL"); 4559 } 4560 message.append("\n"); 4561 message.append("Errors at"); 4562 } 4563 message.append(" ["); 4564 message.append(Integer.toString(i)); 4565 message.append(", "); 4566 message.append(Integer.toString(j)); 4567 message.append("]"); 4568 } 4569 } 4570 } 4571 assertFalse("Incorrect output for checkConvertUint3Uchar3" + 4572 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4573 } 4574 4575 private void checkConvertUint4Uchar4() { 4576 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4b09f9f5cfeb5l, false, 8); 4577 try { 4578 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4579 script.forEach_testConvertUchar4Uint4Uchar4(inV, out); 4580 verifyResultsConvertUint4Uchar4(inV, out, false); 4581 out.destroy(); 4582 } catch (Exception e) { 4583 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString()); 4584 } 4585 try { 4586 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4587 scriptRelaxed.forEach_testConvertUchar4Uint4Uchar4(inV, out); 4588 verifyResultsConvertUint4Uchar4(inV, out, true); 4589 out.destroy(); 4590 } catch (Exception e) { 4591 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString()); 4592 } 4593 inV.destroy(); 4594 } 4595 4596 private void verifyResultsConvertUint4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 4597 int[] arrayInV = new int[INPUTSIZE * 4]; 4598 Arrays.fill(arrayInV, (int) 42); 4599 inV.copyTo(arrayInV); 4600 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4601 Arrays.fill(arrayOut, (byte) 42); 4602 out.copyTo(arrayOut); 4603 StringBuilder message = new StringBuilder(); 4604 boolean errorFound = false; 4605 for (int i = 0; i < INPUTSIZE; i++) { 4606 for (int j = 0; j < 4 ; j++) { 4607 // Extract the inputs. 4608 ArgumentsUintUchar args = new ArgumentsUintUchar(); 4609 args.inV = arrayInV[i * 4 + j]; 4610 // Figure out what the outputs should have been. 4611 CoreMathVerifier.computeConvert(args); 4612 // Validate the outputs. 4613 boolean valid = true; 4614 if (args.out != arrayOut[i * 4 + j]) { 4615 valid = false; 4616 } 4617 if (!valid) { 4618 if (!errorFound) { 4619 errorFound = true; 4620 message.append("Input inV: "); 4621 appendVariableToMessage(message, args.inV); 4622 message.append("\n"); 4623 message.append("Expected output out: "); 4624 appendVariableToMessage(message, args.out); 4625 message.append("\n"); 4626 message.append("Actual output out: "); 4627 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4628 if (args.out != arrayOut[i * 4 + j]) { 4629 message.append(" FAIL"); 4630 } 4631 message.append("\n"); 4632 message.append("Errors at"); 4633 } 4634 message.append(" ["); 4635 message.append(Integer.toString(i)); 4636 message.append(", "); 4637 message.append(Integer.toString(j)); 4638 message.append("]"); 4639 } 4640 } 4641 } 4642 assertFalse("Incorrect output for checkConvertUint4Uchar4" + 4643 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4644 } 4645 4646 public class ArgumentsFloatShort { 4647 public float inV; 4648 public short out; 4649 } 4650 4651 private void checkConvertFloat2Short2() { 4652 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb529ef98fcf2692l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 4653 try { 4654 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4655 script.forEach_testConvertShort2Float2Short2(inV, out); 4656 verifyResultsConvertFloat2Short2(inV, out, false); 4657 out.destroy(); 4658 } catch (Exception e) { 4659 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString()); 4660 } 4661 try { 4662 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4663 scriptRelaxed.forEach_testConvertShort2Float2Short2(inV, out); 4664 verifyResultsConvertFloat2Short2(inV, out, true); 4665 out.destroy(); 4666 } catch (Exception e) { 4667 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString()); 4668 } 4669 inV.destroy(); 4670 } 4671 4672 private void verifyResultsConvertFloat2Short2(Allocation inV, Allocation out, boolean relaxed) { 4673 float[] arrayInV = new float[INPUTSIZE * 2]; 4674 Arrays.fill(arrayInV, (float) 42); 4675 inV.copyTo(arrayInV); 4676 short[] arrayOut = new short[INPUTSIZE * 2]; 4677 Arrays.fill(arrayOut, (short) 42); 4678 out.copyTo(arrayOut); 4679 StringBuilder message = new StringBuilder(); 4680 boolean errorFound = false; 4681 for (int i = 0; i < INPUTSIZE; i++) { 4682 for (int j = 0; j < 2 ; j++) { 4683 // Extract the inputs. 4684 ArgumentsFloatShort args = new ArgumentsFloatShort(); 4685 args.inV = arrayInV[i * 2 + j]; 4686 // Figure out what the outputs should have been. 4687 CoreMathVerifier.computeConvert(args); 4688 // Validate the outputs. 4689 boolean valid = true; 4690 if (args.out != arrayOut[i * 2 + j]) { 4691 valid = false; 4692 } 4693 if (!valid) { 4694 if (!errorFound) { 4695 errorFound = true; 4696 message.append("Input inV: "); 4697 appendVariableToMessage(message, args.inV); 4698 message.append("\n"); 4699 message.append("Expected output out: "); 4700 appendVariableToMessage(message, args.out); 4701 message.append("\n"); 4702 message.append("Actual output out: "); 4703 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4704 if (args.out != arrayOut[i * 2 + j]) { 4705 message.append(" FAIL"); 4706 } 4707 message.append("\n"); 4708 message.append("Errors at"); 4709 } 4710 message.append(" ["); 4711 message.append(Integer.toString(i)); 4712 message.append(", "); 4713 message.append(Integer.toString(j)); 4714 message.append("]"); 4715 } 4716 } 4717 } 4718 assertFalse("Incorrect output for checkConvertFloat2Short2" + 4719 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4720 } 4721 4722 private void checkConvertFloat3Short3() { 4723 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb54681485ea4770l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 4724 try { 4725 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4726 script.forEach_testConvertShort3Float3Short3(inV, out); 4727 verifyResultsConvertFloat3Short3(inV, out, false); 4728 out.destroy(); 4729 } catch (Exception e) { 4730 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString()); 4731 } 4732 try { 4733 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4734 scriptRelaxed.forEach_testConvertShort3Float3Short3(inV, out); 4735 verifyResultsConvertFloat3Short3(inV, out, true); 4736 out.destroy(); 4737 } catch (Exception e) { 4738 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString()); 4739 } 4740 inV.destroy(); 4741 } 4742 4743 private void verifyResultsConvertFloat3Short3(Allocation inV, Allocation out, boolean relaxed) { 4744 float[] arrayInV = new float[INPUTSIZE * 4]; 4745 Arrays.fill(arrayInV, (float) 42); 4746 inV.copyTo(arrayInV); 4747 short[] arrayOut = new short[INPUTSIZE * 4]; 4748 Arrays.fill(arrayOut, (short) 42); 4749 out.copyTo(arrayOut); 4750 StringBuilder message = new StringBuilder(); 4751 boolean errorFound = false; 4752 for (int i = 0; i < INPUTSIZE; i++) { 4753 for (int j = 0; j < 3 ; j++) { 4754 // Extract the inputs. 4755 ArgumentsFloatShort args = new ArgumentsFloatShort(); 4756 args.inV = arrayInV[i * 4 + j]; 4757 // Figure out what the outputs should have been. 4758 CoreMathVerifier.computeConvert(args); 4759 // Validate the outputs. 4760 boolean valid = true; 4761 if (args.out != arrayOut[i * 4 + j]) { 4762 valid = false; 4763 } 4764 if (!valid) { 4765 if (!errorFound) { 4766 errorFound = true; 4767 message.append("Input inV: "); 4768 appendVariableToMessage(message, args.inV); 4769 message.append("\n"); 4770 message.append("Expected output out: "); 4771 appendVariableToMessage(message, args.out); 4772 message.append("\n"); 4773 message.append("Actual output out: "); 4774 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4775 if (args.out != arrayOut[i * 4 + j]) { 4776 message.append(" FAIL"); 4777 } 4778 message.append("\n"); 4779 message.append("Errors at"); 4780 } 4781 message.append(" ["); 4782 message.append(Integer.toString(i)); 4783 message.append(", "); 4784 message.append(Integer.toString(j)); 4785 message.append("]"); 4786 } 4787 } 4788 } 4789 assertFalse("Incorrect output for checkConvertFloat3Short3" + 4790 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4791 } 4792 4793 private void checkConvertFloat4Short4() { 4794 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56312f7c05684el, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 4795 try { 4796 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 4797 script.forEach_testConvertShort4Float4Short4(inV, out); 4798 verifyResultsConvertFloat4Short4(inV, out, false); 4799 out.destroy(); 4800 } catch (Exception e) { 4801 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString()); 4802 } 4803 try { 4804 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 4805 scriptRelaxed.forEach_testConvertShort4Float4Short4(inV, out); 4806 verifyResultsConvertFloat4Short4(inV, out, true); 4807 out.destroy(); 4808 } catch (Exception e) { 4809 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString()); 4810 } 4811 inV.destroy(); 4812 } 4813 4814 private void verifyResultsConvertFloat4Short4(Allocation inV, Allocation out, boolean relaxed) { 4815 float[] arrayInV = new float[INPUTSIZE * 4]; 4816 Arrays.fill(arrayInV, (float) 42); 4817 inV.copyTo(arrayInV); 4818 short[] arrayOut = new short[INPUTSIZE * 4]; 4819 Arrays.fill(arrayOut, (short) 42); 4820 out.copyTo(arrayOut); 4821 StringBuilder message = new StringBuilder(); 4822 boolean errorFound = false; 4823 for (int i = 0; i < INPUTSIZE; i++) { 4824 for (int j = 0; j < 4 ; j++) { 4825 // Extract the inputs. 4826 ArgumentsFloatShort args = new ArgumentsFloatShort(); 4827 args.inV = arrayInV[i * 4 + j]; 4828 // Figure out what the outputs should have been. 4829 CoreMathVerifier.computeConvert(args); 4830 // Validate the outputs. 4831 boolean valid = true; 4832 if (args.out != arrayOut[i * 4 + j]) { 4833 valid = false; 4834 } 4835 if (!valid) { 4836 if (!errorFound) { 4837 errorFound = true; 4838 message.append("Input inV: "); 4839 appendVariableToMessage(message, args.inV); 4840 message.append("\n"); 4841 message.append("Expected output out: "); 4842 appendVariableToMessage(message, args.out); 4843 message.append("\n"); 4844 message.append("Actual output out: "); 4845 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4846 if (args.out != arrayOut[i * 4 + j]) { 4847 message.append(" FAIL"); 4848 } 4849 message.append("\n"); 4850 message.append("Errors at"); 4851 } 4852 message.append(" ["); 4853 message.append(Integer.toString(i)); 4854 message.append(", "); 4855 message.append(Integer.toString(j)); 4856 message.append("]"); 4857 } 4858 } 4859 } 4860 assertFalse("Incorrect output for checkConvertFloat4Short4" + 4861 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4862 } 4863 4864 public class ArgumentsCharShort { 4865 public byte inV; 4866 public short out; 4867 } 4868 4869 private void checkConvertChar2Short2() { 4870 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x58626b4b60f84e52l, true, 7); 4871 try { 4872 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4873 script.forEach_testConvertShort2Char2Short2(inV, out); 4874 verifyResultsConvertChar2Short2(inV, out, false); 4875 out.destroy(); 4876 } catch (Exception e) { 4877 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString()); 4878 } 4879 try { 4880 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4881 scriptRelaxed.forEach_testConvertShort2Char2Short2(inV, out); 4882 verifyResultsConvertChar2Short2(inV, out, true); 4883 out.destroy(); 4884 } catch (Exception e) { 4885 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString()); 4886 } 4887 inV.destroy(); 4888 } 4889 4890 private void verifyResultsConvertChar2Short2(Allocation inV, Allocation out, boolean relaxed) { 4891 byte[] arrayInV = new byte[INPUTSIZE * 2]; 4892 Arrays.fill(arrayInV, (byte) 42); 4893 inV.copyTo(arrayInV); 4894 short[] arrayOut = new short[INPUTSIZE * 2]; 4895 Arrays.fill(arrayOut, (short) 42); 4896 out.copyTo(arrayOut); 4897 StringBuilder message = new StringBuilder(); 4898 boolean errorFound = false; 4899 for (int i = 0; i < INPUTSIZE; i++) { 4900 for (int j = 0; j < 2 ; j++) { 4901 // Extract the inputs. 4902 ArgumentsCharShort args = new ArgumentsCharShort(); 4903 args.inV = arrayInV[i * 2 + j]; 4904 // Figure out what the outputs should have been. 4905 CoreMathVerifier.computeConvert(args); 4906 // Validate the outputs. 4907 boolean valid = true; 4908 if (args.out != arrayOut[i * 2 + j]) { 4909 valid = false; 4910 } 4911 if (!valid) { 4912 if (!errorFound) { 4913 errorFound = true; 4914 message.append("Input inV: "); 4915 appendVariableToMessage(message, args.inV); 4916 message.append("\n"); 4917 message.append("Expected output out: "); 4918 appendVariableToMessage(message, args.out); 4919 message.append("\n"); 4920 message.append("Actual output out: "); 4921 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4922 if (args.out != arrayOut[i * 2 + j]) { 4923 message.append(" FAIL"); 4924 } 4925 message.append("\n"); 4926 message.append("Errors at"); 4927 } 4928 message.append(" ["); 4929 message.append(Integer.toString(i)); 4930 message.append(", "); 4931 message.append(Integer.toString(j)); 4932 message.append("]"); 4933 } 4934 } 4935 } 4936 assertFalse("Incorrect output for checkConvertChar2Short2" + 4937 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4938 } 4939 4940 private void checkConvertChar3Short3() { 4941 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x5864346657136f30l, true, 7); 4942 try { 4943 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4944 script.forEach_testConvertShort3Char3Short3(inV, out); 4945 verifyResultsConvertChar3Short3(inV, out, false); 4946 out.destroy(); 4947 } catch (Exception e) { 4948 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString()); 4949 } 4950 try { 4951 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4952 scriptRelaxed.forEach_testConvertShort3Char3Short3(inV, out); 4953 verifyResultsConvertChar3Short3(inV, out, true); 4954 out.destroy(); 4955 } catch (Exception e) { 4956 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString()); 4957 } 4958 inV.destroy(); 4959 } 4960 4961 private void verifyResultsConvertChar3Short3(Allocation inV, Allocation out, boolean relaxed) { 4962 byte[] arrayInV = new byte[INPUTSIZE * 4]; 4963 Arrays.fill(arrayInV, (byte) 42); 4964 inV.copyTo(arrayInV); 4965 short[] arrayOut = new short[INPUTSIZE * 4]; 4966 Arrays.fill(arrayOut, (short) 42); 4967 out.copyTo(arrayOut); 4968 StringBuilder message = new StringBuilder(); 4969 boolean errorFound = false; 4970 for (int i = 0; i < INPUTSIZE; i++) { 4971 for (int j = 0; j < 3 ; j++) { 4972 // Extract the inputs. 4973 ArgumentsCharShort args = new ArgumentsCharShort(); 4974 args.inV = arrayInV[i * 4 + j]; 4975 // Figure out what the outputs should have been. 4976 CoreMathVerifier.computeConvert(args); 4977 // Validate the outputs. 4978 boolean valid = true; 4979 if (args.out != arrayOut[i * 4 + j]) { 4980 valid = false; 4981 } 4982 if (!valid) { 4983 if (!errorFound) { 4984 errorFound = true; 4985 message.append("Input inV: "); 4986 appendVariableToMessage(message, args.inV); 4987 message.append("\n"); 4988 message.append("Expected output out: "); 4989 appendVariableToMessage(message, args.out); 4990 message.append("\n"); 4991 message.append("Actual output out: "); 4992 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4993 if (args.out != arrayOut[i * 4 + j]) { 4994 message.append(" FAIL"); 4995 } 4996 message.append("\n"); 4997 message.append("Errors at"); 4998 } 4999 message.append(" ["); 5000 message.append(Integer.toString(i)); 5001 message.append(", "); 5002 message.append(Integer.toString(j)); 5003 message.append("]"); 5004 } 5005 } 5006 } 5007 assertFalse("Incorrect output for checkConvertChar3Short3" + 5008 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5009 } 5010 5011 private void checkConvertChar4Short4() { 5012 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5865fd814d2e900el, true, 7); 5013 try { 5014 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5015 script.forEach_testConvertShort4Char4Short4(inV, out); 5016 verifyResultsConvertChar4Short4(inV, out, false); 5017 out.destroy(); 5018 } catch (Exception e) { 5019 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString()); 5020 } 5021 try { 5022 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5023 scriptRelaxed.forEach_testConvertShort4Char4Short4(inV, out); 5024 verifyResultsConvertChar4Short4(inV, out, true); 5025 out.destroy(); 5026 } catch (Exception e) { 5027 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString()); 5028 } 5029 inV.destroy(); 5030 } 5031 5032 private void verifyResultsConvertChar4Short4(Allocation inV, Allocation out, boolean relaxed) { 5033 byte[] arrayInV = new byte[INPUTSIZE * 4]; 5034 Arrays.fill(arrayInV, (byte) 42); 5035 inV.copyTo(arrayInV); 5036 short[] arrayOut = new short[INPUTSIZE * 4]; 5037 Arrays.fill(arrayOut, (short) 42); 5038 out.copyTo(arrayOut); 5039 StringBuilder message = new StringBuilder(); 5040 boolean errorFound = false; 5041 for (int i = 0; i < INPUTSIZE; i++) { 5042 for (int j = 0; j < 4 ; j++) { 5043 // Extract the inputs. 5044 ArgumentsCharShort args = new ArgumentsCharShort(); 5045 args.inV = arrayInV[i * 4 + j]; 5046 // Figure out what the outputs should have been. 5047 CoreMathVerifier.computeConvert(args); 5048 // Validate the outputs. 5049 boolean valid = true; 5050 if (args.out != arrayOut[i * 4 + j]) { 5051 valid = false; 5052 } 5053 if (!valid) { 5054 if (!errorFound) { 5055 errorFound = true; 5056 message.append("Input inV: "); 5057 appendVariableToMessage(message, args.inV); 5058 message.append("\n"); 5059 message.append("Expected output out: "); 5060 appendVariableToMessage(message, args.out); 5061 message.append("\n"); 5062 message.append("Actual output out: "); 5063 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5064 if (args.out != arrayOut[i * 4 + j]) { 5065 message.append(" FAIL"); 5066 } 5067 message.append("\n"); 5068 message.append("Errors at"); 5069 } 5070 message.append(" ["); 5071 message.append(Integer.toString(i)); 5072 message.append(", "); 5073 message.append(Integer.toString(j)); 5074 message.append("]"); 5075 } 5076 } 5077 } 5078 assertFalse("Incorrect output for checkConvertChar4Short4" + 5079 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5080 } 5081 5082 public class ArgumentsUcharShort { 5083 public byte inV; 5084 public short out; 5085 } 5086 5087 private void checkConvertUchar2Short2() { 5088 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d308b52fcd067fdl, false, 8); 5089 try { 5090 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5091 script.forEach_testConvertShort2Uchar2Short2(inV, out); 5092 verifyResultsConvertUchar2Short2(inV, out, false); 5093 out.destroy(); 5094 } catch (Exception e) { 5095 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString()); 5096 } 5097 try { 5098 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5099 scriptRelaxed.forEach_testConvertShort2Uchar2Short2(inV, out); 5100 verifyResultsConvertUchar2Short2(inV, out, true); 5101 out.destroy(); 5102 } catch (Exception e) { 5103 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString()); 5104 } 5105 inV.destroy(); 5106 } 5107 5108 private void verifyResultsConvertUchar2Short2(Allocation inV, Allocation out, boolean relaxed) { 5109 byte[] arrayInV = new byte[INPUTSIZE * 2]; 5110 Arrays.fill(arrayInV, (byte) 42); 5111 inV.copyTo(arrayInV); 5112 short[] arrayOut = new short[INPUTSIZE * 2]; 5113 Arrays.fill(arrayOut, (short) 42); 5114 out.copyTo(arrayOut); 5115 StringBuilder message = new StringBuilder(); 5116 boolean errorFound = false; 5117 for (int i = 0; i < INPUTSIZE; i++) { 5118 for (int j = 0; j < 2 ; j++) { 5119 // Extract the inputs. 5120 ArgumentsUcharShort args = new ArgumentsUcharShort(); 5121 args.inV = arrayInV[i * 2 + j]; 5122 // Figure out what the outputs should have been. 5123 CoreMathVerifier.computeConvert(args); 5124 // Validate the outputs. 5125 boolean valid = true; 5126 if (args.out != arrayOut[i * 2 + j]) { 5127 valid = false; 5128 } 5129 if (!valid) { 5130 if (!errorFound) { 5131 errorFound = true; 5132 message.append("Input inV: "); 5133 appendVariableToMessage(message, args.inV); 5134 message.append("\n"); 5135 message.append("Expected output out: "); 5136 appendVariableToMessage(message, args.out); 5137 message.append("\n"); 5138 message.append("Actual output out: "); 5139 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5140 if (args.out != arrayOut[i * 2 + j]) { 5141 message.append(" FAIL"); 5142 } 5143 message.append("\n"); 5144 message.append("Errors at"); 5145 } 5146 message.append(" ["); 5147 message.append(Integer.toString(i)); 5148 message.append(", "); 5149 message.append(Integer.toString(j)); 5150 message.append("]"); 5151 } 5152 } 5153 } 5154 assertFalse("Incorrect output for checkConvertUchar2Short2" + 5155 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5156 } 5157 5158 private void checkConvertUchar3Short3() { 5159 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d32546df2eb88dbl, false, 8); 5160 try { 5161 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5162 script.forEach_testConvertShort3Uchar3Short3(inV, out); 5163 verifyResultsConvertUchar3Short3(inV, out, false); 5164 out.destroy(); 5165 } catch (Exception e) { 5166 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString()); 5167 } 5168 try { 5169 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5170 scriptRelaxed.forEach_testConvertShort3Uchar3Short3(inV, out); 5171 verifyResultsConvertUchar3Short3(inV, out, true); 5172 out.destroy(); 5173 } catch (Exception e) { 5174 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString()); 5175 } 5176 inV.destroy(); 5177 } 5178 5179 private void verifyResultsConvertUchar3Short3(Allocation inV, Allocation out, boolean relaxed) { 5180 byte[] arrayInV = new byte[INPUTSIZE * 4]; 5181 Arrays.fill(arrayInV, (byte) 42); 5182 inV.copyTo(arrayInV); 5183 short[] arrayOut = new short[INPUTSIZE * 4]; 5184 Arrays.fill(arrayOut, (short) 42); 5185 out.copyTo(arrayOut); 5186 StringBuilder message = new StringBuilder(); 5187 boolean errorFound = false; 5188 for (int i = 0; i < INPUTSIZE; i++) { 5189 for (int j = 0; j < 3 ; j++) { 5190 // Extract the inputs. 5191 ArgumentsUcharShort args = new ArgumentsUcharShort(); 5192 args.inV = arrayInV[i * 4 + j]; 5193 // Figure out what the outputs should have been. 5194 CoreMathVerifier.computeConvert(args); 5195 // Validate the outputs. 5196 boolean valid = true; 5197 if (args.out != arrayOut[i * 4 + j]) { 5198 valid = false; 5199 } 5200 if (!valid) { 5201 if (!errorFound) { 5202 errorFound = true; 5203 message.append("Input inV: "); 5204 appendVariableToMessage(message, args.inV); 5205 message.append("\n"); 5206 message.append("Expected output out: "); 5207 appendVariableToMessage(message, args.out); 5208 message.append("\n"); 5209 message.append("Actual output out: "); 5210 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5211 if (args.out != arrayOut[i * 4 + j]) { 5212 message.append(" FAIL"); 5213 } 5214 message.append("\n"); 5215 message.append("Errors at"); 5216 } 5217 message.append(" ["); 5218 message.append(Integer.toString(i)); 5219 message.append(", "); 5220 message.append(Integer.toString(j)); 5221 message.append("]"); 5222 } 5223 } 5224 } 5225 assertFalse("Incorrect output for checkConvertUchar3Short3" + 5226 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5227 } 5228 5229 private void checkConvertUchar4Short4() { 5230 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d341d88e906a9b9l, false, 8); 5231 try { 5232 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5233 script.forEach_testConvertShort4Uchar4Short4(inV, out); 5234 verifyResultsConvertUchar4Short4(inV, out, false); 5235 out.destroy(); 5236 } catch (Exception e) { 5237 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString()); 5238 } 5239 try { 5240 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5241 scriptRelaxed.forEach_testConvertShort4Uchar4Short4(inV, out); 5242 verifyResultsConvertUchar4Short4(inV, out, true); 5243 out.destroy(); 5244 } catch (Exception e) { 5245 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString()); 5246 } 5247 inV.destroy(); 5248 } 5249 5250 private void verifyResultsConvertUchar4Short4(Allocation inV, Allocation out, boolean relaxed) { 5251 byte[] arrayInV = new byte[INPUTSIZE * 4]; 5252 Arrays.fill(arrayInV, (byte) 42); 5253 inV.copyTo(arrayInV); 5254 short[] arrayOut = new short[INPUTSIZE * 4]; 5255 Arrays.fill(arrayOut, (short) 42); 5256 out.copyTo(arrayOut); 5257 StringBuilder message = new StringBuilder(); 5258 boolean errorFound = false; 5259 for (int i = 0; i < INPUTSIZE; i++) { 5260 for (int j = 0; j < 4 ; j++) { 5261 // Extract the inputs. 5262 ArgumentsUcharShort args = new ArgumentsUcharShort(); 5263 args.inV = arrayInV[i * 4 + j]; 5264 // Figure out what the outputs should have been. 5265 CoreMathVerifier.computeConvert(args); 5266 // Validate the outputs. 5267 boolean valid = true; 5268 if (args.out != arrayOut[i * 4 + j]) { 5269 valid = false; 5270 } 5271 if (!valid) { 5272 if (!errorFound) { 5273 errorFound = true; 5274 message.append("Input inV: "); 5275 appendVariableToMessage(message, args.inV); 5276 message.append("\n"); 5277 message.append("Expected output out: "); 5278 appendVariableToMessage(message, args.out); 5279 message.append("\n"); 5280 message.append("Actual output out: "); 5281 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5282 if (args.out != arrayOut[i * 4 + j]) { 5283 message.append(" FAIL"); 5284 } 5285 message.append("\n"); 5286 message.append("Errors at"); 5287 } 5288 message.append(" ["); 5289 message.append(Integer.toString(i)); 5290 message.append(", "); 5291 message.append(Integer.toString(j)); 5292 message.append("]"); 5293 } 5294 } 5295 } 5296 assertFalse("Incorrect output for checkConvertUchar4Short4" + 5297 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5298 } 5299 5300 public class ArgumentsShortShort { 5301 public short inV; 5302 public short out; 5303 } 5304 5305 private void checkConvertShort2Short2() { 5306 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94caa18440d14d3el, true, 15); 5307 try { 5308 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5309 script.forEach_testConvertShort2Short2Short2(inV, out); 5310 verifyResultsConvertShort2Short2(inV, out, false); 5311 out.destroy(); 5312 } catch (Exception e) { 5313 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString()); 5314 } 5315 try { 5316 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5317 scriptRelaxed.forEach_testConvertShort2Short2Short2(inV, out); 5318 verifyResultsConvertShort2Short2(inV, out, true); 5319 out.destroy(); 5320 } catch (Exception e) { 5321 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString()); 5322 } 5323 inV.destroy(); 5324 } 5325 5326 private void verifyResultsConvertShort2Short2(Allocation inV, Allocation out, boolean relaxed) { 5327 short[] arrayInV = new short[INPUTSIZE * 2]; 5328 Arrays.fill(arrayInV, (short) 42); 5329 inV.copyTo(arrayInV); 5330 short[] arrayOut = new short[INPUTSIZE * 2]; 5331 Arrays.fill(arrayOut, (short) 42); 5332 out.copyTo(arrayOut); 5333 StringBuilder message = new StringBuilder(); 5334 boolean errorFound = false; 5335 for (int i = 0; i < INPUTSIZE; i++) { 5336 for (int j = 0; j < 2 ; j++) { 5337 // Extract the inputs. 5338 ArgumentsShortShort args = new ArgumentsShortShort(); 5339 args.inV = arrayInV[i * 2 + j]; 5340 // Figure out what the outputs should have been. 5341 CoreMathVerifier.computeConvert(args); 5342 // Validate the outputs. 5343 boolean valid = true; 5344 if (args.out != arrayOut[i * 2 + j]) { 5345 valid = false; 5346 } 5347 if (!valid) { 5348 if (!errorFound) { 5349 errorFound = true; 5350 message.append("Input inV: "); 5351 appendVariableToMessage(message, args.inV); 5352 message.append("\n"); 5353 message.append("Expected output out: "); 5354 appendVariableToMessage(message, args.out); 5355 message.append("\n"); 5356 message.append("Actual output out: "); 5357 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5358 if (args.out != arrayOut[i * 2 + j]) { 5359 message.append(" FAIL"); 5360 } 5361 message.append("\n"); 5362 message.append("Errors at"); 5363 } 5364 message.append(" ["); 5365 message.append(Integer.toString(i)); 5366 message.append(", "); 5367 message.append(Integer.toString(j)); 5368 message.append("]"); 5369 } 5370 } 5371 } 5372 assertFalse("Incorrect output for checkConvertShort2Short2" + 5373 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5374 } 5375 5376 private void checkConvertShort3Short3() { 5377 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc6a9f36ec6e1cl, true, 15); 5378 try { 5379 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5380 script.forEach_testConvertShort3Short3Short3(inV, out); 5381 verifyResultsConvertShort3Short3(inV, out, false); 5382 out.destroy(); 5383 } catch (Exception e) { 5384 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString()); 5385 } 5386 try { 5387 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5388 scriptRelaxed.forEach_testConvertShort3Short3Short3(inV, out); 5389 verifyResultsConvertShort3Short3(inV, out, true); 5390 out.destroy(); 5391 } catch (Exception e) { 5392 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString()); 5393 } 5394 inV.destroy(); 5395 } 5396 5397 private void verifyResultsConvertShort3Short3(Allocation inV, Allocation out, boolean relaxed) { 5398 short[] arrayInV = new short[INPUTSIZE * 4]; 5399 Arrays.fill(arrayInV, (short) 42); 5400 inV.copyTo(arrayInV); 5401 short[] arrayOut = new short[INPUTSIZE * 4]; 5402 Arrays.fill(arrayOut, (short) 42); 5403 out.copyTo(arrayOut); 5404 StringBuilder message = new StringBuilder(); 5405 boolean errorFound = false; 5406 for (int i = 0; i < INPUTSIZE; i++) { 5407 for (int j = 0; j < 3 ; j++) { 5408 // Extract the inputs. 5409 ArgumentsShortShort args = new ArgumentsShortShort(); 5410 args.inV = arrayInV[i * 4 + j]; 5411 // Figure out what the outputs should have been. 5412 CoreMathVerifier.computeConvert(args); 5413 // Validate the outputs. 5414 boolean valid = true; 5415 if (args.out != arrayOut[i * 4 + j]) { 5416 valid = false; 5417 } 5418 if (!valid) { 5419 if (!errorFound) { 5420 errorFound = true; 5421 message.append("Input inV: "); 5422 appendVariableToMessage(message, args.inV); 5423 message.append("\n"); 5424 message.append("Expected output out: "); 5425 appendVariableToMessage(message, args.out); 5426 message.append("\n"); 5427 message.append("Actual output out: "); 5428 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5429 if (args.out != arrayOut[i * 4 + j]) { 5430 message.append(" FAIL"); 5431 } 5432 message.append("\n"); 5433 message.append("Errors at"); 5434 } 5435 message.append(" ["); 5436 message.append(Integer.toString(i)); 5437 message.append(", "); 5438 message.append(Integer.toString(j)); 5439 message.append("]"); 5440 } 5441 } 5442 } 5443 assertFalse("Incorrect output for checkConvertShort3Short3" + 5444 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5445 } 5446 5447 private void checkConvertShort4Short4() { 5448 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce33ba2d078efal, true, 15); 5449 try { 5450 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5451 script.forEach_testConvertShort4Short4Short4(inV, out); 5452 verifyResultsConvertShort4Short4(inV, out, false); 5453 out.destroy(); 5454 } catch (Exception e) { 5455 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString()); 5456 } 5457 try { 5458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5459 scriptRelaxed.forEach_testConvertShort4Short4Short4(inV, out); 5460 verifyResultsConvertShort4Short4(inV, out, true); 5461 out.destroy(); 5462 } catch (Exception e) { 5463 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString()); 5464 } 5465 inV.destroy(); 5466 } 5467 5468 private void verifyResultsConvertShort4Short4(Allocation inV, Allocation out, boolean relaxed) { 5469 short[] arrayInV = new short[INPUTSIZE * 4]; 5470 Arrays.fill(arrayInV, (short) 42); 5471 inV.copyTo(arrayInV); 5472 short[] arrayOut = new short[INPUTSIZE * 4]; 5473 Arrays.fill(arrayOut, (short) 42); 5474 out.copyTo(arrayOut); 5475 StringBuilder message = new StringBuilder(); 5476 boolean errorFound = false; 5477 for (int i = 0; i < INPUTSIZE; i++) { 5478 for (int j = 0; j < 4 ; j++) { 5479 // Extract the inputs. 5480 ArgumentsShortShort args = new ArgumentsShortShort(); 5481 args.inV = arrayInV[i * 4 + j]; 5482 // Figure out what the outputs should have been. 5483 CoreMathVerifier.computeConvert(args); 5484 // Validate the outputs. 5485 boolean valid = true; 5486 if (args.out != arrayOut[i * 4 + j]) { 5487 valid = false; 5488 } 5489 if (!valid) { 5490 if (!errorFound) { 5491 errorFound = true; 5492 message.append("Input inV: "); 5493 appendVariableToMessage(message, args.inV); 5494 message.append("\n"); 5495 message.append("Expected output out: "); 5496 appendVariableToMessage(message, args.out); 5497 message.append("\n"); 5498 message.append("Actual output out: "); 5499 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5500 if (args.out != arrayOut[i * 4 + j]) { 5501 message.append(" FAIL"); 5502 } 5503 message.append("\n"); 5504 message.append("Errors at"); 5505 } 5506 message.append(" ["); 5507 message.append(Integer.toString(i)); 5508 message.append(", "); 5509 message.append(Integer.toString(j)); 5510 message.append("]"); 5511 } 5512 } 5513 } 5514 assertFalse("Incorrect output for checkConvertShort4Short4" + 5515 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5516 } 5517 5518 public class ArgumentsUshortShort { 5519 public short inV; 5520 public short out; 5521 } 5522 5523 private void checkConvertUshort2Short2() { 5524 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a02cb6e1d9cf7l, false, 15); 5525 try { 5526 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5527 script.forEach_testConvertShort2Ushort2Short2(inV, out); 5528 verifyResultsConvertUshort2Short2(inV, out, false); 5529 out.destroy(); 5530 } catch (Exception e) { 5531 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString()); 5532 } 5533 try { 5534 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5535 scriptRelaxed.forEach_testConvertShort2Ushort2Short2(inV, out); 5536 verifyResultsConvertUshort2Short2(inV, out, true); 5537 out.destroy(); 5538 } catch (Exception e) { 5539 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString()); 5540 } 5541 inV.destroy(); 5542 } 5543 5544 private void verifyResultsConvertUshort2Short2(Allocation inV, Allocation out, boolean relaxed) { 5545 short[] arrayInV = new short[INPUTSIZE * 2]; 5546 Arrays.fill(arrayInV, (short) 42); 5547 inV.copyTo(arrayInV); 5548 short[] arrayOut = new short[INPUTSIZE * 2]; 5549 Arrays.fill(arrayOut, (short) 42); 5550 out.copyTo(arrayOut); 5551 StringBuilder message = new StringBuilder(); 5552 boolean errorFound = false; 5553 for (int i = 0; i < INPUTSIZE; i++) { 5554 for (int j = 0; j < 2 ; j++) { 5555 // Extract the inputs. 5556 ArgumentsUshortShort args = new ArgumentsUshortShort(); 5557 args.inV = arrayInV[i * 2 + j]; 5558 // Figure out what the outputs should have been. 5559 CoreMathVerifier.computeConvert(args); 5560 // Validate the outputs. 5561 boolean valid = true; 5562 if (args.out != arrayOut[i * 2 + j]) { 5563 valid = false; 5564 } 5565 if (!valid) { 5566 if (!errorFound) { 5567 errorFound = true; 5568 message.append("Input inV: "); 5569 appendVariableToMessage(message, args.inV); 5570 message.append("\n"); 5571 message.append("Expected output out: "); 5572 appendVariableToMessage(message, args.out); 5573 message.append("\n"); 5574 message.append("Actual output out: "); 5575 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5576 if (args.out != arrayOut[i * 2 + j]) { 5577 message.append(" FAIL"); 5578 } 5579 message.append("\n"); 5580 message.append("Errors at"); 5581 } 5582 message.append(" ["); 5583 message.append(Integer.toString(i)); 5584 message.append(", "); 5585 message.append(Integer.toString(j)); 5586 message.append("]"); 5587 } 5588 } 5589 } 5590 assertFalse("Incorrect output for checkConvertUshort2Short2" + 5591 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5592 } 5593 5594 private void checkConvertUshort3Short3() { 5595 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36bcbe66438bdd5l, false, 15); 5596 try { 5597 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5598 script.forEach_testConvertShort3Ushort3Short3(inV, out); 5599 verifyResultsConvertUshort3Short3(inV, out, false); 5600 out.destroy(); 5601 } catch (Exception e) { 5602 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString()); 5603 } 5604 try { 5605 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5606 scriptRelaxed.forEach_testConvertShort3Ushort3Short3(inV, out); 5607 verifyResultsConvertUshort3Short3(inV, out, true); 5608 out.destroy(); 5609 } catch (Exception e) { 5610 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString()); 5611 } 5612 inV.destroy(); 5613 } 5614 5615 private void verifyResultsConvertUshort3Short3(Allocation inV, Allocation out, boolean relaxed) { 5616 short[] arrayInV = new short[INPUTSIZE * 4]; 5617 Arrays.fill(arrayInV, (short) 42); 5618 inV.copyTo(arrayInV); 5619 short[] arrayOut = new short[INPUTSIZE * 4]; 5620 Arrays.fill(arrayOut, (short) 42); 5621 out.copyTo(arrayOut); 5622 StringBuilder message = new StringBuilder(); 5623 boolean errorFound = false; 5624 for (int i = 0; i < INPUTSIZE; i++) { 5625 for (int j = 0; j < 3 ; j++) { 5626 // Extract the inputs. 5627 ArgumentsUshortShort args = new ArgumentsUshortShort(); 5628 args.inV = arrayInV[i * 4 + j]; 5629 // Figure out what the outputs should have been. 5630 CoreMathVerifier.computeConvert(args); 5631 // Validate the outputs. 5632 boolean valid = true; 5633 if (args.out != arrayOut[i * 4 + j]) { 5634 valid = false; 5635 } 5636 if (!valid) { 5637 if (!errorFound) { 5638 errorFound = true; 5639 message.append("Input inV: "); 5640 appendVariableToMessage(message, args.inV); 5641 message.append("\n"); 5642 message.append("Expected output out: "); 5643 appendVariableToMessage(message, args.out); 5644 message.append("\n"); 5645 message.append("Actual output out: "); 5646 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5647 if (args.out != arrayOut[i * 4 + j]) { 5648 message.append(" FAIL"); 5649 } 5650 message.append("\n"); 5651 message.append("Errors at"); 5652 } 5653 message.append(" ["); 5654 message.append(Integer.toString(i)); 5655 message.append(", "); 5656 message.append(Integer.toString(j)); 5657 message.append("]"); 5658 } 5659 } 5660 } 5661 assertFalse("Incorrect output for checkConvertUshort3Short3" + 5662 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5663 } 5664 5665 private void checkConvertUshort4Short4() { 5666 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36d95015a53deb3l, false, 15); 5667 try { 5668 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5669 script.forEach_testConvertShort4Ushort4Short4(inV, out); 5670 verifyResultsConvertUshort4Short4(inV, out, false); 5671 out.destroy(); 5672 } catch (Exception e) { 5673 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString()); 5674 } 5675 try { 5676 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5677 scriptRelaxed.forEach_testConvertShort4Ushort4Short4(inV, out); 5678 verifyResultsConvertUshort4Short4(inV, out, true); 5679 out.destroy(); 5680 } catch (Exception e) { 5681 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString()); 5682 } 5683 inV.destroy(); 5684 } 5685 5686 private void verifyResultsConvertUshort4Short4(Allocation inV, Allocation out, boolean relaxed) { 5687 short[] arrayInV = new short[INPUTSIZE * 4]; 5688 Arrays.fill(arrayInV, (short) 42); 5689 inV.copyTo(arrayInV); 5690 short[] arrayOut = new short[INPUTSIZE * 4]; 5691 Arrays.fill(arrayOut, (short) 42); 5692 out.copyTo(arrayOut); 5693 StringBuilder message = new StringBuilder(); 5694 boolean errorFound = false; 5695 for (int i = 0; i < INPUTSIZE; i++) { 5696 for (int j = 0; j < 4 ; j++) { 5697 // Extract the inputs. 5698 ArgumentsUshortShort args = new ArgumentsUshortShort(); 5699 args.inV = arrayInV[i * 4 + j]; 5700 // Figure out what the outputs should have been. 5701 CoreMathVerifier.computeConvert(args); 5702 // Validate the outputs. 5703 boolean valid = true; 5704 if (args.out != arrayOut[i * 4 + j]) { 5705 valid = false; 5706 } 5707 if (!valid) { 5708 if (!errorFound) { 5709 errorFound = true; 5710 message.append("Input inV: "); 5711 appendVariableToMessage(message, args.inV); 5712 message.append("\n"); 5713 message.append("Expected output out: "); 5714 appendVariableToMessage(message, args.out); 5715 message.append("\n"); 5716 message.append("Actual output out: "); 5717 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5718 if (args.out != arrayOut[i * 4 + j]) { 5719 message.append(" FAIL"); 5720 } 5721 message.append("\n"); 5722 message.append("Errors at"); 5723 } 5724 message.append(" ["); 5725 message.append(Integer.toString(i)); 5726 message.append(", "); 5727 message.append(Integer.toString(j)); 5728 message.append("]"); 5729 } 5730 } 5731 } 5732 assertFalse("Incorrect output for checkConvertUshort4Short4" + 5733 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5734 } 5735 5736 public class ArgumentsIntShort { 5737 public int inV; 5738 public short out; 5739 } 5740 5741 private void checkConvertInt2Short2() { 5742 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a535120b5b27b91l, true, 15); 5743 try { 5744 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5745 script.forEach_testConvertShort2Int2Short2(inV, out); 5746 verifyResultsConvertInt2Short2(inV, out, false); 5747 out.destroy(); 5748 } catch (Exception e) { 5749 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString()); 5750 } 5751 try { 5752 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5753 scriptRelaxed.forEach_testConvertShort2Int2Short2(inV, out); 5754 verifyResultsConvertInt2Short2(inV, out, true); 5755 out.destroy(); 5756 } catch (Exception e) { 5757 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString()); 5758 } 5759 inV.destroy(); 5760 } 5761 5762 private void verifyResultsConvertInt2Short2(Allocation inV, Allocation out, boolean relaxed) { 5763 int[] arrayInV = new int[INPUTSIZE * 2]; 5764 Arrays.fill(arrayInV, (int) 42); 5765 inV.copyTo(arrayInV); 5766 short[] arrayOut = new short[INPUTSIZE * 2]; 5767 Arrays.fill(arrayOut, (short) 42); 5768 out.copyTo(arrayOut); 5769 StringBuilder message = new StringBuilder(); 5770 boolean errorFound = false; 5771 for (int i = 0; i < INPUTSIZE; i++) { 5772 for (int j = 0; j < 2 ; j++) { 5773 // Extract the inputs. 5774 ArgumentsIntShort args = new ArgumentsIntShort(); 5775 args.inV = arrayInV[i * 2 + j]; 5776 // Figure out what the outputs should have been. 5777 CoreMathVerifier.computeConvert(args); 5778 // Validate the outputs. 5779 boolean valid = true; 5780 if (args.out != arrayOut[i * 2 + j]) { 5781 valid = false; 5782 } 5783 if (!valid) { 5784 if (!errorFound) { 5785 errorFound = true; 5786 message.append("Input inV: "); 5787 appendVariableToMessage(message, args.inV); 5788 message.append("\n"); 5789 message.append("Expected output out: "); 5790 appendVariableToMessage(message, args.out); 5791 message.append("\n"); 5792 message.append("Actual output out: "); 5793 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5794 if (args.out != arrayOut[i * 2 + j]) { 5795 message.append(" FAIL"); 5796 } 5797 message.append("\n"); 5798 message.append("Errors at"); 5799 } 5800 message.append(" ["); 5801 message.append(Integer.toString(i)); 5802 message.append(", "); 5803 message.append(Integer.toString(j)); 5804 message.append("]"); 5805 } 5806 } 5807 } 5808 assertFalse("Incorrect output for checkConvertInt2Short2" + 5809 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5810 } 5811 5812 private void checkConvertInt3Short3() { 5813 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a551a3babcd9c6fl, true, 15); 5814 try { 5815 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5816 script.forEach_testConvertShort3Int3Short3(inV, out); 5817 verifyResultsConvertInt3Short3(inV, out, false); 5818 out.destroy(); 5819 } catch (Exception e) { 5820 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString()); 5821 } 5822 try { 5823 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5824 scriptRelaxed.forEach_testConvertShort3Int3Short3(inV, out); 5825 verifyResultsConvertInt3Short3(inV, out, true); 5826 out.destroy(); 5827 } catch (Exception e) { 5828 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString()); 5829 } 5830 inV.destroy(); 5831 } 5832 5833 private void verifyResultsConvertInt3Short3(Allocation inV, Allocation out, boolean relaxed) { 5834 int[] arrayInV = new int[INPUTSIZE * 4]; 5835 Arrays.fill(arrayInV, (int) 42); 5836 inV.copyTo(arrayInV); 5837 short[] arrayOut = new short[INPUTSIZE * 4]; 5838 Arrays.fill(arrayOut, (short) 42); 5839 out.copyTo(arrayOut); 5840 StringBuilder message = new StringBuilder(); 5841 boolean errorFound = false; 5842 for (int i = 0; i < INPUTSIZE; i++) { 5843 for (int j = 0; j < 3 ; j++) { 5844 // Extract the inputs. 5845 ArgumentsIntShort args = new ArgumentsIntShort(); 5846 args.inV = arrayInV[i * 4 + j]; 5847 // Figure out what the outputs should have been. 5848 CoreMathVerifier.computeConvert(args); 5849 // Validate the outputs. 5850 boolean valid = true; 5851 if (args.out != arrayOut[i * 4 + j]) { 5852 valid = false; 5853 } 5854 if (!valid) { 5855 if (!errorFound) { 5856 errorFound = true; 5857 message.append("Input inV: "); 5858 appendVariableToMessage(message, args.inV); 5859 message.append("\n"); 5860 message.append("Expected output out: "); 5861 appendVariableToMessage(message, args.out); 5862 message.append("\n"); 5863 message.append("Actual output out: "); 5864 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5865 if (args.out != arrayOut[i * 4 + j]) { 5866 message.append(" FAIL"); 5867 } 5868 message.append("\n"); 5869 message.append("Errors at"); 5870 } 5871 message.append(" ["); 5872 message.append(Integer.toString(i)); 5873 message.append(", "); 5874 message.append(Integer.toString(j)); 5875 message.append("]"); 5876 } 5877 } 5878 } 5879 assertFalse("Incorrect output for checkConvertInt3Short3" + 5880 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5881 } 5882 5883 private void checkConvertInt4Short4() { 5884 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56e356a1e8bd4dl, true, 15); 5885 try { 5886 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5887 script.forEach_testConvertShort4Int4Short4(inV, out); 5888 verifyResultsConvertInt4Short4(inV, out, false); 5889 out.destroy(); 5890 } catch (Exception e) { 5891 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString()); 5892 } 5893 try { 5894 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5895 scriptRelaxed.forEach_testConvertShort4Int4Short4(inV, out); 5896 verifyResultsConvertInt4Short4(inV, out, true); 5897 out.destroy(); 5898 } catch (Exception e) { 5899 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString()); 5900 } 5901 inV.destroy(); 5902 } 5903 5904 private void verifyResultsConvertInt4Short4(Allocation inV, Allocation out, boolean relaxed) { 5905 int[] arrayInV = new int[INPUTSIZE * 4]; 5906 Arrays.fill(arrayInV, (int) 42); 5907 inV.copyTo(arrayInV); 5908 short[] arrayOut = new short[INPUTSIZE * 4]; 5909 Arrays.fill(arrayOut, (short) 42); 5910 out.copyTo(arrayOut); 5911 StringBuilder message = new StringBuilder(); 5912 boolean errorFound = false; 5913 for (int i = 0; i < INPUTSIZE; i++) { 5914 for (int j = 0; j < 4 ; j++) { 5915 // Extract the inputs. 5916 ArgumentsIntShort args = new ArgumentsIntShort(); 5917 args.inV = arrayInV[i * 4 + j]; 5918 // Figure out what the outputs should have been. 5919 CoreMathVerifier.computeConvert(args); 5920 // Validate the outputs. 5921 boolean valid = true; 5922 if (args.out != arrayOut[i * 4 + j]) { 5923 valid = false; 5924 } 5925 if (!valid) { 5926 if (!errorFound) { 5927 errorFound = true; 5928 message.append("Input inV: "); 5929 appendVariableToMessage(message, args.inV); 5930 message.append("\n"); 5931 message.append("Expected output out: "); 5932 appendVariableToMessage(message, args.out); 5933 message.append("\n"); 5934 message.append("Actual output out: "); 5935 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5936 if (args.out != arrayOut[i * 4 + j]) { 5937 message.append(" FAIL"); 5938 } 5939 message.append("\n"); 5940 message.append("Errors at"); 5941 } 5942 message.append(" ["); 5943 message.append(Integer.toString(i)); 5944 message.append(", "); 5945 message.append(Integer.toString(j)); 5946 message.append("]"); 5947 } 5948 } 5949 } 5950 assertFalse("Incorrect output for checkConvertInt4Short4" + 5951 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5952 } 5953 5954 public class ArgumentsUintShort { 5955 public int inV; 5956 public short out; 5957 } 5958 5959 private void checkConvertUint2Short2() { 5960 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e10a6e48348812l, false, 15); 5961 try { 5962 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5963 script.forEach_testConvertShort2Uint2Short2(inV, out); 5964 verifyResultsConvertUint2Short2(inV, out, false); 5965 out.destroy(); 5966 } catch (Exception e) { 5967 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString()); 5968 } 5969 try { 5970 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5971 scriptRelaxed.forEach_testConvertShort2Uint2Short2(inV, out); 5972 verifyResultsConvertUint2Short2(inV, out, true); 5973 out.destroy(); 5974 } catch (Exception e) { 5975 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString()); 5976 } 5977 inV.destroy(); 5978 } 5979 5980 private void verifyResultsConvertUint2Short2(Allocation inV, Allocation out, boolean relaxed) { 5981 int[] arrayInV = new int[INPUTSIZE * 2]; 5982 Arrays.fill(arrayInV, (int) 42); 5983 inV.copyTo(arrayInV); 5984 short[] arrayOut = new short[INPUTSIZE * 2]; 5985 Arrays.fill(arrayOut, (short) 42); 5986 out.copyTo(arrayOut); 5987 StringBuilder message = new StringBuilder(); 5988 boolean errorFound = false; 5989 for (int i = 0; i < INPUTSIZE; i++) { 5990 for (int j = 0; j < 2 ; j++) { 5991 // Extract the inputs. 5992 ArgumentsUintShort args = new ArgumentsUintShort(); 5993 args.inV = arrayInV[i * 2 + j]; 5994 // Figure out what the outputs should have been. 5995 CoreMathVerifier.computeConvert(args); 5996 // Validate the outputs. 5997 boolean valid = true; 5998 if (args.out != arrayOut[i * 2 + j]) { 5999 valid = false; 6000 } 6001 if (!valid) { 6002 if (!errorFound) { 6003 errorFound = true; 6004 message.append("Input inV: "); 6005 appendVariableToMessage(message, args.inV); 6006 message.append("\n"); 6007 message.append("Expected output out: "); 6008 appendVariableToMessage(message, args.out); 6009 message.append("\n"); 6010 message.append("Actual output out: "); 6011 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6012 if (args.out != arrayOut[i * 2 + j]) { 6013 message.append(" FAIL"); 6014 } 6015 message.append("\n"); 6016 message.append("Errors at"); 6017 } 6018 message.append(" ["); 6019 message.append(Integer.toString(i)); 6020 message.append(", "); 6021 message.append(Integer.toString(j)); 6022 message.append("]"); 6023 } 6024 } 6025 } 6026 assertFalse("Incorrect output for checkConvertUint2Short2" + 6027 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6028 } 6029 6030 private void checkConvertUint3Short3() { 6031 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2d3893e4fa8f0l, false, 15); 6032 try { 6033 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 6034 script.forEach_testConvertShort3Uint3Short3(inV, out); 6035 verifyResultsConvertUint3Short3(inV, out, false); 6036 out.destroy(); 6037 } catch (Exception e) { 6038 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString()); 6039 } 6040 try { 6041 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 6042 scriptRelaxed.forEach_testConvertShort3Uint3Short3(inV, out); 6043 verifyResultsConvertUint3Short3(inV, out, true); 6044 out.destroy(); 6045 } catch (Exception e) { 6046 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString()); 6047 } 6048 inV.destroy(); 6049 } 6050 6051 private void verifyResultsConvertUint3Short3(Allocation inV, Allocation out, boolean relaxed) { 6052 int[] arrayInV = new int[INPUTSIZE * 4]; 6053 Arrays.fill(arrayInV, (int) 42); 6054 inV.copyTo(arrayInV); 6055 short[] arrayOut = new short[INPUTSIZE * 4]; 6056 Arrays.fill(arrayOut, (short) 42); 6057 out.copyTo(arrayOut); 6058 StringBuilder message = new StringBuilder(); 6059 boolean errorFound = false; 6060 for (int i = 0; i < INPUTSIZE; i++) { 6061 for (int j = 0; j < 3 ; j++) { 6062 // Extract the inputs. 6063 ArgumentsUintShort args = new ArgumentsUintShort(); 6064 args.inV = arrayInV[i * 4 + j]; 6065 // Figure out what the outputs should have been. 6066 CoreMathVerifier.computeConvert(args); 6067 // Validate the outputs. 6068 boolean valid = true; 6069 if (args.out != arrayOut[i * 4 + j]) { 6070 valid = false; 6071 } 6072 if (!valid) { 6073 if (!errorFound) { 6074 errorFound = true; 6075 message.append("Input inV: "); 6076 appendVariableToMessage(message, args.inV); 6077 message.append("\n"); 6078 message.append("Expected output out: "); 6079 appendVariableToMessage(message, args.out); 6080 message.append("\n"); 6081 message.append("Actual output out: "); 6082 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6083 if (args.out != arrayOut[i * 4 + j]) { 6084 message.append(" FAIL"); 6085 } 6086 message.append("\n"); 6087 message.append("Errors at"); 6088 } 6089 message.append(" ["); 6090 message.append(Integer.toString(i)); 6091 message.append(", "); 6092 message.append(Integer.toString(j)); 6093 message.append("]"); 6094 } 6095 } 6096 } 6097 assertFalse("Incorrect output for checkConvertUint3Short3" + 6098 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6099 } 6100 6101 private void checkConvertUint4Short4() { 6102 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e49ca4346ac9cel, false, 15); 6103 try { 6104 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 6105 script.forEach_testConvertShort4Uint4Short4(inV, out); 6106 verifyResultsConvertUint4Short4(inV, out, false); 6107 out.destroy(); 6108 } catch (Exception e) { 6109 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString()); 6110 } 6111 try { 6112 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 6113 scriptRelaxed.forEach_testConvertShort4Uint4Short4(inV, out); 6114 verifyResultsConvertUint4Short4(inV, out, true); 6115 out.destroy(); 6116 } catch (Exception e) { 6117 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString()); 6118 } 6119 inV.destroy(); 6120 } 6121 6122 private void verifyResultsConvertUint4Short4(Allocation inV, Allocation out, boolean relaxed) { 6123 int[] arrayInV = new int[INPUTSIZE * 4]; 6124 Arrays.fill(arrayInV, (int) 42); 6125 inV.copyTo(arrayInV); 6126 short[] arrayOut = new short[INPUTSIZE * 4]; 6127 Arrays.fill(arrayOut, (short) 42); 6128 out.copyTo(arrayOut); 6129 StringBuilder message = new StringBuilder(); 6130 boolean errorFound = false; 6131 for (int i = 0; i < INPUTSIZE; i++) { 6132 for (int j = 0; j < 4 ; j++) { 6133 // Extract the inputs. 6134 ArgumentsUintShort args = new ArgumentsUintShort(); 6135 args.inV = arrayInV[i * 4 + j]; 6136 // Figure out what the outputs should have been. 6137 CoreMathVerifier.computeConvert(args); 6138 // Validate the outputs. 6139 boolean valid = true; 6140 if (args.out != arrayOut[i * 4 + j]) { 6141 valid = false; 6142 } 6143 if (!valid) { 6144 if (!errorFound) { 6145 errorFound = true; 6146 message.append("Input inV: "); 6147 appendVariableToMessage(message, args.inV); 6148 message.append("\n"); 6149 message.append("Expected output out: "); 6150 appendVariableToMessage(message, args.out); 6151 message.append("\n"); 6152 message.append("Actual output out: "); 6153 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6154 if (args.out != arrayOut[i * 4 + j]) { 6155 message.append(" FAIL"); 6156 } 6157 message.append("\n"); 6158 message.append("Errors at"); 6159 } 6160 message.append(" ["); 6161 message.append(Integer.toString(i)); 6162 message.append(", "); 6163 message.append(Integer.toString(j)); 6164 message.append("]"); 6165 } 6166 } 6167 } 6168 assertFalse("Incorrect output for checkConvertUint4Short4" + 6169 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6170 } 6171 6172 public class ArgumentsFloatUshort { 6173 public float inV; 6174 public short out; 6175 } 6176 6177 private void checkConvertFloat2Ushort2() { 6178 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36e4b950b708416fl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 6179 try { 6180 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6181 script.forEach_testConvertUshort2Float2Ushort2(inV, out); 6182 verifyResultsConvertFloat2Ushort2(inV, out, false); 6183 out.destroy(); 6184 } catch (Exception e) { 6185 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString()); 6186 } 6187 try { 6188 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6189 scriptRelaxed.forEach_testConvertUshort2Float2Ushort2(inV, out); 6190 verifyResultsConvertFloat2Ushort2(inV, out, true); 6191 out.destroy(); 6192 } catch (Exception e) { 6193 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString()); 6194 } 6195 inV.destroy(); 6196 } 6197 6198 private void verifyResultsConvertFloat2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6199 float[] arrayInV = new float[INPUTSIZE * 2]; 6200 Arrays.fill(arrayInV, (float) 42); 6201 inV.copyTo(arrayInV); 6202 short[] arrayOut = new short[INPUTSIZE * 2]; 6203 Arrays.fill(arrayOut, (short) 42); 6204 out.copyTo(arrayOut); 6205 StringBuilder message = new StringBuilder(); 6206 boolean errorFound = false; 6207 for (int i = 0; i < INPUTSIZE; i++) { 6208 for (int j = 0; j < 2 ; j++) { 6209 // Extract the inputs. 6210 ArgumentsFloatUshort args = new ArgumentsFloatUshort(); 6211 args.inV = arrayInV[i * 2 + j]; 6212 // Figure out what the outputs should have been. 6213 CoreMathVerifier.computeConvert(args); 6214 // Validate the outputs. 6215 boolean valid = true; 6216 if (args.out != arrayOut[i * 2 + j]) { 6217 valid = false; 6218 } 6219 if (!valid) { 6220 if (!errorFound) { 6221 errorFound = true; 6222 message.append("Input inV: "); 6223 appendVariableToMessage(message, args.inV); 6224 message.append("\n"); 6225 message.append("Expected output out: "); 6226 appendVariableToMessage(message, args.out); 6227 message.append("\n"); 6228 message.append("Actual output out: "); 6229 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6230 if (args.out != arrayOut[i * 2 + j]) { 6231 message.append(" FAIL"); 6232 } 6233 message.append("\n"); 6234 message.append("Errors at"); 6235 } 6236 message.append(" ["); 6237 message.append(Integer.toString(i)); 6238 message.append(", "); 6239 message.append(Integer.toString(j)); 6240 message.append("]"); 6241 } 6242 } 6243 } 6244 assertFalse("Incorrect output for checkConvertFloat2Ushort2" + 6245 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6246 } 6247 6248 private void checkConvertFloat3Ushort3() { 6249 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x373180d80d63d29bl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 6250 try { 6251 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6252 script.forEach_testConvertUshort3Float3Ushort3(inV, out); 6253 verifyResultsConvertFloat3Ushort3(inV, out, false); 6254 out.destroy(); 6255 } catch (Exception e) { 6256 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString()); 6257 } 6258 try { 6259 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6260 scriptRelaxed.forEach_testConvertUshort3Float3Ushort3(inV, out); 6261 verifyResultsConvertFloat3Ushort3(inV, out, true); 6262 out.destroy(); 6263 } catch (Exception e) { 6264 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString()); 6265 } 6266 inV.destroy(); 6267 } 6268 6269 private void verifyResultsConvertFloat3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6270 float[] arrayInV = new float[INPUTSIZE * 4]; 6271 Arrays.fill(arrayInV, (float) 42); 6272 inV.copyTo(arrayInV); 6273 short[] arrayOut = new short[INPUTSIZE * 4]; 6274 Arrays.fill(arrayOut, (short) 42); 6275 out.copyTo(arrayOut); 6276 StringBuilder message = new StringBuilder(); 6277 boolean errorFound = false; 6278 for (int i = 0; i < INPUTSIZE; i++) { 6279 for (int j = 0; j < 3 ; j++) { 6280 // Extract the inputs. 6281 ArgumentsFloatUshort args = new ArgumentsFloatUshort(); 6282 args.inV = arrayInV[i * 4 + j]; 6283 // Figure out what the outputs should have been. 6284 CoreMathVerifier.computeConvert(args); 6285 // Validate the outputs. 6286 boolean valid = true; 6287 if (args.out != arrayOut[i * 4 + j]) { 6288 valid = false; 6289 } 6290 if (!valid) { 6291 if (!errorFound) { 6292 errorFound = true; 6293 message.append("Input inV: "); 6294 appendVariableToMessage(message, args.inV); 6295 message.append("\n"); 6296 message.append("Expected output out: "); 6297 appendVariableToMessage(message, args.out); 6298 message.append("\n"); 6299 message.append("Actual output out: "); 6300 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6301 if (args.out != arrayOut[i * 4 + j]) { 6302 message.append(" FAIL"); 6303 } 6304 message.append("\n"); 6305 message.append("Errors at"); 6306 } 6307 message.append(" ["); 6308 message.append(Integer.toString(i)); 6309 message.append(", "); 6310 message.append(Integer.toString(j)); 6311 message.append("]"); 6312 } 6313 } 6314 } 6315 assertFalse("Incorrect output for checkConvertFloat3Ushort3" + 6316 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6317 } 6318 6319 private void checkConvertFloat4Ushort4() { 6320 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x377e485f63bf63c7l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 6321 try { 6322 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6323 script.forEach_testConvertUshort4Float4Ushort4(inV, out); 6324 verifyResultsConvertFloat4Ushort4(inV, out, false); 6325 out.destroy(); 6326 } catch (Exception e) { 6327 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString()); 6328 } 6329 try { 6330 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6331 scriptRelaxed.forEach_testConvertUshort4Float4Ushort4(inV, out); 6332 verifyResultsConvertFloat4Ushort4(inV, out, true); 6333 out.destroy(); 6334 } catch (Exception e) { 6335 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString()); 6336 } 6337 inV.destroy(); 6338 } 6339 6340 private void verifyResultsConvertFloat4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6341 float[] arrayInV = new float[INPUTSIZE * 4]; 6342 Arrays.fill(arrayInV, (float) 42); 6343 inV.copyTo(arrayInV); 6344 short[] arrayOut = new short[INPUTSIZE * 4]; 6345 Arrays.fill(arrayOut, (short) 42); 6346 out.copyTo(arrayOut); 6347 StringBuilder message = new StringBuilder(); 6348 boolean errorFound = false; 6349 for (int i = 0; i < INPUTSIZE; i++) { 6350 for (int j = 0; j < 4 ; j++) { 6351 // Extract the inputs. 6352 ArgumentsFloatUshort args = new ArgumentsFloatUshort(); 6353 args.inV = arrayInV[i * 4 + j]; 6354 // Figure out what the outputs should have been. 6355 CoreMathVerifier.computeConvert(args); 6356 // Validate the outputs. 6357 boolean valid = true; 6358 if (args.out != arrayOut[i * 4 + j]) { 6359 valid = false; 6360 } 6361 if (!valid) { 6362 if (!errorFound) { 6363 errorFound = true; 6364 message.append("Input inV: "); 6365 appendVariableToMessage(message, args.inV); 6366 message.append("\n"); 6367 message.append("Expected output out: "); 6368 appendVariableToMessage(message, args.out); 6369 message.append("\n"); 6370 message.append("Actual output out: "); 6371 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6372 if (args.out != arrayOut[i * 4 + j]) { 6373 message.append(" FAIL"); 6374 } 6375 message.append("\n"); 6376 message.append("Errors at"); 6377 } 6378 message.append(" ["); 6379 message.append(Integer.toString(i)); 6380 message.append(", "); 6381 message.append(Integer.toString(j)); 6382 message.append("]"); 6383 } 6384 } 6385 } 6386 assertFalse("Incorrect output for checkConvertFloat4Ushort4" + 6387 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6388 } 6389 6390 public class ArgumentsCharUshort { 6391 public byte inV; 6392 public short out; 6393 } 6394 6395 private void checkConvertChar2Ushort2() { 6396 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd88c0b0ed8f1eeafl, false, 7); 6397 try { 6398 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6399 script.forEach_testConvertUshort2Char2Ushort2(inV, out); 6400 verifyResultsConvertChar2Ushort2(inV, out, false); 6401 out.destroy(); 6402 } catch (Exception e) { 6403 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString()); 6404 } 6405 try { 6406 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6407 scriptRelaxed.forEach_testConvertUshort2Char2Ushort2(inV, out); 6408 verifyResultsConvertChar2Ushort2(inV, out, true); 6409 out.destroy(); 6410 } catch (Exception e) { 6411 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString()); 6412 } 6413 inV.destroy(); 6414 } 6415 6416 private void verifyResultsConvertChar2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6417 byte[] arrayInV = new byte[INPUTSIZE * 2]; 6418 Arrays.fill(arrayInV, (byte) 42); 6419 inV.copyTo(arrayInV); 6420 short[] arrayOut = new short[INPUTSIZE * 2]; 6421 Arrays.fill(arrayOut, (short) 42); 6422 out.copyTo(arrayOut); 6423 StringBuilder message = new StringBuilder(); 6424 boolean errorFound = false; 6425 for (int i = 0; i < INPUTSIZE; i++) { 6426 for (int j = 0; j < 2 ; j++) { 6427 // Extract the inputs. 6428 ArgumentsCharUshort args = new ArgumentsCharUshort(); 6429 args.inV = arrayInV[i * 2 + j]; 6430 // Figure out what the outputs should have been. 6431 CoreMathVerifier.computeConvert(args); 6432 // Validate the outputs. 6433 boolean valid = true; 6434 if (args.out != arrayOut[i * 2 + j]) { 6435 valid = false; 6436 } 6437 if (!valid) { 6438 if (!errorFound) { 6439 errorFound = true; 6440 message.append("Input inV: "); 6441 appendVariableToMessage(message, args.inV); 6442 message.append("\n"); 6443 message.append("Expected output out: "); 6444 appendVariableToMessage(message, args.out); 6445 message.append("\n"); 6446 message.append("Actual output out: "); 6447 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6448 if (args.out != arrayOut[i * 2 + j]) { 6449 message.append(" FAIL"); 6450 } 6451 message.append("\n"); 6452 message.append("Errors at"); 6453 } 6454 message.append(" ["); 6455 message.append(Integer.toString(i)); 6456 message.append(", "); 6457 message.append(Integer.toString(j)); 6458 message.append("]"); 6459 } 6460 } 6461 } 6462 assertFalse("Incorrect output for checkConvertChar2Ushort2" + 6463 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6464 } 6465 6466 private void checkConvertChar3Ushort3() { 6467 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd8d8d2962f4d7fdbl, false, 7); 6468 try { 6469 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6470 script.forEach_testConvertUshort3Char3Ushort3(inV, out); 6471 verifyResultsConvertChar3Ushort3(inV, out, false); 6472 out.destroy(); 6473 } catch (Exception e) { 6474 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString()); 6475 } 6476 try { 6477 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6478 scriptRelaxed.forEach_testConvertUshort3Char3Ushort3(inV, out); 6479 verifyResultsConvertChar3Ushort3(inV, out, true); 6480 out.destroy(); 6481 } catch (Exception e) { 6482 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString()); 6483 } 6484 inV.destroy(); 6485 } 6486 6487 private void verifyResultsConvertChar3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6488 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6489 Arrays.fill(arrayInV, (byte) 42); 6490 inV.copyTo(arrayInV); 6491 short[] arrayOut = new short[INPUTSIZE * 4]; 6492 Arrays.fill(arrayOut, (short) 42); 6493 out.copyTo(arrayOut); 6494 StringBuilder message = new StringBuilder(); 6495 boolean errorFound = false; 6496 for (int i = 0; i < INPUTSIZE; i++) { 6497 for (int j = 0; j < 3 ; j++) { 6498 // Extract the inputs. 6499 ArgumentsCharUshort args = new ArgumentsCharUshort(); 6500 args.inV = arrayInV[i * 4 + j]; 6501 // Figure out what the outputs should have been. 6502 CoreMathVerifier.computeConvert(args); 6503 // Validate the outputs. 6504 boolean valid = true; 6505 if (args.out != arrayOut[i * 4 + j]) { 6506 valid = false; 6507 } 6508 if (!valid) { 6509 if (!errorFound) { 6510 errorFound = true; 6511 message.append("Input inV: "); 6512 appendVariableToMessage(message, args.inV); 6513 message.append("\n"); 6514 message.append("Expected output out: "); 6515 appendVariableToMessage(message, args.out); 6516 message.append("\n"); 6517 message.append("Actual output out: "); 6518 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6519 if (args.out != arrayOut[i * 4 + j]) { 6520 message.append(" FAIL"); 6521 } 6522 message.append("\n"); 6523 message.append("Errors at"); 6524 } 6525 message.append(" ["); 6526 message.append(Integer.toString(i)); 6527 message.append(", "); 6528 message.append(Integer.toString(j)); 6529 message.append("]"); 6530 } 6531 } 6532 } 6533 assertFalse("Incorrect output for checkConvertChar3Ushort3" + 6534 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6535 } 6536 6537 private void checkConvertChar4Ushort4() { 6538 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd9259a1d85a91107l, false, 7); 6539 try { 6540 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6541 script.forEach_testConvertUshort4Char4Ushort4(inV, out); 6542 verifyResultsConvertChar4Ushort4(inV, out, false); 6543 out.destroy(); 6544 } catch (Exception e) { 6545 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString()); 6546 } 6547 try { 6548 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6549 scriptRelaxed.forEach_testConvertUshort4Char4Ushort4(inV, out); 6550 verifyResultsConvertChar4Ushort4(inV, out, true); 6551 out.destroy(); 6552 } catch (Exception e) { 6553 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString()); 6554 } 6555 inV.destroy(); 6556 } 6557 6558 private void verifyResultsConvertChar4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6559 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6560 Arrays.fill(arrayInV, (byte) 42); 6561 inV.copyTo(arrayInV); 6562 short[] arrayOut = new short[INPUTSIZE * 4]; 6563 Arrays.fill(arrayOut, (short) 42); 6564 out.copyTo(arrayOut); 6565 StringBuilder message = new StringBuilder(); 6566 boolean errorFound = false; 6567 for (int i = 0; i < INPUTSIZE; i++) { 6568 for (int j = 0; j < 4 ; j++) { 6569 // Extract the inputs. 6570 ArgumentsCharUshort args = new ArgumentsCharUshort(); 6571 args.inV = arrayInV[i * 4 + j]; 6572 // Figure out what the outputs should have been. 6573 CoreMathVerifier.computeConvert(args); 6574 // Validate the outputs. 6575 boolean valid = true; 6576 if (args.out != arrayOut[i * 4 + j]) { 6577 valid = false; 6578 } 6579 if (!valid) { 6580 if (!errorFound) { 6581 errorFound = true; 6582 message.append("Input inV: "); 6583 appendVariableToMessage(message, args.inV); 6584 message.append("\n"); 6585 message.append("Expected output out: "); 6586 appendVariableToMessage(message, args.out); 6587 message.append("\n"); 6588 message.append("Actual output out: "); 6589 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6590 if (args.out != arrayOut[i * 4 + j]) { 6591 message.append(" FAIL"); 6592 } 6593 message.append("\n"); 6594 message.append("Errors at"); 6595 } 6596 message.append(" ["); 6597 message.append(Integer.toString(i)); 6598 message.append(", "); 6599 message.append(Integer.toString(j)); 6600 message.append("]"); 6601 } 6602 } 6603 } 6604 assertFalse("Incorrect output for checkConvertChar4Ushort4" + 6605 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6606 } 6607 6608 public class ArgumentsUcharUshort { 6609 public byte inV; 6610 public short out; 6611 } 6612 6613 private void checkConvertUchar2Ushort2() { 6614 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x72b6c56063e3e68l, false, 8); 6615 try { 6616 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6617 script.forEach_testConvertUshort2Uchar2Ushort2(inV, out); 6618 verifyResultsConvertUchar2Ushort2(inV, out, false); 6619 out.destroy(); 6620 } catch (Exception e) { 6621 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString()); 6622 } 6623 try { 6624 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6625 scriptRelaxed.forEach_testConvertUshort2Uchar2Ushort2(inV, out); 6626 verifyResultsConvertUchar2Ushort2(inV, out, true); 6627 out.destroy(); 6628 } catch (Exception e) { 6629 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString()); 6630 } 6631 inV.destroy(); 6632 } 6633 6634 private void verifyResultsConvertUchar2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6635 byte[] arrayInV = new byte[INPUTSIZE * 2]; 6636 Arrays.fill(arrayInV, (byte) 42); 6637 inV.copyTo(arrayInV); 6638 short[] arrayOut = new short[INPUTSIZE * 2]; 6639 Arrays.fill(arrayOut, (short) 42); 6640 out.copyTo(arrayOut); 6641 StringBuilder message = new StringBuilder(); 6642 boolean errorFound = false; 6643 for (int i = 0; i < INPUTSIZE; i++) { 6644 for (int j = 0; j < 2 ; j++) { 6645 // Extract the inputs. 6646 ArgumentsUcharUshort args = new ArgumentsUcharUshort(); 6647 args.inV = arrayInV[i * 2 + j]; 6648 // Figure out what the outputs should have been. 6649 CoreMathVerifier.computeConvert(args); 6650 // Validate the outputs. 6651 boolean valid = true; 6652 if (args.out != arrayOut[i * 2 + j]) { 6653 valid = false; 6654 } 6655 if (!valid) { 6656 if (!errorFound) { 6657 errorFound = true; 6658 message.append("Input inV: "); 6659 appendVariableToMessage(message, args.inV); 6660 message.append("\n"); 6661 message.append("Expected output out: "); 6662 appendVariableToMessage(message, args.out); 6663 message.append("\n"); 6664 message.append("Actual output out: "); 6665 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6666 if (args.out != arrayOut[i * 2 + j]) { 6667 message.append(" FAIL"); 6668 } 6669 message.append("\n"); 6670 message.append("Errors at"); 6671 } 6672 message.append(" ["); 6673 message.append(Integer.toString(i)); 6674 message.append(", "); 6675 message.append(Integer.toString(j)); 6676 message.append("]"); 6677 } 6678 } 6679 } 6680 assertFalse("Incorrect output for checkConvertUchar2Ushort2" + 6681 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6682 } 6683 6684 private void checkConvertUchar3Ushort3() { 6685 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x77833dd5c99cf94l, false, 8); 6686 try { 6687 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6688 script.forEach_testConvertUshort3Uchar3Ushort3(inV, out); 6689 verifyResultsConvertUchar3Ushort3(inV, out, false); 6690 out.destroy(); 6691 } catch (Exception e) { 6692 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString()); 6693 } 6694 try { 6695 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6696 scriptRelaxed.forEach_testConvertUshort3Uchar3Ushort3(inV, out); 6697 verifyResultsConvertUchar3Ushort3(inV, out, true); 6698 out.destroy(); 6699 } catch (Exception e) { 6700 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString()); 6701 } 6702 inV.destroy(); 6703 } 6704 6705 private void verifyResultsConvertUchar3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6706 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6707 Arrays.fill(arrayInV, (byte) 42); 6708 inV.copyTo(arrayInV); 6709 short[] arrayOut = new short[INPUTSIZE * 4]; 6710 Arrays.fill(arrayOut, (short) 42); 6711 out.copyTo(arrayOut); 6712 StringBuilder message = new StringBuilder(); 6713 boolean errorFound = false; 6714 for (int i = 0; i < INPUTSIZE; i++) { 6715 for (int j = 0; j < 3 ; j++) { 6716 // Extract the inputs. 6717 ArgumentsUcharUshort args = new ArgumentsUcharUshort(); 6718 args.inV = arrayInV[i * 4 + j]; 6719 // Figure out what the outputs should have been. 6720 CoreMathVerifier.computeConvert(args); 6721 // Validate the outputs. 6722 boolean valid = true; 6723 if (args.out != arrayOut[i * 4 + j]) { 6724 valid = false; 6725 } 6726 if (!valid) { 6727 if (!errorFound) { 6728 errorFound = true; 6729 message.append("Input inV: "); 6730 appendVariableToMessage(message, args.inV); 6731 message.append("\n"); 6732 message.append("Expected output out: "); 6733 appendVariableToMessage(message, args.out); 6734 message.append("\n"); 6735 message.append("Actual output out: "); 6736 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6737 if (args.out != arrayOut[i * 4 + j]) { 6738 message.append(" FAIL"); 6739 } 6740 message.append("\n"); 6741 message.append("Errors at"); 6742 } 6743 message.append(" ["); 6744 message.append(Integer.toString(i)); 6745 message.append(", "); 6746 message.append(Integer.toString(j)); 6747 message.append("]"); 6748 } 6749 } 6750 } 6751 assertFalse("Incorrect output for checkConvertUchar3Ushort3" + 6752 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6753 } 6754 6755 private void checkConvertUchar4Ushort4() { 6756 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7c4fb64b2f560c0l, false, 8); 6757 try { 6758 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6759 script.forEach_testConvertUshort4Uchar4Ushort4(inV, out); 6760 verifyResultsConvertUchar4Ushort4(inV, out, false); 6761 out.destroy(); 6762 } catch (Exception e) { 6763 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString()); 6764 } 6765 try { 6766 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6767 scriptRelaxed.forEach_testConvertUshort4Uchar4Ushort4(inV, out); 6768 verifyResultsConvertUchar4Ushort4(inV, out, true); 6769 out.destroy(); 6770 } catch (Exception e) { 6771 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString()); 6772 } 6773 inV.destroy(); 6774 } 6775 6776 private void verifyResultsConvertUchar4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6777 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6778 Arrays.fill(arrayInV, (byte) 42); 6779 inV.copyTo(arrayInV); 6780 short[] arrayOut = new short[INPUTSIZE * 4]; 6781 Arrays.fill(arrayOut, (short) 42); 6782 out.copyTo(arrayOut); 6783 StringBuilder message = new StringBuilder(); 6784 boolean errorFound = false; 6785 for (int i = 0; i < INPUTSIZE; i++) { 6786 for (int j = 0; j < 4 ; j++) { 6787 // Extract the inputs. 6788 ArgumentsUcharUshort args = new ArgumentsUcharUshort(); 6789 args.inV = arrayInV[i * 4 + j]; 6790 // Figure out what the outputs should have been. 6791 CoreMathVerifier.computeConvert(args); 6792 // Validate the outputs. 6793 boolean valid = true; 6794 if (args.out != arrayOut[i * 4 + j]) { 6795 valid = false; 6796 } 6797 if (!valid) { 6798 if (!errorFound) { 6799 errorFound = true; 6800 message.append("Input inV: "); 6801 appendVariableToMessage(message, args.inV); 6802 message.append("\n"); 6803 message.append("Expected output out: "); 6804 appendVariableToMessage(message, args.out); 6805 message.append("\n"); 6806 message.append("Actual output out: "); 6807 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6808 if (args.out != arrayOut[i * 4 + j]) { 6809 message.append(" FAIL"); 6810 } 6811 message.append("\n"); 6812 message.append("Errors at"); 6813 } 6814 message.append(" ["); 6815 message.append(Integer.toString(i)); 6816 message.append(", "); 6817 message.append(Integer.toString(j)); 6818 message.append("]"); 6819 } 6820 } 6821 } 6822 assertFalse("Incorrect output for checkConvertUchar4Ushort4" + 6823 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6824 } 6825 6826 public class ArgumentsShortUshort { 6827 public short inV; 6828 public short out; 6829 } 6830 6831 private void checkConvertShort2Ushort2() { 6832 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xfe0d269c7264c053l, false, 15); 6833 try { 6834 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6835 script.forEach_testConvertUshort2Short2Ushort2(inV, out); 6836 verifyResultsConvertShort2Ushort2(inV, out, false); 6837 out.destroy(); 6838 } catch (Exception e) { 6839 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString()); 6840 } 6841 try { 6842 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6843 scriptRelaxed.forEach_testConvertUshort2Short2Ushort2(inV, out); 6844 verifyResultsConvertShort2Ushort2(inV, out, true); 6845 out.destroy(); 6846 } catch (Exception e) { 6847 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString()); 6848 } 6849 inV.destroy(); 6850 } 6851 6852 private void verifyResultsConvertShort2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6853 short[] arrayInV = new short[INPUTSIZE * 2]; 6854 Arrays.fill(arrayInV, (short) 42); 6855 inV.copyTo(arrayInV); 6856 short[] arrayOut = new short[INPUTSIZE * 2]; 6857 Arrays.fill(arrayOut, (short) 42); 6858 out.copyTo(arrayOut); 6859 StringBuilder message = new StringBuilder(); 6860 boolean errorFound = false; 6861 for (int i = 0; i < INPUTSIZE; i++) { 6862 for (int j = 0; j < 2 ; j++) { 6863 // Extract the inputs. 6864 ArgumentsShortUshort args = new ArgumentsShortUshort(); 6865 args.inV = arrayInV[i * 2 + j]; 6866 // Figure out what the outputs should have been. 6867 CoreMathVerifier.computeConvert(args); 6868 // Validate the outputs. 6869 boolean valid = true; 6870 if (args.out != arrayOut[i * 2 + j]) { 6871 valid = false; 6872 } 6873 if (!valid) { 6874 if (!errorFound) { 6875 errorFound = true; 6876 message.append("Input inV: "); 6877 appendVariableToMessage(message, args.inV); 6878 message.append("\n"); 6879 message.append("Expected output out: "); 6880 appendVariableToMessage(message, args.out); 6881 message.append("\n"); 6882 message.append("Actual output out: "); 6883 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6884 if (args.out != arrayOut[i * 2 + j]) { 6885 message.append(" FAIL"); 6886 } 6887 message.append("\n"); 6888 message.append("Errors at"); 6889 } 6890 message.append(" ["); 6891 message.append(Integer.toString(i)); 6892 message.append(", "); 6893 message.append(Integer.toString(j)); 6894 message.append("]"); 6895 } 6896 } 6897 } 6898 assertFalse("Incorrect output for checkConvertShort2Ushort2" + 6899 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6900 } 6901 6902 private void checkConvertShort3Ushort3() { 6903 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xfe59ee23c8c0517fl, false, 15); 6904 try { 6905 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6906 script.forEach_testConvertUshort3Short3Ushort3(inV, out); 6907 verifyResultsConvertShort3Ushort3(inV, out, false); 6908 out.destroy(); 6909 } catch (Exception e) { 6910 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString()); 6911 } 6912 try { 6913 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6914 scriptRelaxed.forEach_testConvertUshort3Short3Ushort3(inV, out); 6915 verifyResultsConvertShort3Ushort3(inV, out, true); 6916 out.destroy(); 6917 } catch (Exception e) { 6918 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString()); 6919 } 6920 inV.destroy(); 6921 } 6922 6923 private void verifyResultsConvertShort3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6924 short[] arrayInV = new short[INPUTSIZE * 4]; 6925 Arrays.fill(arrayInV, (short) 42); 6926 inV.copyTo(arrayInV); 6927 short[] arrayOut = new short[INPUTSIZE * 4]; 6928 Arrays.fill(arrayOut, (short) 42); 6929 out.copyTo(arrayOut); 6930 StringBuilder message = new StringBuilder(); 6931 boolean errorFound = false; 6932 for (int i = 0; i < INPUTSIZE; i++) { 6933 for (int j = 0; j < 3 ; j++) { 6934 // Extract the inputs. 6935 ArgumentsShortUshort args = new ArgumentsShortUshort(); 6936 args.inV = arrayInV[i * 4 + j]; 6937 // Figure out what the outputs should have been. 6938 CoreMathVerifier.computeConvert(args); 6939 // Validate the outputs. 6940 boolean valid = true; 6941 if (args.out != arrayOut[i * 4 + j]) { 6942 valid = false; 6943 } 6944 if (!valid) { 6945 if (!errorFound) { 6946 errorFound = true; 6947 message.append("Input inV: "); 6948 appendVariableToMessage(message, args.inV); 6949 message.append("\n"); 6950 message.append("Expected output out: "); 6951 appendVariableToMessage(message, args.out); 6952 message.append("\n"); 6953 message.append("Actual output out: "); 6954 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6955 if (args.out != arrayOut[i * 4 + j]) { 6956 message.append(" FAIL"); 6957 } 6958 message.append("\n"); 6959 message.append("Errors at"); 6960 } 6961 message.append(" ["); 6962 message.append(Integer.toString(i)); 6963 message.append(", "); 6964 message.append(Integer.toString(j)); 6965 message.append("]"); 6966 } 6967 } 6968 } 6969 assertFalse("Incorrect output for checkConvertShort3Ushort3" + 6970 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6971 } 6972 6973 private void checkConvertShort4Ushort4() { 6974 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xfea6b5ab1f1be2abl, false, 15); 6975 try { 6976 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6977 script.forEach_testConvertUshort4Short4Ushort4(inV, out); 6978 verifyResultsConvertShort4Ushort4(inV, out, false); 6979 out.destroy(); 6980 } catch (Exception e) { 6981 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString()); 6982 } 6983 try { 6984 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6985 scriptRelaxed.forEach_testConvertUshort4Short4Ushort4(inV, out); 6986 verifyResultsConvertShort4Ushort4(inV, out, true); 6987 out.destroy(); 6988 } catch (Exception e) { 6989 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString()); 6990 } 6991 inV.destroy(); 6992 } 6993 6994 private void verifyResultsConvertShort4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6995 short[] arrayInV = new short[INPUTSIZE * 4]; 6996 Arrays.fill(arrayInV, (short) 42); 6997 inV.copyTo(arrayInV); 6998 short[] arrayOut = new short[INPUTSIZE * 4]; 6999 Arrays.fill(arrayOut, (short) 42); 7000 out.copyTo(arrayOut); 7001 StringBuilder message = new StringBuilder(); 7002 boolean errorFound = false; 7003 for (int i = 0; i < INPUTSIZE; i++) { 7004 for (int j = 0; j < 4 ; j++) { 7005 // Extract the inputs. 7006 ArgumentsShortUshort args = new ArgumentsShortUshort(); 7007 args.inV = arrayInV[i * 4 + j]; 7008 // Figure out what the outputs should have been. 7009 CoreMathVerifier.computeConvert(args); 7010 // Validate the outputs. 7011 boolean valid = true; 7012 if (args.out != arrayOut[i * 4 + j]) { 7013 valid = false; 7014 } 7015 if (!valid) { 7016 if (!errorFound) { 7017 errorFound = true; 7018 message.append("Input inV: "); 7019 appendVariableToMessage(message, args.inV); 7020 message.append("\n"); 7021 message.append("Expected output out: "); 7022 appendVariableToMessage(message, args.out); 7023 message.append("\n"); 7024 message.append("Actual output out: "); 7025 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7026 if (args.out != arrayOut[i * 4 + j]) { 7027 message.append(" FAIL"); 7028 } 7029 message.append("\n"); 7030 message.append("Errors at"); 7031 } 7032 message.append(" ["); 7033 message.append(Integer.toString(i)); 7034 message.append(", "); 7035 message.append(Integer.toString(j)); 7036 message.append("]"); 7037 } 7038 } 7039 } 7040 assertFalse("Incorrect output for checkConvertShort4Ushort4" + 7041 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7042 } 7043 7044 public class ArgumentsUshortUshort { 7045 public short inV; 7046 public short out; 7047 } 7048 7049 private void checkConvertUshort2Ushort2() { 7050 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd2d27d910e362466l, false, 16); 7051 try { 7052 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7053 script.forEach_testConvertUshort2Ushort2Ushort2(inV, out); 7054 verifyResultsConvertUshort2Ushort2(inV, out, false); 7055 out.destroy(); 7056 } catch (Exception e) { 7057 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString()); 7058 } 7059 try { 7060 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7061 scriptRelaxed.forEach_testConvertUshort2Ushort2Ushort2(inV, out); 7062 verifyResultsConvertUshort2Ushort2(inV, out, true); 7063 out.destroy(); 7064 } catch (Exception e) { 7065 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString()); 7066 } 7067 inV.destroy(); 7068 } 7069 7070 private void verifyResultsConvertUshort2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 7071 short[] arrayInV = new short[INPUTSIZE * 2]; 7072 Arrays.fill(arrayInV, (short) 42); 7073 inV.copyTo(arrayInV); 7074 short[] arrayOut = new short[INPUTSIZE * 2]; 7075 Arrays.fill(arrayOut, (short) 42); 7076 out.copyTo(arrayOut); 7077 StringBuilder message = new StringBuilder(); 7078 boolean errorFound = false; 7079 for (int i = 0; i < INPUTSIZE; i++) { 7080 for (int j = 0; j < 2 ; j++) { 7081 // Extract the inputs. 7082 ArgumentsUshortUshort args = new ArgumentsUshortUshort(); 7083 args.inV = arrayInV[i * 2 + j]; 7084 // Figure out what the outputs should have been. 7085 CoreMathVerifier.computeConvert(args); 7086 // Validate the outputs. 7087 boolean valid = true; 7088 if (args.out != arrayOut[i * 2 + j]) { 7089 valid = false; 7090 } 7091 if (!valid) { 7092 if (!errorFound) { 7093 errorFound = true; 7094 message.append("Input inV: "); 7095 appendVariableToMessage(message, args.inV); 7096 message.append("\n"); 7097 message.append("Expected output out: "); 7098 appendVariableToMessage(message, args.out); 7099 message.append("\n"); 7100 message.append("Actual output out: "); 7101 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7102 if (args.out != arrayOut[i * 2 + j]) { 7103 message.append(" FAIL"); 7104 } 7105 message.append("\n"); 7106 message.append("Errors at"); 7107 } 7108 message.append(" ["); 7109 message.append(Integer.toString(i)); 7110 message.append(", "); 7111 message.append(Integer.toString(j)); 7112 message.append("]"); 7113 } 7114 } 7115 } 7116 assertFalse("Incorrect output for checkConvertUshort2Ushort2" + 7117 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7118 } 7119 7120 private void checkConvertUshort3Ushort3() { 7121 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd31f45186491b592l, false, 16); 7122 try { 7123 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7124 script.forEach_testConvertUshort3Ushort3Ushort3(inV, out); 7125 verifyResultsConvertUshort3Ushort3(inV, out, false); 7126 out.destroy(); 7127 } catch (Exception e) { 7128 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString()); 7129 } 7130 try { 7131 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7132 scriptRelaxed.forEach_testConvertUshort3Ushort3Ushort3(inV, out); 7133 verifyResultsConvertUshort3Ushort3(inV, out, true); 7134 out.destroy(); 7135 } catch (Exception e) { 7136 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString()); 7137 } 7138 inV.destroy(); 7139 } 7140 7141 private void verifyResultsConvertUshort3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 7142 short[] arrayInV = new short[INPUTSIZE * 4]; 7143 Arrays.fill(arrayInV, (short) 42); 7144 inV.copyTo(arrayInV); 7145 short[] arrayOut = new short[INPUTSIZE * 4]; 7146 Arrays.fill(arrayOut, (short) 42); 7147 out.copyTo(arrayOut); 7148 StringBuilder message = new StringBuilder(); 7149 boolean errorFound = false; 7150 for (int i = 0; i < INPUTSIZE; i++) { 7151 for (int j = 0; j < 3 ; j++) { 7152 // Extract the inputs. 7153 ArgumentsUshortUshort args = new ArgumentsUshortUshort(); 7154 args.inV = arrayInV[i * 4 + j]; 7155 // Figure out what the outputs should have been. 7156 CoreMathVerifier.computeConvert(args); 7157 // Validate the outputs. 7158 boolean valid = true; 7159 if (args.out != arrayOut[i * 4 + j]) { 7160 valid = false; 7161 } 7162 if (!valid) { 7163 if (!errorFound) { 7164 errorFound = true; 7165 message.append("Input inV: "); 7166 appendVariableToMessage(message, args.inV); 7167 message.append("\n"); 7168 message.append("Expected output out: "); 7169 appendVariableToMessage(message, args.out); 7170 message.append("\n"); 7171 message.append("Actual output out: "); 7172 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7173 if (args.out != arrayOut[i * 4 + j]) { 7174 message.append(" FAIL"); 7175 } 7176 message.append("\n"); 7177 message.append("Errors at"); 7178 } 7179 message.append(" ["); 7180 message.append(Integer.toString(i)); 7181 message.append(", "); 7182 message.append(Integer.toString(j)); 7183 message.append("]"); 7184 } 7185 } 7186 } 7187 assertFalse("Incorrect output for checkConvertUshort3Ushort3" + 7188 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7189 } 7190 7191 private void checkConvertUshort4Ushort4() { 7192 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xd36c0c9fbaed46bel, false, 16); 7193 try { 7194 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7195 script.forEach_testConvertUshort4Ushort4Ushort4(inV, out); 7196 verifyResultsConvertUshort4Ushort4(inV, out, false); 7197 out.destroy(); 7198 } catch (Exception e) { 7199 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString()); 7200 } 7201 try { 7202 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7203 scriptRelaxed.forEach_testConvertUshort4Ushort4Ushort4(inV, out); 7204 verifyResultsConvertUshort4Ushort4(inV, out, true); 7205 out.destroy(); 7206 } catch (Exception e) { 7207 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString()); 7208 } 7209 inV.destroy(); 7210 } 7211 7212 private void verifyResultsConvertUshort4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 7213 short[] arrayInV = new short[INPUTSIZE * 4]; 7214 Arrays.fill(arrayInV, (short) 42); 7215 inV.copyTo(arrayInV); 7216 short[] arrayOut = new short[INPUTSIZE * 4]; 7217 Arrays.fill(arrayOut, (short) 42); 7218 out.copyTo(arrayOut); 7219 StringBuilder message = new StringBuilder(); 7220 boolean errorFound = false; 7221 for (int i = 0; i < INPUTSIZE; i++) { 7222 for (int j = 0; j < 4 ; j++) { 7223 // Extract the inputs. 7224 ArgumentsUshortUshort args = new ArgumentsUshortUshort(); 7225 args.inV = arrayInV[i * 4 + j]; 7226 // Figure out what the outputs should have been. 7227 CoreMathVerifier.computeConvert(args); 7228 // Validate the outputs. 7229 boolean valid = true; 7230 if (args.out != arrayOut[i * 4 + j]) { 7231 valid = false; 7232 } 7233 if (!valid) { 7234 if (!errorFound) { 7235 errorFound = true; 7236 message.append("Input inV: "); 7237 appendVariableToMessage(message, args.inV); 7238 message.append("\n"); 7239 message.append("Expected output out: "); 7240 appendVariableToMessage(message, args.out); 7241 message.append("\n"); 7242 message.append("Actual output out: "); 7243 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7244 if (args.out != arrayOut[i * 4 + j]) { 7245 message.append(" FAIL"); 7246 } 7247 message.append("\n"); 7248 message.append("Errors at"); 7249 } 7250 message.append(" ["); 7251 message.append(Integer.toString(i)); 7252 message.append(", "); 7253 message.append(Integer.toString(j)); 7254 message.append("]"); 7255 } 7256 } 7257 } 7258 assertFalse("Incorrect output for checkConvertUshort4Ushort4" + 7259 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7260 } 7261 7262 public class ArgumentsIntUshort { 7263 public int inV; 7264 public short out; 7265 } 7266 7267 private void checkConvertInt2Ushort2() { 7268 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x1c02a5e414378844l, false, 16); 7269 try { 7270 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7271 script.forEach_testConvertUshort2Int2Ushort2(inV, out); 7272 verifyResultsConvertInt2Ushort2(inV, out, false); 7273 out.destroy(); 7274 } catch (Exception e) { 7275 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString()); 7276 } 7277 try { 7278 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7279 scriptRelaxed.forEach_testConvertUshort2Int2Ushort2(inV, out); 7280 verifyResultsConvertInt2Ushort2(inV, out, true); 7281 out.destroy(); 7282 } catch (Exception e) { 7283 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString()); 7284 } 7285 inV.destroy(); 7286 } 7287 7288 private void verifyResultsConvertInt2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 7289 int[] arrayInV = new int[INPUTSIZE * 2]; 7290 Arrays.fill(arrayInV, (int) 42); 7291 inV.copyTo(arrayInV); 7292 short[] arrayOut = new short[INPUTSIZE * 2]; 7293 Arrays.fill(arrayOut, (short) 42); 7294 out.copyTo(arrayOut); 7295 StringBuilder message = new StringBuilder(); 7296 boolean errorFound = false; 7297 for (int i = 0; i < INPUTSIZE; i++) { 7298 for (int j = 0; j < 2 ; j++) { 7299 // Extract the inputs. 7300 ArgumentsIntUshort args = new ArgumentsIntUshort(); 7301 args.inV = arrayInV[i * 2 + j]; 7302 // Figure out what the outputs should have been. 7303 CoreMathVerifier.computeConvert(args); 7304 // Validate the outputs. 7305 boolean valid = true; 7306 if (args.out != arrayOut[i * 2 + j]) { 7307 valid = false; 7308 } 7309 if (!valid) { 7310 if (!errorFound) { 7311 errorFound = true; 7312 message.append("Input inV: "); 7313 appendVariableToMessage(message, args.inV); 7314 message.append("\n"); 7315 message.append("Expected output out: "); 7316 appendVariableToMessage(message, args.out); 7317 message.append("\n"); 7318 message.append("Actual output out: "); 7319 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7320 if (args.out != arrayOut[i * 2 + j]) { 7321 message.append(" FAIL"); 7322 } 7323 message.append("\n"); 7324 message.append("Errors at"); 7325 } 7326 message.append(" ["); 7327 message.append(Integer.toString(i)); 7328 message.append(", "); 7329 message.append(Integer.toString(j)); 7330 message.append("]"); 7331 } 7332 } 7333 } 7334 assertFalse("Incorrect output for checkConvertInt2Ushort2" + 7335 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7336 } 7337 7338 private void checkConvertInt3Ushort3() { 7339 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1c4f6d6b6a931970l, false, 16); 7340 try { 7341 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7342 script.forEach_testConvertUshort3Int3Ushort3(inV, out); 7343 verifyResultsConvertInt3Ushort3(inV, out, false); 7344 out.destroy(); 7345 } catch (Exception e) { 7346 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString()); 7347 } 7348 try { 7349 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7350 scriptRelaxed.forEach_testConvertUshort3Int3Ushort3(inV, out); 7351 verifyResultsConvertInt3Ushort3(inV, out, true); 7352 out.destroy(); 7353 } catch (Exception e) { 7354 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString()); 7355 } 7356 inV.destroy(); 7357 } 7358 7359 private void verifyResultsConvertInt3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 7360 int[] arrayInV = new int[INPUTSIZE * 4]; 7361 Arrays.fill(arrayInV, (int) 42); 7362 inV.copyTo(arrayInV); 7363 short[] arrayOut = new short[INPUTSIZE * 4]; 7364 Arrays.fill(arrayOut, (short) 42); 7365 out.copyTo(arrayOut); 7366 StringBuilder message = new StringBuilder(); 7367 boolean errorFound = false; 7368 for (int i = 0; i < INPUTSIZE; i++) { 7369 for (int j = 0; j < 3 ; j++) { 7370 // Extract the inputs. 7371 ArgumentsIntUshort args = new ArgumentsIntUshort(); 7372 args.inV = arrayInV[i * 4 + j]; 7373 // Figure out what the outputs should have been. 7374 CoreMathVerifier.computeConvert(args); 7375 // Validate the outputs. 7376 boolean valid = true; 7377 if (args.out != arrayOut[i * 4 + j]) { 7378 valid = false; 7379 } 7380 if (!valid) { 7381 if (!errorFound) { 7382 errorFound = true; 7383 message.append("Input inV: "); 7384 appendVariableToMessage(message, args.inV); 7385 message.append("\n"); 7386 message.append("Expected output out: "); 7387 appendVariableToMessage(message, args.out); 7388 message.append("\n"); 7389 message.append("Actual output out: "); 7390 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7391 if (args.out != arrayOut[i * 4 + j]) { 7392 message.append(" FAIL"); 7393 } 7394 message.append("\n"); 7395 message.append("Errors at"); 7396 } 7397 message.append(" ["); 7398 message.append(Integer.toString(i)); 7399 message.append(", "); 7400 message.append(Integer.toString(j)); 7401 message.append("]"); 7402 } 7403 } 7404 } 7405 assertFalse("Incorrect output for checkConvertInt3Ushort3" + 7406 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7407 } 7408 7409 private void checkConvertInt4Ushort4() { 7410 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x1c9c34f2c0eeaa9cl, false, 16); 7411 try { 7412 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7413 script.forEach_testConvertUshort4Int4Ushort4(inV, out); 7414 verifyResultsConvertInt4Ushort4(inV, out, false); 7415 out.destroy(); 7416 } catch (Exception e) { 7417 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString()); 7418 } 7419 try { 7420 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7421 scriptRelaxed.forEach_testConvertUshort4Int4Ushort4(inV, out); 7422 verifyResultsConvertInt4Ushort4(inV, out, true); 7423 out.destroy(); 7424 } catch (Exception e) { 7425 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString()); 7426 } 7427 inV.destroy(); 7428 } 7429 7430 private void verifyResultsConvertInt4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 7431 int[] arrayInV = new int[INPUTSIZE * 4]; 7432 Arrays.fill(arrayInV, (int) 42); 7433 inV.copyTo(arrayInV); 7434 short[] arrayOut = new short[INPUTSIZE * 4]; 7435 Arrays.fill(arrayOut, (short) 42); 7436 out.copyTo(arrayOut); 7437 StringBuilder message = new StringBuilder(); 7438 boolean errorFound = false; 7439 for (int i = 0; i < INPUTSIZE; i++) { 7440 for (int j = 0; j < 4 ; j++) { 7441 // Extract the inputs. 7442 ArgumentsIntUshort args = new ArgumentsIntUshort(); 7443 args.inV = arrayInV[i * 4 + j]; 7444 // Figure out what the outputs should have been. 7445 CoreMathVerifier.computeConvert(args); 7446 // Validate the outputs. 7447 boolean valid = true; 7448 if (args.out != arrayOut[i * 4 + j]) { 7449 valid = false; 7450 } 7451 if (!valid) { 7452 if (!errorFound) { 7453 errorFound = true; 7454 message.append("Input inV: "); 7455 appendVariableToMessage(message, args.inV); 7456 message.append("\n"); 7457 message.append("Expected output out: "); 7458 appendVariableToMessage(message, args.out); 7459 message.append("\n"); 7460 message.append("Actual output out: "); 7461 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7462 if (args.out != arrayOut[i * 4 + j]) { 7463 message.append(" FAIL"); 7464 } 7465 message.append("\n"); 7466 message.append("Errors at"); 7467 } 7468 message.append(" ["); 7469 message.append(Integer.toString(i)); 7470 message.append(", "); 7471 message.append(Integer.toString(j)); 7472 message.append("]"); 7473 } 7474 } 7475 } 7476 assertFalse("Incorrect output for checkConvertInt4Ushort4" + 7477 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7478 } 7479 7480 public class ArgumentsUintUshort { 7481 public int inV; 7482 public short out; 7483 } 7484 7485 private void checkConvertUint2Ushort2() { 7486 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x40d0c5ebb00fa1efl, false, 16); 7487 try { 7488 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7489 script.forEach_testConvertUshort2Uint2Ushort2(inV, out); 7490 verifyResultsConvertUint2Ushort2(inV, out, false); 7491 out.destroy(); 7492 } catch (Exception e) { 7493 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString()); 7494 } 7495 try { 7496 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7497 scriptRelaxed.forEach_testConvertUshort2Uint2Ushort2(inV, out); 7498 verifyResultsConvertUint2Ushort2(inV, out, true); 7499 out.destroy(); 7500 } catch (Exception e) { 7501 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString()); 7502 } 7503 inV.destroy(); 7504 } 7505 7506 private void verifyResultsConvertUint2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 7507 int[] arrayInV = new int[INPUTSIZE * 2]; 7508 Arrays.fill(arrayInV, (int) 42); 7509 inV.copyTo(arrayInV); 7510 short[] arrayOut = new short[INPUTSIZE * 2]; 7511 Arrays.fill(arrayOut, (short) 42); 7512 out.copyTo(arrayOut); 7513 StringBuilder message = new StringBuilder(); 7514 boolean errorFound = false; 7515 for (int i = 0; i < INPUTSIZE; i++) { 7516 for (int j = 0; j < 2 ; j++) { 7517 // Extract the inputs. 7518 ArgumentsUintUshort args = new ArgumentsUintUshort(); 7519 args.inV = arrayInV[i * 2 + j]; 7520 // Figure out what the outputs should have been. 7521 CoreMathVerifier.computeConvert(args); 7522 // Validate the outputs. 7523 boolean valid = true; 7524 if (args.out != arrayOut[i * 2 + j]) { 7525 valid = false; 7526 } 7527 if (!valid) { 7528 if (!errorFound) { 7529 errorFound = true; 7530 message.append("Input inV: "); 7531 appendVariableToMessage(message, args.inV); 7532 message.append("\n"); 7533 message.append("Expected output out: "); 7534 appendVariableToMessage(message, args.out); 7535 message.append("\n"); 7536 message.append("Actual output out: "); 7537 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7538 if (args.out != arrayOut[i * 2 + j]) { 7539 message.append(" FAIL"); 7540 } 7541 message.append("\n"); 7542 message.append("Errors at"); 7543 } 7544 message.append(" ["); 7545 message.append(Integer.toString(i)); 7546 message.append(", "); 7547 message.append(Integer.toString(j)); 7548 message.append("]"); 7549 } 7550 } 7551 } 7552 assertFalse("Incorrect output for checkConvertUint2Ushort2" + 7553 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7554 } 7555 7556 private void checkConvertUint3Ushort3() { 7557 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x411d8d73066b331bl, false, 16); 7558 try { 7559 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7560 script.forEach_testConvertUshort3Uint3Ushort3(inV, out); 7561 verifyResultsConvertUint3Ushort3(inV, out, false); 7562 out.destroy(); 7563 } catch (Exception e) { 7564 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString()); 7565 } 7566 try { 7567 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7568 scriptRelaxed.forEach_testConvertUshort3Uint3Ushort3(inV, out); 7569 verifyResultsConvertUint3Ushort3(inV, out, true); 7570 out.destroy(); 7571 } catch (Exception e) { 7572 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString()); 7573 } 7574 inV.destroy(); 7575 } 7576 7577 private void verifyResultsConvertUint3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 7578 int[] arrayInV = new int[INPUTSIZE * 4]; 7579 Arrays.fill(arrayInV, (int) 42); 7580 inV.copyTo(arrayInV); 7581 short[] arrayOut = new short[INPUTSIZE * 4]; 7582 Arrays.fill(arrayOut, (short) 42); 7583 out.copyTo(arrayOut); 7584 StringBuilder message = new StringBuilder(); 7585 boolean errorFound = false; 7586 for (int i = 0; i < INPUTSIZE; i++) { 7587 for (int j = 0; j < 3 ; j++) { 7588 // Extract the inputs. 7589 ArgumentsUintUshort args = new ArgumentsUintUshort(); 7590 args.inV = arrayInV[i * 4 + j]; 7591 // Figure out what the outputs should have been. 7592 CoreMathVerifier.computeConvert(args); 7593 // Validate the outputs. 7594 boolean valid = true; 7595 if (args.out != arrayOut[i * 4 + j]) { 7596 valid = false; 7597 } 7598 if (!valid) { 7599 if (!errorFound) { 7600 errorFound = true; 7601 message.append("Input inV: "); 7602 appendVariableToMessage(message, args.inV); 7603 message.append("\n"); 7604 message.append("Expected output out: "); 7605 appendVariableToMessage(message, args.out); 7606 message.append("\n"); 7607 message.append("Actual output out: "); 7608 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7609 if (args.out != arrayOut[i * 4 + j]) { 7610 message.append(" FAIL"); 7611 } 7612 message.append("\n"); 7613 message.append("Errors at"); 7614 } 7615 message.append(" ["); 7616 message.append(Integer.toString(i)); 7617 message.append(", "); 7618 message.append(Integer.toString(j)); 7619 message.append("]"); 7620 } 7621 } 7622 } 7623 assertFalse("Incorrect output for checkConvertUint3Ushort3" + 7624 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7625 } 7626 7627 private void checkConvertUint4Ushort4() { 7628 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x416a54fa5cc6c447l, false, 16); 7629 try { 7630 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7631 script.forEach_testConvertUshort4Uint4Ushort4(inV, out); 7632 verifyResultsConvertUint4Ushort4(inV, out, false); 7633 out.destroy(); 7634 } catch (Exception e) { 7635 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString()); 7636 } 7637 try { 7638 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7639 scriptRelaxed.forEach_testConvertUshort4Uint4Ushort4(inV, out); 7640 verifyResultsConvertUint4Ushort4(inV, out, true); 7641 out.destroy(); 7642 } catch (Exception e) { 7643 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString()); 7644 } 7645 inV.destroy(); 7646 } 7647 7648 private void verifyResultsConvertUint4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 7649 int[] arrayInV = new int[INPUTSIZE * 4]; 7650 Arrays.fill(arrayInV, (int) 42); 7651 inV.copyTo(arrayInV); 7652 short[] arrayOut = new short[INPUTSIZE * 4]; 7653 Arrays.fill(arrayOut, (short) 42); 7654 out.copyTo(arrayOut); 7655 StringBuilder message = new StringBuilder(); 7656 boolean errorFound = false; 7657 for (int i = 0; i < INPUTSIZE; i++) { 7658 for (int j = 0; j < 4 ; j++) { 7659 // Extract the inputs. 7660 ArgumentsUintUshort args = new ArgumentsUintUshort(); 7661 args.inV = arrayInV[i * 4 + j]; 7662 // Figure out what the outputs should have been. 7663 CoreMathVerifier.computeConvert(args); 7664 // Validate the outputs. 7665 boolean valid = true; 7666 if (args.out != arrayOut[i * 4 + j]) { 7667 valid = false; 7668 } 7669 if (!valid) { 7670 if (!errorFound) { 7671 errorFound = true; 7672 message.append("Input inV: "); 7673 appendVariableToMessage(message, args.inV); 7674 message.append("\n"); 7675 message.append("Expected output out: "); 7676 appendVariableToMessage(message, args.out); 7677 message.append("\n"); 7678 message.append("Actual output out: "); 7679 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7680 if (args.out != arrayOut[i * 4 + j]) { 7681 message.append(" FAIL"); 7682 } 7683 message.append("\n"); 7684 message.append("Errors at"); 7685 } 7686 message.append(" ["); 7687 message.append(Integer.toString(i)); 7688 message.append(", "); 7689 message.append(Integer.toString(j)); 7690 message.append("]"); 7691 } 7692 } 7693 } 7694 assertFalse("Incorrect output for checkConvertUint4Ushort4" + 7695 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7696 } 7697 7698 public class ArgumentsFloatInt { 7699 public float inV; 7700 public int out; 7701 } 7702 7703 private void checkConvertFloat2Int2() { 7704 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fb63fb7c069dd5dl, -2.1474835210000000000e+09, 2.1474835200000000000e+09); 7705 try { 7706 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7707 script.forEach_testConvertInt2Float2Int2(inV, out); 7708 verifyResultsConvertFloat2Int2(inV, out, false); 7709 out.destroy(); 7710 } catch (Exception e) { 7711 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString()); 7712 } 7713 try { 7714 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7715 scriptRelaxed.forEach_testConvertInt2Float2Int2(inV, out); 7716 verifyResultsConvertFloat2Int2(inV, out, true); 7717 out.destroy(); 7718 } catch (Exception e) { 7719 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString()); 7720 } 7721 inV.destroy(); 7722 } 7723 7724 private void verifyResultsConvertFloat2Int2(Allocation inV, Allocation out, boolean relaxed) { 7725 float[] arrayInV = new float[INPUTSIZE * 2]; 7726 Arrays.fill(arrayInV, (float) 42); 7727 inV.copyTo(arrayInV); 7728 int[] arrayOut = new int[INPUTSIZE * 2]; 7729 Arrays.fill(arrayOut, (int) 42); 7730 out.copyTo(arrayOut); 7731 StringBuilder message = new StringBuilder(); 7732 boolean errorFound = false; 7733 for (int i = 0; i < INPUTSIZE; i++) { 7734 for (int j = 0; j < 2 ; j++) { 7735 // Extract the inputs. 7736 ArgumentsFloatInt args = new ArgumentsFloatInt(); 7737 args.inV = arrayInV[i * 2 + j]; 7738 // Figure out what the outputs should have been. 7739 CoreMathVerifier.computeConvert(args); 7740 // Validate the outputs. 7741 boolean valid = true; 7742 if (args.out != arrayOut[i * 2 + j]) { 7743 valid = false; 7744 } 7745 if (!valid) { 7746 if (!errorFound) { 7747 errorFound = true; 7748 message.append("Input inV: "); 7749 appendVariableToMessage(message, args.inV); 7750 message.append("\n"); 7751 message.append("Expected output out: "); 7752 appendVariableToMessage(message, args.out); 7753 message.append("\n"); 7754 message.append("Actual output out: "); 7755 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7756 if (args.out != arrayOut[i * 2 + j]) { 7757 message.append(" FAIL"); 7758 } 7759 message.append("\n"); 7760 message.append("Errors at"); 7761 } 7762 message.append(" ["); 7763 message.append(Integer.toString(i)); 7764 message.append(", "); 7765 message.append(Integer.toString(j)); 7766 message.append("]"); 7767 } 7768 } 7769 } 7770 assertFalse("Incorrect output for checkConvertFloat2Int2" + 7771 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7772 } 7773 7774 private void checkConvertFloat3Int3() { 7775 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8fb63ff70a11ed93l, -2.1474835210000000000e+09, 2.1474835200000000000e+09); 7776 try { 7777 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7778 script.forEach_testConvertInt3Float3Int3(inV, out); 7779 verifyResultsConvertFloat3Int3(inV, out, false); 7780 out.destroy(); 7781 } catch (Exception e) { 7782 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString()); 7783 } 7784 try { 7785 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7786 scriptRelaxed.forEach_testConvertInt3Float3Int3(inV, out); 7787 verifyResultsConvertFloat3Int3(inV, out, true); 7788 out.destroy(); 7789 } catch (Exception e) { 7790 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString()); 7791 } 7792 inV.destroy(); 7793 } 7794 7795 private void verifyResultsConvertFloat3Int3(Allocation inV, Allocation out, boolean relaxed) { 7796 float[] arrayInV = new float[INPUTSIZE * 4]; 7797 Arrays.fill(arrayInV, (float) 42); 7798 inV.copyTo(arrayInV); 7799 int[] arrayOut = new int[INPUTSIZE * 4]; 7800 Arrays.fill(arrayOut, (int) 42); 7801 out.copyTo(arrayOut); 7802 StringBuilder message = new StringBuilder(); 7803 boolean errorFound = false; 7804 for (int i = 0; i < INPUTSIZE; i++) { 7805 for (int j = 0; j < 3 ; j++) { 7806 // Extract the inputs. 7807 ArgumentsFloatInt args = new ArgumentsFloatInt(); 7808 args.inV = arrayInV[i * 4 + j]; 7809 // Figure out what the outputs should have been. 7810 CoreMathVerifier.computeConvert(args); 7811 // Validate the outputs. 7812 boolean valid = true; 7813 if (args.out != arrayOut[i * 4 + j]) { 7814 valid = false; 7815 } 7816 if (!valid) { 7817 if (!errorFound) { 7818 errorFound = true; 7819 message.append("Input inV: "); 7820 appendVariableToMessage(message, args.inV); 7821 message.append("\n"); 7822 message.append("Expected output out: "); 7823 appendVariableToMessage(message, args.out); 7824 message.append("\n"); 7825 message.append("Actual output out: "); 7826 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7827 if (args.out != arrayOut[i * 4 + j]) { 7828 message.append(" FAIL"); 7829 } 7830 message.append("\n"); 7831 message.append("Errors at"); 7832 } 7833 message.append(" ["); 7834 message.append(Integer.toString(i)); 7835 message.append(", "); 7836 message.append(Integer.toString(j)); 7837 message.append("]"); 7838 } 7839 } 7840 } 7841 assertFalse("Incorrect output for checkConvertFloat3Int3" + 7842 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7843 } 7844 7845 private void checkConvertFloat4Int4() { 7846 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8fb6403653b9fdc9l, -2.1474835210000000000e+09, 2.1474835200000000000e+09); 7847 try { 7848 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7849 script.forEach_testConvertInt4Float4Int4(inV, out); 7850 verifyResultsConvertFloat4Int4(inV, out, false); 7851 out.destroy(); 7852 } catch (Exception e) { 7853 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString()); 7854 } 7855 try { 7856 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7857 scriptRelaxed.forEach_testConvertInt4Float4Int4(inV, out); 7858 verifyResultsConvertFloat4Int4(inV, out, true); 7859 out.destroy(); 7860 } catch (Exception e) { 7861 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString()); 7862 } 7863 inV.destroy(); 7864 } 7865 7866 private void verifyResultsConvertFloat4Int4(Allocation inV, Allocation out, boolean relaxed) { 7867 float[] arrayInV = new float[INPUTSIZE * 4]; 7868 Arrays.fill(arrayInV, (float) 42); 7869 inV.copyTo(arrayInV); 7870 int[] arrayOut = new int[INPUTSIZE * 4]; 7871 Arrays.fill(arrayOut, (int) 42); 7872 out.copyTo(arrayOut); 7873 StringBuilder message = new StringBuilder(); 7874 boolean errorFound = false; 7875 for (int i = 0; i < INPUTSIZE; i++) { 7876 for (int j = 0; j < 4 ; j++) { 7877 // Extract the inputs. 7878 ArgumentsFloatInt args = new ArgumentsFloatInt(); 7879 args.inV = arrayInV[i * 4 + j]; 7880 // Figure out what the outputs should have been. 7881 CoreMathVerifier.computeConvert(args); 7882 // Validate the outputs. 7883 boolean valid = true; 7884 if (args.out != arrayOut[i * 4 + j]) { 7885 valid = false; 7886 } 7887 if (!valid) { 7888 if (!errorFound) { 7889 errorFound = true; 7890 message.append("Input inV: "); 7891 appendVariableToMessage(message, args.inV); 7892 message.append("\n"); 7893 message.append("Expected output out: "); 7894 appendVariableToMessage(message, args.out); 7895 message.append("\n"); 7896 message.append("Actual output out: "); 7897 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7898 if (args.out != arrayOut[i * 4 + j]) { 7899 message.append(" FAIL"); 7900 } 7901 message.append("\n"); 7902 message.append("Errors at"); 7903 } 7904 message.append(" ["); 7905 message.append(Integer.toString(i)); 7906 message.append(", "); 7907 message.append(Integer.toString(j)); 7908 message.append("]"); 7909 } 7910 } 7911 } 7912 assertFalse("Incorrect output for checkConvertFloat4Int4" + 7913 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7914 } 7915 7916 public class ArgumentsCharInt { 7917 public byte inV; 7918 public int out; 7919 } 7920 7921 private void checkConvertChar2Int2() { 7922 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x880244ac94c6831dl, true, 7); 7923 try { 7924 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7925 script.forEach_testConvertInt2Char2Int2(inV, out); 7926 verifyResultsConvertChar2Int2(inV, out, false); 7927 out.destroy(); 7928 } catch (Exception e) { 7929 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString()); 7930 } 7931 try { 7932 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7933 scriptRelaxed.forEach_testConvertInt2Char2Int2(inV, out); 7934 verifyResultsConvertChar2Int2(inV, out, true); 7935 out.destroy(); 7936 } catch (Exception e) { 7937 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString()); 7938 } 7939 inV.destroy(); 7940 } 7941 7942 private void verifyResultsConvertChar2Int2(Allocation inV, Allocation out, boolean relaxed) { 7943 byte[] arrayInV = new byte[INPUTSIZE * 2]; 7944 Arrays.fill(arrayInV, (byte) 42); 7945 inV.copyTo(arrayInV); 7946 int[] arrayOut = new int[INPUTSIZE * 2]; 7947 Arrays.fill(arrayOut, (int) 42); 7948 out.copyTo(arrayOut); 7949 StringBuilder message = new StringBuilder(); 7950 boolean errorFound = false; 7951 for (int i = 0; i < INPUTSIZE; i++) { 7952 for (int j = 0; j < 2 ; j++) { 7953 // Extract the inputs. 7954 ArgumentsCharInt args = new ArgumentsCharInt(); 7955 args.inV = arrayInV[i * 2 + j]; 7956 // Figure out what the outputs should have been. 7957 CoreMathVerifier.computeConvert(args); 7958 // Validate the outputs. 7959 boolean valid = true; 7960 if (args.out != arrayOut[i * 2 + j]) { 7961 valid = false; 7962 } 7963 if (!valid) { 7964 if (!errorFound) { 7965 errorFound = true; 7966 message.append("Input inV: "); 7967 appendVariableToMessage(message, args.inV); 7968 message.append("\n"); 7969 message.append("Expected output out: "); 7970 appendVariableToMessage(message, args.out); 7971 message.append("\n"); 7972 message.append("Actual output out: "); 7973 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7974 if (args.out != arrayOut[i * 2 + j]) { 7975 message.append(" FAIL"); 7976 } 7977 message.append("\n"); 7978 message.append("Errors at"); 7979 } 7980 message.append(" ["); 7981 message.append(Integer.toString(i)); 7982 message.append(", "); 7983 message.append(Integer.toString(j)); 7984 message.append("]"); 7985 } 7986 } 7987 } 7988 assertFalse("Incorrect output for checkConvertChar2Int2" + 7989 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7990 } 7991 7992 private void checkConvertChar3Int3() { 7993 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x880244ebde6e9353l, true, 7); 7994 try { 7995 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7996 script.forEach_testConvertInt3Char3Int3(inV, out); 7997 verifyResultsConvertChar3Int3(inV, out, false); 7998 out.destroy(); 7999 } catch (Exception e) { 8000 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString()); 8001 } 8002 try { 8003 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8004 scriptRelaxed.forEach_testConvertInt3Char3Int3(inV, out); 8005 verifyResultsConvertChar3Int3(inV, out, true); 8006 out.destroy(); 8007 } catch (Exception e) { 8008 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString()); 8009 } 8010 inV.destroy(); 8011 } 8012 8013 private void verifyResultsConvertChar3Int3(Allocation inV, Allocation out, boolean relaxed) { 8014 byte[] arrayInV = new byte[INPUTSIZE * 4]; 8015 Arrays.fill(arrayInV, (byte) 42); 8016 inV.copyTo(arrayInV); 8017 int[] arrayOut = new int[INPUTSIZE * 4]; 8018 Arrays.fill(arrayOut, (int) 42); 8019 out.copyTo(arrayOut); 8020 StringBuilder message = new StringBuilder(); 8021 boolean errorFound = false; 8022 for (int i = 0; i < INPUTSIZE; i++) { 8023 for (int j = 0; j < 3 ; j++) { 8024 // Extract the inputs. 8025 ArgumentsCharInt args = new ArgumentsCharInt(); 8026 args.inV = arrayInV[i * 4 + j]; 8027 // Figure out what the outputs should have been. 8028 CoreMathVerifier.computeConvert(args); 8029 // Validate the outputs. 8030 boolean valid = true; 8031 if (args.out != arrayOut[i * 4 + j]) { 8032 valid = false; 8033 } 8034 if (!valid) { 8035 if (!errorFound) { 8036 errorFound = true; 8037 message.append("Input inV: "); 8038 appendVariableToMessage(message, args.inV); 8039 message.append("\n"); 8040 message.append("Expected output out: "); 8041 appendVariableToMessage(message, args.out); 8042 message.append("\n"); 8043 message.append("Actual output out: "); 8044 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8045 if (args.out != arrayOut[i * 4 + j]) { 8046 message.append(" FAIL"); 8047 } 8048 message.append("\n"); 8049 message.append("Errors at"); 8050 } 8051 message.append(" ["); 8052 message.append(Integer.toString(i)); 8053 message.append(", "); 8054 message.append(Integer.toString(j)); 8055 message.append("]"); 8056 } 8057 } 8058 } 8059 assertFalse("Incorrect output for checkConvertChar3Int3" + 8060 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8061 } 8062 8063 private void checkConvertChar4Int4() { 8064 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x8802452b2816a389l, true, 7); 8065 try { 8066 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8067 script.forEach_testConvertInt4Char4Int4(inV, out); 8068 verifyResultsConvertChar4Int4(inV, out, false); 8069 out.destroy(); 8070 } catch (Exception e) { 8071 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString()); 8072 } 8073 try { 8074 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8075 scriptRelaxed.forEach_testConvertInt4Char4Int4(inV, out); 8076 verifyResultsConvertChar4Int4(inV, out, true); 8077 out.destroy(); 8078 } catch (Exception e) { 8079 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString()); 8080 } 8081 inV.destroy(); 8082 } 8083 8084 private void verifyResultsConvertChar4Int4(Allocation inV, Allocation out, boolean relaxed) { 8085 byte[] arrayInV = new byte[INPUTSIZE * 4]; 8086 Arrays.fill(arrayInV, (byte) 42); 8087 inV.copyTo(arrayInV); 8088 int[] arrayOut = new int[INPUTSIZE * 4]; 8089 Arrays.fill(arrayOut, (int) 42); 8090 out.copyTo(arrayOut); 8091 StringBuilder message = new StringBuilder(); 8092 boolean errorFound = false; 8093 for (int i = 0; i < INPUTSIZE; i++) { 8094 for (int j = 0; j < 4 ; j++) { 8095 // Extract the inputs. 8096 ArgumentsCharInt args = new ArgumentsCharInt(); 8097 args.inV = arrayInV[i * 4 + j]; 8098 // Figure out what the outputs should have been. 8099 CoreMathVerifier.computeConvert(args); 8100 // Validate the outputs. 8101 boolean valid = true; 8102 if (args.out != arrayOut[i * 4 + j]) { 8103 valid = false; 8104 } 8105 if (!valid) { 8106 if (!errorFound) { 8107 errorFound = true; 8108 message.append("Input inV: "); 8109 appendVariableToMessage(message, args.inV); 8110 message.append("\n"); 8111 message.append("Expected output out: "); 8112 appendVariableToMessage(message, args.out); 8113 message.append("\n"); 8114 message.append("Actual output out: "); 8115 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8116 if (args.out != arrayOut[i * 4 + j]) { 8117 message.append(" FAIL"); 8118 } 8119 message.append("\n"); 8120 message.append("Errors at"); 8121 } 8122 message.append(" ["); 8123 message.append(Integer.toString(i)); 8124 message.append(", "); 8125 message.append(Integer.toString(j)); 8126 message.append("]"); 8127 } 8128 } 8129 } 8130 assertFalse("Incorrect output for checkConvertChar4Int4" + 8131 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8132 } 8133 8134 public class ArgumentsUcharInt { 8135 public byte inV; 8136 public int out; 8137 } 8138 8139 private void checkConvertUchar2Int2() { 8140 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x97cffb96923aa720l, false, 8); 8141 try { 8142 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8143 script.forEach_testConvertInt2Uchar2Int2(inV, out); 8144 verifyResultsConvertUchar2Int2(inV, out, false); 8145 out.destroy(); 8146 } catch (Exception e) { 8147 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString()); 8148 } 8149 try { 8150 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8151 scriptRelaxed.forEach_testConvertInt2Uchar2Int2(inV, out); 8152 verifyResultsConvertUchar2Int2(inV, out, true); 8153 out.destroy(); 8154 } catch (Exception e) { 8155 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString()); 8156 } 8157 inV.destroy(); 8158 } 8159 8160 private void verifyResultsConvertUchar2Int2(Allocation inV, Allocation out, boolean relaxed) { 8161 byte[] arrayInV = new byte[INPUTSIZE * 2]; 8162 Arrays.fill(arrayInV, (byte) 42); 8163 inV.copyTo(arrayInV); 8164 int[] arrayOut = new int[INPUTSIZE * 2]; 8165 Arrays.fill(arrayOut, (int) 42); 8166 out.copyTo(arrayOut); 8167 StringBuilder message = new StringBuilder(); 8168 boolean errorFound = false; 8169 for (int i = 0; i < INPUTSIZE; i++) { 8170 for (int j = 0; j < 2 ; j++) { 8171 // Extract the inputs. 8172 ArgumentsUcharInt args = new ArgumentsUcharInt(); 8173 args.inV = arrayInV[i * 2 + j]; 8174 // Figure out what the outputs should have been. 8175 CoreMathVerifier.computeConvert(args); 8176 // Validate the outputs. 8177 boolean valid = true; 8178 if (args.out != arrayOut[i * 2 + j]) { 8179 valid = false; 8180 } 8181 if (!valid) { 8182 if (!errorFound) { 8183 errorFound = true; 8184 message.append("Input inV: "); 8185 appendVariableToMessage(message, args.inV); 8186 message.append("\n"); 8187 message.append("Expected output out: "); 8188 appendVariableToMessage(message, args.out); 8189 message.append("\n"); 8190 message.append("Actual output out: "); 8191 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8192 if (args.out != arrayOut[i * 2 + j]) { 8193 message.append(" FAIL"); 8194 } 8195 message.append("\n"); 8196 message.append("Errors at"); 8197 } 8198 message.append(" ["); 8199 message.append(Integer.toString(i)); 8200 message.append(", "); 8201 message.append(Integer.toString(j)); 8202 message.append("]"); 8203 } 8204 } 8205 } 8206 assertFalse("Incorrect output for checkConvertUchar2Int2" + 8207 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8208 } 8209 8210 private void checkConvertUchar3Int3() { 8211 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x97cffbd5dbe2b756l, false, 8); 8212 try { 8213 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8214 script.forEach_testConvertInt3Uchar3Int3(inV, out); 8215 verifyResultsConvertUchar3Int3(inV, out, false); 8216 out.destroy(); 8217 } catch (Exception e) { 8218 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString()); 8219 } 8220 try { 8221 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8222 scriptRelaxed.forEach_testConvertInt3Uchar3Int3(inV, out); 8223 verifyResultsConvertUchar3Int3(inV, out, true); 8224 out.destroy(); 8225 } catch (Exception e) { 8226 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString()); 8227 } 8228 inV.destroy(); 8229 } 8230 8231 private void verifyResultsConvertUchar3Int3(Allocation inV, Allocation out, boolean relaxed) { 8232 byte[] arrayInV = new byte[INPUTSIZE * 4]; 8233 Arrays.fill(arrayInV, (byte) 42); 8234 inV.copyTo(arrayInV); 8235 int[] arrayOut = new int[INPUTSIZE * 4]; 8236 Arrays.fill(arrayOut, (int) 42); 8237 out.copyTo(arrayOut); 8238 StringBuilder message = new StringBuilder(); 8239 boolean errorFound = false; 8240 for (int i = 0; i < INPUTSIZE; i++) { 8241 for (int j = 0; j < 3 ; j++) { 8242 // Extract the inputs. 8243 ArgumentsUcharInt args = new ArgumentsUcharInt(); 8244 args.inV = arrayInV[i * 4 + j]; 8245 // Figure out what the outputs should have been. 8246 CoreMathVerifier.computeConvert(args); 8247 // Validate the outputs. 8248 boolean valid = true; 8249 if (args.out != arrayOut[i * 4 + j]) { 8250 valid = false; 8251 } 8252 if (!valid) { 8253 if (!errorFound) { 8254 errorFound = true; 8255 message.append("Input inV: "); 8256 appendVariableToMessage(message, args.inV); 8257 message.append("\n"); 8258 message.append("Expected output out: "); 8259 appendVariableToMessage(message, args.out); 8260 message.append("\n"); 8261 message.append("Actual output out: "); 8262 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8263 if (args.out != arrayOut[i * 4 + j]) { 8264 message.append(" FAIL"); 8265 } 8266 message.append("\n"); 8267 message.append("Errors at"); 8268 } 8269 message.append(" ["); 8270 message.append(Integer.toString(i)); 8271 message.append(", "); 8272 message.append(Integer.toString(j)); 8273 message.append("]"); 8274 } 8275 } 8276 } 8277 assertFalse("Incorrect output for checkConvertUchar3Int3" + 8278 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8279 } 8280 8281 private void checkConvertUchar4Int4() { 8282 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x97cffc15258ac78cl, false, 8); 8283 try { 8284 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8285 script.forEach_testConvertInt4Uchar4Int4(inV, out); 8286 verifyResultsConvertUchar4Int4(inV, out, false); 8287 out.destroy(); 8288 } catch (Exception e) { 8289 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString()); 8290 } 8291 try { 8292 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8293 scriptRelaxed.forEach_testConvertInt4Uchar4Int4(inV, out); 8294 verifyResultsConvertUchar4Int4(inV, out, true); 8295 out.destroy(); 8296 } catch (Exception e) { 8297 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString()); 8298 } 8299 inV.destroy(); 8300 } 8301 8302 private void verifyResultsConvertUchar4Int4(Allocation inV, Allocation out, boolean relaxed) { 8303 byte[] arrayInV = new byte[INPUTSIZE * 4]; 8304 Arrays.fill(arrayInV, (byte) 42); 8305 inV.copyTo(arrayInV); 8306 int[] arrayOut = new int[INPUTSIZE * 4]; 8307 Arrays.fill(arrayOut, (int) 42); 8308 out.copyTo(arrayOut); 8309 StringBuilder message = new StringBuilder(); 8310 boolean errorFound = false; 8311 for (int i = 0; i < INPUTSIZE; i++) { 8312 for (int j = 0; j < 4 ; j++) { 8313 // Extract the inputs. 8314 ArgumentsUcharInt args = new ArgumentsUcharInt(); 8315 args.inV = arrayInV[i * 4 + j]; 8316 // Figure out what the outputs should have been. 8317 CoreMathVerifier.computeConvert(args); 8318 // Validate the outputs. 8319 boolean valid = true; 8320 if (args.out != arrayOut[i * 4 + j]) { 8321 valid = false; 8322 } 8323 if (!valid) { 8324 if (!errorFound) { 8325 errorFound = true; 8326 message.append("Input inV: "); 8327 appendVariableToMessage(message, args.inV); 8328 message.append("\n"); 8329 message.append("Expected output out: "); 8330 appendVariableToMessage(message, args.out); 8331 message.append("\n"); 8332 message.append("Actual output out: "); 8333 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8334 if (args.out != arrayOut[i * 4 + j]) { 8335 message.append(" FAIL"); 8336 } 8337 message.append("\n"); 8338 message.append("Errors at"); 8339 } 8340 message.append(" ["); 8341 message.append(Integer.toString(i)); 8342 message.append(", "); 8343 message.append(Integer.toString(j)); 8344 message.append("]"); 8345 } 8346 } 8347 } 8348 assertFalse("Incorrect output for checkConvertUchar4Int4" + 8349 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8350 } 8351 8352 public class ArgumentsShortInt { 8353 public short inV; 8354 public int out; 8355 } 8356 8357 private void checkConvertShort2Int2() { 8358 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x85693203252a2d69l, true, 15); 8359 try { 8360 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8361 script.forEach_testConvertInt2Short2Int2(inV, out); 8362 verifyResultsConvertShort2Int2(inV, out, false); 8363 out.destroy(); 8364 } catch (Exception e) { 8365 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString()); 8366 } 8367 try { 8368 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8369 scriptRelaxed.forEach_testConvertInt2Short2Int2(inV, out); 8370 verifyResultsConvertShort2Int2(inV, out, true); 8371 out.destroy(); 8372 } catch (Exception e) { 8373 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString()); 8374 } 8375 inV.destroy(); 8376 } 8377 8378 private void verifyResultsConvertShort2Int2(Allocation inV, Allocation out, boolean relaxed) { 8379 short[] arrayInV = new short[INPUTSIZE * 2]; 8380 Arrays.fill(arrayInV, (short) 42); 8381 inV.copyTo(arrayInV); 8382 int[] arrayOut = new int[INPUTSIZE * 2]; 8383 Arrays.fill(arrayOut, (int) 42); 8384 out.copyTo(arrayOut); 8385 StringBuilder message = new StringBuilder(); 8386 boolean errorFound = false; 8387 for (int i = 0; i < INPUTSIZE; i++) { 8388 for (int j = 0; j < 2 ; j++) { 8389 // Extract the inputs. 8390 ArgumentsShortInt args = new ArgumentsShortInt(); 8391 args.inV = arrayInV[i * 2 + j]; 8392 // Figure out what the outputs should have been. 8393 CoreMathVerifier.computeConvert(args); 8394 // Validate the outputs. 8395 boolean valid = true; 8396 if (args.out != arrayOut[i * 2 + j]) { 8397 valid = false; 8398 } 8399 if (!valid) { 8400 if (!errorFound) { 8401 errorFound = true; 8402 message.append("Input inV: "); 8403 appendVariableToMessage(message, args.inV); 8404 message.append("\n"); 8405 message.append("Expected output out: "); 8406 appendVariableToMessage(message, args.out); 8407 message.append("\n"); 8408 message.append("Actual output out: "); 8409 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8410 if (args.out != arrayOut[i * 2 + j]) { 8411 message.append(" FAIL"); 8412 } 8413 message.append("\n"); 8414 message.append("Errors at"); 8415 } 8416 message.append(" ["); 8417 message.append(Integer.toString(i)); 8418 message.append(", "); 8419 message.append(Integer.toString(j)); 8420 message.append("]"); 8421 } 8422 } 8423 } 8424 assertFalse("Incorrect output for checkConvertShort2Int2" + 8425 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8426 } 8427 8428 private void checkConvertShort3Int3() { 8429 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x856932426ed23d9fl, true, 15); 8430 try { 8431 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8432 script.forEach_testConvertInt3Short3Int3(inV, out); 8433 verifyResultsConvertShort3Int3(inV, out, false); 8434 out.destroy(); 8435 } catch (Exception e) { 8436 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString()); 8437 } 8438 try { 8439 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8440 scriptRelaxed.forEach_testConvertInt3Short3Int3(inV, out); 8441 verifyResultsConvertShort3Int3(inV, out, true); 8442 out.destroy(); 8443 } catch (Exception e) { 8444 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString()); 8445 } 8446 inV.destroy(); 8447 } 8448 8449 private void verifyResultsConvertShort3Int3(Allocation inV, Allocation out, boolean relaxed) { 8450 short[] arrayInV = new short[INPUTSIZE * 4]; 8451 Arrays.fill(arrayInV, (short) 42); 8452 inV.copyTo(arrayInV); 8453 int[] arrayOut = new int[INPUTSIZE * 4]; 8454 Arrays.fill(arrayOut, (int) 42); 8455 out.copyTo(arrayOut); 8456 StringBuilder message = new StringBuilder(); 8457 boolean errorFound = false; 8458 for (int i = 0; i < INPUTSIZE; i++) { 8459 for (int j = 0; j < 3 ; j++) { 8460 // Extract the inputs. 8461 ArgumentsShortInt args = new ArgumentsShortInt(); 8462 args.inV = arrayInV[i * 4 + j]; 8463 // Figure out what the outputs should have been. 8464 CoreMathVerifier.computeConvert(args); 8465 // Validate the outputs. 8466 boolean valid = true; 8467 if (args.out != arrayOut[i * 4 + j]) { 8468 valid = false; 8469 } 8470 if (!valid) { 8471 if (!errorFound) { 8472 errorFound = true; 8473 message.append("Input inV: "); 8474 appendVariableToMessage(message, args.inV); 8475 message.append("\n"); 8476 message.append("Expected output out: "); 8477 appendVariableToMessage(message, args.out); 8478 message.append("\n"); 8479 message.append("Actual output out: "); 8480 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8481 if (args.out != arrayOut[i * 4 + j]) { 8482 message.append(" FAIL"); 8483 } 8484 message.append("\n"); 8485 message.append("Errors at"); 8486 } 8487 message.append(" ["); 8488 message.append(Integer.toString(i)); 8489 message.append(", "); 8490 message.append(Integer.toString(j)); 8491 message.append("]"); 8492 } 8493 } 8494 } 8495 assertFalse("Incorrect output for checkConvertShort3Int3" + 8496 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8497 } 8498 8499 private void checkConvertShort4Int4() { 8500 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x85693281b87a4dd5l, true, 15); 8501 try { 8502 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8503 script.forEach_testConvertInt4Short4Int4(inV, out); 8504 verifyResultsConvertShort4Int4(inV, out, false); 8505 out.destroy(); 8506 } catch (Exception e) { 8507 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString()); 8508 } 8509 try { 8510 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8511 scriptRelaxed.forEach_testConvertInt4Short4Int4(inV, out); 8512 verifyResultsConvertShort4Int4(inV, out, true); 8513 out.destroy(); 8514 } catch (Exception e) { 8515 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString()); 8516 } 8517 inV.destroy(); 8518 } 8519 8520 private void verifyResultsConvertShort4Int4(Allocation inV, Allocation out, boolean relaxed) { 8521 short[] arrayInV = new short[INPUTSIZE * 4]; 8522 Arrays.fill(arrayInV, (short) 42); 8523 inV.copyTo(arrayInV); 8524 int[] arrayOut = new int[INPUTSIZE * 4]; 8525 Arrays.fill(arrayOut, (int) 42); 8526 out.copyTo(arrayOut); 8527 StringBuilder message = new StringBuilder(); 8528 boolean errorFound = false; 8529 for (int i = 0; i < INPUTSIZE; i++) { 8530 for (int j = 0; j < 4 ; j++) { 8531 // Extract the inputs. 8532 ArgumentsShortInt args = new ArgumentsShortInt(); 8533 args.inV = arrayInV[i * 4 + j]; 8534 // Figure out what the outputs should have been. 8535 CoreMathVerifier.computeConvert(args); 8536 // Validate the outputs. 8537 boolean valid = true; 8538 if (args.out != arrayOut[i * 4 + j]) { 8539 valid = false; 8540 } 8541 if (!valid) { 8542 if (!errorFound) { 8543 errorFound = true; 8544 message.append("Input inV: "); 8545 appendVariableToMessage(message, args.inV); 8546 message.append("\n"); 8547 message.append("Expected output out: "); 8548 appendVariableToMessage(message, args.out); 8549 message.append("\n"); 8550 message.append("Actual output out: "); 8551 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8552 if (args.out != arrayOut[i * 4 + j]) { 8553 message.append(" FAIL"); 8554 } 8555 message.append("\n"); 8556 message.append("Errors at"); 8557 } 8558 message.append(" ["); 8559 message.append(Integer.toString(i)); 8560 message.append(", "); 8561 message.append(Integer.toString(j)); 8562 message.append("]"); 8563 } 8564 } 8565 } 8566 assertFalse("Incorrect output for checkConvertShort4Int4" + 8567 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8568 } 8569 8570 public class ArgumentsUshortInt { 8571 public short inV; 8572 public int out; 8573 } 8574 8575 private void checkConvertUshort2Int2() { 8576 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2cf6eb50b7ac39eal, false, 16); 8577 try { 8578 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8579 script.forEach_testConvertInt2Ushort2Int2(inV, out); 8580 verifyResultsConvertUshort2Int2(inV, out, false); 8581 out.destroy(); 8582 } catch (Exception e) { 8583 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString()); 8584 } 8585 try { 8586 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8587 scriptRelaxed.forEach_testConvertInt2Ushort2Int2(inV, out); 8588 verifyResultsConvertUshort2Int2(inV, out, true); 8589 out.destroy(); 8590 } catch (Exception e) { 8591 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString()); 8592 } 8593 inV.destroy(); 8594 } 8595 8596 private void verifyResultsConvertUshort2Int2(Allocation inV, Allocation out, boolean relaxed) { 8597 short[] arrayInV = new short[INPUTSIZE * 2]; 8598 Arrays.fill(arrayInV, (short) 42); 8599 inV.copyTo(arrayInV); 8600 int[] arrayOut = new int[INPUTSIZE * 2]; 8601 Arrays.fill(arrayOut, (int) 42); 8602 out.copyTo(arrayOut); 8603 StringBuilder message = new StringBuilder(); 8604 boolean errorFound = false; 8605 for (int i = 0; i < INPUTSIZE; i++) { 8606 for (int j = 0; j < 2 ; j++) { 8607 // Extract the inputs. 8608 ArgumentsUshortInt args = new ArgumentsUshortInt(); 8609 args.inV = arrayInV[i * 2 + j]; 8610 // Figure out what the outputs should have been. 8611 CoreMathVerifier.computeConvert(args); 8612 // Validate the outputs. 8613 boolean valid = true; 8614 if (args.out != arrayOut[i * 2 + j]) { 8615 valid = false; 8616 } 8617 if (!valid) { 8618 if (!errorFound) { 8619 errorFound = true; 8620 message.append("Input inV: "); 8621 appendVariableToMessage(message, args.inV); 8622 message.append("\n"); 8623 message.append("Expected output out: "); 8624 appendVariableToMessage(message, args.out); 8625 message.append("\n"); 8626 message.append("Actual output out: "); 8627 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8628 if (args.out != arrayOut[i * 2 + j]) { 8629 message.append(" FAIL"); 8630 } 8631 message.append("\n"); 8632 message.append("Errors at"); 8633 } 8634 message.append(" ["); 8635 message.append(Integer.toString(i)); 8636 message.append(", "); 8637 message.append(Integer.toString(j)); 8638 message.append("]"); 8639 } 8640 } 8641 } 8642 assertFalse("Incorrect output for checkConvertUshort2Int2" + 8643 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8644 } 8645 8646 private void checkConvertUshort3Int3() { 8647 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x2cf6eb9001544a20l, false, 16); 8648 try { 8649 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8650 script.forEach_testConvertInt3Ushort3Int3(inV, out); 8651 verifyResultsConvertUshort3Int3(inV, out, false); 8652 out.destroy(); 8653 } catch (Exception e) { 8654 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString()); 8655 } 8656 try { 8657 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8658 scriptRelaxed.forEach_testConvertInt3Ushort3Int3(inV, out); 8659 verifyResultsConvertUshort3Int3(inV, out, true); 8660 out.destroy(); 8661 } catch (Exception e) { 8662 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString()); 8663 } 8664 inV.destroy(); 8665 } 8666 8667 private void verifyResultsConvertUshort3Int3(Allocation inV, Allocation out, boolean relaxed) { 8668 short[] arrayInV = new short[INPUTSIZE * 4]; 8669 Arrays.fill(arrayInV, (short) 42); 8670 inV.copyTo(arrayInV); 8671 int[] arrayOut = new int[INPUTSIZE * 4]; 8672 Arrays.fill(arrayOut, (int) 42); 8673 out.copyTo(arrayOut); 8674 StringBuilder message = new StringBuilder(); 8675 boolean errorFound = false; 8676 for (int i = 0; i < INPUTSIZE; i++) { 8677 for (int j = 0; j < 3 ; j++) { 8678 // Extract the inputs. 8679 ArgumentsUshortInt args = new ArgumentsUshortInt(); 8680 args.inV = arrayInV[i * 4 + j]; 8681 // Figure out what the outputs should have been. 8682 CoreMathVerifier.computeConvert(args); 8683 // Validate the outputs. 8684 boolean valid = true; 8685 if (args.out != arrayOut[i * 4 + j]) { 8686 valid = false; 8687 } 8688 if (!valid) { 8689 if (!errorFound) { 8690 errorFound = true; 8691 message.append("Input inV: "); 8692 appendVariableToMessage(message, args.inV); 8693 message.append("\n"); 8694 message.append("Expected output out: "); 8695 appendVariableToMessage(message, args.out); 8696 message.append("\n"); 8697 message.append("Actual output out: "); 8698 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8699 if (args.out != arrayOut[i * 4 + j]) { 8700 message.append(" FAIL"); 8701 } 8702 message.append("\n"); 8703 message.append("Errors at"); 8704 } 8705 message.append(" ["); 8706 message.append(Integer.toString(i)); 8707 message.append(", "); 8708 message.append(Integer.toString(j)); 8709 message.append("]"); 8710 } 8711 } 8712 } 8713 assertFalse("Incorrect output for checkConvertUshort3Int3" + 8714 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8715 } 8716 8717 private void checkConvertUshort4Int4() { 8718 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2cf6ebcf4afc5a56l, false, 16); 8719 try { 8720 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8721 script.forEach_testConvertInt4Ushort4Int4(inV, out); 8722 verifyResultsConvertUshort4Int4(inV, out, false); 8723 out.destroy(); 8724 } catch (Exception e) { 8725 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString()); 8726 } 8727 try { 8728 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8729 scriptRelaxed.forEach_testConvertInt4Ushort4Int4(inV, out); 8730 verifyResultsConvertUshort4Int4(inV, out, true); 8731 out.destroy(); 8732 } catch (Exception e) { 8733 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString()); 8734 } 8735 inV.destroy(); 8736 } 8737 8738 private void verifyResultsConvertUshort4Int4(Allocation inV, Allocation out, boolean relaxed) { 8739 short[] arrayInV = new short[INPUTSIZE * 4]; 8740 Arrays.fill(arrayInV, (short) 42); 8741 inV.copyTo(arrayInV); 8742 int[] arrayOut = new int[INPUTSIZE * 4]; 8743 Arrays.fill(arrayOut, (int) 42); 8744 out.copyTo(arrayOut); 8745 StringBuilder message = new StringBuilder(); 8746 boolean errorFound = false; 8747 for (int i = 0; i < INPUTSIZE; i++) { 8748 for (int j = 0; j < 4 ; j++) { 8749 // Extract the inputs. 8750 ArgumentsUshortInt args = new ArgumentsUshortInt(); 8751 args.inV = arrayInV[i * 4 + j]; 8752 // Figure out what the outputs should have been. 8753 CoreMathVerifier.computeConvert(args); 8754 // Validate the outputs. 8755 boolean valid = true; 8756 if (args.out != arrayOut[i * 4 + j]) { 8757 valid = false; 8758 } 8759 if (!valid) { 8760 if (!errorFound) { 8761 errorFound = true; 8762 message.append("Input inV: "); 8763 appendVariableToMessage(message, args.inV); 8764 message.append("\n"); 8765 message.append("Expected output out: "); 8766 appendVariableToMessage(message, args.out); 8767 message.append("\n"); 8768 message.append("Actual output out: "); 8769 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8770 if (args.out != arrayOut[i * 4 + j]) { 8771 message.append(" FAIL"); 8772 } 8773 message.append("\n"); 8774 message.append("Errors at"); 8775 } 8776 message.append(" ["); 8777 message.append(Integer.toString(i)); 8778 message.append(", "); 8779 message.append(Integer.toString(j)); 8780 message.append("]"); 8781 } 8782 } 8783 } 8784 assertFalse("Incorrect output for checkConvertUshort4Int4" + 8785 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8786 } 8787 8788 public class ArgumentsIntInt { 8789 public int inV; 8790 public int out; 8791 } 8792 8793 private void checkConvertInt2Int2() { 8794 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x501d84049a42354l, true, 31); 8795 try { 8796 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8797 script.forEach_testConvertInt2Int2Int2(inV, out); 8798 verifyResultsConvertInt2Int2(inV, out, false); 8799 out.destroy(); 8800 } catch (Exception e) { 8801 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString()); 8802 } 8803 try { 8804 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8805 scriptRelaxed.forEach_testConvertInt2Int2Int2(inV, out); 8806 verifyResultsConvertInt2Int2(inV, out, true); 8807 out.destroy(); 8808 } catch (Exception e) { 8809 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString()); 8810 } 8811 inV.destroy(); 8812 } 8813 8814 private void verifyResultsConvertInt2Int2(Allocation inV, Allocation out, boolean relaxed) { 8815 int[] arrayInV = new int[INPUTSIZE * 2]; 8816 Arrays.fill(arrayInV, (int) 42); 8817 inV.copyTo(arrayInV); 8818 int[] arrayOut = new int[INPUTSIZE * 2]; 8819 Arrays.fill(arrayOut, (int) 42); 8820 out.copyTo(arrayOut); 8821 StringBuilder message = new StringBuilder(); 8822 boolean errorFound = false; 8823 for (int i = 0; i < INPUTSIZE; i++) { 8824 for (int j = 0; j < 2 ; j++) { 8825 // Extract the inputs. 8826 ArgumentsIntInt args = new ArgumentsIntInt(); 8827 args.inV = arrayInV[i * 2 + j]; 8828 // Figure out what the outputs should have been. 8829 CoreMathVerifier.computeConvert(args); 8830 // Validate the outputs. 8831 boolean valid = true; 8832 if (args.out != arrayOut[i * 2 + j]) { 8833 valid = false; 8834 } 8835 if (!valid) { 8836 if (!errorFound) { 8837 errorFound = true; 8838 message.append("Input inV: "); 8839 appendVariableToMessage(message, args.inV); 8840 message.append("\n"); 8841 message.append("Expected output out: "); 8842 appendVariableToMessage(message, args.out); 8843 message.append("\n"); 8844 message.append("Actual output out: "); 8845 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8846 if (args.out != arrayOut[i * 2 + j]) { 8847 message.append(" FAIL"); 8848 } 8849 message.append("\n"); 8850 message.append("Errors at"); 8851 } 8852 message.append(" ["); 8853 message.append(Integer.toString(i)); 8854 message.append(", "); 8855 message.append(Integer.toString(j)); 8856 message.append("]"); 8857 } 8858 } 8859 } 8860 assertFalse("Incorrect output for checkConvertInt2Int2" + 8861 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8862 } 8863 8864 private void checkConvertInt3Int3() { 8865 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x501d87f934c338al, true, 31); 8866 try { 8867 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8868 script.forEach_testConvertInt3Int3Int3(inV, out); 8869 verifyResultsConvertInt3Int3(inV, out, false); 8870 out.destroy(); 8871 } catch (Exception e) { 8872 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString()); 8873 } 8874 try { 8875 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8876 scriptRelaxed.forEach_testConvertInt3Int3Int3(inV, out); 8877 verifyResultsConvertInt3Int3(inV, out, true); 8878 out.destroy(); 8879 } catch (Exception e) { 8880 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString()); 8881 } 8882 inV.destroy(); 8883 } 8884 8885 private void verifyResultsConvertInt3Int3(Allocation inV, Allocation out, boolean relaxed) { 8886 int[] arrayInV = new int[INPUTSIZE * 4]; 8887 Arrays.fill(arrayInV, (int) 42); 8888 inV.copyTo(arrayInV); 8889 int[] arrayOut = new int[INPUTSIZE * 4]; 8890 Arrays.fill(arrayOut, (int) 42); 8891 out.copyTo(arrayOut); 8892 StringBuilder message = new StringBuilder(); 8893 boolean errorFound = false; 8894 for (int i = 0; i < INPUTSIZE; i++) { 8895 for (int j = 0; j < 3 ; j++) { 8896 // Extract the inputs. 8897 ArgumentsIntInt args = new ArgumentsIntInt(); 8898 args.inV = arrayInV[i * 4 + j]; 8899 // Figure out what the outputs should have been. 8900 CoreMathVerifier.computeConvert(args); 8901 // Validate the outputs. 8902 boolean valid = true; 8903 if (args.out != arrayOut[i * 4 + j]) { 8904 valid = false; 8905 } 8906 if (!valid) { 8907 if (!errorFound) { 8908 errorFound = true; 8909 message.append("Input inV: "); 8910 appendVariableToMessage(message, args.inV); 8911 message.append("\n"); 8912 message.append("Expected output out: "); 8913 appendVariableToMessage(message, args.out); 8914 message.append("\n"); 8915 message.append("Actual output out: "); 8916 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8917 if (args.out != arrayOut[i * 4 + j]) { 8918 message.append(" FAIL"); 8919 } 8920 message.append("\n"); 8921 message.append("Errors at"); 8922 } 8923 message.append(" ["); 8924 message.append(Integer.toString(i)); 8925 message.append(", "); 8926 message.append(Integer.toString(j)); 8927 message.append("]"); 8928 } 8929 } 8930 } 8931 assertFalse("Incorrect output for checkConvertInt3Int3" + 8932 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8933 } 8934 8935 private void checkConvertInt4Int4() { 8936 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x501d8bedcf443c0l, true, 31); 8937 try { 8938 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8939 script.forEach_testConvertInt4Int4Int4(inV, out); 8940 verifyResultsConvertInt4Int4(inV, out, false); 8941 out.destroy(); 8942 } catch (Exception e) { 8943 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString()); 8944 } 8945 try { 8946 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8947 scriptRelaxed.forEach_testConvertInt4Int4Int4(inV, out); 8948 verifyResultsConvertInt4Int4(inV, out, true); 8949 out.destroy(); 8950 } catch (Exception e) { 8951 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString()); 8952 } 8953 inV.destroy(); 8954 } 8955 8956 private void verifyResultsConvertInt4Int4(Allocation inV, Allocation out, boolean relaxed) { 8957 int[] arrayInV = new int[INPUTSIZE * 4]; 8958 Arrays.fill(arrayInV, (int) 42); 8959 inV.copyTo(arrayInV); 8960 int[] arrayOut = new int[INPUTSIZE * 4]; 8961 Arrays.fill(arrayOut, (int) 42); 8962 out.copyTo(arrayOut); 8963 StringBuilder message = new StringBuilder(); 8964 boolean errorFound = false; 8965 for (int i = 0; i < INPUTSIZE; i++) { 8966 for (int j = 0; j < 4 ; j++) { 8967 // Extract the inputs. 8968 ArgumentsIntInt args = new ArgumentsIntInt(); 8969 args.inV = arrayInV[i * 4 + j]; 8970 // Figure out what the outputs should have been. 8971 CoreMathVerifier.computeConvert(args); 8972 // Validate the outputs. 8973 boolean valid = true; 8974 if (args.out != arrayOut[i * 4 + j]) { 8975 valid = false; 8976 } 8977 if (!valid) { 8978 if (!errorFound) { 8979 errorFound = true; 8980 message.append("Input inV: "); 8981 appendVariableToMessage(message, args.inV); 8982 message.append("\n"); 8983 message.append("Expected output out: "); 8984 appendVariableToMessage(message, args.out); 8985 message.append("\n"); 8986 message.append("Actual output out: "); 8987 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8988 if (args.out != arrayOut[i * 4 + j]) { 8989 message.append(" FAIL"); 8990 } 8991 message.append("\n"); 8992 message.append("Errors at"); 8993 } 8994 message.append(" ["); 8995 message.append(Integer.toString(i)); 8996 message.append(", "); 8997 message.append(Integer.toString(j)); 8998 message.append("]"); 8999 } 9000 } 9001 } 9002 assertFalse("Incorrect output for checkConvertInt4Int4" + 9003 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9004 } 9005 9006 public class ArgumentsUintInt { 9007 public int inV; 9008 public int out; 9009 } 9010 9011 private void checkConvertUint2Int2() { 9012 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x70899b043daccaddl, false, 31); 9013 try { 9014 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 9015 script.forEach_testConvertInt2Uint2Int2(inV, out); 9016 verifyResultsConvertUint2Int2(inV, out, false); 9017 out.destroy(); 9018 } catch (Exception e) { 9019 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString()); 9020 } 9021 try { 9022 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 9023 scriptRelaxed.forEach_testConvertInt2Uint2Int2(inV, out); 9024 verifyResultsConvertUint2Int2(inV, out, true); 9025 out.destroy(); 9026 } catch (Exception e) { 9027 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString()); 9028 } 9029 inV.destroy(); 9030 } 9031 9032 private void verifyResultsConvertUint2Int2(Allocation inV, Allocation out, boolean relaxed) { 9033 int[] arrayInV = new int[INPUTSIZE * 2]; 9034 Arrays.fill(arrayInV, (int) 42); 9035 inV.copyTo(arrayInV); 9036 int[] arrayOut = new int[INPUTSIZE * 2]; 9037 Arrays.fill(arrayOut, (int) 42); 9038 out.copyTo(arrayOut); 9039 StringBuilder message = new StringBuilder(); 9040 boolean errorFound = false; 9041 for (int i = 0; i < INPUTSIZE; i++) { 9042 for (int j = 0; j < 2 ; j++) { 9043 // Extract the inputs. 9044 ArgumentsUintInt args = new ArgumentsUintInt(); 9045 args.inV = arrayInV[i * 2 + j]; 9046 // Figure out what the outputs should have been. 9047 CoreMathVerifier.computeConvert(args); 9048 // Validate the outputs. 9049 boolean valid = true; 9050 if (args.out != arrayOut[i * 2 + j]) { 9051 valid = false; 9052 } 9053 if (!valid) { 9054 if (!errorFound) { 9055 errorFound = true; 9056 message.append("Input inV: "); 9057 appendVariableToMessage(message, args.inV); 9058 message.append("\n"); 9059 message.append("Expected output out: "); 9060 appendVariableToMessage(message, args.out); 9061 message.append("\n"); 9062 message.append("Actual output out: "); 9063 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9064 if (args.out != arrayOut[i * 2 + j]) { 9065 message.append(" FAIL"); 9066 } 9067 message.append("\n"); 9068 message.append("Errors at"); 9069 } 9070 message.append(" ["); 9071 message.append(Integer.toString(i)); 9072 message.append(", "); 9073 message.append(Integer.toString(j)); 9074 message.append("]"); 9075 } 9076 } 9077 } 9078 assertFalse("Incorrect output for checkConvertUint2Int2" + 9079 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9080 } 9081 9082 private void checkConvertUint3Int3() { 9083 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x70899b438754db13l, false, 31); 9084 try { 9085 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 9086 script.forEach_testConvertInt3Uint3Int3(inV, out); 9087 verifyResultsConvertUint3Int3(inV, out, false); 9088 out.destroy(); 9089 } catch (Exception e) { 9090 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString()); 9091 } 9092 try { 9093 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 9094 scriptRelaxed.forEach_testConvertInt3Uint3Int3(inV, out); 9095 verifyResultsConvertUint3Int3(inV, out, true); 9096 out.destroy(); 9097 } catch (Exception e) { 9098 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString()); 9099 } 9100 inV.destroy(); 9101 } 9102 9103 private void verifyResultsConvertUint3Int3(Allocation inV, Allocation out, boolean relaxed) { 9104 int[] arrayInV = new int[INPUTSIZE * 4]; 9105 Arrays.fill(arrayInV, (int) 42); 9106 inV.copyTo(arrayInV); 9107 int[] arrayOut = new int[INPUTSIZE * 4]; 9108 Arrays.fill(arrayOut, (int) 42); 9109 out.copyTo(arrayOut); 9110 StringBuilder message = new StringBuilder(); 9111 boolean errorFound = false; 9112 for (int i = 0; i < INPUTSIZE; i++) { 9113 for (int j = 0; j < 3 ; j++) { 9114 // Extract the inputs. 9115 ArgumentsUintInt args = new ArgumentsUintInt(); 9116 args.inV = arrayInV[i * 4 + j]; 9117 // Figure out what the outputs should have been. 9118 CoreMathVerifier.computeConvert(args); 9119 // Validate the outputs. 9120 boolean valid = true; 9121 if (args.out != arrayOut[i * 4 + j]) { 9122 valid = false; 9123 } 9124 if (!valid) { 9125 if (!errorFound) { 9126 errorFound = true; 9127 message.append("Input inV: "); 9128 appendVariableToMessage(message, args.inV); 9129 message.append("\n"); 9130 message.append("Expected output out: "); 9131 appendVariableToMessage(message, args.out); 9132 message.append("\n"); 9133 message.append("Actual output out: "); 9134 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9135 if (args.out != arrayOut[i * 4 + j]) { 9136 message.append(" FAIL"); 9137 } 9138 message.append("\n"); 9139 message.append("Errors at"); 9140 } 9141 message.append(" ["); 9142 message.append(Integer.toString(i)); 9143 message.append(", "); 9144 message.append(Integer.toString(j)); 9145 message.append("]"); 9146 } 9147 } 9148 } 9149 assertFalse("Incorrect output for checkConvertUint3Int3" + 9150 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9151 } 9152 9153 private void checkConvertUint4Int4() { 9154 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x70899b82d0fceb49l, false, 31); 9155 try { 9156 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 9157 script.forEach_testConvertInt4Uint4Int4(inV, out); 9158 verifyResultsConvertUint4Int4(inV, out, false); 9159 out.destroy(); 9160 } catch (Exception e) { 9161 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString()); 9162 } 9163 try { 9164 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 9165 scriptRelaxed.forEach_testConvertInt4Uint4Int4(inV, out); 9166 verifyResultsConvertUint4Int4(inV, out, true); 9167 out.destroy(); 9168 } catch (Exception e) { 9169 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString()); 9170 } 9171 inV.destroy(); 9172 } 9173 9174 private void verifyResultsConvertUint4Int4(Allocation inV, Allocation out, boolean relaxed) { 9175 int[] arrayInV = new int[INPUTSIZE * 4]; 9176 Arrays.fill(arrayInV, (int) 42); 9177 inV.copyTo(arrayInV); 9178 int[] arrayOut = new int[INPUTSIZE * 4]; 9179 Arrays.fill(arrayOut, (int) 42); 9180 out.copyTo(arrayOut); 9181 StringBuilder message = new StringBuilder(); 9182 boolean errorFound = false; 9183 for (int i = 0; i < INPUTSIZE; i++) { 9184 for (int j = 0; j < 4 ; j++) { 9185 // Extract the inputs. 9186 ArgumentsUintInt args = new ArgumentsUintInt(); 9187 args.inV = arrayInV[i * 4 + j]; 9188 // Figure out what the outputs should have been. 9189 CoreMathVerifier.computeConvert(args); 9190 // Validate the outputs. 9191 boolean valid = true; 9192 if (args.out != arrayOut[i * 4 + j]) { 9193 valid = false; 9194 } 9195 if (!valid) { 9196 if (!errorFound) { 9197 errorFound = true; 9198 message.append("Input inV: "); 9199 appendVariableToMessage(message, args.inV); 9200 message.append("\n"); 9201 message.append("Expected output out: "); 9202 appendVariableToMessage(message, args.out); 9203 message.append("\n"); 9204 message.append("Actual output out: "); 9205 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9206 if (args.out != arrayOut[i * 4 + j]) { 9207 message.append(" FAIL"); 9208 } 9209 message.append("\n"); 9210 message.append("Errors at"); 9211 } 9212 message.append(" ["); 9213 message.append(Integer.toString(i)); 9214 message.append(", "); 9215 message.append(Integer.toString(j)); 9216 message.append("]"); 9217 } 9218 } 9219 } 9220 assertFalse("Incorrect output for checkConvertUint4Int4" + 9221 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9222 } 9223 9224 public class ArgumentsFloatUint { 9225 public float inV; 9226 public int out; 9227 } 9228 9229 private void checkConvertFloat2Uint2() { 9230 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb6cd424dca22l, 0.0000000000000000000e+00, 4.2949670400000000000e+09); 9231 try { 9232 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9233 script.forEach_testConvertUint2Float2Uint2(inV, out); 9234 verifyResultsConvertFloat2Uint2(inV, out, false); 9235 out.destroy(); 9236 } catch (Exception e) { 9237 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString()); 9238 } 9239 try { 9240 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9241 scriptRelaxed.forEach_testConvertUint2Float2Uint2(inV, out); 9242 verifyResultsConvertFloat2Uint2(inV, out, true); 9243 out.destroy(); 9244 } catch (Exception e) { 9245 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString()); 9246 } 9247 inV.destroy(); 9248 } 9249 9250 private void verifyResultsConvertFloat2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9251 float[] arrayInV = new float[INPUTSIZE * 2]; 9252 Arrays.fill(arrayInV, (float) 42); 9253 inV.copyTo(arrayInV); 9254 int[] arrayOut = new int[INPUTSIZE * 2]; 9255 Arrays.fill(arrayOut, (int) 42); 9256 out.copyTo(arrayOut); 9257 StringBuilder message = new StringBuilder(); 9258 boolean errorFound = false; 9259 for (int i = 0; i < INPUTSIZE; i++) { 9260 for (int j = 0; j < 2 ; j++) { 9261 // Extract the inputs. 9262 ArgumentsFloatUint args = new ArgumentsFloatUint(); 9263 args.inV = arrayInV[i * 2 + j]; 9264 // Figure out what the outputs should have been. 9265 CoreMathVerifier.computeConvert(args); 9266 // Validate the outputs. 9267 boolean valid = true; 9268 if (args.out != arrayOut[i * 2 + j]) { 9269 valid = false; 9270 } 9271 if (!valid) { 9272 if (!errorFound) { 9273 errorFound = true; 9274 message.append("Input inV: "); 9275 appendVariableToMessage(message, args.inV); 9276 message.append("\n"); 9277 message.append("Expected output out: "); 9278 appendVariableToMessage(message, args.out); 9279 message.append("\n"); 9280 message.append("Actual output out: "); 9281 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9282 if (args.out != arrayOut[i * 2 + j]) { 9283 message.append(" FAIL"); 9284 } 9285 message.append("\n"); 9286 message.append("Errors at"); 9287 } 9288 message.append(" ["); 9289 message.append(Integer.toString(i)); 9290 message.append(", "); 9291 message.append(Integer.toString(j)); 9292 message.append("]"); 9293 } 9294 } 9295 } 9296 assertFalse("Incorrect output for checkConvertFloat2Uint2" + 9297 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9298 } 9299 9300 private void checkConvertFloat3Uint3() { 9301 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cc16ea1558f16l, 0.0000000000000000000e+00, 4.2949670400000000000e+09); 9302 try { 9303 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9304 script.forEach_testConvertUint3Float3Uint3(inV, out); 9305 verifyResultsConvertFloat3Uint3(inV, out, false); 9306 out.destroy(); 9307 } catch (Exception e) { 9308 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString()); 9309 } 9310 try { 9311 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9312 scriptRelaxed.forEach_testConvertUint3Float3Uint3(inV, out); 9313 verifyResultsConvertFloat3Uint3(inV, out, true); 9314 out.destroy(); 9315 } catch (Exception e) { 9316 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString()); 9317 } 9318 inV.destroy(); 9319 } 9320 9321 private void verifyResultsConvertFloat3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9322 float[] arrayInV = new float[INPUTSIZE * 4]; 9323 Arrays.fill(arrayInV, (float) 42); 9324 inV.copyTo(arrayInV); 9325 int[] arrayOut = new int[INPUTSIZE * 4]; 9326 Arrays.fill(arrayOut, (int) 42); 9327 out.copyTo(arrayOut); 9328 StringBuilder message = new StringBuilder(); 9329 boolean errorFound = false; 9330 for (int i = 0; i < INPUTSIZE; i++) { 9331 for (int j = 0; j < 3 ; j++) { 9332 // Extract the inputs. 9333 ArgumentsFloatUint args = new ArgumentsFloatUint(); 9334 args.inV = arrayInV[i * 4 + j]; 9335 // Figure out what the outputs should have been. 9336 CoreMathVerifier.computeConvert(args); 9337 // Validate the outputs. 9338 boolean valid = true; 9339 if (args.out != arrayOut[i * 4 + j]) { 9340 valid = false; 9341 } 9342 if (!valid) { 9343 if (!errorFound) { 9344 errorFound = true; 9345 message.append("Input inV: "); 9346 appendVariableToMessage(message, args.inV); 9347 message.append("\n"); 9348 message.append("Expected output out: "); 9349 appendVariableToMessage(message, args.out); 9350 message.append("\n"); 9351 message.append("Actual output out: "); 9352 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9353 if (args.out != arrayOut[i * 4 + j]) { 9354 message.append(" FAIL"); 9355 } 9356 message.append("\n"); 9357 message.append("Errors at"); 9358 } 9359 message.append(" ["); 9360 message.append(Integer.toString(i)); 9361 message.append(", "); 9362 message.append(Integer.toString(j)); 9363 message.append("]"); 9364 } 9365 } 9366 } 9367 assertFalse("Incorrect output for checkConvertFloat3Uint3" + 9368 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9369 } 9370 9371 private void checkConvertFloat4Uint4() { 9372 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239ccc10005d540al, 0.0000000000000000000e+00, 4.2949670400000000000e+09); 9373 try { 9374 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9375 script.forEach_testConvertUint4Float4Uint4(inV, out); 9376 verifyResultsConvertFloat4Uint4(inV, out, false); 9377 out.destroy(); 9378 } catch (Exception e) { 9379 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString()); 9380 } 9381 try { 9382 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9383 scriptRelaxed.forEach_testConvertUint4Float4Uint4(inV, out); 9384 verifyResultsConvertFloat4Uint4(inV, out, true); 9385 out.destroy(); 9386 } catch (Exception e) { 9387 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString()); 9388 } 9389 inV.destroy(); 9390 } 9391 9392 private void verifyResultsConvertFloat4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9393 float[] arrayInV = new float[INPUTSIZE * 4]; 9394 Arrays.fill(arrayInV, (float) 42); 9395 inV.copyTo(arrayInV); 9396 int[] arrayOut = new int[INPUTSIZE * 4]; 9397 Arrays.fill(arrayOut, (int) 42); 9398 out.copyTo(arrayOut); 9399 StringBuilder message = new StringBuilder(); 9400 boolean errorFound = false; 9401 for (int i = 0; i < INPUTSIZE; i++) { 9402 for (int j = 0; j < 4 ; j++) { 9403 // Extract the inputs. 9404 ArgumentsFloatUint args = new ArgumentsFloatUint(); 9405 args.inV = arrayInV[i * 4 + j]; 9406 // Figure out what the outputs should have been. 9407 CoreMathVerifier.computeConvert(args); 9408 // Validate the outputs. 9409 boolean valid = true; 9410 if (args.out != arrayOut[i * 4 + j]) { 9411 valid = false; 9412 } 9413 if (!valid) { 9414 if (!errorFound) { 9415 errorFound = true; 9416 message.append("Input inV: "); 9417 appendVariableToMessage(message, args.inV); 9418 message.append("\n"); 9419 message.append("Expected output out: "); 9420 appendVariableToMessage(message, args.out); 9421 message.append("\n"); 9422 message.append("Actual output out: "); 9423 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9424 if (args.out != arrayOut[i * 4 + j]) { 9425 message.append(" FAIL"); 9426 } 9427 message.append("\n"); 9428 message.append("Errors at"); 9429 } 9430 message.append(" ["); 9431 message.append(Integer.toString(i)); 9432 message.append(", "); 9433 message.append(Integer.toString(j)); 9434 message.append("]"); 9435 } 9436 } 9437 } 9438 assertFalse("Incorrect output for checkConvertFloat4Uint4" + 9439 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9440 } 9441 9442 public class ArgumentsCharUint { 9443 public byte inV; 9444 public int out; 9445 } 9446 9447 private void checkConvertChar2Uint2() { 9448 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8618beceddda162l, false, 7); 9449 try { 9450 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9451 script.forEach_testConvertUint2Char2Uint2(inV, out); 9452 verifyResultsConvertChar2Uint2(inV, out, false); 9453 out.destroy(); 9454 } catch (Exception e) { 9455 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString()); 9456 } 9457 try { 9458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9459 scriptRelaxed.forEach_testConvertUint2Char2Uint2(inV, out); 9460 verifyResultsConvertChar2Uint2(inV, out, true); 9461 out.destroy(); 9462 } catch (Exception e) { 9463 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString()); 9464 } 9465 inV.destroy(); 9466 } 9467 9468 private void verifyResultsConvertChar2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9469 byte[] arrayInV = new byte[INPUTSIZE * 2]; 9470 Arrays.fill(arrayInV, (byte) 42); 9471 inV.copyTo(arrayInV); 9472 int[] arrayOut = new int[INPUTSIZE * 2]; 9473 Arrays.fill(arrayOut, (int) 42); 9474 out.copyTo(arrayOut); 9475 StringBuilder message = new StringBuilder(); 9476 boolean errorFound = false; 9477 for (int i = 0; i < INPUTSIZE; i++) { 9478 for (int j = 0; j < 2 ; j++) { 9479 // Extract the inputs. 9480 ArgumentsCharUint args = new ArgumentsCharUint(); 9481 args.inV = arrayInV[i * 2 + j]; 9482 // Figure out what the outputs should have been. 9483 CoreMathVerifier.computeConvert(args); 9484 // Validate the outputs. 9485 boolean valid = true; 9486 if (args.out != arrayOut[i * 2 + j]) { 9487 valid = false; 9488 } 9489 if (!valid) { 9490 if (!errorFound) { 9491 errorFound = true; 9492 message.append("Input inV: "); 9493 appendVariableToMessage(message, args.inV); 9494 message.append("\n"); 9495 message.append("Expected output out: "); 9496 appendVariableToMessage(message, args.out); 9497 message.append("\n"); 9498 message.append("Actual output out: "); 9499 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9500 if (args.out != arrayOut[i * 2 + j]) { 9501 message.append(" FAIL"); 9502 } 9503 message.append("\n"); 9504 message.append("Errors at"); 9505 } 9506 message.append(" ["); 9507 message.append(Integer.toString(i)); 9508 message.append(", "); 9509 message.append(Integer.toString(j)); 9510 message.append("]"); 9511 } 9512 } 9513 } 9514 assertFalse("Incorrect output for checkConvertChar2Uint2" + 9515 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9516 } 9517 9518 private void checkConvertChar3Uint3() { 9519 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861968e4ce56656l, false, 7); 9520 try { 9521 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9522 script.forEach_testConvertUint3Char3Uint3(inV, out); 9523 verifyResultsConvertChar3Uint3(inV, out, false); 9524 out.destroy(); 9525 } catch (Exception e) { 9526 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString()); 9527 } 9528 try { 9529 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9530 scriptRelaxed.forEach_testConvertUint3Char3Uint3(inV, out); 9531 verifyResultsConvertChar3Uint3(inV, out, true); 9532 out.destroy(); 9533 } catch (Exception e) { 9534 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString()); 9535 } 9536 inV.destroy(); 9537 } 9538 9539 private void verifyResultsConvertChar3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9540 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9541 Arrays.fill(arrayInV, (byte) 42); 9542 inV.copyTo(arrayInV); 9543 int[] arrayOut = new int[INPUTSIZE * 4]; 9544 Arrays.fill(arrayOut, (int) 42); 9545 out.copyTo(arrayOut); 9546 StringBuilder message = new StringBuilder(); 9547 boolean errorFound = false; 9548 for (int i = 0; i < INPUTSIZE; i++) { 9549 for (int j = 0; j < 3 ; j++) { 9550 // Extract the inputs. 9551 ArgumentsCharUint args = new ArgumentsCharUint(); 9552 args.inV = arrayInV[i * 4 + j]; 9553 // Figure out what the outputs should have been. 9554 CoreMathVerifier.computeConvert(args); 9555 // Validate the outputs. 9556 boolean valid = true; 9557 if (args.out != arrayOut[i * 4 + j]) { 9558 valid = false; 9559 } 9560 if (!valid) { 9561 if (!errorFound) { 9562 errorFound = true; 9563 message.append("Input inV: "); 9564 appendVariableToMessage(message, args.inV); 9565 message.append("\n"); 9566 message.append("Expected output out: "); 9567 appendVariableToMessage(message, args.out); 9568 message.append("\n"); 9569 message.append("Actual output out: "); 9570 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9571 if (args.out != arrayOut[i * 4 + j]) { 9572 message.append(" FAIL"); 9573 } 9574 message.append("\n"); 9575 message.append("Errors at"); 9576 } 9577 message.append(" ["); 9578 message.append(Integer.toString(i)); 9579 message.append(", "); 9580 message.append(Integer.toString(j)); 9581 message.append("]"); 9582 } 9583 } 9584 } 9585 assertFalse("Incorrect output for checkConvertChar3Uint3" + 9586 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9587 } 9588 9589 private void checkConvertChar4Uint4() { 9590 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd861a12fabed2b4al, false, 7); 9591 try { 9592 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9593 script.forEach_testConvertUint4Char4Uint4(inV, out); 9594 verifyResultsConvertChar4Uint4(inV, out, false); 9595 out.destroy(); 9596 } catch (Exception e) { 9597 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString()); 9598 } 9599 try { 9600 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9601 scriptRelaxed.forEach_testConvertUint4Char4Uint4(inV, out); 9602 verifyResultsConvertChar4Uint4(inV, out, true); 9603 out.destroy(); 9604 } catch (Exception e) { 9605 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString()); 9606 } 9607 inV.destroy(); 9608 } 9609 9610 private void verifyResultsConvertChar4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9611 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9612 Arrays.fill(arrayInV, (byte) 42); 9613 inV.copyTo(arrayInV); 9614 int[] arrayOut = new int[INPUTSIZE * 4]; 9615 Arrays.fill(arrayOut, (int) 42); 9616 out.copyTo(arrayOut); 9617 StringBuilder message = new StringBuilder(); 9618 boolean errorFound = false; 9619 for (int i = 0; i < INPUTSIZE; i++) { 9620 for (int j = 0; j < 4 ; j++) { 9621 // Extract the inputs. 9622 ArgumentsCharUint args = new ArgumentsCharUint(); 9623 args.inV = arrayInV[i * 4 + j]; 9624 // Figure out what the outputs should have been. 9625 CoreMathVerifier.computeConvert(args); 9626 // Validate the outputs. 9627 boolean valid = true; 9628 if (args.out != arrayOut[i * 4 + j]) { 9629 valid = false; 9630 } 9631 if (!valid) { 9632 if (!errorFound) { 9633 errorFound = true; 9634 message.append("Input inV: "); 9635 appendVariableToMessage(message, args.inV); 9636 message.append("\n"); 9637 message.append("Expected output out: "); 9638 appendVariableToMessage(message, args.out); 9639 message.append("\n"); 9640 message.append("Actual output out: "); 9641 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9642 if (args.out != arrayOut[i * 4 + j]) { 9643 message.append(" FAIL"); 9644 } 9645 message.append("\n"); 9646 message.append("Errors at"); 9647 } 9648 message.append(" ["); 9649 message.append(Integer.toString(i)); 9650 message.append(", "); 9651 message.append(Integer.toString(j)); 9652 message.append("]"); 9653 } 9654 } 9655 } 9656 assertFalse("Incorrect output for checkConvertChar4Uint4" + 9657 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9658 } 9659 9660 public class ArgumentsUcharUint { 9661 public byte inV; 9662 public int out; 9663 } 9664 9665 private void checkConvertUchar2Uint2() { 9666 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef453a805fade3l, false, 8); 9667 try { 9668 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9669 script.forEach_testConvertUint2Uchar2Uint2(inV, out); 9670 verifyResultsConvertUchar2Uint2(inV, out, false); 9671 out.destroy(); 9672 } catch (Exception e) { 9673 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString()); 9674 } 9675 try { 9676 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9677 scriptRelaxed.forEach_testConvertUint2Uchar2Uint2(inV, out); 9678 verifyResultsConvertUchar2Uint2(inV, out, true); 9679 out.destroy(); 9680 } catch (Exception e) { 9681 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString()); 9682 } 9683 inV.destroy(); 9684 } 9685 9686 private void verifyResultsConvertUchar2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9687 byte[] arrayInV = new byte[INPUTSIZE * 2]; 9688 Arrays.fill(arrayInV, (byte) 42); 9689 inV.copyTo(arrayInV); 9690 int[] arrayOut = new int[INPUTSIZE * 2]; 9691 Arrays.fill(arrayOut, (int) 42); 9692 out.copyTo(arrayOut); 9693 StringBuilder message = new StringBuilder(); 9694 boolean errorFound = false; 9695 for (int i = 0; i < INPUTSIZE; i++) { 9696 for (int j = 0; j < 2 ; j++) { 9697 // Extract the inputs. 9698 ArgumentsUcharUint args = new ArgumentsUcharUint(); 9699 args.inV = arrayInV[i * 2 + j]; 9700 // Figure out what the outputs should have been. 9701 CoreMathVerifier.computeConvert(args); 9702 // Validate the outputs. 9703 boolean valid = true; 9704 if (args.out != arrayOut[i * 2 + j]) { 9705 valid = false; 9706 } 9707 if (!valid) { 9708 if (!errorFound) { 9709 errorFound = true; 9710 message.append("Input inV: "); 9711 appendVariableToMessage(message, args.inV); 9712 message.append("\n"); 9713 message.append("Expected output out: "); 9714 appendVariableToMessage(message, args.out); 9715 message.append("\n"); 9716 message.append("Actual output out: "); 9717 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9718 if (args.out != arrayOut[i * 2 + j]) { 9719 message.append(" FAIL"); 9720 } 9721 message.append("\n"); 9722 message.append("Errors at"); 9723 } 9724 message.append(" ["); 9725 message.append(Integer.toString(i)); 9726 message.append(", "); 9727 message.append(Integer.toString(j)); 9728 message.append("]"); 9729 } 9730 } 9731 } 9732 assertFalse("Incorrect output for checkConvertUchar2Uint2" + 9733 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9734 } 9735 9736 private void checkConvertUchar3Uint3() { 9737 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4fdbdf6772d7l, false, 8); 9738 try { 9739 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9740 script.forEach_testConvertUint3Uchar3Uint3(inV, out); 9741 verifyResultsConvertUchar3Uint3(inV, out, false); 9742 out.destroy(); 9743 } catch (Exception e) { 9744 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString()); 9745 } 9746 try { 9747 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9748 scriptRelaxed.forEach_testConvertUint3Uchar3Uint3(inV, out); 9749 verifyResultsConvertUchar3Uint3(inV, out, true); 9750 out.destroy(); 9751 } catch (Exception e) { 9752 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString()); 9753 } 9754 inV.destroy(); 9755 } 9756 9757 private void verifyResultsConvertUchar3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9758 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9759 Arrays.fill(arrayInV, (byte) 42); 9760 inV.copyTo(arrayInV); 9761 int[] arrayOut = new int[INPUTSIZE * 4]; 9762 Arrays.fill(arrayOut, (int) 42); 9763 out.copyTo(arrayOut); 9764 StringBuilder message = new StringBuilder(); 9765 boolean errorFound = false; 9766 for (int i = 0; i < INPUTSIZE; i++) { 9767 for (int j = 0; j < 3 ; j++) { 9768 // Extract the inputs. 9769 ArgumentsUcharUint args = new ArgumentsUcharUint(); 9770 args.inV = arrayInV[i * 4 + j]; 9771 // Figure out what the outputs should have been. 9772 CoreMathVerifier.computeConvert(args); 9773 // Validate the outputs. 9774 boolean valid = true; 9775 if (args.out != arrayOut[i * 4 + j]) { 9776 valid = false; 9777 } 9778 if (!valid) { 9779 if (!errorFound) { 9780 errorFound = true; 9781 message.append("Input inV: "); 9782 appendVariableToMessage(message, args.inV); 9783 message.append("\n"); 9784 message.append("Expected output out: "); 9785 appendVariableToMessage(message, args.out); 9786 message.append("\n"); 9787 message.append("Actual output out: "); 9788 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9789 if (args.out != arrayOut[i * 4 + j]) { 9790 message.append(" FAIL"); 9791 } 9792 message.append("\n"); 9793 message.append("Errors at"); 9794 } 9795 message.append(" ["); 9796 message.append(Integer.toString(i)); 9797 message.append(", "); 9798 message.append(Integer.toString(j)); 9799 message.append("]"); 9800 } 9801 } 9802 } 9803 assertFalse("Incorrect output for checkConvertUchar3Uint3" + 9804 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9805 } 9806 9807 private void checkConvertUchar4Uint4() { 9808 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef5a7d3e6f37cbl, false, 8); 9809 try { 9810 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9811 script.forEach_testConvertUint4Uchar4Uint4(inV, out); 9812 verifyResultsConvertUchar4Uint4(inV, out, false); 9813 out.destroy(); 9814 } catch (Exception e) { 9815 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString()); 9816 } 9817 try { 9818 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9819 scriptRelaxed.forEach_testConvertUint4Uchar4Uint4(inV, out); 9820 verifyResultsConvertUchar4Uint4(inV, out, true); 9821 out.destroy(); 9822 } catch (Exception e) { 9823 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString()); 9824 } 9825 inV.destroy(); 9826 } 9827 9828 private void verifyResultsConvertUchar4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9829 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9830 Arrays.fill(arrayInV, (byte) 42); 9831 inV.copyTo(arrayInV); 9832 int[] arrayOut = new int[INPUTSIZE * 4]; 9833 Arrays.fill(arrayOut, (int) 42); 9834 out.copyTo(arrayOut); 9835 StringBuilder message = new StringBuilder(); 9836 boolean errorFound = false; 9837 for (int i = 0; i < INPUTSIZE; i++) { 9838 for (int j = 0; j < 4 ; j++) { 9839 // Extract the inputs. 9840 ArgumentsUcharUint args = new ArgumentsUcharUint(); 9841 args.inV = arrayInV[i * 4 + j]; 9842 // Figure out what the outputs should have been. 9843 CoreMathVerifier.computeConvert(args); 9844 // Validate the outputs. 9845 boolean valid = true; 9846 if (args.out != arrayOut[i * 4 + j]) { 9847 valid = false; 9848 } 9849 if (!valid) { 9850 if (!errorFound) { 9851 errorFound = true; 9852 message.append("Input inV: "); 9853 appendVariableToMessage(message, args.inV); 9854 message.append("\n"); 9855 message.append("Expected output out: "); 9856 appendVariableToMessage(message, args.out); 9857 message.append("\n"); 9858 message.append("Actual output out: "); 9859 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9860 if (args.out != arrayOut[i * 4 + j]) { 9861 message.append(" FAIL"); 9862 } 9863 message.append("\n"); 9864 message.append("Errors at"); 9865 } 9866 message.append(" ["); 9867 message.append(Integer.toString(i)); 9868 message.append(", "); 9869 message.append(Integer.toString(j)); 9870 message.append("]"); 9871 } 9872 } 9873 } 9874 assertFalse("Incorrect output for checkConvertUchar4Uint4" + 9875 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9876 } 9877 9878 public class ArgumentsShortUint { 9879 public short inV; 9880 public int out; 9881 } 9882 9883 private void checkConvertShort2Uint2() { 9884 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab69772e9b3c26l, false, 15); 9885 try { 9886 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9887 script.forEach_testConvertUint2Short2Uint2(inV, out); 9888 verifyResultsConvertShort2Uint2(inV, out, false); 9889 out.destroy(); 9890 } catch (Exception e) { 9891 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString()); 9892 } 9893 try { 9894 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9895 scriptRelaxed.forEach_testConvertUint2Short2Uint2(inV, out); 9896 verifyResultsConvertShort2Uint2(inV, out, true); 9897 out.destroy(); 9898 } catch (Exception e) { 9899 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString()); 9900 } 9901 inV.destroy(); 9902 } 9903 9904 private void verifyResultsConvertShort2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9905 short[] arrayInV = new short[INPUTSIZE * 2]; 9906 Arrays.fill(arrayInV, (short) 42); 9907 inV.copyTo(arrayInV); 9908 int[] arrayOut = new int[INPUTSIZE * 2]; 9909 Arrays.fill(arrayOut, (int) 42); 9910 out.copyTo(arrayOut); 9911 StringBuilder message = new StringBuilder(); 9912 boolean errorFound = false; 9913 for (int i = 0; i < INPUTSIZE; i++) { 9914 for (int j = 0; j < 2 ; j++) { 9915 // Extract the inputs. 9916 ArgumentsShortUint args = new ArgumentsShortUint(); 9917 args.inV = arrayInV[i * 2 + j]; 9918 // Figure out what the outputs should have been. 9919 CoreMathVerifier.computeConvert(args); 9920 // Validate the outputs. 9921 boolean valid = true; 9922 if (args.out != arrayOut[i * 2 + j]) { 9923 valid = false; 9924 } 9925 if (!valid) { 9926 if (!errorFound) { 9927 errorFound = true; 9928 message.append("Input inV: "); 9929 appendVariableToMessage(message, args.inV); 9930 message.append("\n"); 9931 message.append("Expected output out: "); 9932 appendVariableToMessage(message, args.out); 9933 message.append("\n"); 9934 message.append("Actual output out: "); 9935 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9936 if (args.out != arrayOut[i * 2 + j]) { 9937 message.append(" FAIL"); 9938 } 9939 message.append("\n"); 9940 message.append("Errors at"); 9941 } 9942 message.append(" ["); 9943 message.append(Integer.toString(i)); 9944 message.append(", "); 9945 message.append(Integer.toString(j)); 9946 message.append("]"); 9947 } 9948 } 9949 } 9950 assertFalse("Incorrect output for checkConvertShort2Uint2" + 9951 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9952 } 9953 9954 private void checkConvertShort3Uint3() { 9955 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab74188da3011al, false, 15); 9956 try { 9957 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9958 script.forEach_testConvertUint3Short3Uint3(inV, out); 9959 verifyResultsConvertShort3Uint3(inV, out, false); 9960 out.destroy(); 9961 } catch (Exception e) { 9962 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString()); 9963 } 9964 try { 9965 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9966 scriptRelaxed.forEach_testConvertUint3Short3Uint3(inV, out); 9967 verifyResultsConvertShort3Uint3(inV, out, true); 9968 out.destroy(); 9969 } catch (Exception e) { 9970 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString()); 9971 } 9972 inV.destroy(); 9973 } 9974 9975 private void verifyResultsConvertShort3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9976 short[] arrayInV = new short[INPUTSIZE * 4]; 9977 Arrays.fill(arrayInV, (short) 42); 9978 inV.copyTo(arrayInV); 9979 int[] arrayOut = new int[INPUTSIZE * 4]; 9980 Arrays.fill(arrayOut, (int) 42); 9981 out.copyTo(arrayOut); 9982 StringBuilder message = new StringBuilder(); 9983 boolean errorFound = false; 9984 for (int i = 0; i < INPUTSIZE; i++) { 9985 for (int j = 0; j < 3 ; j++) { 9986 // Extract the inputs. 9987 ArgumentsShortUint args = new ArgumentsShortUint(); 9988 args.inV = arrayInV[i * 4 + j]; 9989 // Figure out what the outputs should have been. 9990 CoreMathVerifier.computeConvert(args); 9991 // Validate the outputs. 9992 boolean valid = true; 9993 if (args.out != arrayOut[i * 4 + j]) { 9994 valid = false; 9995 } 9996 if (!valid) { 9997 if (!errorFound) { 9998 errorFound = true; 9999 message.append("Input inV: "); 10000 appendVariableToMessage(message, args.inV); 10001 message.append("\n"); 10002 message.append("Expected output out: "); 10003 appendVariableToMessage(message, args.out); 10004 message.append("\n"); 10005 message.append("Actual output out: "); 10006 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10007 if (args.out != arrayOut[i * 4 + j]) { 10008 message.append(" FAIL"); 10009 } 10010 message.append("\n"); 10011 message.append("Errors at"); 10012 } 10013 message.append(" ["); 10014 message.append(Integer.toString(i)); 10015 message.append(", "); 10016 message.append(Integer.toString(j)); 10017 message.append("]"); 10018 } 10019 } 10020 } 10021 assertFalse("Incorrect output for checkConvertShort3Uint3" + 10022 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10023 } 10024 10025 private void checkConvertShort4Uint4() { 10026 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7eb9ecaac60el, false, 15); 10027 try { 10028 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10029 script.forEach_testConvertUint4Short4Uint4(inV, out); 10030 verifyResultsConvertShort4Uint4(inV, out, false); 10031 out.destroy(); 10032 } catch (Exception e) { 10033 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString()); 10034 } 10035 try { 10036 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10037 scriptRelaxed.forEach_testConvertUint4Short4Uint4(inV, out); 10038 verifyResultsConvertShort4Uint4(inV, out, true); 10039 out.destroy(); 10040 } catch (Exception e) { 10041 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString()); 10042 } 10043 inV.destroy(); 10044 } 10045 10046 private void verifyResultsConvertShort4Uint4(Allocation inV, Allocation out, boolean relaxed) { 10047 short[] arrayInV = new short[INPUTSIZE * 4]; 10048 Arrays.fill(arrayInV, (short) 42); 10049 inV.copyTo(arrayInV); 10050 int[] arrayOut = new int[INPUTSIZE * 4]; 10051 Arrays.fill(arrayOut, (int) 42); 10052 out.copyTo(arrayOut); 10053 StringBuilder message = new StringBuilder(); 10054 boolean errorFound = false; 10055 for (int i = 0; i < INPUTSIZE; i++) { 10056 for (int j = 0; j < 4 ; j++) { 10057 // Extract the inputs. 10058 ArgumentsShortUint args = new ArgumentsShortUint(); 10059 args.inV = arrayInV[i * 4 + j]; 10060 // Figure out what the outputs should have been. 10061 CoreMathVerifier.computeConvert(args); 10062 // Validate the outputs. 10063 boolean valid = true; 10064 if (args.out != arrayOut[i * 4 + j]) { 10065 valid = false; 10066 } 10067 if (!valid) { 10068 if (!errorFound) { 10069 errorFound = true; 10070 message.append("Input inV: "); 10071 appendVariableToMessage(message, args.inV); 10072 message.append("\n"); 10073 message.append("Expected output out: "); 10074 appendVariableToMessage(message, args.out); 10075 message.append("\n"); 10076 message.append("Actual output out: "); 10077 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10078 if (args.out != arrayOut[i * 4 + j]) { 10079 message.append(" FAIL"); 10080 } 10081 message.append("\n"); 10082 message.append("Errors at"); 10083 } 10084 message.append(" ["); 10085 message.append(Integer.toString(i)); 10086 message.append(", "); 10087 message.append(Integer.toString(j)); 10088 message.append("]"); 10089 } 10090 } 10091 } 10092 assertFalse("Incorrect output for checkConvertShort4Uint4" + 10093 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10094 } 10095 10096 public class ArgumentsUshortUint { 10097 public short inV; 10098 public int out; 10099 } 10100 10101 private void checkConvertUshort2Uint2() { 10102 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79897eca7355d1l, false, 16); 10103 try { 10104 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10105 script.forEach_testConvertUint2Ushort2Uint2(inV, out); 10106 verifyResultsConvertUshort2Uint2(inV, out, false); 10107 out.destroy(); 10108 } catch (Exception e) { 10109 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString()); 10110 } 10111 try { 10112 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10113 scriptRelaxed.forEach_testConvertUint2Ushort2Uint2(inV, out); 10114 verifyResultsConvertUshort2Uint2(inV, out, true); 10115 out.destroy(); 10116 } catch (Exception e) { 10117 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString()); 10118 } 10119 inV.destroy(); 10120 } 10121 10122 private void verifyResultsConvertUshort2Uint2(Allocation inV, Allocation out, boolean relaxed) { 10123 short[] arrayInV = new short[INPUTSIZE * 2]; 10124 Arrays.fill(arrayInV, (short) 42); 10125 inV.copyTo(arrayInV); 10126 int[] arrayOut = new int[INPUTSIZE * 2]; 10127 Arrays.fill(arrayOut, (int) 42); 10128 out.copyTo(arrayOut); 10129 StringBuilder message = new StringBuilder(); 10130 boolean errorFound = false; 10131 for (int i = 0; i < INPUTSIZE; i++) { 10132 for (int j = 0; j < 2 ; j++) { 10133 // Extract the inputs. 10134 ArgumentsUshortUint args = new ArgumentsUshortUint(); 10135 args.inV = arrayInV[i * 2 + j]; 10136 // Figure out what the outputs should have been. 10137 CoreMathVerifier.computeConvert(args); 10138 // Validate the outputs. 10139 boolean valid = true; 10140 if (args.out != arrayOut[i * 2 + j]) { 10141 valid = false; 10142 } 10143 if (!valid) { 10144 if (!errorFound) { 10145 errorFound = true; 10146 message.append("Input inV: "); 10147 appendVariableToMessage(message, args.inV); 10148 message.append("\n"); 10149 message.append("Expected output out: "); 10150 appendVariableToMessage(message, args.out); 10151 message.append("\n"); 10152 message.append("Actual output out: "); 10153 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10154 if (args.out != arrayOut[i * 2 + j]) { 10155 message.append(" FAIL"); 10156 } 10157 message.append("\n"); 10158 message.append("Errors at"); 10159 } 10160 message.append(" ["); 10161 message.append(Integer.toString(i)); 10162 message.append(", "); 10163 message.append(Integer.toString(j)); 10164 message.append("]"); 10165 } 10166 } 10167 } 10168 assertFalse("Incorrect output for checkConvertUshort2Uint2" + 10169 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10170 } 10171 10172 private void checkConvertUshort3Uint3() { 10173 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d799420297b1ac5l, false, 16); 10174 try { 10175 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10176 script.forEach_testConvertUint3Ushort3Uint3(inV, out); 10177 verifyResultsConvertUshort3Uint3(inV, out, false); 10178 out.destroy(); 10179 } catch (Exception e) { 10180 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString()); 10181 } 10182 try { 10183 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10184 scriptRelaxed.forEach_testConvertUint3Ushort3Uint3(inV, out); 10185 verifyResultsConvertUshort3Uint3(inV, out, true); 10186 out.destroy(); 10187 } catch (Exception e) { 10188 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString()); 10189 } 10190 inV.destroy(); 10191 } 10192 10193 private void verifyResultsConvertUshort3Uint3(Allocation inV, Allocation out, boolean relaxed) { 10194 short[] arrayInV = new short[INPUTSIZE * 4]; 10195 Arrays.fill(arrayInV, (short) 42); 10196 inV.copyTo(arrayInV); 10197 int[] arrayOut = new int[INPUTSIZE * 4]; 10198 Arrays.fill(arrayOut, (int) 42); 10199 out.copyTo(arrayOut); 10200 StringBuilder message = new StringBuilder(); 10201 boolean errorFound = false; 10202 for (int i = 0; i < INPUTSIZE; i++) { 10203 for (int j = 0; j < 3 ; j++) { 10204 // Extract the inputs. 10205 ArgumentsUshortUint args = new ArgumentsUshortUint(); 10206 args.inV = arrayInV[i * 4 + j]; 10207 // Figure out what the outputs should have been. 10208 CoreMathVerifier.computeConvert(args); 10209 // Validate the outputs. 10210 boolean valid = true; 10211 if (args.out != arrayOut[i * 4 + j]) { 10212 valid = false; 10213 } 10214 if (!valid) { 10215 if (!errorFound) { 10216 errorFound = true; 10217 message.append("Input inV: "); 10218 appendVariableToMessage(message, args.inV); 10219 message.append("\n"); 10220 message.append("Expected output out: "); 10221 appendVariableToMessage(message, args.out); 10222 message.append("\n"); 10223 message.append("Actual output out: "); 10224 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10225 if (args.out != arrayOut[i * 4 + j]) { 10226 message.append(" FAIL"); 10227 } 10228 message.append("\n"); 10229 message.append("Errors at"); 10230 } 10231 message.append(" ["); 10232 message.append(Integer.toString(i)); 10233 message.append(", "); 10234 message.append(Integer.toString(j)); 10235 message.append("]"); 10236 } 10237 } 10238 } 10239 assertFalse("Incorrect output for checkConvertUshort3Uint3" + 10240 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10241 } 10242 10243 private void checkConvertUshort4Uint4() { 10244 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799ec18882dfb9l, false, 16); 10245 try { 10246 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10247 script.forEach_testConvertUint4Ushort4Uint4(inV, out); 10248 verifyResultsConvertUshort4Uint4(inV, out, false); 10249 out.destroy(); 10250 } catch (Exception e) { 10251 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString()); 10252 } 10253 try { 10254 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10255 scriptRelaxed.forEach_testConvertUint4Ushort4Uint4(inV, out); 10256 verifyResultsConvertUshort4Uint4(inV, out, true); 10257 out.destroy(); 10258 } catch (Exception e) { 10259 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString()); 10260 } 10261 inV.destroy(); 10262 } 10263 10264 private void verifyResultsConvertUshort4Uint4(Allocation inV, Allocation out, boolean relaxed) { 10265 short[] arrayInV = new short[INPUTSIZE * 4]; 10266 Arrays.fill(arrayInV, (short) 42); 10267 inV.copyTo(arrayInV); 10268 int[] arrayOut = new int[INPUTSIZE * 4]; 10269 Arrays.fill(arrayOut, (int) 42); 10270 out.copyTo(arrayOut); 10271 StringBuilder message = new StringBuilder(); 10272 boolean errorFound = false; 10273 for (int i = 0; i < INPUTSIZE; i++) { 10274 for (int j = 0; j < 4 ; j++) { 10275 // Extract the inputs. 10276 ArgumentsUshortUint args = new ArgumentsUshortUint(); 10277 args.inV = arrayInV[i * 4 + j]; 10278 // Figure out what the outputs should have been. 10279 CoreMathVerifier.computeConvert(args); 10280 // Validate the outputs. 10281 boolean valid = true; 10282 if (args.out != arrayOut[i * 4 + j]) { 10283 valid = false; 10284 } 10285 if (!valid) { 10286 if (!errorFound) { 10287 errorFound = true; 10288 message.append("Input inV: "); 10289 appendVariableToMessage(message, args.inV); 10290 message.append("\n"); 10291 message.append("Expected output out: "); 10292 appendVariableToMessage(message, args.out); 10293 message.append("\n"); 10294 message.append("Actual output out: "); 10295 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10296 if (args.out != arrayOut[i * 4 + j]) { 10297 message.append(" FAIL"); 10298 } 10299 message.append("\n"); 10300 message.append("Errors at"); 10301 } 10302 message.append(" ["); 10303 message.append(Integer.toString(i)); 10304 message.append(", "); 10305 message.append(Integer.toString(j)); 10306 message.append("]"); 10307 } 10308 } 10309 } 10310 assertFalse("Incorrect output for checkConvertUshort4Uint4" + 10311 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10312 } 10313 10314 public class ArgumentsIntUint { 10315 public int inV; 10316 public int out; 10317 } 10318 10319 private void checkConvertInt2Uint2() { 10320 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f55bc4f178a9fl, false, 31); 10321 try { 10322 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10323 script.forEach_testConvertUint2Int2Uint2(inV, out); 10324 verifyResultsConvertInt2Uint2(inV, out, false); 10325 out.destroy(); 10326 } catch (Exception e) { 10327 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString()); 10328 } 10329 try { 10330 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10331 scriptRelaxed.forEach_testConvertUint2Int2Uint2(inV, out); 10332 verifyResultsConvertInt2Uint2(inV, out, true); 10333 out.destroy(); 10334 } catch (Exception e) { 10335 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString()); 10336 } 10337 inV.destroy(); 10338 } 10339 10340 private void verifyResultsConvertInt2Uint2(Allocation inV, Allocation out, boolean relaxed) { 10341 int[] arrayInV = new int[INPUTSIZE * 2]; 10342 Arrays.fill(arrayInV, (int) 42); 10343 inV.copyTo(arrayInV); 10344 int[] arrayOut = new int[INPUTSIZE * 2]; 10345 Arrays.fill(arrayOut, (int) 42); 10346 out.copyTo(arrayOut); 10347 StringBuilder message = new StringBuilder(); 10348 boolean errorFound = false; 10349 for (int i = 0; i < INPUTSIZE; i++) { 10350 for (int j = 0; j < 2 ; j++) { 10351 // Extract the inputs. 10352 ArgumentsIntUint args = new ArgumentsIntUint(); 10353 args.inV = arrayInV[i * 2 + j]; 10354 // Figure out what the outputs should have been. 10355 CoreMathVerifier.computeConvert(args); 10356 // Validate the outputs. 10357 boolean valid = true; 10358 if (args.out != arrayOut[i * 2 + j]) { 10359 valid = false; 10360 } 10361 if (!valid) { 10362 if (!errorFound) { 10363 errorFound = true; 10364 message.append("Input inV: "); 10365 appendVariableToMessage(message, args.inV); 10366 message.append("\n"); 10367 message.append("Expected output out: "); 10368 appendVariableToMessage(message, args.out); 10369 message.append("\n"); 10370 message.append("Actual output out: "); 10371 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10372 if (args.out != arrayOut[i * 2 + j]) { 10373 message.append(" FAIL"); 10374 } 10375 message.append("\n"); 10376 message.append("Errors at"); 10377 } 10378 message.append(" ["); 10379 message.append(Integer.toString(i)); 10380 message.append(", "); 10381 message.append(Integer.toString(j)); 10382 message.append("]"); 10383 } 10384 } 10385 } 10386 assertFalse("Incorrect output for checkConvertInt2Uint2" + 10387 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10388 } 10389 10390 private void checkConvertInt3Uint3() { 10391 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f605dae1f4f93l, false, 31); 10392 try { 10393 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10394 script.forEach_testConvertUint3Int3Uint3(inV, out); 10395 verifyResultsConvertInt3Uint3(inV, out, false); 10396 out.destroy(); 10397 } catch (Exception e) { 10398 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString()); 10399 } 10400 try { 10401 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10402 scriptRelaxed.forEach_testConvertUint3Int3Uint3(inV, out); 10403 verifyResultsConvertInt3Uint3(inV, out, true); 10404 out.destroy(); 10405 } catch (Exception e) { 10406 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString()); 10407 } 10408 inV.destroy(); 10409 } 10410 10411 private void verifyResultsConvertInt3Uint3(Allocation inV, Allocation out, boolean relaxed) { 10412 int[] arrayInV = new int[INPUTSIZE * 4]; 10413 Arrays.fill(arrayInV, (int) 42); 10414 inV.copyTo(arrayInV); 10415 int[] arrayOut = new int[INPUTSIZE * 4]; 10416 Arrays.fill(arrayOut, (int) 42); 10417 out.copyTo(arrayOut); 10418 StringBuilder message = new StringBuilder(); 10419 boolean errorFound = false; 10420 for (int i = 0; i < INPUTSIZE; i++) { 10421 for (int j = 0; j < 3 ; j++) { 10422 // Extract the inputs. 10423 ArgumentsIntUint args = new ArgumentsIntUint(); 10424 args.inV = arrayInV[i * 4 + j]; 10425 // Figure out what the outputs should have been. 10426 CoreMathVerifier.computeConvert(args); 10427 // Validate the outputs. 10428 boolean valid = true; 10429 if (args.out != arrayOut[i * 4 + j]) { 10430 valid = false; 10431 } 10432 if (!valid) { 10433 if (!errorFound) { 10434 errorFound = true; 10435 message.append("Input inV: "); 10436 appendVariableToMessage(message, args.inV); 10437 message.append("\n"); 10438 message.append("Expected output out: "); 10439 appendVariableToMessage(message, args.out); 10440 message.append("\n"); 10441 message.append("Actual output out: "); 10442 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10443 if (args.out != arrayOut[i * 4 + j]) { 10444 message.append(" FAIL"); 10445 } 10446 message.append("\n"); 10447 message.append("Errors at"); 10448 } 10449 message.append(" ["); 10450 message.append(Integer.toString(i)); 10451 message.append(", "); 10452 message.append(Integer.toString(j)); 10453 message.append("]"); 10454 } 10455 } 10456 } 10457 assertFalse("Incorrect output for checkConvertInt3Uint3" + 10458 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10459 } 10460 10461 private void checkConvertInt4Uint4() { 10462 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f6aff0d271487l, false, 31); 10463 try { 10464 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10465 script.forEach_testConvertUint4Int4Uint4(inV, out); 10466 verifyResultsConvertInt4Uint4(inV, out, false); 10467 out.destroy(); 10468 } catch (Exception e) { 10469 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString()); 10470 } 10471 try { 10472 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10473 scriptRelaxed.forEach_testConvertUint4Int4Uint4(inV, out); 10474 verifyResultsConvertInt4Uint4(inV, out, true); 10475 out.destroy(); 10476 } catch (Exception e) { 10477 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString()); 10478 } 10479 inV.destroy(); 10480 } 10481 10482 private void verifyResultsConvertInt4Uint4(Allocation inV, Allocation out, boolean relaxed) { 10483 int[] arrayInV = new int[INPUTSIZE * 4]; 10484 Arrays.fill(arrayInV, (int) 42); 10485 inV.copyTo(arrayInV); 10486 int[] arrayOut = new int[INPUTSIZE * 4]; 10487 Arrays.fill(arrayOut, (int) 42); 10488 out.copyTo(arrayOut); 10489 StringBuilder message = new StringBuilder(); 10490 boolean errorFound = false; 10491 for (int i = 0; i < INPUTSIZE; i++) { 10492 for (int j = 0; j < 4 ; j++) { 10493 // Extract the inputs. 10494 ArgumentsIntUint args = new ArgumentsIntUint(); 10495 args.inV = arrayInV[i * 4 + j]; 10496 // Figure out what the outputs should have been. 10497 CoreMathVerifier.computeConvert(args); 10498 // Validate the outputs. 10499 boolean valid = true; 10500 if (args.out != arrayOut[i * 4 + j]) { 10501 valid = false; 10502 } 10503 if (!valid) { 10504 if (!errorFound) { 10505 errorFound = true; 10506 message.append("Input inV: "); 10507 appendVariableToMessage(message, args.inV); 10508 message.append("\n"); 10509 message.append("Expected output out: "); 10510 appendVariableToMessage(message, args.out); 10511 message.append("\n"); 10512 message.append("Actual output out: "); 10513 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10514 if (args.out != arrayOut[i * 4 + j]) { 10515 message.append(" FAIL"); 10516 } 10517 message.append("\n"); 10518 message.append("Errors at"); 10519 } 10520 message.append(" ["); 10521 message.append(Integer.toString(i)); 10522 message.append(", "); 10523 message.append(Integer.toString(j)); 10524 message.append("]"); 10525 } 10526 } 10527 } 10528 assertFalse("Incorrect output for checkConvertInt4Uint4" + 10529 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10530 } 10531 10532 public class ArgumentsUintUint { 10533 public int inV; 10534 public int out; 10535 } 10536 10537 private void checkConvertUint2Uint2() { 10538 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0ca64c8baea2l, false, 32); 10539 try { 10540 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10541 script.forEach_testConvertUint2Uint2Uint2(inV, out); 10542 verifyResultsConvertUint2Uint2(inV, out, false); 10543 out.destroy(); 10544 } catch (Exception e) { 10545 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString()); 10546 } 10547 try { 10548 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10549 scriptRelaxed.forEach_testConvertUint2Uint2Uint2(inV, out); 10550 verifyResultsConvertUint2Uint2(inV, out, true); 10551 out.destroy(); 10552 } catch (Exception e) { 10553 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString()); 10554 } 10555 inV.destroy(); 10556 } 10557 10558 private void verifyResultsConvertUint2Uint2(Allocation inV, Allocation out, boolean relaxed) { 10559 int[] arrayInV = new int[INPUTSIZE * 2]; 10560 Arrays.fill(arrayInV, (int) 42); 10561 inV.copyTo(arrayInV); 10562 int[] arrayOut = new int[INPUTSIZE * 2]; 10563 Arrays.fill(arrayOut, (int) 42); 10564 out.copyTo(arrayOut); 10565 StringBuilder message = new StringBuilder(); 10566 boolean errorFound = false; 10567 for (int i = 0; i < INPUTSIZE; i++) { 10568 for (int j = 0; j < 2 ; j++) { 10569 // Extract the inputs. 10570 ArgumentsUintUint args = new ArgumentsUintUint(); 10571 args.inV = arrayInV[i * 2 + j]; 10572 // Figure out what the outputs should have been. 10573 CoreMathVerifier.computeConvert(args); 10574 // Validate the outputs. 10575 boolean valid = true; 10576 if (args.out != arrayOut[i * 2 + j]) { 10577 valid = false; 10578 } 10579 if (!valid) { 10580 if (!errorFound) { 10581 errorFound = true; 10582 message.append("Input inV: "); 10583 appendVariableToMessage(message, args.inV); 10584 message.append("\n"); 10585 message.append("Expected output out: "); 10586 appendVariableToMessage(message, args.out); 10587 message.append("\n"); 10588 message.append("Actual output out: "); 10589 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10590 if (args.out != arrayOut[i * 2 + j]) { 10591 message.append(" FAIL"); 10592 } 10593 message.append("\n"); 10594 message.append("Errors at"); 10595 } 10596 message.append(" ["); 10597 message.append(Integer.toString(i)); 10598 message.append(", "); 10599 message.append(Integer.toString(j)); 10600 message.append("]"); 10601 } 10602 } 10603 } 10604 assertFalse("Incorrect output for checkConvertUint2Uint2" + 10605 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10606 } 10607 10608 private void checkConvertUint3Uint3() { 10609 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d1747ab937396l, false, 32); 10610 try { 10611 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10612 script.forEach_testConvertUint3Uint3Uint3(inV, out); 10613 verifyResultsConvertUint3Uint3(inV, out, false); 10614 out.destroy(); 10615 } catch (Exception e) { 10616 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString()); 10617 } 10618 try { 10619 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10620 scriptRelaxed.forEach_testConvertUint3Uint3Uint3(inV, out); 10621 verifyResultsConvertUint3Uint3(inV, out, true); 10622 out.destroy(); 10623 } catch (Exception e) { 10624 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString()); 10625 } 10626 inV.destroy(); 10627 } 10628 10629 private void verifyResultsConvertUint3Uint3(Allocation inV, Allocation out, boolean relaxed) { 10630 int[] arrayInV = new int[INPUTSIZE * 4]; 10631 Arrays.fill(arrayInV, (int) 42); 10632 inV.copyTo(arrayInV); 10633 int[] arrayOut = new int[INPUTSIZE * 4]; 10634 Arrays.fill(arrayOut, (int) 42); 10635 out.copyTo(arrayOut); 10636 StringBuilder message = new StringBuilder(); 10637 boolean errorFound = false; 10638 for (int i = 0; i < INPUTSIZE; i++) { 10639 for (int j = 0; j < 3 ; j++) { 10640 // Extract the inputs. 10641 ArgumentsUintUint args = new ArgumentsUintUint(); 10642 args.inV = arrayInV[i * 4 + j]; 10643 // Figure out what the outputs should have been. 10644 CoreMathVerifier.computeConvert(args); 10645 // Validate the outputs. 10646 boolean valid = true; 10647 if (args.out != arrayOut[i * 4 + j]) { 10648 valid = false; 10649 } 10650 if (!valid) { 10651 if (!errorFound) { 10652 errorFound = true; 10653 message.append("Input inV: "); 10654 appendVariableToMessage(message, args.inV); 10655 message.append("\n"); 10656 message.append("Expected output out: "); 10657 appendVariableToMessage(message, args.out); 10658 message.append("\n"); 10659 message.append("Actual output out: "); 10660 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10661 if (args.out != arrayOut[i * 4 + j]) { 10662 message.append(" FAIL"); 10663 } 10664 message.append("\n"); 10665 message.append("Errors at"); 10666 } 10667 message.append(" ["); 10668 message.append(Integer.toString(i)); 10669 message.append(", "); 10670 message.append(Integer.toString(j)); 10671 message.append("]"); 10672 } 10673 } 10674 } 10675 assertFalse("Incorrect output for checkConvertUint3Uint3" + 10676 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10677 } 10678 10679 private void checkConvertUint4Uint4() { 10680 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d21e90a9b388al, false, 32); 10681 try { 10682 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10683 script.forEach_testConvertUint4Uint4Uint4(inV, out); 10684 verifyResultsConvertUint4Uint4(inV, out, false); 10685 out.destroy(); 10686 } catch (Exception e) { 10687 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString()); 10688 } 10689 try { 10690 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10691 scriptRelaxed.forEach_testConvertUint4Uint4Uint4(inV, out); 10692 verifyResultsConvertUint4Uint4(inV, out, true); 10693 out.destroy(); 10694 } catch (Exception e) { 10695 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString()); 10696 } 10697 inV.destroy(); 10698 } 10699 10700 private void verifyResultsConvertUint4Uint4(Allocation inV, Allocation out, boolean relaxed) { 10701 int[] arrayInV = new int[INPUTSIZE * 4]; 10702 Arrays.fill(arrayInV, (int) 42); 10703 inV.copyTo(arrayInV); 10704 int[] arrayOut = new int[INPUTSIZE * 4]; 10705 Arrays.fill(arrayOut, (int) 42); 10706 out.copyTo(arrayOut); 10707 StringBuilder message = new StringBuilder(); 10708 boolean errorFound = false; 10709 for (int i = 0; i < INPUTSIZE; i++) { 10710 for (int j = 0; j < 4 ; j++) { 10711 // Extract the inputs. 10712 ArgumentsUintUint args = new ArgumentsUintUint(); 10713 args.inV = arrayInV[i * 4 + j]; 10714 // Figure out what the outputs should have been. 10715 CoreMathVerifier.computeConvert(args); 10716 // Validate the outputs. 10717 boolean valid = true; 10718 if (args.out != arrayOut[i * 4 + j]) { 10719 valid = false; 10720 } 10721 if (!valid) { 10722 if (!errorFound) { 10723 errorFound = true; 10724 message.append("Input inV: "); 10725 appendVariableToMessage(message, args.inV); 10726 message.append("\n"); 10727 message.append("Expected output out: "); 10728 appendVariableToMessage(message, args.out); 10729 message.append("\n"); 10730 message.append("Actual output out: "); 10731 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10732 if (args.out != arrayOut[i * 4 + j]) { 10733 message.append(" FAIL"); 10734 } 10735 message.append("\n"); 10736 message.append("Errors at"); 10737 } 10738 message.append(" ["); 10739 message.append(Integer.toString(i)); 10740 message.append(", "); 10741 message.append(Integer.toString(j)); 10742 message.append("]"); 10743 } 10744 } 10745 } 10746 assertFalse("Incorrect output for checkConvertUint4Uint4" + 10747 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10748 } 10749 10750 public class ArgumentsDoubleDouble { 10751 public double inV; 10752 public Target.Floaty out; 10753 } 10754 10755 private void checkConvertDouble2Double2() { 10756 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x345b4a823902786el, -8.5390423905960001625e+307, 8.5390423905960001625e+307); 10757 try { 10758 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10759 script.forEach_testConvertDouble2Double2Double2(inV, out); 10760 verifyResultsConvertDouble2Double2(inV, out, false); 10761 out.destroy(); 10762 } catch (Exception e) { 10763 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString()); 10764 } 10765 try { 10766 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10767 scriptRelaxed.forEach_testConvertDouble2Double2Double2(inV, out); 10768 verifyResultsConvertDouble2Double2(inV, out, true); 10769 out.destroy(); 10770 } catch (Exception e) { 10771 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString()); 10772 } 10773 inV.destroy(); 10774 } 10775 10776 private void verifyResultsConvertDouble2Double2(Allocation inV, Allocation out, boolean relaxed) { 10777 double[] arrayInV = new double[INPUTSIZE * 2]; 10778 Arrays.fill(arrayInV, (double) 42); 10779 inV.copyTo(arrayInV); 10780 double[] arrayOut = new double[INPUTSIZE * 2]; 10781 Arrays.fill(arrayOut, (double) 42); 10782 out.copyTo(arrayOut); 10783 StringBuilder message = new StringBuilder(); 10784 boolean errorFound = false; 10785 for (int i = 0; i < INPUTSIZE; i++) { 10786 for (int j = 0; j < 2 ; j++) { 10787 // Extract the inputs. 10788 ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); 10789 args.inV = arrayInV[i * 2 + j]; 10790 // Figure out what the outputs should have been. 10791 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10792 CoreMathVerifier.computeConvert(args, target); 10793 // Validate the outputs. 10794 boolean valid = true; 10795 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10796 valid = false; 10797 } 10798 if (!valid) { 10799 if (!errorFound) { 10800 errorFound = true; 10801 message.append("Input inV: "); 10802 appendVariableToMessage(message, args.inV); 10803 message.append("\n"); 10804 message.append("Expected output out: "); 10805 appendVariableToMessage(message, args.out); 10806 message.append("\n"); 10807 message.append("Actual output out: "); 10808 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10809 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10810 message.append(" FAIL"); 10811 } 10812 message.append("\n"); 10813 message.append("Errors at"); 10814 } 10815 message.append(" ["); 10816 message.append(Integer.toString(i)); 10817 message.append(", "); 10818 message.append(Integer.toString(j)); 10819 message.append("]"); 10820 } 10821 } 10822 } 10823 assertFalse("Incorrect output for checkConvertDouble2Double2" + 10824 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10825 } 10826 10827 private void checkConvertDouble3Double3() { 10828 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x34a812098f5e099al, -8.5390423905960001625e+307, 8.5390423905960001625e+307); 10829 try { 10830 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10831 script.forEach_testConvertDouble3Double3Double3(inV, out); 10832 verifyResultsConvertDouble3Double3(inV, out, false); 10833 out.destroy(); 10834 } catch (Exception e) { 10835 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString()); 10836 } 10837 try { 10838 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10839 scriptRelaxed.forEach_testConvertDouble3Double3Double3(inV, out); 10840 verifyResultsConvertDouble3Double3(inV, out, true); 10841 out.destroy(); 10842 } catch (Exception e) { 10843 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString()); 10844 } 10845 inV.destroy(); 10846 } 10847 10848 private void verifyResultsConvertDouble3Double3(Allocation inV, Allocation out, boolean relaxed) { 10849 double[] arrayInV = new double[INPUTSIZE * 4]; 10850 Arrays.fill(arrayInV, (double) 42); 10851 inV.copyTo(arrayInV); 10852 double[] arrayOut = new double[INPUTSIZE * 4]; 10853 Arrays.fill(arrayOut, (double) 42); 10854 out.copyTo(arrayOut); 10855 StringBuilder message = new StringBuilder(); 10856 boolean errorFound = false; 10857 for (int i = 0; i < INPUTSIZE; i++) { 10858 for (int j = 0; j < 3 ; j++) { 10859 // Extract the inputs. 10860 ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); 10861 args.inV = arrayInV[i * 4 + j]; 10862 // Figure out what the outputs should have been. 10863 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10864 CoreMathVerifier.computeConvert(args, target); 10865 // Validate the outputs. 10866 boolean valid = true; 10867 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10868 valid = false; 10869 } 10870 if (!valid) { 10871 if (!errorFound) { 10872 errorFound = true; 10873 message.append("Input inV: "); 10874 appendVariableToMessage(message, args.inV); 10875 message.append("\n"); 10876 message.append("Expected output out: "); 10877 appendVariableToMessage(message, args.out); 10878 message.append("\n"); 10879 message.append("Actual output out: "); 10880 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10881 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10882 message.append(" FAIL"); 10883 } 10884 message.append("\n"); 10885 message.append("Errors at"); 10886 } 10887 message.append(" ["); 10888 message.append(Integer.toString(i)); 10889 message.append(", "); 10890 message.append(Integer.toString(j)); 10891 message.append("]"); 10892 } 10893 } 10894 } 10895 assertFalse("Incorrect output for checkConvertDouble3Double3" + 10896 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10897 } 10898 10899 private void checkConvertDouble4Double4() { 10900 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x34f4d990e5b99ac6l, -8.5390423905960001625e+307, 8.5390423905960001625e+307); 10901 try { 10902 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10903 script.forEach_testConvertDouble4Double4Double4(inV, out); 10904 verifyResultsConvertDouble4Double4(inV, out, false); 10905 out.destroy(); 10906 } catch (Exception e) { 10907 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString()); 10908 } 10909 try { 10910 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10911 scriptRelaxed.forEach_testConvertDouble4Double4Double4(inV, out); 10912 verifyResultsConvertDouble4Double4(inV, out, true); 10913 out.destroy(); 10914 } catch (Exception e) { 10915 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString()); 10916 } 10917 inV.destroy(); 10918 } 10919 10920 private void verifyResultsConvertDouble4Double4(Allocation inV, Allocation out, boolean relaxed) { 10921 double[] arrayInV = new double[INPUTSIZE * 4]; 10922 Arrays.fill(arrayInV, (double) 42); 10923 inV.copyTo(arrayInV); 10924 double[] arrayOut = new double[INPUTSIZE * 4]; 10925 Arrays.fill(arrayOut, (double) 42); 10926 out.copyTo(arrayOut); 10927 StringBuilder message = new StringBuilder(); 10928 boolean errorFound = false; 10929 for (int i = 0; i < INPUTSIZE; i++) { 10930 for (int j = 0; j < 4 ; j++) { 10931 // Extract the inputs. 10932 ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); 10933 args.inV = arrayInV[i * 4 + j]; 10934 // Figure out what the outputs should have been. 10935 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10936 CoreMathVerifier.computeConvert(args, target); 10937 // Validate the outputs. 10938 boolean valid = true; 10939 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10940 valid = false; 10941 } 10942 if (!valid) { 10943 if (!errorFound) { 10944 errorFound = true; 10945 message.append("Input inV: "); 10946 appendVariableToMessage(message, args.inV); 10947 message.append("\n"); 10948 message.append("Expected output out: "); 10949 appendVariableToMessage(message, args.out); 10950 message.append("\n"); 10951 message.append("Actual output out: "); 10952 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10953 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10954 message.append(" FAIL"); 10955 } 10956 message.append("\n"); 10957 message.append("Errors at"); 10958 } 10959 message.append(" ["); 10960 message.append(Integer.toString(i)); 10961 message.append(", "); 10962 message.append(Integer.toString(j)); 10963 message.append("]"); 10964 } 10965 } 10966 } 10967 assertFalse("Incorrect output for checkConvertDouble4Double4" + 10968 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10969 } 10970 10971 public class ArgumentsLongDouble { 10972 public long inV; 10973 public Target.Floaty out; 10974 } 10975 10976 private void checkConvertLong2Double2() { 10977 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7b7807124c70299bl, true, 63); 10978 try { 10979 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10980 script.forEach_testConvertDouble2Long2Double2(inV, out); 10981 verifyResultsConvertLong2Double2(inV, out, false); 10982 out.destroy(); 10983 } catch (Exception e) { 10984 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString()); 10985 } 10986 try { 10987 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10988 scriptRelaxed.forEach_testConvertDouble2Long2Double2(inV, out); 10989 verifyResultsConvertLong2Double2(inV, out, true); 10990 out.destroy(); 10991 } catch (Exception e) { 10992 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString()); 10993 } 10994 inV.destroy(); 10995 } 10996 10997 private void verifyResultsConvertLong2Double2(Allocation inV, Allocation out, boolean relaxed) { 10998 long[] arrayInV = new long[INPUTSIZE * 2]; 10999 Arrays.fill(arrayInV, (long) 42); 11000 inV.copyTo(arrayInV); 11001 double[] arrayOut = new double[INPUTSIZE * 2]; 11002 Arrays.fill(arrayOut, (double) 42); 11003 out.copyTo(arrayOut); 11004 StringBuilder message = new StringBuilder(); 11005 boolean errorFound = false; 11006 for (int i = 0; i < INPUTSIZE; i++) { 11007 for (int j = 0; j < 2 ; j++) { 11008 // Extract the inputs. 11009 ArgumentsLongDouble args = new ArgumentsLongDouble(); 11010 args.inV = arrayInV[i * 2 + j]; 11011 // Figure out what the outputs should have been. 11012 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 11013 CoreMathVerifier.computeConvert(args, target); 11014 // Validate the outputs. 11015 boolean valid = true; 11016 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 11017 valid = false; 11018 } 11019 if (!valid) { 11020 if (!errorFound) { 11021 errorFound = true; 11022 message.append("Input inV: "); 11023 appendVariableToMessage(message, args.inV); 11024 message.append("\n"); 11025 message.append("Expected output out: "); 11026 appendVariableToMessage(message, args.out); 11027 message.append("\n"); 11028 message.append("Actual output out: "); 11029 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11030 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 11031 message.append(" FAIL"); 11032 } 11033 message.append("\n"); 11034 message.append("Errors at"); 11035 } 11036 message.append(" ["); 11037 message.append(Integer.toString(i)); 11038 message.append(", "); 11039 message.append(Integer.toString(j)); 11040 message.append("]"); 11041 } 11042 } 11043 } 11044 assertFalse("Incorrect output for checkConvertLong2Double2" + 11045 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11046 } 11047 11048 private void checkConvertLong3Double3() { 11049 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7bc4ce99a2cbbac7l, true, 63); 11050 try { 11051 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 11052 script.forEach_testConvertDouble3Long3Double3(inV, out); 11053 verifyResultsConvertLong3Double3(inV, out, false); 11054 out.destroy(); 11055 } catch (Exception e) { 11056 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString()); 11057 } 11058 try { 11059 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 11060 scriptRelaxed.forEach_testConvertDouble3Long3Double3(inV, out); 11061 verifyResultsConvertLong3Double3(inV, out, true); 11062 out.destroy(); 11063 } catch (Exception e) { 11064 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString()); 11065 } 11066 inV.destroy(); 11067 } 11068 11069 private void verifyResultsConvertLong3Double3(Allocation inV, Allocation out, boolean relaxed) { 11070 long[] arrayInV = new long[INPUTSIZE * 4]; 11071 Arrays.fill(arrayInV, (long) 42); 11072 inV.copyTo(arrayInV); 11073 double[] arrayOut = new double[INPUTSIZE * 4]; 11074 Arrays.fill(arrayOut, (double) 42); 11075 out.copyTo(arrayOut); 11076 StringBuilder message = new StringBuilder(); 11077 boolean errorFound = false; 11078 for (int i = 0; i < INPUTSIZE; i++) { 11079 for (int j = 0; j < 3 ; j++) { 11080 // Extract the inputs. 11081 ArgumentsLongDouble args = new ArgumentsLongDouble(); 11082 args.inV = arrayInV[i * 4 + j]; 11083 // Figure out what the outputs should have been. 11084 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 11085 CoreMathVerifier.computeConvert(args, target); 11086 // Validate the outputs. 11087 boolean valid = true; 11088 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11089 valid = false; 11090 } 11091 if (!valid) { 11092 if (!errorFound) { 11093 errorFound = true; 11094 message.append("Input inV: "); 11095 appendVariableToMessage(message, args.inV); 11096 message.append("\n"); 11097 message.append("Expected output out: "); 11098 appendVariableToMessage(message, args.out); 11099 message.append("\n"); 11100 message.append("Actual output out: "); 11101 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11102 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11103 message.append(" FAIL"); 11104 } 11105 message.append("\n"); 11106 message.append("Errors at"); 11107 } 11108 message.append(" ["); 11109 message.append(Integer.toString(i)); 11110 message.append(", "); 11111 message.append(Integer.toString(j)); 11112 message.append("]"); 11113 } 11114 } 11115 } 11116 assertFalse("Incorrect output for checkConvertLong3Double3" + 11117 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11118 } 11119 11120 private void checkConvertLong4Double4() { 11121 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7c119620f9274bf3l, true, 63); 11122 try { 11123 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 11124 script.forEach_testConvertDouble4Long4Double4(inV, out); 11125 verifyResultsConvertLong4Double4(inV, out, false); 11126 out.destroy(); 11127 } catch (Exception e) { 11128 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString()); 11129 } 11130 try { 11131 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 11132 scriptRelaxed.forEach_testConvertDouble4Long4Double4(inV, out); 11133 verifyResultsConvertLong4Double4(inV, out, true); 11134 out.destroy(); 11135 } catch (Exception e) { 11136 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString()); 11137 } 11138 inV.destroy(); 11139 } 11140 11141 private void verifyResultsConvertLong4Double4(Allocation inV, Allocation out, boolean relaxed) { 11142 long[] arrayInV = new long[INPUTSIZE * 4]; 11143 Arrays.fill(arrayInV, (long) 42); 11144 inV.copyTo(arrayInV); 11145 double[] arrayOut = new double[INPUTSIZE * 4]; 11146 Arrays.fill(arrayOut, (double) 42); 11147 out.copyTo(arrayOut); 11148 StringBuilder message = new StringBuilder(); 11149 boolean errorFound = false; 11150 for (int i = 0; i < INPUTSIZE; i++) { 11151 for (int j = 0; j < 4 ; j++) { 11152 // Extract the inputs. 11153 ArgumentsLongDouble args = new ArgumentsLongDouble(); 11154 args.inV = arrayInV[i * 4 + j]; 11155 // Figure out what the outputs should have been. 11156 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 11157 CoreMathVerifier.computeConvert(args, target); 11158 // Validate the outputs. 11159 boolean valid = true; 11160 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11161 valid = false; 11162 } 11163 if (!valid) { 11164 if (!errorFound) { 11165 errorFound = true; 11166 message.append("Input inV: "); 11167 appendVariableToMessage(message, args.inV); 11168 message.append("\n"); 11169 message.append("Expected output out: "); 11170 appendVariableToMessage(message, args.out); 11171 message.append("\n"); 11172 message.append("Actual output out: "); 11173 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11174 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11175 message.append(" FAIL"); 11176 } 11177 message.append("\n"); 11178 message.append("Errors at"); 11179 } 11180 message.append(" ["); 11181 message.append(Integer.toString(i)); 11182 message.append(", "); 11183 message.append(Integer.toString(j)); 11184 message.append("]"); 11185 } 11186 } 11187 } 11188 assertFalse("Incorrect output for checkConvertLong4Double4" + 11189 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11190 } 11191 11192 public class ArgumentsUlongDouble { 11193 public long inV; 11194 public Target.Floaty out; 11195 } 11196 11197 private void checkConvertUlong2Double2() { 11198 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xaa17685979bc7954l, false, 64); 11199 try { 11200 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 11201 script.forEach_testConvertDouble2Ulong2Double2(inV, out); 11202 verifyResultsConvertUlong2Double2(inV, out, false); 11203 out.destroy(); 11204 } catch (Exception e) { 11205 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString()); 11206 } 11207 try { 11208 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 11209 scriptRelaxed.forEach_testConvertDouble2Ulong2Double2(inV, out); 11210 verifyResultsConvertUlong2Double2(inV, out, true); 11211 out.destroy(); 11212 } catch (Exception e) { 11213 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString()); 11214 } 11215 inV.destroy(); 11216 } 11217 11218 private void verifyResultsConvertUlong2Double2(Allocation inV, Allocation out, boolean relaxed) { 11219 long[] arrayInV = new long[INPUTSIZE * 2]; 11220 Arrays.fill(arrayInV, (long) 42); 11221 inV.copyTo(arrayInV); 11222 double[] arrayOut = new double[INPUTSIZE * 2]; 11223 Arrays.fill(arrayOut, (double) 42); 11224 out.copyTo(arrayOut); 11225 StringBuilder message = new StringBuilder(); 11226 boolean errorFound = false; 11227 for (int i = 0; i < INPUTSIZE; i++) { 11228 for (int j = 0; j < 2 ; j++) { 11229 // Extract the inputs. 11230 ArgumentsUlongDouble args = new ArgumentsUlongDouble(); 11231 args.inV = arrayInV[i * 2 + j]; 11232 // Figure out what the outputs should have been. 11233 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 11234 CoreMathVerifier.computeConvert(args, target); 11235 // Validate the outputs. 11236 boolean valid = true; 11237 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 11238 valid = false; 11239 } 11240 if (!valid) { 11241 if (!errorFound) { 11242 errorFound = true; 11243 message.append("Input inV: "); 11244 appendVariableToMessage(message, args.inV); 11245 message.append("\n"); 11246 message.append("Expected output out: "); 11247 appendVariableToMessage(message, args.out); 11248 message.append("\n"); 11249 message.append("Actual output out: "); 11250 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11251 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 11252 message.append(" FAIL"); 11253 } 11254 message.append("\n"); 11255 message.append("Errors at"); 11256 } 11257 message.append(" ["); 11258 message.append(Integer.toString(i)); 11259 message.append(", "); 11260 message.append(Integer.toString(j)); 11261 message.append("]"); 11262 } 11263 } 11264 } 11265 assertFalse("Incorrect output for checkConvertUlong2Double2" + 11266 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11267 } 11268 11269 private void checkConvertUlong3Double3() { 11270 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaa642fe0d0180a80l, false, 64); 11271 try { 11272 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 11273 script.forEach_testConvertDouble3Ulong3Double3(inV, out); 11274 verifyResultsConvertUlong3Double3(inV, out, false); 11275 out.destroy(); 11276 } catch (Exception e) { 11277 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString()); 11278 } 11279 try { 11280 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 11281 scriptRelaxed.forEach_testConvertDouble3Ulong3Double3(inV, out); 11282 verifyResultsConvertUlong3Double3(inV, out, true); 11283 out.destroy(); 11284 } catch (Exception e) { 11285 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString()); 11286 } 11287 inV.destroy(); 11288 } 11289 11290 private void verifyResultsConvertUlong3Double3(Allocation inV, Allocation out, boolean relaxed) { 11291 long[] arrayInV = new long[INPUTSIZE * 4]; 11292 Arrays.fill(arrayInV, (long) 42); 11293 inV.copyTo(arrayInV); 11294 double[] arrayOut = new double[INPUTSIZE * 4]; 11295 Arrays.fill(arrayOut, (double) 42); 11296 out.copyTo(arrayOut); 11297 StringBuilder message = new StringBuilder(); 11298 boolean errorFound = false; 11299 for (int i = 0; i < INPUTSIZE; i++) { 11300 for (int j = 0; j < 3 ; j++) { 11301 // Extract the inputs. 11302 ArgumentsUlongDouble args = new ArgumentsUlongDouble(); 11303 args.inV = arrayInV[i * 4 + j]; 11304 // Figure out what the outputs should have been. 11305 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 11306 CoreMathVerifier.computeConvert(args, target); 11307 // Validate the outputs. 11308 boolean valid = true; 11309 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11310 valid = false; 11311 } 11312 if (!valid) { 11313 if (!errorFound) { 11314 errorFound = true; 11315 message.append("Input inV: "); 11316 appendVariableToMessage(message, args.inV); 11317 message.append("\n"); 11318 message.append("Expected output out: "); 11319 appendVariableToMessage(message, args.out); 11320 message.append("\n"); 11321 message.append("Actual output out: "); 11322 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11323 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11324 message.append(" FAIL"); 11325 } 11326 message.append("\n"); 11327 message.append("Errors at"); 11328 } 11329 message.append(" ["); 11330 message.append(Integer.toString(i)); 11331 message.append(", "); 11332 message.append(Integer.toString(j)); 11333 message.append("]"); 11334 } 11335 } 11336 } 11337 assertFalse("Incorrect output for checkConvertUlong3Double3" + 11338 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11339 } 11340 11341 private void checkConvertUlong4Double4() { 11342 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xaab0f76826739bacl, false, 64); 11343 try { 11344 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 11345 script.forEach_testConvertDouble4Ulong4Double4(inV, out); 11346 verifyResultsConvertUlong4Double4(inV, out, false); 11347 out.destroy(); 11348 } catch (Exception e) { 11349 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString()); 11350 } 11351 try { 11352 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 11353 scriptRelaxed.forEach_testConvertDouble4Ulong4Double4(inV, out); 11354 verifyResultsConvertUlong4Double4(inV, out, true); 11355 out.destroy(); 11356 } catch (Exception e) { 11357 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString()); 11358 } 11359 inV.destroy(); 11360 } 11361 11362 private void verifyResultsConvertUlong4Double4(Allocation inV, Allocation out, boolean relaxed) { 11363 long[] arrayInV = new long[INPUTSIZE * 4]; 11364 Arrays.fill(arrayInV, (long) 42); 11365 inV.copyTo(arrayInV); 11366 double[] arrayOut = new double[INPUTSIZE * 4]; 11367 Arrays.fill(arrayOut, (double) 42); 11368 out.copyTo(arrayOut); 11369 StringBuilder message = new StringBuilder(); 11370 boolean errorFound = false; 11371 for (int i = 0; i < INPUTSIZE; i++) { 11372 for (int j = 0; j < 4 ; j++) { 11373 // Extract the inputs. 11374 ArgumentsUlongDouble args = new ArgumentsUlongDouble(); 11375 args.inV = arrayInV[i * 4 + j]; 11376 // Figure out what the outputs should have been. 11377 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 11378 CoreMathVerifier.computeConvert(args, target); 11379 // Validate the outputs. 11380 boolean valid = true; 11381 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11382 valid = false; 11383 } 11384 if (!valid) { 11385 if (!errorFound) { 11386 errorFound = true; 11387 message.append("Input inV: "); 11388 appendVariableToMessage(message, args.inV); 11389 message.append("\n"); 11390 message.append("Expected output out: "); 11391 appendVariableToMessage(message, args.out); 11392 message.append("\n"); 11393 message.append("Actual output out: "); 11394 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11395 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 11396 message.append(" FAIL"); 11397 } 11398 message.append("\n"); 11399 message.append("Errors at"); 11400 } 11401 message.append(" ["); 11402 message.append(Integer.toString(i)); 11403 message.append(", "); 11404 message.append(Integer.toString(j)); 11405 message.append("]"); 11406 } 11407 } 11408 } 11409 assertFalse("Incorrect output for checkConvertUlong4Double4" + 11410 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11411 } 11412 11413 public class ArgumentsDoubleLong { 11414 public double inV; 11415 public long out; 11416 } 11417 11418 private void checkConvertDouble2Long2() { 11419 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84dc0430cbe95l, -9.2233720368547747840e+18, 9.2233720368547747840e+18); 11420 try { 11421 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11422 script.forEach_testConvertLong2Double2Long2(inV, out); 11423 verifyResultsConvertDouble2Long2(inV, out, false); 11424 out.destroy(); 11425 } catch (Exception e) { 11426 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString()); 11427 } 11428 try { 11429 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11430 scriptRelaxed.forEach_testConvertLong2Double2Long2(inV, out); 11431 verifyResultsConvertDouble2Long2(inV, out, true); 11432 out.destroy(); 11433 } catch (Exception e) { 11434 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString()); 11435 } 11436 inV.destroy(); 11437 } 11438 11439 private void verifyResultsConvertDouble2Long2(Allocation inV, Allocation out, boolean relaxed) { 11440 double[] arrayInV = new double[INPUTSIZE * 2]; 11441 Arrays.fill(arrayInV, (double) 42); 11442 inV.copyTo(arrayInV); 11443 long[] arrayOut = new long[INPUTSIZE * 2]; 11444 Arrays.fill(arrayOut, (long) 42); 11445 out.copyTo(arrayOut); 11446 StringBuilder message = new StringBuilder(); 11447 boolean errorFound = false; 11448 for (int i = 0; i < INPUTSIZE; i++) { 11449 for (int j = 0; j < 2 ; j++) { 11450 // Extract the inputs. 11451 ArgumentsDoubleLong args = new ArgumentsDoubleLong(); 11452 args.inV = arrayInV[i * 2 + j]; 11453 // Figure out what the outputs should have been. 11454 CoreMathVerifier.computeConvert(args); 11455 // Validate the outputs. 11456 boolean valid = true; 11457 if (args.out != arrayOut[i * 2 + j]) { 11458 valid = false; 11459 } 11460 if (!valid) { 11461 if (!errorFound) { 11462 errorFound = true; 11463 message.append("Input inV: "); 11464 appendVariableToMessage(message, args.inV); 11465 message.append("\n"); 11466 message.append("Expected output out: "); 11467 appendVariableToMessage(message, args.out); 11468 message.append("\n"); 11469 message.append("Actual output out: "); 11470 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11471 if (args.out != arrayOut[i * 2 + j]) { 11472 message.append(" FAIL"); 11473 } 11474 message.append("\n"); 11475 message.append("Errors at"); 11476 } 11477 message.append(" ["); 11478 message.append(Integer.toString(i)); 11479 message.append(", "); 11480 message.append(Integer.toString(j)); 11481 message.append("]"); 11482 } 11483 } 11484 } 11485 assertFalse("Incorrect output for checkConvertDouble2Long2" + 11486 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11487 } 11488 11489 private void checkConvertDouble3Long3() { 11490 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf85861a2148389l, -9.2233720368547747840e+18, 9.2233720368547747840e+18); 11491 try { 11492 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11493 script.forEach_testConvertLong3Double3Long3(inV, out); 11494 verifyResultsConvertDouble3Long3(inV, out, false); 11495 out.destroy(); 11496 } catch (Exception e) { 11497 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString()); 11498 } 11499 try { 11500 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11501 scriptRelaxed.forEach_testConvertLong3Double3Long3(inV, out); 11502 verifyResultsConvertDouble3Long3(inV, out, true); 11503 out.destroy(); 11504 } catch (Exception e) { 11505 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString()); 11506 } 11507 inV.destroy(); 11508 } 11509 11510 private void verifyResultsConvertDouble3Long3(Allocation inV, Allocation out, boolean relaxed) { 11511 double[] arrayInV = new double[INPUTSIZE * 4]; 11512 Arrays.fill(arrayInV, (double) 42); 11513 inV.copyTo(arrayInV); 11514 long[] arrayOut = new long[INPUTSIZE * 4]; 11515 Arrays.fill(arrayOut, (long) 42); 11516 out.copyTo(arrayOut); 11517 StringBuilder message = new StringBuilder(); 11518 boolean errorFound = false; 11519 for (int i = 0; i < INPUTSIZE; i++) { 11520 for (int j = 0; j < 3 ; j++) { 11521 // Extract the inputs. 11522 ArgumentsDoubleLong args = new ArgumentsDoubleLong(); 11523 args.inV = arrayInV[i * 4 + j]; 11524 // Figure out what the outputs should have been. 11525 CoreMathVerifier.computeConvert(args); 11526 // Validate the outputs. 11527 boolean valid = true; 11528 if (args.out != arrayOut[i * 4 + j]) { 11529 valid = false; 11530 } 11531 if (!valid) { 11532 if (!errorFound) { 11533 errorFound = true; 11534 message.append("Input inV: "); 11535 appendVariableToMessage(message, args.inV); 11536 message.append("\n"); 11537 message.append("Expected output out: "); 11538 appendVariableToMessage(message, args.out); 11539 message.append("\n"); 11540 message.append("Actual output out: "); 11541 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11542 if (args.out != arrayOut[i * 4 + j]) { 11543 message.append(" FAIL"); 11544 } 11545 message.append("\n"); 11546 message.append("Errors at"); 11547 } 11548 message.append(" ["); 11549 message.append(Integer.toString(i)); 11550 message.append(", "); 11551 message.append(Integer.toString(j)); 11552 message.append("]"); 11553 } 11554 } 11555 } 11556 assertFalse("Incorrect output for checkConvertDouble3Long3" + 11557 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11558 } 11559 11560 private void checkConvertDouble4Long4() { 11561 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf86303011c487dl, -9.2233720368547747840e+18, 9.2233720368547747840e+18); 11562 try { 11563 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11564 script.forEach_testConvertLong4Double4Long4(inV, out); 11565 verifyResultsConvertDouble4Long4(inV, out, false); 11566 out.destroy(); 11567 } catch (Exception e) { 11568 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString()); 11569 } 11570 try { 11571 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11572 scriptRelaxed.forEach_testConvertLong4Double4Long4(inV, out); 11573 verifyResultsConvertDouble4Long4(inV, out, true); 11574 out.destroy(); 11575 } catch (Exception e) { 11576 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString()); 11577 } 11578 inV.destroy(); 11579 } 11580 11581 private void verifyResultsConvertDouble4Long4(Allocation inV, Allocation out, boolean relaxed) { 11582 double[] arrayInV = new double[INPUTSIZE * 4]; 11583 Arrays.fill(arrayInV, (double) 42); 11584 inV.copyTo(arrayInV); 11585 long[] arrayOut = new long[INPUTSIZE * 4]; 11586 Arrays.fill(arrayOut, (long) 42); 11587 out.copyTo(arrayOut); 11588 StringBuilder message = new StringBuilder(); 11589 boolean errorFound = false; 11590 for (int i = 0; i < INPUTSIZE; i++) { 11591 for (int j = 0; j < 4 ; j++) { 11592 // Extract the inputs. 11593 ArgumentsDoubleLong args = new ArgumentsDoubleLong(); 11594 args.inV = arrayInV[i * 4 + j]; 11595 // Figure out what the outputs should have been. 11596 CoreMathVerifier.computeConvert(args); 11597 // Validate the outputs. 11598 boolean valid = true; 11599 if (args.out != arrayOut[i * 4 + j]) { 11600 valid = false; 11601 } 11602 if (!valid) { 11603 if (!errorFound) { 11604 errorFound = true; 11605 message.append("Input inV: "); 11606 appendVariableToMessage(message, args.inV); 11607 message.append("\n"); 11608 message.append("Expected output out: "); 11609 appendVariableToMessage(message, args.out); 11610 message.append("\n"); 11611 message.append("Actual output out: "); 11612 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11613 if (args.out != arrayOut[i * 4 + j]) { 11614 message.append(" FAIL"); 11615 } 11616 message.append("\n"); 11617 message.append("Errors at"); 11618 } 11619 message.append(" ["); 11620 message.append(Integer.toString(i)); 11621 message.append(", "); 11622 message.append(Integer.toString(j)); 11623 message.append("]"); 11624 } 11625 } 11626 } 11627 assertFalse("Incorrect output for checkConvertDouble4Long4" + 11628 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11629 } 11630 11631 public class ArgumentsLongLong { 11632 public long inV; 11633 public long out; 11634 } 11635 11636 private void checkConvertLong2Long2() { 11637 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c607c81d242al, true, 63); 11638 try { 11639 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11640 script.forEach_testConvertLong2Long2Long2(inV, out); 11641 verifyResultsConvertLong2Long2(inV, out, false); 11642 out.destroy(); 11643 } catch (Exception e) { 11644 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString()); 11645 } 11646 try { 11647 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11648 scriptRelaxed.forEach_testConvertLong2Long2Long2(inV, out); 11649 verifyResultsConvertLong2Long2(inV, out, true); 11650 out.destroy(); 11651 } catch (Exception e) { 11652 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString()); 11653 } 11654 inV.destroy(); 11655 } 11656 11657 private void verifyResultsConvertLong2Long2(Allocation inV, Allocation out, boolean relaxed) { 11658 long[] arrayInV = new long[INPUTSIZE * 2]; 11659 Arrays.fill(arrayInV, (long) 42); 11660 inV.copyTo(arrayInV); 11661 long[] arrayOut = new long[INPUTSIZE * 2]; 11662 Arrays.fill(arrayOut, (long) 42); 11663 out.copyTo(arrayOut); 11664 StringBuilder message = new StringBuilder(); 11665 boolean errorFound = false; 11666 for (int i = 0; i < INPUTSIZE; i++) { 11667 for (int j = 0; j < 2 ; j++) { 11668 // Extract the inputs. 11669 ArgumentsLongLong args = new ArgumentsLongLong(); 11670 args.inV = arrayInV[i * 2 + j]; 11671 // Figure out what the outputs should have been. 11672 CoreMathVerifier.computeConvert(args); 11673 // Validate the outputs. 11674 boolean valid = true; 11675 if (args.out != arrayOut[i * 2 + j]) { 11676 valid = false; 11677 } 11678 if (!valid) { 11679 if (!errorFound) { 11680 errorFound = true; 11681 message.append("Input inV: "); 11682 appendVariableToMessage(message, args.inV); 11683 message.append("\n"); 11684 message.append("Expected output out: "); 11685 appendVariableToMessage(message, args.out); 11686 message.append("\n"); 11687 message.append("Actual output out: "); 11688 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11689 if (args.out != arrayOut[i * 2 + j]) { 11690 message.append(" FAIL"); 11691 } 11692 message.append("\n"); 11693 message.append("Errors at"); 11694 } 11695 message.append(" ["); 11696 message.append(Integer.toString(i)); 11697 message.append(", "); 11698 message.append(Integer.toString(j)); 11699 message.append("]"); 11700 } 11701 } 11702 } 11703 assertFalse("Incorrect output for checkConvertLong2Long2" + 11704 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11705 } 11706 11707 private void checkConvertLong3Long3() { 11708 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570d0a92724e91el, true, 63); 11709 try { 11710 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11711 script.forEach_testConvertLong3Long3Long3(inV, out); 11712 verifyResultsConvertLong3Long3(inV, out, false); 11713 out.destroy(); 11714 } catch (Exception e) { 11715 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString()); 11716 } 11717 try { 11718 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11719 scriptRelaxed.forEach_testConvertLong3Long3Long3(inV, out); 11720 verifyResultsConvertLong3Long3(inV, out, true); 11721 out.destroy(); 11722 } catch (Exception e) { 11723 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString()); 11724 } 11725 inV.destroy(); 11726 } 11727 11728 private void verifyResultsConvertLong3Long3(Allocation inV, Allocation out, boolean relaxed) { 11729 long[] arrayInV = new long[INPUTSIZE * 4]; 11730 Arrays.fill(arrayInV, (long) 42); 11731 inV.copyTo(arrayInV); 11732 long[] arrayOut = new long[INPUTSIZE * 4]; 11733 Arrays.fill(arrayOut, (long) 42); 11734 out.copyTo(arrayOut); 11735 StringBuilder message = new StringBuilder(); 11736 boolean errorFound = false; 11737 for (int i = 0; i < INPUTSIZE; i++) { 11738 for (int j = 0; j < 3 ; j++) { 11739 // Extract the inputs. 11740 ArgumentsLongLong args = new ArgumentsLongLong(); 11741 args.inV = arrayInV[i * 4 + j]; 11742 // Figure out what the outputs should have been. 11743 CoreMathVerifier.computeConvert(args); 11744 // Validate the outputs. 11745 boolean valid = true; 11746 if (args.out != arrayOut[i * 4 + j]) { 11747 valid = false; 11748 } 11749 if (!valid) { 11750 if (!errorFound) { 11751 errorFound = true; 11752 message.append("Input inV: "); 11753 appendVariableToMessage(message, args.inV); 11754 message.append("\n"); 11755 message.append("Expected output out: "); 11756 appendVariableToMessage(message, args.out); 11757 message.append("\n"); 11758 message.append("Actual output out: "); 11759 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11760 if (args.out != arrayOut[i * 4 + j]) { 11761 message.append(" FAIL"); 11762 } 11763 message.append("\n"); 11764 message.append("Errors at"); 11765 } 11766 message.append(" ["); 11767 message.append(Integer.toString(i)); 11768 message.append(", "); 11769 message.append(Integer.toString(j)); 11770 message.append("]"); 11771 } 11772 } 11773 } 11774 assertFalse("Incorrect output for checkConvertLong3Long3" + 11775 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11776 } 11777 11778 private void checkConvertLong4Long4() { 11779 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570db4a862cae12l, true, 63); 11780 try { 11781 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11782 script.forEach_testConvertLong4Long4Long4(inV, out); 11783 verifyResultsConvertLong4Long4(inV, out, false); 11784 out.destroy(); 11785 } catch (Exception e) { 11786 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString()); 11787 } 11788 try { 11789 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11790 scriptRelaxed.forEach_testConvertLong4Long4Long4(inV, out); 11791 verifyResultsConvertLong4Long4(inV, out, true); 11792 out.destroy(); 11793 } catch (Exception e) { 11794 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString()); 11795 } 11796 inV.destroy(); 11797 } 11798 11799 private void verifyResultsConvertLong4Long4(Allocation inV, Allocation out, boolean relaxed) { 11800 long[] arrayInV = new long[INPUTSIZE * 4]; 11801 Arrays.fill(arrayInV, (long) 42); 11802 inV.copyTo(arrayInV); 11803 long[] arrayOut = new long[INPUTSIZE * 4]; 11804 Arrays.fill(arrayOut, (long) 42); 11805 out.copyTo(arrayOut); 11806 StringBuilder message = new StringBuilder(); 11807 boolean errorFound = false; 11808 for (int i = 0; i < INPUTSIZE; i++) { 11809 for (int j = 0; j < 4 ; j++) { 11810 // Extract the inputs. 11811 ArgumentsLongLong args = new ArgumentsLongLong(); 11812 args.inV = arrayInV[i * 4 + j]; 11813 // Figure out what the outputs should have been. 11814 CoreMathVerifier.computeConvert(args); 11815 // Validate the outputs. 11816 boolean valid = true; 11817 if (args.out != arrayOut[i * 4 + j]) { 11818 valid = false; 11819 } 11820 if (!valid) { 11821 if (!errorFound) { 11822 errorFound = true; 11823 message.append("Input inV: "); 11824 appendVariableToMessage(message, args.inV); 11825 message.append("\n"); 11826 message.append("Expected output out: "); 11827 appendVariableToMessage(message, args.out); 11828 message.append("\n"); 11829 message.append("Actual output out: "); 11830 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11831 if (args.out != arrayOut[i * 4 + j]) { 11832 message.append(" FAIL"); 11833 } 11834 message.append("\n"); 11835 message.append("Errors at"); 11836 } 11837 message.append(" ["); 11838 message.append(Integer.toString(i)); 11839 message.append(", "); 11840 message.append(Integer.toString(j)); 11841 message.append("]"); 11842 } 11843 } 11844 } 11845 assertFalse("Incorrect output for checkConvertLong4Long4" + 11846 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11847 } 11848 11849 public class ArgumentsUlongLong { 11850 public long inV; 11851 public long out; 11852 } 11853 11854 private void checkConvertUlong2Long2() { 11855 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7f555a9f30abl, false, 63); 11856 try { 11857 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11858 script.forEach_testConvertLong2Ulong2Long2(inV, out); 11859 verifyResultsConvertUlong2Long2(inV, out, false); 11860 out.destroy(); 11861 } catch (Exception e) { 11862 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString()); 11863 } 11864 try { 11865 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11866 scriptRelaxed.forEach_testConvertLong2Ulong2Long2(inV, out); 11867 verifyResultsConvertUlong2Long2(inV, out, true); 11868 out.destroy(); 11869 } catch (Exception e) { 11870 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString()); 11871 } 11872 inV.destroy(); 11873 } 11874 11875 private void verifyResultsConvertUlong2Long2(Allocation inV, Allocation out, boolean relaxed) { 11876 long[] arrayInV = new long[INPUTSIZE * 2]; 11877 Arrays.fill(arrayInV, (long) 42); 11878 inV.copyTo(arrayInV); 11879 long[] arrayOut = new long[INPUTSIZE * 2]; 11880 Arrays.fill(arrayOut, (long) 42); 11881 out.copyTo(arrayOut); 11882 StringBuilder message = new StringBuilder(); 11883 boolean errorFound = false; 11884 for (int i = 0; i < INPUTSIZE; i++) { 11885 for (int j = 0; j < 2 ; j++) { 11886 // Extract the inputs. 11887 ArgumentsUlongLong args = new ArgumentsUlongLong(); 11888 args.inV = arrayInV[i * 2 + j]; 11889 // Figure out what the outputs should have been. 11890 CoreMathVerifier.computeConvert(args); 11891 // Validate the outputs. 11892 boolean valid = true; 11893 if (args.out != arrayOut[i * 2 + j]) { 11894 valid = false; 11895 } 11896 if (!valid) { 11897 if (!errorFound) { 11898 errorFound = true; 11899 message.append("Input inV: "); 11900 appendVariableToMessage(message, args.inV); 11901 message.append("\n"); 11902 message.append("Expected output out: "); 11903 appendVariableToMessage(message, args.out); 11904 message.append("\n"); 11905 message.append("Actual output out: "); 11906 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11907 if (args.out != arrayOut[i * 2 + j]) { 11908 message.append(" FAIL"); 11909 } 11910 message.append("\n"); 11911 message.append("Errors at"); 11912 } 11913 message.append(" ["); 11914 message.append(Integer.toString(i)); 11915 message.append(", "); 11916 message.append(Integer.toString(j)); 11917 message.append("]"); 11918 } 11919 } 11920 } 11921 assertFalse("Incorrect output for checkConvertUlong2Long2" + 11922 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11923 } 11924 11925 private void checkConvertUlong3Long3() { 11926 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe89f6b9a6f59fl, false, 63); 11927 try { 11928 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11929 script.forEach_testConvertLong3Ulong3Long3(inV, out); 11930 verifyResultsConvertUlong3Long3(inV, out, false); 11931 out.destroy(); 11932 } catch (Exception e) { 11933 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString()); 11934 } 11935 try { 11936 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11937 scriptRelaxed.forEach_testConvertLong3Ulong3Long3(inV, out); 11938 verifyResultsConvertUlong3Long3(inV, out, true); 11939 out.destroy(); 11940 } catch (Exception e) { 11941 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString()); 11942 } 11943 inV.destroy(); 11944 } 11945 11946 private void verifyResultsConvertUlong3Long3(Allocation inV, Allocation out, boolean relaxed) { 11947 long[] arrayInV = new long[INPUTSIZE * 4]; 11948 Arrays.fill(arrayInV, (long) 42); 11949 inV.copyTo(arrayInV); 11950 long[] arrayOut = new long[INPUTSIZE * 4]; 11951 Arrays.fill(arrayOut, (long) 42); 11952 out.copyTo(arrayOut); 11953 StringBuilder message = new StringBuilder(); 11954 boolean errorFound = false; 11955 for (int i = 0; i < INPUTSIZE; i++) { 11956 for (int j = 0; j < 3 ; j++) { 11957 // Extract the inputs. 11958 ArgumentsUlongLong args = new ArgumentsUlongLong(); 11959 args.inV = arrayInV[i * 4 + j]; 11960 // Figure out what the outputs should have been. 11961 CoreMathVerifier.computeConvert(args); 11962 // Validate the outputs. 11963 boolean valid = true; 11964 if (args.out != arrayOut[i * 4 + j]) { 11965 valid = false; 11966 } 11967 if (!valid) { 11968 if (!errorFound) { 11969 errorFound = true; 11970 message.append("Input inV: "); 11971 appendVariableToMessage(message, args.inV); 11972 message.append("\n"); 11973 message.append("Expected output out: "); 11974 appendVariableToMessage(message, args.out); 11975 message.append("\n"); 11976 message.append("Actual output out: "); 11977 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11978 if (args.out != arrayOut[i * 4 + j]) { 11979 message.append(" FAIL"); 11980 } 11981 message.append("\n"); 11982 message.append("Errors at"); 11983 } 11984 message.append(" ["); 11985 message.append(Integer.toString(i)); 11986 message.append(", "); 11987 message.append(Integer.toString(j)); 11988 message.append("]"); 11989 } 11990 } 11991 } 11992 assertFalse("Incorrect output for checkConvertUlong3Long3" + 11993 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11994 } 11995 11996 private void checkConvertUlong4Long4() { 11997 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe949818aeba93l, false, 63); 11998 try { 11999 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 12000 script.forEach_testConvertLong4Ulong4Long4(inV, out); 12001 verifyResultsConvertUlong4Long4(inV, out, false); 12002 out.destroy(); 12003 } catch (Exception e) { 12004 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString()); 12005 } 12006 try { 12007 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 12008 scriptRelaxed.forEach_testConvertLong4Ulong4Long4(inV, out); 12009 verifyResultsConvertUlong4Long4(inV, out, true); 12010 out.destroy(); 12011 } catch (Exception e) { 12012 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString()); 12013 } 12014 inV.destroy(); 12015 } 12016 12017 private void verifyResultsConvertUlong4Long4(Allocation inV, Allocation out, boolean relaxed) { 12018 long[] arrayInV = new long[INPUTSIZE * 4]; 12019 Arrays.fill(arrayInV, (long) 42); 12020 inV.copyTo(arrayInV); 12021 long[] arrayOut = new long[INPUTSIZE * 4]; 12022 Arrays.fill(arrayOut, (long) 42); 12023 out.copyTo(arrayOut); 12024 StringBuilder message = new StringBuilder(); 12025 boolean errorFound = false; 12026 for (int i = 0; i < INPUTSIZE; i++) { 12027 for (int j = 0; j < 4 ; j++) { 12028 // Extract the inputs. 12029 ArgumentsUlongLong args = new ArgumentsUlongLong(); 12030 args.inV = arrayInV[i * 4 + j]; 12031 // Figure out what the outputs should have been. 12032 CoreMathVerifier.computeConvert(args); 12033 // Validate the outputs. 12034 boolean valid = true; 12035 if (args.out != arrayOut[i * 4 + j]) { 12036 valid = false; 12037 } 12038 if (!valid) { 12039 if (!errorFound) { 12040 errorFound = true; 12041 message.append("Input inV: "); 12042 appendVariableToMessage(message, args.inV); 12043 message.append("\n"); 12044 message.append("Expected output out: "); 12045 appendVariableToMessage(message, args.out); 12046 message.append("\n"); 12047 message.append("Actual output out: "); 12048 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12049 if (args.out != arrayOut[i * 4 + j]) { 12050 message.append(" FAIL"); 12051 } 12052 message.append("\n"); 12053 message.append("Errors at"); 12054 } 12055 message.append(" ["); 12056 message.append(Integer.toString(i)); 12057 message.append(", "); 12058 message.append(Integer.toString(j)); 12059 message.append("]"); 12060 } 12061 } 12062 } 12063 assertFalse("Incorrect output for checkConvertUlong4Long4" + 12064 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12065 } 12066 12067 public class ArgumentsDoubleUlong { 12068 public double inV; 12069 public long out; 12070 } 12071 12072 private void checkConvertDouble2Ulong2() { 12073 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b56e3b7e12ff5el, 0.0000000000000000000e+00, 1.8446744073709549568e+19); 12074 try { 12075 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 12076 script.forEach_testConvertUlong2Double2Ulong2(inV, out); 12077 verifyResultsConvertDouble2Ulong2(inV, out, false); 12078 out.destroy(); 12079 } catch (Exception e) { 12080 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString()); 12081 } 12082 try { 12083 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 12084 scriptRelaxed.forEach_testConvertUlong2Double2Ulong2(inV, out); 12085 verifyResultsConvertDouble2Ulong2(inV, out, true); 12086 out.destroy(); 12087 } catch (Exception e) { 12088 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString()); 12089 } 12090 inV.destroy(); 12091 } 12092 12093 private void verifyResultsConvertDouble2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 12094 double[] arrayInV = new double[INPUTSIZE * 2]; 12095 Arrays.fill(arrayInV, (double) 42); 12096 inV.copyTo(arrayInV); 12097 long[] arrayOut = new long[INPUTSIZE * 2]; 12098 Arrays.fill(arrayOut, (long) 42); 12099 out.copyTo(arrayOut); 12100 StringBuilder message = new StringBuilder(); 12101 boolean errorFound = false; 12102 for (int i = 0; i < INPUTSIZE; i++) { 12103 for (int j = 0; j < 2 ; j++) { 12104 // Extract the inputs. 12105 ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); 12106 args.inV = arrayInV[i * 2 + j]; 12107 // Figure out what the outputs should have been. 12108 CoreMathVerifier.computeConvert(args); 12109 // Validate the outputs. 12110 boolean valid = true; 12111 if (args.out != arrayOut[i * 2 + j]) { 12112 valid = false; 12113 } 12114 if (!valid) { 12115 if (!errorFound) { 12116 errorFound = true; 12117 message.append("Input inV: "); 12118 appendVariableToMessage(message, args.inV); 12119 message.append("\n"); 12120 message.append("Expected output out: "); 12121 appendVariableToMessage(message, args.out); 12122 message.append("\n"); 12123 message.append("Actual output out: "); 12124 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12125 if (args.out != arrayOut[i * 2 + j]) { 12126 message.append(" FAIL"); 12127 } 12128 message.append("\n"); 12129 message.append("Errors at"); 12130 } 12131 message.append(" ["); 12132 message.append(Integer.toString(i)); 12133 message.append(", "); 12134 message.append(Integer.toString(j)); 12135 message.append("]"); 12136 } 12137 } 12138 } 12139 assertFalse("Incorrect output for checkConvertDouble2Ulong2" + 12140 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12141 } 12142 12143 private void checkConvertDouble3Ulong3() { 12144 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b73756742e203cl, 0.0000000000000000000e+00, 1.8446744073709549568e+19); 12145 try { 12146 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12147 script.forEach_testConvertUlong3Double3Ulong3(inV, out); 12148 verifyResultsConvertDouble3Ulong3(inV, out, false); 12149 out.destroy(); 12150 } catch (Exception e) { 12151 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString()); 12152 } 12153 try { 12154 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12155 scriptRelaxed.forEach_testConvertUlong3Double3Ulong3(inV, out); 12156 verifyResultsConvertDouble3Ulong3(inV, out, true); 12157 out.destroy(); 12158 } catch (Exception e) { 12159 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString()); 12160 } 12161 inV.destroy(); 12162 } 12163 12164 private void verifyResultsConvertDouble3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 12165 double[] arrayInV = new double[INPUTSIZE * 4]; 12166 Arrays.fill(arrayInV, (double) 42); 12167 inV.copyTo(arrayInV); 12168 long[] arrayOut = new long[INPUTSIZE * 4]; 12169 Arrays.fill(arrayOut, (long) 42); 12170 out.copyTo(arrayOut); 12171 StringBuilder message = new StringBuilder(); 12172 boolean errorFound = false; 12173 for (int i = 0; i < INPUTSIZE; i++) { 12174 for (int j = 0; j < 3 ; j++) { 12175 // Extract the inputs. 12176 ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); 12177 args.inV = arrayInV[i * 4 + j]; 12178 // Figure out what the outputs should have been. 12179 CoreMathVerifier.computeConvert(args); 12180 // Validate the outputs. 12181 boolean valid = true; 12182 if (args.out != arrayOut[i * 4 + j]) { 12183 valid = false; 12184 } 12185 if (!valid) { 12186 if (!errorFound) { 12187 errorFound = true; 12188 message.append("Input inV: "); 12189 appendVariableToMessage(message, args.inV); 12190 message.append("\n"); 12191 message.append("Expected output out: "); 12192 appendVariableToMessage(message, args.out); 12193 message.append("\n"); 12194 message.append("Actual output out: "); 12195 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12196 if (args.out != arrayOut[i * 4 + j]) { 12197 message.append(" FAIL"); 12198 } 12199 message.append("\n"); 12200 message.append("Errors at"); 12201 } 12202 message.append(" ["); 12203 message.append(Integer.toString(i)); 12204 message.append(", "); 12205 message.append(Integer.toString(j)); 12206 message.append("]"); 12207 } 12208 } 12209 } 12210 assertFalse("Incorrect output for checkConvertDouble3Ulong3" + 12211 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12212 } 12213 12214 private void checkConvertDouble4Ulong4() { 12215 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b900716a49411al, 0.0000000000000000000e+00, 1.8446744073709549568e+19); 12216 try { 12217 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12218 script.forEach_testConvertUlong4Double4Ulong4(inV, out); 12219 verifyResultsConvertDouble4Ulong4(inV, out, false); 12220 out.destroy(); 12221 } catch (Exception e) { 12222 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString()); 12223 } 12224 try { 12225 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12226 scriptRelaxed.forEach_testConvertUlong4Double4Ulong4(inV, out); 12227 verifyResultsConvertDouble4Ulong4(inV, out, true); 12228 out.destroy(); 12229 } catch (Exception e) { 12230 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString()); 12231 } 12232 inV.destroy(); 12233 } 12234 12235 private void verifyResultsConvertDouble4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 12236 double[] arrayInV = new double[INPUTSIZE * 4]; 12237 Arrays.fill(arrayInV, (double) 42); 12238 inV.copyTo(arrayInV); 12239 long[] arrayOut = new long[INPUTSIZE * 4]; 12240 Arrays.fill(arrayOut, (long) 42); 12241 out.copyTo(arrayOut); 12242 StringBuilder message = new StringBuilder(); 12243 boolean errorFound = false; 12244 for (int i = 0; i < INPUTSIZE; i++) { 12245 for (int j = 0; j < 4 ; j++) { 12246 // Extract the inputs. 12247 ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); 12248 args.inV = arrayInV[i * 4 + j]; 12249 // Figure out what the outputs should have been. 12250 CoreMathVerifier.computeConvert(args); 12251 // Validate the outputs. 12252 boolean valid = true; 12253 if (args.out != arrayOut[i * 4 + j]) { 12254 valid = false; 12255 } 12256 if (!valid) { 12257 if (!errorFound) { 12258 errorFound = true; 12259 message.append("Input inV: "); 12260 appendVariableToMessage(message, args.inV); 12261 message.append("\n"); 12262 message.append("Expected output out: "); 12263 appendVariableToMessage(message, args.out); 12264 message.append("\n"); 12265 message.append("Actual output out: "); 12266 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12267 if (args.out != arrayOut[i * 4 + j]) { 12268 message.append(" FAIL"); 12269 } 12270 message.append("\n"); 12271 message.append("Errors at"); 12272 } 12273 message.append(" ["); 12274 message.append(Integer.toString(i)); 12275 message.append(", "); 12276 message.append(Integer.toString(j)); 12277 message.append("]"); 12278 } 12279 } 12280 } 12281 assertFalse("Incorrect output for checkConvertDouble4Ulong4" + 12282 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12283 } 12284 12285 public class ArgumentsLongUlong { 12286 public long inV; 12287 public long out; 12288 } 12289 12290 private void checkConvertLong2Ulong2() { 12291 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f1a23ed7d40f65l, false, 63); 12292 try { 12293 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 12294 script.forEach_testConvertUlong2Long2Ulong2(inV, out); 12295 verifyResultsConvertLong2Ulong2(inV, out, false); 12296 out.destroy(); 12297 } catch (Exception e) { 12298 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString()); 12299 } 12300 try { 12301 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 12302 scriptRelaxed.forEach_testConvertUlong2Long2Ulong2(inV, out); 12303 verifyResultsConvertLong2Ulong2(inV, out, true); 12304 out.destroy(); 12305 } catch (Exception e) { 12306 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString()); 12307 } 12308 inV.destroy(); 12309 } 12310 12311 private void verifyResultsConvertLong2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 12312 long[] arrayInV = new long[INPUTSIZE * 2]; 12313 Arrays.fill(arrayInV, (long) 42); 12314 inV.copyTo(arrayInV); 12315 long[] arrayOut = new long[INPUTSIZE * 2]; 12316 Arrays.fill(arrayOut, (long) 42); 12317 out.copyTo(arrayOut); 12318 StringBuilder message = new StringBuilder(); 12319 boolean errorFound = false; 12320 for (int i = 0; i < INPUTSIZE; i++) { 12321 for (int j = 0; j < 2 ; j++) { 12322 // Extract the inputs. 12323 ArgumentsLongUlong args = new ArgumentsLongUlong(); 12324 args.inV = arrayInV[i * 2 + j]; 12325 // Figure out what the outputs should have been. 12326 CoreMathVerifier.computeConvert(args); 12327 // Validate the outputs. 12328 boolean valid = true; 12329 if (args.out != arrayOut[i * 2 + j]) { 12330 valid = false; 12331 } 12332 if (!valid) { 12333 if (!errorFound) { 12334 errorFound = true; 12335 message.append("Input inV: "); 12336 appendVariableToMessage(message, args.inV); 12337 message.append("\n"); 12338 message.append("Expected output out: "); 12339 appendVariableToMessage(message, args.out); 12340 message.append("\n"); 12341 message.append("Actual output out: "); 12342 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12343 if (args.out != arrayOut[i * 2 + j]) { 12344 message.append(" FAIL"); 12345 } 12346 message.append("\n"); 12347 message.append("Errors at"); 12348 } 12349 message.append(" ["); 12350 message.append(Integer.toString(i)); 12351 message.append(", "); 12352 message.append(Integer.toString(j)); 12353 message.append("]"); 12354 } 12355 } 12356 } 12357 assertFalse("Incorrect output for checkConvertLong2Ulong2" + 12358 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12359 } 12360 12361 private void checkConvertLong3Ulong3() { 12362 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f36b59cdef3043l, false, 63); 12363 try { 12364 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12365 script.forEach_testConvertUlong3Long3Ulong3(inV, out); 12366 verifyResultsConvertLong3Ulong3(inV, out, false); 12367 out.destroy(); 12368 } catch (Exception e) { 12369 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString()); 12370 } 12371 try { 12372 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12373 scriptRelaxed.forEach_testConvertUlong3Long3Ulong3(inV, out); 12374 verifyResultsConvertLong3Ulong3(inV, out, true); 12375 out.destroy(); 12376 } catch (Exception e) { 12377 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString()); 12378 } 12379 inV.destroy(); 12380 } 12381 12382 private void verifyResultsConvertLong3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 12383 long[] arrayInV = new long[INPUTSIZE * 4]; 12384 Arrays.fill(arrayInV, (long) 42); 12385 inV.copyTo(arrayInV); 12386 long[] arrayOut = new long[INPUTSIZE * 4]; 12387 Arrays.fill(arrayOut, (long) 42); 12388 out.copyTo(arrayOut); 12389 StringBuilder message = new StringBuilder(); 12390 boolean errorFound = false; 12391 for (int i = 0; i < INPUTSIZE; i++) { 12392 for (int j = 0; j < 3 ; j++) { 12393 // Extract the inputs. 12394 ArgumentsLongUlong args = new ArgumentsLongUlong(); 12395 args.inV = arrayInV[i * 4 + j]; 12396 // Figure out what the outputs should have been. 12397 CoreMathVerifier.computeConvert(args); 12398 // Validate the outputs. 12399 boolean valid = true; 12400 if (args.out != arrayOut[i * 4 + j]) { 12401 valid = false; 12402 } 12403 if (!valid) { 12404 if (!errorFound) { 12405 errorFound = true; 12406 message.append("Input inV: "); 12407 appendVariableToMessage(message, args.inV); 12408 message.append("\n"); 12409 message.append("Expected output out: "); 12410 appendVariableToMessage(message, args.out); 12411 message.append("\n"); 12412 message.append("Actual output out: "); 12413 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12414 if (args.out != arrayOut[i * 4 + j]) { 12415 message.append(" FAIL"); 12416 } 12417 message.append("\n"); 12418 message.append("Errors at"); 12419 } 12420 message.append(" ["); 12421 message.append(Integer.toString(i)); 12422 message.append(", "); 12423 message.append(Integer.toString(j)); 12424 message.append("]"); 12425 } 12426 } 12427 } 12428 assertFalse("Incorrect output for checkConvertLong3Ulong3" + 12429 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12430 } 12431 12432 private void checkConvertLong4Ulong4() { 12433 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f53474c40a5121l, false, 63); 12434 try { 12435 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12436 script.forEach_testConvertUlong4Long4Ulong4(inV, out); 12437 verifyResultsConvertLong4Ulong4(inV, out, false); 12438 out.destroy(); 12439 } catch (Exception e) { 12440 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString()); 12441 } 12442 try { 12443 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12444 scriptRelaxed.forEach_testConvertUlong4Long4Ulong4(inV, out); 12445 verifyResultsConvertLong4Ulong4(inV, out, true); 12446 out.destroy(); 12447 } catch (Exception e) { 12448 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString()); 12449 } 12450 inV.destroy(); 12451 } 12452 12453 private void verifyResultsConvertLong4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 12454 long[] arrayInV = new long[INPUTSIZE * 4]; 12455 Arrays.fill(arrayInV, (long) 42); 12456 inV.copyTo(arrayInV); 12457 long[] arrayOut = new long[INPUTSIZE * 4]; 12458 Arrays.fill(arrayOut, (long) 42); 12459 out.copyTo(arrayOut); 12460 StringBuilder message = new StringBuilder(); 12461 boolean errorFound = false; 12462 for (int i = 0; i < INPUTSIZE; i++) { 12463 for (int j = 0; j < 4 ; j++) { 12464 // Extract the inputs. 12465 ArgumentsLongUlong args = new ArgumentsLongUlong(); 12466 args.inV = arrayInV[i * 4 + j]; 12467 // Figure out what the outputs should have been. 12468 CoreMathVerifier.computeConvert(args); 12469 // Validate the outputs. 12470 boolean valid = true; 12471 if (args.out != arrayOut[i * 4 + j]) { 12472 valid = false; 12473 } 12474 if (!valid) { 12475 if (!errorFound) { 12476 errorFound = true; 12477 message.append("Input inV: "); 12478 appendVariableToMessage(message, args.inV); 12479 message.append("\n"); 12480 message.append("Expected output out: "); 12481 appendVariableToMessage(message, args.out); 12482 message.append("\n"); 12483 message.append("Actual output out: "); 12484 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12485 if (args.out != arrayOut[i * 4 + j]) { 12486 message.append(" FAIL"); 12487 } 12488 message.append("\n"); 12489 message.append("Errors at"); 12490 } 12491 message.append(" ["); 12492 message.append(Integer.toString(i)); 12493 message.append(", "); 12494 message.append(Integer.toString(j)); 12495 message.append("]"); 12496 } 12497 } 12498 } 12499 assertFalse("Incorrect output for checkConvertLong4Ulong4" + 12500 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12501 } 12502 12503 public class ArgumentsUlongUlong { 12504 public long inV; 12505 public long out; 12506 } 12507 12508 private void checkConvertUlong2Ulong2() { 12509 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfc24673ac2910l, false, 64); 12510 try { 12511 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 12512 script.forEach_testConvertUlong2Ulong2Ulong2(inV, out); 12513 verifyResultsConvertUlong2Ulong2(inV, out, false); 12514 out.destroy(); 12515 } catch (Exception e) { 12516 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString()); 12517 } 12518 try { 12519 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 12520 scriptRelaxed.forEach_testConvertUlong2Ulong2Ulong2(inV, out); 12521 verifyResultsConvertUlong2Ulong2(inV, out, true); 12522 out.destroy(); 12523 } catch (Exception e) { 12524 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString()); 12525 } 12526 inV.destroy(); 12527 } 12528 12529 private void verifyResultsConvertUlong2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 12530 long[] arrayInV = new long[INPUTSIZE * 2]; 12531 Arrays.fill(arrayInV, (long) 42); 12532 inV.copyTo(arrayInV); 12533 long[] arrayOut = new long[INPUTSIZE * 2]; 12534 Arrays.fill(arrayOut, (long) 42); 12535 out.copyTo(arrayOut); 12536 StringBuilder message = new StringBuilder(); 12537 boolean errorFound = false; 12538 for (int i = 0; i < INPUTSIZE; i++) { 12539 for (int j = 0; j < 2 ; j++) { 12540 // Extract the inputs. 12541 ArgumentsUlongUlong args = new ArgumentsUlongUlong(); 12542 args.inV = arrayInV[i * 2 + j]; 12543 // Figure out what the outputs should have been. 12544 CoreMathVerifier.computeConvert(args); 12545 // Validate the outputs. 12546 boolean valid = true; 12547 if (args.out != arrayOut[i * 2 + j]) { 12548 valid = false; 12549 } 12550 if (!valid) { 12551 if (!errorFound) { 12552 errorFound = true; 12553 message.append("Input inV: "); 12554 appendVariableToMessage(message, args.inV); 12555 message.append("\n"); 12556 message.append("Expected output out: "); 12557 appendVariableToMessage(message, args.out); 12558 message.append("\n"); 12559 message.append("Actual output out: "); 12560 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12561 if (args.out != arrayOut[i * 2 + j]) { 12562 message.append(" FAIL"); 12563 } 12564 message.append("\n"); 12565 message.append("Errors at"); 12566 } 12567 message.append(" ["); 12568 message.append(Integer.toString(i)); 12569 message.append(", "); 12570 message.append(Integer.toString(j)); 12571 message.append("]"); 12572 } 12573 } 12574 } 12575 assertFalse("Incorrect output for checkConvertUlong2Ulong2" + 12576 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12577 } 12578 12579 private void checkConvertUlong3Ulong3() { 12580 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec18b6169c749eel, false, 64); 12581 try { 12582 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12583 script.forEach_testConvertUlong3Ulong3Ulong3(inV, out); 12584 verifyResultsConvertUlong3Ulong3(inV, out, false); 12585 out.destroy(); 12586 } catch (Exception e) { 12587 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString()); 12588 } 12589 try { 12590 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12591 scriptRelaxed.forEach_testConvertUlong3Ulong3Ulong3(inV, out); 12592 verifyResultsConvertUlong3Ulong3(inV, out, true); 12593 out.destroy(); 12594 } catch (Exception e) { 12595 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString()); 12596 } 12597 inV.destroy(); 12598 } 12599 12600 private void verifyResultsConvertUlong3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 12601 long[] arrayInV = new long[INPUTSIZE * 4]; 12602 Arrays.fill(arrayInV, (long) 42); 12603 inV.copyTo(arrayInV); 12604 long[] arrayOut = new long[INPUTSIZE * 4]; 12605 Arrays.fill(arrayOut, (long) 42); 12606 out.copyTo(arrayOut); 12607 StringBuilder message = new StringBuilder(); 12608 boolean errorFound = false; 12609 for (int i = 0; i < INPUTSIZE; i++) { 12610 for (int j = 0; j < 3 ; j++) { 12611 // Extract the inputs. 12612 ArgumentsUlongUlong args = new ArgumentsUlongUlong(); 12613 args.inV = arrayInV[i * 4 + j]; 12614 // Figure out what the outputs should have been. 12615 CoreMathVerifier.computeConvert(args); 12616 // Validate the outputs. 12617 boolean valid = true; 12618 if (args.out != arrayOut[i * 4 + j]) { 12619 valid = false; 12620 } 12621 if (!valid) { 12622 if (!errorFound) { 12623 errorFound = true; 12624 message.append("Input inV: "); 12625 appendVariableToMessage(message, args.inV); 12626 message.append("\n"); 12627 message.append("Expected output out: "); 12628 appendVariableToMessage(message, args.out); 12629 message.append("\n"); 12630 message.append("Actual output out: "); 12631 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12632 if (args.out != arrayOut[i * 4 + j]) { 12633 message.append(" FAIL"); 12634 } 12635 message.append("\n"); 12636 message.append("Errors at"); 12637 } 12638 message.append(" ["); 12639 message.append(Integer.toString(i)); 12640 message.append(", "); 12641 message.append(Integer.toString(j)); 12642 message.append("]"); 12643 } 12644 } 12645 } 12646 assertFalse("Incorrect output for checkConvertUlong3Ulong3" + 12647 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12648 } 12649 12650 private void checkConvertUlong4Ulong4() { 12651 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec3547c5fe26accl, false, 64); 12652 try { 12653 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12654 script.forEach_testConvertUlong4Ulong4Ulong4(inV, out); 12655 verifyResultsConvertUlong4Ulong4(inV, out, false); 12656 out.destroy(); 12657 } catch (Exception e) { 12658 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString()); 12659 } 12660 try { 12661 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12662 scriptRelaxed.forEach_testConvertUlong4Ulong4Ulong4(inV, out); 12663 verifyResultsConvertUlong4Ulong4(inV, out, true); 12664 out.destroy(); 12665 } catch (Exception e) { 12666 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString()); 12667 } 12668 inV.destroy(); 12669 } 12670 12671 private void verifyResultsConvertUlong4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 12672 long[] arrayInV = new long[INPUTSIZE * 4]; 12673 Arrays.fill(arrayInV, (long) 42); 12674 inV.copyTo(arrayInV); 12675 long[] arrayOut = new long[INPUTSIZE * 4]; 12676 Arrays.fill(arrayOut, (long) 42); 12677 out.copyTo(arrayOut); 12678 StringBuilder message = new StringBuilder(); 12679 boolean errorFound = false; 12680 for (int i = 0; i < INPUTSIZE; i++) { 12681 for (int j = 0; j < 4 ; j++) { 12682 // Extract the inputs. 12683 ArgumentsUlongUlong args = new ArgumentsUlongUlong(); 12684 args.inV = arrayInV[i * 4 + j]; 12685 // Figure out what the outputs should have been. 12686 CoreMathVerifier.computeConvert(args); 12687 // Validate the outputs. 12688 boolean valid = true; 12689 if (args.out != arrayOut[i * 4 + j]) { 12690 valid = false; 12691 } 12692 if (!valid) { 12693 if (!errorFound) { 12694 errorFound = true; 12695 message.append("Input inV: "); 12696 appendVariableToMessage(message, args.inV); 12697 message.append("\n"); 12698 message.append("Expected output out: "); 12699 appendVariableToMessage(message, args.out); 12700 message.append("\n"); 12701 message.append("Actual output out: "); 12702 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12703 if (args.out != arrayOut[i * 4 + j]) { 12704 message.append(" FAIL"); 12705 } 12706 message.append("\n"); 12707 message.append("Errors at"); 12708 } 12709 message.append(" ["); 12710 message.append(Integer.toString(i)); 12711 message.append(", "); 12712 message.append(Integer.toString(j)); 12713 message.append("]"); 12714 } 12715 } 12716 } 12717 assertFalse("Incorrect output for checkConvertUlong4Ulong4" + 12718 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12719 } 12720 12721 public class ArgumentsDoubleFloat { 12722 public double inV; 12723 public Target.Floaty out; 12724 } 12725 12726 private void checkConvertDouble2Float2() { 12727 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b4cec67d6d9a2dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 12728 try { 12729 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12730 script.forEach_testConvertFloat2Double2Float2(inV, out); 12731 verifyResultsConvertDouble2Float2(inV, out, false); 12732 out.destroy(); 12733 } catch (Exception e) { 12734 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString()); 12735 } 12736 try { 12737 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12738 scriptRelaxed.forEach_testConvertFloat2Double2Float2(inV, out); 12739 verifyResultsConvertDouble2Float2(inV, out, true); 12740 out.destroy(); 12741 } catch (Exception e) { 12742 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString()); 12743 } 12744 inV.destroy(); 12745 } 12746 12747 private void verifyResultsConvertDouble2Float2(Allocation inV, Allocation out, boolean relaxed) { 12748 double[] arrayInV = new double[INPUTSIZE * 2]; 12749 Arrays.fill(arrayInV, (double) 42); 12750 inV.copyTo(arrayInV); 12751 float[] arrayOut = new float[INPUTSIZE * 2]; 12752 Arrays.fill(arrayOut, (float) 42); 12753 out.copyTo(arrayOut); 12754 StringBuilder message = new StringBuilder(); 12755 boolean errorFound = false; 12756 for (int i = 0; i < INPUTSIZE; i++) { 12757 for (int j = 0; j < 2 ; j++) { 12758 // Extract the inputs. 12759 ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); 12760 args.inV = arrayInV[i * 2 + j]; 12761 // Figure out what the outputs should have been. 12762 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12763 CoreMathVerifier.computeConvert(args, target); 12764 // Validate the outputs. 12765 boolean valid = true; 12766 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12767 valid = false; 12768 } 12769 if (!valid) { 12770 if (!errorFound) { 12771 errorFound = true; 12772 message.append("Input inV: "); 12773 appendVariableToMessage(message, args.inV); 12774 message.append("\n"); 12775 message.append("Expected output out: "); 12776 appendVariableToMessage(message, args.out); 12777 message.append("\n"); 12778 message.append("Actual output out: "); 12779 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12780 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12781 message.append(" FAIL"); 12782 } 12783 message.append("\n"); 12784 message.append("Errors at"); 12785 } 12786 message.append(" ["); 12787 message.append(Integer.toString(i)); 12788 message.append(", "); 12789 message.append(Integer.toString(j)); 12790 message.append("]"); 12791 } 12792 } 12793 } 12794 assertFalse("Incorrect output for checkConvertDouble2Float2" + 12795 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12796 } 12797 12798 private void checkConvertDouble3Float3() { 12799 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b697e17388bb0bl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 12800 try { 12801 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12802 script.forEach_testConvertFloat3Double3Float3(inV, out); 12803 verifyResultsConvertDouble3Float3(inV, out, false); 12804 out.destroy(); 12805 } catch (Exception e) { 12806 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString()); 12807 } 12808 try { 12809 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12810 scriptRelaxed.forEach_testConvertFloat3Double3Float3(inV, out); 12811 verifyResultsConvertDouble3Float3(inV, out, true); 12812 out.destroy(); 12813 } catch (Exception e) { 12814 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString()); 12815 } 12816 inV.destroy(); 12817 } 12818 12819 private void verifyResultsConvertDouble3Float3(Allocation inV, Allocation out, boolean relaxed) { 12820 double[] arrayInV = new double[INPUTSIZE * 4]; 12821 Arrays.fill(arrayInV, (double) 42); 12822 inV.copyTo(arrayInV); 12823 float[] arrayOut = new float[INPUTSIZE * 4]; 12824 Arrays.fill(arrayOut, (float) 42); 12825 out.copyTo(arrayOut); 12826 StringBuilder message = new StringBuilder(); 12827 boolean errorFound = false; 12828 for (int i = 0; i < INPUTSIZE; i++) { 12829 for (int j = 0; j < 3 ; j++) { 12830 // Extract the inputs. 12831 ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); 12832 args.inV = arrayInV[i * 4 + j]; 12833 // Figure out what the outputs should have been. 12834 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12835 CoreMathVerifier.computeConvert(args, target); 12836 // Validate the outputs. 12837 boolean valid = true; 12838 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12839 valid = false; 12840 } 12841 if (!valid) { 12842 if (!errorFound) { 12843 errorFound = true; 12844 message.append("Input inV: "); 12845 appendVariableToMessage(message, args.inV); 12846 message.append("\n"); 12847 message.append("Expected output out: "); 12848 appendVariableToMessage(message, args.out); 12849 message.append("\n"); 12850 message.append("Actual output out: "); 12851 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12852 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12853 message.append(" FAIL"); 12854 } 12855 message.append("\n"); 12856 message.append("Errors at"); 12857 } 12858 message.append(" ["); 12859 message.append(Integer.toString(i)); 12860 message.append(", "); 12861 message.append(Integer.toString(j)); 12862 message.append("]"); 12863 } 12864 } 12865 } 12866 assertFalse("Incorrect output for checkConvertDouble3Float3" + 12867 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12868 } 12869 12870 private void checkConvertDouble4Float4() { 12871 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b860fc69a3dbe9l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 12872 try { 12873 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12874 script.forEach_testConvertFloat4Double4Float4(inV, out); 12875 verifyResultsConvertDouble4Float4(inV, out, false); 12876 out.destroy(); 12877 } catch (Exception e) { 12878 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString()); 12879 } 12880 try { 12881 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12882 scriptRelaxed.forEach_testConvertFloat4Double4Float4(inV, out); 12883 verifyResultsConvertDouble4Float4(inV, out, true); 12884 out.destroy(); 12885 } catch (Exception e) { 12886 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString()); 12887 } 12888 inV.destroy(); 12889 } 12890 12891 private void verifyResultsConvertDouble4Float4(Allocation inV, Allocation out, boolean relaxed) { 12892 double[] arrayInV = new double[INPUTSIZE * 4]; 12893 Arrays.fill(arrayInV, (double) 42); 12894 inV.copyTo(arrayInV); 12895 float[] arrayOut = new float[INPUTSIZE * 4]; 12896 Arrays.fill(arrayOut, (float) 42); 12897 out.copyTo(arrayOut); 12898 StringBuilder message = new StringBuilder(); 12899 boolean errorFound = false; 12900 for (int i = 0; i < INPUTSIZE; i++) { 12901 for (int j = 0; j < 4 ; j++) { 12902 // Extract the inputs. 12903 ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); 12904 args.inV = arrayInV[i * 4 + j]; 12905 // Figure out what the outputs should have been. 12906 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12907 CoreMathVerifier.computeConvert(args, target); 12908 // Validate the outputs. 12909 boolean valid = true; 12910 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12911 valid = false; 12912 } 12913 if (!valid) { 12914 if (!errorFound) { 12915 errorFound = true; 12916 message.append("Input inV: "); 12917 appendVariableToMessage(message, args.inV); 12918 message.append("\n"); 12919 message.append("Expected output out: "); 12920 appendVariableToMessage(message, args.out); 12921 message.append("\n"); 12922 message.append("Actual output out: "); 12923 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12924 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12925 message.append(" FAIL"); 12926 } 12927 message.append("\n"); 12928 message.append("Errors at"); 12929 } 12930 message.append(" ["); 12931 message.append(Integer.toString(i)); 12932 message.append(", "); 12933 message.append(Integer.toString(j)); 12934 message.append("]"); 12935 } 12936 } 12937 } 12938 assertFalse("Incorrect output for checkConvertDouble4Float4" + 12939 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12940 } 12941 12942 public class ArgumentsLongFloat { 12943 public long inV; 12944 public Target.Floaty out; 12945 } 12946 12947 private void checkConvertLong2Float2() { 12948 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f102c9d72eaa34l, true, 63); 12949 try { 12950 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12951 script.forEach_testConvertFloat2Long2Float2(inV, out); 12952 verifyResultsConvertLong2Float2(inV, out, false); 12953 out.destroy(); 12954 } catch (Exception e) { 12955 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString()); 12956 } 12957 try { 12958 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12959 scriptRelaxed.forEach_testConvertFloat2Long2Float2(inV, out); 12960 verifyResultsConvertLong2Float2(inV, out, true); 12961 out.destroy(); 12962 } catch (Exception e) { 12963 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString()); 12964 } 12965 inV.destroy(); 12966 } 12967 12968 private void verifyResultsConvertLong2Float2(Allocation inV, Allocation out, boolean relaxed) { 12969 long[] arrayInV = new long[INPUTSIZE * 2]; 12970 Arrays.fill(arrayInV, (long) 42); 12971 inV.copyTo(arrayInV); 12972 float[] arrayOut = new float[INPUTSIZE * 2]; 12973 Arrays.fill(arrayOut, (float) 42); 12974 out.copyTo(arrayOut); 12975 StringBuilder message = new StringBuilder(); 12976 boolean errorFound = false; 12977 for (int i = 0; i < INPUTSIZE; i++) { 12978 for (int j = 0; j < 2 ; j++) { 12979 // Extract the inputs. 12980 ArgumentsLongFloat args = new ArgumentsLongFloat(); 12981 args.inV = arrayInV[i * 2 + j]; 12982 // Figure out what the outputs should have been. 12983 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12984 CoreMathVerifier.computeConvert(args, target); 12985 // Validate the outputs. 12986 boolean valid = true; 12987 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12988 valid = false; 12989 } 12990 if (!valid) { 12991 if (!errorFound) { 12992 errorFound = true; 12993 message.append("Input inV: "); 12994 appendVariableToMessage(message, args.inV); 12995 message.append("\n"); 12996 message.append("Expected output out: "); 12997 appendVariableToMessage(message, args.out); 12998 message.append("\n"); 12999 message.append("Actual output out: "); 13000 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13001 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 13002 message.append(" FAIL"); 13003 } 13004 message.append("\n"); 13005 message.append("Errors at"); 13006 } 13007 message.append(" ["); 13008 message.append(Integer.toString(i)); 13009 message.append(", "); 13010 message.append(Integer.toString(j)); 13011 message.append("]"); 13012 } 13013 } 13014 } 13015 assertFalse("Incorrect output for checkConvertLong2Float2" + 13016 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13017 } 13018 13019 private void checkConvertLong3Float3() { 13020 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f2cbe4cd49cb12l, true, 63); 13021 try { 13022 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 13023 script.forEach_testConvertFloat3Long3Float3(inV, out); 13024 verifyResultsConvertLong3Float3(inV, out, false); 13025 out.destroy(); 13026 } catch (Exception e) { 13027 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString()); 13028 } 13029 try { 13030 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 13031 scriptRelaxed.forEach_testConvertFloat3Long3Float3(inV, out); 13032 verifyResultsConvertLong3Float3(inV, out, true); 13033 out.destroy(); 13034 } catch (Exception e) { 13035 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString()); 13036 } 13037 inV.destroy(); 13038 } 13039 13040 private void verifyResultsConvertLong3Float3(Allocation inV, Allocation out, boolean relaxed) { 13041 long[] arrayInV = new long[INPUTSIZE * 4]; 13042 Arrays.fill(arrayInV, (long) 42); 13043 inV.copyTo(arrayInV); 13044 float[] arrayOut = new float[INPUTSIZE * 4]; 13045 Arrays.fill(arrayOut, (float) 42); 13046 out.copyTo(arrayOut); 13047 StringBuilder message = new StringBuilder(); 13048 boolean errorFound = false; 13049 for (int i = 0; i < INPUTSIZE; i++) { 13050 for (int j = 0; j < 3 ; j++) { 13051 // Extract the inputs. 13052 ArgumentsLongFloat args = new ArgumentsLongFloat(); 13053 args.inV = arrayInV[i * 4 + j]; 13054 // Figure out what the outputs should have been. 13055 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 13056 CoreMathVerifier.computeConvert(args, target); 13057 // Validate the outputs. 13058 boolean valid = true; 13059 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13060 valid = false; 13061 } 13062 if (!valid) { 13063 if (!errorFound) { 13064 errorFound = true; 13065 message.append("Input inV: "); 13066 appendVariableToMessage(message, args.inV); 13067 message.append("\n"); 13068 message.append("Expected output out: "); 13069 appendVariableToMessage(message, args.out); 13070 message.append("\n"); 13071 message.append("Actual output out: "); 13072 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13073 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13074 message.append(" FAIL"); 13075 } 13076 message.append("\n"); 13077 message.append("Errors at"); 13078 } 13079 message.append(" ["); 13080 message.append(Integer.toString(i)); 13081 message.append(", "); 13082 message.append(Integer.toString(j)); 13083 message.append("]"); 13084 } 13085 } 13086 } 13087 assertFalse("Incorrect output for checkConvertLong3Float3" + 13088 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13089 } 13090 13091 private void checkConvertLong4Float4() { 13092 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f494ffc364ebf0l, true, 63); 13093 try { 13094 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 13095 script.forEach_testConvertFloat4Long4Float4(inV, out); 13096 verifyResultsConvertLong4Float4(inV, out, false); 13097 out.destroy(); 13098 } catch (Exception e) { 13099 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString()); 13100 } 13101 try { 13102 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 13103 scriptRelaxed.forEach_testConvertFloat4Long4Float4(inV, out); 13104 verifyResultsConvertLong4Float4(inV, out, true); 13105 out.destroy(); 13106 } catch (Exception e) { 13107 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString()); 13108 } 13109 inV.destroy(); 13110 } 13111 13112 private void verifyResultsConvertLong4Float4(Allocation inV, Allocation out, boolean relaxed) { 13113 long[] arrayInV = new long[INPUTSIZE * 4]; 13114 Arrays.fill(arrayInV, (long) 42); 13115 inV.copyTo(arrayInV); 13116 float[] arrayOut = new float[INPUTSIZE * 4]; 13117 Arrays.fill(arrayOut, (float) 42); 13118 out.copyTo(arrayOut); 13119 StringBuilder message = new StringBuilder(); 13120 boolean errorFound = false; 13121 for (int i = 0; i < INPUTSIZE; i++) { 13122 for (int j = 0; j < 4 ; j++) { 13123 // Extract the inputs. 13124 ArgumentsLongFloat args = new ArgumentsLongFloat(); 13125 args.inV = arrayInV[i * 4 + j]; 13126 // Figure out what the outputs should have been. 13127 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 13128 CoreMathVerifier.computeConvert(args, target); 13129 // Validate the outputs. 13130 boolean valid = true; 13131 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13132 valid = false; 13133 } 13134 if (!valid) { 13135 if (!errorFound) { 13136 errorFound = true; 13137 message.append("Input inV: "); 13138 appendVariableToMessage(message, args.inV); 13139 message.append("\n"); 13140 message.append("Expected output out: "); 13141 appendVariableToMessage(message, args.out); 13142 message.append("\n"); 13143 message.append("Actual output out: "); 13144 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13145 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13146 message.append(" FAIL"); 13147 } 13148 message.append("\n"); 13149 message.append("Errors at"); 13150 } 13151 message.append(" ["); 13152 message.append(Integer.toString(i)); 13153 message.append(", "); 13154 message.append(Integer.toString(j)); 13155 message.append("]"); 13156 } 13157 } 13158 } 13159 assertFalse("Incorrect output for checkConvertLong4Float4" + 13160 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13161 } 13162 13163 public class ArgumentsUlongFloat { 13164 public long inV; 13165 public Target.Floaty out; 13166 } 13167 13168 private void checkConvertUlong2Float2() { 13169 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebf22d17306c3dfl, false, 64); 13170 try { 13171 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 13172 script.forEach_testConvertFloat2Ulong2Float2(inV, out); 13173 verifyResultsConvertUlong2Float2(inV, out, false); 13174 out.destroy(); 13175 } catch (Exception e) { 13176 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString()); 13177 } 13178 try { 13179 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 13180 scriptRelaxed.forEach_testConvertFloat2Ulong2Float2(inV, out); 13181 verifyResultsConvertUlong2Float2(inV, out, true); 13182 out.destroy(); 13183 } catch (Exception e) { 13184 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString()); 13185 } 13186 inV.destroy(); 13187 } 13188 13189 private void verifyResultsConvertUlong2Float2(Allocation inV, Allocation out, boolean relaxed) { 13190 long[] arrayInV = new long[INPUTSIZE * 2]; 13191 Arrays.fill(arrayInV, (long) 42); 13192 inV.copyTo(arrayInV); 13193 float[] arrayOut = new float[INPUTSIZE * 2]; 13194 Arrays.fill(arrayOut, (float) 42); 13195 out.copyTo(arrayOut); 13196 StringBuilder message = new StringBuilder(); 13197 boolean errorFound = false; 13198 for (int i = 0; i < INPUTSIZE; i++) { 13199 for (int j = 0; j < 2 ; j++) { 13200 // Extract the inputs. 13201 ArgumentsUlongFloat args = new ArgumentsUlongFloat(); 13202 args.inV = arrayInV[i * 2 + j]; 13203 // Figure out what the outputs should have been. 13204 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 13205 CoreMathVerifier.computeConvert(args, target); 13206 // Validate the outputs. 13207 boolean valid = true; 13208 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 13209 valid = false; 13210 } 13211 if (!valid) { 13212 if (!errorFound) { 13213 errorFound = true; 13214 message.append("Input inV: "); 13215 appendVariableToMessage(message, args.inV); 13216 message.append("\n"); 13217 message.append("Expected output out: "); 13218 appendVariableToMessage(message, args.out); 13219 message.append("\n"); 13220 message.append("Actual output out: "); 13221 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13222 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 13223 message.append(" FAIL"); 13224 } 13225 message.append("\n"); 13226 message.append("Errors at"); 13227 } 13228 message.append(" ["); 13229 message.append(Integer.toString(i)); 13230 message.append(", "); 13231 message.append(Integer.toString(j)); 13232 message.append("]"); 13233 } 13234 } 13235 } 13236 assertFalse("Incorrect output for checkConvertUlong2Float2" + 13237 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13238 } 13239 13240 private void checkConvertUlong3Float3() { 13241 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec0ebec6921e4bdl, false, 64); 13242 try { 13243 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 13244 script.forEach_testConvertFloat3Ulong3Float3(inV, out); 13245 verifyResultsConvertUlong3Float3(inV, out, false); 13246 out.destroy(); 13247 } catch (Exception e) { 13248 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString()); 13249 } 13250 try { 13251 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 13252 scriptRelaxed.forEach_testConvertFloat3Ulong3Float3(inV, out); 13253 verifyResultsConvertUlong3Float3(inV, out, true); 13254 out.destroy(); 13255 } catch (Exception e) { 13256 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString()); 13257 } 13258 inV.destroy(); 13259 } 13260 13261 private void verifyResultsConvertUlong3Float3(Allocation inV, Allocation out, boolean relaxed) { 13262 long[] arrayInV = new long[INPUTSIZE * 4]; 13263 Arrays.fill(arrayInV, (long) 42); 13264 inV.copyTo(arrayInV); 13265 float[] arrayOut = new float[INPUTSIZE * 4]; 13266 Arrays.fill(arrayOut, (float) 42); 13267 out.copyTo(arrayOut); 13268 StringBuilder message = new StringBuilder(); 13269 boolean errorFound = false; 13270 for (int i = 0; i < INPUTSIZE; i++) { 13271 for (int j = 0; j < 3 ; j++) { 13272 // Extract the inputs. 13273 ArgumentsUlongFloat args = new ArgumentsUlongFloat(); 13274 args.inV = arrayInV[i * 4 + j]; 13275 // Figure out what the outputs should have been. 13276 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 13277 CoreMathVerifier.computeConvert(args, target); 13278 // Validate the outputs. 13279 boolean valid = true; 13280 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13281 valid = false; 13282 } 13283 if (!valid) { 13284 if (!errorFound) { 13285 errorFound = true; 13286 message.append("Input inV: "); 13287 appendVariableToMessage(message, args.inV); 13288 message.append("\n"); 13289 message.append("Expected output out: "); 13290 appendVariableToMessage(message, args.out); 13291 message.append("\n"); 13292 message.append("Actual output out: "); 13293 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13294 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13295 message.append(" FAIL"); 13296 } 13297 message.append("\n"); 13298 message.append("Errors at"); 13299 } 13300 message.append(" ["); 13301 message.append(Integer.toString(i)); 13302 message.append(", "); 13303 message.append(Integer.toString(j)); 13304 message.append("]"); 13305 } 13306 } 13307 } 13308 assertFalse("Incorrect output for checkConvertUlong3Float3" + 13309 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13310 } 13311 13312 private void checkConvertUlong4Float4() { 13313 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec2b5075f3d059bl, false, 64); 13314 try { 13315 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 13316 script.forEach_testConvertFloat4Ulong4Float4(inV, out); 13317 verifyResultsConvertUlong4Float4(inV, out, false); 13318 out.destroy(); 13319 } catch (Exception e) { 13320 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString()); 13321 } 13322 try { 13323 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 13324 scriptRelaxed.forEach_testConvertFloat4Ulong4Float4(inV, out); 13325 verifyResultsConvertUlong4Float4(inV, out, true); 13326 out.destroy(); 13327 } catch (Exception e) { 13328 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString()); 13329 } 13330 inV.destroy(); 13331 } 13332 13333 private void verifyResultsConvertUlong4Float4(Allocation inV, Allocation out, boolean relaxed) { 13334 long[] arrayInV = new long[INPUTSIZE * 4]; 13335 Arrays.fill(arrayInV, (long) 42); 13336 inV.copyTo(arrayInV); 13337 float[] arrayOut = new float[INPUTSIZE * 4]; 13338 Arrays.fill(arrayOut, (float) 42); 13339 out.copyTo(arrayOut); 13340 StringBuilder message = new StringBuilder(); 13341 boolean errorFound = false; 13342 for (int i = 0; i < INPUTSIZE; i++) { 13343 for (int j = 0; j < 4 ; j++) { 13344 // Extract the inputs. 13345 ArgumentsUlongFloat args = new ArgumentsUlongFloat(); 13346 args.inV = arrayInV[i * 4 + j]; 13347 // Figure out what the outputs should have been. 13348 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 13349 CoreMathVerifier.computeConvert(args, target); 13350 // Validate the outputs. 13351 boolean valid = true; 13352 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13353 valid = false; 13354 } 13355 if (!valid) { 13356 if (!errorFound) { 13357 errorFound = true; 13358 message.append("Input inV: "); 13359 appendVariableToMessage(message, args.inV); 13360 message.append("\n"); 13361 message.append("Expected output out: "); 13362 appendVariableToMessage(message, args.out); 13363 message.append("\n"); 13364 message.append("Actual output out: "); 13365 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13366 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 13367 message.append(" FAIL"); 13368 } 13369 message.append("\n"); 13370 message.append("Errors at"); 13371 } 13372 message.append(" ["); 13373 message.append(Integer.toString(i)); 13374 message.append(", "); 13375 message.append(Integer.toString(j)); 13376 message.append("]"); 13377 } 13378 } 13379 } 13380 assertFalse("Incorrect output for checkConvertUlong4Float4" + 13381 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13382 } 13383 13384 public class ArgumentsDoubleChar { 13385 public double inV; 13386 public byte out; 13387 } 13388 13389 private void checkConvertDouble2Char2() { 13390 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84b7bef094a17l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 13391 try { 13392 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13393 script.forEach_testConvertChar2Double2Char2(inV, out); 13394 verifyResultsConvertDouble2Char2(inV, out, false); 13395 out.destroy(); 13396 } catch (Exception e) { 13397 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString()); 13398 } 13399 try { 13400 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13401 scriptRelaxed.forEach_testConvertChar2Double2Char2(inV, out); 13402 verifyResultsConvertDouble2Char2(inV, out, true); 13403 out.destroy(); 13404 } catch (Exception e) { 13405 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString()); 13406 } 13407 inV.destroy(); 13408 } 13409 13410 private void verifyResultsConvertDouble2Char2(Allocation inV, Allocation out, boolean relaxed) { 13411 double[] arrayInV = new double[INPUTSIZE * 2]; 13412 Arrays.fill(arrayInV, (double) 42); 13413 inV.copyTo(arrayInV); 13414 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13415 Arrays.fill(arrayOut, (byte) 42); 13416 out.copyTo(arrayOut); 13417 StringBuilder message = new StringBuilder(); 13418 boolean errorFound = false; 13419 for (int i = 0; i < INPUTSIZE; i++) { 13420 for (int j = 0; j < 2 ; j++) { 13421 // Extract the inputs. 13422 ArgumentsDoubleChar args = new ArgumentsDoubleChar(); 13423 args.inV = arrayInV[i * 2 + j]; 13424 // Figure out what the outputs should have been. 13425 CoreMathVerifier.computeConvert(args); 13426 // Validate the outputs. 13427 boolean valid = true; 13428 if (args.out != arrayOut[i * 2 + j]) { 13429 valid = false; 13430 } 13431 if (!valid) { 13432 if (!errorFound) { 13433 errorFound = true; 13434 message.append("Input inV: "); 13435 appendVariableToMessage(message, args.inV); 13436 message.append("\n"); 13437 message.append("Expected output out: "); 13438 appendVariableToMessage(message, args.out); 13439 message.append("\n"); 13440 message.append("Actual output out: "); 13441 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13442 if (args.out != arrayOut[i * 2 + j]) { 13443 message.append(" FAIL"); 13444 } 13445 message.append("\n"); 13446 message.append("Errors at"); 13447 } 13448 message.append(" ["); 13449 message.append(Integer.toString(i)); 13450 message.append(", "); 13451 message.append(Integer.toString(j)); 13452 message.append("]"); 13453 } 13454 } 13455 } 13456 assertFalse("Incorrect output for checkConvertDouble2Char2" + 13457 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13458 } 13459 13460 private void checkConvertDouble3Char3() { 13461 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf8561d4e110f0bl, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 13462 try { 13463 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13464 script.forEach_testConvertChar3Double3Char3(inV, out); 13465 verifyResultsConvertDouble3Char3(inV, out, false); 13466 out.destroy(); 13467 } catch (Exception e) { 13468 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString()); 13469 } 13470 try { 13471 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13472 scriptRelaxed.forEach_testConvertChar3Double3Char3(inV, out); 13473 verifyResultsConvertDouble3Char3(inV, out, true); 13474 out.destroy(); 13475 } catch (Exception e) { 13476 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString()); 13477 } 13478 inV.destroy(); 13479 } 13480 13481 private void verifyResultsConvertDouble3Char3(Allocation inV, Allocation out, boolean relaxed) { 13482 double[] arrayInV = new double[INPUTSIZE * 4]; 13483 Arrays.fill(arrayInV, (double) 42); 13484 inV.copyTo(arrayInV); 13485 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13486 Arrays.fill(arrayOut, (byte) 42); 13487 out.copyTo(arrayOut); 13488 StringBuilder message = new StringBuilder(); 13489 boolean errorFound = false; 13490 for (int i = 0; i < INPUTSIZE; i++) { 13491 for (int j = 0; j < 3 ; j++) { 13492 // Extract the inputs. 13493 ArgumentsDoubleChar args = new ArgumentsDoubleChar(); 13494 args.inV = arrayInV[i * 4 + j]; 13495 // Figure out what the outputs should have been. 13496 CoreMathVerifier.computeConvert(args); 13497 // Validate the outputs. 13498 boolean valid = true; 13499 if (args.out != arrayOut[i * 4 + j]) { 13500 valid = false; 13501 } 13502 if (!valid) { 13503 if (!errorFound) { 13504 errorFound = true; 13505 message.append("Input inV: "); 13506 appendVariableToMessage(message, args.inV); 13507 message.append("\n"); 13508 message.append("Expected output out: "); 13509 appendVariableToMessage(message, args.out); 13510 message.append("\n"); 13511 message.append("Actual output out: "); 13512 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13513 if (args.out != arrayOut[i * 4 + j]) { 13514 message.append(" FAIL"); 13515 } 13516 message.append("\n"); 13517 message.append("Errors at"); 13518 } 13519 message.append(" ["); 13520 message.append(Integer.toString(i)); 13521 message.append(", "); 13522 message.append(Integer.toString(j)); 13523 message.append("]"); 13524 } 13525 } 13526 } 13527 assertFalse("Incorrect output for checkConvertDouble3Char3" + 13528 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13529 } 13530 13531 private void checkConvertDouble4Char4() { 13532 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf860bead18d3ffl, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 13533 try { 13534 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13535 script.forEach_testConvertChar4Double4Char4(inV, out); 13536 verifyResultsConvertDouble4Char4(inV, out, false); 13537 out.destroy(); 13538 } catch (Exception e) { 13539 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString()); 13540 } 13541 try { 13542 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13543 scriptRelaxed.forEach_testConvertChar4Double4Char4(inV, out); 13544 verifyResultsConvertDouble4Char4(inV, out, true); 13545 out.destroy(); 13546 } catch (Exception e) { 13547 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString()); 13548 } 13549 inV.destroy(); 13550 } 13551 13552 private void verifyResultsConvertDouble4Char4(Allocation inV, Allocation out, boolean relaxed) { 13553 double[] arrayInV = new double[INPUTSIZE * 4]; 13554 Arrays.fill(arrayInV, (double) 42); 13555 inV.copyTo(arrayInV); 13556 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13557 Arrays.fill(arrayOut, (byte) 42); 13558 out.copyTo(arrayOut); 13559 StringBuilder message = new StringBuilder(); 13560 boolean errorFound = false; 13561 for (int i = 0; i < INPUTSIZE; i++) { 13562 for (int j = 0; j < 4 ; j++) { 13563 // Extract the inputs. 13564 ArgumentsDoubleChar args = new ArgumentsDoubleChar(); 13565 args.inV = arrayInV[i * 4 + j]; 13566 // Figure out what the outputs should have been. 13567 CoreMathVerifier.computeConvert(args); 13568 // Validate the outputs. 13569 boolean valid = true; 13570 if (args.out != arrayOut[i * 4 + j]) { 13571 valid = false; 13572 } 13573 if (!valid) { 13574 if (!errorFound) { 13575 errorFound = true; 13576 message.append("Input inV: "); 13577 appendVariableToMessage(message, args.inV); 13578 message.append("\n"); 13579 message.append("Expected output out: "); 13580 appendVariableToMessage(message, args.out); 13581 message.append("\n"); 13582 message.append("Actual output out: "); 13583 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13584 if (args.out != arrayOut[i * 4 + j]) { 13585 message.append(" FAIL"); 13586 } 13587 message.append("\n"); 13588 message.append("Errors at"); 13589 } 13590 message.append(" ["); 13591 message.append(Integer.toString(i)); 13592 message.append(", "); 13593 message.append(Integer.toString(j)); 13594 message.append("]"); 13595 } 13596 } 13597 } 13598 assertFalse("Incorrect output for checkConvertDouble4Char4" + 13599 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13600 } 13601 13602 public class ArgumentsLongChar { 13603 public long inV; 13604 public byte out; 13605 } 13606 13607 private void checkConvertLong2Char2() { 13608 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c3c37419afacl, true, 7); 13609 try { 13610 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13611 script.forEach_testConvertChar2Long2Char2(inV, out); 13612 verifyResultsConvertLong2Char2(inV, out, false); 13613 out.destroy(); 13614 } catch (Exception e) { 13615 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString()); 13616 } 13617 try { 13618 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13619 scriptRelaxed.forEach_testConvertChar2Long2Char2(inV, out); 13620 verifyResultsConvertLong2Char2(inV, out, true); 13621 out.destroy(); 13622 } catch (Exception e) { 13623 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString()); 13624 } 13625 inV.destroy(); 13626 } 13627 13628 private void verifyResultsConvertLong2Char2(Allocation inV, Allocation out, boolean relaxed) { 13629 long[] arrayInV = new long[INPUTSIZE * 2]; 13630 Arrays.fill(arrayInV, (long) 42); 13631 inV.copyTo(arrayInV); 13632 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13633 Arrays.fill(arrayOut, (byte) 42); 13634 out.copyTo(arrayOut); 13635 StringBuilder message = new StringBuilder(); 13636 boolean errorFound = false; 13637 for (int i = 0; i < INPUTSIZE; i++) { 13638 for (int j = 0; j < 2 ; j++) { 13639 // Extract the inputs. 13640 ArgumentsLongChar args = new ArgumentsLongChar(); 13641 args.inV = arrayInV[i * 2 + j]; 13642 // Figure out what the outputs should have been. 13643 CoreMathVerifier.computeConvert(args); 13644 // Validate the outputs. 13645 boolean valid = true; 13646 if (args.out != arrayOut[i * 2 + j]) { 13647 valid = false; 13648 } 13649 if (!valid) { 13650 if (!errorFound) { 13651 errorFound = true; 13652 message.append("Input inV: "); 13653 appendVariableToMessage(message, args.inV); 13654 message.append("\n"); 13655 message.append("Expected output out: "); 13656 appendVariableToMessage(message, args.out); 13657 message.append("\n"); 13658 message.append("Actual output out: "); 13659 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13660 if (args.out != arrayOut[i * 2 + j]) { 13661 message.append(" FAIL"); 13662 } 13663 message.append("\n"); 13664 message.append("Errors at"); 13665 } 13666 message.append(" ["); 13667 message.append(Integer.toString(i)); 13668 message.append(", "); 13669 message.append(Integer.toString(j)); 13670 message.append("]"); 13671 } 13672 } 13673 } 13674 assertFalse("Incorrect output for checkConvertLong2Char2" + 13675 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13676 } 13677 13678 private void checkConvertLong3Char3() { 13679 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570ce64d32174a0l, true, 7); 13680 try { 13681 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13682 script.forEach_testConvertChar3Long3Char3(inV, out); 13683 verifyResultsConvertLong3Char3(inV, out, false); 13684 out.destroy(); 13685 } catch (Exception e) { 13686 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString()); 13687 } 13688 try { 13689 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13690 scriptRelaxed.forEach_testConvertChar3Long3Char3(inV, out); 13691 verifyResultsConvertLong3Char3(inV, out, true); 13692 out.destroy(); 13693 } catch (Exception e) { 13694 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString()); 13695 } 13696 inV.destroy(); 13697 } 13698 13699 private void verifyResultsConvertLong3Char3(Allocation inV, Allocation out, boolean relaxed) { 13700 long[] arrayInV = new long[INPUTSIZE * 4]; 13701 Arrays.fill(arrayInV, (long) 42); 13702 inV.copyTo(arrayInV); 13703 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13704 Arrays.fill(arrayOut, (byte) 42); 13705 out.copyTo(arrayOut); 13706 StringBuilder message = new StringBuilder(); 13707 boolean errorFound = false; 13708 for (int i = 0; i < INPUTSIZE; i++) { 13709 for (int j = 0; j < 3 ; j++) { 13710 // Extract the inputs. 13711 ArgumentsLongChar args = new ArgumentsLongChar(); 13712 args.inV = arrayInV[i * 4 + j]; 13713 // Figure out what the outputs should have been. 13714 CoreMathVerifier.computeConvert(args); 13715 // Validate the outputs. 13716 boolean valid = true; 13717 if (args.out != arrayOut[i * 4 + j]) { 13718 valid = false; 13719 } 13720 if (!valid) { 13721 if (!errorFound) { 13722 errorFound = true; 13723 message.append("Input inV: "); 13724 appendVariableToMessage(message, args.inV); 13725 message.append("\n"); 13726 message.append("Expected output out: "); 13727 appendVariableToMessage(message, args.out); 13728 message.append("\n"); 13729 message.append("Actual output out: "); 13730 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13731 if (args.out != arrayOut[i * 4 + j]) { 13732 message.append(" FAIL"); 13733 } 13734 message.append("\n"); 13735 message.append("Errors at"); 13736 } 13737 message.append(" ["); 13738 message.append(Integer.toString(i)); 13739 message.append(", "); 13740 message.append(Integer.toString(j)); 13741 message.append("]"); 13742 } 13743 } 13744 } 13745 assertFalse("Incorrect output for checkConvertLong3Char3" + 13746 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13747 } 13748 13749 private void checkConvertLong4Char4() { 13750 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570d90632293994l, true, 7); 13751 try { 13752 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13753 script.forEach_testConvertChar4Long4Char4(inV, out); 13754 verifyResultsConvertLong4Char4(inV, out, false); 13755 out.destroy(); 13756 } catch (Exception e) { 13757 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString()); 13758 } 13759 try { 13760 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13761 scriptRelaxed.forEach_testConvertChar4Long4Char4(inV, out); 13762 verifyResultsConvertLong4Char4(inV, out, true); 13763 out.destroy(); 13764 } catch (Exception e) { 13765 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString()); 13766 } 13767 inV.destroy(); 13768 } 13769 13770 private void verifyResultsConvertLong4Char4(Allocation inV, Allocation out, boolean relaxed) { 13771 long[] arrayInV = new long[INPUTSIZE * 4]; 13772 Arrays.fill(arrayInV, (long) 42); 13773 inV.copyTo(arrayInV); 13774 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13775 Arrays.fill(arrayOut, (byte) 42); 13776 out.copyTo(arrayOut); 13777 StringBuilder message = new StringBuilder(); 13778 boolean errorFound = false; 13779 for (int i = 0; i < INPUTSIZE; i++) { 13780 for (int j = 0; j < 4 ; j++) { 13781 // Extract the inputs. 13782 ArgumentsLongChar args = new ArgumentsLongChar(); 13783 args.inV = arrayInV[i * 4 + j]; 13784 // Figure out what the outputs should have been. 13785 CoreMathVerifier.computeConvert(args); 13786 // Validate the outputs. 13787 boolean valid = true; 13788 if (args.out != arrayOut[i * 4 + j]) { 13789 valid = false; 13790 } 13791 if (!valid) { 13792 if (!errorFound) { 13793 errorFound = true; 13794 message.append("Input inV: "); 13795 appendVariableToMessage(message, args.inV); 13796 message.append("\n"); 13797 message.append("Expected output out: "); 13798 appendVariableToMessage(message, args.out); 13799 message.append("\n"); 13800 message.append("Actual output out: "); 13801 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13802 if (args.out != arrayOut[i * 4 + j]) { 13803 message.append(" FAIL"); 13804 } 13805 message.append("\n"); 13806 message.append("Errors at"); 13807 } 13808 message.append(" ["); 13809 message.append(Integer.toString(i)); 13810 message.append(", "); 13811 message.append(Integer.toString(j)); 13812 message.append("]"); 13813 } 13814 } 13815 } 13816 assertFalse("Incorrect output for checkConvertLong4Char4" + 13817 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13818 } 13819 13820 public class ArgumentsUlongChar { 13821 public long inV; 13822 public byte out; 13823 } 13824 13825 private void checkConvertUlong2Char2() { 13826 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7d11069bbc2dl, false, 7); 13827 try { 13828 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13829 script.forEach_testConvertChar2Ulong2Char2(inV, out); 13830 verifyResultsConvertUlong2Char2(inV, out, false); 13831 out.destroy(); 13832 } catch (Exception e) { 13833 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString()); 13834 } 13835 try { 13836 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13837 scriptRelaxed.forEach_testConvertChar2Ulong2Char2(inV, out); 13838 verifyResultsConvertUlong2Char2(inV, out, true); 13839 out.destroy(); 13840 } catch (Exception e) { 13841 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString()); 13842 } 13843 inV.destroy(); 13844 } 13845 13846 private void verifyResultsConvertUlong2Char2(Allocation inV, Allocation out, boolean relaxed) { 13847 long[] arrayInV = new long[INPUTSIZE * 2]; 13848 Arrays.fill(arrayInV, (long) 42); 13849 inV.copyTo(arrayInV); 13850 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13851 Arrays.fill(arrayOut, (byte) 42); 13852 out.copyTo(arrayOut); 13853 StringBuilder message = new StringBuilder(); 13854 boolean errorFound = false; 13855 for (int i = 0; i < INPUTSIZE; i++) { 13856 for (int j = 0; j < 2 ; j++) { 13857 // Extract the inputs. 13858 ArgumentsUlongChar args = new ArgumentsUlongChar(); 13859 args.inV = arrayInV[i * 2 + j]; 13860 // Figure out what the outputs should have been. 13861 CoreMathVerifier.computeConvert(args); 13862 // Validate the outputs. 13863 boolean valid = true; 13864 if (args.out != arrayOut[i * 2 + j]) { 13865 valid = false; 13866 } 13867 if (!valid) { 13868 if (!errorFound) { 13869 errorFound = true; 13870 message.append("Input inV: "); 13871 appendVariableToMessage(message, args.inV); 13872 message.append("\n"); 13873 message.append("Expected output out: "); 13874 appendVariableToMessage(message, args.out); 13875 message.append("\n"); 13876 message.append("Actual output out: "); 13877 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13878 if (args.out != arrayOut[i * 2 + j]) { 13879 message.append(" FAIL"); 13880 } 13881 message.append("\n"); 13882 message.append("Errors at"); 13883 } 13884 message.append(" ["); 13885 message.append(Integer.toString(i)); 13886 message.append(", "); 13887 message.append(Integer.toString(j)); 13888 message.append("]"); 13889 } 13890 } 13891 } 13892 assertFalse("Incorrect output for checkConvertUlong2Char2" + 13893 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13894 } 13895 13896 private void checkConvertUlong3Char3() { 13897 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe87b265a38121l, false, 7); 13898 try { 13899 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13900 script.forEach_testConvertChar3Ulong3Char3(inV, out); 13901 verifyResultsConvertUlong3Char3(inV, out, false); 13902 out.destroy(); 13903 } catch (Exception e) { 13904 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString()); 13905 } 13906 try { 13907 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13908 scriptRelaxed.forEach_testConvertChar3Ulong3Char3(inV, out); 13909 verifyResultsConvertUlong3Char3(inV, out, true); 13910 out.destroy(); 13911 } catch (Exception e) { 13912 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString()); 13913 } 13914 inV.destroy(); 13915 } 13916 13917 private void verifyResultsConvertUlong3Char3(Allocation inV, Allocation out, boolean relaxed) { 13918 long[] arrayInV = new long[INPUTSIZE * 4]; 13919 Arrays.fill(arrayInV, (long) 42); 13920 inV.copyTo(arrayInV); 13921 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13922 Arrays.fill(arrayOut, (byte) 42); 13923 out.copyTo(arrayOut); 13924 StringBuilder message = new StringBuilder(); 13925 boolean errorFound = false; 13926 for (int i = 0; i < INPUTSIZE; i++) { 13927 for (int j = 0; j < 3 ; j++) { 13928 // Extract the inputs. 13929 ArgumentsUlongChar args = new ArgumentsUlongChar(); 13930 args.inV = arrayInV[i * 4 + j]; 13931 // Figure out what the outputs should have been. 13932 CoreMathVerifier.computeConvert(args); 13933 // Validate the outputs. 13934 boolean valid = true; 13935 if (args.out != arrayOut[i * 4 + j]) { 13936 valid = false; 13937 } 13938 if (!valid) { 13939 if (!errorFound) { 13940 errorFound = true; 13941 message.append("Input inV: "); 13942 appendVariableToMessage(message, args.inV); 13943 message.append("\n"); 13944 message.append("Expected output out: "); 13945 appendVariableToMessage(message, args.out); 13946 message.append("\n"); 13947 message.append("Actual output out: "); 13948 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13949 if (args.out != arrayOut[i * 4 + j]) { 13950 message.append(" FAIL"); 13951 } 13952 message.append("\n"); 13953 message.append("Errors at"); 13954 } 13955 message.append(" ["); 13956 message.append(Integer.toString(i)); 13957 message.append(", "); 13958 message.append(Integer.toString(j)); 13959 message.append("]"); 13960 } 13961 } 13962 } 13963 assertFalse("Incorrect output for checkConvertUlong3Char3" + 13964 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13965 } 13966 13967 private void checkConvertUlong4Char4() { 13968 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe9253c4ab4615l, false, 7); 13969 try { 13970 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13971 script.forEach_testConvertChar4Ulong4Char4(inV, out); 13972 verifyResultsConvertUlong4Char4(inV, out, false); 13973 out.destroy(); 13974 } catch (Exception e) { 13975 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString()); 13976 } 13977 try { 13978 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13979 scriptRelaxed.forEach_testConvertChar4Ulong4Char4(inV, out); 13980 verifyResultsConvertUlong4Char4(inV, out, true); 13981 out.destroy(); 13982 } catch (Exception e) { 13983 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString()); 13984 } 13985 inV.destroy(); 13986 } 13987 13988 private void verifyResultsConvertUlong4Char4(Allocation inV, Allocation out, boolean relaxed) { 13989 long[] arrayInV = new long[INPUTSIZE * 4]; 13990 Arrays.fill(arrayInV, (long) 42); 13991 inV.copyTo(arrayInV); 13992 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13993 Arrays.fill(arrayOut, (byte) 42); 13994 out.copyTo(arrayOut); 13995 StringBuilder message = new StringBuilder(); 13996 boolean errorFound = false; 13997 for (int i = 0; i < INPUTSIZE; i++) { 13998 for (int j = 0; j < 4 ; j++) { 13999 // Extract the inputs. 14000 ArgumentsUlongChar args = new ArgumentsUlongChar(); 14001 args.inV = arrayInV[i * 4 + j]; 14002 // Figure out what the outputs should have been. 14003 CoreMathVerifier.computeConvert(args); 14004 // Validate the outputs. 14005 boolean valid = true; 14006 if (args.out != arrayOut[i * 4 + j]) { 14007 valid = false; 14008 } 14009 if (!valid) { 14010 if (!errorFound) { 14011 errorFound = true; 14012 message.append("Input inV: "); 14013 appendVariableToMessage(message, args.inV); 14014 message.append("\n"); 14015 message.append("Expected output out: "); 14016 appendVariableToMessage(message, args.out); 14017 message.append("\n"); 14018 message.append("Actual output out: "); 14019 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14020 if (args.out != arrayOut[i * 4 + j]) { 14021 message.append(" FAIL"); 14022 } 14023 message.append("\n"); 14024 message.append("Errors at"); 14025 } 14026 message.append(" ["); 14027 message.append(Integer.toString(i)); 14028 message.append(", "); 14029 message.append(Integer.toString(j)); 14030 message.append("]"); 14031 } 14032 } 14033 } 14034 assertFalse("Incorrect output for checkConvertUlong4Char4" + 14035 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14036 } 14037 14038 public class ArgumentsDoubleUchar { 14039 public double inV; 14040 public byte out; 14041 } 14042 14043 private void checkConvertDouble2Uchar2() { 14044 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b56bf72a0f8ae0l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 14045 try { 14046 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 14047 script.forEach_testConvertUchar2Double2Uchar2(inV, out); 14048 verifyResultsConvertDouble2Uchar2(inV, out, false); 14049 out.destroy(); 14050 } catch (Exception e) { 14051 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString()); 14052 } 14053 try { 14054 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 14055 scriptRelaxed.forEach_testConvertUchar2Double2Uchar2(inV, out); 14056 verifyResultsConvertDouble2Uchar2(inV, out, true); 14057 out.destroy(); 14058 } catch (Exception e) { 14059 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString()); 14060 } 14061 inV.destroy(); 14062 } 14063 14064 private void verifyResultsConvertDouble2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 14065 double[] arrayInV = new double[INPUTSIZE * 2]; 14066 Arrays.fill(arrayInV, (double) 42); 14067 inV.copyTo(arrayInV); 14068 byte[] arrayOut = new byte[INPUTSIZE * 2]; 14069 Arrays.fill(arrayOut, (byte) 42); 14070 out.copyTo(arrayOut); 14071 StringBuilder message = new StringBuilder(); 14072 boolean errorFound = false; 14073 for (int i = 0; i < INPUTSIZE; i++) { 14074 for (int j = 0; j < 2 ; j++) { 14075 // Extract the inputs. 14076 ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); 14077 args.inV = arrayInV[i * 2 + j]; 14078 // Figure out what the outputs should have been. 14079 CoreMathVerifier.computeConvert(args); 14080 // Validate the outputs. 14081 boolean valid = true; 14082 if (args.out != arrayOut[i * 2 + j]) { 14083 valid = false; 14084 } 14085 if (!valid) { 14086 if (!errorFound) { 14087 errorFound = true; 14088 message.append("Input inV: "); 14089 appendVariableToMessage(message, args.inV); 14090 message.append("\n"); 14091 message.append("Expected output out: "); 14092 appendVariableToMessage(message, args.out); 14093 message.append("\n"); 14094 message.append("Actual output out: "); 14095 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14096 if (args.out != arrayOut[i * 2 + j]) { 14097 message.append(" FAIL"); 14098 } 14099 message.append("\n"); 14100 message.append("Errors at"); 14101 } 14102 message.append(" ["); 14103 message.append(Integer.toString(i)); 14104 message.append(", "); 14105 message.append(Integer.toString(j)); 14106 message.append("]"); 14107 } 14108 } 14109 } 14110 assertFalse("Incorrect output for checkConvertDouble2Uchar2" + 14111 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14112 } 14113 14114 private void checkConvertDouble3Uchar3() { 14115 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b73512202aabbel, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 14116 try { 14117 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 14118 script.forEach_testConvertUchar3Double3Uchar3(inV, out); 14119 verifyResultsConvertDouble3Uchar3(inV, out, false); 14120 out.destroy(); 14121 } catch (Exception e) { 14122 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString()); 14123 } 14124 try { 14125 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 14126 scriptRelaxed.forEach_testConvertUchar3Double3Uchar3(inV, out); 14127 verifyResultsConvertDouble3Uchar3(inV, out, true); 14128 out.destroy(); 14129 } catch (Exception e) { 14130 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString()); 14131 } 14132 inV.destroy(); 14133 } 14134 14135 private void verifyResultsConvertDouble3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 14136 double[] arrayInV = new double[INPUTSIZE * 4]; 14137 Arrays.fill(arrayInV, (double) 42); 14138 inV.copyTo(arrayInV); 14139 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14140 Arrays.fill(arrayOut, (byte) 42); 14141 out.copyTo(arrayOut); 14142 StringBuilder message = new StringBuilder(); 14143 boolean errorFound = false; 14144 for (int i = 0; i < INPUTSIZE; i++) { 14145 for (int j = 0; j < 3 ; j++) { 14146 // Extract the inputs. 14147 ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); 14148 args.inV = arrayInV[i * 4 + j]; 14149 // Figure out what the outputs should have been. 14150 CoreMathVerifier.computeConvert(args); 14151 // Validate the outputs. 14152 boolean valid = true; 14153 if (args.out != arrayOut[i * 4 + j]) { 14154 valid = false; 14155 } 14156 if (!valid) { 14157 if (!errorFound) { 14158 errorFound = true; 14159 message.append("Input inV: "); 14160 appendVariableToMessage(message, args.inV); 14161 message.append("\n"); 14162 message.append("Expected output out: "); 14163 appendVariableToMessage(message, args.out); 14164 message.append("\n"); 14165 message.append("Actual output out: "); 14166 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14167 if (args.out != arrayOut[i * 4 + j]) { 14168 message.append(" FAIL"); 14169 } 14170 message.append("\n"); 14171 message.append("Errors at"); 14172 } 14173 message.append(" ["); 14174 message.append(Integer.toString(i)); 14175 message.append(", "); 14176 message.append(Integer.toString(j)); 14177 message.append("]"); 14178 } 14179 } 14180 } 14181 assertFalse("Incorrect output for checkConvertDouble3Uchar3" + 14182 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14183 } 14184 14185 private void checkConvertDouble4Uchar4() { 14186 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b8fe2d1645cc9cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 14187 try { 14188 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14189 script.forEach_testConvertUchar4Double4Uchar4(inV, out); 14190 verifyResultsConvertDouble4Uchar4(inV, out, false); 14191 out.destroy(); 14192 } catch (Exception e) { 14193 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString()); 14194 } 14195 try { 14196 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14197 scriptRelaxed.forEach_testConvertUchar4Double4Uchar4(inV, out); 14198 verifyResultsConvertDouble4Uchar4(inV, out, true); 14199 out.destroy(); 14200 } catch (Exception e) { 14201 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString()); 14202 } 14203 inV.destroy(); 14204 } 14205 14206 private void verifyResultsConvertDouble4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 14207 double[] arrayInV = new double[INPUTSIZE * 4]; 14208 Arrays.fill(arrayInV, (double) 42); 14209 inV.copyTo(arrayInV); 14210 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14211 Arrays.fill(arrayOut, (byte) 42); 14212 out.copyTo(arrayOut); 14213 StringBuilder message = new StringBuilder(); 14214 boolean errorFound = false; 14215 for (int i = 0; i < INPUTSIZE; i++) { 14216 for (int j = 0; j < 4 ; j++) { 14217 // Extract the inputs. 14218 ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); 14219 args.inV = arrayInV[i * 4 + j]; 14220 // Figure out what the outputs should have been. 14221 CoreMathVerifier.computeConvert(args); 14222 // Validate the outputs. 14223 boolean valid = true; 14224 if (args.out != arrayOut[i * 4 + j]) { 14225 valid = false; 14226 } 14227 if (!valid) { 14228 if (!errorFound) { 14229 errorFound = true; 14230 message.append("Input inV: "); 14231 appendVariableToMessage(message, args.inV); 14232 message.append("\n"); 14233 message.append("Expected output out: "); 14234 appendVariableToMessage(message, args.out); 14235 message.append("\n"); 14236 message.append("Actual output out: "); 14237 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14238 if (args.out != arrayOut[i * 4 + j]) { 14239 message.append(" FAIL"); 14240 } 14241 message.append("\n"); 14242 message.append("Errors at"); 14243 } 14244 message.append(" ["); 14245 message.append(Integer.toString(i)); 14246 message.append(", "); 14247 message.append(Integer.toString(j)); 14248 message.append("]"); 14249 } 14250 } 14251 } 14252 assertFalse("Incorrect output for checkConvertDouble4Uchar4" + 14253 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14254 } 14255 14256 public class ArgumentsLongUchar { 14257 public long inV; 14258 public byte out; 14259 } 14260 14261 private void checkConvertLong2Uchar2() { 14262 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f19ffa83d09ae7l, false, 8); 14263 try { 14264 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 14265 script.forEach_testConvertUchar2Long2Uchar2(inV, out); 14266 verifyResultsConvertLong2Uchar2(inV, out, false); 14267 out.destroy(); 14268 } catch (Exception e) { 14269 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString()); 14270 } 14271 try { 14272 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 14273 scriptRelaxed.forEach_testConvertUchar2Long2Uchar2(inV, out); 14274 verifyResultsConvertLong2Uchar2(inV, out, true); 14275 out.destroy(); 14276 } catch (Exception e) { 14277 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString()); 14278 } 14279 inV.destroy(); 14280 } 14281 14282 private void verifyResultsConvertLong2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 14283 long[] arrayInV = new long[INPUTSIZE * 2]; 14284 Arrays.fill(arrayInV, (long) 42); 14285 inV.copyTo(arrayInV); 14286 byte[] arrayOut = new byte[INPUTSIZE * 2]; 14287 Arrays.fill(arrayOut, (byte) 42); 14288 out.copyTo(arrayOut); 14289 StringBuilder message = new StringBuilder(); 14290 boolean errorFound = false; 14291 for (int i = 0; i < INPUTSIZE; i++) { 14292 for (int j = 0; j < 2 ; j++) { 14293 // Extract the inputs. 14294 ArgumentsLongUchar args = new ArgumentsLongUchar(); 14295 args.inV = arrayInV[i * 2 + j]; 14296 // Figure out what the outputs should have been. 14297 CoreMathVerifier.computeConvert(args); 14298 // Validate the outputs. 14299 boolean valid = true; 14300 if (args.out != arrayOut[i * 2 + j]) { 14301 valid = false; 14302 } 14303 if (!valid) { 14304 if (!errorFound) { 14305 errorFound = true; 14306 message.append("Input inV: "); 14307 appendVariableToMessage(message, args.inV); 14308 message.append("\n"); 14309 message.append("Expected output out: "); 14310 appendVariableToMessage(message, args.out); 14311 message.append("\n"); 14312 message.append("Actual output out: "); 14313 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14314 if (args.out != arrayOut[i * 2 + j]) { 14315 message.append(" FAIL"); 14316 } 14317 message.append("\n"); 14318 message.append("Errors at"); 14319 } 14320 message.append(" ["); 14321 message.append(Integer.toString(i)); 14322 message.append(", "); 14323 message.append(Integer.toString(j)); 14324 message.append("]"); 14325 } 14326 } 14327 } 14328 assertFalse("Incorrect output for checkConvertLong2Uchar2" + 14329 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14330 } 14331 14332 private void checkConvertLong3Uchar3() { 14333 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f3691579ebbbc5l, false, 8); 14334 try { 14335 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 14336 script.forEach_testConvertUchar3Long3Uchar3(inV, out); 14337 verifyResultsConvertLong3Uchar3(inV, out, false); 14338 out.destroy(); 14339 } catch (Exception e) { 14340 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString()); 14341 } 14342 try { 14343 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 14344 scriptRelaxed.forEach_testConvertUchar3Long3Uchar3(inV, out); 14345 verifyResultsConvertLong3Uchar3(inV, out, true); 14346 out.destroy(); 14347 } catch (Exception e) { 14348 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString()); 14349 } 14350 inV.destroy(); 14351 } 14352 14353 private void verifyResultsConvertLong3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 14354 long[] arrayInV = new long[INPUTSIZE * 4]; 14355 Arrays.fill(arrayInV, (long) 42); 14356 inV.copyTo(arrayInV); 14357 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14358 Arrays.fill(arrayOut, (byte) 42); 14359 out.copyTo(arrayOut); 14360 StringBuilder message = new StringBuilder(); 14361 boolean errorFound = false; 14362 for (int i = 0; i < INPUTSIZE; i++) { 14363 for (int j = 0; j < 3 ; j++) { 14364 // Extract the inputs. 14365 ArgumentsLongUchar args = new ArgumentsLongUchar(); 14366 args.inV = arrayInV[i * 4 + j]; 14367 // Figure out what the outputs should have been. 14368 CoreMathVerifier.computeConvert(args); 14369 // Validate the outputs. 14370 boolean valid = true; 14371 if (args.out != arrayOut[i * 4 + j]) { 14372 valid = false; 14373 } 14374 if (!valid) { 14375 if (!errorFound) { 14376 errorFound = true; 14377 message.append("Input inV: "); 14378 appendVariableToMessage(message, args.inV); 14379 message.append("\n"); 14380 message.append("Expected output out: "); 14381 appendVariableToMessage(message, args.out); 14382 message.append("\n"); 14383 message.append("Actual output out: "); 14384 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14385 if (args.out != arrayOut[i * 4 + j]) { 14386 message.append(" FAIL"); 14387 } 14388 message.append("\n"); 14389 message.append("Errors at"); 14390 } 14391 message.append(" ["); 14392 message.append(Integer.toString(i)); 14393 message.append(", "); 14394 message.append(Integer.toString(j)); 14395 message.append("]"); 14396 } 14397 } 14398 } 14399 assertFalse("Incorrect output for checkConvertLong3Uchar3" + 14400 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14401 } 14402 14403 private void checkConvertLong4Uchar4() { 14404 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f532307006dca3l, false, 8); 14405 try { 14406 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14407 script.forEach_testConvertUchar4Long4Uchar4(inV, out); 14408 verifyResultsConvertLong4Uchar4(inV, out, false); 14409 out.destroy(); 14410 } catch (Exception e) { 14411 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString()); 14412 } 14413 try { 14414 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14415 scriptRelaxed.forEach_testConvertUchar4Long4Uchar4(inV, out); 14416 verifyResultsConvertLong4Uchar4(inV, out, true); 14417 out.destroy(); 14418 } catch (Exception e) { 14419 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString()); 14420 } 14421 inV.destroy(); 14422 } 14423 14424 private void verifyResultsConvertLong4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 14425 long[] arrayInV = new long[INPUTSIZE * 4]; 14426 Arrays.fill(arrayInV, (long) 42); 14427 inV.copyTo(arrayInV); 14428 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14429 Arrays.fill(arrayOut, (byte) 42); 14430 out.copyTo(arrayOut); 14431 StringBuilder message = new StringBuilder(); 14432 boolean errorFound = false; 14433 for (int i = 0; i < INPUTSIZE; i++) { 14434 for (int j = 0; j < 4 ; j++) { 14435 // Extract the inputs. 14436 ArgumentsLongUchar args = new ArgumentsLongUchar(); 14437 args.inV = arrayInV[i * 4 + j]; 14438 // Figure out what the outputs should have been. 14439 CoreMathVerifier.computeConvert(args); 14440 // Validate the outputs. 14441 boolean valid = true; 14442 if (args.out != arrayOut[i * 4 + j]) { 14443 valid = false; 14444 } 14445 if (!valid) { 14446 if (!errorFound) { 14447 errorFound = true; 14448 message.append("Input inV: "); 14449 appendVariableToMessage(message, args.inV); 14450 message.append("\n"); 14451 message.append("Expected output out: "); 14452 appendVariableToMessage(message, args.out); 14453 message.append("\n"); 14454 message.append("Actual output out: "); 14455 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14456 if (args.out != arrayOut[i * 4 + j]) { 14457 message.append(" FAIL"); 14458 } 14459 message.append("\n"); 14460 message.append("Errors at"); 14461 } 14462 message.append(" ["); 14463 message.append(Integer.toString(i)); 14464 message.append(", "); 14465 message.append(Integer.toString(j)); 14466 message.append("]"); 14467 } 14468 } 14469 } 14470 assertFalse("Incorrect output for checkConvertLong4Uchar4" + 14471 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14472 } 14473 14474 public class ArgumentsUlongUchar { 14475 public long inV; 14476 public byte out; 14477 } 14478 14479 private void checkConvertUlong2Uchar2() { 14480 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfc0021fa8b492l, false, 8); 14481 try { 14482 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 14483 script.forEach_testConvertUchar2Ulong2Uchar2(inV, out); 14484 verifyResultsConvertUlong2Uchar2(inV, out, false); 14485 out.destroy(); 14486 } catch (Exception e) { 14487 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString()); 14488 } 14489 try { 14490 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 14491 scriptRelaxed.forEach_testConvertUchar2Ulong2Uchar2(inV, out); 14492 verifyResultsConvertUlong2Uchar2(inV, out, true); 14493 out.destroy(); 14494 } catch (Exception e) { 14495 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString()); 14496 } 14497 inV.destroy(); 14498 } 14499 14500 private void verifyResultsConvertUlong2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 14501 long[] arrayInV = new long[INPUTSIZE * 2]; 14502 Arrays.fill(arrayInV, (long) 42); 14503 inV.copyTo(arrayInV); 14504 byte[] arrayOut = new byte[INPUTSIZE * 2]; 14505 Arrays.fill(arrayOut, (byte) 42); 14506 out.copyTo(arrayOut); 14507 StringBuilder message = new StringBuilder(); 14508 boolean errorFound = false; 14509 for (int i = 0; i < INPUTSIZE; i++) { 14510 for (int j = 0; j < 2 ; j++) { 14511 // Extract the inputs. 14512 ArgumentsUlongUchar args = new ArgumentsUlongUchar(); 14513 args.inV = arrayInV[i * 2 + j]; 14514 // Figure out what the outputs should have been. 14515 CoreMathVerifier.computeConvert(args); 14516 // Validate the outputs. 14517 boolean valid = true; 14518 if (args.out != arrayOut[i * 2 + j]) { 14519 valid = false; 14520 } 14521 if (!valid) { 14522 if (!errorFound) { 14523 errorFound = true; 14524 message.append("Input inV: "); 14525 appendVariableToMessage(message, args.inV); 14526 message.append("\n"); 14527 message.append("Expected output out: "); 14528 appendVariableToMessage(message, args.out); 14529 message.append("\n"); 14530 message.append("Actual output out: "); 14531 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14532 if (args.out != arrayOut[i * 2 + j]) { 14533 message.append(" FAIL"); 14534 } 14535 message.append("\n"); 14536 message.append("Errors at"); 14537 } 14538 message.append(" ["); 14539 message.append(Integer.toString(i)); 14540 message.append(", "); 14541 message.append(Integer.toString(j)); 14542 message.append("]"); 14543 } 14544 } 14545 } 14546 assertFalse("Incorrect output for checkConvertUlong2Uchar2" + 14547 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14548 } 14549 14550 private void checkConvertUlong3Uchar3() { 14551 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec1891d15c3d570l, false, 8); 14552 try { 14553 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 14554 script.forEach_testConvertUchar3Ulong3Uchar3(inV, out); 14555 verifyResultsConvertUlong3Uchar3(inV, out, false); 14556 out.destroy(); 14557 } catch (Exception e) { 14558 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString()); 14559 } 14560 try { 14561 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 14562 scriptRelaxed.forEach_testConvertUchar3Ulong3Uchar3(inV, out); 14563 verifyResultsConvertUlong3Uchar3(inV, out, true); 14564 out.destroy(); 14565 } catch (Exception e) { 14566 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString()); 14567 } 14568 inV.destroy(); 14569 } 14570 14571 private void verifyResultsConvertUlong3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 14572 long[] arrayInV = new long[INPUTSIZE * 4]; 14573 Arrays.fill(arrayInV, (long) 42); 14574 inV.copyTo(arrayInV); 14575 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14576 Arrays.fill(arrayOut, (byte) 42); 14577 out.copyTo(arrayOut); 14578 StringBuilder message = new StringBuilder(); 14579 boolean errorFound = false; 14580 for (int i = 0; i < INPUTSIZE; i++) { 14581 for (int j = 0; j < 3 ; j++) { 14582 // Extract the inputs. 14583 ArgumentsUlongUchar args = new ArgumentsUlongUchar(); 14584 args.inV = arrayInV[i * 4 + j]; 14585 // Figure out what the outputs should have been. 14586 CoreMathVerifier.computeConvert(args); 14587 // Validate the outputs. 14588 boolean valid = true; 14589 if (args.out != arrayOut[i * 4 + j]) { 14590 valid = false; 14591 } 14592 if (!valid) { 14593 if (!errorFound) { 14594 errorFound = true; 14595 message.append("Input inV: "); 14596 appendVariableToMessage(message, args.inV); 14597 message.append("\n"); 14598 message.append("Expected output out: "); 14599 appendVariableToMessage(message, args.out); 14600 message.append("\n"); 14601 message.append("Actual output out: "); 14602 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14603 if (args.out != arrayOut[i * 4 + j]) { 14604 message.append(" FAIL"); 14605 } 14606 message.append("\n"); 14607 message.append("Errors at"); 14608 } 14609 message.append(" ["); 14610 message.append(Integer.toString(i)); 14611 message.append(", "); 14612 message.append(Integer.toString(j)); 14613 message.append("]"); 14614 } 14615 } 14616 } 14617 assertFalse("Incorrect output for checkConvertUlong3Uchar3" + 14618 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14619 } 14620 14621 private void checkConvertUlong4Uchar4() { 14622 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec352380bdef64el, false, 8); 14623 try { 14624 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14625 script.forEach_testConvertUchar4Ulong4Uchar4(inV, out); 14626 verifyResultsConvertUlong4Uchar4(inV, out, false); 14627 out.destroy(); 14628 } catch (Exception e) { 14629 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString()); 14630 } 14631 try { 14632 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14633 scriptRelaxed.forEach_testConvertUchar4Ulong4Uchar4(inV, out); 14634 verifyResultsConvertUlong4Uchar4(inV, out, true); 14635 out.destroy(); 14636 } catch (Exception e) { 14637 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString()); 14638 } 14639 inV.destroy(); 14640 } 14641 14642 private void verifyResultsConvertUlong4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 14643 long[] arrayInV = new long[INPUTSIZE * 4]; 14644 Arrays.fill(arrayInV, (long) 42); 14645 inV.copyTo(arrayInV); 14646 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14647 Arrays.fill(arrayOut, (byte) 42); 14648 out.copyTo(arrayOut); 14649 StringBuilder message = new StringBuilder(); 14650 boolean errorFound = false; 14651 for (int i = 0; i < INPUTSIZE; i++) { 14652 for (int j = 0; j < 4 ; j++) { 14653 // Extract the inputs. 14654 ArgumentsUlongUchar args = new ArgumentsUlongUchar(); 14655 args.inV = arrayInV[i * 4 + j]; 14656 // Figure out what the outputs should have been. 14657 CoreMathVerifier.computeConvert(args); 14658 // Validate the outputs. 14659 boolean valid = true; 14660 if (args.out != arrayOut[i * 4 + j]) { 14661 valid = false; 14662 } 14663 if (!valid) { 14664 if (!errorFound) { 14665 errorFound = true; 14666 message.append("Input inV: "); 14667 appendVariableToMessage(message, args.inV); 14668 message.append("\n"); 14669 message.append("Expected output out: "); 14670 appendVariableToMessage(message, args.out); 14671 message.append("\n"); 14672 message.append("Actual output out: "); 14673 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14674 if (args.out != arrayOut[i * 4 + j]) { 14675 message.append(" FAIL"); 14676 } 14677 message.append("\n"); 14678 message.append("Errors at"); 14679 } 14680 message.append(" ["); 14681 message.append(Integer.toString(i)); 14682 message.append(", "); 14683 message.append(Integer.toString(j)); 14684 message.append("]"); 14685 } 14686 } 14687 } 14688 assertFalse("Incorrect output for checkConvertUlong4Uchar4" + 14689 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14690 } 14691 14692 public class ArgumentsDoubleShort { 14693 public double inV; 14694 public short out; 14695 } 14696 14697 private void checkConvertDouble2Short2() { 14698 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b557fbbf1d55f9l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 14699 try { 14700 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14701 script.forEach_testConvertShort2Double2Short2(inV, out); 14702 verifyResultsConvertDouble2Short2(inV, out, false); 14703 out.destroy(); 14704 } catch (Exception e) { 14705 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString()); 14706 } 14707 try { 14708 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14709 scriptRelaxed.forEach_testConvertShort2Double2Short2(inV, out); 14710 verifyResultsConvertDouble2Short2(inV, out, true); 14711 out.destroy(); 14712 } catch (Exception e) { 14713 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString()); 14714 } 14715 inV.destroy(); 14716 } 14717 14718 private void verifyResultsConvertDouble2Short2(Allocation inV, Allocation out, boolean relaxed) { 14719 double[] arrayInV = new double[INPUTSIZE * 2]; 14720 Arrays.fill(arrayInV, (double) 42); 14721 inV.copyTo(arrayInV); 14722 short[] arrayOut = new short[INPUTSIZE * 2]; 14723 Arrays.fill(arrayOut, (short) 42); 14724 out.copyTo(arrayOut); 14725 StringBuilder message = new StringBuilder(); 14726 boolean errorFound = false; 14727 for (int i = 0; i < INPUTSIZE; i++) { 14728 for (int j = 0; j < 2 ; j++) { 14729 // Extract the inputs. 14730 ArgumentsDoubleShort args = new ArgumentsDoubleShort(); 14731 args.inV = arrayInV[i * 2 + j]; 14732 // Figure out what the outputs should have been. 14733 CoreMathVerifier.computeConvert(args); 14734 // Validate the outputs. 14735 boolean valid = true; 14736 if (args.out != arrayOut[i * 2 + j]) { 14737 valid = false; 14738 } 14739 if (!valid) { 14740 if (!errorFound) { 14741 errorFound = true; 14742 message.append("Input inV: "); 14743 appendVariableToMessage(message, args.inV); 14744 message.append("\n"); 14745 message.append("Expected output out: "); 14746 appendVariableToMessage(message, args.out); 14747 message.append("\n"); 14748 message.append("Actual output out: "); 14749 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14750 if (args.out != arrayOut[i * 2 + j]) { 14751 message.append(" FAIL"); 14752 } 14753 message.append("\n"); 14754 message.append("Errors at"); 14755 } 14756 message.append(" ["); 14757 message.append(Integer.toString(i)); 14758 message.append(", "); 14759 message.append(Integer.toString(j)); 14760 message.append("]"); 14761 } 14762 } 14763 } 14764 assertFalse("Incorrect output for checkConvertDouble2Short2" + 14765 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14766 } 14767 14768 private void checkConvertDouble3Short3() { 14769 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b72116b53876d7l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 14770 try { 14771 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14772 script.forEach_testConvertShort3Double3Short3(inV, out); 14773 verifyResultsConvertDouble3Short3(inV, out, false); 14774 out.destroy(); 14775 } catch (Exception e) { 14776 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString()); 14777 } 14778 try { 14779 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14780 scriptRelaxed.forEach_testConvertShort3Double3Short3(inV, out); 14781 verifyResultsConvertDouble3Short3(inV, out, true); 14782 out.destroy(); 14783 } catch (Exception e) { 14784 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString()); 14785 } 14786 inV.destroy(); 14787 } 14788 14789 private void verifyResultsConvertDouble3Short3(Allocation inV, Allocation out, boolean relaxed) { 14790 double[] arrayInV = new double[INPUTSIZE * 4]; 14791 Arrays.fill(arrayInV, (double) 42); 14792 inV.copyTo(arrayInV); 14793 short[] arrayOut = new short[INPUTSIZE * 4]; 14794 Arrays.fill(arrayOut, (short) 42); 14795 out.copyTo(arrayOut); 14796 StringBuilder message = new StringBuilder(); 14797 boolean errorFound = false; 14798 for (int i = 0; i < INPUTSIZE; i++) { 14799 for (int j = 0; j < 3 ; j++) { 14800 // Extract the inputs. 14801 ArgumentsDoubleShort args = new ArgumentsDoubleShort(); 14802 args.inV = arrayInV[i * 4 + j]; 14803 // Figure out what the outputs should have been. 14804 CoreMathVerifier.computeConvert(args); 14805 // Validate the outputs. 14806 boolean valid = true; 14807 if (args.out != arrayOut[i * 4 + j]) { 14808 valid = false; 14809 } 14810 if (!valid) { 14811 if (!errorFound) { 14812 errorFound = true; 14813 message.append("Input inV: "); 14814 appendVariableToMessage(message, args.inV); 14815 message.append("\n"); 14816 message.append("Expected output out: "); 14817 appendVariableToMessage(message, args.out); 14818 message.append("\n"); 14819 message.append("Actual output out: "); 14820 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14821 if (args.out != arrayOut[i * 4 + j]) { 14822 message.append(" FAIL"); 14823 } 14824 message.append("\n"); 14825 message.append("Errors at"); 14826 } 14827 message.append(" ["); 14828 message.append(Integer.toString(i)); 14829 message.append(", "); 14830 message.append(Integer.toString(j)); 14831 message.append("]"); 14832 } 14833 } 14834 } 14835 assertFalse("Incorrect output for checkConvertDouble3Short3" + 14836 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14837 } 14838 14839 private void checkConvertDouble4Short4() { 14840 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b8ea31ab5397b5l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 14841 try { 14842 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14843 script.forEach_testConvertShort4Double4Short4(inV, out); 14844 verifyResultsConvertDouble4Short4(inV, out, false); 14845 out.destroy(); 14846 } catch (Exception e) { 14847 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString()); 14848 } 14849 try { 14850 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14851 scriptRelaxed.forEach_testConvertShort4Double4Short4(inV, out); 14852 verifyResultsConvertDouble4Short4(inV, out, true); 14853 out.destroy(); 14854 } catch (Exception e) { 14855 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString()); 14856 } 14857 inV.destroy(); 14858 } 14859 14860 private void verifyResultsConvertDouble4Short4(Allocation inV, Allocation out, boolean relaxed) { 14861 double[] arrayInV = new double[INPUTSIZE * 4]; 14862 Arrays.fill(arrayInV, (double) 42); 14863 inV.copyTo(arrayInV); 14864 short[] arrayOut = new short[INPUTSIZE * 4]; 14865 Arrays.fill(arrayOut, (short) 42); 14866 out.copyTo(arrayOut); 14867 StringBuilder message = new StringBuilder(); 14868 boolean errorFound = false; 14869 for (int i = 0; i < INPUTSIZE; i++) { 14870 for (int j = 0; j < 4 ; j++) { 14871 // Extract the inputs. 14872 ArgumentsDoubleShort args = new ArgumentsDoubleShort(); 14873 args.inV = arrayInV[i * 4 + j]; 14874 // Figure out what the outputs should have been. 14875 CoreMathVerifier.computeConvert(args); 14876 // Validate the outputs. 14877 boolean valid = true; 14878 if (args.out != arrayOut[i * 4 + j]) { 14879 valid = false; 14880 } 14881 if (!valid) { 14882 if (!errorFound) { 14883 errorFound = true; 14884 message.append("Input inV: "); 14885 appendVariableToMessage(message, args.inV); 14886 message.append("\n"); 14887 message.append("Expected output out: "); 14888 appendVariableToMessage(message, args.out); 14889 message.append("\n"); 14890 message.append("Actual output out: "); 14891 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14892 if (args.out != arrayOut[i * 4 + j]) { 14893 message.append(" FAIL"); 14894 } 14895 message.append("\n"); 14896 message.append("Errors at"); 14897 } 14898 message.append(" ["); 14899 message.append(Integer.toString(i)); 14900 message.append(", "); 14901 message.append(Integer.toString(j)); 14902 message.append("]"); 14903 } 14904 } 14905 } 14906 assertFalse("Incorrect output for checkConvertDouble4Short4" + 14907 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14908 } 14909 14910 public class ArgumentsLongShort { 14911 public long inV; 14912 public short out; 14913 } 14914 14915 private void checkConvertLong2Short2() { 14916 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f18bff18de6600l, true, 15); 14917 try { 14918 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14919 script.forEach_testConvertShort2Long2Short2(inV, out); 14920 verifyResultsConvertLong2Short2(inV, out, false); 14921 out.destroy(); 14922 } catch (Exception e) { 14923 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString()); 14924 } 14925 try { 14926 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14927 scriptRelaxed.forEach_testConvertShort2Long2Short2(inV, out); 14928 verifyResultsConvertLong2Short2(inV, out, true); 14929 out.destroy(); 14930 } catch (Exception e) { 14931 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString()); 14932 } 14933 inV.destroy(); 14934 } 14935 14936 private void verifyResultsConvertLong2Short2(Allocation inV, Allocation out, boolean relaxed) { 14937 long[] arrayInV = new long[INPUTSIZE * 2]; 14938 Arrays.fill(arrayInV, (long) 42); 14939 inV.copyTo(arrayInV); 14940 short[] arrayOut = new short[INPUTSIZE * 2]; 14941 Arrays.fill(arrayOut, (short) 42); 14942 out.copyTo(arrayOut); 14943 StringBuilder message = new StringBuilder(); 14944 boolean errorFound = false; 14945 for (int i = 0; i < INPUTSIZE; i++) { 14946 for (int j = 0; j < 2 ; j++) { 14947 // Extract the inputs. 14948 ArgumentsLongShort args = new ArgumentsLongShort(); 14949 args.inV = arrayInV[i * 2 + j]; 14950 // Figure out what the outputs should have been. 14951 CoreMathVerifier.computeConvert(args); 14952 // Validate the outputs. 14953 boolean valid = true; 14954 if (args.out != arrayOut[i * 2 + j]) { 14955 valid = false; 14956 } 14957 if (!valid) { 14958 if (!errorFound) { 14959 errorFound = true; 14960 message.append("Input inV: "); 14961 appendVariableToMessage(message, args.inV); 14962 message.append("\n"); 14963 message.append("Expected output out: "); 14964 appendVariableToMessage(message, args.out); 14965 message.append("\n"); 14966 message.append("Actual output out: "); 14967 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14968 if (args.out != arrayOut[i * 2 + j]) { 14969 message.append(" FAIL"); 14970 } 14971 message.append("\n"); 14972 message.append("Errors at"); 14973 } 14974 message.append(" ["); 14975 message.append(Integer.toString(i)); 14976 message.append(", "); 14977 message.append(Integer.toString(j)); 14978 message.append("]"); 14979 } 14980 } 14981 } 14982 assertFalse("Incorrect output for checkConvertLong2Short2" + 14983 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14984 } 14985 14986 private void checkConvertLong3Short3() { 14987 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f3551a0ef986del, true, 15); 14988 try { 14989 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14990 script.forEach_testConvertShort3Long3Short3(inV, out); 14991 verifyResultsConvertLong3Short3(inV, out, false); 14992 out.destroy(); 14993 } catch (Exception e) { 14994 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString()); 14995 } 14996 try { 14997 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14998 scriptRelaxed.forEach_testConvertShort3Long3Short3(inV, out); 14999 verifyResultsConvertLong3Short3(inV, out, true); 15000 out.destroy(); 15001 } catch (Exception e) { 15002 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString()); 15003 } 15004 inV.destroy(); 15005 } 15006 15007 private void verifyResultsConvertLong3Short3(Allocation inV, Allocation out, boolean relaxed) { 15008 long[] arrayInV = new long[INPUTSIZE * 4]; 15009 Arrays.fill(arrayInV, (long) 42); 15010 inV.copyTo(arrayInV); 15011 short[] arrayOut = new short[INPUTSIZE * 4]; 15012 Arrays.fill(arrayOut, (short) 42); 15013 out.copyTo(arrayOut); 15014 StringBuilder message = new StringBuilder(); 15015 boolean errorFound = false; 15016 for (int i = 0; i < INPUTSIZE; i++) { 15017 for (int j = 0; j < 3 ; j++) { 15018 // Extract the inputs. 15019 ArgumentsLongShort args = new ArgumentsLongShort(); 15020 args.inV = arrayInV[i * 4 + j]; 15021 // Figure out what the outputs should have been. 15022 CoreMathVerifier.computeConvert(args); 15023 // Validate the outputs. 15024 boolean valid = true; 15025 if (args.out != arrayOut[i * 4 + j]) { 15026 valid = false; 15027 } 15028 if (!valid) { 15029 if (!errorFound) { 15030 errorFound = true; 15031 message.append("Input inV: "); 15032 appendVariableToMessage(message, args.inV); 15033 message.append("\n"); 15034 message.append("Expected output out: "); 15035 appendVariableToMessage(message, args.out); 15036 message.append("\n"); 15037 message.append("Actual output out: "); 15038 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15039 if (args.out != arrayOut[i * 4 + j]) { 15040 message.append(" FAIL"); 15041 } 15042 message.append("\n"); 15043 message.append("Errors at"); 15044 } 15045 message.append(" ["); 15046 message.append(Integer.toString(i)); 15047 message.append(", "); 15048 message.append(Integer.toString(j)); 15049 message.append("]"); 15050 } 15051 } 15052 } 15053 assertFalse("Incorrect output for checkConvertLong3Short3" + 15054 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15055 } 15056 15057 private void checkConvertLong4Short4() { 15058 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f51e350514a7bcl, true, 15); 15059 try { 15060 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 15061 script.forEach_testConvertShort4Long4Short4(inV, out); 15062 verifyResultsConvertLong4Short4(inV, out, false); 15063 out.destroy(); 15064 } catch (Exception e) { 15065 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString()); 15066 } 15067 try { 15068 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 15069 scriptRelaxed.forEach_testConvertShort4Long4Short4(inV, out); 15070 verifyResultsConvertLong4Short4(inV, out, true); 15071 out.destroy(); 15072 } catch (Exception e) { 15073 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString()); 15074 } 15075 inV.destroy(); 15076 } 15077 15078 private void verifyResultsConvertLong4Short4(Allocation inV, Allocation out, boolean relaxed) { 15079 long[] arrayInV = new long[INPUTSIZE * 4]; 15080 Arrays.fill(arrayInV, (long) 42); 15081 inV.copyTo(arrayInV); 15082 short[] arrayOut = new short[INPUTSIZE * 4]; 15083 Arrays.fill(arrayOut, (short) 42); 15084 out.copyTo(arrayOut); 15085 StringBuilder message = new StringBuilder(); 15086 boolean errorFound = false; 15087 for (int i = 0; i < INPUTSIZE; i++) { 15088 for (int j = 0; j < 4 ; j++) { 15089 // Extract the inputs. 15090 ArgumentsLongShort args = new ArgumentsLongShort(); 15091 args.inV = arrayInV[i * 4 + j]; 15092 // Figure out what the outputs should have been. 15093 CoreMathVerifier.computeConvert(args); 15094 // Validate the outputs. 15095 boolean valid = true; 15096 if (args.out != arrayOut[i * 4 + j]) { 15097 valid = false; 15098 } 15099 if (!valid) { 15100 if (!errorFound) { 15101 errorFound = true; 15102 message.append("Input inV: "); 15103 appendVariableToMessage(message, args.inV); 15104 message.append("\n"); 15105 message.append("Expected output out: "); 15106 appendVariableToMessage(message, args.out); 15107 message.append("\n"); 15108 message.append("Actual output out: "); 15109 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15110 if (args.out != arrayOut[i * 4 + j]) { 15111 message.append(" FAIL"); 15112 } 15113 message.append("\n"); 15114 message.append("Errors at"); 15115 } 15116 message.append(" ["); 15117 message.append(Integer.toString(i)); 15118 message.append(", "); 15119 message.append(Integer.toString(j)); 15120 message.append("]"); 15121 } 15122 } 15123 } 15124 assertFalse("Incorrect output for checkConvertLong4Short4" + 15125 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15126 } 15127 15128 public class ArgumentsUlongShort { 15129 public long inV; 15130 public short out; 15131 } 15132 15133 private void checkConvertUlong2Short2() { 15134 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfac06b4b67fabl, false, 15); 15135 try { 15136 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 15137 script.forEach_testConvertShort2Ulong2Short2(inV, out); 15138 verifyResultsConvertUlong2Short2(inV, out, false); 15139 out.destroy(); 15140 } catch (Exception e) { 15141 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString()); 15142 } 15143 try { 15144 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 15145 scriptRelaxed.forEach_testConvertShort2Ulong2Short2(inV, out); 15146 verifyResultsConvertUlong2Short2(inV, out, true); 15147 out.destroy(); 15148 } catch (Exception e) { 15149 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString()); 15150 } 15151 inV.destroy(); 15152 } 15153 15154 private void verifyResultsConvertUlong2Short2(Allocation inV, Allocation out, boolean relaxed) { 15155 long[] arrayInV = new long[INPUTSIZE * 2]; 15156 Arrays.fill(arrayInV, (long) 42); 15157 inV.copyTo(arrayInV); 15158 short[] arrayOut = new short[INPUTSIZE * 2]; 15159 Arrays.fill(arrayOut, (short) 42); 15160 out.copyTo(arrayOut); 15161 StringBuilder message = new StringBuilder(); 15162 boolean errorFound = false; 15163 for (int i = 0; i < INPUTSIZE; i++) { 15164 for (int j = 0; j < 2 ; j++) { 15165 // Extract the inputs. 15166 ArgumentsUlongShort args = new ArgumentsUlongShort(); 15167 args.inV = arrayInV[i * 2 + j]; 15168 // Figure out what the outputs should have been. 15169 CoreMathVerifier.computeConvert(args); 15170 // Validate the outputs. 15171 boolean valid = true; 15172 if (args.out != arrayOut[i * 2 + j]) { 15173 valid = false; 15174 } 15175 if (!valid) { 15176 if (!errorFound) { 15177 errorFound = true; 15178 message.append("Input inV: "); 15179 appendVariableToMessage(message, args.inV); 15180 message.append("\n"); 15181 message.append("Expected output out: "); 15182 appendVariableToMessage(message, args.out); 15183 message.append("\n"); 15184 message.append("Actual output out: "); 15185 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15186 if (args.out != arrayOut[i * 2 + j]) { 15187 message.append(" FAIL"); 15188 } 15189 message.append("\n"); 15190 message.append("Errors at"); 15191 } 15192 message.append(" ["); 15193 message.append(Integer.toString(i)); 15194 message.append(", "); 15195 message.append(Integer.toString(j)); 15196 message.append("]"); 15197 } 15198 } 15199 } 15200 assertFalse("Incorrect output for checkConvertUlong2Short2" + 15201 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15202 } 15203 15204 private void checkConvertUlong3Short3() { 15205 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec17521aad1a089l, false, 15); 15206 try { 15207 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 15208 script.forEach_testConvertShort3Ulong3Short3(inV, out); 15209 verifyResultsConvertUlong3Short3(inV, out, false); 15210 out.destroy(); 15211 } catch (Exception e) { 15212 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString()); 15213 } 15214 try { 15215 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 15216 scriptRelaxed.forEach_testConvertShort3Ulong3Short3(inV, out); 15217 verifyResultsConvertUlong3Short3(inV, out, true); 15218 out.destroy(); 15219 } catch (Exception e) { 15220 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString()); 15221 } 15222 inV.destroy(); 15223 } 15224 15225 private void verifyResultsConvertUlong3Short3(Allocation inV, Allocation out, boolean relaxed) { 15226 long[] arrayInV = new long[INPUTSIZE * 4]; 15227 Arrays.fill(arrayInV, (long) 42); 15228 inV.copyTo(arrayInV); 15229 short[] arrayOut = new short[INPUTSIZE * 4]; 15230 Arrays.fill(arrayOut, (short) 42); 15231 out.copyTo(arrayOut); 15232 StringBuilder message = new StringBuilder(); 15233 boolean errorFound = false; 15234 for (int i = 0; i < INPUTSIZE; i++) { 15235 for (int j = 0; j < 3 ; j++) { 15236 // Extract the inputs. 15237 ArgumentsUlongShort args = new ArgumentsUlongShort(); 15238 args.inV = arrayInV[i * 4 + j]; 15239 // Figure out what the outputs should have been. 15240 CoreMathVerifier.computeConvert(args); 15241 // Validate the outputs. 15242 boolean valid = true; 15243 if (args.out != arrayOut[i * 4 + j]) { 15244 valid = false; 15245 } 15246 if (!valid) { 15247 if (!errorFound) { 15248 errorFound = true; 15249 message.append("Input inV: "); 15250 appendVariableToMessage(message, args.inV); 15251 message.append("\n"); 15252 message.append("Expected output out: "); 15253 appendVariableToMessage(message, args.out); 15254 message.append("\n"); 15255 message.append("Actual output out: "); 15256 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15257 if (args.out != arrayOut[i * 4 + j]) { 15258 message.append(" FAIL"); 15259 } 15260 message.append("\n"); 15261 message.append("Errors at"); 15262 } 15263 message.append(" ["); 15264 message.append(Integer.toString(i)); 15265 message.append(", "); 15266 message.append(Integer.toString(j)); 15267 message.append("]"); 15268 } 15269 } 15270 } 15271 assertFalse("Incorrect output for checkConvertUlong3Short3" + 15272 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15273 } 15274 15275 private void checkConvertUlong4Short4() { 15276 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec33e3ca0ecc167l, false, 15); 15277 try { 15278 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 15279 script.forEach_testConvertShort4Ulong4Short4(inV, out); 15280 verifyResultsConvertUlong4Short4(inV, out, false); 15281 out.destroy(); 15282 } catch (Exception e) { 15283 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString()); 15284 } 15285 try { 15286 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 15287 scriptRelaxed.forEach_testConvertShort4Ulong4Short4(inV, out); 15288 verifyResultsConvertUlong4Short4(inV, out, true); 15289 out.destroy(); 15290 } catch (Exception e) { 15291 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString()); 15292 } 15293 inV.destroy(); 15294 } 15295 15296 private void verifyResultsConvertUlong4Short4(Allocation inV, Allocation out, boolean relaxed) { 15297 long[] arrayInV = new long[INPUTSIZE * 4]; 15298 Arrays.fill(arrayInV, (long) 42); 15299 inV.copyTo(arrayInV); 15300 short[] arrayOut = new short[INPUTSIZE * 4]; 15301 Arrays.fill(arrayOut, (short) 42); 15302 out.copyTo(arrayOut); 15303 StringBuilder message = new StringBuilder(); 15304 boolean errorFound = false; 15305 for (int i = 0; i < INPUTSIZE; i++) { 15306 for (int j = 0; j < 4 ; j++) { 15307 // Extract the inputs. 15308 ArgumentsUlongShort args = new ArgumentsUlongShort(); 15309 args.inV = arrayInV[i * 4 + j]; 15310 // Figure out what the outputs should have been. 15311 CoreMathVerifier.computeConvert(args); 15312 // Validate the outputs. 15313 boolean valid = true; 15314 if (args.out != arrayOut[i * 4 + j]) { 15315 valid = false; 15316 } 15317 if (!valid) { 15318 if (!errorFound) { 15319 errorFound = true; 15320 message.append("Input inV: "); 15321 appendVariableToMessage(message, args.inV); 15322 message.append("\n"); 15323 message.append("Expected output out: "); 15324 appendVariableToMessage(message, args.out); 15325 message.append("\n"); 15326 message.append("Actual output out: "); 15327 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15328 if (args.out != arrayOut[i * 4 + j]) { 15329 message.append(" FAIL"); 15330 } 15331 message.append("\n"); 15332 message.append("Errors at"); 15333 } 15334 message.append(" ["); 15335 message.append(Integer.toString(i)); 15336 message.append(", "); 15337 message.append(Integer.toString(j)); 15338 message.append("]"); 15339 } 15340 } 15341 } 15342 assertFalse("Incorrect output for checkConvertUlong4Short4" + 15343 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15344 } 15345 15346 public class ArgumentsDoubleUshort { 15347 public double inV; 15348 public short out; 15349 } 15350 15351 private void checkConvertDouble2Ushort2() { 15352 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x3479ccaea92a37bcl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 15353 try { 15354 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15355 script.forEach_testConvertUshort2Double2Ushort2(inV, out); 15356 verifyResultsConvertDouble2Ushort2(inV, out, false); 15357 out.destroy(); 15358 } catch (Exception e) { 15359 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString()); 15360 } 15361 try { 15362 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15363 scriptRelaxed.forEach_testConvertUshort2Double2Ushort2(inV, out); 15364 verifyResultsConvertDouble2Ushort2(inV, out, true); 15365 out.destroy(); 15366 } catch (Exception e) { 15367 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString()); 15368 } 15369 inV.destroy(); 15370 } 15371 15372 private void verifyResultsConvertDouble2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 15373 double[] arrayInV = new double[INPUTSIZE * 2]; 15374 Arrays.fill(arrayInV, (double) 42); 15375 inV.copyTo(arrayInV); 15376 short[] arrayOut = new short[INPUTSIZE * 2]; 15377 Arrays.fill(arrayOut, (short) 42); 15378 out.copyTo(arrayOut); 15379 StringBuilder message = new StringBuilder(); 15380 boolean errorFound = false; 15381 for (int i = 0; i < INPUTSIZE; i++) { 15382 for (int j = 0; j < 2 ; j++) { 15383 // Extract the inputs. 15384 ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); 15385 args.inV = arrayInV[i * 2 + j]; 15386 // Figure out what the outputs should have been. 15387 CoreMathVerifier.computeConvert(args); 15388 // Validate the outputs. 15389 boolean valid = true; 15390 if (args.out != arrayOut[i * 2 + j]) { 15391 valid = false; 15392 } 15393 if (!valid) { 15394 if (!errorFound) { 15395 errorFound = true; 15396 message.append("Input inV: "); 15397 appendVariableToMessage(message, args.inV); 15398 message.append("\n"); 15399 message.append("Expected output out: "); 15400 appendVariableToMessage(message, args.out); 15401 message.append("\n"); 15402 message.append("Actual output out: "); 15403 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15404 if (args.out != arrayOut[i * 2 + j]) { 15405 message.append(" FAIL"); 15406 } 15407 message.append("\n"); 15408 message.append("Errors at"); 15409 } 15410 message.append(" ["); 15411 message.append(Integer.toString(i)); 15412 message.append(", "); 15413 message.append(Integer.toString(j)); 15414 message.append("]"); 15415 } 15416 } 15417 } 15418 assertFalse("Incorrect output for checkConvertDouble2Ushort2" + 15419 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15420 } 15421 15422 private void checkConvertDouble3Ushort3() { 15423 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x34c69435ff85c8e8l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 15424 try { 15425 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15426 script.forEach_testConvertUshort3Double3Ushort3(inV, out); 15427 verifyResultsConvertDouble3Ushort3(inV, out, false); 15428 out.destroy(); 15429 } catch (Exception e) { 15430 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString()); 15431 } 15432 try { 15433 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15434 scriptRelaxed.forEach_testConvertUshort3Double3Ushort3(inV, out); 15435 verifyResultsConvertDouble3Ushort3(inV, out, true); 15436 out.destroy(); 15437 } catch (Exception e) { 15438 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString()); 15439 } 15440 inV.destroy(); 15441 } 15442 15443 private void verifyResultsConvertDouble3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 15444 double[] arrayInV = new double[INPUTSIZE * 4]; 15445 Arrays.fill(arrayInV, (double) 42); 15446 inV.copyTo(arrayInV); 15447 short[] arrayOut = new short[INPUTSIZE * 4]; 15448 Arrays.fill(arrayOut, (short) 42); 15449 out.copyTo(arrayOut); 15450 StringBuilder message = new StringBuilder(); 15451 boolean errorFound = false; 15452 for (int i = 0; i < INPUTSIZE; i++) { 15453 for (int j = 0; j < 3 ; j++) { 15454 // Extract the inputs. 15455 ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); 15456 args.inV = arrayInV[i * 4 + j]; 15457 // Figure out what the outputs should have been. 15458 CoreMathVerifier.computeConvert(args); 15459 // Validate the outputs. 15460 boolean valid = true; 15461 if (args.out != arrayOut[i * 4 + j]) { 15462 valid = false; 15463 } 15464 if (!valid) { 15465 if (!errorFound) { 15466 errorFound = true; 15467 message.append("Input inV: "); 15468 appendVariableToMessage(message, args.inV); 15469 message.append("\n"); 15470 message.append("Expected output out: "); 15471 appendVariableToMessage(message, args.out); 15472 message.append("\n"); 15473 message.append("Actual output out: "); 15474 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15475 if (args.out != arrayOut[i * 4 + j]) { 15476 message.append(" FAIL"); 15477 } 15478 message.append("\n"); 15479 message.append("Errors at"); 15480 } 15481 message.append(" ["); 15482 message.append(Integer.toString(i)); 15483 message.append(", "); 15484 message.append(Integer.toString(j)); 15485 message.append("]"); 15486 } 15487 } 15488 } 15489 assertFalse("Incorrect output for checkConvertDouble3Ushort3" + 15490 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15491 } 15492 15493 private void checkConvertDouble4Ushort4() { 15494 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x35135bbd55e15a14l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 15495 try { 15496 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15497 script.forEach_testConvertUshort4Double4Ushort4(inV, out); 15498 verifyResultsConvertDouble4Ushort4(inV, out, false); 15499 out.destroy(); 15500 } catch (Exception e) { 15501 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString()); 15502 } 15503 try { 15504 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15505 scriptRelaxed.forEach_testConvertUshort4Double4Ushort4(inV, out); 15506 verifyResultsConvertDouble4Ushort4(inV, out, true); 15507 out.destroy(); 15508 } catch (Exception e) { 15509 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString()); 15510 } 15511 inV.destroy(); 15512 } 15513 15514 private void verifyResultsConvertDouble4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 15515 double[] arrayInV = new double[INPUTSIZE * 4]; 15516 Arrays.fill(arrayInV, (double) 42); 15517 inV.copyTo(arrayInV); 15518 short[] arrayOut = new short[INPUTSIZE * 4]; 15519 Arrays.fill(arrayOut, (short) 42); 15520 out.copyTo(arrayOut); 15521 StringBuilder message = new StringBuilder(); 15522 boolean errorFound = false; 15523 for (int i = 0; i < INPUTSIZE; i++) { 15524 for (int j = 0; j < 4 ; j++) { 15525 // Extract the inputs. 15526 ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); 15527 args.inV = arrayInV[i * 4 + j]; 15528 // Figure out what the outputs should have been. 15529 CoreMathVerifier.computeConvert(args); 15530 // Validate the outputs. 15531 boolean valid = true; 15532 if (args.out != arrayOut[i * 4 + j]) { 15533 valid = false; 15534 } 15535 if (!valid) { 15536 if (!errorFound) { 15537 errorFound = true; 15538 message.append("Input inV: "); 15539 appendVariableToMessage(message, args.inV); 15540 message.append("\n"); 15541 message.append("Expected output out: "); 15542 appendVariableToMessage(message, args.out); 15543 message.append("\n"); 15544 message.append("Actual output out: "); 15545 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15546 if (args.out != arrayOut[i * 4 + j]) { 15547 message.append(" FAIL"); 15548 } 15549 message.append("\n"); 15550 message.append("Errors at"); 15551 } 15552 message.append(" ["); 15553 message.append(Integer.toString(i)); 15554 message.append(", "); 15555 message.append(Integer.toString(j)); 15556 message.append("]"); 15557 } 15558 } 15559 } 15560 assertFalse("Incorrect output for checkConvertDouble4Ushort4" + 15561 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15562 } 15563 15564 public class ArgumentsLongUshort { 15565 public long inV; 15566 public short out; 15567 } 15568 15569 private void checkConvertLong2Ushort2() { 15570 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7b96893ebc97e8e9l, false, 16); 15571 try { 15572 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15573 script.forEach_testConvertUshort2Long2Ushort2(inV, out); 15574 verifyResultsConvertLong2Ushort2(inV, out, false); 15575 out.destroy(); 15576 } catch (Exception e) { 15577 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString()); 15578 } 15579 try { 15580 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15581 scriptRelaxed.forEach_testConvertUshort2Long2Ushort2(inV, out); 15582 verifyResultsConvertLong2Ushort2(inV, out, true); 15583 out.destroy(); 15584 } catch (Exception e) { 15585 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString()); 15586 } 15587 inV.destroy(); 15588 } 15589 15590 private void verifyResultsConvertLong2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 15591 long[] arrayInV = new long[INPUTSIZE * 2]; 15592 Arrays.fill(arrayInV, (long) 42); 15593 inV.copyTo(arrayInV); 15594 short[] arrayOut = new short[INPUTSIZE * 2]; 15595 Arrays.fill(arrayOut, (short) 42); 15596 out.copyTo(arrayOut); 15597 StringBuilder message = new StringBuilder(); 15598 boolean errorFound = false; 15599 for (int i = 0; i < INPUTSIZE; i++) { 15600 for (int j = 0; j < 2 ; j++) { 15601 // Extract the inputs. 15602 ArgumentsLongUshort args = new ArgumentsLongUshort(); 15603 args.inV = arrayInV[i * 2 + j]; 15604 // Figure out what the outputs should have been. 15605 CoreMathVerifier.computeConvert(args); 15606 // Validate the outputs. 15607 boolean valid = true; 15608 if (args.out != arrayOut[i * 2 + j]) { 15609 valid = false; 15610 } 15611 if (!valid) { 15612 if (!errorFound) { 15613 errorFound = true; 15614 message.append("Input inV: "); 15615 appendVariableToMessage(message, args.inV); 15616 message.append("\n"); 15617 message.append("Expected output out: "); 15618 appendVariableToMessage(message, args.out); 15619 message.append("\n"); 15620 message.append("Actual output out: "); 15621 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15622 if (args.out != arrayOut[i * 2 + j]) { 15623 message.append(" FAIL"); 15624 } 15625 message.append("\n"); 15626 message.append("Errors at"); 15627 } 15628 message.append(" ["); 15629 message.append(Integer.toString(i)); 15630 message.append(", "); 15631 message.append(Integer.toString(j)); 15632 message.append("]"); 15633 } 15634 } 15635 } 15636 assertFalse("Incorrect output for checkConvertLong2Ushort2" + 15637 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15638 } 15639 15640 private void checkConvertLong3Ushort3() { 15641 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7be350c612f37a15l, false, 16); 15642 try { 15643 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15644 script.forEach_testConvertUshort3Long3Ushort3(inV, out); 15645 verifyResultsConvertLong3Ushort3(inV, out, false); 15646 out.destroy(); 15647 } catch (Exception e) { 15648 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString()); 15649 } 15650 try { 15651 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15652 scriptRelaxed.forEach_testConvertUshort3Long3Ushort3(inV, out); 15653 verifyResultsConvertLong3Ushort3(inV, out, true); 15654 out.destroy(); 15655 } catch (Exception e) { 15656 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString()); 15657 } 15658 inV.destroy(); 15659 } 15660 15661 private void verifyResultsConvertLong3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 15662 long[] arrayInV = new long[INPUTSIZE * 4]; 15663 Arrays.fill(arrayInV, (long) 42); 15664 inV.copyTo(arrayInV); 15665 short[] arrayOut = new short[INPUTSIZE * 4]; 15666 Arrays.fill(arrayOut, (short) 42); 15667 out.copyTo(arrayOut); 15668 StringBuilder message = new StringBuilder(); 15669 boolean errorFound = false; 15670 for (int i = 0; i < INPUTSIZE; i++) { 15671 for (int j = 0; j < 3 ; j++) { 15672 // Extract the inputs. 15673 ArgumentsLongUshort args = new ArgumentsLongUshort(); 15674 args.inV = arrayInV[i * 4 + j]; 15675 // Figure out what the outputs should have been. 15676 CoreMathVerifier.computeConvert(args); 15677 // Validate the outputs. 15678 boolean valid = true; 15679 if (args.out != arrayOut[i * 4 + j]) { 15680 valid = false; 15681 } 15682 if (!valid) { 15683 if (!errorFound) { 15684 errorFound = true; 15685 message.append("Input inV: "); 15686 appendVariableToMessage(message, args.inV); 15687 message.append("\n"); 15688 message.append("Expected output out: "); 15689 appendVariableToMessage(message, args.out); 15690 message.append("\n"); 15691 message.append("Actual output out: "); 15692 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15693 if (args.out != arrayOut[i * 4 + j]) { 15694 message.append(" FAIL"); 15695 } 15696 message.append("\n"); 15697 message.append("Errors at"); 15698 } 15699 message.append(" ["); 15700 message.append(Integer.toString(i)); 15701 message.append(", "); 15702 message.append(Integer.toString(j)); 15703 message.append("]"); 15704 } 15705 } 15706 } 15707 assertFalse("Incorrect output for checkConvertLong3Ushort3" + 15708 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15709 } 15710 15711 private void checkConvertLong4Ushort4() { 15712 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7c30184d694f0b41l, false, 16); 15713 try { 15714 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15715 script.forEach_testConvertUshort4Long4Ushort4(inV, out); 15716 verifyResultsConvertLong4Ushort4(inV, out, false); 15717 out.destroy(); 15718 } catch (Exception e) { 15719 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString()); 15720 } 15721 try { 15722 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15723 scriptRelaxed.forEach_testConvertUshort4Long4Ushort4(inV, out); 15724 verifyResultsConvertLong4Ushort4(inV, out, true); 15725 out.destroy(); 15726 } catch (Exception e) { 15727 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString()); 15728 } 15729 inV.destroy(); 15730 } 15731 15732 private void verifyResultsConvertLong4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 15733 long[] arrayInV = new long[INPUTSIZE * 4]; 15734 Arrays.fill(arrayInV, (long) 42); 15735 inV.copyTo(arrayInV); 15736 short[] arrayOut = new short[INPUTSIZE * 4]; 15737 Arrays.fill(arrayOut, (short) 42); 15738 out.copyTo(arrayOut); 15739 StringBuilder message = new StringBuilder(); 15740 boolean errorFound = false; 15741 for (int i = 0; i < INPUTSIZE; i++) { 15742 for (int j = 0; j < 4 ; j++) { 15743 // Extract the inputs. 15744 ArgumentsLongUshort args = new ArgumentsLongUshort(); 15745 args.inV = arrayInV[i * 4 + j]; 15746 // Figure out what the outputs should have been. 15747 CoreMathVerifier.computeConvert(args); 15748 // Validate the outputs. 15749 boolean valid = true; 15750 if (args.out != arrayOut[i * 4 + j]) { 15751 valid = false; 15752 } 15753 if (!valid) { 15754 if (!errorFound) { 15755 errorFound = true; 15756 message.append("Input inV: "); 15757 appendVariableToMessage(message, args.inV); 15758 message.append("\n"); 15759 message.append("Expected output out: "); 15760 appendVariableToMessage(message, args.out); 15761 message.append("\n"); 15762 message.append("Actual output out: "); 15763 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15764 if (args.out != arrayOut[i * 4 + j]) { 15765 message.append(" FAIL"); 15766 } 15767 message.append("\n"); 15768 message.append("Errors at"); 15769 } 15770 message.append(" ["); 15771 message.append(Integer.toString(i)); 15772 message.append(", "); 15773 message.append(Integer.toString(j)); 15774 message.append("]"); 15775 } 15776 } 15777 } 15778 assertFalse("Incorrect output for checkConvertLong4Ushort4" + 15779 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15780 } 15781 15782 public class ArgumentsUlongUshort { 15783 public long inV; 15784 public short out; 15785 } 15786 15787 private void checkConvertUlong2Ushort2() { 15788 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xaa35ea85e9e438a2l, false, 16); 15789 try { 15790 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15791 script.forEach_testConvertUshort2Ulong2Ushort2(inV, out); 15792 verifyResultsConvertUlong2Ushort2(inV, out, false); 15793 out.destroy(); 15794 } catch (Exception e) { 15795 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString()); 15796 } 15797 try { 15798 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15799 scriptRelaxed.forEach_testConvertUshort2Ulong2Ushort2(inV, out); 15800 verifyResultsConvertUlong2Ushort2(inV, out, true); 15801 out.destroy(); 15802 } catch (Exception e) { 15803 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString()); 15804 } 15805 inV.destroy(); 15806 } 15807 15808 private void verifyResultsConvertUlong2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 15809 long[] arrayInV = new long[INPUTSIZE * 2]; 15810 Arrays.fill(arrayInV, (long) 42); 15811 inV.copyTo(arrayInV); 15812 short[] arrayOut = new short[INPUTSIZE * 2]; 15813 Arrays.fill(arrayOut, (short) 42); 15814 out.copyTo(arrayOut); 15815 StringBuilder message = new StringBuilder(); 15816 boolean errorFound = false; 15817 for (int i = 0; i < INPUTSIZE; i++) { 15818 for (int j = 0; j < 2 ; j++) { 15819 // Extract the inputs. 15820 ArgumentsUlongUshort args = new ArgumentsUlongUshort(); 15821 args.inV = arrayInV[i * 2 + j]; 15822 // Figure out what the outputs should have been. 15823 CoreMathVerifier.computeConvert(args); 15824 // Validate the outputs. 15825 boolean valid = true; 15826 if (args.out != arrayOut[i * 2 + j]) { 15827 valid = false; 15828 } 15829 if (!valid) { 15830 if (!errorFound) { 15831 errorFound = true; 15832 message.append("Input inV: "); 15833 appendVariableToMessage(message, args.inV); 15834 message.append("\n"); 15835 message.append("Expected output out: "); 15836 appendVariableToMessage(message, args.out); 15837 message.append("\n"); 15838 message.append("Actual output out: "); 15839 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15840 if (args.out != arrayOut[i * 2 + j]) { 15841 message.append(" FAIL"); 15842 } 15843 message.append("\n"); 15844 message.append("Errors at"); 15845 } 15846 message.append(" ["); 15847 message.append(Integer.toString(i)); 15848 message.append(", "); 15849 message.append(Integer.toString(j)); 15850 message.append("]"); 15851 } 15852 } 15853 } 15854 assertFalse("Incorrect output for checkConvertUlong2Ushort2" + 15855 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15856 } 15857 15858 private void checkConvertUlong3Ushort3() { 15859 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaa82b20d403fc9cel, false, 16); 15860 try { 15861 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15862 script.forEach_testConvertUshort3Ulong3Ushort3(inV, out); 15863 verifyResultsConvertUlong3Ushort3(inV, out, false); 15864 out.destroy(); 15865 } catch (Exception e) { 15866 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString()); 15867 } 15868 try { 15869 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15870 scriptRelaxed.forEach_testConvertUshort3Ulong3Ushort3(inV, out); 15871 verifyResultsConvertUlong3Ushort3(inV, out, true); 15872 out.destroy(); 15873 } catch (Exception e) { 15874 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString()); 15875 } 15876 inV.destroy(); 15877 } 15878 15879 private void verifyResultsConvertUlong3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 15880 long[] arrayInV = new long[INPUTSIZE * 4]; 15881 Arrays.fill(arrayInV, (long) 42); 15882 inV.copyTo(arrayInV); 15883 short[] arrayOut = new short[INPUTSIZE * 4]; 15884 Arrays.fill(arrayOut, (short) 42); 15885 out.copyTo(arrayOut); 15886 StringBuilder message = new StringBuilder(); 15887 boolean errorFound = false; 15888 for (int i = 0; i < INPUTSIZE; i++) { 15889 for (int j = 0; j < 3 ; j++) { 15890 // Extract the inputs. 15891 ArgumentsUlongUshort args = new ArgumentsUlongUshort(); 15892 args.inV = arrayInV[i * 4 + j]; 15893 // Figure out what the outputs should have been. 15894 CoreMathVerifier.computeConvert(args); 15895 // Validate the outputs. 15896 boolean valid = true; 15897 if (args.out != arrayOut[i * 4 + j]) { 15898 valid = false; 15899 } 15900 if (!valid) { 15901 if (!errorFound) { 15902 errorFound = true; 15903 message.append("Input inV: "); 15904 appendVariableToMessage(message, args.inV); 15905 message.append("\n"); 15906 message.append("Expected output out: "); 15907 appendVariableToMessage(message, args.out); 15908 message.append("\n"); 15909 message.append("Actual output out: "); 15910 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15911 if (args.out != arrayOut[i * 4 + j]) { 15912 message.append(" FAIL"); 15913 } 15914 message.append("\n"); 15915 message.append("Errors at"); 15916 } 15917 message.append(" ["); 15918 message.append(Integer.toString(i)); 15919 message.append(", "); 15920 message.append(Integer.toString(j)); 15921 message.append("]"); 15922 } 15923 } 15924 } 15925 assertFalse("Incorrect output for checkConvertUlong3Ushort3" + 15926 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15927 } 15928 15929 private void checkConvertUlong4Ushort4() { 15930 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xaacf7994969b5afal, false, 16); 15931 try { 15932 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15933 script.forEach_testConvertUshort4Ulong4Ushort4(inV, out); 15934 verifyResultsConvertUlong4Ushort4(inV, out, false); 15935 out.destroy(); 15936 } catch (Exception e) { 15937 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString()); 15938 } 15939 try { 15940 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15941 scriptRelaxed.forEach_testConvertUshort4Ulong4Ushort4(inV, out); 15942 verifyResultsConvertUlong4Ushort4(inV, out, true); 15943 out.destroy(); 15944 } catch (Exception e) { 15945 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString()); 15946 } 15947 inV.destroy(); 15948 } 15949 15950 private void verifyResultsConvertUlong4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 15951 long[] arrayInV = new long[INPUTSIZE * 4]; 15952 Arrays.fill(arrayInV, (long) 42); 15953 inV.copyTo(arrayInV); 15954 short[] arrayOut = new short[INPUTSIZE * 4]; 15955 Arrays.fill(arrayOut, (short) 42); 15956 out.copyTo(arrayOut); 15957 StringBuilder message = new StringBuilder(); 15958 boolean errorFound = false; 15959 for (int i = 0; i < INPUTSIZE; i++) { 15960 for (int j = 0; j < 4 ; j++) { 15961 // Extract the inputs. 15962 ArgumentsUlongUshort args = new ArgumentsUlongUshort(); 15963 args.inV = arrayInV[i * 4 + j]; 15964 // Figure out what the outputs should have been. 15965 CoreMathVerifier.computeConvert(args); 15966 // Validate the outputs. 15967 boolean valid = true; 15968 if (args.out != arrayOut[i * 4 + j]) { 15969 valid = false; 15970 } 15971 if (!valid) { 15972 if (!errorFound) { 15973 errorFound = true; 15974 message.append("Input inV: "); 15975 appendVariableToMessage(message, args.inV); 15976 message.append("\n"); 15977 message.append("Expected output out: "); 15978 appendVariableToMessage(message, args.out); 15979 message.append("\n"); 15980 message.append("Actual output out: "); 15981 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15982 if (args.out != arrayOut[i * 4 + j]) { 15983 message.append(" FAIL"); 15984 } 15985 message.append("\n"); 15986 message.append("Errors at"); 15987 } 15988 message.append(" ["); 15989 message.append(Integer.toString(i)); 15990 message.append(", "); 15991 message.append(Integer.toString(j)); 15992 message.append("]"); 15993 } 15994 } 15995 } 15996 assertFalse("Incorrect output for checkConvertUlong4Ushort4" + 15997 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15998 } 15999 16000 public class ArgumentsDoubleInt { 16001 public double inV; 16002 public int out; 16003 } 16004 16005 private void checkConvertDouble2Int2() { 16006 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xa57cd81dcaf628fcl, -2.1474836480000000000e+09, 2.1474836470000000000e+09); 16007 try { 16008 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 16009 script.forEach_testConvertInt2Double2Int2(inV, out); 16010 verifyResultsConvertDouble2Int2(inV, out, false); 16011 out.destroy(); 16012 } catch (Exception e) { 16013 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString()); 16014 } 16015 try { 16016 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 16017 scriptRelaxed.forEach_testConvertInt2Double2Int2(inV, out); 16018 verifyResultsConvertDouble2Int2(inV, out, true); 16019 out.destroy(); 16020 } catch (Exception e) { 16021 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString()); 16022 } 16023 inV.destroy(); 16024 } 16025 16026 private void verifyResultsConvertDouble2Int2(Allocation inV, Allocation out, boolean relaxed) { 16027 double[] arrayInV = new double[INPUTSIZE * 2]; 16028 Arrays.fill(arrayInV, (double) 42); 16029 inV.copyTo(arrayInV); 16030 int[] arrayOut = new int[INPUTSIZE * 2]; 16031 Arrays.fill(arrayOut, (int) 42); 16032 out.copyTo(arrayOut); 16033 StringBuilder message = new StringBuilder(); 16034 boolean errorFound = false; 16035 for (int i = 0; i < INPUTSIZE; i++) { 16036 for (int j = 0; j < 2 ; j++) { 16037 // Extract the inputs. 16038 ArgumentsDoubleInt args = new ArgumentsDoubleInt(); 16039 args.inV = arrayInV[i * 2 + j]; 16040 // Figure out what the outputs should have been. 16041 CoreMathVerifier.computeConvert(args); 16042 // Validate the outputs. 16043 boolean valid = true; 16044 if (args.out != arrayOut[i * 2 + j]) { 16045 valid = false; 16046 } 16047 if (!valid) { 16048 if (!errorFound) { 16049 errorFound = true; 16050 message.append("Input inV: "); 16051 appendVariableToMessage(message, args.inV); 16052 message.append("\n"); 16053 message.append("Expected output out: "); 16054 appendVariableToMessage(message, args.out); 16055 message.append("\n"); 16056 message.append("Actual output out: "); 16057 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16058 if (args.out != arrayOut[i * 2 + j]) { 16059 message.append(" FAIL"); 16060 } 16061 message.append("\n"); 16062 message.append("Errors at"); 16063 } 16064 message.append(" ["); 16065 message.append(Integer.toString(i)); 16066 message.append(", "); 16067 message.append(Integer.toString(j)); 16068 message.append("]"); 16069 } 16070 } 16071 } 16072 assertFalse("Incorrect output for checkConvertDouble2Int2" + 16073 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16074 } 16075 16076 private void checkConvertDouble3Int3() { 16077 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xa57cd85d149e3932l, -2.1474836480000000000e+09, 2.1474836470000000000e+09); 16078 try { 16079 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 16080 script.forEach_testConvertInt3Double3Int3(inV, out); 16081 verifyResultsConvertDouble3Int3(inV, out, false); 16082 out.destroy(); 16083 } catch (Exception e) { 16084 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString()); 16085 } 16086 try { 16087 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 16088 scriptRelaxed.forEach_testConvertInt3Double3Int3(inV, out); 16089 verifyResultsConvertDouble3Int3(inV, out, true); 16090 out.destroy(); 16091 } catch (Exception e) { 16092 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString()); 16093 } 16094 inV.destroy(); 16095 } 16096 16097 private void verifyResultsConvertDouble3Int3(Allocation inV, Allocation out, boolean relaxed) { 16098 double[] arrayInV = new double[INPUTSIZE * 4]; 16099 Arrays.fill(arrayInV, (double) 42); 16100 inV.copyTo(arrayInV); 16101 int[] arrayOut = new int[INPUTSIZE * 4]; 16102 Arrays.fill(arrayOut, (int) 42); 16103 out.copyTo(arrayOut); 16104 StringBuilder message = new StringBuilder(); 16105 boolean errorFound = false; 16106 for (int i = 0; i < INPUTSIZE; i++) { 16107 for (int j = 0; j < 3 ; j++) { 16108 // Extract the inputs. 16109 ArgumentsDoubleInt args = new ArgumentsDoubleInt(); 16110 args.inV = arrayInV[i * 4 + j]; 16111 // Figure out what the outputs should have been. 16112 CoreMathVerifier.computeConvert(args); 16113 // Validate the outputs. 16114 boolean valid = true; 16115 if (args.out != arrayOut[i * 4 + j]) { 16116 valid = false; 16117 } 16118 if (!valid) { 16119 if (!errorFound) { 16120 errorFound = true; 16121 message.append("Input inV: "); 16122 appendVariableToMessage(message, args.inV); 16123 message.append("\n"); 16124 message.append("Expected output out: "); 16125 appendVariableToMessage(message, args.out); 16126 message.append("\n"); 16127 message.append("Actual output out: "); 16128 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16129 if (args.out != arrayOut[i * 4 + j]) { 16130 message.append(" FAIL"); 16131 } 16132 message.append("\n"); 16133 message.append("Errors at"); 16134 } 16135 message.append(" ["); 16136 message.append(Integer.toString(i)); 16137 message.append(", "); 16138 message.append(Integer.toString(j)); 16139 message.append("]"); 16140 } 16141 } 16142 } 16143 assertFalse("Incorrect output for checkConvertDouble3Int3" + 16144 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16145 } 16146 16147 private void checkConvertDouble4Int4() { 16148 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xa57cd89c5e464968l, -2.1474836480000000000e+09, 2.1474836470000000000e+09); 16149 try { 16150 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 16151 script.forEach_testConvertInt4Double4Int4(inV, out); 16152 verifyResultsConvertDouble4Int4(inV, out, false); 16153 out.destroy(); 16154 } catch (Exception e) { 16155 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString()); 16156 } 16157 try { 16158 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 16159 scriptRelaxed.forEach_testConvertInt4Double4Int4(inV, out); 16160 verifyResultsConvertDouble4Int4(inV, out, true); 16161 out.destroy(); 16162 } catch (Exception e) { 16163 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString()); 16164 } 16165 inV.destroy(); 16166 } 16167 16168 private void verifyResultsConvertDouble4Int4(Allocation inV, Allocation out, boolean relaxed) { 16169 double[] arrayInV = new double[INPUTSIZE * 4]; 16170 Arrays.fill(arrayInV, (double) 42); 16171 inV.copyTo(arrayInV); 16172 int[] arrayOut = new int[INPUTSIZE * 4]; 16173 Arrays.fill(arrayOut, (int) 42); 16174 out.copyTo(arrayOut); 16175 StringBuilder message = new StringBuilder(); 16176 boolean errorFound = false; 16177 for (int i = 0; i < INPUTSIZE; i++) { 16178 for (int j = 0; j < 4 ; j++) { 16179 // Extract the inputs. 16180 ArgumentsDoubleInt args = new ArgumentsDoubleInt(); 16181 args.inV = arrayInV[i * 4 + j]; 16182 // Figure out what the outputs should have been. 16183 CoreMathVerifier.computeConvert(args); 16184 // Validate the outputs. 16185 boolean valid = true; 16186 if (args.out != arrayOut[i * 4 + j]) { 16187 valid = false; 16188 } 16189 if (!valid) { 16190 if (!errorFound) { 16191 errorFound = true; 16192 message.append("Input inV: "); 16193 appendVariableToMessage(message, args.inV); 16194 message.append("\n"); 16195 message.append("Expected output out: "); 16196 appendVariableToMessage(message, args.out); 16197 message.append("\n"); 16198 message.append("Actual output out: "); 16199 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16200 if (args.out != arrayOut[i * 4 + j]) { 16201 message.append(" FAIL"); 16202 } 16203 message.append("\n"); 16204 message.append("Errors at"); 16205 } 16206 message.append(" ["); 16207 message.append(Integer.toString(i)); 16208 message.append(", "); 16209 message.append(Integer.toString(j)); 16210 message.append("]"); 16211 } 16212 } 16213 } 16214 assertFalse("Incorrect output for checkConvertDouble4Int4" + 16215 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16216 } 16217 16218 public class ArgumentsLongInt { 16219 public long inV; 16220 public int out; 16221 } 16222 16223 private void checkConvertLong2Int2() { 16224 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xfe441c66e5deba3bl, true, 31); 16225 try { 16226 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 16227 script.forEach_testConvertInt2Long2Int2(inV, out); 16228 verifyResultsConvertLong2Int2(inV, out, false); 16229 out.destroy(); 16230 } catch (Exception e) { 16231 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString()); 16232 } 16233 try { 16234 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 16235 scriptRelaxed.forEach_testConvertInt2Long2Int2(inV, out); 16236 verifyResultsConvertLong2Int2(inV, out, true); 16237 out.destroy(); 16238 } catch (Exception e) { 16239 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString()); 16240 } 16241 inV.destroy(); 16242 } 16243 16244 private void verifyResultsConvertLong2Int2(Allocation inV, Allocation out, boolean relaxed) { 16245 long[] arrayInV = new long[INPUTSIZE * 2]; 16246 Arrays.fill(arrayInV, (long) 42); 16247 inV.copyTo(arrayInV); 16248 int[] arrayOut = new int[INPUTSIZE * 2]; 16249 Arrays.fill(arrayOut, (int) 42); 16250 out.copyTo(arrayOut); 16251 StringBuilder message = new StringBuilder(); 16252 boolean errorFound = false; 16253 for (int i = 0; i < INPUTSIZE; i++) { 16254 for (int j = 0; j < 2 ; j++) { 16255 // Extract the inputs. 16256 ArgumentsLongInt args = new ArgumentsLongInt(); 16257 args.inV = arrayInV[i * 2 + j]; 16258 // Figure out what the outputs should have been. 16259 CoreMathVerifier.computeConvert(args); 16260 // Validate the outputs. 16261 boolean valid = true; 16262 if (args.out != arrayOut[i * 2 + j]) { 16263 valid = false; 16264 } 16265 if (!valid) { 16266 if (!errorFound) { 16267 errorFound = true; 16268 message.append("Input inV: "); 16269 appendVariableToMessage(message, args.inV); 16270 message.append("\n"); 16271 message.append("Expected output out: "); 16272 appendVariableToMessage(message, args.out); 16273 message.append("\n"); 16274 message.append("Actual output out: "); 16275 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16276 if (args.out != arrayOut[i * 2 + j]) { 16277 message.append(" FAIL"); 16278 } 16279 message.append("\n"); 16280 message.append("Errors at"); 16281 } 16282 message.append(" ["); 16283 message.append(Integer.toString(i)); 16284 message.append(", "); 16285 message.append(Integer.toString(j)); 16286 message.append("]"); 16287 } 16288 } 16289 } 16290 assertFalse("Incorrect output for checkConvertLong2Int2" + 16291 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16292 } 16293 16294 private void checkConvertLong3Int3() { 16295 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xfe441ca62f86ca71l, true, 31); 16296 try { 16297 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 16298 script.forEach_testConvertInt3Long3Int3(inV, out); 16299 verifyResultsConvertLong3Int3(inV, out, false); 16300 out.destroy(); 16301 } catch (Exception e) { 16302 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString()); 16303 } 16304 try { 16305 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 16306 scriptRelaxed.forEach_testConvertInt3Long3Int3(inV, out); 16307 verifyResultsConvertLong3Int3(inV, out, true); 16308 out.destroy(); 16309 } catch (Exception e) { 16310 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString()); 16311 } 16312 inV.destroy(); 16313 } 16314 16315 private void verifyResultsConvertLong3Int3(Allocation inV, Allocation out, boolean relaxed) { 16316 long[] arrayInV = new long[INPUTSIZE * 4]; 16317 Arrays.fill(arrayInV, (long) 42); 16318 inV.copyTo(arrayInV); 16319 int[] arrayOut = new int[INPUTSIZE * 4]; 16320 Arrays.fill(arrayOut, (int) 42); 16321 out.copyTo(arrayOut); 16322 StringBuilder message = new StringBuilder(); 16323 boolean errorFound = false; 16324 for (int i = 0; i < INPUTSIZE; i++) { 16325 for (int j = 0; j < 3 ; j++) { 16326 // Extract the inputs. 16327 ArgumentsLongInt args = new ArgumentsLongInt(); 16328 args.inV = arrayInV[i * 4 + j]; 16329 // Figure out what the outputs should have been. 16330 CoreMathVerifier.computeConvert(args); 16331 // Validate the outputs. 16332 boolean valid = true; 16333 if (args.out != arrayOut[i * 4 + j]) { 16334 valid = false; 16335 } 16336 if (!valid) { 16337 if (!errorFound) { 16338 errorFound = true; 16339 message.append("Input inV: "); 16340 appendVariableToMessage(message, args.inV); 16341 message.append("\n"); 16342 message.append("Expected output out: "); 16343 appendVariableToMessage(message, args.out); 16344 message.append("\n"); 16345 message.append("Actual output out: "); 16346 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16347 if (args.out != arrayOut[i * 4 + j]) { 16348 message.append(" FAIL"); 16349 } 16350 message.append("\n"); 16351 message.append("Errors at"); 16352 } 16353 message.append(" ["); 16354 message.append(Integer.toString(i)); 16355 message.append(", "); 16356 message.append(Integer.toString(j)); 16357 message.append("]"); 16358 } 16359 } 16360 } 16361 assertFalse("Incorrect output for checkConvertLong3Int3" + 16362 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16363 } 16364 16365 private void checkConvertLong4Int4() { 16366 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xfe441ce5792edaa7l, true, 31); 16367 try { 16368 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 16369 script.forEach_testConvertInt4Long4Int4(inV, out); 16370 verifyResultsConvertLong4Int4(inV, out, false); 16371 out.destroy(); 16372 } catch (Exception e) { 16373 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString()); 16374 } 16375 try { 16376 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 16377 scriptRelaxed.forEach_testConvertInt4Long4Int4(inV, out); 16378 verifyResultsConvertLong4Int4(inV, out, true); 16379 out.destroy(); 16380 } catch (Exception e) { 16381 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString()); 16382 } 16383 inV.destroy(); 16384 } 16385 16386 private void verifyResultsConvertLong4Int4(Allocation inV, Allocation out, boolean relaxed) { 16387 long[] arrayInV = new long[INPUTSIZE * 4]; 16388 Arrays.fill(arrayInV, (long) 42); 16389 inV.copyTo(arrayInV); 16390 int[] arrayOut = new int[INPUTSIZE * 4]; 16391 Arrays.fill(arrayOut, (int) 42); 16392 out.copyTo(arrayOut); 16393 StringBuilder message = new StringBuilder(); 16394 boolean errorFound = false; 16395 for (int i = 0; i < INPUTSIZE; i++) { 16396 for (int j = 0; j < 4 ; j++) { 16397 // Extract the inputs. 16398 ArgumentsLongInt args = new ArgumentsLongInt(); 16399 args.inV = arrayInV[i * 4 + j]; 16400 // Figure out what the outputs should have been. 16401 CoreMathVerifier.computeConvert(args); 16402 // Validate the outputs. 16403 boolean valid = true; 16404 if (args.out != arrayOut[i * 4 + j]) { 16405 valid = false; 16406 } 16407 if (!valid) { 16408 if (!errorFound) { 16409 errorFound = true; 16410 message.append("Input inV: "); 16411 appendVariableToMessage(message, args.inV); 16412 message.append("\n"); 16413 message.append("Expected output out: "); 16414 appendVariableToMessage(message, args.out); 16415 message.append("\n"); 16416 message.append("Actual output out: "); 16417 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16418 if (args.out != arrayOut[i * 4 + j]) { 16419 message.append(" FAIL"); 16420 } 16421 message.append("\n"); 16422 message.append("Errors at"); 16423 } 16424 message.append(" ["); 16425 message.append(Integer.toString(i)); 16426 message.append(", "); 16427 message.append(Integer.toString(j)); 16428 message.append("]"); 16429 } 16430 } 16431 } 16432 assertFalse("Incorrect output for checkConvertLong4Int4" + 16433 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16434 } 16435 16436 public class ArgumentsUlongInt { 16437 public long inV; 16438 public int out; 16439 } 16440 16441 private void checkConvertUlong2Int2() { 16442 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe11d350e352de3el, false, 31); 16443 try { 16444 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 16445 script.forEach_testConvertInt2Ulong2Int2(inV, out); 16446 verifyResultsConvertUlong2Int2(inV, out, false); 16447 out.destroy(); 16448 } catch (Exception e) { 16449 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString()); 16450 } 16451 try { 16452 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 16453 scriptRelaxed.forEach_testConvertInt2Ulong2Int2(inV, out); 16454 verifyResultsConvertUlong2Int2(inV, out, true); 16455 out.destroy(); 16456 } catch (Exception e) { 16457 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString()); 16458 } 16459 inV.destroy(); 16460 } 16461 16462 private void verifyResultsConvertUlong2Int2(Allocation inV, Allocation out, boolean relaxed) { 16463 long[] arrayInV = new long[INPUTSIZE * 2]; 16464 Arrays.fill(arrayInV, (long) 42); 16465 inV.copyTo(arrayInV); 16466 int[] arrayOut = new int[INPUTSIZE * 2]; 16467 Arrays.fill(arrayOut, (int) 42); 16468 out.copyTo(arrayOut); 16469 StringBuilder message = new StringBuilder(); 16470 boolean errorFound = false; 16471 for (int i = 0; i < INPUTSIZE; i++) { 16472 for (int j = 0; j < 2 ; j++) { 16473 // Extract the inputs. 16474 ArgumentsUlongInt args = new ArgumentsUlongInt(); 16475 args.inV = arrayInV[i * 2 + j]; 16476 // Figure out what the outputs should have been. 16477 CoreMathVerifier.computeConvert(args); 16478 // Validate the outputs. 16479 boolean valid = true; 16480 if (args.out != arrayOut[i * 2 + j]) { 16481 valid = false; 16482 } 16483 if (!valid) { 16484 if (!errorFound) { 16485 errorFound = true; 16486 message.append("Input inV: "); 16487 appendVariableToMessage(message, args.inV); 16488 message.append("\n"); 16489 message.append("Expected output out: "); 16490 appendVariableToMessage(message, args.out); 16491 message.append("\n"); 16492 message.append("Actual output out: "); 16493 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16494 if (args.out != arrayOut[i * 2 + j]) { 16495 message.append(" FAIL"); 16496 } 16497 message.append("\n"); 16498 message.append("Errors at"); 16499 } 16500 message.append(" ["); 16501 message.append(Integer.toString(i)); 16502 message.append(", "); 16503 message.append(Integer.toString(j)); 16504 message.append("]"); 16505 } 16506 } 16507 } 16508 assertFalse("Incorrect output for checkConvertUlong2Int2" + 16509 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16510 } 16511 16512 private void checkConvertUlong3Int3() { 16513 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xe11d3902cfaee74l, false, 31); 16514 try { 16515 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 16516 script.forEach_testConvertInt3Ulong3Int3(inV, out); 16517 verifyResultsConvertUlong3Int3(inV, out, false); 16518 out.destroy(); 16519 } catch (Exception e) { 16520 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString()); 16521 } 16522 try { 16523 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 16524 scriptRelaxed.forEach_testConvertInt3Ulong3Int3(inV, out); 16525 verifyResultsConvertUlong3Int3(inV, out, true); 16526 out.destroy(); 16527 } catch (Exception e) { 16528 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString()); 16529 } 16530 inV.destroy(); 16531 } 16532 16533 private void verifyResultsConvertUlong3Int3(Allocation inV, Allocation out, boolean relaxed) { 16534 long[] arrayInV = new long[INPUTSIZE * 4]; 16535 Arrays.fill(arrayInV, (long) 42); 16536 inV.copyTo(arrayInV); 16537 int[] arrayOut = new int[INPUTSIZE * 4]; 16538 Arrays.fill(arrayOut, (int) 42); 16539 out.copyTo(arrayOut); 16540 StringBuilder message = new StringBuilder(); 16541 boolean errorFound = false; 16542 for (int i = 0; i < INPUTSIZE; i++) { 16543 for (int j = 0; j < 3 ; j++) { 16544 // Extract the inputs. 16545 ArgumentsUlongInt args = new ArgumentsUlongInt(); 16546 args.inV = arrayInV[i * 4 + j]; 16547 // Figure out what the outputs should have been. 16548 CoreMathVerifier.computeConvert(args); 16549 // Validate the outputs. 16550 boolean valid = true; 16551 if (args.out != arrayOut[i * 4 + j]) { 16552 valid = false; 16553 } 16554 if (!valid) { 16555 if (!errorFound) { 16556 errorFound = true; 16557 message.append("Input inV: "); 16558 appendVariableToMessage(message, args.inV); 16559 message.append("\n"); 16560 message.append("Expected output out: "); 16561 appendVariableToMessage(message, args.out); 16562 message.append("\n"); 16563 message.append("Actual output out: "); 16564 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16565 if (args.out != arrayOut[i * 4 + j]) { 16566 message.append(" FAIL"); 16567 } 16568 message.append("\n"); 16569 message.append("Errors at"); 16570 } 16571 message.append(" ["); 16572 message.append(Integer.toString(i)); 16573 message.append(", "); 16574 message.append(Integer.toString(j)); 16575 message.append("]"); 16576 } 16577 } 16578 } 16579 assertFalse("Incorrect output for checkConvertUlong3Int3" + 16580 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16581 } 16582 16583 private void checkConvertUlong4Int4() { 16584 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xe11d3cf76a2feaal, false, 31); 16585 try { 16586 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 16587 script.forEach_testConvertInt4Ulong4Int4(inV, out); 16588 verifyResultsConvertUlong4Int4(inV, out, false); 16589 out.destroy(); 16590 } catch (Exception e) { 16591 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString()); 16592 } 16593 try { 16594 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 16595 scriptRelaxed.forEach_testConvertInt4Ulong4Int4(inV, out); 16596 verifyResultsConvertUlong4Int4(inV, out, true); 16597 out.destroy(); 16598 } catch (Exception e) { 16599 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString()); 16600 } 16601 inV.destroy(); 16602 } 16603 16604 private void verifyResultsConvertUlong4Int4(Allocation inV, Allocation out, boolean relaxed) { 16605 long[] arrayInV = new long[INPUTSIZE * 4]; 16606 Arrays.fill(arrayInV, (long) 42); 16607 inV.copyTo(arrayInV); 16608 int[] arrayOut = new int[INPUTSIZE * 4]; 16609 Arrays.fill(arrayOut, (int) 42); 16610 out.copyTo(arrayOut); 16611 StringBuilder message = new StringBuilder(); 16612 boolean errorFound = false; 16613 for (int i = 0; i < INPUTSIZE; i++) { 16614 for (int j = 0; j < 4 ; j++) { 16615 // Extract the inputs. 16616 ArgumentsUlongInt args = new ArgumentsUlongInt(); 16617 args.inV = arrayInV[i * 4 + j]; 16618 // Figure out what the outputs should have been. 16619 CoreMathVerifier.computeConvert(args); 16620 // Validate the outputs. 16621 boolean valid = true; 16622 if (args.out != arrayOut[i * 4 + j]) { 16623 valid = false; 16624 } 16625 if (!valid) { 16626 if (!errorFound) { 16627 errorFound = true; 16628 message.append("Input inV: "); 16629 appendVariableToMessage(message, args.inV); 16630 message.append("\n"); 16631 message.append("Expected output out: "); 16632 appendVariableToMessage(message, args.out); 16633 message.append("\n"); 16634 message.append("Actual output out: "); 16635 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16636 if (args.out != arrayOut[i * 4 + j]) { 16637 message.append(" FAIL"); 16638 } 16639 message.append("\n"); 16640 message.append("Errors at"); 16641 } 16642 message.append(" ["); 16643 message.append(Integer.toString(i)); 16644 message.append(", "); 16645 message.append(Integer.toString(j)); 16646 message.append("]"); 16647 } 16648 } 16649 } 16650 assertFalse("Incorrect output for checkConvertUlong4Int4" + 16651 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16652 } 16653 16654 public class ArgumentsDoubleUint { 16655 public double inV; 16656 public int out; 16657 } 16658 16659 private void checkConvertDouble2Uint2() { 16660 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84ff107de7dd7l, 0.0000000000000000000e+00, 4.2949672950000000000e+09); 16661 try { 16662 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16663 script.forEach_testConvertUint2Double2Uint2(inV, out); 16664 verifyResultsConvertDouble2Uint2(inV, out, false); 16665 out.destroy(); 16666 } catch (Exception e) { 16667 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString()); 16668 } 16669 try { 16670 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16671 scriptRelaxed.forEach_testConvertUint2Double2Uint2(inV, out); 16672 verifyResultsConvertDouble2Uint2(inV, out, true); 16673 out.destroy(); 16674 } catch (Exception e) { 16675 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString()); 16676 } 16677 inV.destroy(); 16678 } 16679 16680 private void verifyResultsConvertDouble2Uint2(Allocation inV, Allocation out, boolean relaxed) { 16681 double[] arrayInV = new double[INPUTSIZE * 2]; 16682 Arrays.fill(arrayInV, (double) 42); 16683 inV.copyTo(arrayInV); 16684 int[] arrayOut = new int[INPUTSIZE * 2]; 16685 Arrays.fill(arrayOut, (int) 42); 16686 out.copyTo(arrayOut); 16687 StringBuilder message = new StringBuilder(); 16688 boolean errorFound = false; 16689 for (int i = 0; i < INPUTSIZE; i++) { 16690 for (int j = 0; j < 2 ; j++) { 16691 // Extract the inputs. 16692 ArgumentsDoubleUint args = new ArgumentsDoubleUint(); 16693 args.inV = arrayInV[i * 2 + j]; 16694 // Figure out what the outputs should have been. 16695 CoreMathVerifier.computeConvert(args); 16696 // Validate the outputs. 16697 boolean valid = true; 16698 if (args.out != arrayOut[i * 2 + j]) { 16699 valid = false; 16700 } 16701 if (!valid) { 16702 if (!errorFound) { 16703 errorFound = true; 16704 message.append("Input inV: "); 16705 appendVariableToMessage(message, args.inV); 16706 message.append("\n"); 16707 message.append("Expected output out: "); 16708 appendVariableToMessage(message, args.out); 16709 message.append("\n"); 16710 message.append("Actual output out: "); 16711 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16712 if (args.out != arrayOut[i * 2 + j]) { 16713 message.append(" FAIL"); 16714 } 16715 message.append("\n"); 16716 message.append("Errors at"); 16717 } 16718 message.append(" ["); 16719 message.append(Integer.toString(i)); 16720 message.append(", "); 16721 message.append(Integer.toString(j)); 16722 message.append("]"); 16723 } 16724 } 16725 } 16726 assertFalse("Incorrect output for checkConvertDouble2Uint2" + 16727 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16728 } 16729 16730 private void checkConvertDouble3Uint3() { 16731 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf85a9266e642cbl, 0.0000000000000000000e+00, 4.2949672950000000000e+09); 16732 try { 16733 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16734 script.forEach_testConvertUint3Double3Uint3(inV, out); 16735 verifyResultsConvertDouble3Uint3(inV, out, false); 16736 out.destroy(); 16737 } catch (Exception e) { 16738 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString()); 16739 } 16740 try { 16741 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16742 scriptRelaxed.forEach_testConvertUint3Double3Uint3(inV, out); 16743 verifyResultsConvertDouble3Uint3(inV, out, true); 16744 out.destroy(); 16745 } catch (Exception e) { 16746 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString()); 16747 } 16748 inV.destroy(); 16749 } 16750 16751 private void verifyResultsConvertDouble3Uint3(Allocation inV, Allocation out, boolean relaxed) { 16752 double[] arrayInV = new double[INPUTSIZE * 4]; 16753 Arrays.fill(arrayInV, (double) 42); 16754 inV.copyTo(arrayInV); 16755 int[] arrayOut = new int[INPUTSIZE * 4]; 16756 Arrays.fill(arrayOut, (int) 42); 16757 out.copyTo(arrayOut); 16758 StringBuilder message = new StringBuilder(); 16759 boolean errorFound = false; 16760 for (int i = 0; i < INPUTSIZE; i++) { 16761 for (int j = 0; j < 3 ; j++) { 16762 // Extract the inputs. 16763 ArgumentsDoubleUint args = new ArgumentsDoubleUint(); 16764 args.inV = arrayInV[i * 4 + j]; 16765 // Figure out what the outputs should have been. 16766 CoreMathVerifier.computeConvert(args); 16767 // Validate the outputs. 16768 boolean valid = true; 16769 if (args.out != arrayOut[i * 4 + j]) { 16770 valid = false; 16771 } 16772 if (!valid) { 16773 if (!errorFound) { 16774 errorFound = true; 16775 message.append("Input inV: "); 16776 appendVariableToMessage(message, args.inV); 16777 message.append("\n"); 16778 message.append("Expected output out: "); 16779 appendVariableToMessage(message, args.out); 16780 message.append("\n"); 16781 message.append("Actual output out: "); 16782 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16783 if (args.out != arrayOut[i * 4 + j]) { 16784 message.append(" FAIL"); 16785 } 16786 message.append("\n"); 16787 message.append("Errors at"); 16788 } 16789 message.append(" ["); 16790 message.append(Integer.toString(i)); 16791 message.append(", "); 16792 message.append(Integer.toString(j)); 16793 message.append("]"); 16794 } 16795 } 16796 } 16797 assertFalse("Incorrect output for checkConvertDouble3Uint3" + 16798 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16799 } 16800 16801 private void checkConvertDouble4Uint4() { 16802 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf86533c5ee07bfl, 0.0000000000000000000e+00, 4.2949672950000000000e+09); 16803 try { 16804 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16805 script.forEach_testConvertUint4Double4Uint4(inV, out); 16806 verifyResultsConvertDouble4Uint4(inV, out, false); 16807 out.destroy(); 16808 } catch (Exception e) { 16809 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString()); 16810 } 16811 try { 16812 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16813 scriptRelaxed.forEach_testConvertUint4Double4Uint4(inV, out); 16814 verifyResultsConvertDouble4Uint4(inV, out, true); 16815 out.destroy(); 16816 } catch (Exception e) { 16817 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString()); 16818 } 16819 inV.destroy(); 16820 } 16821 16822 private void verifyResultsConvertDouble4Uint4(Allocation inV, Allocation out, boolean relaxed) { 16823 double[] arrayInV = new double[INPUTSIZE * 4]; 16824 Arrays.fill(arrayInV, (double) 42); 16825 inV.copyTo(arrayInV); 16826 int[] arrayOut = new int[INPUTSIZE * 4]; 16827 Arrays.fill(arrayOut, (int) 42); 16828 out.copyTo(arrayOut); 16829 StringBuilder message = new StringBuilder(); 16830 boolean errorFound = false; 16831 for (int i = 0; i < INPUTSIZE; i++) { 16832 for (int j = 0; j < 4 ; j++) { 16833 // Extract the inputs. 16834 ArgumentsDoubleUint args = new ArgumentsDoubleUint(); 16835 args.inV = arrayInV[i * 4 + j]; 16836 // Figure out what the outputs should have been. 16837 CoreMathVerifier.computeConvert(args); 16838 // Validate the outputs. 16839 boolean valid = true; 16840 if (args.out != arrayOut[i * 4 + j]) { 16841 valid = false; 16842 } 16843 if (!valid) { 16844 if (!errorFound) { 16845 errorFound = true; 16846 message.append("Input inV: "); 16847 appendVariableToMessage(message, args.inV); 16848 message.append("\n"); 16849 message.append("Expected output out: "); 16850 appendVariableToMessage(message, args.out); 16851 message.append("\n"); 16852 message.append("Actual output out: "); 16853 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16854 if (args.out != arrayOut[i * 4 + j]) { 16855 message.append(" FAIL"); 16856 } 16857 message.append("\n"); 16858 message.append("Errors at"); 16859 } 16860 message.append(" ["); 16861 message.append(Integer.toString(i)); 16862 message.append(", "); 16863 message.append(Integer.toString(j)); 16864 message.append("]"); 16865 } 16866 } 16867 } 16868 assertFalse("Incorrect output for checkConvertDouble4Uint4" + 16869 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16870 } 16871 16872 public class ArgumentsLongUint { 16873 public long inV; 16874 public int out; 16875 } 16876 16877 private void checkConvertLong2Uint2() { 16878 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c8388ceee36cl, false, 32); 16879 try { 16880 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16881 script.forEach_testConvertUint2Long2Uint2(inV, out); 16882 verifyResultsConvertLong2Uint2(inV, out, false); 16883 out.destroy(); 16884 } catch (Exception e) { 16885 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString()); 16886 } 16887 try { 16888 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16889 scriptRelaxed.forEach_testConvertUint2Long2Uint2(inV, out); 16890 verifyResultsConvertLong2Uint2(inV, out, true); 16891 out.destroy(); 16892 } catch (Exception e) { 16893 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString()); 16894 } 16895 inV.destroy(); 16896 } 16897 16898 private void verifyResultsConvertLong2Uint2(Allocation inV, Allocation out, boolean relaxed) { 16899 long[] arrayInV = new long[INPUTSIZE * 2]; 16900 Arrays.fill(arrayInV, (long) 42); 16901 inV.copyTo(arrayInV); 16902 int[] arrayOut = new int[INPUTSIZE * 2]; 16903 Arrays.fill(arrayOut, (int) 42); 16904 out.copyTo(arrayOut); 16905 StringBuilder message = new StringBuilder(); 16906 boolean errorFound = false; 16907 for (int i = 0; i < INPUTSIZE; i++) { 16908 for (int j = 0; j < 2 ; j++) { 16909 // Extract the inputs. 16910 ArgumentsLongUint args = new ArgumentsLongUint(); 16911 args.inV = arrayInV[i * 2 + j]; 16912 // Figure out what the outputs should have been. 16913 CoreMathVerifier.computeConvert(args); 16914 // Validate the outputs. 16915 boolean valid = true; 16916 if (args.out != arrayOut[i * 2 + j]) { 16917 valid = false; 16918 } 16919 if (!valid) { 16920 if (!errorFound) { 16921 errorFound = true; 16922 message.append("Input inV: "); 16923 appendVariableToMessage(message, args.inV); 16924 message.append("\n"); 16925 message.append("Expected output out: "); 16926 appendVariableToMessage(message, args.out); 16927 message.append("\n"); 16928 message.append("Actual output out: "); 16929 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16930 if (args.out != arrayOut[i * 2 + j]) { 16931 message.append(" FAIL"); 16932 } 16933 message.append("\n"); 16934 message.append("Errors at"); 16935 } 16936 message.append(" ["); 16937 message.append(Integer.toString(i)); 16938 message.append(", "); 16939 message.append(Integer.toString(j)); 16940 message.append("]"); 16941 } 16942 } 16943 } 16944 assertFalse("Incorrect output for checkConvertLong2Uint2" + 16945 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16946 } 16947 16948 private void checkConvertLong3Uint3() { 16949 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570d2d9ebf6a860l, false, 32); 16950 try { 16951 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16952 script.forEach_testConvertUint3Long3Uint3(inV, out); 16953 verifyResultsConvertLong3Uint3(inV, out, false); 16954 out.destroy(); 16955 } catch (Exception e) { 16956 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString()); 16957 } 16958 try { 16959 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16960 scriptRelaxed.forEach_testConvertUint3Long3Uint3(inV, out); 16961 verifyResultsConvertLong3Uint3(inV, out, true); 16962 out.destroy(); 16963 } catch (Exception e) { 16964 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString()); 16965 } 16966 inV.destroy(); 16967 } 16968 16969 private void verifyResultsConvertLong3Uint3(Allocation inV, Allocation out, boolean relaxed) { 16970 long[] arrayInV = new long[INPUTSIZE * 4]; 16971 Arrays.fill(arrayInV, (long) 42); 16972 inV.copyTo(arrayInV); 16973 int[] arrayOut = new int[INPUTSIZE * 4]; 16974 Arrays.fill(arrayOut, (int) 42); 16975 out.copyTo(arrayOut); 16976 StringBuilder message = new StringBuilder(); 16977 boolean errorFound = false; 16978 for (int i = 0; i < INPUTSIZE; i++) { 16979 for (int j = 0; j < 3 ; j++) { 16980 // Extract the inputs. 16981 ArgumentsLongUint args = new ArgumentsLongUint(); 16982 args.inV = arrayInV[i * 4 + j]; 16983 // Figure out what the outputs should have been. 16984 CoreMathVerifier.computeConvert(args); 16985 // Validate the outputs. 16986 boolean valid = true; 16987 if (args.out != arrayOut[i * 4 + j]) { 16988 valid = false; 16989 } 16990 if (!valid) { 16991 if (!errorFound) { 16992 errorFound = true; 16993 message.append("Input inV: "); 16994 appendVariableToMessage(message, args.inV); 16995 message.append("\n"); 16996 message.append("Expected output out: "); 16997 appendVariableToMessage(message, args.out); 16998 message.append("\n"); 16999 message.append("Actual output out: "); 17000 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17001 if (args.out != arrayOut[i * 4 + j]) { 17002 message.append(" FAIL"); 17003 } 17004 message.append("\n"); 17005 message.append("Errors at"); 17006 } 17007 message.append(" ["); 17008 message.append(Integer.toString(i)); 17009 message.append(", "); 17010 message.append(Integer.toString(j)); 17011 message.append("]"); 17012 } 17013 } 17014 } 17015 assertFalse("Incorrect output for checkConvertLong3Uint3" + 17016 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17017 } 17018 17019 private void checkConvertLong4Uint4() { 17020 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570dd7b4afe6d54l, false, 32); 17021 try { 17022 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 17023 script.forEach_testConvertUint4Long4Uint4(inV, out); 17024 verifyResultsConvertLong4Uint4(inV, out, false); 17025 out.destroy(); 17026 } catch (Exception e) { 17027 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString()); 17028 } 17029 try { 17030 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 17031 scriptRelaxed.forEach_testConvertUint4Long4Uint4(inV, out); 17032 verifyResultsConvertLong4Uint4(inV, out, true); 17033 out.destroy(); 17034 } catch (Exception e) { 17035 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString()); 17036 } 17037 inV.destroy(); 17038 } 17039 17040 private void verifyResultsConvertLong4Uint4(Allocation inV, Allocation out, boolean relaxed) { 17041 long[] arrayInV = new long[INPUTSIZE * 4]; 17042 Arrays.fill(arrayInV, (long) 42); 17043 inV.copyTo(arrayInV); 17044 int[] arrayOut = new int[INPUTSIZE * 4]; 17045 Arrays.fill(arrayOut, (int) 42); 17046 out.copyTo(arrayOut); 17047 StringBuilder message = new StringBuilder(); 17048 boolean errorFound = false; 17049 for (int i = 0; i < INPUTSIZE; i++) { 17050 for (int j = 0; j < 4 ; j++) { 17051 // Extract the inputs. 17052 ArgumentsLongUint args = new ArgumentsLongUint(); 17053 args.inV = arrayInV[i * 4 + j]; 17054 // Figure out what the outputs should have been. 17055 CoreMathVerifier.computeConvert(args); 17056 // Validate the outputs. 17057 boolean valid = true; 17058 if (args.out != arrayOut[i * 4 + j]) { 17059 valid = false; 17060 } 17061 if (!valid) { 17062 if (!errorFound) { 17063 errorFound = true; 17064 message.append("Input inV: "); 17065 appendVariableToMessage(message, args.inV); 17066 message.append("\n"); 17067 message.append("Expected output out: "); 17068 appendVariableToMessage(message, args.out); 17069 message.append("\n"); 17070 message.append("Actual output out: "); 17071 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17072 if (args.out != arrayOut[i * 4 + j]) { 17073 message.append(" FAIL"); 17074 } 17075 message.append("\n"); 17076 message.append("Errors at"); 17077 } 17078 message.append(" ["); 17079 message.append(Integer.toString(i)); 17080 message.append(", "); 17081 message.append(Integer.toString(j)); 17082 message.append("]"); 17083 } 17084 } 17085 } 17086 assertFalse("Incorrect output for checkConvertLong4Uint4" + 17087 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17088 } 17089 17090 public class ArgumentsUlongUint { 17091 public long inV; 17092 public int out; 17093 } 17094 17095 private void checkConvertUlong2Uint2() { 17096 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe81861f70efedl, false, 32); 17097 try { 17098 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 17099 script.forEach_testConvertUint2Ulong2Uint2(inV, out); 17100 verifyResultsConvertUlong2Uint2(inV, out, false); 17101 out.destroy(); 17102 } catch (Exception e) { 17103 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString()); 17104 } 17105 try { 17106 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 17107 scriptRelaxed.forEach_testConvertUint2Ulong2Uint2(inV, out); 17108 verifyResultsConvertUlong2Uint2(inV, out, true); 17109 out.destroy(); 17110 } catch (Exception e) { 17111 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString()); 17112 } 17113 inV.destroy(); 17114 } 17115 17116 private void verifyResultsConvertUlong2Uint2(Allocation inV, Allocation out, boolean relaxed) { 17117 long[] arrayInV = new long[INPUTSIZE * 2]; 17118 Arrays.fill(arrayInV, (long) 42); 17119 inV.copyTo(arrayInV); 17120 int[] arrayOut = new int[INPUTSIZE * 2]; 17121 Arrays.fill(arrayOut, (int) 42); 17122 out.copyTo(arrayOut); 17123 StringBuilder message = new StringBuilder(); 17124 boolean errorFound = false; 17125 for (int i = 0; i < INPUTSIZE; i++) { 17126 for (int j = 0; j < 2 ; j++) { 17127 // Extract the inputs. 17128 ArgumentsUlongUint args = new ArgumentsUlongUint(); 17129 args.inV = arrayInV[i * 2 + j]; 17130 // Figure out what the outputs should have been. 17131 CoreMathVerifier.computeConvert(args); 17132 // Validate the outputs. 17133 boolean valid = true; 17134 if (args.out != arrayOut[i * 2 + j]) { 17135 valid = false; 17136 } 17137 if (!valid) { 17138 if (!errorFound) { 17139 errorFound = true; 17140 message.append("Input inV: "); 17141 appendVariableToMessage(message, args.inV); 17142 message.append("\n"); 17143 message.append("Expected output out: "); 17144 appendVariableToMessage(message, args.out); 17145 message.append("\n"); 17146 message.append("Actual output out: "); 17147 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17148 if (args.out != arrayOut[i * 2 + j]) { 17149 message.append(" FAIL"); 17150 } 17151 message.append("\n"); 17152 message.append("Errors at"); 17153 } 17154 message.append(" ["); 17155 message.append(Integer.toString(i)); 17156 message.append(", "); 17157 message.append(Integer.toString(j)); 17158 message.append("]"); 17159 } 17160 } 17161 } 17162 assertFalse("Incorrect output for checkConvertUlong2Uint2" + 17163 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17164 } 17165 17166 private void checkConvertUlong3Uint3() { 17167 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe8c277e78b4e1l, false, 32); 17168 try { 17169 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 17170 script.forEach_testConvertUint3Ulong3Uint3(inV, out); 17171 verifyResultsConvertUlong3Uint3(inV, out, false); 17172 out.destroy(); 17173 } catch (Exception e) { 17174 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString()); 17175 } 17176 try { 17177 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 17178 scriptRelaxed.forEach_testConvertUint3Ulong3Uint3(inV, out); 17179 verifyResultsConvertUlong3Uint3(inV, out, true); 17180 out.destroy(); 17181 } catch (Exception e) { 17182 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString()); 17183 } 17184 inV.destroy(); 17185 } 17186 17187 private void verifyResultsConvertUlong3Uint3(Allocation inV, Allocation out, boolean relaxed) { 17188 long[] arrayInV = new long[INPUTSIZE * 4]; 17189 Arrays.fill(arrayInV, (long) 42); 17190 inV.copyTo(arrayInV); 17191 int[] arrayOut = new int[INPUTSIZE * 4]; 17192 Arrays.fill(arrayOut, (int) 42); 17193 out.copyTo(arrayOut); 17194 StringBuilder message = new StringBuilder(); 17195 boolean errorFound = false; 17196 for (int i = 0; i < INPUTSIZE; i++) { 17197 for (int j = 0; j < 3 ; j++) { 17198 // Extract the inputs. 17199 ArgumentsUlongUint args = new ArgumentsUlongUint(); 17200 args.inV = arrayInV[i * 4 + j]; 17201 // Figure out what the outputs should have been. 17202 CoreMathVerifier.computeConvert(args); 17203 // Validate the outputs. 17204 boolean valid = true; 17205 if (args.out != arrayOut[i * 4 + j]) { 17206 valid = false; 17207 } 17208 if (!valid) { 17209 if (!errorFound) { 17210 errorFound = true; 17211 message.append("Input inV: "); 17212 appendVariableToMessage(message, args.inV); 17213 message.append("\n"); 17214 message.append("Expected output out: "); 17215 appendVariableToMessage(message, args.out); 17216 message.append("\n"); 17217 message.append("Actual output out: "); 17218 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17219 if (args.out != arrayOut[i * 4 + j]) { 17220 message.append(" FAIL"); 17221 } 17222 message.append("\n"); 17223 message.append("Errors at"); 17224 } 17225 message.append(" ["); 17226 message.append(Integer.toString(i)); 17227 message.append(", "); 17228 message.append(Integer.toString(j)); 17229 message.append("]"); 17230 } 17231 } 17232 } 17233 assertFalse("Incorrect output for checkConvertUlong3Uint3" + 17234 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17235 } 17236 17237 private void checkConvertUlong4Uint4() { 17238 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe96c8dd8079d5l, false, 32); 17239 try { 17240 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 17241 script.forEach_testConvertUint4Ulong4Uint4(inV, out); 17242 verifyResultsConvertUlong4Uint4(inV, out, false); 17243 out.destroy(); 17244 } catch (Exception e) { 17245 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString()); 17246 } 17247 try { 17248 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 17249 scriptRelaxed.forEach_testConvertUint4Ulong4Uint4(inV, out); 17250 verifyResultsConvertUlong4Uint4(inV, out, true); 17251 out.destroy(); 17252 } catch (Exception e) { 17253 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString()); 17254 } 17255 inV.destroy(); 17256 } 17257 17258 private void verifyResultsConvertUlong4Uint4(Allocation inV, Allocation out, boolean relaxed) { 17259 long[] arrayInV = new long[INPUTSIZE * 4]; 17260 Arrays.fill(arrayInV, (long) 42); 17261 inV.copyTo(arrayInV); 17262 int[] arrayOut = new int[INPUTSIZE * 4]; 17263 Arrays.fill(arrayOut, (int) 42); 17264 out.copyTo(arrayOut); 17265 StringBuilder message = new StringBuilder(); 17266 boolean errorFound = false; 17267 for (int i = 0; i < INPUTSIZE; i++) { 17268 for (int j = 0; j < 4 ; j++) { 17269 // Extract the inputs. 17270 ArgumentsUlongUint args = new ArgumentsUlongUint(); 17271 args.inV = arrayInV[i * 4 + j]; 17272 // Figure out what the outputs should have been. 17273 CoreMathVerifier.computeConvert(args); 17274 // Validate the outputs. 17275 boolean valid = true; 17276 if (args.out != arrayOut[i * 4 + j]) { 17277 valid = false; 17278 } 17279 if (!valid) { 17280 if (!errorFound) { 17281 errorFound = true; 17282 message.append("Input inV: "); 17283 appendVariableToMessage(message, args.inV); 17284 message.append("\n"); 17285 message.append("Expected output out: "); 17286 appendVariableToMessage(message, args.out); 17287 message.append("\n"); 17288 message.append("Actual output out: "); 17289 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17290 if (args.out != arrayOut[i * 4 + j]) { 17291 message.append(" FAIL"); 17292 } 17293 message.append("\n"); 17294 message.append("Errors at"); 17295 } 17296 message.append(" ["); 17297 message.append(Integer.toString(i)); 17298 message.append(", "); 17299 message.append(Integer.toString(j)); 17300 message.append("]"); 17301 } 17302 } 17303 } 17304 assertFalse("Incorrect output for checkConvertUlong4Uint4" + 17305 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17306 } 17307 17308 public class ArgumentsFloatDouble { 17309 public float inV; 17310 public Target.Floaty out; 17311 } 17312 17313 private void checkConvertFloat2Double2() { 17314 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36c6372446e08221l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 17315 try { 17316 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17317 script.forEach_testConvertDouble2Float2Double2(inV, out); 17318 verifyResultsConvertFloat2Double2(inV, out, false); 17319 out.destroy(); 17320 } catch (Exception e) { 17321 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString()); 17322 } 17323 try { 17324 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17325 scriptRelaxed.forEach_testConvertDouble2Float2Double2(inV, out); 17326 verifyResultsConvertFloat2Double2(inV, out, true); 17327 out.destroy(); 17328 } catch (Exception e) { 17329 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString()); 17330 } 17331 inV.destroy(); 17332 } 17333 17334 private void verifyResultsConvertFloat2Double2(Allocation inV, Allocation out, boolean relaxed) { 17335 float[] arrayInV = new float[INPUTSIZE * 2]; 17336 Arrays.fill(arrayInV, (float) 42); 17337 inV.copyTo(arrayInV); 17338 double[] arrayOut = new double[INPUTSIZE * 2]; 17339 Arrays.fill(arrayOut, (double) 42); 17340 out.copyTo(arrayOut); 17341 StringBuilder message = new StringBuilder(); 17342 boolean errorFound = false; 17343 for (int i = 0; i < INPUTSIZE; i++) { 17344 for (int j = 0; j < 2 ; j++) { 17345 // Extract the inputs. 17346 ArgumentsFloatDouble args = new ArgumentsFloatDouble(); 17347 args.inV = arrayInV[i * 2 + j]; 17348 // Figure out what the outputs should have been. 17349 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17350 CoreMathVerifier.computeConvert(args, target); 17351 // Validate the outputs. 17352 boolean valid = true; 17353 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17354 valid = false; 17355 } 17356 if (!valid) { 17357 if (!errorFound) { 17358 errorFound = true; 17359 message.append("Input inV: "); 17360 appendVariableToMessage(message, args.inV); 17361 message.append("\n"); 17362 message.append("Expected output out: "); 17363 appendVariableToMessage(message, args.out); 17364 message.append("\n"); 17365 message.append("Actual output out: "); 17366 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17367 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17368 message.append(" FAIL"); 17369 } 17370 message.append("\n"); 17371 message.append("Errors at"); 17372 } 17373 message.append(" ["); 17374 message.append(Integer.toString(i)); 17375 message.append(", "); 17376 message.append(Integer.toString(j)); 17377 message.append("]"); 17378 } 17379 } 17380 } 17381 assertFalse("Incorrect output for checkConvertFloat2Double2" + 17382 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17383 } 17384 17385 private void checkConvertFloat3Double3() { 17386 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3712feab9d3c134dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 17387 try { 17388 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17389 script.forEach_testConvertDouble3Float3Double3(inV, out); 17390 verifyResultsConvertFloat3Double3(inV, out, false); 17391 out.destroy(); 17392 } catch (Exception e) { 17393 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString()); 17394 } 17395 try { 17396 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17397 scriptRelaxed.forEach_testConvertDouble3Float3Double3(inV, out); 17398 verifyResultsConvertFloat3Double3(inV, out, true); 17399 out.destroy(); 17400 } catch (Exception e) { 17401 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString()); 17402 } 17403 inV.destroy(); 17404 } 17405 17406 private void verifyResultsConvertFloat3Double3(Allocation inV, Allocation out, boolean relaxed) { 17407 float[] arrayInV = new float[INPUTSIZE * 4]; 17408 Arrays.fill(arrayInV, (float) 42); 17409 inV.copyTo(arrayInV); 17410 double[] arrayOut = new double[INPUTSIZE * 4]; 17411 Arrays.fill(arrayOut, (double) 42); 17412 out.copyTo(arrayOut); 17413 StringBuilder message = new StringBuilder(); 17414 boolean errorFound = false; 17415 for (int i = 0; i < INPUTSIZE; i++) { 17416 for (int j = 0; j < 3 ; j++) { 17417 // Extract the inputs. 17418 ArgumentsFloatDouble args = new ArgumentsFloatDouble(); 17419 args.inV = arrayInV[i * 4 + j]; 17420 // Figure out what the outputs should have been. 17421 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17422 CoreMathVerifier.computeConvert(args, target); 17423 // Validate the outputs. 17424 boolean valid = true; 17425 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17426 valid = false; 17427 } 17428 if (!valid) { 17429 if (!errorFound) { 17430 errorFound = true; 17431 message.append("Input inV: "); 17432 appendVariableToMessage(message, args.inV); 17433 message.append("\n"); 17434 message.append("Expected output out: "); 17435 appendVariableToMessage(message, args.out); 17436 message.append("\n"); 17437 message.append("Actual output out: "); 17438 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17439 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17440 message.append(" FAIL"); 17441 } 17442 message.append("\n"); 17443 message.append("Errors at"); 17444 } 17445 message.append(" ["); 17446 message.append(Integer.toString(i)); 17447 message.append(", "); 17448 message.append(Integer.toString(j)); 17449 message.append("]"); 17450 } 17451 } 17452 } 17453 assertFalse("Incorrect output for checkConvertFloat3Double3" + 17454 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17455 } 17456 17457 private void checkConvertFloat4Double4() { 17458 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x375fc632f397a479l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 17459 try { 17460 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17461 script.forEach_testConvertDouble4Float4Double4(inV, out); 17462 verifyResultsConvertFloat4Double4(inV, out, false); 17463 out.destroy(); 17464 } catch (Exception e) { 17465 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString()); 17466 } 17467 try { 17468 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17469 scriptRelaxed.forEach_testConvertDouble4Float4Double4(inV, out); 17470 verifyResultsConvertFloat4Double4(inV, out, true); 17471 out.destroy(); 17472 } catch (Exception e) { 17473 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString()); 17474 } 17475 inV.destroy(); 17476 } 17477 17478 private void verifyResultsConvertFloat4Double4(Allocation inV, Allocation out, boolean relaxed) { 17479 float[] arrayInV = new float[INPUTSIZE * 4]; 17480 Arrays.fill(arrayInV, (float) 42); 17481 inV.copyTo(arrayInV); 17482 double[] arrayOut = new double[INPUTSIZE * 4]; 17483 Arrays.fill(arrayOut, (double) 42); 17484 out.copyTo(arrayOut); 17485 StringBuilder message = new StringBuilder(); 17486 boolean errorFound = false; 17487 for (int i = 0; i < INPUTSIZE; i++) { 17488 for (int j = 0; j < 4 ; j++) { 17489 // Extract the inputs. 17490 ArgumentsFloatDouble args = new ArgumentsFloatDouble(); 17491 args.inV = arrayInV[i * 4 + j]; 17492 // Figure out what the outputs should have been. 17493 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17494 CoreMathVerifier.computeConvert(args, target); 17495 // Validate the outputs. 17496 boolean valid = true; 17497 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17498 valid = false; 17499 } 17500 if (!valid) { 17501 if (!errorFound) { 17502 errorFound = true; 17503 message.append("Input inV: "); 17504 appendVariableToMessage(message, args.inV); 17505 message.append("\n"); 17506 message.append("Expected output out: "); 17507 appendVariableToMessage(message, args.out); 17508 message.append("\n"); 17509 message.append("Actual output out: "); 17510 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17511 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17512 message.append(" FAIL"); 17513 } 17514 message.append("\n"); 17515 message.append("Errors at"); 17516 } 17517 message.append(" ["); 17518 message.append(Integer.toString(i)); 17519 message.append(", "); 17520 message.append(Integer.toString(j)); 17521 message.append("]"); 17522 } 17523 } 17524 } 17525 assertFalse("Incorrect output for checkConvertFloat4Double4" + 17526 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17527 } 17528 17529 public class ArgumentsCharDouble { 17530 public byte inV; 17531 public Target.Floaty out; 17532 } 17533 17534 private void checkConvertChar2Double2() { 17535 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86d88e268ca2f61l, true, 7); 17536 try { 17537 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17538 script.forEach_testConvertDouble2Char2Double2(inV, out); 17539 verifyResultsConvertChar2Double2(inV, out, false); 17540 out.destroy(); 17541 } catch (Exception e) { 17542 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString()); 17543 } 17544 try { 17545 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17546 scriptRelaxed.forEach_testConvertDouble2Char2Double2(inV, out); 17547 verifyResultsConvertChar2Double2(inV, out, true); 17548 out.destroy(); 17549 } catch (Exception e) { 17550 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString()); 17551 } 17552 inV.destroy(); 17553 } 17554 17555 private void verifyResultsConvertChar2Double2(Allocation inV, Allocation out, boolean relaxed) { 17556 byte[] arrayInV = new byte[INPUTSIZE * 2]; 17557 Arrays.fill(arrayInV, (byte) 42); 17558 inV.copyTo(arrayInV); 17559 double[] arrayOut = new double[INPUTSIZE * 2]; 17560 Arrays.fill(arrayOut, (double) 42); 17561 out.copyTo(arrayOut); 17562 StringBuilder message = new StringBuilder(); 17563 boolean errorFound = false; 17564 for (int i = 0; i < INPUTSIZE; i++) { 17565 for (int j = 0; j < 2 ; j++) { 17566 // Extract the inputs. 17567 ArgumentsCharDouble args = new ArgumentsCharDouble(); 17568 args.inV = arrayInV[i * 2 + j]; 17569 // Figure out what the outputs should have been. 17570 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17571 CoreMathVerifier.computeConvert(args, target); 17572 // Validate the outputs. 17573 boolean valid = true; 17574 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17575 valid = false; 17576 } 17577 if (!valid) { 17578 if (!errorFound) { 17579 errorFound = true; 17580 message.append("Input inV: "); 17581 appendVariableToMessage(message, args.inV); 17582 message.append("\n"); 17583 message.append("Expected output out: "); 17584 appendVariableToMessage(message, args.out); 17585 message.append("\n"); 17586 message.append("Actual output out: "); 17587 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17588 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17589 message.append(" FAIL"); 17590 } 17591 message.append("\n"); 17592 message.append("Errors at"); 17593 } 17594 message.append(" ["); 17595 message.append(Integer.toString(i)); 17596 message.append(", "); 17597 message.append(Integer.toString(j)); 17598 message.append("]"); 17599 } 17600 } 17601 } 17602 assertFalse("Incorrect output for checkConvertChar2Double2" + 17603 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17604 } 17605 17606 private void checkConvertChar3Double3() { 17607 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd8ba5069bf25c08dl, true, 7); 17608 try { 17609 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17610 script.forEach_testConvertDouble3Char3Double3(inV, out); 17611 verifyResultsConvertChar3Double3(inV, out, false); 17612 out.destroy(); 17613 } catch (Exception e) { 17614 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString()); 17615 } 17616 try { 17617 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17618 scriptRelaxed.forEach_testConvertDouble3Char3Double3(inV, out); 17619 verifyResultsConvertChar3Double3(inV, out, true); 17620 out.destroy(); 17621 } catch (Exception e) { 17622 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString()); 17623 } 17624 inV.destroy(); 17625 } 17626 17627 private void verifyResultsConvertChar3Double3(Allocation inV, Allocation out, boolean relaxed) { 17628 byte[] arrayInV = new byte[INPUTSIZE * 4]; 17629 Arrays.fill(arrayInV, (byte) 42); 17630 inV.copyTo(arrayInV); 17631 double[] arrayOut = new double[INPUTSIZE * 4]; 17632 Arrays.fill(arrayOut, (double) 42); 17633 out.copyTo(arrayOut); 17634 StringBuilder message = new StringBuilder(); 17635 boolean errorFound = false; 17636 for (int i = 0; i < INPUTSIZE; i++) { 17637 for (int j = 0; j < 3 ; j++) { 17638 // Extract the inputs. 17639 ArgumentsCharDouble args = new ArgumentsCharDouble(); 17640 args.inV = arrayInV[i * 4 + j]; 17641 // Figure out what the outputs should have been. 17642 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17643 CoreMathVerifier.computeConvert(args, target); 17644 // Validate the outputs. 17645 boolean valid = true; 17646 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17647 valid = false; 17648 } 17649 if (!valid) { 17650 if (!errorFound) { 17651 errorFound = true; 17652 message.append("Input inV: "); 17653 appendVariableToMessage(message, args.inV); 17654 message.append("\n"); 17655 message.append("Expected output out: "); 17656 appendVariableToMessage(message, args.out); 17657 message.append("\n"); 17658 message.append("Actual output out: "); 17659 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17660 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17661 message.append(" FAIL"); 17662 } 17663 message.append("\n"); 17664 message.append("Errors at"); 17665 } 17666 message.append(" ["); 17667 message.append(Integer.toString(i)); 17668 message.append(", "); 17669 message.append(Integer.toString(j)); 17670 message.append("]"); 17671 } 17672 } 17673 } 17674 assertFalse("Incorrect output for checkConvertChar3Double3" + 17675 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17676 } 17677 17678 private void checkConvertChar4Double4() { 17679 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd90717f1158151b9l, true, 7); 17680 try { 17681 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17682 script.forEach_testConvertDouble4Char4Double4(inV, out); 17683 verifyResultsConvertChar4Double4(inV, out, false); 17684 out.destroy(); 17685 } catch (Exception e) { 17686 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString()); 17687 } 17688 try { 17689 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17690 scriptRelaxed.forEach_testConvertDouble4Char4Double4(inV, out); 17691 verifyResultsConvertChar4Double4(inV, out, true); 17692 out.destroy(); 17693 } catch (Exception e) { 17694 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString()); 17695 } 17696 inV.destroy(); 17697 } 17698 17699 private void verifyResultsConvertChar4Double4(Allocation inV, Allocation out, boolean relaxed) { 17700 byte[] arrayInV = new byte[INPUTSIZE * 4]; 17701 Arrays.fill(arrayInV, (byte) 42); 17702 inV.copyTo(arrayInV); 17703 double[] arrayOut = new double[INPUTSIZE * 4]; 17704 Arrays.fill(arrayOut, (double) 42); 17705 out.copyTo(arrayOut); 17706 StringBuilder message = new StringBuilder(); 17707 boolean errorFound = false; 17708 for (int i = 0; i < INPUTSIZE; i++) { 17709 for (int j = 0; j < 4 ; j++) { 17710 // Extract the inputs. 17711 ArgumentsCharDouble args = new ArgumentsCharDouble(); 17712 args.inV = arrayInV[i * 4 + j]; 17713 // Figure out what the outputs should have been. 17714 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17715 CoreMathVerifier.computeConvert(args, target); 17716 // Validate the outputs. 17717 boolean valid = true; 17718 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17719 valid = false; 17720 } 17721 if (!valid) { 17722 if (!errorFound) { 17723 errorFound = true; 17724 message.append("Input inV: "); 17725 appendVariableToMessage(message, args.inV); 17726 message.append("\n"); 17727 message.append("Expected output out: "); 17728 appendVariableToMessage(message, args.out); 17729 message.append("\n"); 17730 message.append("Actual output out: "); 17731 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17732 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17733 message.append(" FAIL"); 17734 } 17735 message.append("\n"); 17736 message.append("Errors at"); 17737 } 17738 message.append(" ["); 17739 message.append(Integer.toString(i)); 17740 message.append(", "); 17741 message.append(Integer.toString(j)); 17742 message.append("]"); 17743 } 17744 } 17745 } 17746 assertFalse("Incorrect output for checkConvertChar4Double4" + 17747 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17748 } 17749 17750 public class ArgumentsUcharDouble { 17751 public byte inV; 17752 public Target.Floaty out; 17753 } 17754 17755 private void checkConvertUchar2Double2() { 17756 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x70cea2996167f1al, false, 8); 17757 try { 17758 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17759 script.forEach_testConvertDouble2Uchar2Double2(inV, out); 17760 verifyResultsConvertUchar2Double2(inV, out, false); 17761 out.destroy(); 17762 } catch (Exception e) { 17763 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString()); 17764 } 17765 try { 17766 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17767 scriptRelaxed.forEach_testConvertDouble2Uchar2Double2(inV, out); 17768 verifyResultsConvertUchar2Double2(inV, out, true); 17769 out.destroy(); 17770 } catch (Exception e) { 17771 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString()); 17772 } 17773 inV.destroy(); 17774 } 17775 17776 private void verifyResultsConvertUchar2Double2(Allocation inV, Allocation out, boolean relaxed) { 17777 byte[] arrayInV = new byte[INPUTSIZE * 2]; 17778 Arrays.fill(arrayInV, (byte) 42); 17779 inV.copyTo(arrayInV); 17780 double[] arrayOut = new double[INPUTSIZE * 2]; 17781 Arrays.fill(arrayOut, (double) 42); 17782 out.copyTo(arrayOut); 17783 StringBuilder message = new StringBuilder(); 17784 boolean errorFound = false; 17785 for (int i = 0; i < INPUTSIZE; i++) { 17786 for (int j = 0; j < 2 ; j++) { 17787 // Extract the inputs. 17788 ArgumentsUcharDouble args = new ArgumentsUcharDouble(); 17789 args.inV = arrayInV[i * 2 + j]; 17790 // Figure out what the outputs should have been. 17791 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17792 CoreMathVerifier.computeConvert(args, target); 17793 // Validate the outputs. 17794 boolean valid = true; 17795 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17796 valid = false; 17797 } 17798 if (!valid) { 17799 if (!errorFound) { 17800 errorFound = true; 17801 message.append("Input inV: "); 17802 appendVariableToMessage(message, args.inV); 17803 message.append("\n"); 17804 message.append("Expected output out: "); 17805 appendVariableToMessage(message, args.out); 17806 message.append("\n"); 17807 message.append("Actual output out: "); 17808 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17809 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17810 message.append(" FAIL"); 17811 } 17812 message.append("\n"); 17813 message.append("Errors at"); 17814 } 17815 message.append(" ["); 17816 message.append(Integer.toString(i)); 17817 message.append(", "); 17818 message.append(Integer.toString(j)); 17819 message.append("]"); 17820 } 17821 } 17822 } 17823 assertFalse("Incorrect output for checkConvertUchar2Double2" + 17824 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17825 } 17826 17827 private void checkConvertUchar3Double3() { 17828 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x759b1b0ec721046l, false, 8); 17829 try { 17830 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17831 script.forEach_testConvertDouble3Uchar3Double3(inV, out); 17832 verifyResultsConvertUchar3Double3(inV, out, false); 17833 out.destroy(); 17834 } catch (Exception e) { 17835 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString()); 17836 } 17837 try { 17838 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17839 scriptRelaxed.forEach_testConvertDouble3Uchar3Double3(inV, out); 17840 verifyResultsConvertUchar3Double3(inV, out, true); 17841 out.destroy(); 17842 } catch (Exception e) { 17843 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString()); 17844 } 17845 inV.destroy(); 17846 } 17847 17848 private void verifyResultsConvertUchar3Double3(Allocation inV, Allocation out, boolean relaxed) { 17849 byte[] arrayInV = new byte[INPUTSIZE * 4]; 17850 Arrays.fill(arrayInV, (byte) 42); 17851 inV.copyTo(arrayInV); 17852 double[] arrayOut = new double[INPUTSIZE * 4]; 17853 Arrays.fill(arrayOut, (double) 42); 17854 out.copyTo(arrayOut); 17855 StringBuilder message = new StringBuilder(); 17856 boolean errorFound = false; 17857 for (int i = 0; i < INPUTSIZE; i++) { 17858 for (int j = 0; j < 3 ; j++) { 17859 // Extract the inputs. 17860 ArgumentsUcharDouble args = new ArgumentsUcharDouble(); 17861 args.inV = arrayInV[i * 4 + j]; 17862 // Figure out what the outputs should have been. 17863 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17864 CoreMathVerifier.computeConvert(args, target); 17865 // Validate the outputs. 17866 boolean valid = true; 17867 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17868 valid = false; 17869 } 17870 if (!valid) { 17871 if (!errorFound) { 17872 errorFound = true; 17873 message.append("Input inV: "); 17874 appendVariableToMessage(message, args.inV); 17875 message.append("\n"); 17876 message.append("Expected output out: "); 17877 appendVariableToMessage(message, args.out); 17878 message.append("\n"); 17879 message.append("Actual output out: "); 17880 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17881 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17882 message.append(" FAIL"); 17883 } 17884 message.append("\n"); 17885 message.append("Errors at"); 17886 } 17887 message.append(" ["); 17888 message.append(Integer.toString(i)); 17889 message.append(", "); 17890 message.append(Integer.toString(j)); 17891 message.append("]"); 17892 } 17893 } 17894 } 17895 assertFalse("Incorrect output for checkConvertUchar3Double3" + 17896 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17897 } 17898 17899 private void checkConvertUchar4Double4() { 17900 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7a6793842cda172l, false, 8); 17901 try { 17902 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17903 script.forEach_testConvertDouble4Uchar4Double4(inV, out); 17904 verifyResultsConvertUchar4Double4(inV, out, false); 17905 out.destroy(); 17906 } catch (Exception e) { 17907 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString()); 17908 } 17909 try { 17910 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17911 scriptRelaxed.forEach_testConvertDouble4Uchar4Double4(inV, out); 17912 verifyResultsConvertUchar4Double4(inV, out, true); 17913 out.destroy(); 17914 } catch (Exception e) { 17915 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString()); 17916 } 17917 inV.destroy(); 17918 } 17919 17920 private void verifyResultsConvertUchar4Double4(Allocation inV, Allocation out, boolean relaxed) { 17921 byte[] arrayInV = new byte[INPUTSIZE * 4]; 17922 Arrays.fill(arrayInV, (byte) 42); 17923 inV.copyTo(arrayInV); 17924 double[] arrayOut = new double[INPUTSIZE * 4]; 17925 Arrays.fill(arrayOut, (double) 42); 17926 out.copyTo(arrayOut); 17927 StringBuilder message = new StringBuilder(); 17928 boolean errorFound = false; 17929 for (int i = 0; i < INPUTSIZE; i++) { 17930 for (int j = 0; j < 4 ; j++) { 17931 // Extract the inputs. 17932 ArgumentsUcharDouble args = new ArgumentsUcharDouble(); 17933 args.inV = arrayInV[i * 4 + j]; 17934 // Figure out what the outputs should have been. 17935 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17936 CoreMathVerifier.computeConvert(args, target); 17937 // Validate the outputs. 17938 boolean valid = true; 17939 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17940 valid = false; 17941 } 17942 if (!valid) { 17943 if (!errorFound) { 17944 errorFound = true; 17945 message.append("Input inV: "); 17946 appendVariableToMessage(message, args.inV); 17947 message.append("\n"); 17948 message.append("Expected output out: "); 17949 appendVariableToMessage(message, args.out); 17950 message.append("\n"); 17951 message.append("Actual output out: "); 17952 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17953 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17954 message.append(" FAIL"); 17955 } 17956 message.append("\n"); 17957 message.append("Errors at"); 17958 } 17959 message.append(" ["); 17960 message.append(Integer.toString(i)); 17961 message.append(", "); 17962 message.append(Integer.toString(j)); 17963 message.append("]"); 17964 } 17965 } 17966 } 17967 assertFalse("Incorrect output for checkConvertUchar4Double4" + 17968 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17969 } 17970 17971 public class ArgumentsShortDouble { 17972 public short inV; 17973 public Target.Floaty out; 17974 } 17975 17976 private void checkConvertShort2Double2() { 17977 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xfdeea470023d0105l, true, 15); 17978 try { 17979 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17980 script.forEach_testConvertDouble2Short2Double2(inV, out); 17981 verifyResultsConvertShort2Double2(inV, out, false); 17982 out.destroy(); 17983 } catch (Exception e) { 17984 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString()); 17985 } 17986 try { 17987 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17988 scriptRelaxed.forEach_testConvertDouble2Short2Double2(inV, out); 17989 verifyResultsConvertShort2Double2(inV, out, true); 17990 out.destroy(); 17991 } catch (Exception e) { 17992 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString()); 17993 } 17994 inV.destroy(); 17995 } 17996 17997 private void verifyResultsConvertShort2Double2(Allocation inV, Allocation out, boolean relaxed) { 17998 short[] arrayInV = new short[INPUTSIZE * 2]; 17999 Arrays.fill(arrayInV, (short) 42); 18000 inV.copyTo(arrayInV); 18001 double[] arrayOut = new double[INPUTSIZE * 2]; 18002 Arrays.fill(arrayOut, (double) 42); 18003 out.copyTo(arrayOut); 18004 StringBuilder message = new StringBuilder(); 18005 boolean errorFound = false; 18006 for (int i = 0; i < INPUTSIZE; i++) { 18007 for (int j = 0; j < 2 ; j++) { 18008 // Extract the inputs. 18009 ArgumentsShortDouble args = new ArgumentsShortDouble(); 18010 args.inV = arrayInV[i * 2 + j]; 18011 // Figure out what the outputs should have been. 18012 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18013 CoreMathVerifier.computeConvert(args, target); 18014 // Validate the outputs. 18015 boolean valid = true; 18016 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18017 valid = false; 18018 } 18019 if (!valid) { 18020 if (!errorFound) { 18021 errorFound = true; 18022 message.append("Input inV: "); 18023 appendVariableToMessage(message, args.inV); 18024 message.append("\n"); 18025 message.append("Expected output out: "); 18026 appendVariableToMessage(message, args.out); 18027 message.append("\n"); 18028 message.append("Actual output out: "); 18029 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18030 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18031 message.append(" FAIL"); 18032 } 18033 message.append("\n"); 18034 message.append("Errors at"); 18035 } 18036 message.append(" ["); 18037 message.append(Integer.toString(i)); 18038 message.append(", "); 18039 message.append(Integer.toString(j)); 18040 message.append("]"); 18041 } 18042 } 18043 } 18044 assertFalse("Incorrect output for checkConvertShort2Double2" + 18045 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18046 } 18047 18048 private void checkConvertShort3Double3() { 18049 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xfe3b6bf758989231l, true, 15); 18050 try { 18051 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18052 script.forEach_testConvertDouble3Short3Double3(inV, out); 18053 verifyResultsConvertShort3Double3(inV, out, false); 18054 out.destroy(); 18055 } catch (Exception e) { 18056 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString()); 18057 } 18058 try { 18059 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18060 scriptRelaxed.forEach_testConvertDouble3Short3Double3(inV, out); 18061 verifyResultsConvertShort3Double3(inV, out, true); 18062 out.destroy(); 18063 } catch (Exception e) { 18064 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString()); 18065 } 18066 inV.destroy(); 18067 } 18068 18069 private void verifyResultsConvertShort3Double3(Allocation inV, Allocation out, boolean relaxed) { 18070 short[] arrayInV = new short[INPUTSIZE * 4]; 18071 Arrays.fill(arrayInV, (short) 42); 18072 inV.copyTo(arrayInV); 18073 double[] arrayOut = new double[INPUTSIZE * 4]; 18074 Arrays.fill(arrayOut, (double) 42); 18075 out.copyTo(arrayOut); 18076 StringBuilder message = new StringBuilder(); 18077 boolean errorFound = false; 18078 for (int i = 0; i < INPUTSIZE; i++) { 18079 for (int j = 0; j < 3 ; j++) { 18080 // Extract the inputs. 18081 ArgumentsShortDouble args = new ArgumentsShortDouble(); 18082 args.inV = arrayInV[i * 4 + j]; 18083 // Figure out what the outputs should have been. 18084 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18085 CoreMathVerifier.computeConvert(args, target); 18086 // Validate the outputs. 18087 boolean valid = true; 18088 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18089 valid = false; 18090 } 18091 if (!valid) { 18092 if (!errorFound) { 18093 errorFound = true; 18094 message.append("Input inV: "); 18095 appendVariableToMessage(message, args.inV); 18096 message.append("\n"); 18097 message.append("Expected output out: "); 18098 appendVariableToMessage(message, args.out); 18099 message.append("\n"); 18100 message.append("Actual output out: "); 18101 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18102 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18103 message.append(" FAIL"); 18104 } 18105 message.append("\n"); 18106 message.append("Errors at"); 18107 } 18108 message.append(" ["); 18109 message.append(Integer.toString(i)); 18110 message.append(", "); 18111 message.append(Integer.toString(j)); 18112 message.append("]"); 18113 } 18114 } 18115 } 18116 assertFalse("Incorrect output for checkConvertShort3Double3" + 18117 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18118 } 18119 18120 private void checkConvertShort4Double4() { 18121 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xfe88337eaef4235dl, true, 15); 18122 try { 18123 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18124 script.forEach_testConvertDouble4Short4Double4(inV, out); 18125 verifyResultsConvertShort4Double4(inV, out, false); 18126 out.destroy(); 18127 } catch (Exception e) { 18128 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString()); 18129 } 18130 try { 18131 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18132 scriptRelaxed.forEach_testConvertDouble4Short4Double4(inV, out); 18133 verifyResultsConvertShort4Double4(inV, out, true); 18134 out.destroy(); 18135 } catch (Exception e) { 18136 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString()); 18137 } 18138 inV.destroy(); 18139 } 18140 18141 private void verifyResultsConvertShort4Double4(Allocation inV, Allocation out, boolean relaxed) { 18142 short[] arrayInV = new short[INPUTSIZE * 4]; 18143 Arrays.fill(arrayInV, (short) 42); 18144 inV.copyTo(arrayInV); 18145 double[] arrayOut = new double[INPUTSIZE * 4]; 18146 Arrays.fill(arrayOut, (double) 42); 18147 out.copyTo(arrayOut); 18148 StringBuilder message = new StringBuilder(); 18149 boolean errorFound = false; 18150 for (int i = 0; i < INPUTSIZE; i++) { 18151 for (int j = 0; j < 4 ; j++) { 18152 // Extract the inputs. 18153 ArgumentsShortDouble args = new ArgumentsShortDouble(); 18154 args.inV = arrayInV[i * 4 + j]; 18155 // Figure out what the outputs should have been. 18156 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18157 CoreMathVerifier.computeConvert(args, target); 18158 // Validate the outputs. 18159 boolean valid = true; 18160 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18161 valid = false; 18162 } 18163 if (!valid) { 18164 if (!errorFound) { 18165 errorFound = true; 18166 message.append("Input inV: "); 18167 appendVariableToMessage(message, args.inV); 18168 message.append("\n"); 18169 message.append("Expected output out: "); 18170 appendVariableToMessage(message, args.out); 18171 message.append("\n"); 18172 message.append("Actual output out: "); 18173 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18174 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18175 message.append(" FAIL"); 18176 } 18177 message.append("\n"); 18178 message.append("Errors at"); 18179 } 18180 message.append(" ["); 18181 message.append(Integer.toString(i)); 18182 message.append(", "); 18183 message.append(Integer.toString(j)); 18184 message.append("]"); 18185 } 18186 } 18187 } 18188 assertFalse("Incorrect output for checkConvertShort4Double4" + 18189 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18190 } 18191 18192 public class ArgumentsUshortDouble { 18193 public short inV; 18194 public Target.Floaty out; 18195 } 18196 18197 private void checkConvertUshort2Double2() { 18198 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd2b3fb649e0e6518l, false, 16); 18199 try { 18200 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 18201 script.forEach_testConvertDouble2Ushort2Double2(inV, out); 18202 verifyResultsConvertUshort2Double2(inV, out, false); 18203 out.destroy(); 18204 } catch (Exception e) { 18205 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString()); 18206 } 18207 try { 18208 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 18209 scriptRelaxed.forEach_testConvertDouble2Ushort2Double2(inV, out); 18210 verifyResultsConvertUshort2Double2(inV, out, true); 18211 out.destroy(); 18212 } catch (Exception e) { 18213 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString()); 18214 } 18215 inV.destroy(); 18216 } 18217 18218 private void verifyResultsConvertUshort2Double2(Allocation inV, Allocation out, boolean relaxed) { 18219 short[] arrayInV = new short[INPUTSIZE * 2]; 18220 Arrays.fill(arrayInV, (short) 42); 18221 inV.copyTo(arrayInV); 18222 double[] arrayOut = new double[INPUTSIZE * 2]; 18223 Arrays.fill(arrayOut, (double) 42); 18224 out.copyTo(arrayOut); 18225 StringBuilder message = new StringBuilder(); 18226 boolean errorFound = false; 18227 for (int i = 0; i < INPUTSIZE; i++) { 18228 for (int j = 0; j < 2 ; j++) { 18229 // Extract the inputs. 18230 ArgumentsUshortDouble args = new ArgumentsUshortDouble(); 18231 args.inV = arrayInV[i * 2 + j]; 18232 // Figure out what the outputs should have been. 18233 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18234 CoreMathVerifier.computeConvert(args, target); 18235 // Validate the outputs. 18236 boolean valid = true; 18237 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18238 valid = false; 18239 } 18240 if (!valid) { 18241 if (!errorFound) { 18242 errorFound = true; 18243 message.append("Input inV: "); 18244 appendVariableToMessage(message, args.inV); 18245 message.append("\n"); 18246 message.append("Expected output out: "); 18247 appendVariableToMessage(message, args.out); 18248 message.append("\n"); 18249 message.append("Actual output out: "); 18250 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18251 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18252 message.append(" FAIL"); 18253 } 18254 message.append("\n"); 18255 message.append("Errors at"); 18256 } 18257 message.append(" ["); 18258 message.append(Integer.toString(i)); 18259 message.append(", "); 18260 message.append(Integer.toString(j)); 18261 message.append("]"); 18262 } 18263 } 18264 } 18265 assertFalse("Incorrect output for checkConvertUshort2Double2" + 18266 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18267 } 18268 18269 private void checkConvertUshort3Double3() { 18270 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd300c2ebf469f644l, false, 16); 18271 try { 18272 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18273 script.forEach_testConvertDouble3Ushort3Double3(inV, out); 18274 verifyResultsConvertUshort3Double3(inV, out, false); 18275 out.destroy(); 18276 } catch (Exception e) { 18277 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString()); 18278 } 18279 try { 18280 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18281 scriptRelaxed.forEach_testConvertDouble3Ushort3Double3(inV, out); 18282 verifyResultsConvertUshort3Double3(inV, out, true); 18283 out.destroy(); 18284 } catch (Exception e) { 18285 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString()); 18286 } 18287 inV.destroy(); 18288 } 18289 18290 private void verifyResultsConvertUshort3Double3(Allocation inV, Allocation out, boolean relaxed) { 18291 short[] arrayInV = new short[INPUTSIZE * 4]; 18292 Arrays.fill(arrayInV, (short) 42); 18293 inV.copyTo(arrayInV); 18294 double[] arrayOut = new double[INPUTSIZE * 4]; 18295 Arrays.fill(arrayOut, (double) 42); 18296 out.copyTo(arrayOut); 18297 StringBuilder message = new StringBuilder(); 18298 boolean errorFound = false; 18299 for (int i = 0; i < INPUTSIZE; i++) { 18300 for (int j = 0; j < 3 ; j++) { 18301 // Extract the inputs. 18302 ArgumentsUshortDouble args = new ArgumentsUshortDouble(); 18303 args.inV = arrayInV[i * 4 + j]; 18304 // Figure out what the outputs should have been. 18305 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18306 CoreMathVerifier.computeConvert(args, target); 18307 // Validate the outputs. 18308 boolean valid = true; 18309 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18310 valid = false; 18311 } 18312 if (!valid) { 18313 if (!errorFound) { 18314 errorFound = true; 18315 message.append("Input inV: "); 18316 appendVariableToMessage(message, args.inV); 18317 message.append("\n"); 18318 message.append("Expected output out: "); 18319 appendVariableToMessage(message, args.out); 18320 message.append("\n"); 18321 message.append("Actual output out: "); 18322 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18323 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18324 message.append(" FAIL"); 18325 } 18326 message.append("\n"); 18327 message.append("Errors at"); 18328 } 18329 message.append(" ["); 18330 message.append(Integer.toString(i)); 18331 message.append(", "); 18332 message.append(Integer.toString(j)); 18333 message.append("]"); 18334 } 18335 } 18336 } 18337 assertFalse("Incorrect output for checkConvertUshort3Double3" + 18338 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18339 } 18340 18341 private void checkConvertUshort4Double4() { 18342 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xd34d8a734ac58770l, false, 16); 18343 try { 18344 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18345 script.forEach_testConvertDouble4Ushort4Double4(inV, out); 18346 verifyResultsConvertUshort4Double4(inV, out, false); 18347 out.destroy(); 18348 } catch (Exception e) { 18349 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString()); 18350 } 18351 try { 18352 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18353 scriptRelaxed.forEach_testConvertDouble4Ushort4Double4(inV, out); 18354 verifyResultsConvertUshort4Double4(inV, out, true); 18355 out.destroy(); 18356 } catch (Exception e) { 18357 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString()); 18358 } 18359 inV.destroy(); 18360 } 18361 18362 private void verifyResultsConvertUshort4Double4(Allocation inV, Allocation out, boolean relaxed) { 18363 short[] arrayInV = new short[INPUTSIZE * 4]; 18364 Arrays.fill(arrayInV, (short) 42); 18365 inV.copyTo(arrayInV); 18366 double[] arrayOut = new double[INPUTSIZE * 4]; 18367 Arrays.fill(arrayOut, (double) 42); 18368 out.copyTo(arrayOut); 18369 StringBuilder message = new StringBuilder(); 18370 boolean errorFound = false; 18371 for (int i = 0; i < INPUTSIZE; i++) { 18372 for (int j = 0; j < 4 ; j++) { 18373 // Extract the inputs. 18374 ArgumentsUshortDouble args = new ArgumentsUshortDouble(); 18375 args.inV = arrayInV[i * 4 + j]; 18376 // Figure out what the outputs should have been. 18377 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18378 CoreMathVerifier.computeConvert(args, target); 18379 // Validate the outputs. 18380 boolean valid = true; 18381 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18382 valid = false; 18383 } 18384 if (!valid) { 18385 if (!errorFound) { 18386 errorFound = true; 18387 message.append("Input inV: "); 18388 appendVariableToMessage(message, args.inV); 18389 message.append("\n"); 18390 message.append("Expected output out: "); 18391 appendVariableToMessage(message, args.out); 18392 message.append("\n"); 18393 message.append("Actual output out: "); 18394 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18395 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18396 message.append(" FAIL"); 18397 } 18398 message.append("\n"); 18399 message.append("Errors at"); 18400 } 18401 message.append(" ["); 18402 message.append(Integer.toString(i)); 18403 message.append(", "); 18404 message.append(Integer.toString(j)); 18405 message.append("]"); 18406 } 18407 } 18408 } 18409 assertFalse("Incorrect output for checkConvertUshort4Double4" + 18410 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18411 } 18412 18413 public class ArgumentsIntDouble { 18414 public int inV; 18415 public Target.Floaty out; 18416 } 18417 18418 private void checkConvertInt2Double2() { 18419 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x1be423b7a40fc8f6l, true, 31); 18420 try { 18421 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 18422 script.forEach_testConvertDouble2Int2Double2(inV, out); 18423 verifyResultsConvertInt2Double2(inV, out, false); 18424 out.destroy(); 18425 } catch (Exception e) { 18426 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString()); 18427 } 18428 try { 18429 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 18430 scriptRelaxed.forEach_testConvertDouble2Int2Double2(inV, out); 18431 verifyResultsConvertInt2Double2(inV, out, true); 18432 out.destroy(); 18433 } catch (Exception e) { 18434 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString()); 18435 } 18436 inV.destroy(); 18437 } 18438 18439 private void verifyResultsConvertInt2Double2(Allocation inV, Allocation out, boolean relaxed) { 18440 int[] arrayInV = new int[INPUTSIZE * 2]; 18441 Arrays.fill(arrayInV, (int) 42); 18442 inV.copyTo(arrayInV); 18443 double[] arrayOut = new double[INPUTSIZE * 2]; 18444 Arrays.fill(arrayOut, (double) 42); 18445 out.copyTo(arrayOut); 18446 StringBuilder message = new StringBuilder(); 18447 boolean errorFound = false; 18448 for (int i = 0; i < INPUTSIZE; i++) { 18449 for (int j = 0; j < 2 ; j++) { 18450 // Extract the inputs. 18451 ArgumentsIntDouble args = new ArgumentsIntDouble(); 18452 args.inV = arrayInV[i * 2 + j]; 18453 // Figure out what the outputs should have been. 18454 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18455 CoreMathVerifier.computeConvert(args, target); 18456 // Validate the outputs. 18457 boolean valid = true; 18458 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18459 valid = false; 18460 } 18461 if (!valid) { 18462 if (!errorFound) { 18463 errorFound = true; 18464 message.append("Input inV: "); 18465 appendVariableToMessage(message, args.inV); 18466 message.append("\n"); 18467 message.append("Expected output out: "); 18468 appendVariableToMessage(message, args.out); 18469 message.append("\n"); 18470 message.append("Actual output out: "); 18471 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18472 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18473 message.append(" FAIL"); 18474 } 18475 message.append("\n"); 18476 message.append("Errors at"); 18477 } 18478 message.append(" ["); 18479 message.append(Integer.toString(i)); 18480 message.append(", "); 18481 message.append(Integer.toString(j)); 18482 message.append("]"); 18483 } 18484 } 18485 } 18486 assertFalse("Incorrect output for checkConvertInt2Double2" + 18487 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18488 } 18489 18490 private void checkConvertInt3Double3() { 18491 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1c30eb3efa6b5a22l, true, 31); 18492 try { 18493 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18494 script.forEach_testConvertDouble3Int3Double3(inV, out); 18495 verifyResultsConvertInt3Double3(inV, out, false); 18496 out.destroy(); 18497 } catch (Exception e) { 18498 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString()); 18499 } 18500 try { 18501 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18502 scriptRelaxed.forEach_testConvertDouble3Int3Double3(inV, out); 18503 verifyResultsConvertInt3Double3(inV, out, true); 18504 out.destroy(); 18505 } catch (Exception e) { 18506 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString()); 18507 } 18508 inV.destroy(); 18509 } 18510 18511 private void verifyResultsConvertInt3Double3(Allocation inV, Allocation out, boolean relaxed) { 18512 int[] arrayInV = new int[INPUTSIZE * 4]; 18513 Arrays.fill(arrayInV, (int) 42); 18514 inV.copyTo(arrayInV); 18515 double[] arrayOut = new double[INPUTSIZE * 4]; 18516 Arrays.fill(arrayOut, (double) 42); 18517 out.copyTo(arrayOut); 18518 StringBuilder message = new StringBuilder(); 18519 boolean errorFound = false; 18520 for (int i = 0; i < INPUTSIZE; i++) { 18521 for (int j = 0; j < 3 ; j++) { 18522 // Extract the inputs. 18523 ArgumentsIntDouble args = new ArgumentsIntDouble(); 18524 args.inV = arrayInV[i * 4 + j]; 18525 // Figure out what the outputs should have been. 18526 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18527 CoreMathVerifier.computeConvert(args, target); 18528 // Validate the outputs. 18529 boolean valid = true; 18530 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18531 valid = false; 18532 } 18533 if (!valid) { 18534 if (!errorFound) { 18535 errorFound = true; 18536 message.append("Input inV: "); 18537 appendVariableToMessage(message, args.inV); 18538 message.append("\n"); 18539 message.append("Expected output out: "); 18540 appendVariableToMessage(message, args.out); 18541 message.append("\n"); 18542 message.append("Actual output out: "); 18543 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18544 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18545 message.append(" FAIL"); 18546 } 18547 message.append("\n"); 18548 message.append("Errors at"); 18549 } 18550 message.append(" ["); 18551 message.append(Integer.toString(i)); 18552 message.append(", "); 18553 message.append(Integer.toString(j)); 18554 message.append("]"); 18555 } 18556 } 18557 } 18558 assertFalse("Incorrect output for checkConvertInt3Double3" + 18559 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18560 } 18561 18562 private void checkConvertInt4Double4() { 18563 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x1c7db2c650c6eb4el, true, 31); 18564 try { 18565 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18566 script.forEach_testConvertDouble4Int4Double4(inV, out); 18567 verifyResultsConvertInt4Double4(inV, out, false); 18568 out.destroy(); 18569 } catch (Exception e) { 18570 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString()); 18571 } 18572 try { 18573 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18574 scriptRelaxed.forEach_testConvertDouble4Int4Double4(inV, out); 18575 verifyResultsConvertInt4Double4(inV, out, true); 18576 out.destroy(); 18577 } catch (Exception e) { 18578 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString()); 18579 } 18580 inV.destroy(); 18581 } 18582 18583 private void verifyResultsConvertInt4Double4(Allocation inV, Allocation out, boolean relaxed) { 18584 int[] arrayInV = new int[INPUTSIZE * 4]; 18585 Arrays.fill(arrayInV, (int) 42); 18586 inV.copyTo(arrayInV); 18587 double[] arrayOut = new double[INPUTSIZE * 4]; 18588 Arrays.fill(arrayOut, (double) 42); 18589 out.copyTo(arrayOut); 18590 StringBuilder message = new StringBuilder(); 18591 boolean errorFound = false; 18592 for (int i = 0; i < INPUTSIZE; i++) { 18593 for (int j = 0; j < 4 ; j++) { 18594 // Extract the inputs. 18595 ArgumentsIntDouble args = new ArgumentsIntDouble(); 18596 args.inV = arrayInV[i * 4 + j]; 18597 // Figure out what the outputs should have been. 18598 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18599 CoreMathVerifier.computeConvert(args, target); 18600 // Validate the outputs. 18601 boolean valid = true; 18602 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18603 valid = false; 18604 } 18605 if (!valid) { 18606 if (!errorFound) { 18607 errorFound = true; 18608 message.append("Input inV: "); 18609 appendVariableToMessage(message, args.inV); 18610 message.append("\n"); 18611 message.append("Expected output out: "); 18612 appendVariableToMessage(message, args.out); 18613 message.append("\n"); 18614 message.append("Actual output out: "); 18615 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18616 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18617 message.append(" FAIL"); 18618 } 18619 message.append("\n"); 18620 message.append("Errors at"); 18621 } 18622 message.append(" ["); 18623 message.append(Integer.toString(i)); 18624 message.append(", "); 18625 message.append(Integer.toString(j)); 18626 message.append("]"); 18627 } 18628 } 18629 } 18630 assertFalse("Incorrect output for checkConvertInt4Double4" + 18631 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18632 } 18633 18634 public class ArgumentsUintDouble { 18635 public int inV; 18636 public Target.Floaty out; 18637 } 18638 18639 private void checkConvertUint2Double2() { 18640 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x40b243bf3fe7e2a1l, false, 32); 18641 try { 18642 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 18643 script.forEach_testConvertDouble2Uint2Double2(inV, out); 18644 verifyResultsConvertUint2Double2(inV, out, false); 18645 out.destroy(); 18646 } catch (Exception e) { 18647 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString()); 18648 } 18649 try { 18650 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 18651 scriptRelaxed.forEach_testConvertDouble2Uint2Double2(inV, out); 18652 verifyResultsConvertUint2Double2(inV, out, true); 18653 out.destroy(); 18654 } catch (Exception e) { 18655 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString()); 18656 } 18657 inV.destroy(); 18658 } 18659 18660 private void verifyResultsConvertUint2Double2(Allocation inV, Allocation out, boolean relaxed) { 18661 int[] arrayInV = new int[INPUTSIZE * 2]; 18662 Arrays.fill(arrayInV, (int) 42); 18663 inV.copyTo(arrayInV); 18664 double[] arrayOut = new double[INPUTSIZE * 2]; 18665 Arrays.fill(arrayOut, (double) 42); 18666 out.copyTo(arrayOut); 18667 StringBuilder message = new StringBuilder(); 18668 boolean errorFound = false; 18669 for (int i = 0; i < INPUTSIZE; i++) { 18670 for (int j = 0; j < 2 ; j++) { 18671 // Extract the inputs. 18672 ArgumentsUintDouble args = new ArgumentsUintDouble(); 18673 args.inV = arrayInV[i * 2 + j]; 18674 // Figure out what the outputs should have been. 18675 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18676 CoreMathVerifier.computeConvert(args, target); 18677 // Validate the outputs. 18678 boolean valid = true; 18679 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18680 valid = false; 18681 } 18682 if (!valid) { 18683 if (!errorFound) { 18684 errorFound = true; 18685 message.append("Input inV: "); 18686 appendVariableToMessage(message, args.inV); 18687 message.append("\n"); 18688 message.append("Expected output out: "); 18689 appendVariableToMessage(message, args.out); 18690 message.append("\n"); 18691 message.append("Actual output out: "); 18692 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18693 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 18694 message.append(" FAIL"); 18695 } 18696 message.append("\n"); 18697 message.append("Errors at"); 18698 } 18699 message.append(" ["); 18700 message.append(Integer.toString(i)); 18701 message.append(", "); 18702 message.append(Integer.toString(j)); 18703 message.append("]"); 18704 } 18705 } 18706 } 18707 assertFalse("Incorrect output for checkConvertUint2Double2" + 18708 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18709 } 18710 18711 private void checkConvertUint3Double3() { 18712 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x40ff0b46964373cdl, false, 32); 18713 try { 18714 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18715 script.forEach_testConvertDouble3Uint3Double3(inV, out); 18716 verifyResultsConvertUint3Double3(inV, out, false); 18717 out.destroy(); 18718 } catch (Exception e) { 18719 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString()); 18720 } 18721 try { 18722 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 18723 scriptRelaxed.forEach_testConvertDouble3Uint3Double3(inV, out); 18724 verifyResultsConvertUint3Double3(inV, out, true); 18725 out.destroy(); 18726 } catch (Exception e) { 18727 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString()); 18728 } 18729 inV.destroy(); 18730 } 18731 18732 private void verifyResultsConvertUint3Double3(Allocation inV, Allocation out, boolean relaxed) { 18733 int[] arrayInV = new int[INPUTSIZE * 4]; 18734 Arrays.fill(arrayInV, (int) 42); 18735 inV.copyTo(arrayInV); 18736 double[] arrayOut = new double[INPUTSIZE * 4]; 18737 Arrays.fill(arrayOut, (double) 42); 18738 out.copyTo(arrayOut); 18739 StringBuilder message = new StringBuilder(); 18740 boolean errorFound = false; 18741 for (int i = 0; i < INPUTSIZE; i++) { 18742 for (int j = 0; j < 3 ; j++) { 18743 // Extract the inputs. 18744 ArgumentsUintDouble args = new ArgumentsUintDouble(); 18745 args.inV = arrayInV[i * 4 + j]; 18746 // Figure out what the outputs should have been. 18747 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18748 CoreMathVerifier.computeConvert(args, target); 18749 // Validate the outputs. 18750 boolean valid = true; 18751 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18752 valid = false; 18753 } 18754 if (!valid) { 18755 if (!errorFound) { 18756 errorFound = true; 18757 message.append("Input inV: "); 18758 appendVariableToMessage(message, args.inV); 18759 message.append("\n"); 18760 message.append("Expected output out: "); 18761 appendVariableToMessage(message, args.out); 18762 message.append("\n"); 18763 message.append("Actual output out: "); 18764 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18765 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18766 message.append(" FAIL"); 18767 } 18768 message.append("\n"); 18769 message.append("Errors at"); 18770 } 18771 message.append(" ["); 18772 message.append(Integer.toString(i)); 18773 message.append(", "); 18774 message.append(Integer.toString(j)); 18775 message.append("]"); 18776 } 18777 } 18778 } 18779 assertFalse("Incorrect output for checkConvertUint3Double3" + 18780 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18781 } 18782 18783 private void checkConvertUint4Double4() { 18784 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x414bd2cdec9f04f9l, false, 32); 18785 try { 18786 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18787 script.forEach_testConvertDouble4Uint4Double4(inV, out); 18788 verifyResultsConvertUint4Double4(inV, out, false); 18789 out.destroy(); 18790 } catch (Exception e) { 18791 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString()); 18792 } 18793 try { 18794 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18795 scriptRelaxed.forEach_testConvertDouble4Uint4Double4(inV, out); 18796 verifyResultsConvertUint4Double4(inV, out, true); 18797 out.destroy(); 18798 } catch (Exception e) { 18799 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString()); 18800 } 18801 inV.destroy(); 18802 } 18803 18804 private void verifyResultsConvertUint4Double4(Allocation inV, Allocation out, boolean relaxed) { 18805 int[] arrayInV = new int[INPUTSIZE * 4]; 18806 Arrays.fill(arrayInV, (int) 42); 18807 inV.copyTo(arrayInV); 18808 double[] arrayOut = new double[INPUTSIZE * 4]; 18809 Arrays.fill(arrayOut, (double) 42); 18810 out.copyTo(arrayOut); 18811 StringBuilder message = new StringBuilder(); 18812 boolean errorFound = false; 18813 for (int i = 0; i < INPUTSIZE; i++) { 18814 for (int j = 0; j < 4 ; j++) { 18815 // Extract the inputs. 18816 ArgumentsUintDouble args = new ArgumentsUintDouble(); 18817 args.inV = arrayInV[i * 4 + j]; 18818 // Figure out what the outputs should have been. 18819 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18820 CoreMathVerifier.computeConvert(args, target); 18821 // Validate the outputs. 18822 boolean valid = true; 18823 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18824 valid = false; 18825 } 18826 if (!valid) { 18827 if (!errorFound) { 18828 errorFound = true; 18829 message.append("Input inV: "); 18830 appendVariableToMessage(message, args.inV); 18831 message.append("\n"); 18832 message.append("Expected output out: "); 18833 appendVariableToMessage(message, args.out); 18834 message.append("\n"); 18835 message.append("Actual output out: "); 18836 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18837 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18838 message.append(" FAIL"); 18839 } 18840 message.append("\n"); 18841 message.append("Errors at"); 18842 } 18843 message.append(" ["); 18844 message.append(Integer.toString(i)); 18845 message.append(", "); 18846 message.append(Integer.toString(j)); 18847 message.append("]"); 18848 } 18849 } 18850 } 18851 assertFalse("Incorrect output for checkConvertUint4Double4" + 18852 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18853 } 18854 18855 public class ArgumentsFloatLong { 18856 public float inV; 18857 public long out; 18858 } 18859 18860 private void checkConvertFloat2Long2() { 18861 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb49c7d7c0ae0l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); 18862 try { 18863 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18864 script.forEach_testConvertLong2Float2Long2(inV, out); 18865 verifyResultsConvertFloat2Long2(inV, out, false); 18866 out.destroy(); 18867 } catch (Exception e) { 18868 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString()); 18869 } 18870 try { 18871 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18872 scriptRelaxed.forEach_testConvertLong2Float2Long2(inV, out); 18873 verifyResultsConvertFloat2Long2(inV, out, true); 18874 out.destroy(); 18875 } catch (Exception e) { 18876 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString()); 18877 } 18878 inV.destroy(); 18879 } 18880 18881 private void verifyResultsConvertFloat2Long2(Allocation inV, Allocation out, boolean relaxed) { 18882 float[] arrayInV = new float[INPUTSIZE * 2]; 18883 Arrays.fill(arrayInV, (float) 42); 18884 inV.copyTo(arrayInV); 18885 long[] arrayOut = new long[INPUTSIZE * 2]; 18886 Arrays.fill(arrayOut, (long) 42); 18887 out.copyTo(arrayOut); 18888 StringBuilder message = new StringBuilder(); 18889 boolean errorFound = false; 18890 for (int i = 0; i < INPUTSIZE; i++) { 18891 for (int j = 0; j < 2 ; j++) { 18892 // Extract the inputs. 18893 ArgumentsFloatLong args = new ArgumentsFloatLong(); 18894 args.inV = arrayInV[i * 2 + j]; 18895 // Figure out what the outputs should have been. 18896 CoreMathVerifier.computeConvert(args); 18897 // Validate the outputs. 18898 boolean valid = true; 18899 if (args.out != arrayOut[i * 2 + j]) { 18900 valid = false; 18901 } 18902 if (!valid) { 18903 if (!errorFound) { 18904 errorFound = true; 18905 message.append("Input inV: "); 18906 appendVariableToMessage(message, args.inV); 18907 message.append("\n"); 18908 message.append("Expected output out: "); 18909 appendVariableToMessage(message, args.out); 18910 message.append("\n"); 18911 message.append("Actual output out: "); 18912 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18913 if (args.out != arrayOut[i * 2 + j]) { 18914 message.append(" FAIL"); 18915 } 18916 message.append("\n"); 18917 message.append("Errors at"); 18918 } 18919 message.append(" ["); 18920 message.append(Integer.toString(i)); 18921 message.append(", "); 18922 message.append(Integer.toString(j)); 18923 message.append("]"); 18924 } 18925 } 18926 } 18927 assertFalse("Incorrect output for checkConvertFloat2Long2" + 18928 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18929 } 18930 18931 private void checkConvertFloat3Long3() { 18932 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbf3ddc83cfd4l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); 18933 try { 18934 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18935 script.forEach_testConvertLong3Float3Long3(inV, out); 18936 verifyResultsConvertFloat3Long3(inV, out, false); 18937 out.destroy(); 18938 } catch (Exception e) { 18939 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString()); 18940 } 18941 try { 18942 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18943 scriptRelaxed.forEach_testConvertLong3Float3Long3(inV, out); 18944 verifyResultsConvertFloat3Long3(inV, out, true); 18945 out.destroy(); 18946 } catch (Exception e) { 18947 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString()); 18948 } 18949 inV.destroy(); 18950 } 18951 18952 private void verifyResultsConvertFloat3Long3(Allocation inV, Allocation out, boolean relaxed) { 18953 float[] arrayInV = new float[INPUTSIZE * 4]; 18954 Arrays.fill(arrayInV, (float) 42); 18955 inV.copyTo(arrayInV); 18956 long[] arrayOut = new long[INPUTSIZE * 4]; 18957 Arrays.fill(arrayOut, (long) 42); 18958 out.copyTo(arrayOut); 18959 StringBuilder message = new StringBuilder(); 18960 boolean errorFound = false; 18961 for (int i = 0; i < INPUTSIZE; i++) { 18962 for (int j = 0; j < 3 ; j++) { 18963 // Extract the inputs. 18964 ArgumentsFloatLong args = new ArgumentsFloatLong(); 18965 args.inV = arrayInV[i * 4 + j]; 18966 // Figure out what the outputs should have been. 18967 CoreMathVerifier.computeConvert(args); 18968 // Validate the outputs. 18969 boolean valid = true; 18970 if (args.out != arrayOut[i * 4 + j]) { 18971 valid = false; 18972 } 18973 if (!valid) { 18974 if (!errorFound) { 18975 errorFound = true; 18976 message.append("Input inV: "); 18977 appendVariableToMessage(message, args.inV); 18978 message.append("\n"); 18979 message.append("Expected output out: "); 18980 appendVariableToMessage(message, args.out); 18981 message.append("\n"); 18982 message.append("Actual output out: "); 18983 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18984 if (args.out != arrayOut[i * 4 + j]) { 18985 message.append(" FAIL"); 18986 } 18987 message.append("\n"); 18988 message.append("Errors at"); 18989 } 18990 message.append(" ["); 18991 message.append(Integer.toString(i)); 18992 message.append(", "); 18993 message.append(Integer.toString(j)); 18994 message.append("]"); 18995 } 18996 } 18997 } 18998 assertFalse("Incorrect output for checkConvertFloat3Long3" + 18999 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19000 } 19001 19002 private void checkConvertFloat4Long4() { 19003 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc9df3b8b94c8l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); 19004 try { 19005 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19006 script.forEach_testConvertLong4Float4Long4(inV, out); 19007 verifyResultsConvertFloat4Long4(inV, out, false); 19008 out.destroy(); 19009 } catch (Exception e) { 19010 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString()); 19011 } 19012 try { 19013 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19014 scriptRelaxed.forEach_testConvertLong4Float4Long4(inV, out); 19015 verifyResultsConvertFloat4Long4(inV, out, true); 19016 out.destroy(); 19017 } catch (Exception e) { 19018 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString()); 19019 } 19020 inV.destroy(); 19021 } 19022 19023 private void verifyResultsConvertFloat4Long4(Allocation inV, Allocation out, boolean relaxed) { 19024 float[] arrayInV = new float[INPUTSIZE * 4]; 19025 Arrays.fill(arrayInV, (float) 42); 19026 inV.copyTo(arrayInV); 19027 long[] arrayOut = new long[INPUTSIZE * 4]; 19028 Arrays.fill(arrayOut, (long) 42); 19029 out.copyTo(arrayOut); 19030 StringBuilder message = new StringBuilder(); 19031 boolean errorFound = false; 19032 for (int i = 0; i < INPUTSIZE; i++) { 19033 for (int j = 0; j < 4 ; j++) { 19034 // Extract the inputs. 19035 ArgumentsFloatLong args = new ArgumentsFloatLong(); 19036 args.inV = arrayInV[i * 4 + j]; 19037 // Figure out what the outputs should have been. 19038 CoreMathVerifier.computeConvert(args); 19039 // Validate the outputs. 19040 boolean valid = true; 19041 if (args.out != arrayOut[i * 4 + j]) { 19042 valid = false; 19043 } 19044 if (!valid) { 19045 if (!errorFound) { 19046 errorFound = true; 19047 message.append("Input inV: "); 19048 appendVariableToMessage(message, args.inV); 19049 message.append("\n"); 19050 message.append("Expected output out: "); 19051 appendVariableToMessage(message, args.out); 19052 message.append("\n"); 19053 message.append("Actual output out: "); 19054 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19055 if (args.out != arrayOut[i * 4 + j]) { 19056 message.append(" FAIL"); 19057 } 19058 message.append("\n"); 19059 message.append("Errors at"); 19060 } 19061 message.append(" ["); 19062 message.append(Integer.toString(i)); 19063 message.append(", "); 19064 message.append(Integer.toString(j)); 19065 message.append("]"); 19066 } 19067 } 19068 } 19069 assertFalse("Incorrect output for checkConvertFloat4Long4" + 19070 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19071 } 19072 19073 public class ArgumentsCharLong { 19074 public byte inV; 19075 public long out; 19076 } 19077 19078 private void checkConvertChar2Long2() { 19079 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86189bc290be220l, true, 7); 19080 try { 19081 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19082 script.forEach_testConvertLong2Char2Long2(inV, out); 19083 verifyResultsConvertChar2Long2(inV, out, false); 19084 out.destroy(); 19085 } catch (Exception e) { 19086 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString()); 19087 } 19088 try { 19089 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19090 scriptRelaxed.forEach_testConvertLong2Char2Long2(inV, out); 19091 verifyResultsConvertChar2Long2(inV, out, true); 19092 out.destroy(); 19093 } catch (Exception e) { 19094 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString()); 19095 } 19096 inV.destroy(); 19097 } 19098 19099 private void verifyResultsConvertChar2Long2(Allocation inV, Allocation out, boolean relaxed) { 19100 byte[] arrayInV = new byte[INPUTSIZE * 2]; 19101 Arrays.fill(arrayInV, (byte) 42); 19102 inV.copyTo(arrayInV); 19103 long[] arrayOut = new long[INPUTSIZE * 2]; 19104 Arrays.fill(arrayOut, (long) 42); 19105 out.copyTo(arrayOut); 19106 StringBuilder message = new StringBuilder(); 19107 boolean errorFound = false; 19108 for (int i = 0; i < INPUTSIZE; i++) { 19109 for (int j = 0; j < 2 ; j++) { 19110 // Extract the inputs. 19111 ArgumentsCharLong args = new ArgumentsCharLong(); 19112 args.inV = arrayInV[i * 2 + j]; 19113 // Figure out what the outputs should have been. 19114 CoreMathVerifier.computeConvert(args); 19115 // Validate the outputs. 19116 boolean valid = true; 19117 if (args.out != arrayOut[i * 2 + j]) { 19118 valid = false; 19119 } 19120 if (!valid) { 19121 if (!errorFound) { 19122 errorFound = true; 19123 message.append("Input inV: "); 19124 appendVariableToMessage(message, args.inV); 19125 message.append("\n"); 19126 message.append("Expected output out: "); 19127 appendVariableToMessage(message, args.out); 19128 message.append("\n"); 19129 message.append("Actual output out: "); 19130 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19131 if (args.out != arrayOut[i * 2 + j]) { 19132 message.append(" FAIL"); 19133 } 19134 message.append("\n"); 19135 message.append("Errors at"); 19136 } 19137 message.append(" ["); 19138 message.append(Integer.toString(i)); 19139 message.append(", "); 19140 message.append(Integer.toString(j)); 19141 message.append("]"); 19142 } 19143 } 19144 } 19145 assertFalse("Incorrect output for checkConvertChar2Long2" + 19146 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19147 } 19148 19149 private void checkConvertChar3Long3() { 19150 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861945d8813a714l, true, 7); 19151 try { 19152 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19153 script.forEach_testConvertLong3Char3Long3(inV, out); 19154 verifyResultsConvertChar3Long3(inV, out, false); 19155 out.destroy(); 19156 } catch (Exception e) { 19157 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString()); 19158 } 19159 try { 19160 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19161 scriptRelaxed.forEach_testConvertLong3Char3Long3(inV, out); 19162 verifyResultsConvertChar3Long3(inV, out, true); 19163 out.destroy(); 19164 } catch (Exception e) { 19165 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString()); 19166 } 19167 inV.destroy(); 19168 } 19169 19170 private void verifyResultsConvertChar3Long3(Allocation inV, Allocation out, boolean relaxed) { 19171 byte[] arrayInV = new byte[INPUTSIZE * 4]; 19172 Arrays.fill(arrayInV, (byte) 42); 19173 inV.copyTo(arrayInV); 19174 long[] arrayOut = new long[INPUTSIZE * 4]; 19175 Arrays.fill(arrayOut, (long) 42); 19176 out.copyTo(arrayOut); 19177 StringBuilder message = new StringBuilder(); 19178 boolean errorFound = false; 19179 for (int i = 0; i < INPUTSIZE; i++) { 19180 for (int j = 0; j < 3 ; j++) { 19181 // Extract the inputs. 19182 ArgumentsCharLong args = new ArgumentsCharLong(); 19183 args.inV = arrayInV[i * 4 + j]; 19184 // Figure out what the outputs should have been. 19185 CoreMathVerifier.computeConvert(args); 19186 // Validate the outputs. 19187 boolean valid = true; 19188 if (args.out != arrayOut[i * 4 + j]) { 19189 valid = false; 19190 } 19191 if (!valid) { 19192 if (!errorFound) { 19193 errorFound = true; 19194 message.append("Input inV: "); 19195 appendVariableToMessage(message, args.inV); 19196 message.append("\n"); 19197 message.append("Expected output out: "); 19198 appendVariableToMessage(message, args.out); 19199 message.append("\n"); 19200 message.append("Actual output out: "); 19201 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19202 if (args.out != arrayOut[i * 4 + j]) { 19203 message.append(" FAIL"); 19204 } 19205 message.append("\n"); 19206 message.append("Errors at"); 19207 } 19208 message.append(" ["); 19209 message.append(Integer.toString(i)); 19210 message.append(", "); 19211 message.append(Integer.toString(j)); 19212 message.append("]"); 19213 } 19214 } 19215 } 19216 assertFalse("Incorrect output for checkConvertChar3Long3" + 19217 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19218 } 19219 19220 private void checkConvertChar4Long4() { 19221 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619efee71b6c08l, true, 7); 19222 try { 19223 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19224 script.forEach_testConvertLong4Char4Long4(inV, out); 19225 verifyResultsConvertChar4Long4(inV, out, false); 19226 out.destroy(); 19227 } catch (Exception e) { 19228 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString()); 19229 } 19230 try { 19231 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19232 scriptRelaxed.forEach_testConvertLong4Char4Long4(inV, out); 19233 verifyResultsConvertChar4Long4(inV, out, true); 19234 out.destroy(); 19235 } catch (Exception e) { 19236 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString()); 19237 } 19238 inV.destroy(); 19239 } 19240 19241 private void verifyResultsConvertChar4Long4(Allocation inV, Allocation out, boolean relaxed) { 19242 byte[] arrayInV = new byte[INPUTSIZE * 4]; 19243 Arrays.fill(arrayInV, (byte) 42); 19244 inV.copyTo(arrayInV); 19245 long[] arrayOut = new long[INPUTSIZE * 4]; 19246 Arrays.fill(arrayOut, (long) 42); 19247 out.copyTo(arrayOut); 19248 StringBuilder message = new StringBuilder(); 19249 boolean errorFound = false; 19250 for (int i = 0; i < INPUTSIZE; i++) { 19251 for (int j = 0; j < 4 ; j++) { 19252 // Extract the inputs. 19253 ArgumentsCharLong args = new ArgumentsCharLong(); 19254 args.inV = arrayInV[i * 4 + j]; 19255 // Figure out what the outputs should have been. 19256 CoreMathVerifier.computeConvert(args); 19257 // Validate the outputs. 19258 boolean valid = true; 19259 if (args.out != arrayOut[i * 4 + j]) { 19260 valid = false; 19261 } 19262 if (!valid) { 19263 if (!errorFound) { 19264 errorFound = true; 19265 message.append("Input inV: "); 19266 appendVariableToMessage(message, args.inV); 19267 message.append("\n"); 19268 message.append("Expected output out: "); 19269 appendVariableToMessage(message, args.out); 19270 message.append("\n"); 19271 message.append("Actual output out: "); 19272 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19273 if (args.out != arrayOut[i * 4 + j]) { 19274 message.append(" FAIL"); 19275 } 19276 message.append("\n"); 19277 message.append("Errors at"); 19278 } 19279 message.append(" ["); 19280 message.append(Integer.toString(i)); 19281 message.append(", "); 19282 message.append(Integer.toString(j)); 19283 message.append("]"); 19284 } 19285 } 19286 } 19287 assertFalse("Incorrect output for checkConvertChar4Long4" + 19288 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19289 } 19290 19291 public class ArgumentsUcharLong { 19292 public byte inV; 19293 public long out; 19294 } 19295 19296 private void checkConvertUchar2Long2() { 19297 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef4309bb8deea1l, false, 8); 19298 try { 19299 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19300 script.forEach_testConvertLong2Uchar2Long2(inV, out); 19301 verifyResultsConvertUchar2Long2(inV, out, false); 19302 out.destroy(); 19303 } catch (Exception e) { 19304 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString()); 19305 } 19306 try { 19307 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19308 scriptRelaxed.forEach_testConvertLong2Uchar2Long2(inV, out); 19309 verifyResultsConvertUchar2Long2(inV, out, true); 19310 out.destroy(); 19311 } catch (Exception e) { 19312 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString()); 19313 } 19314 inV.destroy(); 19315 } 19316 19317 private void verifyResultsConvertUchar2Long2(Allocation inV, Allocation out, boolean relaxed) { 19318 byte[] arrayInV = new byte[INPUTSIZE * 2]; 19319 Arrays.fill(arrayInV, (byte) 42); 19320 inV.copyTo(arrayInV); 19321 long[] arrayOut = new long[INPUTSIZE * 2]; 19322 Arrays.fill(arrayOut, (long) 42); 19323 out.copyTo(arrayOut); 19324 StringBuilder message = new StringBuilder(); 19325 boolean errorFound = false; 19326 for (int i = 0; i < INPUTSIZE; i++) { 19327 for (int j = 0; j < 2 ; j++) { 19328 // Extract the inputs. 19329 ArgumentsUcharLong args = new ArgumentsUcharLong(); 19330 args.inV = arrayInV[i * 2 + j]; 19331 // Figure out what the outputs should have been. 19332 CoreMathVerifier.computeConvert(args); 19333 // Validate the outputs. 19334 boolean valid = true; 19335 if (args.out != arrayOut[i * 2 + j]) { 19336 valid = false; 19337 } 19338 if (!valid) { 19339 if (!errorFound) { 19340 errorFound = true; 19341 message.append("Input inV: "); 19342 appendVariableToMessage(message, args.inV); 19343 message.append("\n"); 19344 message.append("Expected output out: "); 19345 appendVariableToMessage(message, args.out); 19346 message.append("\n"); 19347 message.append("Actual output out: "); 19348 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19349 if (args.out != arrayOut[i * 2 + j]) { 19350 message.append(" FAIL"); 19351 } 19352 message.append("\n"); 19353 message.append("Errors at"); 19354 } 19355 message.append(" ["); 19356 message.append(Integer.toString(i)); 19357 message.append(", "); 19358 message.append(Integer.toString(j)); 19359 message.append("]"); 19360 } 19361 } 19362 } 19363 assertFalse("Incorrect output for checkConvertUchar2Long2" + 19364 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19365 } 19366 19367 private void checkConvertUchar3Long3() { 19368 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4dab1a95b395l, false, 8); 19369 try { 19370 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19371 script.forEach_testConvertLong3Uchar3Long3(inV, out); 19372 verifyResultsConvertUchar3Long3(inV, out, false); 19373 out.destroy(); 19374 } catch (Exception e) { 19375 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString()); 19376 } 19377 try { 19378 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19379 scriptRelaxed.forEach_testConvertLong3Uchar3Long3(inV, out); 19380 verifyResultsConvertUchar3Long3(inV, out, true); 19381 out.destroy(); 19382 } catch (Exception e) { 19383 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString()); 19384 } 19385 inV.destroy(); 19386 } 19387 19388 private void verifyResultsConvertUchar3Long3(Allocation inV, Allocation out, boolean relaxed) { 19389 byte[] arrayInV = new byte[INPUTSIZE * 4]; 19390 Arrays.fill(arrayInV, (byte) 42); 19391 inV.copyTo(arrayInV); 19392 long[] arrayOut = new long[INPUTSIZE * 4]; 19393 Arrays.fill(arrayOut, (long) 42); 19394 out.copyTo(arrayOut); 19395 StringBuilder message = new StringBuilder(); 19396 boolean errorFound = false; 19397 for (int i = 0; i < INPUTSIZE; i++) { 19398 for (int j = 0; j < 3 ; j++) { 19399 // Extract the inputs. 19400 ArgumentsUcharLong args = new ArgumentsUcharLong(); 19401 args.inV = arrayInV[i * 4 + j]; 19402 // Figure out what the outputs should have been. 19403 CoreMathVerifier.computeConvert(args); 19404 // Validate the outputs. 19405 boolean valid = true; 19406 if (args.out != arrayOut[i * 4 + j]) { 19407 valid = false; 19408 } 19409 if (!valid) { 19410 if (!errorFound) { 19411 errorFound = true; 19412 message.append("Input inV: "); 19413 appendVariableToMessage(message, args.inV); 19414 message.append("\n"); 19415 message.append("Expected output out: "); 19416 appendVariableToMessage(message, args.out); 19417 message.append("\n"); 19418 message.append("Actual output out: "); 19419 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19420 if (args.out != arrayOut[i * 4 + j]) { 19421 message.append(" FAIL"); 19422 } 19423 message.append("\n"); 19424 message.append("Errors at"); 19425 } 19426 message.append(" ["); 19427 message.append(Integer.toString(i)); 19428 message.append(", "); 19429 message.append(Integer.toString(j)); 19430 message.append("]"); 19431 } 19432 } 19433 } 19434 assertFalse("Incorrect output for checkConvertUchar3Long3" + 19435 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19436 } 19437 19438 private void checkConvertUchar4Long4() { 19439 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef584c799d7889l, false, 8); 19440 try { 19441 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19442 script.forEach_testConvertLong4Uchar4Long4(inV, out); 19443 verifyResultsConvertUchar4Long4(inV, out, false); 19444 out.destroy(); 19445 } catch (Exception e) { 19446 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString()); 19447 } 19448 try { 19449 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19450 scriptRelaxed.forEach_testConvertLong4Uchar4Long4(inV, out); 19451 verifyResultsConvertUchar4Long4(inV, out, true); 19452 out.destroy(); 19453 } catch (Exception e) { 19454 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString()); 19455 } 19456 inV.destroy(); 19457 } 19458 19459 private void verifyResultsConvertUchar4Long4(Allocation inV, Allocation out, boolean relaxed) { 19460 byte[] arrayInV = new byte[INPUTSIZE * 4]; 19461 Arrays.fill(arrayInV, (byte) 42); 19462 inV.copyTo(arrayInV); 19463 long[] arrayOut = new long[INPUTSIZE * 4]; 19464 Arrays.fill(arrayOut, (long) 42); 19465 out.copyTo(arrayOut); 19466 StringBuilder message = new StringBuilder(); 19467 boolean errorFound = false; 19468 for (int i = 0; i < INPUTSIZE; i++) { 19469 for (int j = 0; j < 4 ; j++) { 19470 // Extract the inputs. 19471 ArgumentsUcharLong args = new ArgumentsUcharLong(); 19472 args.inV = arrayInV[i * 4 + j]; 19473 // Figure out what the outputs should have been. 19474 CoreMathVerifier.computeConvert(args); 19475 // Validate the outputs. 19476 boolean valid = true; 19477 if (args.out != arrayOut[i * 4 + j]) { 19478 valid = false; 19479 } 19480 if (!valid) { 19481 if (!errorFound) { 19482 errorFound = true; 19483 message.append("Input inV: "); 19484 appendVariableToMessage(message, args.inV); 19485 message.append("\n"); 19486 message.append("Expected output out: "); 19487 appendVariableToMessage(message, args.out); 19488 message.append("\n"); 19489 message.append("Actual output out: "); 19490 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19491 if (args.out != arrayOut[i * 4 + j]) { 19492 message.append(" FAIL"); 19493 } 19494 message.append("\n"); 19495 message.append("Errors at"); 19496 } 19497 message.append(" ["); 19498 message.append(Integer.toString(i)); 19499 message.append(", "); 19500 message.append(Integer.toString(j)); 19501 message.append("]"); 19502 } 19503 } 19504 } 19505 assertFalse("Incorrect output for checkConvertUchar4Long4" + 19506 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19507 } 19508 19509 public class ArgumentsShortLong { 19510 public short inV; 19511 public long out; 19512 } 19513 19514 private void checkConvertShort2Long2() { 19515 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab674669c97ce4l, true, 15); 19516 try { 19517 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19518 script.forEach_testConvertLong2Short2Long2(inV, out); 19519 verifyResultsConvertShort2Long2(inV, out, false); 19520 out.destroy(); 19521 } catch (Exception e) { 19522 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString()); 19523 } 19524 try { 19525 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19526 scriptRelaxed.forEach_testConvertLong2Short2Long2(inV, out); 19527 verifyResultsConvertShort2Long2(inV, out, true); 19528 out.destroy(); 19529 } catch (Exception e) { 19530 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString()); 19531 } 19532 inV.destroy(); 19533 } 19534 19535 private void verifyResultsConvertShort2Long2(Allocation inV, Allocation out, boolean relaxed) { 19536 short[] arrayInV = new short[INPUTSIZE * 2]; 19537 Arrays.fill(arrayInV, (short) 42); 19538 inV.copyTo(arrayInV); 19539 long[] arrayOut = new long[INPUTSIZE * 2]; 19540 Arrays.fill(arrayOut, (long) 42); 19541 out.copyTo(arrayOut); 19542 StringBuilder message = new StringBuilder(); 19543 boolean errorFound = false; 19544 for (int i = 0; i < INPUTSIZE; i++) { 19545 for (int j = 0; j < 2 ; j++) { 19546 // Extract the inputs. 19547 ArgumentsShortLong args = new ArgumentsShortLong(); 19548 args.inV = arrayInV[i * 2 + j]; 19549 // Figure out what the outputs should have been. 19550 CoreMathVerifier.computeConvert(args); 19551 // Validate the outputs. 19552 boolean valid = true; 19553 if (args.out != arrayOut[i * 2 + j]) { 19554 valid = false; 19555 } 19556 if (!valid) { 19557 if (!errorFound) { 19558 errorFound = true; 19559 message.append("Input inV: "); 19560 appendVariableToMessage(message, args.inV); 19561 message.append("\n"); 19562 message.append("Expected output out: "); 19563 appendVariableToMessage(message, args.out); 19564 message.append("\n"); 19565 message.append("Actual output out: "); 19566 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19567 if (args.out != arrayOut[i * 2 + j]) { 19568 message.append(" FAIL"); 19569 } 19570 message.append("\n"); 19571 message.append("Errors at"); 19572 } 19573 message.append(" ["); 19574 message.append(Integer.toString(i)); 19575 message.append(", "); 19576 message.append(Integer.toString(j)); 19577 message.append("]"); 19578 } 19579 } 19580 } 19581 assertFalse("Incorrect output for checkConvertShort2Long2" + 19582 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19583 } 19584 19585 private void checkConvertShort3Long3() { 19586 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab71e7c8d141d8l, true, 15); 19587 try { 19588 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19589 script.forEach_testConvertLong3Short3Long3(inV, out); 19590 verifyResultsConvertShort3Long3(inV, out, false); 19591 out.destroy(); 19592 } catch (Exception e) { 19593 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString()); 19594 } 19595 try { 19596 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19597 scriptRelaxed.forEach_testConvertLong3Short3Long3(inV, out); 19598 verifyResultsConvertShort3Long3(inV, out, true); 19599 out.destroy(); 19600 } catch (Exception e) { 19601 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString()); 19602 } 19603 inV.destroy(); 19604 } 19605 19606 private void verifyResultsConvertShort3Long3(Allocation inV, Allocation out, boolean relaxed) { 19607 short[] arrayInV = new short[INPUTSIZE * 4]; 19608 Arrays.fill(arrayInV, (short) 42); 19609 inV.copyTo(arrayInV); 19610 long[] arrayOut = new long[INPUTSIZE * 4]; 19611 Arrays.fill(arrayOut, (long) 42); 19612 out.copyTo(arrayOut); 19613 StringBuilder message = new StringBuilder(); 19614 boolean errorFound = false; 19615 for (int i = 0; i < INPUTSIZE; i++) { 19616 for (int j = 0; j < 3 ; j++) { 19617 // Extract the inputs. 19618 ArgumentsShortLong args = new ArgumentsShortLong(); 19619 args.inV = arrayInV[i * 4 + j]; 19620 // Figure out what the outputs should have been. 19621 CoreMathVerifier.computeConvert(args); 19622 // Validate the outputs. 19623 boolean valid = true; 19624 if (args.out != arrayOut[i * 4 + j]) { 19625 valid = false; 19626 } 19627 if (!valid) { 19628 if (!errorFound) { 19629 errorFound = true; 19630 message.append("Input inV: "); 19631 appendVariableToMessage(message, args.inV); 19632 message.append("\n"); 19633 message.append("Expected output out: "); 19634 appendVariableToMessage(message, args.out); 19635 message.append("\n"); 19636 message.append("Actual output out: "); 19637 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19638 if (args.out != arrayOut[i * 4 + j]) { 19639 message.append(" FAIL"); 19640 } 19641 message.append("\n"); 19642 message.append("Errors at"); 19643 } 19644 message.append(" ["); 19645 message.append(Integer.toString(i)); 19646 message.append(", "); 19647 message.append(Integer.toString(j)); 19648 message.append("]"); 19649 } 19650 } 19651 } 19652 assertFalse("Incorrect output for checkConvertShort3Long3" + 19653 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19654 } 19655 19656 private void checkConvertShort4Long4() { 19657 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7c8927d906ccl, true, 15); 19658 try { 19659 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19660 script.forEach_testConvertLong4Short4Long4(inV, out); 19661 verifyResultsConvertShort4Long4(inV, out, false); 19662 out.destroy(); 19663 } catch (Exception e) { 19664 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString()); 19665 } 19666 try { 19667 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19668 scriptRelaxed.forEach_testConvertLong4Short4Long4(inV, out); 19669 verifyResultsConvertShort4Long4(inV, out, true); 19670 out.destroy(); 19671 } catch (Exception e) { 19672 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString()); 19673 } 19674 inV.destroy(); 19675 } 19676 19677 private void verifyResultsConvertShort4Long4(Allocation inV, Allocation out, boolean relaxed) { 19678 short[] arrayInV = new short[INPUTSIZE * 4]; 19679 Arrays.fill(arrayInV, (short) 42); 19680 inV.copyTo(arrayInV); 19681 long[] arrayOut = new long[INPUTSIZE * 4]; 19682 Arrays.fill(arrayOut, (long) 42); 19683 out.copyTo(arrayOut); 19684 StringBuilder message = new StringBuilder(); 19685 boolean errorFound = false; 19686 for (int i = 0; i < INPUTSIZE; i++) { 19687 for (int j = 0; j < 4 ; j++) { 19688 // Extract the inputs. 19689 ArgumentsShortLong args = new ArgumentsShortLong(); 19690 args.inV = arrayInV[i * 4 + j]; 19691 // Figure out what the outputs should have been. 19692 CoreMathVerifier.computeConvert(args); 19693 // Validate the outputs. 19694 boolean valid = true; 19695 if (args.out != arrayOut[i * 4 + j]) { 19696 valid = false; 19697 } 19698 if (!valid) { 19699 if (!errorFound) { 19700 errorFound = true; 19701 message.append("Input inV: "); 19702 appendVariableToMessage(message, args.inV); 19703 message.append("\n"); 19704 message.append("Expected output out: "); 19705 appendVariableToMessage(message, args.out); 19706 message.append("\n"); 19707 message.append("Actual output out: "); 19708 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19709 if (args.out != arrayOut[i * 4 + j]) { 19710 message.append(" FAIL"); 19711 } 19712 message.append("\n"); 19713 message.append("Errors at"); 19714 } 19715 message.append(" ["); 19716 message.append(Integer.toString(i)); 19717 message.append(", "); 19718 message.append(Integer.toString(j)); 19719 message.append("]"); 19720 } 19721 } 19722 } 19723 assertFalse("Incorrect output for checkConvertShort4Long4" + 19724 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19725 } 19726 19727 public class ArgumentsUshortLong { 19728 public short inV; 19729 public long out; 19730 } 19731 19732 private void checkConvertUshort2Long2() { 19733 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79874e05a1968fl, false, 16); 19734 try { 19735 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19736 script.forEach_testConvertLong2Ushort2Long2(inV, out); 19737 verifyResultsConvertUshort2Long2(inV, out, false); 19738 out.destroy(); 19739 } catch (Exception e) { 19740 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString()); 19741 } 19742 try { 19743 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19744 scriptRelaxed.forEach_testConvertLong2Ushort2Long2(inV, out); 19745 verifyResultsConvertUshort2Long2(inV, out, true); 19746 out.destroy(); 19747 } catch (Exception e) { 19748 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString()); 19749 } 19750 inV.destroy(); 19751 } 19752 19753 private void verifyResultsConvertUshort2Long2(Allocation inV, Allocation out, boolean relaxed) { 19754 short[] arrayInV = new short[INPUTSIZE * 2]; 19755 Arrays.fill(arrayInV, (short) 42); 19756 inV.copyTo(arrayInV); 19757 long[] arrayOut = new long[INPUTSIZE * 2]; 19758 Arrays.fill(arrayOut, (long) 42); 19759 out.copyTo(arrayOut); 19760 StringBuilder message = new StringBuilder(); 19761 boolean errorFound = false; 19762 for (int i = 0; i < INPUTSIZE; i++) { 19763 for (int j = 0; j < 2 ; j++) { 19764 // Extract the inputs. 19765 ArgumentsUshortLong args = new ArgumentsUshortLong(); 19766 args.inV = arrayInV[i * 2 + j]; 19767 // Figure out what the outputs should have been. 19768 CoreMathVerifier.computeConvert(args); 19769 // Validate the outputs. 19770 boolean valid = true; 19771 if (args.out != arrayOut[i * 2 + j]) { 19772 valid = false; 19773 } 19774 if (!valid) { 19775 if (!errorFound) { 19776 errorFound = true; 19777 message.append("Input inV: "); 19778 appendVariableToMessage(message, args.inV); 19779 message.append("\n"); 19780 message.append("Expected output out: "); 19781 appendVariableToMessage(message, args.out); 19782 message.append("\n"); 19783 message.append("Actual output out: "); 19784 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19785 if (args.out != arrayOut[i * 2 + j]) { 19786 message.append(" FAIL"); 19787 } 19788 message.append("\n"); 19789 message.append("Errors at"); 19790 } 19791 message.append(" ["); 19792 message.append(Integer.toString(i)); 19793 message.append(", "); 19794 message.append(Integer.toString(j)); 19795 message.append("]"); 19796 } 19797 } 19798 } 19799 assertFalse("Incorrect output for checkConvertUshort2Long2" + 19800 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19801 } 19802 19803 private void checkConvertUshort3Long3() { 19804 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d7991ef64a95b83l, false, 16); 19805 try { 19806 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19807 script.forEach_testConvertLong3Ushort3Long3(inV, out); 19808 verifyResultsConvertUshort3Long3(inV, out, false); 19809 out.destroy(); 19810 } catch (Exception e) { 19811 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString()); 19812 } 19813 try { 19814 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19815 scriptRelaxed.forEach_testConvertLong3Ushort3Long3(inV, out); 19816 verifyResultsConvertUshort3Long3(inV, out, true); 19817 out.destroy(); 19818 } catch (Exception e) { 19819 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString()); 19820 } 19821 inV.destroy(); 19822 } 19823 19824 private void verifyResultsConvertUshort3Long3(Allocation inV, Allocation out, boolean relaxed) { 19825 short[] arrayInV = new short[INPUTSIZE * 4]; 19826 Arrays.fill(arrayInV, (short) 42); 19827 inV.copyTo(arrayInV); 19828 long[] arrayOut = new long[INPUTSIZE * 4]; 19829 Arrays.fill(arrayOut, (long) 42); 19830 out.copyTo(arrayOut); 19831 StringBuilder message = new StringBuilder(); 19832 boolean errorFound = false; 19833 for (int i = 0; i < INPUTSIZE; i++) { 19834 for (int j = 0; j < 3 ; j++) { 19835 // Extract the inputs. 19836 ArgumentsUshortLong args = new ArgumentsUshortLong(); 19837 args.inV = arrayInV[i * 4 + j]; 19838 // Figure out what the outputs should have been. 19839 CoreMathVerifier.computeConvert(args); 19840 // Validate the outputs. 19841 boolean valid = true; 19842 if (args.out != arrayOut[i * 4 + j]) { 19843 valid = false; 19844 } 19845 if (!valid) { 19846 if (!errorFound) { 19847 errorFound = true; 19848 message.append("Input inV: "); 19849 appendVariableToMessage(message, args.inV); 19850 message.append("\n"); 19851 message.append("Expected output out: "); 19852 appendVariableToMessage(message, args.out); 19853 message.append("\n"); 19854 message.append("Actual output out: "); 19855 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19856 if (args.out != arrayOut[i * 4 + j]) { 19857 message.append(" FAIL"); 19858 } 19859 message.append("\n"); 19860 message.append("Errors at"); 19861 } 19862 message.append(" ["); 19863 message.append(Integer.toString(i)); 19864 message.append(", "); 19865 message.append(Integer.toString(j)); 19866 message.append("]"); 19867 } 19868 } 19869 } 19870 assertFalse("Incorrect output for checkConvertUshort3Long3" + 19871 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19872 } 19873 19874 private void checkConvertUshort4Long4() { 19875 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799c90c3b12077l, false, 16); 19876 try { 19877 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19878 script.forEach_testConvertLong4Ushort4Long4(inV, out); 19879 verifyResultsConvertUshort4Long4(inV, out, false); 19880 out.destroy(); 19881 } catch (Exception e) { 19882 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString()); 19883 } 19884 try { 19885 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19886 scriptRelaxed.forEach_testConvertLong4Ushort4Long4(inV, out); 19887 verifyResultsConvertUshort4Long4(inV, out, true); 19888 out.destroy(); 19889 } catch (Exception e) { 19890 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString()); 19891 } 19892 inV.destroy(); 19893 } 19894 19895 private void verifyResultsConvertUshort4Long4(Allocation inV, Allocation out, boolean relaxed) { 19896 short[] arrayInV = new short[INPUTSIZE * 4]; 19897 Arrays.fill(arrayInV, (short) 42); 19898 inV.copyTo(arrayInV); 19899 long[] arrayOut = new long[INPUTSIZE * 4]; 19900 Arrays.fill(arrayOut, (long) 42); 19901 out.copyTo(arrayOut); 19902 StringBuilder message = new StringBuilder(); 19903 boolean errorFound = false; 19904 for (int i = 0; i < INPUTSIZE; i++) { 19905 for (int j = 0; j < 4 ; j++) { 19906 // Extract the inputs. 19907 ArgumentsUshortLong args = new ArgumentsUshortLong(); 19908 args.inV = arrayInV[i * 4 + j]; 19909 // Figure out what the outputs should have been. 19910 CoreMathVerifier.computeConvert(args); 19911 // Validate the outputs. 19912 boolean valid = true; 19913 if (args.out != arrayOut[i * 4 + j]) { 19914 valid = false; 19915 } 19916 if (!valid) { 19917 if (!errorFound) { 19918 errorFound = true; 19919 message.append("Input inV: "); 19920 appendVariableToMessage(message, args.inV); 19921 message.append("\n"); 19922 message.append("Expected output out: "); 19923 appendVariableToMessage(message, args.out); 19924 message.append("\n"); 19925 message.append("Actual output out: "); 19926 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19927 if (args.out != arrayOut[i * 4 + j]) { 19928 message.append(" FAIL"); 19929 } 19930 message.append("\n"); 19931 message.append("Errors at"); 19932 } 19933 message.append(" ["); 19934 message.append(Integer.toString(i)); 19935 message.append(", "); 19936 message.append(Integer.toString(j)); 19937 message.append("]"); 19938 } 19939 } 19940 } 19941 assertFalse("Incorrect output for checkConvertUshort4Long4" + 19942 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19943 } 19944 19945 public class ArgumentsIntLong { 19946 public int inV; 19947 public long out; 19948 } 19949 19950 private void checkConvertInt2Long2() { 19951 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f538b8a45cb5dl, true, 31); 19952 try { 19953 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19954 script.forEach_testConvertLong2Int2Long2(inV, out); 19955 verifyResultsConvertInt2Long2(inV, out, false); 19956 out.destroy(); 19957 } catch (Exception e) { 19958 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString()); 19959 } 19960 try { 19961 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19962 scriptRelaxed.forEach_testConvertLong2Int2Long2(inV, out); 19963 verifyResultsConvertInt2Long2(inV, out, true); 19964 out.destroy(); 19965 } catch (Exception e) { 19966 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString()); 19967 } 19968 inV.destroy(); 19969 } 19970 19971 private void verifyResultsConvertInt2Long2(Allocation inV, Allocation out, boolean relaxed) { 19972 int[] arrayInV = new int[INPUTSIZE * 2]; 19973 Arrays.fill(arrayInV, (int) 42); 19974 inV.copyTo(arrayInV); 19975 long[] arrayOut = new long[INPUTSIZE * 2]; 19976 Arrays.fill(arrayOut, (long) 42); 19977 out.copyTo(arrayOut); 19978 StringBuilder message = new StringBuilder(); 19979 boolean errorFound = false; 19980 for (int i = 0; i < INPUTSIZE; i++) { 19981 for (int j = 0; j < 2 ; j++) { 19982 // Extract the inputs. 19983 ArgumentsIntLong args = new ArgumentsIntLong(); 19984 args.inV = arrayInV[i * 2 + j]; 19985 // Figure out what the outputs should have been. 19986 CoreMathVerifier.computeConvert(args); 19987 // Validate the outputs. 19988 boolean valid = true; 19989 if (args.out != arrayOut[i * 2 + j]) { 19990 valid = false; 19991 } 19992 if (!valid) { 19993 if (!errorFound) { 19994 errorFound = true; 19995 message.append("Input inV: "); 19996 appendVariableToMessage(message, args.inV); 19997 message.append("\n"); 19998 message.append("Expected output out: "); 19999 appendVariableToMessage(message, args.out); 20000 message.append("\n"); 20001 message.append("Actual output out: "); 20002 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20003 if (args.out != arrayOut[i * 2 + j]) { 20004 message.append(" FAIL"); 20005 } 20006 message.append("\n"); 20007 message.append("Errors at"); 20008 } 20009 message.append(" ["); 20010 message.append(Integer.toString(i)); 20011 message.append(", "); 20012 message.append(Integer.toString(j)); 20013 message.append("]"); 20014 } 20015 } 20016 } 20017 assertFalse("Incorrect output for checkConvertInt2Long2" + 20018 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20019 } 20020 20021 private void checkConvertInt3Long3() { 20022 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5e2ce94d9051l, true, 31); 20023 try { 20024 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 20025 script.forEach_testConvertLong3Int3Long3(inV, out); 20026 verifyResultsConvertInt3Long3(inV, out, false); 20027 out.destroy(); 20028 } catch (Exception e) { 20029 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString()); 20030 } 20031 try { 20032 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 20033 scriptRelaxed.forEach_testConvertLong3Int3Long3(inV, out); 20034 verifyResultsConvertInt3Long3(inV, out, true); 20035 out.destroy(); 20036 } catch (Exception e) { 20037 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString()); 20038 } 20039 inV.destroy(); 20040 } 20041 20042 private void verifyResultsConvertInt3Long3(Allocation inV, Allocation out, boolean relaxed) { 20043 int[] arrayInV = new int[INPUTSIZE * 4]; 20044 Arrays.fill(arrayInV, (int) 42); 20045 inV.copyTo(arrayInV); 20046 long[] arrayOut = new long[INPUTSIZE * 4]; 20047 Arrays.fill(arrayOut, (long) 42); 20048 out.copyTo(arrayOut); 20049 StringBuilder message = new StringBuilder(); 20050 boolean errorFound = false; 20051 for (int i = 0; i < INPUTSIZE; i++) { 20052 for (int j = 0; j < 3 ; j++) { 20053 // Extract the inputs. 20054 ArgumentsIntLong args = new ArgumentsIntLong(); 20055 args.inV = arrayInV[i * 4 + j]; 20056 // Figure out what the outputs should have been. 20057 CoreMathVerifier.computeConvert(args); 20058 // Validate the outputs. 20059 boolean valid = true; 20060 if (args.out != arrayOut[i * 4 + j]) { 20061 valid = false; 20062 } 20063 if (!valid) { 20064 if (!errorFound) { 20065 errorFound = true; 20066 message.append("Input inV: "); 20067 appendVariableToMessage(message, args.inV); 20068 message.append("\n"); 20069 message.append("Expected output out: "); 20070 appendVariableToMessage(message, args.out); 20071 message.append("\n"); 20072 message.append("Actual output out: "); 20073 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20074 if (args.out != arrayOut[i * 4 + j]) { 20075 message.append(" FAIL"); 20076 } 20077 message.append("\n"); 20078 message.append("Errors at"); 20079 } 20080 message.append(" ["); 20081 message.append(Integer.toString(i)); 20082 message.append(", "); 20083 message.append(Integer.toString(j)); 20084 message.append("]"); 20085 } 20086 } 20087 } 20088 assertFalse("Incorrect output for checkConvertInt3Long3" + 20089 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20090 } 20091 20092 private void checkConvertInt4Long4() { 20093 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f68ce48555545l, true, 31); 20094 try { 20095 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 20096 script.forEach_testConvertLong4Int4Long4(inV, out); 20097 verifyResultsConvertInt4Long4(inV, out, false); 20098 out.destroy(); 20099 } catch (Exception e) { 20100 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString()); 20101 } 20102 try { 20103 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 20104 scriptRelaxed.forEach_testConvertLong4Int4Long4(inV, out); 20105 verifyResultsConvertInt4Long4(inV, out, true); 20106 out.destroy(); 20107 } catch (Exception e) { 20108 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString()); 20109 } 20110 inV.destroy(); 20111 } 20112 20113 private void verifyResultsConvertInt4Long4(Allocation inV, Allocation out, boolean relaxed) { 20114 int[] arrayInV = new int[INPUTSIZE * 4]; 20115 Arrays.fill(arrayInV, (int) 42); 20116 inV.copyTo(arrayInV); 20117 long[] arrayOut = new long[INPUTSIZE * 4]; 20118 Arrays.fill(arrayOut, (long) 42); 20119 out.copyTo(arrayOut); 20120 StringBuilder message = new StringBuilder(); 20121 boolean errorFound = false; 20122 for (int i = 0; i < INPUTSIZE; i++) { 20123 for (int j = 0; j < 4 ; j++) { 20124 // Extract the inputs. 20125 ArgumentsIntLong args = new ArgumentsIntLong(); 20126 args.inV = arrayInV[i * 4 + j]; 20127 // Figure out what the outputs should have been. 20128 CoreMathVerifier.computeConvert(args); 20129 // Validate the outputs. 20130 boolean valid = true; 20131 if (args.out != arrayOut[i * 4 + j]) { 20132 valid = false; 20133 } 20134 if (!valid) { 20135 if (!errorFound) { 20136 errorFound = true; 20137 message.append("Input inV: "); 20138 appendVariableToMessage(message, args.inV); 20139 message.append("\n"); 20140 message.append("Expected output out: "); 20141 appendVariableToMessage(message, args.out); 20142 message.append("\n"); 20143 message.append("Actual output out: "); 20144 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20145 if (args.out != arrayOut[i * 4 + j]) { 20146 message.append(" FAIL"); 20147 } 20148 message.append("\n"); 20149 message.append("Errors at"); 20150 } 20151 message.append(" ["); 20152 message.append(Integer.toString(i)); 20153 message.append(", "); 20154 message.append(Integer.toString(j)); 20155 message.append("]"); 20156 } 20157 } 20158 } 20159 assertFalse("Incorrect output for checkConvertInt4Long4" + 20160 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20161 } 20162 20163 public class ArgumentsUintLong { 20164 public int inV; 20165 public long out; 20166 } 20167 20168 private void checkConvertUint2Long2() { 20169 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0a7587b9ef60l, false, 32); 20170 try { 20171 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 20172 script.forEach_testConvertLong2Uint2Long2(inV, out); 20173 verifyResultsConvertUint2Long2(inV, out, false); 20174 out.destroy(); 20175 } catch (Exception e) { 20176 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString()); 20177 } 20178 try { 20179 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 20180 scriptRelaxed.forEach_testConvertLong2Uint2Long2(inV, out); 20181 verifyResultsConvertUint2Long2(inV, out, true); 20182 out.destroy(); 20183 } catch (Exception e) { 20184 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString()); 20185 } 20186 inV.destroy(); 20187 } 20188 20189 private void verifyResultsConvertUint2Long2(Allocation inV, Allocation out, boolean relaxed) { 20190 int[] arrayInV = new int[INPUTSIZE * 2]; 20191 Arrays.fill(arrayInV, (int) 42); 20192 inV.copyTo(arrayInV); 20193 long[] arrayOut = new long[INPUTSIZE * 2]; 20194 Arrays.fill(arrayOut, (long) 42); 20195 out.copyTo(arrayOut); 20196 StringBuilder message = new StringBuilder(); 20197 boolean errorFound = false; 20198 for (int i = 0; i < INPUTSIZE; i++) { 20199 for (int j = 0; j < 2 ; j++) { 20200 // Extract the inputs. 20201 ArgumentsUintLong args = new ArgumentsUintLong(); 20202 args.inV = arrayInV[i * 2 + j]; 20203 // Figure out what the outputs should have been. 20204 CoreMathVerifier.computeConvert(args); 20205 // Validate the outputs. 20206 boolean valid = true; 20207 if (args.out != arrayOut[i * 2 + j]) { 20208 valid = false; 20209 } 20210 if (!valid) { 20211 if (!errorFound) { 20212 errorFound = true; 20213 message.append("Input inV: "); 20214 appendVariableToMessage(message, args.inV); 20215 message.append("\n"); 20216 message.append("Expected output out: "); 20217 appendVariableToMessage(message, args.out); 20218 message.append("\n"); 20219 message.append("Actual output out: "); 20220 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20221 if (args.out != arrayOut[i * 2 + j]) { 20222 message.append(" FAIL"); 20223 } 20224 message.append("\n"); 20225 message.append("Errors at"); 20226 } 20227 message.append(" ["); 20228 message.append(Integer.toString(i)); 20229 message.append(", "); 20230 message.append(Integer.toString(j)); 20231 message.append("]"); 20232 } 20233 } 20234 } 20235 assertFalse("Incorrect output for checkConvertUint2Long2" + 20236 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20237 } 20238 20239 private void checkConvertUint3Long3() { 20240 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d1516e6c1b454l, false, 32); 20241 try { 20242 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 20243 script.forEach_testConvertLong3Uint3Long3(inV, out); 20244 verifyResultsConvertUint3Long3(inV, out, false); 20245 out.destroy(); 20246 } catch (Exception e) { 20247 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString()); 20248 } 20249 try { 20250 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 20251 scriptRelaxed.forEach_testConvertLong3Uint3Long3(inV, out); 20252 verifyResultsConvertUint3Long3(inV, out, true); 20253 out.destroy(); 20254 } catch (Exception e) { 20255 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString()); 20256 } 20257 inV.destroy(); 20258 } 20259 20260 private void verifyResultsConvertUint3Long3(Allocation inV, Allocation out, boolean relaxed) { 20261 int[] arrayInV = new int[INPUTSIZE * 4]; 20262 Arrays.fill(arrayInV, (int) 42); 20263 inV.copyTo(arrayInV); 20264 long[] arrayOut = new long[INPUTSIZE * 4]; 20265 Arrays.fill(arrayOut, (long) 42); 20266 out.copyTo(arrayOut); 20267 StringBuilder message = new StringBuilder(); 20268 boolean errorFound = false; 20269 for (int i = 0; i < INPUTSIZE; i++) { 20270 for (int j = 0; j < 3 ; j++) { 20271 // Extract the inputs. 20272 ArgumentsUintLong args = new ArgumentsUintLong(); 20273 args.inV = arrayInV[i * 4 + j]; 20274 // Figure out what the outputs should have been. 20275 CoreMathVerifier.computeConvert(args); 20276 // Validate the outputs. 20277 boolean valid = true; 20278 if (args.out != arrayOut[i * 4 + j]) { 20279 valid = false; 20280 } 20281 if (!valid) { 20282 if (!errorFound) { 20283 errorFound = true; 20284 message.append("Input inV: "); 20285 appendVariableToMessage(message, args.inV); 20286 message.append("\n"); 20287 message.append("Expected output out: "); 20288 appendVariableToMessage(message, args.out); 20289 message.append("\n"); 20290 message.append("Actual output out: "); 20291 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20292 if (args.out != arrayOut[i * 4 + j]) { 20293 message.append(" FAIL"); 20294 } 20295 message.append("\n"); 20296 message.append("Errors at"); 20297 } 20298 message.append(" ["); 20299 message.append(Integer.toString(i)); 20300 message.append(", "); 20301 message.append(Integer.toString(j)); 20302 message.append("]"); 20303 } 20304 } 20305 } 20306 assertFalse("Incorrect output for checkConvertUint3Long3" + 20307 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20308 } 20309 20310 private void checkConvertUint4Long4() { 20311 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1fb845c97948l, false, 32); 20312 try { 20313 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 20314 script.forEach_testConvertLong4Uint4Long4(inV, out); 20315 verifyResultsConvertUint4Long4(inV, out, false); 20316 out.destroy(); 20317 } catch (Exception e) { 20318 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString()); 20319 } 20320 try { 20321 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 20322 scriptRelaxed.forEach_testConvertLong4Uint4Long4(inV, out); 20323 verifyResultsConvertUint4Long4(inV, out, true); 20324 out.destroy(); 20325 } catch (Exception e) { 20326 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString()); 20327 } 20328 inV.destroy(); 20329 } 20330 20331 private void verifyResultsConvertUint4Long4(Allocation inV, Allocation out, boolean relaxed) { 20332 int[] arrayInV = new int[INPUTSIZE * 4]; 20333 Arrays.fill(arrayInV, (int) 42); 20334 inV.copyTo(arrayInV); 20335 long[] arrayOut = new long[INPUTSIZE * 4]; 20336 Arrays.fill(arrayOut, (long) 42); 20337 out.copyTo(arrayOut); 20338 StringBuilder message = new StringBuilder(); 20339 boolean errorFound = false; 20340 for (int i = 0; i < INPUTSIZE; i++) { 20341 for (int j = 0; j < 4 ; j++) { 20342 // Extract the inputs. 20343 ArgumentsUintLong args = new ArgumentsUintLong(); 20344 args.inV = arrayInV[i * 4 + j]; 20345 // Figure out what the outputs should have been. 20346 CoreMathVerifier.computeConvert(args); 20347 // Validate the outputs. 20348 boolean valid = true; 20349 if (args.out != arrayOut[i * 4 + j]) { 20350 valid = false; 20351 } 20352 if (!valid) { 20353 if (!errorFound) { 20354 errorFound = true; 20355 message.append("Input inV: "); 20356 appendVariableToMessage(message, args.inV); 20357 message.append("\n"); 20358 message.append("Expected output out: "); 20359 appendVariableToMessage(message, args.out); 20360 message.append("\n"); 20361 message.append("Actual output out: "); 20362 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20363 if (args.out != arrayOut[i * 4 + j]) { 20364 message.append(" FAIL"); 20365 } 20366 message.append("\n"); 20367 message.append("Errors at"); 20368 } 20369 message.append(" ["); 20370 message.append(Integer.toString(i)); 20371 message.append(", "); 20372 message.append(Integer.toString(j)); 20373 message.append("]"); 20374 } 20375 } 20376 } 20377 assertFalse("Incorrect output for checkConvertUint4Long4" + 20378 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20379 } 20380 20381 public class ArgumentsFloatUlong { 20382 public float inV; 20383 public long out; 20384 } 20385 20386 private void checkConvertFloat2Ulong2() { 20387 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb52b5394ec4cff7l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); 20388 try { 20389 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20390 script.forEach_testConvertUlong2Float2Ulong2(inV, out); 20391 verifyResultsConvertFloat2Ulong2(inV, out, false); 20392 out.destroy(); 20393 } catch (Exception e) { 20394 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString()); 20395 } 20396 try { 20397 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20398 scriptRelaxed.forEach_testConvertUlong2Float2Ulong2(inV, out); 20399 verifyResultsConvertFloat2Ulong2(inV, out, true); 20400 out.destroy(); 20401 } catch (Exception e) { 20402 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString()); 20403 } 20404 inV.destroy(); 20405 } 20406 20407 private void verifyResultsConvertFloat2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20408 float[] arrayInV = new float[INPUTSIZE * 2]; 20409 Arrays.fill(arrayInV, (float) 42); 20410 inV.copyTo(arrayInV); 20411 long[] arrayOut = new long[INPUTSIZE * 2]; 20412 Arrays.fill(arrayOut, (long) 42); 20413 out.copyTo(arrayOut); 20414 StringBuilder message = new StringBuilder(); 20415 boolean errorFound = false; 20416 for (int i = 0; i < INPUTSIZE; i++) { 20417 for (int j = 0; j < 2 ; j++) { 20418 // Extract the inputs. 20419 ArgumentsFloatUlong args = new ArgumentsFloatUlong(); 20420 args.inV = arrayInV[i * 2 + j]; 20421 // Figure out what the outputs should have been. 20422 CoreMathVerifier.computeConvert(args); 20423 // Validate the outputs. 20424 boolean valid = true; 20425 if (args.out != arrayOut[i * 2 + j]) { 20426 valid = false; 20427 } 20428 if (!valid) { 20429 if (!errorFound) { 20430 errorFound = true; 20431 message.append("Input inV: "); 20432 appendVariableToMessage(message, args.inV); 20433 message.append("\n"); 20434 message.append("Expected output out: "); 20435 appendVariableToMessage(message, args.out); 20436 message.append("\n"); 20437 message.append("Actual output out: "); 20438 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20439 if (args.out != arrayOut[i * 2 + j]) { 20440 message.append(" FAIL"); 20441 } 20442 message.append("\n"); 20443 message.append("Errors at"); 20444 } 20445 message.append(" ["); 20446 message.append(Integer.toString(i)); 20447 message.append(", "); 20448 message.append(Integer.toString(j)); 20449 message.append("]"); 20450 } 20451 } 20452 } 20453 assertFalse("Incorrect output for checkConvertFloat2Ulong2" + 20454 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20455 } 20456 20457 private void checkConvertFloat3Ulong3() { 20458 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb547e5444dff0d5l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); 20459 try { 20460 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20461 script.forEach_testConvertUlong3Float3Ulong3(inV, out); 20462 verifyResultsConvertFloat3Ulong3(inV, out, false); 20463 out.destroy(); 20464 } catch (Exception e) { 20465 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString()); 20466 } 20467 try { 20468 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20469 scriptRelaxed.forEach_testConvertUlong3Float3Ulong3(inV, out); 20470 verifyResultsConvertFloat3Ulong3(inV, out, true); 20471 out.destroy(); 20472 } catch (Exception e) { 20473 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString()); 20474 } 20475 inV.destroy(); 20476 } 20477 20478 private void verifyResultsConvertFloat3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20479 float[] arrayInV = new float[INPUTSIZE * 4]; 20480 Arrays.fill(arrayInV, (float) 42); 20481 inV.copyTo(arrayInV); 20482 long[] arrayOut = new long[INPUTSIZE * 4]; 20483 Arrays.fill(arrayOut, (long) 42); 20484 out.copyTo(arrayOut); 20485 StringBuilder message = new StringBuilder(); 20486 boolean errorFound = false; 20487 for (int i = 0; i < INPUTSIZE; i++) { 20488 for (int j = 0; j < 3 ; j++) { 20489 // Extract the inputs. 20490 ArgumentsFloatUlong args = new ArgumentsFloatUlong(); 20491 args.inV = arrayInV[i * 4 + j]; 20492 // Figure out what the outputs should have been. 20493 CoreMathVerifier.computeConvert(args); 20494 // Validate the outputs. 20495 boolean valid = true; 20496 if (args.out != arrayOut[i * 4 + j]) { 20497 valid = false; 20498 } 20499 if (!valid) { 20500 if (!errorFound) { 20501 errorFound = true; 20502 message.append("Input inV: "); 20503 appendVariableToMessage(message, args.inV); 20504 message.append("\n"); 20505 message.append("Expected output out: "); 20506 appendVariableToMessage(message, args.out); 20507 message.append("\n"); 20508 message.append("Actual output out: "); 20509 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20510 if (args.out != arrayOut[i * 4 + j]) { 20511 message.append(" FAIL"); 20512 } 20513 message.append("\n"); 20514 message.append("Errors at"); 20515 } 20516 message.append(" ["); 20517 message.append(Integer.toString(i)); 20518 message.append(", "); 20519 message.append(Integer.toString(j)); 20520 message.append("]"); 20521 } 20522 } 20523 } 20524 assertFalse("Incorrect output for checkConvertFloat3Ulong3" + 20525 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20526 } 20527 20528 private void checkConvertFloat4Ulong4() { 20529 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56476f3afb11b3l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); 20530 try { 20531 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20532 script.forEach_testConvertUlong4Float4Ulong4(inV, out); 20533 verifyResultsConvertFloat4Ulong4(inV, out, false); 20534 out.destroy(); 20535 } catch (Exception e) { 20536 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString()); 20537 } 20538 try { 20539 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20540 scriptRelaxed.forEach_testConvertUlong4Float4Ulong4(inV, out); 20541 verifyResultsConvertFloat4Ulong4(inV, out, true); 20542 out.destroy(); 20543 } catch (Exception e) { 20544 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString()); 20545 } 20546 inV.destroy(); 20547 } 20548 20549 private void verifyResultsConvertFloat4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20550 float[] arrayInV = new float[INPUTSIZE * 4]; 20551 Arrays.fill(arrayInV, (float) 42); 20552 inV.copyTo(arrayInV); 20553 long[] arrayOut = new long[INPUTSIZE * 4]; 20554 Arrays.fill(arrayOut, (long) 42); 20555 out.copyTo(arrayOut); 20556 StringBuilder message = new StringBuilder(); 20557 boolean errorFound = false; 20558 for (int i = 0; i < INPUTSIZE; i++) { 20559 for (int j = 0; j < 4 ; j++) { 20560 // Extract the inputs. 20561 ArgumentsFloatUlong args = new ArgumentsFloatUlong(); 20562 args.inV = arrayInV[i * 4 + j]; 20563 // Figure out what the outputs should have been. 20564 CoreMathVerifier.computeConvert(args); 20565 // Validate the outputs. 20566 boolean valid = true; 20567 if (args.out != arrayOut[i * 4 + j]) { 20568 valid = false; 20569 } 20570 if (!valid) { 20571 if (!errorFound) { 20572 errorFound = true; 20573 message.append("Input inV: "); 20574 appendVariableToMessage(message, args.inV); 20575 message.append("\n"); 20576 message.append("Expected output out: "); 20577 appendVariableToMessage(message, args.out); 20578 message.append("\n"); 20579 message.append("Actual output out: "); 20580 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20581 if (args.out != arrayOut[i * 4 + j]) { 20582 message.append(" FAIL"); 20583 } 20584 message.append("\n"); 20585 message.append("Errors at"); 20586 } 20587 message.append(" ["); 20588 message.append(Integer.toString(i)); 20589 message.append(", "); 20590 message.append(Integer.toString(j)); 20591 message.append("]"); 20592 } 20593 } 20594 } 20595 assertFalse("Incorrect output for checkConvertFloat4Ulong4" + 20596 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20597 } 20598 20599 public class ArgumentsCharUlong { 20600 public byte inV; 20601 public long out; 20602 } 20603 20604 private void checkConvertChar2Ulong2() { 20605 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x5862818b1fedf7b7l, false, 7); 20606 try { 20607 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20608 script.forEach_testConvertUlong2Char2Ulong2(inV, out); 20609 verifyResultsConvertChar2Ulong2(inV, out, false); 20610 out.destroy(); 20611 } catch (Exception e) { 20612 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString()); 20613 } 20614 try { 20615 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20616 scriptRelaxed.forEach_testConvertUlong2Char2Ulong2(inV, out); 20617 verifyResultsConvertChar2Ulong2(inV, out, true); 20618 out.destroy(); 20619 } catch (Exception e) { 20620 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString()); 20621 } 20622 inV.destroy(); 20623 } 20624 20625 private void verifyResultsConvertChar2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20626 byte[] arrayInV = new byte[INPUTSIZE * 2]; 20627 Arrays.fill(arrayInV, (byte) 42); 20628 inV.copyTo(arrayInV); 20629 long[] arrayOut = new long[INPUTSIZE * 2]; 20630 Arrays.fill(arrayOut, (long) 42); 20631 out.copyTo(arrayOut); 20632 StringBuilder message = new StringBuilder(); 20633 boolean errorFound = false; 20634 for (int i = 0; i < INPUTSIZE; i++) { 20635 for (int j = 0; j < 2 ; j++) { 20636 // Extract the inputs. 20637 ArgumentsCharUlong args = new ArgumentsCharUlong(); 20638 args.inV = arrayInV[i * 2 + j]; 20639 // Figure out what the outputs should have been. 20640 CoreMathVerifier.computeConvert(args); 20641 // Validate the outputs. 20642 boolean valid = true; 20643 if (args.out != arrayOut[i * 2 + j]) { 20644 valid = false; 20645 } 20646 if (!valid) { 20647 if (!errorFound) { 20648 errorFound = true; 20649 message.append("Input inV: "); 20650 appendVariableToMessage(message, args.inV); 20651 message.append("\n"); 20652 message.append("Expected output out: "); 20653 appendVariableToMessage(message, args.out); 20654 message.append("\n"); 20655 message.append("Actual output out: "); 20656 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20657 if (args.out != arrayOut[i * 2 + j]) { 20658 message.append(" FAIL"); 20659 } 20660 message.append("\n"); 20661 message.append("Errors at"); 20662 } 20663 message.append(" ["); 20664 message.append(Integer.toString(i)); 20665 message.append(", "); 20666 message.append(Integer.toString(j)); 20667 message.append("]"); 20668 } 20669 } 20670 } 20671 assertFalse("Incorrect output for checkConvertChar2Ulong2" + 20672 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20673 } 20674 20675 private void checkConvertChar3Ulong3() { 20676 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x58644aa616091895l, false, 7); 20677 try { 20678 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20679 script.forEach_testConvertUlong3Char3Ulong3(inV, out); 20680 verifyResultsConvertChar3Ulong3(inV, out, false); 20681 out.destroy(); 20682 } catch (Exception e) { 20683 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString()); 20684 } 20685 try { 20686 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20687 scriptRelaxed.forEach_testConvertUlong3Char3Ulong3(inV, out); 20688 verifyResultsConvertChar3Ulong3(inV, out, true); 20689 out.destroy(); 20690 } catch (Exception e) { 20691 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString()); 20692 } 20693 inV.destroy(); 20694 } 20695 20696 private void verifyResultsConvertChar3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20697 byte[] arrayInV = new byte[INPUTSIZE * 4]; 20698 Arrays.fill(arrayInV, (byte) 42); 20699 inV.copyTo(arrayInV); 20700 long[] arrayOut = new long[INPUTSIZE * 4]; 20701 Arrays.fill(arrayOut, (long) 42); 20702 out.copyTo(arrayOut); 20703 StringBuilder message = new StringBuilder(); 20704 boolean errorFound = false; 20705 for (int i = 0; i < INPUTSIZE; i++) { 20706 for (int j = 0; j < 3 ; j++) { 20707 // Extract the inputs. 20708 ArgumentsCharUlong args = new ArgumentsCharUlong(); 20709 args.inV = arrayInV[i * 4 + j]; 20710 // Figure out what the outputs should have been. 20711 CoreMathVerifier.computeConvert(args); 20712 // Validate the outputs. 20713 boolean valid = true; 20714 if (args.out != arrayOut[i * 4 + j]) { 20715 valid = false; 20716 } 20717 if (!valid) { 20718 if (!errorFound) { 20719 errorFound = true; 20720 message.append("Input inV: "); 20721 appendVariableToMessage(message, args.inV); 20722 message.append("\n"); 20723 message.append("Expected output out: "); 20724 appendVariableToMessage(message, args.out); 20725 message.append("\n"); 20726 message.append("Actual output out: "); 20727 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20728 if (args.out != arrayOut[i * 4 + j]) { 20729 message.append(" FAIL"); 20730 } 20731 message.append("\n"); 20732 message.append("Errors at"); 20733 } 20734 message.append(" ["); 20735 message.append(Integer.toString(i)); 20736 message.append(", "); 20737 message.append(Integer.toString(j)); 20738 message.append("]"); 20739 } 20740 } 20741 } 20742 assertFalse("Incorrect output for checkConvertChar3Ulong3" + 20743 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20744 } 20745 20746 private void checkConvertChar4Ulong4() { 20747 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x586613c10c243973l, false, 7); 20748 try { 20749 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20750 script.forEach_testConvertUlong4Char4Ulong4(inV, out); 20751 verifyResultsConvertChar4Ulong4(inV, out, false); 20752 out.destroy(); 20753 } catch (Exception e) { 20754 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString()); 20755 } 20756 try { 20757 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20758 scriptRelaxed.forEach_testConvertUlong4Char4Ulong4(inV, out); 20759 verifyResultsConvertChar4Ulong4(inV, out, true); 20760 out.destroy(); 20761 } catch (Exception e) { 20762 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString()); 20763 } 20764 inV.destroy(); 20765 } 20766 20767 private void verifyResultsConvertChar4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20768 byte[] arrayInV = new byte[INPUTSIZE * 4]; 20769 Arrays.fill(arrayInV, (byte) 42); 20770 inV.copyTo(arrayInV); 20771 long[] arrayOut = new long[INPUTSIZE * 4]; 20772 Arrays.fill(arrayOut, (long) 42); 20773 out.copyTo(arrayOut); 20774 StringBuilder message = new StringBuilder(); 20775 boolean errorFound = false; 20776 for (int i = 0; i < INPUTSIZE; i++) { 20777 for (int j = 0; j < 4 ; j++) { 20778 // Extract the inputs. 20779 ArgumentsCharUlong args = new ArgumentsCharUlong(); 20780 args.inV = arrayInV[i * 4 + j]; 20781 // Figure out what the outputs should have been. 20782 CoreMathVerifier.computeConvert(args); 20783 // Validate the outputs. 20784 boolean valid = true; 20785 if (args.out != arrayOut[i * 4 + j]) { 20786 valid = false; 20787 } 20788 if (!valid) { 20789 if (!errorFound) { 20790 errorFound = true; 20791 message.append("Input inV: "); 20792 appendVariableToMessage(message, args.inV); 20793 message.append("\n"); 20794 message.append("Expected output out: "); 20795 appendVariableToMessage(message, args.out); 20796 message.append("\n"); 20797 message.append("Actual output out: "); 20798 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20799 if (args.out != arrayOut[i * 4 + j]) { 20800 message.append(" FAIL"); 20801 } 20802 message.append("\n"); 20803 message.append("Errors at"); 20804 } 20805 message.append(" ["); 20806 message.append(Integer.toString(i)); 20807 message.append(", "); 20808 message.append(Integer.toString(j)); 20809 message.append("]"); 20810 } 20811 } 20812 } 20813 assertFalse("Incorrect output for checkConvertChar4Ulong4" + 20814 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20815 } 20816 20817 public class ArgumentsUcharUlong { 20818 public byte inV; 20819 public long out; 20820 } 20821 20822 private void checkConvertUchar2Ulong2() { 20823 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d30a192bbc61162l, false, 8); 20824 try { 20825 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20826 script.forEach_testConvertUlong2Uchar2Ulong2(inV, out); 20827 verifyResultsConvertUchar2Ulong2(inV, out, false); 20828 out.destroy(); 20829 } catch (Exception e) { 20830 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString()); 20831 } 20832 try { 20833 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20834 scriptRelaxed.forEach_testConvertUlong2Uchar2Ulong2(inV, out); 20835 verifyResultsConvertUchar2Ulong2(inV, out, true); 20836 out.destroy(); 20837 } catch (Exception e) { 20838 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString()); 20839 } 20840 inV.destroy(); 20841 } 20842 20843 private void verifyResultsConvertUchar2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20844 byte[] arrayInV = new byte[INPUTSIZE * 2]; 20845 Arrays.fill(arrayInV, (byte) 42); 20846 inV.copyTo(arrayInV); 20847 long[] arrayOut = new long[INPUTSIZE * 2]; 20848 Arrays.fill(arrayOut, (long) 42); 20849 out.copyTo(arrayOut); 20850 StringBuilder message = new StringBuilder(); 20851 boolean errorFound = false; 20852 for (int i = 0; i < INPUTSIZE; i++) { 20853 for (int j = 0; j < 2 ; j++) { 20854 // Extract the inputs. 20855 ArgumentsUcharUlong args = new ArgumentsUcharUlong(); 20856 args.inV = arrayInV[i * 2 + j]; 20857 // Figure out what the outputs should have been. 20858 CoreMathVerifier.computeConvert(args); 20859 // Validate the outputs. 20860 boolean valid = true; 20861 if (args.out != arrayOut[i * 2 + j]) { 20862 valid = false; 20863 } 20864 if (!valid) { 20865 if (!errorFound) { 20866 errorFound = true; 20867 message.append("Input inV: "); 20868 appendVariableToMessage(message, args.inV); 20869 message.append("\n"); 20870 message.append("Expected output out: "); 20871 appendVariableToMessage(message, args.out); 20872 message.append("\n"); 20873 message.append("Actual output out: "); 20874 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20875 if (args.out != arrayOut[i * 2 + j]) { 20876 message.append(" FAIL"); 20877 } 20878 message.append("\n"); 20879 message.append("Errors at"); 20880 } 20881 message.append(" ["); 20882 message.append(Integer.toString(i)); 20883 message.append(", "); 20884 message.append(Integer.toString(j)); 20885 message.append("]"); 20886 } 20887 } 20888 } 20889 assertFalse("Incorrect output for checkConvertUchar2Ulong2" + 20890 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20891 } 20892 20893 private void checkConvertUchar3Ulong3() { 20894 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d326aadb1e13240l, false, 8); 20895 try { 20896 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20897 script.forEach_testConvertUlong3Uchar3Ulong3(inV, out); 20898 verifyResultsConvertUchar3Ulong3(inV, out, false); 20899 out.destroy(); 20900 } catch (Exception e) { 20901 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString()); 20902 } 20903 try { 20904 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20905 scriptRelaxed.forEach_testConvertUlong3Uchar3Ulong3(inV, out); 20906 verifyResultsConvertUchar3Ulong3(inV, out, true); 20907 out.destroy(); 20908 } catch (Exception e) { 20909 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString()); 20910 } 20911 inV.destroy(); 20912 } 20913 20914 private void verifyResultsConvertUchar3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20915 byte[] arrayInV = new byte[INPUTSIZE * 4]; 20916 Arrays.fill(arrayInV, (byte) 42); 20917 inV.copyTo(arrayInV); 20918 long[] arrayOut = new long[INPUTSIZE * 4]; 20919 Arrays.fill(arrayOut, (long) 42); 20920 out.copyTo(arrayOut); 20921 StringBuilder message = new StringBuilder(); 20922 boolean errorFound = false; 20923 for (int i = 0; i < INPUTSIZE; i++) { 20924 for (int j = 0; j < 3 ; j++) { 20925 // Extract the inputs. 20926 ArgumentsUcharUlong args = new ArgumentsUcharUlong(); 20927 args.inV = arrayInV[i * 4 + j]; 20928 // Figure out what the outputs should have been. 20929 CoreMathVerifier.computeConvert(args); 20930 // Validate the outputs. 20931 boolean valid = true; 20932 if (args.out != arrayOut[i * 4 + j]) { 20933 valid = false; 20934 } 20935 if (!valid) { 20936 if (!errorFound) { 20937 errorFound = true; 20938 message.append("Input inV: "); 20939 appendVariableToMessage(message, args.inV); 20940 message.append("\n"); 20941 message.append("Expected output out: "); 20942 appendVariableToMessage(message, args.out); 20943 message.append("\n"); 20944 message.append("Actual output out: "); 20945 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20946 if (args.out != arrayOut[i * 4 + j]) { 20947 message.append(" FAIL"); 20948 } 20949 message.append("\n"); 20950 message.append("Errors at"); 20951 } 20952 message.append(" ["); 20953 message.append(Integer.toString(i)); 20954 message.append(", "); 20955 message.append(Integer.toString(j)); 20956 message.append("]"); 20957 } 20958 } 20959 } 20960 assertFalse("Incorrect output for checkConvertUchar3Ulong3" + 20961 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20962 } 20963 20964 private void checkConvertUchar4Ulong4() { 20965 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d3433c8a7fc531el, false, 8); 20966 try { 20967 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20968 script.forEach_testConvertUlong4Uchar4Ulong4(inV, out); 20969 verifyResultsConvertUchar4Ulong4(inV, out, false); 20970 out.destroy(); 20971 } catch (Exception e) { 20972 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString()); 20973 } 20974 try { 20975 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20976 scriptRelaxed.forEach_testConvertUlong4Uchar4Ulong4(inV, out); 20977 verifyResultsConvertUchar4Ulong4(inV, out, true); 20978 out.destroy(); 20979 } catch (Exception e) { 20980 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString()); 20981 } 20982 inV.destroy(); 20983 } 20984 20985 private void verifyResultsConvertUchar4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20986 byte[] arrayInV = new byte[INPUTSIZE * 4]; 20987 Arrays.fill(arrayInV, (byte) 42); 20988 inV.copyTo(arrayInV); 20989 long[] arrayOut = new long[INPUTSIZE * 4]; 20990 Arrays.fill(arrayOut, (long) 42); 20991 out.copyTo(arrayOut); 20992 StringBuilder message = new StringBuilder(); 20993 boolean errorFound = false; 20994 for (int i = 0; i < INPUTSIZE; i++) { 20995 for (int j = 0; j < 4 ; j++) { 20996 // Extract the inputs. 20997 ArgumentsUcharUlong args = new ArgumentsUcharUlong(); 20998 args.inV = arrayInV[i * 4 + j]; 20999 // Figure out what the outputs should have been. 21000 CoreMathVerifier.computeConvert(args); 21001 // Validate the outputs. 21002 boolean valid = true; 21003 if (args.out != arrayOut[i * 4 + j]) { 21004 valid = false; 21005 } 21006 if (!valid) { 21007 if (!errorFound) { 21008 errorFound = true; 21009 message.append("Input inV: "); 21010 appendVariableToMessage(message, args.inV); 21011 message.append("\n"); 21012 message.append("Expected output out: "); 21013 appendVariableToMessage(message, args.out); 21014 message.append("\n"); 21015 message.append("Actual output out: "); 21016 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21017 if (args.out != arrayOut[i * 4 + j]) { 21018 message.append(" FAIL"); 21019 } 21020 message.append("\n"); 21021 message.append("Errors at"); 21022 } 21023 message.append(" ["); 21024 message.append(Integer.toString(i)); 21025 message.append(", "); 21026 message.append(Integer.toString(j)); 21027 message.append("]"); 21028 } 21029 } 21030 } 21031 assertFalse("Incorrect output for checkConvertUchar4Ulong4" + 21032 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21033 } 21034 21035 public class ArgumentsShortUlong { 21036 public short inV; 21037 public long out; 21038 } 21039 21040 private void checkConvertShort2Ulong2() { 21041 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94cab7c3ffc6f6a3l, false, 15); 21042 try { 21043 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21044 script.forEach_testConvertUlong2Short2Ulong2(inV, out); 21045 verifyResultsConvertShort2Ulong2(inV, out, false); 21046 out.destroy(); 21047 } catch (Exception e) { 21048 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString()); 21049 } 21050 try { 21051 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21052 scriptRelaxed.forEach_testConvertUlong2Short2Ulong2(inV, out); 21053 verifyResultsConvertShort2Ulong2(inV, out, true); 21054 out.destroy(); 21055 } catch (Exception e) { 21056 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString()); 21057 } 21058 inV.destroy(); 21059 } 21060 21061 private void verifyResultsConvertShort2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 21062 short[] arrayInV = new short[INPUTSIZE * 2]; 21063 Arrays.fill(arrayInV, (short) 42); 21064 inV.copyTo(arrayInV); 21065 long[] arrayOut = new long[INPUTSIZE * 2]; 21066 Arrays.fill(arrayOut, (long) 42); 21067 out.copyTo(arrayOut); 21068 StringBuilder message = new StringBuilder(); 21069 boolean errorFound = false; 21070 for (int i = 0; i < INPUTSIZE; i++) { 21071 for (int j = 0; j < 2 ; j++) { 21072 // Extract the inputs. 21073 ArgumentsShortUlong args = new ArgumentsShortUlong(); 21074 args.inV = arrayInV[i * 2 + j]; 21075 // Figure out what the outputs should have been. 21076 CoreMathVerifier.computeConvert(args); 21077 // Validate the outputs. 21078 boolean valid = true; 21079 if (args.out != arrayOut[i * 2 + j]) { 21080 valid = false; 21081 } 21082 if (!valid) { 21083 if (!errorFound) { 21084 errorFound = true; 21085 message.append("Input inV: "); 21086 appendVariableToMessage(message, args.inV); 21087 message.append("\n"); 21088 message.append("Expected output out: "); 21089 appendVariableToMessage(message, args.out); 21090 message.append("\n"); 21091 message.append("Actual output out: "); 21092 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21093 if (args.out != arrayOut[i * 2 + j]) { 21094 message.append(" FAIL"); 21095 } 21096 message.append("\n"); 21097 message.append("Errors at"); 21098 } 21099 message.append(" ["); 21100 message.append(Integer.toString(i)); 21101 message.append(", "); 21102 message.append(Integer.toString(j)); 21103 message.append("]"); 21104 } 21105 } 21106 } 21107 assertFalse("Incorrect output for checkConvertShort2Ulong2" + 21108 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21109 } 21110 21111 private void checkConvertShort3Ulong3() { 21112 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc80def5e21781l, false, 15); 21113 try { 21114 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21115 script.forEach_testConvertUlong3Short3Ulong3(inV, out); 21116 verifyResultsConvertShort3Ulong3(inV, out, false); 21117 out.destroy(); 21118 } catch (Exception e) { 21119 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString()); 21120 } 21121 try { 21122 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21123 scriptRelaxed.forEach_testConvertUlong3Short3Ulong3(inV, out); 21124 verifyResultsConvertShort3Ulong3(inV, out, true); 21125 out.destroy(); 21126 } catch (Exception e) { 21127 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString()); 21128 } 21129 inV.destroy(); 21130 } 21131 21132 private void verifyResultsConvertShort3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 21133 short[] arrayInV = new short[INPUTSIZE * 4]; 21134 Arrays.fill(arrayInV, (short) 42); 21135 inV.copyTo(arrayInV); 21136 long[] arrayOut = new long[INPUTSIZE * 4]; 21137 Arrays.fill(arrayOut, (long) 42); 21138 out.copyTo(arrayOut); 21139 StringBuilder message = new StringBuilder(); 21140 boolean errorFound = false; 21141 for (int i = 0; i < INPUTSIZE; i++) { 21142 for (int j = 0; j < 3 ; j++) { 21143 // Extract the inputs. 21144 ArgumentsShortUlong args = new ArgumentsShortUlong(); 21145 args.inV = arrayInV[i * 4 + j]; 21146 // Figure out what the outputs should have been. 21147 CoreMathVerifier.computeConvert(args); 21148 // Validate the outputs. 21149 boolean valid = true; 21150 if (args.out != arrayOut[i * 4 + j]) { 21151 valid = false; 21152 } 21153 if (!valid) { 21154 if (!errorFound) { 21155 errorFound = true; 21156 message.append("Input inV: "); 21157 appendVariableToMessage(message, args.inV); 21158 message.append("\n"); 21159 message.append("Expected output out: "); 21160 appendVariableToMessage(message, args.out); 21161 message.append("\n"); 21162 message.append("Actual output out: "); 21163 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21164 if (args.out != arrayOut[i * 4 + j]) { 21165 message.append(" FAIL"); 21166 } 21167 message.append("\n"); 21168 message.append("Errors at"); 21169 } 21170 message.append(" ["); 21171 message.append(Integer.toString(i)); 21172 message.append(", "); 21173 message.append(Integer.toString(j)); 21174 message.append("]"); 21175 } 21176 } 21177 } 21178 assertFalse("Incorrect output for checkConvertShort3Ulong3" + 21179 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21180 } 21181 21182 private void checkConvertShort4Ulong4() { 21183 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce49f9ebfd385fl, false, 15); 21184 try { 21185 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21186 script.forEach_testConvertUlong4Short4Ulong4(inV, out); 21187 verifyResultsConvertShort4Ulong4(inV, out, false); 21188 out.destroy(); 21189 } catch (Exception e) { 21190 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString()); 21191 } 21192 try { 21193 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21194 scriptRelaxed.forEach_testConvertUlong4Short4Ulong4(inV, out); 21195 verifyResultsConvertShort4Ulong4(inV, out, true); 21196 out.destroy(); 21197 } catch (Exception e) { 21198 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString()); 21199 } 21200 inV.destroy(); 21201 } 21202 21203 private void verifyResultsConvertShort4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 21204 short[] arrayInV = new short[INPUTSIZE * 4]; 21205 Arrays.fill(arrayInV, (short) 42); 21206 inV.copyTo(arrayInV); 21207 long[] arrayOut = new long[INPUTSIZE * 4]; 21208 Arrays.fill(arrayOut, (long) 42); 21209 out.copyTo(arrayOut); 21210 StringBuilder message = new StringBuilder(); 21211 boolean errorFound = false; 21212 for (int i = 0; i < INPUTSIZE; i++) { 21213 for (int j = 0; j < 4 ; j++) { 21214 // Extract the inputs. 21215 ArgumentsShortUlong args = new ArgumentsShortUlong(); 21216 args.inV = arrayInV[i * 4 + j]; 21217 // Figure out what the outputs should have been. 21218 CoreMathVerifier.computeConvert(args); 21219 // Validate the outputs. 21220 boolean valid = true; 21221 if (args.out != arrayOut[i * 4 + j]) { 21222 valid = false; 21223 } 21224 if (!valid) { 21225 if (!errorFound) { 21226 errorFound = true; 21227 message.append("Input inV: "); 21228 appendVariableToMessage(message, args.inV); 21229 message.append("\n"); 21230 message.append("Expected output out: "); 21231 appendVariableToMessage(message, args.out); 21232 message.append("\n"); 21233 message.append("Actual output out: "); 21234 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21235 if (args.out != arrayOut[i * 4 + j]) { 21236 message.append(" FAIL"); 21237 } 21238 message.append("\n"); 21239 message.append("Errors at"); 21240 } 21241 message.append(" ["); 21242 message.append(Integer.toString(i)); 21243 message.append(", "); 21244 message.append(Integer.toString(j)); 21245 message.append("]"); 21246 } 21247 } 21248 } 21249 assertFalse("Incorrect output for checkConvertShort4Ulong4" + 21250 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21251 } 21252 21253 public class ArgumentsUshortUlong { 21254 public short inV; 21255 public long out; 21256 } 21257 21258 private void checkConvertUshort2Ulong2() { 21259 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a190b2d13465cl, false, 16); 21260 try { 21261 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21262 script.forEach_testConvertUlong2Ushort2Ulong2(inV, out); 21263 verifyResultsConvertUshort2Ulong2(inV, out, false); 21264 out.destroy(); 21265 } catch (Exception e) { 21266 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString()); 21267 } 21268 try { 21269 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21270 scriptRelaxed.forEach_testConvertUlong2Ushort2Ulong2(inV, out); 21271 verifyResultsConvertUshort2Ulong2(inV, out, true); 21272 out.destroy(); 21273 } catch (Exception e) { 21274 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString()); 21275 } 21276 inV.destroy(); 21277 } 21278 21279 private void verifyResultsConvertUshort2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 21280 short[] arrayInV = new short[INPUTSIZE * 2]; 21281 Arrays.fill(arrayInV, (short) 42); 21282 inV.copyTo(arrayInV); 21283 long[] arrayOut = new long[INPUTSIZE * 2]; 21284 Arrays.fill(arrayOut, (long) 42); 21285 out.copyTo(arrayOut); 21286 StringBuilder message = new StringBuilder(); 21287 boolean errorFound = false; 21288 for (int i = 0; i < INPUTSIZE; i++) { 21289 for (int j = 0; j < 2 ; j++) { 21290 // Extract the inputs. 21291 ArgumentsUshortUlong args = new ArgumentsUshortUlong(); 21292 args.inV = arrayInV[i * 2 + j]; 21293 // Figure out what the outputs should have been. 21294 CoreMathVerifier.computeConvert(args); 21295 // Validate the outputs. 21296 boolean valid = true; 21297 if (args.out != arrayOut[i * 2 + j]) { 21298 valid = false; 21299 } 21300 if (!valid) { 21301 if (!errorFound) { 21302 errorFound = true; 21303 message.append("Input inV: "); 21304 appendVariableToMessage(message, args.inV); 21305 message.append("\n"); 21306 message.append("Expected output out: "); 21307 appendVariableToMessage(message, args.out); 21308 message.append("\n"); 21309 message.append("Actual output out: "); 21310 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21311 if (args.out != arrayOut[i * 2 + j]) { 21312 message.append(" FAIL"); 21313 } 21314 message.append("\n"); 21315 message.append("Errors at"); 21316 } 21317 message.append(" ["); 21318 message.append(Integer.toString(i)); 21319 message.append(", "); 21320 message.append(Integer.toString(j)); 21321 message.append("]"); 21322 } 21323 } 21324 } 21325 assertFalse("Incorrect output for checkConvertUshort2Ulong2" + 21326 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21327 } 21328 21329 private void checkConvertUshort3Ulong3() { 21330 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36be226232e673al, false, 16); 21331 try { 21332 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21333 script.forEach_testConvertUlong3Ushort3Ulong3(inV, out); 21334 verifyResultsConvertUshort3Ulong3(inV, out, false); 21335 out.destroy(); 21336 } catch (Exception e) { 21337 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString()); 21338 } 21339 try { 21340 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21341 scriptRelaxed.forEach_testConvertUlong3Ushort3Ulong3(inV, out); 21342 verifyResultsConvertUshort3Ulong3(inV, out, true); 21343 out.destroy(); 21344 } catch (Exception e) { 21345 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString()); 21346 } 21347 inV.destroy(); 21348 } 21349 21350 private void verifyResultsConvertUshort3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 21351 short[] arrayInV = new short[INPUTSIZE * 4]; 21352 Arrays.fill(arrayInV, (short) 42); 21353 inV.copyTo(arrayInV); 21354 long[] arrayOut = new long[INPUTSIZE * 4]; 21355 Arrays.fill(arrayOut, (long) 42); 21356 out.copyTo(arrayOut); 21357 StringBuilder message = new StringBuilder(); 21358 boolean errorFound = false; 21359 for (int i = 0; i < INPUTSIZE; i++) { 21360 for (int j = 0; j < 3 ; j++) { 21361 // Extract the inputs. 21362 ArgumentsUshortUlong args = new ArgumentsUshortUlong(); 21363 args.inV = arrayInV[i * 4 + j]; 21364 // Figure out what the outputs should have been. 21365 CoreMathVerifier.computeConvert(args); 21366 // Validate the outputs. 21367 boolean valid = true; 21368 if (args.out != arrayOut[i * 4 + j]) { 21369 valid = false; 21370 } 21371 if (!valid) { 21372 if (!errorFound) { 21373 errorFound = true; 21374 message.append("Input inV: "); 21375 appendVariableToMessage(message, args.inV); 21376 message.append("\n"); 21377 message.append("Expected output out: "); 21378 appendVariableToMessage(message, args.out); 21379 message.append("\n"); 21380 message.append("Actual output out: "); 21381 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21382 if (args.out != arrayOut[i * 4 + j]) { 21383 message.append(" FAIL"); 21384 } 21385 message.append("\n"); 21386 message.append("Errors at"); 21387 } 21388 message.append(" ["); 21389 message.append(Integer.toString(i)); 21390 message.append(", "); 21391 message.append(Integer.toString(j)); 21392 message.append("]"); 21393 } 21394 } 21395 } 21396 assertFalse("Incorrect output for checkConvertUshort3Ulong3" + 21397 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21398 } 21399 21400 private void checkConvertUshort4Ulong4() { 21401 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36dab4119498818l, false, 16); 21402 try { 21403 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21404 script.forEach_testConvertUlong4Ushort4Ulong4(inV, out); 21405 verifyResultsConvertUshort4Ulong4(inV, out, false); 21406 out.destroy(); 21407 } catch (Exception e) { 21408 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString()); 21409 } 21410 try { 21411 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21412 scriptRelaxed.forEach_testConvertUlong4Ushort4Ulong4(inV, out); 21413 verifyResultsConvertUshort4Ulong4(inV, out, true); 21414 out.destroy(); 21415 } catch (Exception e) { 21416 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString()); 21417 } 21418 inV.destroy(); 21419 } 21420 21421 private void verifyResultsConvertUshort4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 21422 short[] arrayInV = new short[INPUTSIZE * 4]; 21423 Arrays.fill(arrayInV, (short) 42); 21424 inV.copyTo(arrayInV); 21425 long[] arrayOut = new long[INPUTSIZE * 4]; 21426 Arrays.fill(arrayOut, (long) 42); 21427 out.copyTo(arrayOut); 21428 StringBuilder message = new StringBuilder(); 21429 boolean errorFound = false; 21430 for (int i = 0; i < INPUTSIZE; i++) { 21431 for (int j = 0; j < 4 ; j++) { 21432 // Extract the inputs. 21433 ArgumentsUshortUlong args = new ArgumentsUshortUlong(); 21434 args.inV = arrayInV[i * 4 + j]; 21435 // Figure out what the outputs should have been. 21436 CoreMathVerifier.computeConvert(args); 21437 // Validate the outputs. 21438 boolean valid = true; 21439 if (args.out != arrayOut[i * 4 + j]) { 21440 valid = false; 21441 } 21442 if (!valid) { 21443 if (!errorFound) { 21444 errorFound = true; 21445 message.append("Input inV: "); 21446 appendVariableToMessage(message, args.inV); 21447 message.append("\n"); 21448 message.append("Expected output out: "); 21449 appendVariableToMessage(message, args.out); 21450 message.append("\n"); 21451 message.append("Actual output out: "); 21452 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21453 if (args.out != arrayOut[i * 4 + j]) { 21454 message.append(" FAIL"); 21455 } 21456 message.append("\n"); 21457 message.append("Errors at"); 21458 } 21459 message.append(" ["); 21460 message.append(Integer.toString(i)); 21461 message.append(", "); 21462 message.append(Integer.toString(j)); 21463 message.append("]"); 21464 } 21465 } 21466 } 21467 assertFalse("Incorrect output for checkConvertUshort4Ulong4" + 21468 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21469 } 21470 21471 public class ArgumentsIntUlong { 21472 public int inV; 21473 public long out; 21474 } 21475 21476 private void checkConvertInt2Ulong2() { 21477 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a53676074a824f6l, false, 31); 21478 try { 21479 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21480 script.forEach_testConvertUlong2Int2Ulong2(inV, out); 21481 verifyResultsConvertInt2Ulong2(inV, out, false); 21482 out.destroy(); 21483 } catch (Exception e) { 21484 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString()); 21485 } 21486 try { 21487 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21488 scriptRelaxed.forEach_testConvertUlong2Int2Ulong2(inV, out); 21489 verifyResultsConvertInt2Ulong2(inV, out, true); 21490 out.destroy(); 21491 } catch (Exception e) { 21492 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString()); 21493 } 21494 inV.destroy(); 21495 } 21496 21497 private void verifyResultsConvertInt2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 21498 int[] arrayInV = new int[INPUTSIZE * 2]; 21499 Arrays.fill(arrayInV, (int) 42); 21500 inV.copyTo(arrayInV); 21501 long[] arrayOut = new long[INPUTSIZE * 2]; 21502 Arrays.fill(arrayOut, (long) 42); 21503 out.copyTo(arrayOut); 21504 StringBuilder message = new StringBuilder(); 21505 boolean errorFound = false; 21506 for (int i = 0; i < INPUTSIZE; i++) { 21507 for (int j = 0; j < 2 ; j++) { 21508 // Extract the inputs. 21509 ArgumentsIntUlong args = new ArgumentsIntUlong(); 21510 args.inV = arrayInV[i * 2 + j]; 21511 // Figure out what the outputs should have been. 21512 CoreMathVerifier.computeConvert(args); 21513 // Validate the outputs. 21514 boolean valid = true; 21515 if (args.out != arrayOut[i * 2 + j]) { 21516 valid = false; 21517 } 21518 if (!valid) { 21519 if (!errorFound) { 21520 errorFound = true; 21521 message.append("Input inV: "); 21522 appendVariableToMessage(message, args.inV); 21523 message.append("\n"); 21524 message.append("Expected output out: "); 21525 appendVariableToMessage(message, args.out); 21526 message.append("\n"); 21527 message.append("Actual output out: "); 21528 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21529 if (args.out != arrayOut[i * 2 + j]) { 21530 message.append(" FAIL"); 21531 } 21532 message.append("\n"); 21533 message.append("Errors at"); 21534 } 21535 message.append(" ["); 21536 message.append(Integer.toString(i)); 21537 message.append(", "); 21538 message.append(Integer.toString(j)); 21539 message.append("]"); 21540 } 21541 } 21542 } 21543 assertFalse("Incorrect output for checkConvertInt2Ulong2" + 21544 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21545 } 21546 21547 private void checkConvertInt3Ulong3() { 21548 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a55307b6ac345d4l, false, 31); 21549 try { 21550 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21551 script.forEach_testConvertUlong3Int3Ulong3(inV, out); 21552 verifyResultsConvertInt3Ulong3(inV, out, false); 21553 out.destroy(); 21554 } catch (Exception e) { 21555 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString()); 21556 } 21557 try { 21558 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21559 scriptRelaxed.forEach_testConvertUlong3Int3Ulong3(inV, out); 21560 verifyResultsConvertInt3Ulong3(inV, out, true); 21561 out.destroy(); 21562 } catch (Exception e) { 21563 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString()); 21564 } 21565 inV.destroy(); 21566 } 21567 21568 private void verifyResultsConvertInt3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 21569 int[] arrayInV = new int[INPUTSIZE * 4]; 21570 Arrays.fill(arrayInV, (int) 42); 21571 inV.copyTo(arrayInV); 21572 long[] arrayOut = new long[INPUTSIZE * 4]; 21573 Arrays.fill(arrayOut, (long) 42); 21574 out.copyTo(arrayOut); 21575 StringBuilder message = new StringBuilder(); 21576 boolean errorFound = false; 21577 for (int i = 0; i < INPUTSIZE; i++) { 21578 for (int j = 0; j < 3 ; j++) { 21579 // Extract the inputs. 21580 ArgumentsIntUlong args = new ArgumentsIntUlong(); 21581 args.inV = arrayInV[i * 4 + j]; 21582 // Figure out what the outputs should have been. 21583 CoreMathVerifier.computeConvert(args); 21584 // Validate the outputs. 21585 boolean valid = true; 21586 if (args.out != arrayOut[i * 4 + j]) { 21587 valid = false; 21588 } 21589 if (!valid) { 21590 if (!errorFound) { 21591 errorFound = true; 21592 message.append("Input inV: "); 21593 appendVariableToMessage(message, args.inV); 21594 message.append("\n"); 21595 message.append("Expected output out: "); 21596 appendVariableToMessage(message, args.out); 21597 message.append("\n"); 21598 message.append("Actual output out: "); 21599 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21600 if (args.out != arrayOut[i * 4 + j]) { 21601 message.append(" FAIL"); 21602 } 21603 message.append("\n"); 21604 message.append("Errors at"); 21605 } 21606 message.append(" ["); 21607 message.append(Integer.toString(i)); 21608 message.append(", "); 21609 message.append(Integer.toString(j)); 21610 message.append("]"); 21611 } 21612 } 21613 } 21614 assertFalse("Incorrect output for checkConvertInt3Ulong3" + 21615 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21616 } 21617 21618 private void checkConvertInt4Ulong4() { 21619 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56f99660de66b2l, false, 31); 21620 try { 21621 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21622 script.forEach_testConvertUlong4Int4Ulong4(inV, out); 21623 verifyResultsConvertInt4Ulong4(inV, out, false); 21624 out.destroy(); 21625 } catch (Exception e) { 21626 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString()); 21627 } 21628 try { 21629 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21630 scriptRelaxed.forEach_testConvertUlong4Int4Ulong4(inV, out); 21631 verifyResultsConvertInt4Ulong4(inV, out, true); 21632 out.destroy(); 21633 } catch (Exception e) { 21634 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString()); 21635 } 21636 inV.destroy(); 21637 } 21638 21639 private void verifyResultsConvertInt4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 21640 int[] arrayInV = new int[INPUTSIZE * 4]; 21641 Arrays.fill(arrayInV, (int) 42); 21642 inV.copyTo(arrayInV); 21643 long[] arrayOut = new long[INPUTSIZE * 4]; 21644 Arrays.fill(arrayOut, (long) 42); 21645 out.copyTo(arrayOut); 21646 StringBuilder message = new StringBuilder(); 21647 boolean errorFound = false; 21648 for (int i = 0; i < INPUTSIZE; i++) { 21649 for (int j = 0; j < 4 ; j++) { 21650 // Extract the inputs. 21651 ArgumentsIntUlong args = new ArgumentsIntUlong(); 21652 args.inV = arrayInV[i * 4 + j]; 21653 // Figure out what the outputs should have been. 21654 CoreMathVerifier.computeConvert(args); 21655 // Validate the outputs. 21656 boolean valid = true; 21657 if (args.out != arrayOut[i * 4 + j]) { 21658 valid = false; 21659 } 21660 if (!valid) { 21661 if (!errorFound) { 21662 errorFound = true; 21663 message.append("Input inV: "); 21664 appendVariableToMessage(message, args.inV); 21665 message.append("\n"); 21666 message.append("Expected output out: "); 21667 appendVariableToMessage(message, args.out); 21668 message.append("\n"); 21669 message.append("Actual output out: "); 21670 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21671 if (args.out != arrayOut[i * 4 + j]) { 21672 message.append(" FAIL"); 21673 } 21674 message.append("\n"); 21675 message.append("Errors at"); 21676 } 21677 message.append(" ["); 21678 message.append(Integer.toString(i)); 21679 message.append(", "); 21680 message.append(Integer.toString(j)); 21681 message.append("]"); 21682 } 21683 } 21684 } 21685 assertFalse("Incorrect output for checkConvertInt4Ulong4" + 21686 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21687 } 21688 21689 public class ArgumentsUintUlong { 21690 public int inV; 21691 public long out; 21692 } 21693 21694 private void checkConvertUint2Ulong2() { 21695 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e120ae072a3177l, false, 32); 21696 try { 21697 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21698 script.forEach_testConvertUlong2Uint2Ulong2(inV, out); 21699 verifyResultsConvertUint2Ulong2(inV, out, false); 21700 out.destroy(); 21701 } catch (Exception e) { 21702 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString()); 21703 } 21704 try { 21705 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 21706 scriptRelaxed.forEach_testConvertUlong2Uint2Ulong2(inV, out); 21707 verifyResultsConvertUint2Ulong2(inV, out, true); 21708 out.destroy(); 21709 } catch (Exception e) { 21710 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString()); 21711 } 21712 inV.destroy(); 21713 } 21714 21715 private void verifyResultsConvertUint2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 21716 int[] arrayInV = new int[INPUTSIZE * 2]; 21717 Arrays.fill(arrayInV, (int) 42); 21718 inV.copyTo(arrayInV); 21719 long[] arrayOut = new long[INPUTSIZE * 2]; 21720 Arrays.fill(arrayOut, (long) 42); 21721 out.copyTo(arrayOut); 21722 StringBuilder message = new StringBuilder(); 21723 boolean errorFound = false; 21724 for (int i = 0; i < INPUTSIZE; i++) { 21725 for (int j = 0; j < 2 ; j++) { 21726 // Extract the inputs. 21727 ArgumentsUintUlong args = new ArgumentsUintUlong(); 21728 args.inV = arrayInV[i * 2 + j]; 21729 // Figure out what the outputs should have been. 21730 CoreMathVerifier.computeConvert(args); 21731 // Validate the outputs. 21732 boolean valid = true; 21733 if (args.out != arrayOut[i * 2 + j]) { 21734 valid = false; 21735 } 21736 if (!valid) { 21737 if (!errorFound) { 21738 errorFound = true; 21739 message.append("Input inV: "); 21740 appendVariableToMessage(message, args.inV); 21741 message.append("\n"); 21742 message.append("Expected output out: "); 21743 appendVariableToMessage(message, args.out); 21744 message.append("\n"); 21745 message.append("Actual output out: "); 21746 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21747 if (args.out != arrayOut[i * 2 + j]) { 21748 message.append(" FAIL"); 21749 } 21750 message.append("\n"); 21751 message.append("Errors at"); 21752 } 21753 message.append(" ["); 21754 message.append(Integer.toString(i)); 21755 message.append(", "); 21756 message.append(Integer.toString(j)); 21757 message.append("]"); 21758 } 21759 } 21760 } 21761 assertFalse("Incorrect output for checkConvertUint2Ulong2" + 21762 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21763 } 21764 21765 private void checkConvertUint3Ulong3() { 21766 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2e9c8fd455255l, false, 32); 21767 try { 21768 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21769 script.forEach_testConvertUlong3Uint3Ulong3(inV, out); 21770 verifyResultsConvertUint3Ulong3(inV, out, false); 21771 out.destroy(); 21772 } catch (Exception e) { 21773 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString()); 21774 } 21775 try { 21776 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 21777 scriptRelaxed.forEach_testConvertUlong3Uint3Ulong3(inV, out); 21778 verifyResultsConvertUint3Ulong3(inV, out, true); 21779 out.destroy(); 21780 } catch (Exception e) { 21781 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString()); 21782 } 21783 inV.destroy(); 21784 } 21785 21786 private void verifyResultsConvertUint3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 21787 int[] arrayInV = new int[INPUTSIZE * 4]; 21788 Arrays.fill(arrayInV, (int) 42); 21789 inV.copyTo(arrayInV); 21790 long[] arrayOut = new long[INPUTSIZE * 4]; 21791 Arrays.fill(arrayOut, (long) 42); 21792 out.copyTo(arrayOut); 21793 StringBuilder message = new StringBuilder(); 21794 boolean errorFound = false; 21795 for (int i = 0; i < INPUTSIZE; i++) { 21796 for (int j = 0; j < 3 ; j++) { 21797 // Extract the inputs. 21798 ArgumentsUintUlong args = new ArgumentsUintUlong(); 21799 args.inV = arrayInV[i * 4 + j]; 21800 // Figure out what the outputs should have been. 21801 CoreMathVerifier.computeConvert(args); 21802 // Validate the outputs. 21803 boolean valid = true; 21804 if (args.out != arrayOut[i * 4 + j]) { 21805 valid = false; 21806 } 21807 if (!valid) { 21808 if (!errorFound) { 21809 errorFound = true; 21810 message.append("Input inV: "); 21811 appendVariableToMessage(message, args.inV); 21812 message.append("\n"); 21813 message.append("Expected output out: "); 21814 appendVariableToMessage(message, args.out); 21815 message.append("\n"); 21816 message.append("Actual output out: "); 21817 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21818 if (args.out != arrayOut[i * 4 + j]) { 21819 message.append(" FAIL"); 21820 } 21821 message.append("\n"); 21822 message.append("Errors at"); 21823 } 21824 message.append(" ["); 21825 message.append(Integer.toString(i)); 21826 message.append(", "); 21827 message.append(Integer.toString(j)); 21828 message.append("]"); 21829 } 21830 } 21831 } 21832 assertFalse("Incorrect output for checkConvertUint3Ulong3" + 21833 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21834 } 21835 21836 private void checkConvertUint4Ulong4() { 21837 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4b2e3f3607333l, false, 32); 21838 try { 21839 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21840 script.forEach_testConvertUlong4Uint4Ulong4(inV, out); 21841 verifyResultsConvertUint4Ulong4(inV, out, false); 21842 out.destroy(); 21843 } catch (Exception e) { 21844 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString()); 21845 } 21846 try { 21847 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 21848 scriptRelaxed.forEach_testConvertUlong4Uint4Ulong4(inV, out); 21849 verifyResultsConvertUint4Ulong4(inV, out, true); 21850 out.destroy(); 21851 } catch (Exception e) { 21852 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString()); 21853 } 21854 inV.destroy(); 21855 } 21856 21857 private void verifyResultsConvertUint4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 21858 int[] arrayInV = new int[INPUTSIZE * 4]; 21859 Arrays.fill(arrayInV, (int) 42); 21860 inV.copyTo(arrayInV); 21861 long[] arrayOut = new long[INPUTSIZE * 4]; 21862 Arrays.fill(arrayOut, (long) 42); 21863 out.copyTo(arrayOut); 21864 StringBuilder message = new StringBuilder(); 21865 boolean errorFound = false; 21866 for (int i = 0; i < INPUTSIZE; i++) { 21867 for (int j = 0; j < 4 ; j++) { 21868 // Extract the inputs. 21869 ArgumentsUintUlong args = new ArgumentsUintUlong(); 21870 args.inV = arrayInV[i * 4 + j]; 21871 // Figure out what the outputs should have been. 21872 CoreMathVerifier.computeConvert(args); 21873 // Validate the outputs. 21874 boolean valid = true; 21875 if (args.out != arrayOut[i * 4 + j]) { 21876 valid = false; 21877 } 21878 if (!valid) { 21879 if (!errorFound) { 21880 errorFound = true; 21881 message.append("Input inV: "); 21882 appendVariableToMessage(message, args.inV); 21883 message.append("\n"); 21884 message.append("Expected output out: "); 21885 appendVariableToMessage(message, args.out); 21886 message.append("\n"); 21887 message.append("Actual output out: "); 21888 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21889 if (args.out != arrayOut[i * 4 + j]) { 21890 message.append(" FAIL"); 21891 } 21892 message.append("\n"); 21893 message.append("Errors at"); 21894 } 21895 message.append(" ["); 21896 message.append(Integer.toString(i)); 21897 message.append(", "); 21898 message.append(Integer.toString(j)); 21899 message.append("]"); 21900 } 21901 } 21902 } 21903 assertFalse("Incorrect output for checkConvertUint4Ulong4" + 21904 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21905 } 21906 21907 public class ArgumentsHalfHalf { 21908 public short inV; 21909 public double inVDouble; 21910 public Target.Floaty out; 21911 } 21912 21913 private void checkConvertHalf2Half2() { 21914 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b69077294e2el, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21915 try { 21916 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 21917 script.forEach_testConvertHalf2Half2Half2(inV, out); 21918 verifyResultsConvertHalf2Half2(inV, out, false); 21919 out.destroy(); 21920 } catch (Exception e) { 21921 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Half2Half2: " + e.toString()); 21922 } 21923 try { 21924 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 21925 scriptRelaxed.forEach_testConvertHalf2Half2Half2(inV, out); 21926 verifyResultsConvertHalf2Half2(inV, out, true); 21927 out.destroy(); 21928 } catch (Exception e) { 21929 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Half2Half2: " + e.toString()); 21930 } 21931 inV.destroy(); 21932 } 21933 21934 private void verifyResultsConvertHalf2Half2(Allocation inV, Allocation out, boolean relaxed) { 21935 short[] arrayInV = new short[INPUTSIZE * 2]; 21936 Arrays.fill(arrayInV, (short) 42); 21937 inV.copyTo(arrayInV); 21938 short[] arrayOut = new short[INPUTSIZE * 2]; 21939 Arrays.fill(arrayOut, (short) 42); 21940 out.copyTo(arrayOut); 21941 StringBuilder message = new StringBuilder(); 21942 boolean errorFound = false; 21943 for (int i = 0; i < INPUTSIZE; i++) { 21944 for (int j = 0; j < 2 ; j++) { 21945 // Extract the inputs. 21946 ArgumentsHalfHalf args = new ArgumentsHalfHalf(); 21947 args.inV = arrayInV[i * 2 + j]; 21948 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21949 // Figure out what the outputs should have been. 21950 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 21951 CoreMathVerifier.computeConvert(args, target); 21952 // Validate the outputs. 21953 boolean valid = true; 21954 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 21955 valid = false; 21956 } 21957 if (!valid) { 21958 if (!errorFound) { 21959 errorFound = true; 21960 message.append("Input inV: "); 21961 appendVariableToMessage(message, args.inV); 21962 message.append("\n"); 21963 message.append("Expected output out: "); 21964 appendVariableToMessage(message, args.out); 21965 message.append("\n"); 21966 message.append("Actual output out: "); 21967 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21968 message.append("\n"); 21969 message.append("Actual output out (in double): "); 21970 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 21971 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 21972 message.append(" FAIL"); 21973 } 21974 message.append("\n"); 21975 message.append("Errors at"); 21976 } 21977 message.append(" ["); 21978 message.append(Integer.toString(i)); 21979 message.append(", "); 21980 message.append(Integer.toString(j)); 21981 message.append("]"); 21982 } 21983 } 21984 } 21985 assertFalse("Incorrect output for checkConvertHalf2Half2" + 21986 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21987 } 21988 21989 private void checkConvertHalf3Half3() { 21990 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613c131d6311322l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21991 try { 21992 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 21993 script.forEach_testConvertHalf3Half3Half3(inV, out); 21994 verifyResultsConvertHalf3Half3(inV, out, false); 21995 out.destroy(); 21996 } catch (Exception e) { 21997 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Half3Half3: " + e.toString()); 21998 } 21999 try { 22000 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 22001 scriptRelaxed.forEach_testConvertHalf3Half3Half3(inV, out); 22002 verifyResultsConvertHalf3Half3(inV, out, true); 22003 out.destroy(); 22004 } catch (Exception e) { 22005 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Half3Half3: " + e.toString()); 22006 } 22007 inV.destroy(); 22008 } 22009 22010 private void verifyResultsConvertHalf3Half3(Allocation inV, Allocation out, boolean relaxed) { 22011 short[] arrayInV = new short[INPUTSIZE * 4]; 22012 Arrays.fill(arrayInV, (short) 42); 22013 inV.copyTo(arrayInV); 22014 short[] arrayOut = new short[INPUTSIZE * 4]; 22015 Arrays.fill(arrayOut, (short) 42); 22016 out.copyTo(arrayOut); 22017 StringBuilder message = new StringBuilder(); 22018 boolean errorFound = false; 22019 for (int i = 0; i < INPUTSIZE; i++) { 22020 for (int j = 0; j < 3 ; j++) { 22021 // Extract the inputs. 22022 ArgumentsHalfHalf args = new ArgumentsHalfHalf(); 22023 args.inV = arrayInV[i * 4 + j]; 22024 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22025 // Figure out what the outputs should have been. 22026 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 22027 CoreMathVerifier.computeConvert(args, target); 22028 // Validate the outputs. 22029 boolean valid = true; 22030 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 22031 valid = false; 22032 } 22033 if (!valid) { 22034 if (!errorFound) { 22035 errorFound = true; 22036 message.append("Input inV: "); 22037 appendVariableToMessage(message, args.inV); 22038 message.append("\n"); 22039 message.append("Expected output out: "); 22040 appendVariableToMessage(message, args.out); 22041 message.append("\n"); 22042 message.append("Actual output out: "); 22043 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22044 message.append("\n"); 22045 message.append("Actual output out (in double): "); 22046 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 22047 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 22048 message.append(" FAIL"); 22049 } 22050 message.append("\n"); 22051 message.append("Errors at"); 22052 } 22053 message.append(" ["); 22054 message.append(Integer.toString(i)); 22055 message.append(", "); 22056 message.append(Integer.toString(j)); 22057 message.append("]"); 22058 } 22059 } 22060 } 22061 assertFalse("Incorrect output for checkConvertHalf3Half3" + 22062 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22063 } 22064 22065 private void checkConvertHalf4Half4() { 22066 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613cbd33538d816l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22067 try { 22068 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 22069 script.forEach_testConvertHalf4Half4Half4(inV, out); 22070 verifyResultsConvertHalf4Half4(inV, out, false); 22071 out.destroy(); 22072 } catch (Exception e) { 22073 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Half4Half4: " + e.toString()); 22074 } 22075 try { 22076 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 22077 scriptRelaxed.forEach_testConvertHalf4Half4Half4(inV, out); 22078 verifyResultsConvertHalf4Half4(inV, out, true); 22079 out.destroy(); 22080 } catch (Exception e) { 22081 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Half4Half4: " + e.toString()); 22082 } 22083 inV.destroy(); 22084 } 22085 22086 private void verifyResultsConvertHalf4Half4(Allocation inV, Allocation out, boolean relaxed) { 22087 short[] arrayInV = new short[INPUTSIZE * 4]; 22088 Arrays.fill(arrayInV, (short) 42); 22089 inV.copyTo(arrayInV); 22090 short[] arrayOut = new short[INPUTSIZE * 4]; 22091 Arrays.fill(arrayOut, (short) 42); 22092 out.copyTo(arrayOut); 22093 StringBuilder message = new StringBuilder(); 22094 boolean errorFound = false; 22095 for (int i = 0; i < INPUTSIZE; i++) { 22096 for (int j = 0; j < 4 ; j++) { 22097 // Extract the inputs. 22098 ArgumentsHalfHalf args = new ArgumentsHalfHalf(); 22099 args.inV = arrayInV[i * 4 + j]; 22100 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22101 // Figure out what the outputs should have been. 22102 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 22103 CoreMathVerifier.computeConvert(args, target); 22104 // Validate the outputs. 22105 boolean valid = true; 22106 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 22107 valid = false; 22108 } 22109 if (!valid) { 22110 if (!errorFound) { 22111 errorFound = true; 22112 message.append("Input inV: "); 22113 appendVariableToMessage(message, args.inV); 22114 message.append("\n"); 22115 message.append("Expected output out: "); 22116 appendVariableToMessage(message, args.out); 22117 message.append("\n"); 22118 message.append("Actual output out: "); 22119 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22120 message.append("\n"); 22121 message.append("Actual output out (in double): "); 22122 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 22123 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 22124 message.append(" FAIL"); 22125 } 22126 message.append("\n"); 22127 message.append("Errors at"); 22128 } 22129 message.append(" ["); 22130 message.append(Integer.toString(i)); 22131 message.append(", "); 22132 message.append(Integer.toString(j)); 22133 message.append("]"); 22134 } 22135 } 22136 } 22137 assertFalse("Incorrect output for checkConvertHalf4Half4" + 22138 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22139 } 22140 22141 public class ArgumentsHalfFloat { 22142 public short inV; 22143 public double inVDouble; 22144 public Target.Floaty out; 22145 } 22146 22147 private void checkConvertHalf2Float2() { 22148 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x754f97bdbbc7b5dbl, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22149 try { 22150 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 22151 script.forEach_testConvertFloat2Half2Float2(inV, out); 22152 verifyResultsConvertHalf2Float2(inV, out, false); 22153 out.destroy(); 22154 } catch (Exception e) { 22155 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Half2Float2: " + e.toString()); 22156 } 22157 try { 22158 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 22159 scriptRelaxed.forEach_testConvertFloat2Half2Float2(inV, out); 22160 verifyResultsConvertHalf2Float2(inV, out, true); 22161 out.destroy(); 22162 } catch (Exception e) { 22163 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Half2Float2: " + e.toString()); 22164 } 22165 inV.destroy(); 22166 } 22167 22168 private void verifyResultsConvertHalf2Float2(Allocation inV, Allocation out, boolean relaxed) { 22169 short[] arrayInV = new short[INPUTSIZE * 2]; 22170 Arrays.fill(arrayInV, (short) 42); 22171 inV.copyTo(arrayInV); 22172 float[] arrayOut = new float[INPUTSIZE * 2]; 22173 Arrays.fill(arrayOut, (float) 42); 22174 out.copyTo(arrayOut); 22175 StringBuilder message = new StringBuilder(); 22176 boolean errorFound = false; 22177 for (int i = 0; i < INPUTSIZE; i++) { 22178 for (int j = 0; j < 2 ; j++) { 22179 // Extract the inputs. 22180 ArgumentsHalfFloat args = new ArgumentsHalfFloat(); 22181 args.inV = arrayInV[i * 2 + j]; 22182 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22183 // Figure out what the outputs should have been. 22184 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 22185 CoreMathVerifier.computeConvert(args, target); 22186 // Validate the outputs. 22187 boolean valid = true; 22188 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 22189 valid = false; 22190 } 22191 if (!valid) { 22192 if (!errorFound) { 22193 errorFound = true; 22194 message.append("Input inV: "); 22195 appendVariableToMessage(message, args.inV); 22196 message.append("\n"); 22197 message.append("Expected output out: "); 22198 appendVariableToMessage(message, args.out); 22199 message.append("\n"); 22200 message.append("Actual output out: "); 22201 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22202 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 22203 message.append(" FAIL"); 22204 } 22205 message.append("\n"); 22206 message.append("Errors at"); 22207 } 22208 message.append(" ["); 22209 message.append(Integer.toString(i)); 22210 message.append(", "); 22211 message.append(Integer.toString(j)); 22212 message.append("]"); 22213 } 22214 } 22215 } 22216 assertFalse("Incorrect output for checkConvertHalf2Float2" + 22217 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22218 } 22219 22220 private void checkConvertHalf3Float3() { 22221 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x755160d8b1e2d6b9l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22222 try { 22223 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 22224 script.forEach_testConvertFloat3Half3Float3(inV, out); 22225 verifyResultsConvertHalf3Float3(inV, out, false); 22226 out.destroy(); 22227 } catch (Exception e) { 22228 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Half3Float3: " + e.toString()); 22229 } 22230 try { 22231 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 22232 scriptRelaxed.forEach_testConvertFloat3Half3Float3(inV, out); 22233 verifyResultsConvertHalf3Float3(inV, out, true); 22234 out.destroy(); 22235 } catch (Exception e) { 22236 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Half3Float3: " + e.toString()); 22237 } 22238 inV.destroy(); 22239 } 22240 22241 private void verifyResultsConvertHalf3Float3(Allocation inV, Allocation out, boolean relaxed) { 22242 short[] arrayInV = new short[INPUTSIZE * 4]; 22243 Arrays.fill(arrayInV, (short) 42); 22244 inV.copyTo(arrayInV); 22245 float[] arrayOut = new float[INPUTSIZE * 4]; 22246 Arrays.fill(arrayOut, (float) 42); 22247 out.copyTo(arrayOut); 22248 StringBuilder message = new StringBuilder(); 22249 boolean errorFound = false; 22250 for (int i = 0; i < INPUTSIZE; i++) { 22251 for (int j = 0; j < 3 ; j++) { 22252 // Extract the inputs. 22253 ArgumentsHalfFloat args = new ArgumentsHalfFloat(); 22254 args.inV = arrayInV[i * 4 + j]; 22255 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22256 // Figure out what the outputs should have been. 22257 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 22258 CoreMathVerifier.computeConvert(args, target); 22259 // Validate the outputs. 22260 boolean valid = true; 22261 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22262 valid = false; 22263 } 22264 if (!valid) { 22265 if (!errorFound) { 22266 errorFound = true; 22267 message.append("Input inV: "); 22268 appendVariableToMessage(message, args.inV); 22269 message.append("\n"); 22270 message.append("Expected output out: "); 22271 appendVariableToMessage(message, args.out); 22272 message.append("\n"); 22273 message.append("Actual output out: "); 22274 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22275 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22276 message.append(" FAIL"); 22277 } 22278 message.append("\n"); 22279 message.append("Errors at"); 22280 } 22281 message.append(" ["); 22282 message.append(Integer.toString(i)); 22283 message.append(", "); 22284 message.append(Integer.toString(j)); 22285 message.append("]"); 22286 } 22287 } 22288 } 22289 assertFalse("Incorrect output for checkConvertHalf3Float3" + 22290 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22291 } 22292 22293 private void checkConvertHalf4Float4() { 22294 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x755329f3a7fdf797l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22295 try { 22296 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 22297 script.forEach_testConvertFloat4Half4Float4(inV, out); 22298 verifyResultsConvertHalf4Float4(inV, out, false); 22299 out.destroy(); 22300 } catch (Exception e) { 22301 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Half4Float4: " + e.toString()); 22302 } 22303 try { 22304 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 22305 scriptRelaxed.forEach_testConvertFloat4Half4Float4(inV, out); 22306 verifyResultsConvertHalf4Float4(inV, out, true); 22307 out.destroy(); 22308 } catch (Exception e) { 22309 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Half4Float4: " + e.toString()); 22310 } 22311 inV.destroy(); 22312 } 22313 22314 private void verifyResultsConvertHalf4Float4(Allocation inV, Allocation out, boolean relaxed) { 22315 short[] arrayInV = new short[INPUTSIZE * 4]; 22316 Arrays.fill(arrayInV, (short) 42); 22317 inV.copyTo(arrayInV); 22318 float[] arrayOut = new float[INPUTSIZE * 4]; 22319 Arrays.fill(arrayOut, (float) 42); 22320 out.copyTo(arrayOut); 22321 StringBuilder message = new StringBuilder(); 22322 boolean errorFound = false; 22323 for (int i = 0; i < INPUTSIZE; i++) { 22324 for (int j = 0; j < 4 ; j++) { 22325 // Extract the inputs. 22326 ArgumentsHalfFloat args = new ArgumentsHalfFloat(); 22327 args.inV = arrayInV[i * 4 + j]; 22328 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22329 // Figure out what the outputs should have been. 22330 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 22331 CoreMathVerifier.computeConvert(args, target); 22332 // Validate the outputs. 22333 boolean valid = true; 22334 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22335 valid = false; 22336 } 22337 if (!valid) { 22338 if (!errorFound) { 22339 errorFound = true; 22340 message.append("Input inV: "); 22341 appendVariableToMessage(message, args.inV); 22342 message.append("\n"); 22343 message.append("Expected output out: "); 22344 appendVariableToMessage(message, args.out); 22345 message.append("\n"); 22346 message.append("Actual output out: "); 22347 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22348 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22349 message.append(" FAIL"); 22350 } 22351 message.append("\n"); 22352 message.append("Errors at"); 22353 } 22354 message.append(" ["); 22355 message.append(Integer.toString(i)); 22356 message.append(", "); 22357 message.append(Integer.toString(j)); 22358 message.append("]"); 22359 } 22360 } 22361 } 22362 assertFalse("Incorrect output for checkConvertHalf4Float4" + 22363 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22364 } 22365 22366 public class ArgumentsHalfDouble { 22367 public short inV; 22368 public double inVDouble; 22369 public Target.Floaty out; 22370 } 22371 22372 private void checkConvertHalf2Double2() { 22373 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb45b0c09b2251ea8l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22374 try { 22375 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 22376 script.forEach_testConvertDouble2Half2Double2(inV, out); 22377 verifyResultsConvertHalf2Double2(inV, out, false); 22378 out.destroy(); 22379 } catch (Exception e) { 22380 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Half2Double2: " + e.toString()); 22381 } 22382 try { 22383 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 22384 scriptRelaxed.forEach_testConvertDouble2Half2Double2(inV, out); 22385 verifyResultsConvertHalf2Double2(inV, out, true); 22386 out.destroy(); 22387 } catch (Exception e) { 22388 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Half2Double2: " + e.toString()); 22389 } 22390 inV.destroy(); 22391 } 22392 22393 private void verifyResultsConvertHalf2Double2(Allocation inV, Allocation out, boolean relaxed) { 22394 short[] arrayInV = new short[INPUTSIZE * 2]; 22395 Arrays.fill(arrayInV, (short) 42); 22396 inV.copyTo(arrayInV); 22397 double[] arrayOut = new double[INPUTSIZE * 2]; 22398 Arrays.fill(arrayOut, (double) 42); 22399 out.copyTo(arrayOut); 22400 StringBuilder message = new StringBuilder(); 22401 boolean errorFound = false; 22402 for (int i = 0; i < INPUTSIZE; i++) { 22403 for (int j = 0; j < 2 ; j++) { 22404 // Extract the inputs. 22405 ArgumentsHalfDouble args = new ArgumentsHalfDouble(); 22406 args.inV = arrayInV[i * 2 + j]; 22407 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22408 // Figure out what the outputs should have been. 22409 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 22410 CoreMathVerifier.computeConvert(args, target); 22411 // Validate the outputs. 22412 boolean valid = true; 22413 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 22414 valid = false; 22415 } 22416 if (!valid) { 22417 if (!errorFound) { 22418 errorFound = true; 22419 message.append("Input inV: "); 22420 appendVariableToMessage(message, args.inV); 22421 message.append("\n"); 22422 message.append("Expected output out: "); 22423 appendVariableToMessage(message, args.out); 22424 message.append("\n"); 22425 message.append("Actual output out: "); 22426 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22427 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 22428 message.append(" FAIL"); 22429 } 22430 message.append("\n"); 22431 message.append("Errors at"); 22432 } 22433 message.append(" ["); 22434 message.append(Integer.toString(i)); 22435 message.append(", "); 22436 message.append(Integer.toString(j)); 22437 message.append("]"); 22438 } 22439 } 22440 } 22441 assertFalse("Incorrect output for checkConvertHalf2Double2" + 22442 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22443 } 22444 22445 private void checkConvertHalf3Double3() { 22446 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb4a7d3910880afd4l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22447 try { 22448 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 22449 script.forEach_testConvertDouble3Half3Double3(inV, out); 22450 verifyResultsConvertHalf3Double3(inV, out, false); 22451 out.destroy(); 22452 } catch (Exception e) { 22453 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Half3Double3: " + e.toString()); 22454 } 22455 try { 22456 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 22457 scriptRelaxed.forEach_testConvertDouble3Half3Double3(inV, out); 22458 verifyResultsConvertHalf3Double3(inV, out, true); 22459 out.destroy(); 22460 } catch (Exception e) { 22461 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Half3Double3: " + e.toString()); 22462 } 22463 inV.destroy(); 22464 } 22465 22466 private void verifyResultsConvertHalf3Double3(Allocation inV, Allocation out, boolean relaxed) { 22467 short[] arrayInV = new short[INPUTSIZE * 4]; 22468 Arrays.fill(arrayInV, (short) 42); 22469 inV.copyTo(arrayInV); 22470 double[] arrayOut = new double[INPUTSIZE * 4]; 22471 Arrays.fill(arrayOut, (double) 42); 22472 out.copyTo(arrayOut); 22473 StringBuilder message = new StringBuilder(); 22474 boolean errorFound = false; 22475 for (int i = 0; i < INPUTSIZE; i++) { 22476 for (int j = 0; j < 3 ; j++) { 22477 // Extract the inputs. 22478 ArgumentsHalfDouble args = new ArgumentsHalfDouble(); 22479 args.inV = arrayInV[i * 4 + j]; 22480 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22481 // Figure out what the outputs should have been. 22482 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 22483 CoreMathVerifier.computeConvert(args, target); 22484 // Validate the outputs. 22485 boolean valid = true; 22486 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22487 valid = false; 22488 } 22489 if (!valid) { 22490 if (!errorFound) { 22491 errorFound = true; 22492 message.append("Input inV: "); 22493 appendVariableToMessage(message, args.inV); 22494 message.append("\n"); 22495 message.append("Expected output out: "); 22496 appendVariableToMessage(message, args.out); 22497 message.append("\n"); 22498 message.append("Actual output out: "); 22499 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22500 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22501 message.append(" FAIL"); 22502 } 22503 message.append("\n"); 22504 message.append("Errors at"); 22505 } 22506 message.append(" ["); 22507 message.append(Integer.toString(i)); 22508 message.append(", "); 22509 message.append(Integer.toString(j)); 22510 message.append("]"); 22511 } 22512 } 22513 } 22514 assertFalse("Incorrect output for checkConvertHalf3Double3" + 22515 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22516 } 22517 22518 private void checkConvertHalf4Double4() { 22519 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb4f49b185edc4100l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 22520 try { 22521 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 22522 script.forEach_testConvertDouble4Half4Double4(inV, out); 22523 verifyResultsConvertHalf4Double4(inV, out, false); 22524 out.destroy(); 22525 } catch (Exception e) { 22526 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Half4Double4: " + e.toString()); 22527 } 22528 try { 22529 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 22530 scriptRelaxed.forEach_testConvertDouble4Half4Double4(inV, out); 22531 verifyResultsConvertHalf4Double4(inV, out, true); 22532 out.destroy(); 22533 } catch (Exception e) { 22534 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Half4Double4: " + e.toString()); 22535 } 22536 inV.destroy(); 22537 } 22538 22539 private void verifyResultsConvertHalf4Double4(Allocation inV, Allocation out, boolean relaxed) { 22540 short[] arrayInV = new short[INPUTSIZE * 4]; 22541 Arrays.fill(arrayInV, (short) 42); 22542 inV.copyTo(arrayInV); 22543 double[] arrayOut = new double[INPUTSIZE * 4]; 22544 Arrays.fill(arrayOut, (double) 42); 22545 out.copyTo(arrayOut); 22546 StringBuilder message = new StringBuilder(); 22547 boolean errorFound = false; 22548 for (int i = 0; i < INPUTSIZE; i++) { 22549 for (int j = 0; j < 4 ; j++) { 22550 // Extract the inputs. 22551 ArgumentsHalfDouble args = new ArgumentsHalfDouble(); 22552 args.inV = arrayInV[i * 4 + j]; 22553 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22554 // Figure out what the outputs should have been. 22555 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 22556 CoreMathVerifier.computeConvert(args, target); 22557 // Validate the outputs. 22558 boolean valid = true; 22559 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22560 valid = false; 22561 } 22562 if (!valid) { 22563 if (!errorFound) { 22564 errorFound = true; 22565 message.append("Input inV: "); 22566 appendVariableToMessage(message, args.inV); 22567 message.append("\n"); 22568 message.append("Expected output out: "); 22569 appendVariableToMessage(message, args.out); 22570 message.append("\n"); 22571 message.append("Actual output out: "); 22572 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22573 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 22574 message.append(" FAIL"); 22575 } 22576 message.append("\n"); 22577 message.append("Errors at"); 22578 } 22579 message.append(" ["); 22580 message.append(Integer.toString(i)); 22581 message.append(", "); 22582 message.append(Integer.toString(j)); 22583 message.append("]"); 22584 } 22585 } 22586 } 22587 assertFalse("Incorrect output for checkConvertHalf4Double4" + 22588 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22589 } 22590 22591 public class ArgumentsHalfChar { 22592 public short inV; 22593 public double inVDouble; 22594 public byte out; 22595 } 22596 22597 private void checkConvertHalf2Char2() { 22598 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b55df6709821l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 22599 try { 22600 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 22601 script.forEach_testConvertChar2Half2Char2(inV, out); 22602 verifyResultsConvertHalf2Char2(inV, out, false); 22603 out.destroy(); 22604 } catch (Exception e) { 22605 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Half2Char2: " + e.toString()); 22606 } 22607 try { 22608 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 22609 scriptRelaxed.forEach_testConvertChar2Half2Char2(inV, out); 22610 verifyResultsConvertHalf2Char2(inV, out, true); 22611 out.destroy(); 22612 } catch (Exception e) { 22613 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Half2Char2: " + e.toString()); 22614 } 22615 inV.destroy(); 22616 } 22617 22618 private void verifyResultsConvertHalf2Char2(Allocation inV, Allocation out, boolean relaxed) { 22619 short[] arrayInV = new short[INPUTSIZE * 2]; 22620 Arrays.fill(arrayInV, (short) 42); 22621 inV.copyTo(arrayInV); 22622 byte[] arrayOut = new byte[INPUTSIZE * 2]; 22623 Arrays.fill(arrayOut, (byte) 42); 22624 out.copyTo(arrayOut); 22625 StringBuilder message = new StringBuilder(); 22626 boolean errorFound = false; 22627 for (int i = 0; i < INPUTSIZE; i++) { 22628 for (int j = 0; j < 2 ; j++) { 22629 // Extract the inputs. 22630 ArgumentsHalfChar args = new ArgumentsHalfChar(); 22631 args.inV = arrayInV[i * 2 + j]; 22632 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22633 // Figure out what the outputs should have been. 22634 CoreMathVerifier.computeConvert(args); 22635 // Validate the outputs. 22636 boolean valid = true; 22637 if (args.out != arrayOut[i * 2 + j]) { 22638 valid = false; 22639 } 22640 if (!valid) { 22641 if (!errorFound) { 22642 errorFound = true; 22643 message.append("Input inV: "); 22644 appendVariableToMessage(message, args.inV); 22645 message.append("\n"); 22646 message.append("Expected output out: "); 22647 appendVariableToMessage(message, args.out); 22648 message.append("\n"); 22649 message.append("Actual output out: "); 22650 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22651 if (args.out != arrayOut[i * 2 + j]) { 22652 message.append(" FAIL"); 22653 } 22654 message.append("\n"); 22655 message.append("Errors at"); 22656 } 22657 message.append(" ["); 22658 message.append(Integer.toString(i)); 22659 message.append(", "); 22660 message.append(Integer.toString(j)); 22661 message.append("]"); 22662 } 22663 } 22664 } 22665 assertFalse("Incorrect output for checkConvertHalf2Char2" + 22666 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22667 } 22668 22669 private void checkConvertHalf3Char3() { 22670 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613bfff55785d15l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 22671 try { 22672 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 22673 script.forEach_testConvertChar3Half3Char3(inV, out); 22674 verifyResultsConvertHalf3Char3(inV, out, false); 22675 out.destroy(); 22676 } catch (Exception e) { 22677 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Half3Char3: " + e.toString()); 22678 } 22679 try { 22680 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 22681 scriptRelaxed.forEach_testConvertChar3Half3Char3(inV, out); 22682 verifyResultsConvertHalf3Char3(inV, out, true); 22683 out.destroy(); 22684 } catch (Exception e) { 22685 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Half3Char3: " + e.toString()); 22686 } 22687 inV.destroy(); 22688 } 22689 22690 private void verifyResultsConvertHalf3Char3(Allocation inV, Allocation out, boolean relaxed) { 22691 short[] arrayInV = new short[INPUTSIZE * 4]; 22692 Arrays.fill(arrayInV, (short) 42); 22693 inV.copyTo(arrayInV); 22694 byte[] arrayOut = new byte[INPUTSIZE * 4]; 22695 Arrays.fill(arrayOut, (byte) 42); 22696 out.copyTo(arrayOut); 22697 StringBuilder message = new StringBuilder(); 22698 boolean errorFound = false; 22699 for (int i = 0; i < INPUTSIZE; i++) { 22700 for (int j = 0; j < 3 ; j++) { 22701 // Extract the inputs. 22702 ArgumentsHalfChar args = new ArgumentsHalfChar(); 22703 args.inV = arrayInV[i * 4 + j]; 22704 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22705 // Figure out what the outputs should have been. 22706 CoreMathVerifier.computeConvert(args); 22707 // Validate the outputs. 22708 boolean valid = true; 22709 if (args.out != arrayOut[i * 4 + j]) { 22710 valid = false; 22711 } 22712 if (!valid) { 22713 if (!errorFound) { 22714 errorFound = true; 22715 message.append("Input inV: "); 22716 appendVariableToMessage(message, args.inV); 22717 message.append("\n"); 22718 message.append("Expected output out: "); 22719 appendVariableToMessage(message, args.out); 22720 message.append("\n"); 22721 message.append("Actual output out: "); 22722 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22723 if (args.out != arrayOut[i * 4 + j]) { 22724 message.append(" FAIL"); 22725 } 22726 message.append("\n"); 22727 message.append("Errors at"); 22728 } 22729 message.append(" ["); 22730 message.append(Integer.toString(i)); 22731 message.append(", "); 22732 message.append(Integer.toString(j)); 22733 message.append("]"); 22734 } 22735 } 22736 } 22737 assertFalse("Incorrect output for checkConvertHalf3Char3" + 22738 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22739 } 22740 22741 private void checkConvertHalf4Char4() { 22742 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613caa0b4802209l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 22743 try { 22744 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 22745 script.forEach_testConvertChar4Half4Char4(inV, out); 22746 verifyResultsConvertHalf4Char4(inV, out, false); 22747 out.destroy(); 22748 } catch (Exception e) { 22749 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Half4Char4: " + e.toString()); 22750 } 22751 try { 22752 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 22753 scriptRelaxed.forEach_testConvertChar4Half4Char4(inV, out); 22754 verifyResultsConvertHalf4Char4(inV, out, true); 22755 out.destroy(); 22756 } catch (Exception e) { 22757 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Half4Char4: " + e.toString()); 22758 } 22759 inV.destroy(); 22760 } 22761 22762 private void verifyResultsConvertHalf4Char4(Allocation inV, Allocation out, boolean relaxed) { 22763 short[] arrayInV = new short[INPUTSIZE * 4]; 22764 Arrays.fill(arrayInV, (short) 42); 22765 inV.copyTo(arrayInV); 22766 byte[] arrayOut = new byte[INPUTSIZE * 4]; 22767 Arrays.fill(arrayOut, (byte) 42); 22768 out.copyTo(arrayOut); 22769 StringBuilder message = new StringBuilder(); 22770 boolean errorFound = false; 22771 for (int i = 0; i < INPUTSIZE; i++) { 22772 for (int j = 0; j < 4 ; j++) { 22773 // Extract the inputs. 22774 ArgumentsHalfChar args = new ArgumentsHalfChar(); 22775 args.inV = arrayInV[i * 4 + j]; 22776 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22777 // Figure out what the outputs should have been. 22778 CoreMathVerifier.computeConvert(args); 22779 // Validate the outputs. 22780 boolean valid = true; 22781 if (args.out != arrayOut[i * 4 + j]) { 22782 valid = false; 22783 } 22784 if (!valid) { 22785 if (!errorFound) { 22786 errorFound = true; 22787 message.append("Input inV: "); 22788 appendVariableToMessage(message, args.inV); 22789 message.append("\n"); 22790 message.append("Expected output out: "); 22791 appendVariableToMessage(message, args.out); 22792 message.append("\n"); 22793 message.append("Actual output out: "); 22794 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22795 if (args.out != arrayOut[i * 4 + j]) { 22796 message.append(" FAIL"); 22797 } 22798 message.append("\n"); 22799 message.append("Errors at"); 22800 } 22801 message.append(" ["); 22802 message.append(Integer.toString(i)); 22803 message.append(", "); 22804 message.append(Integer.toString(j)); 22805 message.append("]"); 22806 } 22807 } 22808 } 22809 assertFalse("Incorrect output for checkConvertHalf4Char4" + 22810 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22811 } 22812 22813 public class ArgumentsHalfUchar { 22814 public short inV; 22815 public double inVDouble; 22816 public byte out; 22817 } 22818 22819 private void checkConvertHalf2Uchar2() { 22820 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x755034ee6869a68el, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 22821 try { 22822 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 22823 script.forEach_testConvertUchar2Half2Uchar2(inV, out); 22824 verifyResultsConvertHalf2Uchar2(inV, out, false); 22825 out.destroy(); 22826 } catch (Exception e) { 22827 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Half2Uchar2: " + e.toString()); 22828 } 22829 try { 22830 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 22831 scriptRelaxed.forEach_testConvertUchar2Half2Uchar2(inV, out); 22832 verifyResultsConvertHalf2Uchar2(inV, out, true); 22833 out.destroy(); 22834 } catch (Exception e) { 22835 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Half2Uchar2: " + e.toString()); 22836 } 22837 inV.destroy(); 22838 } 22839 22840 private void verifyResultsConvertHalf2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 22841 short[] arrayInV = new short[INPUTSIZE * 2]; 22842 Arrays.fill(arrayInV, (short) 42); 22843 inV.copyTo(arrayInV); 22844 byte[] arrayOut = new byte[INPUTSIZE * 2]; 22845 Arrays.fill(arrayOut, (byte) 42); 22846 out.copyTo(arrayOut); 22847 StringBuilder message = new StringBuilder(); 22848 boolean errorFound = false; 22849 for (int i = 0; i < INPUTSIZE; i++) { 22850 for (int j = 0; j < 2 ; j++) { 22851 // Extract the inputs. 22852 ArgumentsHalfUchar args = new ArgumentsHalfUchar(); 22853 args.inV = arrayInV[i * 2 + j]; 22854 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22855 // Figure out what the outputs should have been. 22856 CoreMathVerifier.computeConvert(args); 22857 // Validate the outputs. 22858 boolean valid = true; 22859 if (args.out != arrayOut[i * 2 + j]) { 22860 valid = false; 22861 } 22862 if (!valid) { 22863 if (!errorFound) { 22864 errorFound = true; 22865 message.append("Input inV: "); 22866 appendVariableToMessage(message, args.inV); 22867 message.append("\n"); 22868 message.append("Expected output out: "); 22869 appendVariableToMessage(message, args.out); 22870 message.append("\n"); 22871 message.append("Actual output out: "); 22872 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22873 if (args.out != arrayOut[i * 2 + j]) { 22874 message.append(" FAIL"); 22875 } 22876 message.append("\n"); 22877 message.append("Errors at"); 22878 } 22879 message.append(" ["); 22880 message.append(Integer.toString(i)); 22881 message.append(", "); 22882 message.append(Integer.toString(j)); 22883 message.append("]"); 22884 } 22885 } 22886 } 22887 assertFalse("Incorrect output for checkConvertHalf2Uchar2" + 22888 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22889 } 22890 22891 private void checkConvertHalf3Uchar3() { 22892 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7551fe095e84c76cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 22893 try { 22894 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 22895 script.forEach_testConvertUchar3Half3Uchar3(inV, out); 22896 verifyResultsConvertHalf3Uchar3(inV, out, false); 22897 out.destroy(); 22898 } catch (Exception e) { 22899 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Half3Uchar3: " + e.toString()); 22900 } 22901 try { 22902 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 22903 scriptRelaxed.forEach_testConvertUchar3Half3Uchar3(inV, out); 22904 verifyResultsConvertHalf3Uchar3(inV, out, true); 22905 out.destroy(); 22906 } catch (Exception e) { 22907 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Half3Uchar3: " + e.toString()); 22908 } 22909 inV.destroy(); 22910 } 22911 22912 private void verifyResultsConvertHalf3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 22913 short[] arrayInV = new short[INPUTSIZE * 4]; 22914 Arrays.fill(arrayInV, (short) 42); 22915 inV.copyTo(arrayInV); 22916 byte[] arrayOut = new byte[INPUTSIZE * 4]; 22917 Arrays.fill(arrayOut, (byte) 42); 22918 out.copyTo(arrayOut); 22919 StringBuilder message = new StringBuilder(); 22920 boolean errorFound = false; 22921 for (int i = 0; i < INPUTSIZE; i++) { 22922 for (int j = 0; j < 3 ; j++) { 22923 // Extract the inputs. 22924 ArgumentsHalfUchar args = new ArgumentsHalfUchar(); 22925 args.inV = arrayInV[i * 4 + j]; 22926 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22927 // Figure out what the outputs should have been. 22928 CoreMathVerifier.computeConvert(args); 22929 // Validate the outputs. 22930 boolean valid = true; 22931 if (args.out != arrayOut[i * 4 + j]) { 22932 valid = false; 22933 } 22934 if (!valid) { 22935 if (!errorFound) { 22936 errorFound = true; 22937 message.append("Input inV: "); 22938 appendVariableToMessage(message, args.inV); 22939 message.append("\n"); 22940 message.append("Expected output out: "); 22941 appendVariableToMessage(message, args.out); 22942 message.append("\n"); 22943 message.append("Actual output out: "); 22944 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22945 if (args.out != arrayOut[i * 4 + j]) { 22946 message.append(" FAIL"); 22947 } 22948 message.append("\n"); 22949 message.append("Errors at"); 22950 } 22951 message.append(" ["); 22952 message.append(Integer.toString(i)); 22953 message.append(", "); 22954 message.append(Integer.toString(j)); 22955 message.append("]"); 22956 } 22957 } 22958 } 22959 assertFalse("Incorrect output for checkConvertHalf3Uchar3" + 22960 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22961 } 22962 22963 private void checkConvertHalf4Uchar4() { 22964 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7553c724549fe84al, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 22965 try { 22966 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 22967 script.forEach_testConvertUchar4Half4Uchar4(inV, out); 22968 verifyResultsConvertHalf4Uchar4(inV, out, false); 22969 out.destroy(); 22970 } catch (Exception e) { 22971 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Half4Uchar4: " + e.toString()); 22972 } 22973 try { 22974 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 22975 scriptRelaxed.forEach_testConvertUchar4Half4Uchar4(inV, out); 22976 verifyResultsConvertHalf4Uchar4(inV, out, true); 22977 out.destroy(); 22978 } catch (Exception e) { 22979 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Half4Uchar4: " + e.toString()); 22980 } 22981 inV.destroy(); 22982 } 22983 22984 private void verifyResultsConvertHalf4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 22985 short[] arrayInV = new short[INPUTSIZE * 4]; 22986 Arrays.fill(arrayInV, (short) 42); 22987 inV.copyTo(arrayInV); 22988 byte[] arrayOut = new byte[INPUTSIZE * 4]; 22989 Arrays.fill(arrayOut, (byte) 42); 22990 out.copyTo(arrayOut); 22991 StringBuilder message = new StringBuilder(); 22992 boolean errorFound = false; 22993 for (int i = 0; i < INPUTSIZE; i++) { 22994 for (int j = 0; j < 4 ; j++) { 22995 // Extract the inputs. 22996 ArgumentsHalfUchar args = new ArgumentsHalfUchar(); 22997 args.inV = arrayInV[i * 4 + j]; 22998 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22999 // Figure out what the outputs should have been. 23000 CoreMathVerifier.computeConvert(args); 23001 // Validate the outputs. 23002 boolean valid = true; 23003 if (args.out != arrayOut[i * 4 + j]) { 23004 valid = false; 23005 } 23006 if (!valid) { 23007 if (!errorFound) { 23008 errorFound = true; 23009 message.append("Input inV: "); 23010 appendVariableToMessage(message, args.inV); 23011 message.append("\n"); 23012 message.append("Expected output out: "); 23013 appendVariableToMessage(message, args.out); 23014 message.append("\n"); 23015 message.append("Actual output out: "); 23016 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23017 if (args.out != arrayOut[i * 4 + j]) { 23018 message.append(" FAIL"); 23019 } 23020 message.append("\n"); 23021 message.append("Errors at"); 23022 } 23023 message.append(" ["); 23024 message.append(Integer.toString(i)); 23025 message.append(", "); 23026 message.append(Integer.toString(j)); 23027 message.append("]"); 23028 } 23029 } 23030 } 23031 assertFalse("Incorrect output for checkConvertHalf4Uchar4" + 23032 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23033 } 23034 23035 public class ArgumentsHalfShort { 23036 public short inV; 23037 public double inVDouble; 23038 public short out; 23039 } 23040 23041 private void checkConvertHalf2Short2() { 23042 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x755020f2fd7771a7l, -3.2753000000000000000e+04, 3.2752000000000000000e+04); 23043 try { 23044 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 23045 script.forEach_testConvertShort2Half2Short2(inV, out); 23046 verifyResultsConvertHalf2Short2(inV, out, false); 23047 out.destroy(); 23048 } catch (Exception e) { 23049 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Half2Short2: " + e.toString()); 23050 } 23051 try { 23052 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 23053 scriptRelaxed.forEach_testConvertShort2Half2Short2(inV, out); 23054 verifyResultsConvertHalf2Short2(inV, out, true); 23055 out.destroy(); 23056 } catch (Exception e) { 23057 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Half2Short2: " + e.toString()); 23058 } 23059 inV.destroy(); 23060 } 23061 23062 private void verifyResultsConvertHalf2Short2(Allocation inV, Allocation out, boolean relaxed) { 23063 short[] arrayInV = new short[INPUTSIZE * 2]; 23064 Arrays.fill(arrayInV, (short) 42); 23065 inV.copyTo(arrayInV); 23066 short[] arrayOut = new short[INPUTSIZE * 2]; 23067 Arrays.fill(arrayOut, (short) 42); 23068 out.copyTo(arrayOut); 23069 StringBuilder message = new StringBuilder(); 23070 boolean errorFound = false; 23071 for (int i = 0; i < INPUTSIZE; i++) { 23072 for (int j = 0; j < 2 ; j++) { 23073 // Extract the inputs. 23074 ArgumentsHalfShort args = new ArgumentsHalfShort(); 23075 args.inV = arrayInV[i * 2 + j]; 23076 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23077 // Figure out what the outputs should have been. 23078 CoreMathVerifier.computeConvert(args); 23079 // Validate the outputs. 23080 boolean valid = true; 23081 if (args.out != arrayOut[i * 2 + j]) { 23082 valid = false; 23083 } 23084 if (!valid) { 23085 if (!errorFound) { 23086 errorFound = true; 23087 message.append("Input inV: "); 23088 appendVariableToMessage(message, args.inV); 23089 message.append("\n"); 23090 message.append("Expected output out: "); 23091 appendVariableToMessage(message, args.out); 23092 message.append("\n"); 23093 message.append("Actual output out: "); 23094 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23095 if (args.out != arrayOut[i * 2 + j]) { 23096 message.append(" FAIL"); 23097 } 23098 message.append("\n"); 23099 message.append("Errors at"); 23100 } 23101 message.append(" ["); 23102 message.append(Integer.toString(i)); 23103 message.append(", "); 23104 message.append(Integer.toString(j)); 23105 message.append("]"); 23106 } 23107 } 23108 } 23109 assertFalse("Incorrect output for checkConvertHalf2Short2" + 23110 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23111 } 23112 23113 private void checkConvertHalf3Short3() { 23114 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7551ea0df3929285l, -3.2753000000000000000e+04, 3.2752000000000000000e+04); 23115 try { 23116 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 23117 script.forEach_testConvertShort3Half3Short3(inV, out); 23118 verifyResultsConvertHalf3Short3(inV, out, false); 23119 out.destroy(); 23120 } catch (Exception e) { 23121 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Half3Short3: " + e.toString()); 23122 } 23123 try { 23124 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 23125 scriptRelaxed.forEach_testConvertShort3Half3Short3(inV, out); 23126 verifyResultsConvertHalf3Short3(inV, out, true); 23127 out.destroy(); 23128 } catch (Exception e) { 23129 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Half3Short3: " + e.toString()); 23130 } 23131 inV.destroy(); 23132 } 23133 23134 private void verifyResultsConvertHalf3Short3(Allocation inV, Allocation out, boolean relaxed) { 23135 short[] arrayInV = new short[INPUTSIZE * 4]; 23136 Arrays.fill(arrayInV, (short) 42); 23137 inV.copyTo(arrayInV); 23138 short[] arrayOut = new short[INPUTSIZE * 4]; 23139 Arrays.fill(arrayOut, (short) 42); 23140 out.copyTo(arrayOut); 23141 StringBuilder message = new StringBuilder(); 23142 boolean errorFound = false; 23143 for (int i = 0; i < INPUTSIZE; i++) { 23144 for (int j = 0; j < 3 ; j++) { 23145 // Extract the inputs. 23146 ArgumentsHalfShort args = new ArgumentsHalfShort(); 23147 args.inV = arrayInV[i * 4 + j]; 23148 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23149 // Figure out what the outputs should have been. 23150 CoreMathVerifier.computeConvert(args); 23151 // Validate the outputs. 23152 boolean valid = true; 23153 if (args.out != arrayOut[i * 4 + j]) { 23154 valid = false; 23155 } 23156 if (!valid) { 23157 if (!errorFound) { 23158 errorFound = true; 23159 message.append("Input inV: "); 23160 appendVariableToMessage(message, args.inV); 23161 message.append("\n"); 23162 message.append("Expected output out: "); 23163 appendVariableToMessage(message, args.out); 23164 message.append("\n"); 23165 message.append("Actual output out: "); 23166 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23167 if (args.out != arrayOut[i * 4 + j]) { 23168 message.append(" FAIL"); 23169 } 23170 message.append("\n"); 23171 message.append("Errors at"); 23172 } 23173 message.append(" ["); 23174 message.append(Integer.toString(i)); 23175 message.append(", "); 23176 message.append(Integer.toString(j)); 23177 message.append("]"); 23178 } 23179 } 23180 } 23181 assertFalse("Incorrect output for checkConvertHalf3Short3" + 23182 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23183 } 23184 23185 private void checkConvertHalf4Short4() { 23186 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7553b328e9adb363l, -3.2753000000000000000e+04, 3.2752000000000000000e+04); 23187 try { 23188 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 23189 script.forEach_testConvertShort4Half4Short4(inV, out); 23190 verifyResultsConvertHalf4Short4(inV, out, false); 23191 out.destroy(); 23192 } catch (Exception e) { 23193 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Half4Short4: " + e.toString()); 23194 } 23195 try { 23196 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 23197 scriptRelaxed.forEach_testConvertShort4Half4Short4(inV, out); 23198 verifyResultsConvertHalf4Short4(inV, out, true); 23199 out.destroy(); 23200 } catch (Exception e) { 23201 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Half4Short4: " + e.toString()); 23202 } 23203 inV.destroy(); 23204 } 23205 23206 private void verifyResultsConvertHalf4Short4(Allocation inV, Allocation out, boolean relaxed) { 23207 short[] arrayInV = new short[INPUTSIZE * 4]; 23208 Arrays.fill(arrayInV, (short) 42); 23209 inV.copyTo(arrayInV); 23210 short[] arrayOut = new short[INPUTSIZE * 4]; 23211 Arrays.fill(arrayOut, (short) 42); 23212 out.copyTo(arrayOut); 23213 StringBuilder message = new StringBuilder(); 23214 boolean errorFound = false; 23215 for (int i = 0; i < INPUTSIZE; i++) { 23216 for (int j = 0; j < 4 ; j++) { 23217 // Extract the inputs. 23218 ArgumentsHalfShort args = new ArgumentsHalfShort(); 23219 args.inV = arrayInV[i * 4 + j]; 23220 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23221 // Figure out what the outputs should have been. 23222 CoreMathVerifier.computeConvert(args); 23223 // Validate the outputs. 23224 boolean valid = true; 23225 if (args.out != arrayOut[i * 4 + j]) { 23226 valid = false; 23227 } 23228 if (!valid) { 23229 if (!errorFound) { 23230 errorFound = true; 23231 message.append("Input inV: "); 23232 appendVariableToMessage(message, args.inV); 23233 message.append("\n"); 23234 message.append("Expected output out: "); 23235 appendVariableToMessage(message, args.out); 23236 message.append("\n"); 23237 message.append("Actual output out: "); 23238 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23239 if (args.out != arrayOut[i * 4 + j]) { 23240 message.append(" FAIL"); 23241 } 23242 message.append("\n"); 23243 message.append("Errors at"); 23244 } 23245 message.append(" ["); 23246 message.append(Integer.toString(i)); 23247 message.append(", "); 23248 message.append(Integer.toString(j)); 23249 message.append("]"); 23250 } 23251 } 23252 } 23253 assertFalse("Incorrect output for checkConvertHalf4Short4" + 23254 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23255 } 23256 23257 public class ArgumentsHalfUshort { 23258 public short inV; 23259 public double inVDouble; 23260 public short out; 23261 } 23262 23263 private void checkConvertHalf2Ushort2() { 23264 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb4798e36224cddf6l, 0.0000000000000000000e+00, 6.5504000000000000000e+04); 23265 try { 23266 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 23267 script.forEach_testConvertUshort2Half2Ushort2(inV, out); 23268 verifyResultsConvertHalf2Ushort2(inV, out, false); 23269 out.destroy(); 23270 } catch (Exception e) { 23271 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Half2Ushort2: " + e.toString()); 23272 } 23273 try { 23274 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 23275 scriptRelaxed.forEach_testConvertUshort2Half2Ushort2(inV, out); 23276 verifyResultsConvertHalf2Ushort2(inV, out, true); 23277 out.destroy(); 23278 } catch (Exception e) { 23279 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Half2Ushort2: " + e.toString()); 23280 } 23281 inV.destroy(); 23282 } 23283 23284 private void verifyResultsConvertHalf2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 23285 short[] arrayInV = new short[INPUTSIZE * 2]; 23286 Arrays.fill(arrayInV, (short) 42); 23287 inV.copyTo(arrayInV); 23288 short[] arrayOut = new short[INPUTSIZE * 2]; 23289 Arrays.fill(arrayOut, (short) 42); 23290 out.copyTo(arrayOut); 23291 StringBuilder message = new StringBuilder(); 23292 boolean errorFound = false; 23293 for (int i = 0; i < INPUTSIZE; i++) { 23294 for (int j = 0; j < 2 ; j++) { 23295 // Extract the inputs. 23296 ArgumentsHalfUshort args = new ArgumentsHalfUshort(); 23297 args.inV = arrayInV[i * 2 + j]; 23298 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23299 // Figure out what the outputs should have been. 23300 CoreMathVerifier.computeConvert(args); 23301 // Validate the outputs. 23302 boolean valid = true; 23303 if (args.out != arrayOut[i * 2 + j]) { 23304 valid = false; 23305 } 23306 if (!valid) { 23307 if (!errorFound) { 23308 errorFound = true; 23309 message.append("Input inV: "); 23310 appendVariableToMessage(message, args.inV); 23311 message.append("\n"); 23312 message.append("Expected output out: "); 23313 appendVariableToMessage(message, args.out); 23314 message.append("\n"); 23315 message.append("Actual output out: "); 23316 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23317 if (args.out != arrayOut[i * 2 + j]) { 23318 message.append(" FAIL"); 23319 } 23320 message.append("\n"); 23321 message.append("Errors at"); 23322 } 23323 message.append(" ["); 23324 message.append(Integer.toString(i)); 23325 message.append(", "); 23326 message.append(Integer.toString(j)); 23327 message.append("]"); 23328 } 23329 } 23330 } 23331 assertFalse("Incorrect output for checkConvertHalf2Ushort2" + 23332 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23333 } 23334 23335 private void checkConvertHalf3Ushort3() { 23336 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb4c655bd78a86f22l, 0.0000000000000000000e+00, 6.5504000000000000000e+04); 23337 try { 23338 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 23339 script.forEach_testConvertUshort3Half3Ushort3(inV, out); 23340 verifyResultsConvertHalf3Ushort3(inV, out, false); 23341 out.destroy(); 23342 } catch (Exception e) { 23343 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Half3Ushort3: " + e.toString()); 23344 } 23345 try { 23346 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 23347 scriptRelaxed.forEach_testConvertUshort3Half3Ushort3(inV, out); 23348 verifyResultsConvertHalf3Ushort3(inV, out, true); 23349 out.destroy(); 23350 } catch (Exception e) { 23351 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Half3Ushort3: " + e.toString()); 23352 } 23353 inV.destroy(); 23354 } 23355 23356 private void verifyResultsConvertHalf3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 23357 short[] arrayInV = new short[INPUTSIZE * 4]; 23358 Arrays.fill(arrayInV, (short) 42); 23359 inV.copyTo(arrayInV); 23360 short[] arrayOut = new short[INPUTSIZE * 4]; 23361 Arrays.fill(arrayOut, (short) 42); 23362 out.copyTo(arrayOut); 23363 StringBuilder message = new StringBuilder(); 23364 boolean errorFound = false; 23365 for (int i = 0; i < INPUTSIZE; i++) { 23366 for (int j = 0; j < 3 ; j++) { 23367 // Extract the inputs. 23368 ArgumentsHalfUshort args = new ArgumentsHalfUshort(); 23369 args.inV = arrayInV[i * 4 + j]; 23370 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23371 // Figure out what the outputs should have been. 23372 CoreMathVerifier.computeConvert(args); 23373 // Validate the outputs. 23374 boolean valid = true; 23375 if (args.out != arrayOut[i * 4 + j]) { 23376 valid = false; 23377 } 23378 if (!valid) { 23379 if (!errorFound) { 23380 errorFound = true; 23381 message.append("Input inV: "); 23382 appendVariableToMessage(message, args.inV); 23383 message.append("\n"); 23384 message.append("Expected output out: "); 23385 appendVariableToMessage(message, args.out); 23386 message.append("\n"); 23387 message.append("Actual output out: "); 23388 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23389 if (args.out != arrayOut[i * 4 + j]) { 23390 message.append(" FAIL"); 23391 } 23392 message.append("\n"); 23393 message.append("Errors at"); 23394 } 23395 message.append(" ["); 23396 message.append(Integer.toString(i)); 23397 message.append(", "); 23398 message.append(Integer.toString(j)); 23399 message.append("]"); 23400 } 23401 } 23402 } 23403 assertFalse("Incorrect output for checkConvertHalf3Ushort3" + 23404 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23405 } 23406 23407 private void checkConvertHalf4Ushort4() { 23408 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb5131d44cf04004el, 0.0000000000000000000e+00, 6.5504000000000000000e+04); 23409 try { 23410 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 23411 script.forEach_testConvertUshort4Half4Ushort4(inV, out); 23412 verifyResultsConvertHalf4Ushort4(inV, out, false); 23413 out.destroy(); 23414 } catch (Exception e) { 23415 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Half4Ushort4: " + e.toString()); 23416 } 23417 try { 23418 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 23419 scriptRelaxed.forEach_testConvertUshort4Half4Ushort4(inV, out); 23420 verifyResultsConvertHalf4Ushort4(inV, out, true); 23421 out.destroy(); 23422 } catch (Exception e) { 23423 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Half4Ushort4: " + e.toString()); 23424 } 23425 inV.destroy(); 23426 } 23427 23428 private void verifyResultsConvertHalf4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 23429 short[] arrayInV = new short[INPUTSIZE * 4]; 23430 Arrays.fill(arrayInV, (short) 42); 23431 inV.copyTo(arrayInV); 23432 short[] arrayOut = new short[INPUTSIZE * 4]; 23433 Arrays.fill(arrayOut, (short) 42); 23434 out.copyTo(arrayOut); 23435 StringBuilder message = new StringBuilder(); 23436 boolean errorFound = false; 23437 for (int i = 0; i < INPUTSIZE; i++) { 23438 for (int j = 0; j < 4 ; j++) { 23439 // Extract the inputs. 23440 ArgumentsHalfUshort args = new ArgumentsHalfUshort(); 23441 args.inV = arrayInV[i * 4 + j]; 23442 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23443 // Figure out what the outputs should have been. 23444 CoreMathVerifier.computeConvert(args); 23445 // Validate the outputs. 23446 boolean valid = true; 23447 if (args.out != arrayOut[i * 4 + j]) { 23448 valid = false; 23449 } 23450 if (!valid) { 23451 if (!errorFound) { 23452 errorFound = true; 23453 message.append("Input inV: "); 23454 appendVariableToMessage(message, args.inV); 23455 message.append("\n"); 23456 message.append("Expected output out: "); 23457 appendVariableToMessage(message, args.out); 23458 message.append("\n"); 23459 message.append("Actual output out: "); 23460 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23461 if (args.out != arrayOut[i * 4 + j]) { 23462 message.append(" FAIL"); 23463 } 23464 message.append("\n"); 23465 message.append("Errors at"); 23466 } 23467 message.append(" ["); 23468 message.append(Integer.toString(i)); 23469 message.append(", "); 23470 message.append(Integer.toString(j)); 23471 message.append("]"); 23472 } 23473 } 23474 } 23475 assertFalse("Incorrect output for checkConvertHalf4Ushort4" + 23476 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23477 } 23478 23479 public class ArgumentsHalfInt { 23480 public short inV; 23481 public double inVDouble; 23482 public int out; 23483 } 23484 23485 private void checkConvertHalf2Int2() { 23486 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc677873adcfe841al, -2.1464350730000000000e+09, 2.1464350720000000000e+09); 23487 try { 23488 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 23489 script.forEach_testConvertInt2Half2Int2(inV, out); 23490 verifyResultsConvertHalf2Int2(inV, out, false); 23491 out.destroy(); 23492 } catch (Exception e) { 23493 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Half2Int2: " + e.toString()); 23494 } 23495 try { 23496 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 23497 scriptRelaxed.forEach_testConvertInt2Half2Int2(inV, out); 23498 verifyResultsConvertHalf2Int2(inV, out, true); 23499 out.destroy(); 23500 } catch (Exception e) { 23501 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Half2Int2: " + e.toString()); 23502 } 23503 inV.destroy(); 23504 } 23505 23506 private void verifyResultsConvertHalf2Int2(Allocation inV, Allocation out, boolean relaxed) { 23507 short[] arrayInV = new short[INPUTSIZE * 2]; 23508 Arrays.fill(arrayInV, (short) 42); 23509 inV.copyTo(arrayInV); 23510 int[] arrayOut = new int[INPUTSIZE * 2]; 23511 Arrays.fill(arrayOut, (int) 42); 23512 out.copyTo(arrayOut); 23513 StringBuilder message = new StringBuilder(); 23514 boolean errorFound = false; 23515 for (int i = 0; i < INPUTSIZE; i++) { 23516 for (int j = 0; j < 2 ; j++) { 23517 // Extract the inputs. 23518 ArgumentsHalfInt args = new ArgumentsHalfInt(); 23519 args.inV = arrayInV[i * 2 + j]; 23520 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23521 // Figure out what the outputs should have been. 23522 CoreMathVerifier.computeConvert(args); 23523 // Validate the outputs. 23524 boolean valid = true; 23525 if (args.out != arrayOut[i * 2 + j]) { 23526 valid = false; 23527 } 23528 if (!valid) { 23529 if (!errorFound) { 23530 errorFound = true; 23531 message.append("Input inV: "); 23532 appendVariableToMessage(message, args.inV); 23533 message.append("\n"); 23534 message.append("Expected output out: "); 23535 appendVariableToMessage(message, args.out); 23536 message.append("\n"); 23537 message.append("Actual output out: "); 23538 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23539 if (args.out != arrayOut[i * 2 + j]) { 23540 message.append(" FAIL"); 23541 } 23542 message.append("\n"); 23543 message.append("Errors at"); 23544 } 23545 message.append(" ["); 23546 message.append(Integer.toString(i)); 23547 message.append(", "); 23548 message.append(Integer.toString(j)); 23549 message.append("]"); 23550 } 23551 } 23552 } 23553 assertFalse("Incorrect output for checkConvertHalf2Int2" + 23554 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23555 } 23556 23557 private void checkConvertHalf3Int3() { 23558 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc677877a26a69450l, -2.1464350730000000000e+09, 2.1464350720000000000e+09); 23559 try { 23560 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 23561 script.forEach_testConvertInt3Half3Int3(inV, out); 23562 verifyResultsConvertHalf3Int3(inV, out, false); 23563 out.destroy(); 23564 } catch (Exception e) { 23565 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Half3Int3: " + e.toString()); 23566 } 23567 try { 23568 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 23569 scriptRelaxed.forEach_testConvertInt3Half3Int3(inV, out); 23570 verifyResultsConvertHalf3Int3(inV, out, true); 23571 out.destroy(); 23572 } catch (Exception e) { 23573 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Half3Int3: " + e.toString()); 23574 } 23575 inV.destroy(); 23576 } 23577 23578 private void verifyResultsConvertHalf3Int3(Allocation inV, Allocation out, boolean relaxed) { 23579 short[] arrayInV = new short[INPUTSIZE * 4]; 23580 Arrays.fill(arrayInV, (short) 42); 23581 inV.copyTo(arrayInV); 23582 int[] arrayOut = new int[INPUTSIZE * 4]; 23583 Arrays.fill(arrayOut, (int) 42); 23584 out.copyTo(arrayOut); 23585 StringBuilder message = new StringBuilder(); 23586 boolean errorFound = false; 23587 for (int i = 0; i < INPUTSIZE; i++) { 23588 for (int j = 0; j < 3 ; j++) { 23589 // Extract the inputs. 23590 ArgumentsHalfInt args = new ArgumentsHalfInt(); 23591 args.inV = arrayInV[i * 4 + j]; 23592 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23593 // Figure out what the outputs should have been. 23594 CoreMathVerifier.computeConvert(args); 23595 // Validate the outputs. 23596 boolean valid = true; 23597 if (args.out != arrayOut[i * 4 + j]) { 23598 valid = false; 23599 } 23600 if (!valid) { 23601 if (!errorFound) { 23602 errorFound = true; 23603 message.append("Input inV: "); 23604 appendVariableToMessage(message, args.inV); 23605 message.append("\n"); 23606 message.append("Expected output out: "); 23607 appendVariableToMessage(message, args.out); 23608 message.append("\n"); 23609 message.append("Actual output out: "); 23610 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23611 if (args.out != arrayOut[i * 4 + j]) { 23612 message.append(" FAIL"); 23613 } 23614 message.append("\n"); 23615 message.append("Errors at"); 23616 } 23617 message.append(" ["); 23618 message.append(Integer.toString(i)); 23619 message.append(", "); 23620 message.append(Integer.toString(j)); 23621 message.append("]"); 23622 } 23623 } 23624 } 23625 assertFalse("Incorrect output for checkConvertHalf3Int3" + 23626 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23627 } 23628 23629 private void checkConvertHalf4Int4() { 23630 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc67787b9704ea486l, -2.1464350730000000000e+09, 2.1464350720000000000e+09); 23631 try { 23632 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 23633 script.forEach_testConvertInt4Half4Int4(inV, out); 23634 verifyResultsConvertHalf4Int4(inV, out, false); 23635 out.destroy(); 23636 } catch (Exception e) { 23637 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Half4Int4: " + e.toString()); 23638 } 23639 try { 23640 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 23641 scriptRelaxed.forEach_testConvertInt4Half4Int4(inV, out); 23642 verifyResultsConvertHalf4Int4(inV, out, true); 23643 out.destroy(); 23644 } catch (Exception e) { 23645 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Half4Int4: " + e.toString()); 23646 } 23647 inV.destroy(); 23648 } 23649 23650 private void verifyResultsConvertHalf4Int4(Allocation inV, Allocation out, boolean relaxed) { 23651 short[] arrayInV = new short[INPUTSIZE * 4]; 23652 Arrays.fill(arrayInV, (short) 42); 23653 inV.copyTo(arrayInV); 23654 int[] arrayOut = new int[INPUTSIZE * 4]; 23655 Arrays.fill(arrayOut, (int) 42); 23656 out.copyTo(arrayOut); 23657 StringBuilder message = new StringBuilder(); 23658 boolean errorFound = false; 23659 for (int i = 0; i < INPUTSIZE; i++) { 23660 for (int j = 0; j < 4 ; j++) { 23661 // Extract the inputs. 23662 ArgumentsHalfInt args = new ArgumentsHalfInt(); 23663 args.inV = arrayInV[i * 4 + j]; 23664 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23665 // Figure out what the outputs should have been. 23666 CoreMathVerifier.computeConvert(args); 23667 // Validate the outputs. 23668 boolean valid = true; 23669 if (args.out != arrayOut[i * 4 + j]) { 23670 valid = false; 23671 } 23672 if (!valid) { 23673 if (!errorFound) { 23674 errorFound = true; 23675 message.append("Input inV: "); 23676 appendVariableToMessage(message, args.inV); 23677 message.append("\n"); 23678 message.append("Expected output out: "); 23679 appendVariableToMessage(message, args.out); 23680 message.append("\n"); 23681 message.append("Actual output out: "); 23682 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23683 if (args.out != arrayOut[i * 4 + j]) { 23684 message.append(" FAIL"); 23685 } 23686 message.append("\n"); 23687 message.append("Errors at"); 23688 } 23689 message.append(" ["); 23690 message.append(Integer.toString(i)); 23691 message.append(", "); 23692 message.append(Integer.toString(j)); 23693 message.append("]"); 23694 } 23695 } 23696 } 23697 assertFalse("Incorrect output for checkConvertHalf4Int4" + 23698 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23699 } 23700 23701 public class ArgumentsHalfUint { 23702 public short inV; 23703 public double inVDouble; 23704 public int out; 23705 } 23706 23707 private void checkConvertHalf2Uint2() { 23708 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b9d30f45cbe1l, 0.0000000000000000000e+00, 4.2928701440000000000e+09); 23709 try { 23710 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 23711 script.forEach_testConvertUint2Half2Uint2(inV, out); 23712 verifyResultsConvertHalf2Uint2(inV, out, false); 23713 out.destroy(); 23714 } catch (Exception e) { 23715 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Half2Uint2: " + e.toString()); 23716 } 23717 try { 23718 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 23719 scriptRelaxed.forEach_testConvertUint2Half2Uint2(inV, out); 23720 verifyResultsConvertHalf2Uint2(inV, out, true); 23721 out.destroy(); 23722 } catch (Exception e) { 23723 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Half2Uint2: " + e.toString()); 23724 } 23725 inV.destroy(); 23726 } 23727 23728 private void verifyResultsConvertHalf2Uint2(Allocation inV, Allocation out, boolean relaxed) { 23729 short[] arrayInV = new short[INPUTSIZE * 2]; 23730 Arrays.fill(arrayInV, (short) 42); 23731 inV.copyTo(arrayInV); 23732 int[] arrayOut = new int[INPUTSIZE * 2]; 23733 Arrays.fill(arrayOut, (int) 42); 23734 out.copyTo(arrayOut); 23735 StringBuilder message = new StringBuilder(); 23736 boolean errorFound = false; 23737 for (int i = 0; i < INPUTSIZE; i++) { 23738 for (int j = 0; j < 2 ; j++) { 23739 // Extract the inputs. 23740 ArgumentsHalfUint args = new ArgumentsHalfUint(); 23741 args.inV = arrayInV[i * 2 + j]; 23742 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23743 // Figure out what the outputs should have been. 23744 CoreMathVerifier.computeConvert(args); 23745 // Validate the outputs. 23746 boolean valid = true; 23747 if (args.out != arrayOut[i * 2 + j]) { 23748 valid = false; 23749 } 23750 if (!valid) { 23751 if (!errorFound) { 23752 errorFound = true; 23753 message.append("Input inV: "); 23754 appendVariableToMessage(message, args.inV); 23755 message.append("\n"); 23756 message.append("Expected output out: "); 23757 appendVariableToMessage(message, args.out); 23758 message.append("\n"); 23759 message.append("Actual output out: "); 23760 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23761 if (args.out != arrayOut[i * 2 + j]) { 23762 message.append(" FAIL"); 23763 } 23764 message.append("\n"); 23765 message.append("Errors at"); 23766 } 23767 message.append(" ["); 23768 message.append(Integer.toString(i)); 23769 message.append(", "); 23770 message.append(Integer.toString(j)); 23771 message.append("]"); 23772 } 23773 } 23774 } 23775 assertFalse("Incorrect output for checkConvertHalf2Uint2" + 23776 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23777 } 23778 23779 private void checkConvertHalf3Uint3() { 23780 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613c4746e4d90d5l, 0.0000000000000000000e+00, 4.2928701440000000000e+09); 23781 try { 23782 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 23783 script.forEach_testConvertUint3Half3Uint3(inV, out); 23784 verifyResultsConvertHalf3Uint3(inV, out, false); 23785 out.destroy(); 23786 } catch (Exception e) { 23787 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Half3Uint3: " + e.toString()); 23788 } 23789 try { 23790 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 23791 scriptRelaxed.forEach_testConvertUint3Half3Uint3(inV, out); 23792 verifyResultsConvertHalf3Uint3(inV, out, true); 23793 out.destroy(); 23794 } catch (Exception e) { 23795 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Half3Uint3: " + e.toString()); 23796 } 23797 inV.destroy(); 23798 } 23799 23800 private void verifyResultsConvertHalf3Uint3(Allocation inV, Allocation out, boolean relaxed) { 23801 short[] arrayInV = new short[INPUTSIZE * 4]; 23802 Arrays.fill(arrayInV, (short) 42); 23803 inV.copyTo(arrayInV); 23804 int[] arrayOut = new int[INPUTSIZE * 4]; 23805 Arrays.fill(arrayOut, (int) 42); 23806 out.copyTo(arrayOut); 23807 StringBuilder message = new StringBuilder(); 23808 boolean errorFound = false; 23809 for (int i = 0; i < INPUTSIZE; i++) { 23810 for (int j = 0; j < 3 ; j++) { 23811 // Extract the inputs. 23812 ArgumentsHalfUint args = new ArgumentsHalfUint(); 23813 args.inV = arrayInV[i * 4 + j]; 23814 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23815 // Figure out what the outputs should have been. 23816 CoreMathVerifier.computeConvert(args); 23817 // Validate the outputs. 23818 boolean valid = true; 23819 if (args.out != arrayOut[i * 4 + j]) { 23820 valid = false; 23821 } 23822 if (!valid) { 23823 if (!errorFound) { 23824 errorFound = true; 23825 message.append("Input inV: "); 23826 appendVariableToMessage(message, args.inV); 23827 message.append("\n"); 23828 message.append("Expected output out: "); 23829 appendVariableToMessage(message, args.out); 23830 message.append("\n"); 23831 message.append("Actual output out: "); 23832 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23833 if (args.out != arrayOut[i * 4 + j]) { 23834 message.append(" FAIL"); 23835 } 23836 message.append("\n"); 23837 message.append("Errors at"); 23838 } 23839 message.append(" ["); 23840 message.append(Integer.toString(i)); 23841 message.append(", "); 23842 message.append(Integer.toString(j)); 23843 message.append("]"); 23844 } 23845 } 23846 } 23847 assertFalse("Incorrect output for checkConvertHalf3Uint3" + 23848 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23849 } 23850 23851 private void checkConvertHalf4Uint4() { 23852 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613cf15cd5555c9l, 0.0000000000000000000e+00, 4.2928701440000000000e+09); 23853 try { 23854 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 23855 script.forEach_testConvertUint4Half4Uint4(inV, out); 23856 verifyResultsConvertHalf4Uint4(inV, out, false); 23857 out.destroy(); 23858 } catch (Exception e) { 23859 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Half4Uint4: " + e.toString()); 23860 } 23861 try { 23862 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 23863 scriptRelaxed.forEach_testConvertUint4Half4Uint4(inV, out); 23864 verifyResultsConvertHalf4Uint4(inV, out, true); 23865 out.destroy(); 23866 } catch (Exception e) { 23867 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Half4Uint4: " + e.toString()); 23868 } 23869 inV.destroy(); 23870 } 23871 23872 private void verifyResultsConvertHalf4Uint4(Allocation inV, Allocation out, boolean relaxed) { 23873 short[] arrayInV = new short[INPUTSIZE * 4]; 23874 Arrays.fill(arrayInV, (short) 42); 23875 inV.copyTo(arrayInV); 23876 int[] arrayOut = new int[INPUTSIZE * 4]; 23877 Arrays.fill(arrayOut, (int) 42); 23878 out.copyTo(arrayOut); 23879 StringBuilder message = new StringBuilder(); 23880 boolean errorFound = false; 23881 for (int i = 0; i < INPUTSIZE; i++) { 23882 for (int j = 0; j < 4 ; j++) { 23883 // Extract the inputs. 23884 ArgumentsHalfUint args = new ArgumentsHalfUint(); 23885 args.inV = arrayInV[i * 4 + j]; 23886 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23887 // Figure out what the outputs should have been. 23888 CoreMathVerifier.computeConvert(args); 23889 // Validate the outputs. 23890 boolean valid = true; 23891 if (args.out != arrayOut[i * 4 + j]) { 23892 valid = false; 23893 } 23894 if (!valid) { 23895 if (!errorFound) { 23896 errorFound = true; 23897 message.append("Input inV: "); 23898 appendVariableToMessage(message, args.inV); 23899 message.append("\n"); 23900 message.append("Expected output out: "); 23901 appendVariableToMessage(message, args.out); 23902 message.append("\n"); 23903 message.append("Actual output out: "); 23904 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23905 if (args.out != arrayOut[i * 4 + j]) { 23906 message.append(" FAIL"); 23907 } 23908 message.append("\n"); 23909 message.append("Errors at"); 23910 } 23911 message.append(" ["); 23912 message.append(Integer.toString(i)); 23913 message.append(", "); 23914 message.append(Integer.toString(j)); 23915 message.append("]"); 23916 } 23917 } 23918 } 23919 assertFalse("Incorrect output for checkConvertHalf4Uint4" + 23920 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23921 } 23922 23923 public class ArgumentsHalfLong { 23924 public short inV; 23925 public double inVDouble; 23926 public long out; 23927 } 23928 23929 private void checkConvertHalf2Long2() { 23930 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b7a24a740c9fl, -9.2188684372274053120e+18, 9.2188684372274053120e+18); 23931 try { 23932 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 23933 script.forEach_testConvertLong2Half2Long2(inV, out); 23934 verifyResultsConvertHalf2Long2(inV, out, false); 23935 out.destroy(); 23936 } catch (Exception e) { 23937 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Half2Long2: " + e.toString()); 23938 } 23939 try { 23940 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 23941 scriptRelaxed.forEach_testConvertLong2Half2Long2(inV, out); 23942 verifyResultsConvertHalf2Long2(inV, out, true); 23943 out.destroy(); 23944 } catch (Exception e) { 23945 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Half2Long2: " + e.toString()); 23946 } 23947 inV.destroy(); 23948 } 23949 23950 private void verifyResultsConvertHalf2Long2(Allocation inV, Allocation out, boolean relaxed) { 23951 short[] arrayInV = new short[INPUTSIZE * 2]; 23952 Arrays.fill(arrayInV, (short) 42); 23953 inV.copyTo(arrayInV); 23954 long[] arrayOut = new long[INPUTSIZE * 2]; 23955 Arrays.fill(arrayOut, (long) 42); 23956 out.copyTo(arrayOut); 23957 StringBuilder message = new StringBuilder(); 23958 boolean errorFound = false; 23959 for (int i = 0; i < INPUTSIZE; i++) { 23960 for (int j = 0; j < 2 ; j++) { 23961 // Extract the inputs. 23962 ArgumentsHalfLong args = new ArgumentsHalfLong(); 23963 args.inV = arrayInV[i * 2 + j]; 23964 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23965 // Figure out what the outputs should have been. 23966 CoreMathVerifier.computeConvert(args); 23967 // Validate the outputs. 23968 boolean valid = true; 23969 if (args.out != arrayOut[i * 2 + j]) { 23970 valid = false; 23971 } 23972 if (!valid) { 23973 if (!errorFound) { 23974 errorFound = true; 23975 message.append("Input inV: "); 23976 appendVariableToMessage(message, args.inV); 23977 message.append("\n"); 23978 message.append("Expected output out: "); 23979 appendVariableToMessage(message, args.out); 23980 message.append("\n"); 23981 message.append("Actual output out: "); 23982 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23983 if (args.out != arrayOut[i * 2 + j]) { 23984 message.append(" FAIL"); 23985 } 23986 message.append("\n"); 23987 message.append("Errors at"); 23988 } 23989 message.append(" ["); 23990 message.append(Integer.toString(i)); 23991 message.append(", "); 23992 message.append(Integer.toString(j)); 23993 message.append("]"); 23994 } 23995 } 23996 } 23997 assertFalse("Incorrect output for checkConvertHalf2Long2" + 23998 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23999 } 24000 24001 private void checkConvertHalf3Long3() { 24002 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613c243a97bd193l, -9.2188684372274053120e+18, 9.2188684372274053120e+18); 24003 try { 24004 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 24005 script.forEach_testConvertLong3Half3Long3(inV, out); 24006 verifyResultsConvertHalf3Long3(inV, out, false); 24007 out.destroy(); 24008 } catch (Exception e) { 24009 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Half3Long3: " + e.toString()); 24010 } 24011 try { 24012 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 24013 scriptRelaxed.forEach_testConvertLong3Half3Long3(inV, out); 24014 verifyResultsConvertHalf3Long3(inV, out, true); 24015 out.destroy(); 24016 } catch (Exception e) { 24017 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Half3Long3: " + e.toString()); 24018 } 24019 inV.destroy(); 24020 } 24021 24022 private void verifyResultsConvertHalf3Long3(Allocation inV, Allocation out, boolean relaxed) { 24023 short[] arrayInV = new short[INPUTSIZE * 4]; 24024 Arrays.fill(arrayInV, (short) 42); 24025 inV.copyTo(arrayInV); 24026 long[] arrayOut = new long[INPUTSIZE * 4]; 24027 Arrays.fill(arrayOut, (long) 42); 24028 out.copyTo(arrayOut); 24029 StringBuilder message = new StringBuilder(); 24030 boolean errorFound = false; 24031 for (int i = 0; i < INPUTSIZE; i++) { 24032 for (int j = 0; j < 3 ; j++) { 24033 // Extract the inputs. 24034 ArgumentsHalfLong args = new ArgumentsHalfLong(); 24035 args.inV = arrayInV[i * 4 + j]; 24036 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 24037 // Figure out what the outputs should have been. 24038 CoreMathVerifier.computeConvert(args); 24039 // Validate the outputs. 24040 boolean valid = true; 24041 if (args.out != arrayOut[i * 4 + j]) { 24042 valid = false; 24043 } 24044 if (!valid) { 24045 if (!errorFound) { 24046 errorFound = true; 24047 message.append("Input inV: "); 24048 appendVariableToMessage(message, args.inV); 24049 message.append("\n"); 24050 message.append("Expected output out: "); 24051 appendVariableToMessage(message, args.out); 24052 message.append("\n"); 24053 message.append("Actual output out: "); 24054 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24055 if (args.out != arrayOut[i * 4 + j]) { 24056 message.append(" FAIL"); 24057 } 24058 message.append("\n"); 24059 message.append("Errors at"); 24060 } 24061 message.append(" ["); 24062 message.append(Integer.toString(i)); 24063 message.append(", "); 24064 message.append(Integer.toString(j)); 24065 message.append("]"); 24066 } 24067 } 24068 } 24069 assertFalse("Incorrect output for checkConvertHalf3Long3" + 24070 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24071 } 24072 24073 private void checkConvertHalf4Long4() { 24074 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613cce508839687l, -9.2188684372274053120e+18, 9.2188684372274053120e+18); 24075 try { 24076 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 24077 script.forEach_testConvertLong4Half4Long4(inV, out); 24078 verifyResultsConvertHalf4Long4(inV, out, false); 24079 out.destroy(); 24080 } catch (Exception e) { 24081 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Half4Long4: " + e.toString()); 24082 } 24083 try { 24084 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 24085 scriptRelaxed.forEach_testConvertLong4Half4Long4(inV, out); 24086 verifyResultsConvertHalf4Long4(inV, out, true); 24087 out.destroy(); 24088 } catch (Exception e) { 24089 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Half4Long4: " + e.toString()); 24090 } 24091 inV.destroy(); 24092 } 24093 24094 private void verifyResultsConvertHalf4Long4(Allocation inV, Allocation out, boolean relaxed) { 24095 short[] arrayInV = new short[INPUTSIZE * 4]; 24096 Arrays.fill(arrayInV, (short) 42); 24097 inV.copyTo(arrayInV); 24098 long[] arrayOut = new long[INPUTSIZE * 4]; 24099 Arrays.fill(arrayOut, (long) 42); 24100 out.copyTo(arrayOut); 24101 StringBuilder message = new StringBuilder(); 24102 boolean errorFound = false; 24103 for (int i = 0; i < INPUTSIZE; i++) { 24104 for (int j = 0; j < 4 ; j++) { 24105 // Extract the inputs. 24106 ArgumentsHalfLong args = new ArgumentsHalfLong(); 24107 args.inV = arrayInV[i * 4 + j]; 24108 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 24109 // Figure out what the outputs should have been. 24110 CoreMathVerifier.computeConvert(args); 24111 // Validate the outputs. 24112 boolean valid = true; 24113 if (args.out != arrayOut[i * 4 + j]) { 24114 valid = false; 24115 } 24116 if (!valid) { 24117 if (!errorFound) { 24118 errorFound = true; 24119 message.append("Input inV: "); 24120 appendVariableToMessage(message, args.inV); 24121 message.append("\n"); 24122 message.append("Expected output out: "); 24123 appendVariableToMessage(message, args.out); 24124 message.append("\n"); 24125 message.append("Actual output out: "); 24126 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24127 if (args.out != arrayOut[i * 4 + j]) { 24128 message.append(" FAIL"); 24129 } 24130 message.append("\n"); 24131 message.append("Errors at"); 24132 } 24133 message.append(" ["); 24134 message.append(Integer.toString(i)); 24135 message.append(", "); 24136 message.append(Integer.toString(j)); 24137 message.append("]"); 24138 } 24139 } 24140 } 24141 assertFalse("Incorrect output for checkConvertHalf4Long4" + 24142 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24143 } 24144 24145 public class ArgumentsHalfUlong { 24146 public short inV; 24147 public double inVDouble; 24148 public long out; 24149 } 24150 24151 private void checkConvertHalf2Ulong2() { 24152 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x75503732bc6d1b0cl, 0.0000000000000000000e+00, 1.8437736874454810624e+19); 24153 try { 24154 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 24155 script.forEach_testConvertUlong2Half2Ulong2(inV, out); 24156 verifyResultsConvertHalf2Ulong2(inV, out, false); 24157 out.destroy(); 24158 } catch (Exception e) { 24159 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Half2Ulong2: " + e.toString()); 24160 } 24161 try { 24162 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 24163 scriptRelaxed.forEach_testConvertUlong2Half2Ulong2(inV, out); 24164 verifyResultsConvertHalf2Ulong2(inV, out, true); 24165 out.destroy(); 24166 } catch (Exception e) { 24167 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Half2Ulong2: " + e.toString()); 24168 } 24169 inV.destroy(); 24170 } 24171 24172 private void verifyResultsConvertHalf2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 24173 short[] arrayInV = new short[INPUTSIZE * 2]; 24174 Arrays.fill(arrayInV, (short) 42); 24175 inV.copyTo(arrayInV); 24176 long[] arrayOut = new long[INPUTSIZE * 2]; 24177 Arrays.fill(arrayOut, (long) 42); 24178 out.copyTo(arrayOut); 24179 StringBuilder message = new StringBuilder(); 24180 boolean errorFound = false; 24181 for (int i = 0; i < INPUTSIZE; i++) { 24182 for (int j = 0; j < 2 ; j++) { 24183 // Extract the inputs. 24184 ArgumentsHalfUlong args = new ArgumentsHalfUlong(); 24185 args.inV = arrayInV[i * 2 + j]; 24186 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 24187 // Figure out what the outputs should have been. 24188 CoreMathVerifier.computeConvert(args); 24189 // Validate the outputs. 24190 boolean valid = true; 24191 if (args.out != arrayOut[i * 2 + j]) { 24192 valid = false; 24193 } 24194 if (!valid) { 24195 if (!errorFound) { 24196 errorFound = true; 24197 message.append("Input inV: "); 24198 appendVariableToMessage(message, args.inV); 24199 message.append("\n"); 24200 message.append("Expected output out: "); 24201 appendVariableToMessage(message, args.out); 24202 message.append("\n"); 24203 message.append("Actual output out: "); 24204 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24205 if (args.out != arrayOut[i * 2 + j]) { 24206 message.append(" FAIL"); 24207 } 24208 message.append("\n"); 24209 message.append("Errors at"); 24210 } 24211 message.append(" ["); 24212 message.append(Integer.toString(i)); 24213 message.append(", "); 24214 message.append(Integer.toString(j)); 24215 message.append("]"); 24216 } 24217 } 24218 } 24219 assertFalse("Incorrect output for checkConvertHalf2Ulong2" + 24220 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24221 } 24222 24223 private void checkConvertHalf3Ulong3() { 24224 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7552004db2883beal, 0.0000000000000000000e+00, 1.8437736874454810624e+19); 24225 try { 24226 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 24227 script.forEach_testConvertUlong3Half3Ulong3(inV, out); 24228 verifyResultsConvertHalf3Ulong3(inV, out, false); 24229 out.destroy(); 24230 } catch (Exception e) { 24231 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Half3Ulong3: " + e.toString()); 24232 } 24233 try { 24234 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 24235 scriptRelaxed.forEach_testConvertUlong3Half3Ulong3(inV, out); 24236 verifyResultsConvertHalf3Ulong3(inV, out, true); 24237 out.destroy(); 24238 } catch (Exception e) { 24239 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Half3Ulong3: " + e.toString()); 24240 } 24241 inV.destroy(); 24242 } 24243 24244 private void verifyResultsConvertHalf3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 24245 short[] arrayInV = new short[INPUTSIZE * 4]; 24246 Arrays.fill(arrayInV, (short) 42); 24247 inV.copyTo(arrayInV); 24248 long[] arrayOut = new long[INPUTSIZE * 4]; 24249 Arrays.fill(arrayOut, (long) 42); 24250 out.copyTo(arrayOut); 24251 StringBuilder message = new StringBuilder(); 24252 boolean errorFound = false; 24253 for (int i = 0; i < INPUTSIZE; i++) { 24254 for (int j = 0; j < 3 ; j++) { 24255 // Extract the inputs. 24256 ArgumentsHalfUlong args = new ArgumentsHalfUlong(); 24257 args.inV = arrayInV[i * 4 + j]; 24258 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 24259 // Figure out what the outputs should have been. 24260 CoreMathVerifier.computeConvert(args); 24261 // Validate the outputs. 24262 boolean valid = true; 24263 if (args.out != arrayOut[i * 4 + j]) { 24264 valid = false; 24265 } 24266 if (!valid) { 24267 if (!errorFound) { 24268 errorFound = true; 24269 message.append("Input inV: "); 24270 appendVariableToMessage(message, args.inV); 24271 message.append("\n"); 24272 message.append("Expected output out: "); 24273 appendVariableToMessage(message, args.out); 24274 message.append("\n"); 24275 message.append("Actual output out: "); 24276 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24277 if (args.out != arrayOut[i * 4 + j]) { 24278 message.append(" FAIL"); 24279 } 24280 message.append("\n"); 24281 message.append("Errors at"); 24282 } 24283 message.append(" ["); 24284 message.append(Integer.toString(i)); 24285 message.append(", "); 24286 message.append(Integer.toString(j)); 24287 message.append("]"); 24288 } 24289 } 24290 } 24291 assertFalse("Incorrect output for checkConvertHalf3Ulong3" + 24292 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24293 } 24294 24295 private void checkConvertHalf4Ulong4() { 24296 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7553c968a8a35cc8l, 0.0000000000000000000e+00, 1.8437736874454810624e+19); 24297 try { 24298 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 24299 script.forEach_testConvertUlong4Half4Ulong4(inV, out); 24300 verifyResultsConvertHalf4Ulong4(inV, out, false); 24301 out.destroy(); 24302 } catch (Exception e) { 24303 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Half4Ulong4: " + e.toString()); 24304 } 24305 try { 24306 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 24307 scriptRelaxed.forEach_testConvertUlong4Half4Ulong4(inV, out); 24308 verifyResultsConvertHalf4Ulong4(inV, out, true); 24309 out.destroy(); 24310 } catch (Exception e) { 24311 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Half4Ulong4: " + e.toString()); 24312 } 24313 inV.destroy(); 24314 } 24315 24316 private void verifyResultsConvertHalf4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 24317 short[] arrayInV = new short[INPUTSIZE * 4]; 24318 Arrays.fill(arrayInV, (short) 42); 24319 inV.copyTo(arrayInV); 24320 long[] arrayOut = new long[INPUTSIZE * 4]; 24321 Arrays.fill(arrayOut, (long) 42); 24322 out.copyTo(arrayOut); 24323 StringBuilder message = new StringBuilder(); 24324 boolean errorFound = false; 24325 for (int i = 0; i < INPUTSIZE; i++) { 24326 for (int j = 0; j < 4 ; j++) { 24327 // Extract the inputs. 24328 ArgumentsHalfUlong args = new ArgumentsHalfUlong(); 24329 args.inV = arrayInV[i * 4 + j]; 24330 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 24331 // Figure out what the outputs should have been. 24332 CoreMathVerifier.computeConvert(args); 24333 // Validate the outputs. 24334 boolean valid = true; 24335 if (args.out != arrayOut[i * 4 + j]) { 24336 valid = false; 24337 } 24338 if (!valid) { 24339 if (!errorFound) { 24340 errorFound = true; 24341 message.append("Input inV: "); 24342 appendVariableToMessage(message, args.inV); 24343 message.append("\n"); 24344 message.append("Expected output out: "); 24345 appendVariableToMessage(message, args.out); 24346 message.append("\n"); 24347 message.append("Actual output out: "); 24348 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24349 if (args.out != arrayOut[i * 4 + j]) { 24350 message.append(" FAIL"); 24351 } 24352 message.append("\n"); 24353 message.append("Errors at"); 24354 } 24355 message.append(" ["); 24356 message.append(Integer.toString(i)); 24357 message.append(", "); 24358 message.append(Integer.toString(j)); 24359 message.append("]"); 24360 } 24361 } 24362 } 24363 assertFalse("Incorrect output for checkConvertHalf4Ulong4" + 24364 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24365 } 24366 24367 public class ArgumentsFloatHalf { 24368 public float inV; 24369 public Target.Floaty out; 24370 } 24371 24372 private void checkConvertFloat2Half2() { 24373 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb38aaa314c6fl, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 24374 try { 24375 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24376 script.forEach_testConvertHalf2Float2Half2(inV, out); 24377 verifyResultsConvertFloat2Half2(inV, out, false); 24378 out.destroy(); 24379 } catch (Exception e) { 24380 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Float2Half2: " + e.toString()); 24381 } 24382 try { 24383 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24384 scriptRelaxed.forEach_testConvertHalf2Float2Half2(inV, out); 24385 verifyResultsConvertFloat2Half2(inV, out, true); 24386 out.destroy(); 24387 } catch (Exception e) { 24388 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Float2Half2: " + e.toString()); 24389 } 24390 inV.destroy(); 24391 } 24392 24393 private void verifyResultsConvertFloat2Half2(Allocation inV, Allocation out, boolean relaxed) { 24394 float[] arrayInV = new float[INPUTSIZE * 2]; 24395 Arrays.fill(arrayInV, (float) 42); 24396 inV.copyTo(arrayInV); 24397 short[] arrayOut = new short[INPUTSIZE * 2]; 24398 Arrays.fill(arrayOut, (short) 42); 24399 out.copyTo(arrayOut); 24400 StringBuilder message = new StringBuilder(); 24401 boolean errorFound = false; 24402 for (int i = 0; i < INPUTSIZE; i++) { 24403 for (int j = 0; j < 2 ; j++) { 24404 // Extract the inputs. 24405 ArgumentsFloatHalf args = new ArgumentsFloatHalf(); 24406 args.inV = arrayInV[i * 2 + j]; 24407 // Figure out what the outputs should have been. 24408 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24409 CoreMathVerifier.computeConvert(args, target); 24410 // Validate the outputs. 24411 boolean valid = true; 24412 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24413 valid = false; 24414 } 24415 if (!valid) { 24416 if (!errorFound) { 24417 errorFound = true; 24418 message.append("Input inV: "); 24419 appendVariableToMessage(message, args.inV); 24420 message.append("\n"); 24421 message.append("Expected output out: "); 24422 appendVariableToMessage(message, args.out); 24423 message.append("\n"); 24424 message.append("Actual output out: "); 24425 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24426 message.append("\n"); 24427 message.append("Actual output out (in double): "); 24428 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24429 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24430 message.append(" FAIL"); 24431 } 24432 message.append("\n"); 24433 message.append("Errors at"); 24434 } 24435 message.append(" ["); 24436 message.append(Integer.toString(i)); 24437 message.append(", "); 24438 message.append(Integer.toString(j)); 24439 message.append("]"); 24440 } 24441 } 24442 } 24443 assertFalse("Incorrect output for checkConvertFloat2Half2" + 24444 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24445 } 24446 24447 private void checkConvertFloat3Half3() { 24448 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbe2c09391163l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 24449 try { 24450 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24451 script.forEach_testConvertHalf3Float3Half3(inV, out); 24452 verifyResultsConvertFloat3Half3(inV, out, false); 24453 out.destroy(); 24454 } catch (Exception e) { 24455 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Float3Half3: " + e.toString()); 24456 } 24457 try { 24458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24459 scriptRelaxed.forEach_testConvertHalf3Float3Half3(inV, out); 24460 verifyResultsConvertFloat3Half3(inV, out, true); 24461 out.destroy(); 24462 } catch (Exception e) { 24463 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Float3Half3: " + e.toString()); 24464 } 24465 inV.destroy(); 24466 } 24467 24468 private void verifyResultsConvertFloat3Half3(Allocation inV, Allocation out, boolean relaxed) { 24469 float[] arrayInV = new float[INPUTSIZE * 4]; 24470 Arrays.fill(arrayInV, (float) 42); 24471 inV.copyTo(arrayInV); 24472 short[] arrayOut = new short[INPUTSIZE * 4]; 24473 Arrays.fill(arrayOut, (short) 42); 24474 out.copyTo(arrayOut); 24475 StringBuilder message = new StringBuilder(); 24476 boolean errorFound = false; 24477 for (int i = 0; i < INPUTSIZE; i++) { 24478 for (int j = 0; j < 3 ; j++) { 24479 // Extract the inputs. 24480 ArgumentsFloatHalf args = new ArgumentsFloatHalf(); 24481 args.inV = arrayInV[i * 4 + j]; 24482 // Figure out what the outputs should have been. 24483 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24484 CoreMathVerifier.computeConvert(args, target); 24485 // Validate the outputs. 24486 boolean valid = true; 24487 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24488 valid = false; 24489 } 24490 if (!valid) { 24491 if (!errorFound) { 24492 errorFound = true; 24493 message.append("Input inV: "); 24494 appendVariableToMessage(message, args.inV); 24495 message.append("\n"); 24496 message.append("Expected output out: "); 24497 appendVariableToMessage(message, args.out); 24498 message.append("\n"); 24499 message.append("Actual output out: "); 24500 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24501 message.append("\n"); 24502 message.append("Actual output out (in double): "); 24503 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24504 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24505 message.append(" FAIL"); 24506 } 24507 message.append("\n"); 24508 message.append("Errors at"); 24509 } 24510 message.append(" ["); 24511 message.append(Integer.toString(i)); 24512 message.append(", "); 24513 message.append(Integer.toString(j)); 24514 message.append("]"); 24515 } 24516 } 24517 } 24518 assertFalse("Incorrect output for checkConvertFloat3Half3" + 24519 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24520 } 24521 24522 private void checkConvertFloat4Half4() { 24523 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc8cd6840d657l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 24524 try { 24525 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24526 script.forEach_testConvertHalf4Float4Half4(inV, out); 24527 verifyResultsConvertFloat4Half4(inV, out, false); 24528 out.destroy(); 24529 } catch (Exception e) { 24530 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Float4Half4: " + e.toString()); 24531 } 24532 try { 24533 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24534 scriptRelaxed.forEach_testConvertHalf4Float4Half4(inV, out); 24535 verifyResultsConvertFloat4Half4(inV, out, true); 24536 out.destroy(); 24537 } catch (Exception e) { 24538 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Float4Half4: " + e.toString()); 24539 } 24540 inV.destroy(); 24541 } 24542 24543 private void verifyResultsConvertFloat4Half4(Allocation inV, Allocation out, boolean relaxed) { 24544 float[] arrayInV = new float[INPUTSIZE * 4]; 24545 Arrays.fill(arrayInV, (float) 42); 24546 inV.copyTo(arrayInV); 24547 short[] arrayOut = new short[INPUTSIZE * 4]; 24548 Arrays.fill(arrayOut, (short) 42); 24549 out.copyTo(arrayOut); 24550 StringBuilder message = new StringBuilder(); 24551 boolean errorFound = false; 24552 for (int i = 0; i < INPUTSIZE; i++) { 24553 for (int j = 0; j < 4 ; j++) { 24554 // Extract the inputs. 24555 ArgumentsFloatHalf args = new ArgumentsFloatHalf(); 24556 args.inV = arrayInV[i * 4 + j]; 24557 // Figure out what the outputs should have been. 24558 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24559 CoreMathVerifier.computeConvert(args, target); 24560 // Validate the outputs. 24561 boolean valid = true; 24562 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24563 valid = false; 24564 } 24565 if (!valid) { 24566 if (!errorFound) { 24567 errorFound = true; 24568 message.append("Input inV: "); 24569 appendVariableToMessage(message, args.inV); 24570 message.append("\n"); 24571 message.append("Expected output out: "); 24572 appendVariableToMessage(message, args.out); 24573 message.append("\n"); 24574 message.append("Actual output out: "); 24575 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24576 message.append("\n"); 24577 message.append("Actual output out (in double): "); 24578 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24579 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24580 message.append(" FAIL"); 24581 } 24582 message.append("\n"); 24583 message.append("Errors at"); 24584 } 24585 message.append(" ["); 24586 message.append(Integer.toString(i)); 24587 message.append(", "); 24588 message.append(Integer.toString(j)); 24589 message.append("]"); 24590 } 24591 } 24592 } 24593 assertFalse("Incorrect output for checkConvertFloat4Half4" + 24594 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24595 } 24596 24597 public class ArgumentsDoubleHalf { 24598 public double inV; 24599 public Target.Floaty out; 24600 } 24601 24602 private void checkConvertDouble2Half2() { 24603 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84cae6fc20024l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 24604 try { 24605 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24606 script.forEach_testConvertHalf2Double2Half2(inV, out); 24607 verifyResultsConvertDouble2Half2(inV, out, false); 24608 out.destroy(); 24609 } catch (Exception e) { 24610 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Double2Half2: " + e.toString()); 24611 } 24612 try { 24613 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24614 scriptRelaxed.forEach_testConvertHalf2Double2Half2(inV, out); 24615 verifyResultsConvertDouble2Half2(inV, out, true); 24616 out.destroy(); 24617 } catch (Exception e) { 24618 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Double2Half2: " + e.toString()); 24619 } 24620 inV.destroy(); 24621 } 24622 24623 private void verifyResultsConvertDouble2Half2(Allocation inV, Allocation out, boolean relaxed) { 24624 double[] arrayInV = new double[INPUTSIZE * 2]; 24625 Arrays.fill(arrayInV, (double) 42); 24626 inV.copyTo(arrayInV); 24627 short[] arrayOut = new short[INPUTSIZE * 2]; 24628 Arrays.fill(arrayOut, (short) 42); 24629 out.copyTo(arrayOut); 24630 StringBuilder message = new StringBuilder(); 24631 boolean errorFound = false; 24632 for (int i = 0; i < INPUTSIZE; i++) { 24633 for (int j = 0; j < 2 ; j++) { 24634 // Extract the inputs. 24635 ArgumentsDoubleHalf args = new ArgumentsDoubleHalf(); 24636 args.inV = arrayInV[i * 2 + j]; 24637 // Figure out what the outputs should have been. 24638 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24639 CoreMathVerifier.computeConvert(args, target); 24640 // Validate the outputs. 24641 boolean valid = true; 24642 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24643 valid = false; 24644 } 24645 if (!valid) { 24646 if (!errorFound) { 24647 errorFound = true; 24648 message.append("Input inV: "); 24649 appendVariableToMessage(message, args.inV); 24650 message.append("\n"); 24651 message.append("Expected output out: "); 24652 appendVariableToMessage(message, args.out); 24653 message.append("\n"); 24654 message.append("Actual output out: "); 24655 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24656 message.append("\n"); 24657 message.append("Actual output out (in double): "); 24658 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24659 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24660 message.append(" FAIL"); 24661 } 24662 message.append("\n"); 24663 message.append("Errors at"); 24664 } 24665 message.append(" ["); 24666 message.append(Integer.toString(i)); 24667 message.append(", "); 24668 message.append(Integer.toString(j)); 24669 message.append("]"); 24670 } 24671 } 24672 } 24673 assertFalse("Incorrect output for checkConvertDouble2Half2" + 24674 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24675 } 24676 24677 private void checkConvertDouble3Half3() { 24678 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf8574fcec9c518l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 24679 try { 24680 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24681 script.forEach_testConvertHalf3Double3Half3(inV, out); 24682 verifyResultsConvertDouble3Half3(inV, out, false); 24683 out.destroy(); 24684 } catch (Exception e) { 24685 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Double3Half3: " + e.toString()); 24686 } 24687 try { 24688 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24689 scriptRelaxed.forEach_testConvertHalf3Double3Half3(inV, out); 24690 verifyResultsConvertDouble3Half3(inV, out, true); 24691 out.destroy(); 24692 } catch (Exception e) { 24693 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Double3Half3: " + e.toString()); 24694 } 24695 inV.destroy(); 24696 } 24697 24698 private void verifyResultsConvertDouble3Half3(Allocation inV, Allocation out, boolean relaxed) { 24699 double[] arrayInV = new double[INPUTSIZE * 4]; 24700 Arrays.fill(arrayInV, (double) 42); 24701 inV.copyTo(arrayInV); 24702 short[] arrayOut = new short[INPUTSIZE * 4]; 24703 Arrays.fill(arrayOut, (short) 42); 24704 out.copyTo(arrayOut); 24705 StringBuilder message = new StringBuilder(); 24706 boolean errorFound = false; 24707 for (int i = 0; i < INPUTSIZE; i++) { 24708 for (int j = 0; j < 3 ; j++) { 24709 // Extract the inputs. 24710 ArgumentsDoubleHalf args = new ArgumentsDoubleHalf(); 24711 args.inV = arrayInV[i * 4 + j]; 24712 // Figure out what the outputs should have been. 24713 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24714 CoreMathVerifier.computeConvert(args, target); 24715 // Validate the outputs. 24716 boolean valid = true; 24717 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24718 valid = false; 24719 } 24720 if (!valid) { 24721 if (!errorFound) { 24722 errorFound = true; 24723 message.append("Input inV: "); 24724 appendVariableToMessage(message, args.inV); 24725 message.append("\n"); 24726 message.append("Expected output out: "); 24727 appendVariableToMessage(message, args.out); 24728 message.append("\n"); 24729 message.append("Actual output out: "); 24730 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24731 message.append("\n"); 24732 message.append("Actual output out (in double): "); 24733 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24734 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24735 message.append(" FAIL"); 24736 } 24737 message.append("\n"); 24738 message.append("Errors at"); 24739 } 24740 message.append(" ["); 24741 message.append(Integer.toString(i)); 24742 message.append(", "); 24743 message.append(Integer.toString(j)); 24744 message.append("]"); 24745 } 24746 } 24747 } 24748 assertFalse("Incorrect output for checkConvertDouble3Half3" + 24749 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24750 } 24751 24752 private void checkConvertDouble4Half4() { 24753 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf861f12dd18a0cl, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 24754 try { 24755 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24756 script.forEach_testConvertHalf4Double4Half4(inV, out); 24757 verifyResultsConvertDouble4Half4(inV, out, false); 24758 out.destroy(); 24759 } catch (Exception e) { 24760 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Double4Half4: " + e.toString()); 24761 } 24762 try { 24763 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24764 scriptRelaxed.forEach_testConvertHalf4Double4Half4(inV, out); 24765 verifyResultsConvertDouble4Half4(inV, out, true); 24766 out.destroy(); 24767 } catch (Exception e) { 24768 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Double4Half4: " + e.toString()); 24769 } 24770 inV.destroy(); 24771 } 24772 24773 private void verifyResultsConvertDouble4Half4(Allocation inV, Allocation out, boolean relaxed) { 24774 double[] arrayInV = new double[INPUTSIZE * 4]; 24775 Arrays.fill(arrayInV, (double) 42); 24776 inV.copyTo(arrayInV); 24777 short[] arrayOut = new short[INPUTSIZE * 4]; 24778 Arrays.fill(arrayOut, (short) 42); 24779 out.copyTo(arrayOut); 24780 StringBuilder message = new StringBuilder(); 24781 boolean errorFound = false; 24782 for (int i = 0; i < INPUTSIZE; i++) { 24783 for (int j = 0; j < 4 ; j++) { 24784 // Extract the inputs. 24785 ArgumentsDoubleHalf args = new ArgumentsDoubleHalf(); 24786 args.inV = arrayInV[i * 4 + j]; 24787 // Figure out what the outputs should have been. 24788 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24789 CoreMathVerifier.computeConvert(args, target); 24790 // Validate the outputs. 24791 boolean valid = true; 24792 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24793 valid = false; 24794 } 24795 if (!valid) { 24796 if (!errorFound) { 24797 errorFound = true; 24798 message.append("Input inV: "); 24799 appendVariableToMessage(message, args.inV); 24800 message.append("\n"); 24801 message.append("Expected output out: "); 24802 appendVariableToMessage(message, args.out); 24803 message.append("\n"); 24804 message.append("Actual output out: "); 24805 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24806 message.append("\n"); 24807 message.append("Actual output out (in double): "); 24808 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24809 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24810 message.append(" FAIL"); 24811 } 24812 message.append("\n"); 24813 message.append("Errors at"); 24814 } 24815 message.append(" ["); 24816 message.append(Integer.toString(i)); 24817 message.append(", "); 24818 message.append(Integer.toString(j)); 24819 message.append("]"); 24820 } 24821 } 24822 } 24823 assertFalse("Incorrect output for checkConvertDouble4Half4" + 24824 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24825 } 24826 24827 public class ArgumentsCharHalf { 24828 public byte inV; 24829 public Target.Floaty out; 24830 } 24831 24832 private void checkConvertChar2Half2() { 24833 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86188aa55c123afl, true, 7); 24834 try { 24835 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24836 script.forEach_testConvertHalf2Char2Half2(inV, out); 24837 verifyResultsConvertChar2Half2(inV, out, false); 24838 out.destroy(); 24839 } catch (Exception e) { 24840 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Char2Half2: " + e.toString()); 24841 } 24842 try { 24843 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24844 scriptRelaxed.forEach_testConvertHalf2Char2Half2(inV, out); 24845 verifyResultsConvertChar2Half2(inV, out, true); 24846 out.destroy(); 24847 } catch (Exception e) { 24848 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Char2Half2: " + e.toString()); 24849 } 24850 inV.destroy(); 24851 } 24852 24853 private void verifyResultsConvertChar2Half2(Allocation inV, Allocation out, boolean relaxed) { 24854 byte[] arrayInV = new byte[INPUTSIZE * 2]; 24855 Arrays.fill(arrayInV, (byte) 42); 24856 inV.copyTo(arrayInV); 24857 short[] arrayOut = new short[INPUTSIZE * 2]; 24858 Arrays.fill(arrayOut, (short) 42); 24859 out.copyTo(arrayOut); 24860 StringBuilder message = new StringBuilder(); 24861 boolean errorFound = false; 24862 for (int i = 0; i < INPUTSIZE; i++) { 24863 for (int j = 0; j < 2 ; j++) { 24864 // Extract the inputs. 24865 ArgumentsCharHalf args = new ArgumentsCharHalf(); 24866 args.inV = arrayInV[i * 2 + j]; 24867 // Figure out what the outputs should have been. 24868 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24869 CoreMathVerifier.computeConvert(args, target); 24870 // Validate the outputs. 24871 boolean valid = true; 24872 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24873 valid = false; 24874 } 24875 if (!valid) { 24876 if (!errorFound) { 24877 errorFound = true; 24878 message.append("Input inV: "); 24879 appendVariableToMessage(message, args.inV); 24880 message.append("\n"); 24881 message.append("Expected output out: "); 24882 appendVariableToMessage(message, args.out); 24883 message.append("\n"); 24884 message.append("Actual output out: "); 24885 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24886 message.append("\n"); 24887 message.append("Actual output out (in double): "); 24888 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24889 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24890 message.append(" FAIL"); 24891 } 24892 message.append("\n"); 24893 message.append("Errors at"); 24894 } 24895 message.append(" ["); 24896 message.append(Integer.toString(i)); 24897 message.append(", "); 24898 message.append(Integer.toString(j)); 24899 message.append("]"); 24900 } 24901 } 24902 } 24903 assertFalse("Incorrect output for checkConvertChar2Half2" + 24904 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24905 } 24906 24907 private void checkConvertChar3Half3() { 24908 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861934bb4c8e8a3l, true, 7); 24909 try { 24910 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24911 script.forEach_testConvertHalf3Char3Half3(inV, out); 24912 verifyResultsConvertChar3Half3(inV, out, false); 24913 out.destroy(); 24914 } catch (Exception e) { 24915 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Char3Half3: " + e.toString()); 24916 } 24917 try { 24918 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24919 scriptRelaxed.forEach_testConvertHalf3Char3Half3(inV, out); 24920 verifyResultsConvertChar3Half3(inV, out, true); 24921 out.destroy(); 24922 } catch (Exception e) { 24923 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Char3Half3: " + e.toString()); 24924 } 24925 inV.destroy(); 24926 } 24927 24928 private void verifyResultsConvertChar3Half3(Allocation inV, Allocation out, boolean relaxed) { 24929 byte[] arrayInV = new byte[INPUTSIZE * 4]; 24930 Arrays.fill(arrayInV, (byte) 42); 24931 inV.copyTo(arrayInV); 24932 short[] arrayOut = new short[INPUTSIZE * 4]; 24933 Arrays.fill(arrayOut, (short) 42); 24934 out.copyTo(arrayOut); 24935 StringBuilder message = new StringBuilder(); 24936 boolean errorFound = false; 24937 for (int i = 0; i < INPUTSIZE; i++) { 24938 for (int j = 0; j < 3 ; j++) { 24939 // Extract the inputs. 24940 ArgumentsCharHalf args = new ArgumentsCharHalf(); 24941 args.inV = arrayInV[i * 4 + j]; 24942 // Figure out what the outputs should have been. 24943 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24944 CoreMathVerifier.computeConvert(args, target); 24945 // Validate the outputs. 24946 boolean valid = true; 24947 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24948 valid = false; 24949 } 24950 if (!valid) { 24951 if (!errorFound) { 24952 errorFound = true; 24953 message.append("Input inV: "); 24954 appendVariableToMessage(message, args.inV); 24955 message.append("\n"); 24956 message.append("Expected output out: "); 24957 appendVariableToMessage(message, args.out); 24958 message.append("\n"); 24959 message.append("Actual output out: "); 24960 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24961 message.append("\n"); 24962 message.append("Actual output out (in double): "); 24963 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24964 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24965 message.append(" FAIL"); 24966 } 24967 message.append("\n"); 24968 message.append("Errors at"); 24969 } 24970 message.append(" ["); 24971 message.append(Integer.toString(i)); 24972 message.append(", "); 24973 message.append(Integer.toString(j)); 24974 message.append("]"); 24975 } 24976 } 24977 } 24978 assertFalse("Incorrect output for checkConvertChar3Half3" + 24979 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24980 } 24981 24982 private void checkConvertChar4Half4() { 24983 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619ded13d0ad97l, true, 7); 24984 try { 24985 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24986 script.forEach_testConvertHalf4Char4Half4(inV, out); 24987 verifyResultsConvertChar4Half4(inV, out, false); 24988 out.destroy(); 24989 } catch (Exception e) { 24990 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Char4Half4: " + e.toString()); 24991 } 24992 try { 24993 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24994 scriptRelaxed.forEach_testConvertHalf4Char4Half4(inV, out); 24995 verifyResultsConvertChar4Half4(inV, out, true); 24996 out.destroy(); 24997 } catch (Exception e) { 24998 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Char4Half4: " + e.toString()); 24999 } 25000 inV.destroy(); 25001 } 25002 25003 private void verifyResultsConvertChar4Half4(Allocation inV, Allocation out, boolean relaxed) { 25004 byte[] arrayInV = new byte[INPUTSIZE * 4]; 25005 Arrays.fill(arrayInV, (byte) 42); 25006 inV.copyTo(arrayInV); 25007 short[] arrayOut = new short[INPUTSIZE * 4]; 25008 Arrays.fill(arrayOut, (short) 42); 25009 out.copyTo(arrayOut); 25010 StringBuilder message = new StringBuilder(); 25011 boolean errorFound = false; 25012 for (int i = 0; i < INPUTSIZE; i++) { 25013 for (int j = 0; j < 4 ; j++) { 25014 // Extract the inputs. 25015 ArgumentsCharHalf args = new ArgumentsCharHalf(); 25016 args.inV = arrayInV[i * 4 + j]; 25017 // Figure out what the outputs should have been. 25018 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25019 CoreMathVerifier.computeConvert(args, target); 25020 // Validate the outputs. 25021 boolean valid = true; 25022 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25023 valid = false; 25024 } 25025 if (!valid) { 25026 if (!errorFound) { 25027 errorFound = true; 25028 message.append("Input inV: "); 25029 appendVariableToMessage(message, args.inV); 25030 message.append("\n"); 25031 message.append("Expected output out: "); 25032 appendVariableToMessage(message, args.out); 25033 message.append("\n"); 25034 message.append("Actual output out: "); 25035 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25036 message.append("\n"); 25037 message.append("Actual output out (in double): "); 25038 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25039 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25040 message.append(" FAIL"); 25041 } 25042 message.append("\n"); 25043 message.append("Errors at"); 25044 } 25045 message.append(" ["); 25046 message.append(Integer.toString(i)); 25047 message.append(", "); 25048 message.append(Integer.toString(j)); 25049 message.append("]"); 25050 } 25051 } 25052 } 25053 assertFalse("Incorrect output for checkConvertChar4Half4" + 25054 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25055 } 25056 25057 public class ArgumentsUcharHalf { 25058 public byte inV; 25059 public Target.Floaty out; 25060 } 25061 25062 private void checkConvertUchar2Half2() { 25063 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef41f7e8433030l, false, 8); 25064 try { 25065 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25066 script.forEach_testConvertHalf2Uchar2Half2(inV, out); 25067 verifyResultsConvertUchar2Half2(inV, out, false); 25068 out.destroy(); 25069 } catch (Exception e) { 25070 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uchar2Half2: " + e.toString()); 25071 } 25072 try { 25073 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25074 scriptRelaxed.forEach_testConvertHalf2Uchar2Half2(inV, out); 25075 verifyResultsConvertUchar2Half2(inV, out, true); 25076 out.destroy(); 25077 } catch (Exception e) { 25078 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uchar2Half2: " + e.toString()); 25079 } 25080 inV.destroy(); 25081 } 25082 25083 private void verifyResultsConvertUchar2Half2(Allocation inV, Allocation out, boolean relaxed) { 25084 byte[] arrayInV = new byte[INPUTSIZE * 2]; 25085 Arrays.fill(arrayInV, (byte) 42); 25086 inV.copyTo(arrayInV); 25087 short[] arrayOut = new short[INPUTSIZE * 2]; 25088 Arrays.fill(arrayOut, (short) 42); 25089 out.copyTo(arrayOut); 25090 StringBuilder message = new StringBuilder(); 25091 boolean errorFound = false; 25092 for (int i = 0; i < INPUTSIZE; i++) { 25093 for (int j = 0; j < 2 ; j++) { 25094 // Extract the inputs. 25095 ArgumentsUcharHalf args = new ArgumentsUcharHalf(); 25096 args.inV = arrayInV[i * 2 + j]; 25097 // Figure out what the outputs should have been. 25098 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25099 CoreMathVerifier.computeConvert(args, target); 25100 // Validate the outputs. 25101 boolean valid = true; 25102 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25103 valid = false; 25104 } 25105 if (!valid) { 25106 if (!errorFound) { 25107 errorFound = true; 25108 message.append("Input inV: "); 25109 appendVariableToMessage(message, args.inV); 25110 message.append("\n"); 25111 message.append("Expected output out: "); 25112 appendVariableToMessage(message, args.out); 25113 message.append("\n"); 25114 message.append("Actual output out: "); 25115 appendVariableToMessage(message, arrayOut[i * 2 + j]); 25116 message.append("\n"); 25117 message.append("Actual output out (in double): "); 25118 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 25119 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25120 message.append(" FAIL"); 25121 } 25122 message.append("\n"); 25123 message.append("Errors at"); 25124 } 25125 message.append(" ["); 25126 message.append(Integer.toString(i)); 25127 message.append(", "); 25128 message.append(Integer.toString(j)); 25129 message.append("]"); 25130 } 25131 } 25132 } 25133 assertFalse("Incorrect output for checkConvertUchar2Half2" + 25134 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25135 } 25136 25137 private void checkConvertUchar3Half3() { 25138 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4c99474af524l, false, 8); 25139 try { 25140 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25141 script.forEach_testConvertHalf3Uchar3Half3(inV, out); 25142 verifyResultsConvertUchar3Half3(inV, out, false); 25143 out.destroy(); 25144 } catch (Exception e) { 25145 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uchar3Half3: " + e.toString()); 25146 } 25147 try { 25148 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25149 scriptRelaxed.forEach_testConvertHalf3Uchar3Half3(inV, out); 25150 verifyResultsConvertUchar3Half3(inV, out, true); 25151 out.destroy(); 25152 } catch (Exception e) { 25153 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uchar3Half3: " + e.toString()); 25154 } 25155 inV.destroy(); 25156 } 25157 25158 private void verifyResultsConvertUchar3Half3(Allocation inV, Allocation out, boolean relaxed) { 25159 byte[] arrayInV = new byte[INPUTSIZE * 4]; 25160 Arrays.fill(arrayInV, (byte) 42); 25161 inV.copyTo(arrayInV); 25162 short[] arrayOut = new short[INPUTSIZE * 4]; 25163 Arrays.fill(arrayOut, (short) 42); 25164 out.copyTo(arrayOut); 25165 StringBuilder message = new StringBuilder(); 25166 boolean errorFound = false; 25167 for (int i = 0; i < INPUTSIZE; i++) { 25168 for (int j = 0; j < 3 ; j++) { 25169 // Extract the inputs. 25170 ArgumentsUcharHalf args = new ArgumentsUcharHalf(); 25171 args.inV = arrayInV[i * 4 + j]; 25172 // Figure out what the outputs should have been. 25173 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25174 CoreMathVerifier.computeConvert(args, target); 25175 // Validate the outputs. 25176 boolean valid = true; 25177 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25178 valid = false; 25179 } 25180 if (!valid) { 25181 if (!errorFound) { 25182 errorFound = true; 25183 message.append("Input inV: "); 25184 appendVariableToMessage(message, args.inV); 25185 message.append("\n"); 25186 message.append("Expected output out: "); 25187 appendVariableToMessage(message, args.out); 25188 message.append("\n"); 25189 message.append("Actual output out: "); 25190 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25191 message.append("\n"); 25192 message.append("Actual output out (in double): "); 25193 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25194 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25195 message.append(" FAIL"); 25196 } 25197 message.append("\n"); 25198 message.append("Errors at"); 25199 } 25200 message.append(" ["); 25201 message.append(Integer.toString(i)); 25202 message.append(", "); 25203 message.append(Integer.toString(j)); 25204 message.append("]"); 25205 } 25206 } 25207 } 25208 assertFalse("Incorrect output for checkConvertUchar3Half3" + 25209 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25210 } 25211 25212 private void checkConvertUchar4Half4() { 25213 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef573aa652ba18l, false, 8); 25214 try { 25215 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25216 script.forEach_testConvertHalf4Uchar4Half4(inV, out); 25217 verifyResultsConvertUchar4Half4(inV, out, false); 25218 out.destroy(); 25219 } catch (Exception e) { 25220 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uchar4Half4: " + e.toString()); 25221 } 25222 try { 25223 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25224 scriptRelaxed.forEach_testConvertHalf4Uchar4Half4(inV, out); 25225 verifyResultsConvertUchar4Half4(inV, out, true); 25226 out.destroy(); 25227 } catch (Exception e) { 25228 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uchar4Half4: " + e.toString()); 25229 } 25230 inV.destroy(); 25231 } 25232 25233 private void verifyResultsConvertUchar4Half4(Allocation inV, Allocation out, boolean relaxed) { 25234 byte[] arrayInV = new byte[INPUTSIZE * 4]; 25235 Arrays.fill(arrayInV, (byte) 42); 25236 inV.copyTo(arrayInV); 25237 short[] arrayOut = new short[INPUTSIZE * 4]; 25238 Arrays.fill(arrayOut, (short) 42); 25239 out.copyTo(arrayOut); 25240 StringBuilder message = new StringBuilder(); 25241 boolean errorFound = false; 25242 for (int i = 0; i < INPUTSIZE; i++) { 25243 for (int j = 0; j < 4 ; j++) { 25244 // Extract the inputs. 25245 ArgumentsUcharHalf args = new ArgumentsUcharHalf(); 25246 args.inV = arrayInV[i * 4 + j]; 25247 // Figure out what the outputs should have been. 25248 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25249 CoreMathVerifier.computeConvert(args, target); 25250 // Validate the outputs. 25251 boolean valid = true; 25252 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25253 valid = false; 25254 } 25255 if (!valid) { 25256 if (!errorFound) { 25257 errorFound = true; 25258 message.append("Input inV: "); 25259 appendVariableToMessage(message, args.inV); 25260 message.append("\n"); 25261 message.append("Expected output out: "); 25262 appendVariableToMessage(message, args.out); 25263 message.append("\n"); 25264 message.append("Actual output out: "); 25265 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25266 message.append("\n"); 25267 message.append("Actual output out (in double): "); 25268 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25269 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25270 message.append(" FAIL"); 25271 } 25272 message.append("\n"); 25273 message.append("Errors at"); 25274 } 25275 message.append(" ["); 25276 message.append(Integer.toString(i)); 25277 message.append(", "); 25278 message.append(Integer.toString(j)); 25279 message.append("]"); 25280 } 25281 } 25282 } 25283 assertFalse("Incorrect output for checkConvertUchar4Half4" + 25284 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25285 } 25286 25287 public class ArgumentsShortHalf { 25288 public short inV; 25289 public Target.Floaty out; 25290 } 25291 25292 private void checkConvertShort2Half2() { 25293 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab6634967ebe73l, true, 15); 25294 try { 25295 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25296 script.forEach_testConvertHalf2Short2Half2(inV, out); 25297 verifyResultsConvertShort2Half2(inV, out, false); 25298 out.destroy(); 25299 } catch (Exception e) { 25300 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Short2Half2: " + e.toString()); 25301 } 25302 try { 25303 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25304 scriptRelaxed.forEach_testConvertHalf2Short2Half2(inV, out); 25305 verifyResultsConvertShort2Half2(inV, out, true); 25306 out.destroy(); 25307 } catch (Exception e) { 25308 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Short2Half2: " + e.toString()); 25309 } 25310 inV.destroy(); 25311 } 25312 25313 private void verifyResultsConvertShort2Half2(Allocation inV, Allocation out, boolean relaxed) { 25314 short[] arrayInV = new short[INPUTSIZE * 2]; 25315 Arrays.fill(arrayInV, (short) 42); 25316 inV.copyTo(arrayInV); 25317 short[] arrayOut = new short[INPUTSIZE * 2]; 25318 Arrays.fill(arrayOut, (short) 42); 25319 out.copyTo(arrayOut); 25320 StringBuilder message = new StringBuilder(); 25321 boolean errorFound = false; 25322 for (int i = 0; i < INPUTSIZE; i++) { 25323 for (int j = 0; j < 2 ; j++) { 25324 // Extract the inputs. 25325 ArgumentsShortHalf args = new ArgumentsShortHalf(); 25326 args.inV = arrayInV[i * 2 + j]; 25327 // Figure out what the outputs should have been. 25328 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25329 CoreMathVerifier.computeConvert(args, target); 25330 // Validate the outputs. 25331 boolean valid = true; 25332 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25333 valid = false; 25334 } 25335 if (!valid) { 25336 if (!errorFound) { 25337 errorFound = true; 25338 message.append("Input inV: "); 25339 appendVariableToMessage(message, args.inV); 25340 message.append("\n"); 25341 message.append("Expected output out: "); 25342 appendVariableToMessage(message, args.out); 25343 message.append("\n"); 25344 message.append("Actual output out: "); 25345 appendVariableToMessage(message, arrayOut[i * 2 + j]); 25346 message.append("\n"); 25347 message.append("Actual output out (in double): "); 25348 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 25349 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25350 message.append(" FAIL"); 25351 } 25352 message.append("\n"); 25353 message.append("Errors at"); 25354 } 25355 message.append(" ["); 25356 message.append(Integer.toString(i)); 25357 message.append(", "); 25358 message.append(Integer.toString(j)); 25359 message.append("]"); 25360 } 25361 } 25362 } 25363 assertFalse("Incorrect output for checkConvertShort2Half2" + 25364 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25365 } 25366 25367 private void checkConvertShort3Half3() { 25368 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab70d5f5868367l, true, 15); 25369 try { 25370 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25371 script.forEach_testConvertHalf3Short3Half3(inV, out); 25372 verifyResultsConvertShort3Half3(inV, out, false); 25373 out.destroy(); 25374 } catch (Exception e) { 25375 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Short3Half3: " + e.toString()); 25376 } 25377 try { 25378 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25379 scriptRelaxed.forEach_testConvertHalf3Short3Half3(inV, out); 25380 verifyResultsConvertShort3Half3(inV, out, true); 25381 out.destroy(); 25382 } catch (Exception e) { 25383 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Short3Half3: " + e.toString()); 25384 } 25385 inV.destroy(); 25386 } 25387 25388 private void verifyResultsConvertShort3Half3(Allocation inV, Allocation out, boolean relaxed) { 25389 short[] arrayInV = new short[INPUTSIZE * 4]; 25390 Arrays.fill(arrayInV, (short) 42); 25391 inV.copyTo(arrayInV); 25392 short[] arrayOut = new short[INPUTSIZE * 4]; 25393 Arrays.fill(arrayOut, (short) 42); 25394 out.copyTo(arrayOut); 25395 StringBuilder message = new StringBuilder(); 25396 boolean errorFound = false; 25397 for (int i = 0; i < INPUTSIZE; i++) { 25398 for (int j = 0; j < 3 ; j++) { 25399 // Extract the inputs. 25400 ArgumentsShortHalf args = new ArgumentsShortHalf(); 25401 args.inV = arrayInV[i * 4 + j]; 25402 // Figure out what the outputs should have been. 25403 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25404 CoreMathVerifier.computeConvert(args, target); 25405 // Validate the outputs. 25406 boolean valid = true; 25407 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25408 valid = false; 25409 } 25410 if (!valid) { 25411 if (!errorFound) { 25412 errorFound = true; 25413 message.append("Input inV: "); 25414 appendVariableToMessage(message, args.inV); 25415 message.append("\n"); 25416 message.append("Expected output out: "); 25417 appendVariableToMessage(message, args.out); 25418 message.append("\n"); 25419 message.append("Actual output out: "); 25420 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25421 message.append("\n"); 25422 message.append("Actual output out (in double): "); 25423 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25424 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25425 message.append(" FAIL"); 25426 } 25427 message.append("\n"); 25428 message.append("Errors at"); 25429 } 25430 message.append(" ["); 25431 message.append(Integer.toString(i)); 25432 message.append(", "); 25433 message.append(Integer.toString(j)); 25434 message.append("]"); 25435 } 25436 } 25437 } 25438 assertFalse("Incorrect output for checkConvertShort3Half3" + 25439 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25440 } 25441 25442 private void checkConvertShort4Half4() { 25443 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7b77548e485bl, true, 15); 25444 try { 25445 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25446 script.forEach_testConvertHalf4Short4Half4(inV, out); 25447 verifyResultsConvertShort4Half4(inV, out, false); 25448 out.destroy(); 25449 } catch (Exception e) { 25450 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Short4Half4: " + e.toString()); 25451 } 25452 try { 25453 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25454 scriptRelaxed.forEach_testConvertHalf4Short4Half4(inV, out); 25455 verifyResultsConvertShort4Half4(inV, out, true); 25456 out.destroy(); 25457 } catch (Exception e) { 25458 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Short4Half4: " + e.toString()); 25459 } 25460 inV.destroy(); 25461 } 25462 25463 private void verifyResultsConvertShort4Half4(Allocation inV, Allocation out, boolean relaxed) { 25464 short[] arrayInV = new short[INPUTSIZE * 4]; 25465 Arrays.fill(arrayInV, (short) 42); 25466 inV.copyTo(arrayInV); 25467 short[] arrayOut = new short[INPUTSIZE * 4]; 25468 Arrays.fill(arrayOut, (short) 42); 25469 out.copyTo(arrayOut); 25470 StringBuilder message = new StringBuilder(); 25471 boolean errorFound = false; 25472 for (int i = 0; i < INPUTSIZE; i++) { 25473 for (int j = 0; j < 4 ; j++) { 25474 // Extract the inputs. 25475 ArgumentsShortHalf args = new ArgumentsShortHalf(); 25476 args.inV = arrayInV[i * 4 + j]; 25477 // Figure out what the outputs should have been. 25478 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25479 CoreMathVerifier.computeConvert(args, target); 25480 // Validate the outputs. 25481 boolean valid = true; 25482 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25483 valid = false; 25484 } 25485 if (!valid) { 25486 if (!errorFound) { 25487 errorFound = true; 25488 message.append("Input inV: "); 25489 appendVariableToMessage(message, args.inV); 25490 message.append("\n"); 25491 message.append("Expected output out: "); 25492 appendVariableToMessage(message, args.out); 25493 message.append("\n"); 25494 message.append("Actual output out: "); 25495 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25496 message.append("\n"); 25497 message.append("Actual output out (in double): "); 25498 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25499 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25500 message.append(" FAIL"); 25501 } 25502 message.append("\n"); 25503 message.append("Errors at"); 25504 } 25505 message.append(" ["); 25506 message.append(Integer.toString(i)); 25507 message.append(", "); 25508 message.append(Integer.toString(j)); 25509 message.append("]"); 25510 } 25511 } 25512 } 25513 assertFalse("Incorrect output for checkConvertShort4Half4" + 25514 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25515 } 25516 25517 public class ArgumentsUshortHalf { 25518 public short inV; 25519 public Target.Floaty out; 25520 } 25521 25522 private void checkConvertUshort2Half2() { 25523 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79863c3256d81el, false, 16); 25524 try { 25525 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25526 script.forEach_testConvertHalf2Ushort2Half2(inV, out); 25527 verifyResultsConvertUshort2Half2(inV, out, false); 25528 out.destroy(); 25529 } catch (Exception e) { 25530 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ushort2Half2: " + e.toString()); 25531 } 25532 try { 25533 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25534 scriptRelaxed.forEach_testConvertHalf2Ushort2Half2(inV, out); 25535 verifyResultsConvertUshort2Half2(inV, out, true); 25536 out.destroy(); 25537 } catch (Exception e) { 25538 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ushort2Half2: " + e.toString()); 25539 } 25540 inV.destroy(); 25541 } 25542 25543 private void verifyResultsConvertUshort2Half2(Allocation inV, Allocation out, boolean relaxed) { 25544 short[] arrayInV = new short[INPUTSIZE * 2]; 25545 Arrays.fill(arrayInV, (short) 42); 25546 inV.copyTo(arrayInV); 25547 short[] arrayOut = new short[INPUTSIZE * 2]; 25548 Arrays.fill(arrayOut, (short) 42); 25549 out.copyTo(arrayOut); 25550 StringBuilder message = new StringBuilder(); 25551 boolean errorFound = false; 25552 for (int i = 0; i < INPUTSIZE; i++) { 25553 for (int j = 0; j < 2 ; j++) { 25554 // Extract the inputs. 25555 ArgumentsUshortHalf args = new ArgumentsUshortHalf(); 25556 args.inV = arrayInV[i * 2 + j]; 25557 // Figure out what the outputs should have been. 25558 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25559 CoreMathVerifier.computeConvert(args, target); 25560 // Validate the outputs. 25561 boolean valid = true; 25562 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25563 valid = false; 25564 } 25565 if (!valid) { 25566 if (!errorFound) { 25567 errorFound = true; 25568 message.append("Input inV: "); 25569 appendVariableToMessage(message, args.inV); 25570 message.append("\n"); 25571 message.append("Expected output out: "); 25572 appendVariableToMessage(message, args.out); 25573 message.append("\n"); 25574 message.append("Actual output out: "); 25575 appendVariableToMessage(message, arrayOut[i * 2 + j]); 25576 message.append("\n"); 25577 message.append("Actual output out (in double): "); 25578 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 25579 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25580 message.append(" FAIL"); 25581 } 25582 message.append("\n"); 25583 message.append("Errors at"); 25584 } 25585 message.append(" ["); 25586 message.append(Integer.toString(i)); 25587 message.append(", "); 25588 message.append(Integer.toString(j)); 25589 message.append("]"); 25590 } 25591 } 25592 } 25593 assertFalse("Incorrect output for checkConvertUshort2Half2" + 25594 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25595 } 25596 25597 private void checkConvertUshort3Half3() { 25598 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d7990dd915e9d12l, false, 16); 25599 try { 25600 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25601 script.forEach_testConvertHalf3Ushort3Half3(inV, out); 25602 verifyResultsConvertUshort3Half3(inV, out, false); 25603 out.destroy(); 25604 } catch (Exception e) { 25605 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ushort3Half3: " + e.toString()); 25606 } 25607 try { 25608 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25609 scriptRelaxed.forEach_testConvertHalf3Ushort3Half3(inV, out); 25610 verifyResultsConvertUshort3Half3(inV, out, true); 25611 out.destroy(); 25612 } catch (Exception e) { 25613 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ushort3Half3: " + e.toString()); 25614 } 25615 inV.destroy(); 25616 } 25617 25618 private void verifyResultsConvertUshort3Half3(Allocation inV, Allocation out, boolean relaxed) { 25619 short[] arrayInV = new short[INPUTSIZE * 4]; 25620 Arrays.fill(arrayInV, (short) 42); 25621 inV.copyTo(arrayInV); 25622 short[] arrayOut = new short[INPUTSIZE * 4]; 25623 Arrays.fill(arrayOut, (short) 42); 25624 out.copyTo(arrayOut); 25625 StringBuilder message = new StringBuilder(); 25626 boolean errorFound = false; 25627 for (int i = 0; i < INPUTSIZE; i++) { 25628 for (int j = 0; j < 3 ; j++) { 25629 // Extract the inputs. 25630 ArgumentsUshortHalf args = new ArgumentsUshortHalf(); 25631 args.inV = arrayInV[i * 4 + j]; 25632 // Figure out what the outputs should have been. 25633 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25634 CoreMathVerifier.computeConvert(args, target); 25635 // Validate the outputs. 25636 boolean valid = true; 25637 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25638 valid = false; 25639 } 25640 if (!valid) { 25641 if (!errorFound) { 25642 errorFound = true; 25643 message.append("Input inV: "); 25644 appendVariableToMessage(message, args.inV); 25645 message.append("\n"); 25646 message.append("Expected output out: "); 25647 appendVariableToMessage(message, args.out); 25648 message.append("\n"); 25649 message.append("Actual output out: "); 25650 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25651 message.append("\n"); 25652 message.append("Actual output out (in double): "); 25653 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25654 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25655 message.append(" FAIL"); 25656 } 25657 message.append("\n"); 25658 message.append("Errors at"); 25659 } 25660 message.append(" ["); 25661 message.append(Integer.toString(i)); 25662 message.append(", "); 25663 message.append(Integer.toString(j)); 25664 message.append("]"); 25665 } 25666 } 25667 } 25668 assertFalse("Incorrect output for checkConvertUshort3Half3" + 25669 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25670 } 25671 25672 private void checkConvertUshort4Half4() { 25673 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799b7ef0666206l, false, 16); 25674 try { 25675 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25676 script.forEach_testConvertHalf4Ushort4Half4(inV, out); 25677 verifyResultsConvertUshort4Half4(inV, out, false); 25678 out.destroy(); 25679 } catch (Exception e) { 25680 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ushort4Half4: " + e.toString()); 25681 } 25682 try { 25683 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25684 scriptRelaxed.forEach_testConvertHalf4Ushort4Half4(inV, out); 25685 verifyResultsConvertUshort4Half4(inV, out, true); 25686 out.destroy(); 25687 } catch (Exception e) { 25688 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ushort4Half4: " + e.toString()); 25689 } 25690 inV.destroy(); 25691 } 25692 25693 private void verifyResultsConvertUshort4Half4(Allocation inV, Allocation out, boolean relaxed) { 25694 short[] arrayInV = new short[INPUTSIZE * 4]; 25695 Arrays.fill(arrayInV, (short) 42); 25696 inV.copyTo(arrayInV); 25697 short[] arrayOut = new short[INPUTSIZE * 4]; 25698 Arrays.fill(arrayOut, (short) 42); 25699 out.copyTo(arrayOut); 25700 StringBuilder message = new StringBuilder(); 25701 boolean errorFound = false; 25702 for (int i = 0; i < INPUTSIZE; i++) { 25703 for (int j = 0; j < 4 ; j++) { 25704 // Extract the inputs. 25705 ArgumentsUshortHalf args = new ArgumentsUshortHalf(); 25706 args.inV = arrayInV[i * 4 + j]; 25707 // Figure out what the outputs should have been. 25708 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25709 CoreMathVerifier.computeConvert(args, target); 25710 // Validate the outputs. 25711 boolean valid = true; 25712 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25713 valid = false; 25714 } 25715 if (!valid) { 25716 if (!errorFound) { 25717 errorFound = true; 25718 message.append("Input inV: "); 25719 appendVariableToMessage(message, args.inV); 25720 message.append("\n"); 25721 message.append("Expected output out: "); 25722 appendVariableToMessage(message, args.out); 25723 message.append("\n"); 25724 message.append("Actual output out: "); 25725 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25726 message.append("\n"); 25727 message.append("Actual output out (in double): "); 25728 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25729 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25730 message.append(" FAIL"); 25731 } 25732 message.append("\n"); 25733 message.append("Errors at"); 25734 } 25735 message.append(" ["); 25736 message.append(Integer.toString(i)); 25737 message.append(", "); 25738 message.append(Integer.toString(j)); 25739 message.append("]"); 25740 } 25741 } 25742 } 25743 assertFalse("Incorrect output for checkConvertUshort4Half4" + 25744 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25745 } 25746 25747 public class ArgumentsIntHalf { 25748 public int inV; 25749 public Target.Floaty out; 25750 } 25751 25752 private void checkConvertInt2Half2() { 25753 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f5279b6fb0cecl, true, 31); 25754 try { 25755 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25756 script.forEach_testConvertHalf2Int2Half2(inV, out); 25757 verifyResultsConvertInt2Half2(inV, out, false); 25758 out.destroy(); 25759 } catch (Exception e) { 25760 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Int2Half2: " + e.toString()); 25761 } 25762 try { 25763 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25764 scriptRelaxed.forEach_testConvertHalf2Int2Half2(inV, out); 25765 verifyResultsConvertInt2Half2(inV, out, true); 25766 out.destroy(); 25767 } catch (Exception e) { 25768 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Int2Half2: " + e.toString()); 25769 } 25770 inV.destroy(); 25771 } 25772 25773 private void verifyResultsConvertInt2Half2(Allocation inV, Allocation out, boolean relaxed) { 25774 int[] arrayInV = new int[INPUTSIZE * 2]; 25775 Arrays.fill(arrayInV, (int) 42); 25776 inV.copyTo(arrayInV); 25777 short[] arrayOut = new short[INPUTSIZE * 2]; 25778 Arrays.fill(arrayOut, (short) 42); 25779 out.copyTo(arrayOut); 25780 StringBuilder message = new StringBuilder(); 25781 boolean errorFound = false; 25782 for (int i = 0; i < INPUTSIZE; i++) { 25783 for (int j = 0; j < 2 ; j++) { 25784 // Extract the inputs. 25785 ArgumentsIntHalf args = new ArgumentsIntHalf(); 25786 args.inV = arrayInV[i * 2 + j]; 25787 // Figure out what the outputs should have been. 25788 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25789 CoreMathVerifier.computeConvert(args, target); 25790 // Validate the outputs. 25791 boolean valid = true; 25792 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25793 valid = false; 25794 } 25795 if (!valid) { 25796 if (!errorFound) { 25797 errorFound = true; 25798 message.append("Input inV: "); 25799 appendVariableToMessage(message, args.inV); 25800 message.append("\n"); 25801 message.append("Expected output out: "); 25802 appendVariableToMessage(message, args.out); 25803 message.append("\n"); 25804 message.append("Actual output out: "); 25805 appendVariableToMessage(message, arrayOut[i * 2 + j]); 25806 message.append("\n"); 25807 message.append("Actual output out (in double): "); 25808 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 25809 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25810 message.append(" FAIL"); 25811 } 25812 message.append("\n"); 25813 message.append("Errors at"); 25814 } 25815 message.append(" ["); 25816 message.append(Integer.toString(i)); 25817 message.append(", "); 25818 message.append(Integer.toString(j)); 25819 message.append("]"); 25820 } 25821 } 25822 } 25823 assertFalse("Incorrect output for checkConvertInt2Half2" + 25824 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25825 } 25826 25827 private void checkConvertInt3Half3() { 25828 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5d1b1602d1e0l, true, 31); 25829 try { 25830 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25831 script.forEach_testConvertHalf3Int3Half3(inV, out); 25832 verifyResultsConvertInt3Half3(inV, out, false); 25833 out.destroy(); 25834 } catch (Exception e) { 25835 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Int3Half3: " + e.toString()); 25836 } 25837 try { 25838 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25839 scriptRelaxed.forEach_testConvertHalf3Int3Half3(inV, out); 25840 verifyResultsConvertInt3Half3(inV, out, true); 25841 out.destroy(); 25842 } catch (Exception e) { 25843 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Int3Half3: " + e.toString()); 25844 } 25845 inV.destroy(); 25846 } 25847 25848 private void verifyResultsConvertInt3Half3(Allocation inV, Allocation out, boolean relaxed) { 25849 int[] arrayInV = new int[INPUTSIZE * 4]; 25850 Arrays.fill(arrayInV, (int) 42); 25851 inV.copyTo(arrayInV); 25852 short[] arrayOut = new short[INPUTSIZE * 4]; 25853 Arrays.fill(arrayOut, (short) 42); 25854 out.copyTo(arrayOut); 25855 StringBuilder message = new StringBuilder(); 25856 boolean errorFound = false; 25857 for (int i = 0; i < INPUTSIZE; i++) { 25858 for (int j = 0; j < 3 ; j++) { 25859 // Extract the inputs. 25860 ArgumentsIntHalf args = new ArgumentsIntHalf(); 25861 args.inV = arrayInV[i * 4 + j]; 25862 // Figure out what the outputs should have been. 25863 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25864 CoreMathVerifier.computeConvert(args, target); 25865 // Validate the outputs. 25866 boolean valid = true; 25867 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25868 valid = false; 25869 } 25870 if (!valid) { 25871 if (!errorFound) { 25872 errorFound = true; 25873 message.append("Input inV: "); 25874 appendVariableToMessage(message, args.inV); 25875 message.append("\n"); 25876 message.append("Expected output out: "); 25877 appendVariableToMessage(message, args.out); 25878 message.append("\n"); 25879 message.append("Actual output out: "); 25880 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25881 message.append("\n"); 25882 message.append("Actual output out (in double): "); 25883 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25884 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25885 message.append(" FAIL"); 25886 } 25887 message.append("\n"); 25888 message.append("Errors at"); 25889 } 25890 message.append(" ["); 25891 message.append(Integer.toString(i)); 25892 message.append(", "); 25893 message.append(Integer.toString(j)); 25894 message.append("]"); 25895 } 25896 } 25897 } 25898 assertFalse("Incorrect output for checkConvertInt3Half3" + 25899 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25900 } 25901 25902 private void checkConvertInt4Half4() { 25903 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f67bc750a96d4l, true, 31); 25904 try { 25905 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25906 script.forEach_testConvertHalf4Int4Half4(inV, out); 25907 verifyResultsConvertInt4Half4(inV, out, false); 25908 out.destroy(); 25909 } catch (Exception e) { 25910 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Int4Half4: " + e.toString()); 25911 } 25912 try { 25913 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25914 scriptRelaxed.forEach_testConvertHalf4Int4Half4(inV, out); 25915 verifyResultsConvertInt4Half4(inV, out, true); 25916 out.destroy(); 25917 } catch (Exception e) { 25918 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Int4Half4: " + e.toString()); 25919 } 25920 inV.destroy(); 25921 } 25922 25923 private void verifyResultsConvertInt4Half4(Allocation inV, Allocation out, boolean relaxed) { 25924 int[] arrayInV = new int[INPUTSIZE * 4]; 25925 Arrays.fill(arrayInV, (int) 42); 25926 inV.copyTo(arrayInV); 25927 short[] arrayOut = new short[INPUTSIZE * 4]; 25928 Arrays.fill(arrayOut, (short) 42); 25929 out.copyTo(arrayOut); 25930 StringBuilder message = new StringBuilder(); 25931 boolean errorFound = false; 25932 for (int i = 0; i < INPUTSIZE; i++) { 25933 for (int j = 0; j < 4 ; j++) { 25934 // Extract the inputs. 25935 ArgumentsIntHalf args = new ArgumentsIntHalf(); 25936 args.inV = arrayInV[i * 4 + j]; 25937 // Figure out what the outputs should have been. 25938 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25939 CoreMathVerifier.computeConvert(args, target); 25940 // Validate the outputs. 25941 boolean valid = true; 25942 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25943 valid = false; 25944 } 25945 if (!valid) { 25946 if (!errorFound) { 25947 errorFound = true; 25948 message.append("Input inV: "); 25949 appendVariableToMessage(message, args.inV); 25950 message.append("\n"); 25951 message.append("Expected output out: "); 25952 appendVariableToMessage(message, args.out); 25953 message.append("\n"); 25954 message.append("Actual output out: "); 25955 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25956 message.append("\n"); 25957 message.append("Actual output out (in double): "); 25958 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25959 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25960 message.append(" FAIL"); 25961 } 25962 message.append("\n"); 25963 message.append("Errors at"); 25964 } 25965 message.append(" ["); 25966 message.append(Integer.toString(i)); 25967 message.append(", "); 25968 message.append(Integer.toString(j)); 25969 message.append("]"); 25970 } 25971 } 25972 } 25973 assertFalse("Incorrect output for checkConvertInt4Half4" + 25974 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25975 } 25976 25977 public class ArgumentsUintHalf { 25978 public int inV; 25979 public Target.Floaty out; 25980 } 25981 25982 private void checkConvertUint2Half2() { 25983 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0963b46f30efl, false, 32); 25984 try { 25985 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25986 script.forEach_testConvertHalf2Uint2Half2(inV, out); 25987 verifyResultsConvertUint2Half2(inV, out, false); 25988 out.destroy(); 25989 } catch (Exception e) { 25990 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uint2Half2: " + e.toString()); 25991 } 25992 try { 25993 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25994 scriptRelaxed.forEach_testConvertHalf2Uint2Half2(inV, out); 25995 verifyResultsConvertUint2Half2(inV, out, true); 25996 out.destroy(); 25997 } catch (Exception e) { 25998 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uint2Half2: " + e.toString()); 25999 } 26000 inV.destroy(); 26001 } 26002 26003 private void verifyResultsConvertUint2Half2(Allocation inV, Allocation out, boolean relaxed) { 26004 int[] arrayInV = new int[INPUTSIZE * 2]; 26005 Arrays.fill(arrayInV, (int) 42); 26006 inV.copyTo(arrayInV); 26007 short[] arrayOut = new short[INPUTSIZE * 2]; 26008 Arrays.fill(arrayOut, (short) 42); 26009 out.copyTo(arrayOut); 26010 StringBuilder message = new StringBuilder(); 26011 boolean errorFound = false; 26012 for (int i = 0; i < INPUTSIZE; i++) { 26013 for (int j = 0; j < 2 ; j++) { 26014 // Extract the inputs. 26015 ArgumentsUintHalf args = new ArgumentsUintHalf(); 26016 args.inV = arrayInV[i * 2 + j]; 26017 // Figure out what the outputs should have been. 26018 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26019 CoreMathVerifier.computeConvert(args, target); 26020 // Validate the outputs. 26021 boolean valid = true; 26022 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 26023 valid = false; 26024 } 26025 if (!valid) { 26026 if (!errorFound) { 26027 errorFound = true; 26028 message.append("Input inV: "); 26029 appendVariableToMessage(message, args.inV); 26030 message.append("\n"); 26031 message.append("Expected output out: "); 26032 appendVariableToMessage(message, args.out); 26033 message.append("\n"); 26034 message.append("Actual output out: "); 26035 appendVariableToMessage(message, arrayOut[i * 2 + j]); 26036 message.append("\n"); 26037 message.append("Actual output out (in double): "); 26038 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 26039 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 26040 message.append(" FAIL"); 26041 } 26042 message.append("\n"); 26043 message.append("Errors at"); 26044 } 26045 message.append(" ["); 26046 message.append(Integer.toString(i)); 26047 message.append(", "); 26048 message.append(Integer.toString(j)); 26049 message.append("]"); 26050 } 26051 } 26052 } 26053 assertFalse("Incorrect output for checkConvertUint2Half2" + 26054 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26055 } 26056 26057 private void checkConvertUint3Half3() { 26058 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d14051376f5e3l, false, 32); 26059 try { 26060 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 26061 script.forEach_testConvertHalf3Uint3Half3(inV, out); 26062 verifyResultsConvertUint3Half3(inV, out, false); 26063 out.destroy(); 26064 } catch (Exception e) { 26065 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uint3Half3: " + e.toString()); 26066 } 26067 try { 26068 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 26069 scriptRelaxed.forEach_testConvertHalf3Uint3Half3(inV, out); 26070 verifyResultsConvertUint3Half3(inV, out, true); 26071 out.destroy(); 26072 } catch (Exception e) { 26073 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uint3Half3: " + e.toString()); 26074 } 26075 inV.destroy(); 26076 } 26077 26078 private void verifyResultsConvertUint3Half3(Allocation inV, Allocation out, boolean relaxed) { 26079 int[] arrayInV = new int[INPUTSIZE * 4]; 26080 Arrays.fill(arrayInV, (int) 42); 26081 inV.copyTo(arrayInV); 26082 short[] arrayOut = new short[INPUTSIZE * 4]; 26083 Arrays.fill(arrayOut, (short) 42); 26084 out.copyTo(arrayOut); 26085 StringBuilder message = new StringBuilder(); 26086 boolean errorFound = false; 26087 for (int i = 0; i < INPUTSIZE; i++) { 26088 for (int j = 0; j < 3 ; j++) { 26089 // Extract the inputs. 26090 ArgumentsUintHalf args = new ArgumentsUintHalf(); 26091 args.inV = arrayInV[i * 4 + j]; 26092 // Figure out what the outputs should have been. 26093 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26094 CoreMathVerifier.computeConvert(args, target); 26095 // Validate the outputs. 26096 boolean valid = true; 26097 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26098 valid = false; 26099 } 26100 if (!valid) { 26101 if (!errorFound) { 26102 errorFound = true; 26103 message.append("Input inV: "); 26104 appendVariableToMessage(message, args.inV); 26105 message.append("\n"); 26106 message.append("Expected output out: "); 26107 appendVariableToMessage(message, args.out); 26108 message.append("\n"); 26109 message.append("Actual output out: "); 26110 appendVariableToMessage(message, arrayOut[i * 4 + j]); 26111 message.append("\n"); 26112 message.append("Actual output out (in double): "); 26113 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 26114 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26115 message.append(" FAIL"); 26116 } 26117 message.append("\n"); 26118 message.append("Errors at"); 26119 } 26120 message.append(" ["); 26121 message.append(Integer.toString(i)); 26122 message.append(", "); 26123 message.append(Integer.toString(j)); 26124 message.append("]"); 26125 } 26126 } 26127 } 26128 assertFalse("Incorrect output for checkConvertUint3Half3" + 26129 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26130 } 26131 26132 private void checkConvertUint4Half4() { 26133 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1ea6727ebad7l, false, 32); 26134 try { 26135 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 26136 script.forEach_testConvertHalf4Uint4Half4(inV, out); 26137 verifyResultsConvertUint4Half4(inV, out, false); 26138 out.destroy(); 26139 } catch (Exception e) { 26140 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uint4Half4: " + e.toString()); 26141 } 26142 try { 26143 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 26144 scriptRelaxed.forEach_testConvertHalf4Uint4Half4(inV, out); 26145 verifyResultsConvertUint4Half4(inV, out, true); 26146 out.destroy(); 26147 } catch (Exception e) { 26148 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uint4Half4: " + e.toString()); 26149 } 26150 inV.destroy(); 26151 } 26152 26153 private void verifyResultsConvertUint4Half4(Allocation inV, Allocation out, boolean relaxed) { 26154 int[] arrayInV = new int[INPUTSIZE * 4]; 26155 Arrays.fill(arrayInV, (int) 42); 26156 inV.copyTo(arrayInV); 26157 short[] arrayOut = new short[INPUTSIZE * 4]; 26158 Arrays.fill(arrayOut, (short) 42); 26159 out.copyTo(arrayOut); 26160 StringBuilder message = new StringBuilder(); 26161 boolean errorFound = false; 26162 for (int i = 0; i < INPUTSIZE; i++) { 26163 for (int j = 0; j < 4 ; j++) { 26164 // Extract the inputs. 26165 ArgumentsUintHalf args = new ArgumentsUintHalf(); 26166 args.inV = arrayInV[i * 4 + j]; 26167 // Figure out what the outputs should have been. 26168 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26169 CoreMathVerifier.computeConvert(args, target); 26170 // Validate the outputs. 26171 boolean valid = true; 26172 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26173 valid = false; 26174 } 26175 if (!valid) { 26176 if (!errorFound) { 26177 errorFound = true; 26178 message.append("Input inV: "); 26179 appendVariableToMessage(message, args.inV); 26180 message.append("\n"); 26181 message.append("Expected output out: "); 26182 appendVariableToMessage(message, args.out); 26183 message.append("\n"); 26184 message.append("Actual output out: "); 26185 appendVariableToMessage(message, arrayOut[i * 4 + j]); 26186 message.append("\n"); 26187 message.append("Actual output out (in double): "); 26188 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 26189 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26190 message.append(" FAIL"); 26191 } 26192 message.append("\n"); 26193 message.append("Errors at"); 26194 } 26195 message.append(" ["); 26196 message.append(Integer.toString(i)); 26197 message.append(", "); 26198 message.append(Integer.toString(j)); 26199 message.append("]"); 26200 } 26201 } 26202 } 26203 assertFalse("Incorrect output for checkConvertUint4Half4" + 26204 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26205 } 26206 26207 public class ArgumentsLongHalf { 26208 public long inV; 26209 public Target.Floaty out; 26210 } 26211 26212 private void checkConvertLong2Half2() { 26213 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c4f5f4d265b9l, true, 63); 26214 try { 26215 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 26216 script.forEach_testConvertHalf2Long2Half2(inV, out); 26217 verifyResultsConvertLong2Half2(inV, out, false); 26218 out.destroy(); 26219 } catch (Exception e) { 26220 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Long2Half2: " + e.toString()); 26221 } 26222 try { 26223 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 26224 scriptRelaxed.forEach_testConvertHalf2Long2Half2(inV, out); 26225 verifyResultsConvertLong2Half2(inV, out, true); 26226 out.destroy(); 26227 } catch (Exception e) { 26228 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Long2Half2: " + e.toString()); 26229 } 26230 inV.destroy(); 26231 } 26232 26233 private void verifyResultsConvertLong2Half2(Allocation inV, Allocation out, boolean relaxed) { 26234 long[] arrayInV = new long[INPUTSIZE * 2]; 26235 Arrays.fill(arrayInV, (long) 42); 26236 inV.copyTo(arrayInV); 26237 short[] arrayOut = new short[INPUTSIZE * 2]; 26238 Arrays.fill(arrayOut, (short) 42); 26239 out.copyTo(arrayOut); 26240 StringBuilder message = new StringBuilder(); 26241 boolean errorFound = false; 26242 for (int i = 0; i < INPUTSIZE; i++) { 26243 for (int j = 0; j < 2 ; j++) { 26244 // Extract the inputs. 26245 ArgumentsLongHalf args = new ArgumentsLongHalf(); 26246 args.inV = arrayInV[i * 2 + j]; 26247 // Figure out what the outputs should have been. 26248 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26249 CoreMathVerifier.computeConvert(args, target); 26250 // Validate the outputs. 26251 boolean valid = true; 26252 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 26253 valid = false; 26254 } 26255 if (!valid) { 26256 if (!errorFound) { 26257 errorFound = true; 26258 message.append("Input inV: "); 26259 appendVariableToMessage(message, args.inV); 26260 message.append("\n"); 26261 message.append("Expected output out: "); 26262 appendVariableToMessage(message, args.out); 26263 message.append("\n"); 26264 message.append("Actual output out: "); 26265 appendVariableToMessage(message, arrayOut[i * 2 + j]); 26266 message.append("\n"); 26267 message.append("Actual output out (in double): "); 26268 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 26269 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 26270 message.append(" FAIL"); 26271 } 26272 message.append("\n"); 26273 message.append("Errors at"); 26274 } 26275 message.append(" ["); 26276 message.append(Integer.toString(i)); 26277 message.append(", "); 26278 message.append(Integer.toString(j)); 26279 message.append("]"); 26280 } 26281 } 26282 } 26283 assertFalse("Incorrect output for checkConvertLong2Half2" + 26284 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26285 } 26286 26287 private void checkConvertLong3Half3() { 26288 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570cf9753da2aadl, true, 63); 26289 try { 26290 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 26291 script.forEach_testConvertHalf3Long3Half3(inV, out); 26292 verifyResultsConvertLong3Half3(inV, out, false); 26293 out.destroy(); 26294 } catch (Exception e) { 26295 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Long3Half3: " + e.toString()); 26296 } 26297 try { 26298 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 26299 scriptRelaxed.forEach_testConvertHalf3Long3Half3(inV, out); 26300 verifyResultsConvertLong3Half3(inV, out, true); 26301 out.destroy(); 26302 } catch (Exception e) { 26303 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Long3Half3: " + e.toString()); 26304 } 26305 inV.destroy(); 26306 } 26307 26308 private void verifyResultsConvertLong3Half3(Allocation inV, Allocation out, boolean relaxed) { 26309 long[] arrayInV = new long[INPUTSIZE * 4]; 26310 Arrays.fill(arrayInV, (long) 42); 26311 inV.copyTo(arrayInV); 26312 short[] arrayOut = new short[INPUTSIZE * 4]; 26313 Arrays.fill(arrayOut, (short) 42); 26314 out.copyTo(arrayOut); 26315 StringBuilder message = new StringBuilder(); 26316 boolean errorFound = false; 26317 for (int i = 0; i < INPUTSIZE; i++) { 26318 for (int j = 0; j < 3 ; j++) { 26319 // Extract the inputs. 26320 ArgumentsLongHalf args = new ArgumentsLongHalf(); 26321 args.inV = arrayInV[i * 4 + j]; 26322 // Figure out what the outputs should have been. 26323 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26324 CoreMathVerifier.computeConvert(args, target); 26325 // Validate the outputs. 26326 boolean valid = true; 26327 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26328 valid = false; 26329 } 26330 if (!valid) { 26331 if (!errorFound) { 26332 errorFound = true; 26333 message.append("Input inV: "); 26334 appendVariableToMessage(message, args.inV); 26335 message.append("\n"); 26336 message.append("Expected output out: "); 26337 appendVariableToMessage(message, args.out); 26338 message.append("\n"); 26339 message.append("Actual output out: "); 26340 appendVariableToMessage(message, arrayOut[i * 4 + j]); 26341 message.append("\n"); 26342 message.append("Actual output out (in double): "); 26343 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 26344 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26345 message.append(" FAIL"); 26346 } 26347 message.append("\n"); 26348 message.append("Errors at"); 26349 } 26350 message.append(" ["); 26351 message.append(Integer.toString(i)); 26352 message.append(", "); 26353 message.append(Integer.toString(j)); 26354 message.append("]"); 26355 } 26356 } 26357 } 26358 assertFalse("Incorrect output for checkConvertLong3Half3" + 26359 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26360 } 26361 26362 private void checkConvertLong4Half4() { 26363 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570da38b2e1efa1l, true, 63); 26364 try { 26365 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 26366 script.forEach_testConvertHalf4Long4Half4(inV, out); 26367 verifyResultsConvertLong4Half4(inV, out, false); 26368 out.destroy(); 26369 } catch (Exception e) { 26370 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Long4Half4: " + e.toString()); 26371 } 26372 try { 26373 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 26374 scriptRelaxed.forEach_testConvertHalf4Long4Half4(inV, out); 26375 verifyResultsConvertLong4Half4(inV, out, true); 26376 out.destroy(); 26377 } catch (Exception e) { 26378 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Long4Half4: " + e.toString()); 26379 } 26380 inV.destroy(); 26381 } 26382 26383 private void verifyResultsConvertLong4Half4(Allocation inV, Allocation out, boolean relaxed) { 26384 long[] arrayInV = new long[INPUTSIZE * 4]; 26385 Arrays.fill(arrayInV, (long) 42); 26386 inV.copyTo(arrayInV); 26387 short[] arrayOut = new short[INPUTSIZE * 4]; 26388 Arrays.fill(arrayOut, (short) 42); 26389 out.copyTo(arrayOut); 26390 StringBuilder message = new StringBuilder(); 26391 boolean errorFound = false; 26392 for (int i = 0; i < INPUTSIZE; i++) { 26393 for (int j = 0; j < 4 ; j++) { 26394 // Extract the inputs. 26395 ArgumentsLongHalf args = new ArgumentsLongHalf(); 26396 args.inV = arrayInV[i * 4 + j]; 26397 // Figure out what the outputs should have been. 26398 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26399 CoreMathVerifier.computeConvert(args, target); 26400 // Validate the outputs. 26401 boolean valid = true; 26402 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26403 valid = false; 26404 } 26405 if (!valid) { 26406 if (!errorFound) { 26407 errorFound = true; 26408 message.append("Input inV: "); 26409 appendVariableToMessage(message, args.inV); 26410 message.append("\n"); 26411 message.append("Expected output out: "); 26412 appendVariableToMessage(message, args.out); 26413 message.append("\n"); 26414 message.append("Actual output out: "); 26415 appendVariableToMessage(message, arrayOut[i * 4 + j]); 26416 message.append("\n"); 26417 message.append("Actual output out (in double): "); 26418 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 26419 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26420 message.append(" FAIL"); 26421 } 26422 message.append("\n"); 26423 message.append("Errors at"); 26424 } 26425 message.append(" ["); 26426 message.append(Integer.toString(i)); 26427 message.append(", "); 26428 message.append(Integer.toString(j)); 26429 message.append("]"); 26430 } 26431 } 26432 } 26433 assertFalse("Incorrect output for checkConvertLong4Half4" + 26434 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26435 } 26436 26437 public class ArgumentsUlongHalf { 26438 public long inV; 26439 public Target.Floaty out; 26440 } 26441 26442 private void checkConvertUlong2Half2() { 26443 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7e438754723al, false, 64); 26444 try { 26445 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 26446 script.forEach_testConvertHalf2Ulong2Half2(inV, out); 26447 verifyResultsConvertUlong2Half2(inV, out, false); 26448 out.destroy(); 26449 } catch (Exception e) { 26450 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ulong2Half2: " + e.toString()); 26451 } 26452 try { 26453 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 26454 scriptRelaxed.forEach_testConvertHalf2Ulong2Half2(inV, out); 26455 verifyResultsConvertUlong2Half2(inV, out, true); 26456 out.destroy(); 26457 } catch (Exception e) { 26458 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ulong2Half2: " + e.toString()); 26459 } 26460 inV.destroy(); 26461 } 26462 26463 private void verifyResultsConvertUlong2Half2(Allocation inV, Allocation out, boolean relaxed) { 26464 long[] arrayInV = new long[INPUTSIZE * 2]; 26465 Arrays.fill(arrayInV, (long) 42); 26466 inV.copyTo(arrayInV); 26467 short[] arrayOut = new short[INPUTSIZE * 2]; 26468 Arrays.fill(arrayOut, (short) 42); 26469 out.copyTo(arrayOut); 26470 StringBuilder message = new StringBuilder(); 26471 boolean errorFound = false; 26472 for (int i = 0; i < INPUTSIZE; i++) { 26473 for (int j = 0; j < 2 ; j++) { 26474 // Extract the inputs. 26475 ArgumentsUlongHalf args = new ArgumentsUlongHalf(); 26476 args.inV = arrayInV[i * 2 + j]; 26477 // Figure out what the outputs should have been. 26478 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26479 CoreMathVerifier.computeConvert(args, target); 26480 // Validate the outputs. 26481 boolean valid = true; 26482 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 26483 valid = false; 26484 } 26485 if (!valid) { 26486 if (!errorFound) { 26487 errorFound = true; 26488 message.append("Input inV: "); 26489 appendVariableToMessage(message, args.inV); 26490 message.append("\n"); 26491 message.append("Expected output out: "); 26492 appendVariableToMessage(message, args.out); 26493 message.append("\n"); 26494 message.append("Actual output out: "); 26495 appendVariableToMessage(message, arrayOut[i * 2 + j]); 26496 message.append("\n"); 26497 message.append("Actual output out (in double): "); 26498 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 26499 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 26500 message.append(" FAIL"); 26501 } 26502 message.append("\n"); 26503 message.append("Errors at"); 26504 } 26505 message.append(" ["); 26506 message.append(Integer.toString(i)); 26507 message.append(", "); 26508 message.append(Integer.toString(j)); 26509 message.append("]"); 26510 } 26511 } 26512 } 26513 assertFalse("Incorrect output for checkConvertUlong2Half2" + 26514 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26515 } 26516 26517 private void checkConvertUlong3Half3() { 26518 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe88e4e65c372el, false, 64); 26519 try { 26520 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 26521 script.forEach_testConvertHalf3Ulong3Half3(inV, out); 26522 verifyResultsConvertUlong3Half3(inV, out, false); 26523 out.destroy(); 26524 } catch (Exception e) { 26525 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ulong3Half3: " + e.toString()); 26526 } 26527 try { 26528 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 26529 scriptRelaxed.forEach_testConvertHalf3Ulong3Half3(inV, out); 26530 verifyResultsConvertUlong3Half3(inV, out, true); 26531 out.destroy(); 26532 } catch (Exception e) { 26533 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ulong3Half3: " + e.toString()); 26534 } 26535 inV.destroy(); 26536 } 26537 26538 private void verifyResultsConvertUlong3Half3(Allocation inV, Allocation out, boolean relaxed) { 26539 long[] arrayInV = new long[INPUTSIZE * 4]; 26540 Arrays.fill(arrayInV, (long) 42); 26541 inV.copyTo(arrayInV); 26542 short[] arrayOut = new short[INPUTSIZE * 4]; 26543 Arrays.fill(arrayOut, (short) 42); 26544 out.copyTo(arrayOut); 26545 StringBuilder message = new StringBuilder(); 26546 boolean errorFound = false; 26547 for (int i = 0; i < INPUTSIZE; i++) { 26548 for (int j = 0; j < 3 ; j++) { 26549 // Extract the inputs. 26550 ArgumentsUlongHalf args = new ArgumentsUlongHalf(); 26551 args.inV = arrayInV[i * 4 + j]; 26552 // Figure out what the outputs should have been. 26553 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26554 CoreMathVerifier.computeConvert(args, target); 26555 // Validate the outputs. 26556 boolean valid = true; 26557 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26558 valid = false; 26559 } 26560 if (!valid) { 26561 if (!errorFound) { 26562 errorFound = true; 26563 message.append("Input inV: "); 26564 appendVariableToMessage(message, args.inV); 26565 message.append("\n"); 26566 message.append("Expected output out: "); 26567 appendVariableToMessage(message, args.out); 26568 message.append("\n"); 26569 message.append("Actual output out: "); 26570 appendVariableToMessage(message, arrayOut[i * 4 + j]); 26571 message.append("\n"); 26572 message.append("Actual output out (in double): "); 26573 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 26574 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26575 message.append(" FAIL"); 26576 } 26577 message.append("\n"); 26578 message.append("Errors at"); 26579 } 26580 message.append(" ["); 26581 message.append(Integer.toString(i)); 26582 message.append(", "); 26583 message.append(Integer.toString(j)); 26584 message.append("]"); 26585 } 26586 } 26587 } 26588 assertFalse("Incorrect output for checkConvertUlong3Half3" + 26589 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26590 } 26591 26592 private void checkConvertUlong4Half4() { 26593 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe93864563fc22l, false, 64); 26594 try { 26595 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 26596 script.forEach_testConvertHalf4Ulong4Half4(inV, out); 26597 verifyResultsConvertUlong4Half4(inV, out, false); 26598 out.destroy(); 26599 } catch (Exception e) { 26600 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ulong4Half4: " + e.toString()); 26601 } 26602 try { 26603 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 26604 scriptRelaxed.forEach_testConvertHalf4Ulong4Half4(inV, out); 26605 verifyResultsConvertUlong4Half4(inV, out, true); 26606 out.destroy(); 26607 } catch (Exception e) { 26608 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ulong4Half4: " + e.toString()); 26609 } 26610 inV.destroy(); 26611 } 26612 26613 private void verifyResultsConvertUlong4Half4(Allocation inV, Allocation out, boolean relaxed) { 26614 long[] arrayInV = new long[INPUTSIZE * 4]; 26615 Arrays.fill(arrayInV, (long) 42); 26616 inV.copyTo(arrayInV); 26617 short[] arrayOut = new short[INPUTSIZE * 4]; 26618 Arrays.fill(arrayOut, (short) 42); 26619 out.copyTo(arrayOut); 26620 StringBuilder message = new StringBuilder(); 26621 boolean errorFound = false; 26622 for (int i = 0; i < INPUTSIZE; i++) { 26623 for (int j = 0; j < 4 ; j++) { 26624 // Extract the inputs. 26625 ArgumentsUlongHalf args = new ArgumentsUlongHalf(); 26626 args.inV = arrayInV[i * 4 + j]; 26627 // Figure out what the outputs should have been. 26628 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 26629 CoreMathVerifier.computeConvert(args, target); 26630 // Validate the outputs. 26631 boolean valid = true; 26632 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26633 valid = false; 26634 } 26635 if (!valid) { 26636 if (!errorFound) { 26637 errorFound = true; 26638 message.append("Input inV: "); 26639 appendVariableToMessage(message, args.inV); 26640 message.append("\n"); 26641 message.append("Expected output out: "); 26642 appendVariableToMessage(message, args.out); 26643 message.append("\n"); 26644 message.append("Actual output out: "); 26645 appendVariableToMessage(message, arrayOut[i * 4 + j]); 26646 message.append("\n"); 26647 message.append("Actual output out (in double): "); 26648 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 26649 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 26650 message.append(" FAIL"); 26651 } 26652 message.append("\n"); 26653 message.append("Errors at"); 26654 } 26655 message.append(" ["); 26656 message.append(Integer.toString(i)); 26657 message.append(", "); 26658 message.append(Integer.toString(j)); 26659 message.append("]"); 26660 } 26661 } 26662 } 26663 assertFalse("Incorrect output for checkConvertUlong4Half4" + 26664 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 26665 } 26666 26667 public void testConvert() { 26668 checkConvertFloat2Float2(); 26669 checkConvertFloat3Float3(); 26670 checkConvertFloat4Float4(); 26671 checkConvertChar2Float2(); 26672 checkConvertChar3Float3(); 26673 checkConvertChar4Float4(); 26674 checkConvertUchar2Float2(); 26675 checkConvertUchar3Float3(); 26676 checkConvertUchar4Float4(); 26677 checkConvertShort2Float2(); 26678 checkConvertShort3Float3(); 26679 checkConvertShort4Float4(); 26680 checkConvertUshort2Float2(); 26681 checkConvertUshort3Float3(); 26682 checkConvertUshort4Float4(); 26683 checkConvertInt2Float2(); 26684 checkConvertInt3Float3(); 26685 checkConvertInt4Float4(); 26686 checkConvertUint2Float2(); 26687 checkConvertUint3Float3(); 26688 checkConvertUint4Float4(); 26689 checkConvertFloat2Char2(); 26690 checkConvertFloat3Char3(); 26691 checkConvertFloat4Char4(); 26692 checkConvertChar2Char2(); 26693 checkConvertChar3Char3(); 26694 checkConvertChar4Char4(); 26695 checkConvertUchar2Char2(); 26696 checkConvertUchar3Char3(); 26697 checkConvertUchar4Char4(); 26698 checkConvertShort2Char2(); 26699 checkConvertShort3Char3(); 26700 checkConvertShort4Char4(); 26701 checkConvertUshort2Char2(); 26702 checkConvertUshort3Char3(); 26703 checkConvertUshort4Char4(); 26704 checkConvertInt2Char2(); 26705 checkConvertInt3Char3(); 26706 checkConvertInt4Char4(); 26707 checkConvertUint2Char2(); 26708 checkConvertUint3Char3(); 26709 checkConvertUint4Char4(); 26710 checkConvertFloat2Uchar2(); 26711 checkConvertFloat3Uchar3(); 26712 checkConvertFloat4Uchar4(); 26713 checkConvertChar2Uchar2(); 26714 checkConvertChar3Uchar3(); 26715 checkConvertChar4Uchar4(); 26716 checkConvertUchar2Uchar2(); 26717 checkConvertUchar3Uchar3(); 26718 checkConvertUchar4Uchar4(); 26719 checkConvertShort2Uchar2(); 26720 checkConvertShort3Uchar3(); 26721 checkConvertShort4Uchar4(); 26722 checkConvertUshort2Uchar2(); 26723 checkConvertUshort3Uchar3(); 26724 checkConvertUshort4Uchar4(); 26725 checkConvertInt2Uchar2(); 26726 checkConvertInt3Uchar3(); 26727 checkConvertInt4Uchar4(); 26728 checkConvertUint2Uchar2(); 26729 checkConvertUint3Uchar3(); 26730 checkConvertUint4Uchar4(); 26731 checkConvertFloat2Short2(); 26732 checkConvertFloat3Short3(); 26733 checkConvertFloat4Short4(); 26734 checkConvertChar2Short2(); 26735 checkConvertChar3Short3(); 26736 checkConvertChar4Short4(); 26737 checkConvertUchar2Short2(); 26738 checkConvertUchar3Short3(); 26739 checkConvertUchar4Short4(); 26740 checkConvertShort2Short2(); 26741 checkConvertShort3Short3(); 26742 checkConvertShort4Short4(); 26743 checkConvertUshort2Short2(); 26744 checkConvertUshort3Short3(); 26745 checkConvertUshort4Short4(); 26746 checkConvertInt2Short2(); 26747 checkConvertInt3Short3(); 26748 checkConvertInt4Short4(); 26749 checkConvertUint2Short2(); 26750 checkConvertUint3Short3(); 26751 checkConvertUint4Short4(); 26752 checkConvertFloat2Ushort2(); 26753 checkConvertFloat3Ushort3(); 26754 checkConvertFloat4Ushort4(); 26755 checkConvertChar2Ushort2(); 26756 checkConvertChar3Ushort3(); 26757 checkConvertChar4Ushort4(); 26758 checkConvertUchar2Ushort2(); 26759 checkConvertUchar3Ushort3(); 26760 checkConvertUchar4Ushort4(); 26761 checkConvertShort2Ushort2(); 26762 checkConvertShort3Ushort3(); 26763 checkConvertShort4Ushort4(); 26764 checkConvertUshort2Ushort2(); 26765 checkConvertUshort3Ushort3(); 26766 checkConvertUshort4Ushort4(); 26767 checkConvertInt2Ushort2(); 26768 checkConvertInt3Ushort3(); 26769 checkConvertInt4Ushort4(); 26770 checkConvertUint2Ushort2(); 26771 checkConvertUint3Ushort3(); 26772 checkConvertUint4Ushort4(); 26773 checkConvertFloat2Int2(); 26774 checkConvertFloat3Int3(); 26775 checkConvertFloat4Int4(); 26776 checkConvertChar2Int2(); 26777 checkConvertChar3Int3(); 26778 checkConvertChar4Int4(); 26779 checkConvertUchar2Int2(); 26780 checkConvertUchar3Int3(); 26781 checkConvertUchar4Int4(); 26782 checkConvertShort2Int2(); 26783 checkConvertShort3Int3(); 26784 checkConvertShort4Int4(); 26785 checkConvertUshort2Int2(); 26786 checkConvertUshort3Int3(); 26787 checkConvertUshort4Int4(); 26788 checkConvertInt2Int2(); 26789 checkConvertInt3Int3(); 26790 checkConvertInt4Int4(); 26791 checkConvertUint2Int2(); 26792 checkConvertUint3Int3(); 26793 checkConvertUint4Int4(); 26794 checkConvertFloat2Uint2(); 26795 checkConvertFloat3Uint3(); 26796 checkConvertFloat4Uint4(); 26797 checkConvertChar2Uint2(); 26798 checkConvertChar3Uint3(); 26799 checkConvertChar4Uint4(); 26800 checkConvertUchar2Uint2(); 26801 checkConvertUchar3Uint3(); 26802 checkConvertUchar4Uint4(); 26803 checkConvertShort2Uint2(); 26804 checkConvertShort3Uint3(); 26805 checkConvertShort4Uint4(); 26806 checkConvertUshort2Uint2(); 26807 checkConvertUshort3Uint3(); 26808 checkConvertUshort4Uint4(); 26809 checkConvertInt2Uint2(); 26810 checkConvertInt3Uint3(); 26811 checkConvertInt4Uint4(); 26812 checkConvertUint2Uint2(); 26813 checkConvertUint3Uint3(); 26814 checkConvertUint4Uint4(); 26815 checkConvertDouble2Double2(); 26816 checkConvertDouble3Double3(); 26817 checkConvertDouble4Double4(); 26818 checkConvertLong2Double2(); 26819 checkConvertLong3Double3(); 26820 checkConvertLong4Double4(); 26821 checkConvertUlong2Double2(); 26822 checkConvertUlong3Double3(); 26823 checkConvertUlong4Double4(); 26824 checkConvertDouble2Long2(); 26825 checkConvertDouble3Long3(); 26826 checkConvertDouble4Long4(); 26827 checkConvertLong2Long2(); 26828 checkConvertLong3Long3(); 26829 checkConvertLong4Long4(); 26830 checkConvertUlong2Long2(); 26831 checkConvertUlong3Long3(); 26832 checkConvertUlong4Long4(); 26833 checkConvertDouble2Ulong2(); 26834 checkConvertDouble3Ulong3(); 26835 checkConvertDouble4Ulong4(); 26836 checkConvertLong2Ulong2(); 26837 checkConvertLong3Ulong3(); 26838 checkConvertLong4Ulong4(); 26839 checkConvertUlong2Ulong2(); 26840 checkConvertUlong3Ulong3(); 26841 checkConvertUlong4Ulong4(); 26842 checkConvertDouble2Float2(); 26843 checkConvertDouble3Float3(); 26844 checkConvertDouble4Float4(); 26845 checkConvertLong2Float2(); 26846 checkConvertLong3Float3(); 26847 checkConvertLong4Float4(); 26848 checkConvertUlong2Float2(); 26849 checkConvertUlong3Float3(); 26850 checkConvertUlong4Float4(); 26851 checkConvertDouble2Char2(); 26852 checkConvertDouble3Char3(); 26853 checkConvertDouble4Char4(); 26854 checkConvertLong2Char2(); 26855 checkConvertLong3Char3(); 26856 checkConvertLong4Char4(); 26857 checkConvertUlong2Char2(); 26858 checkConvertUlong3Char3(); 26859 checkConvertUlong4Char4(); 26860 checkConvertDouble2Uchar2(); 26861 checkConvertDouble3Uchar3(); 26862 checkConvertDouble4Uchar4(); 26863 checkConvertLong2Uchar2(); 26864 checkConvertLong3Uchar3(); 26865 checkConvertLong4Uchar4(); 26866 checkConvertUlong2Uchar2(); 26867 checkConvertUlong3Uchar3(); 26868 checkConvertUlong4Uchar4(); 26869 checkConvertDouble2Short2(); 26870 checkConvertDouble3Short3(); 26871 checkConvertDouble4Short4(); 26872 checkConvertLong2Short2(); 26873 checkConvertLong3Short3(); 26874 checkConvertLong4Short4(); 26875 checkConvertUlong2Short2(); 26876 checkConvertUlong3Short3(); 26877 checkConvertUlong4Short4(); 26878 checkConvertDouble2Ushort2(); 26879 checkConvertDouble3Ushort3(); 26880 checkConvertDouble4Ushort4(); 26881 checkConvertLong2Ushort2(); 26882 checkConvertLong3Ushort3(); 26883 checkConvertLong4Ushort4(); 26884 checkConvertUlong2Ushort2(); 26885 checkConvertUlong3Ushort3(); 26886 checkConvertUlong4Ushort4(); 26887 checkConvertDouble2Int2(); 26888 checkConvertDouble3Int3(); 26889 checkConvertDouble4Int4(); 26890 checkConvertLong2Int2(); 26891 checkConvertLong3Int3(); 26892 checkConvertLong4Int4(); 26893 checkConvertUlong2Int2(); 26894 checkConvertUlong3Int3(); 26895 checkConvertUlong4Int4(); 26896 checkConvertDouble2Uint2(); 26897 checkConvertDouble3Uint3(); 26898 checkConvertDouble4Uint4(); 26899 checkConvertLong2Uint2(); 26900 checkConvertLong3Uint3(); 26901 checkConvertLong4Uint4(); 26902 checkConvertUlong2Uint2(); 26903 checkConvertUlong3Uint3(); 26904 checkConvertUlong4Uint4(); 26905 checkConvertFloat2Double2(); 26906 checkConvertFloat3Double3(); 26907 checkConvertFloat4Double4(); 26908 checkConvertChar2Double2(); 26909 checkConvertChar3Double3(); 26910 checkConvertChar4Double4(); 26911 checkConvertUchar2Double2(); 26912 checkConvertUchar3Double3(); 26913 checkConvertUchar4Double4(); 26914 checkConvertShort2Double2(); 26915 checkConvertShort3Double3(); 26916 checkConvertShort4Double4(); 26917 checkConvertUshort2Double2(); 26918 checkConvertUshort3Double3(); 26919 checkConvertUshort4Double4(); 26920 checkConvertInt2Double2(); 26921 checkConvertInt3Double3(); 26922 checkConvertInt4Double4(); 26923 checkConvertUint2Double2(); 26924 checkConvertUint3Double3(); 26925 checkConvertUint4Double4(); 26926 checkConvertFloat2Long2(); 26927 checkConvertFloat3Long3(); 26928 checkConvertFloat4Long4(); 26929 checkConvertChar2Long2(); 26930 checkConvertChar3Long3(); 26931 checkConvertChar4Long4(); 26932 checkConvertUchar2Long2(); 26933 checkConvertUchar3Long3(); 26934 checkConvertUchar4Long4(); 26935 checkConvertShort2Long2(); 26936 checkConvertShort3Long3(); 26937 checkConvertShort4Long4(); 26938 checkConvertUshort2Long2(); 26939 checkConvertUshort3Long3(); 26940 checkConvertUshort4Long4(); 26941 checkConvertInt2Long2(); 26942 checkConvertInt3Long3(); 26943 checkConvertInt4Long4(); 26944 checkConvertUint2Long2(); 26945 checkConvertUint3Long3(); 26946 checkConvertUint4Long4(); 26947 checkConvertFloat2Ulong2(); 26948 checkConvertFloat3Ulong3(); 26949 checkConvertFloat4Ulong4(); 26950 checkConvertChar2Ulong2(); 26951 checkConvertChar3Ulong3(); 26952 checkConvertChar4Ulong4(); 26953 checkConvertUchar2Ulong2(); 26954 checkConvertUchar3Ulong3(); 26955 checkConvertUchar4Ulong4(); 26956 checkConvertShort2Ulong2(); 26957 checkConvertShort3Ulong3(); 26958 checkConvertShort4Ulong4(); 26959 checkConvertUshort2Ulong2(); 26960 checkConvertUshort3Ulong3(); 26961 checkConvertUshort4Ulong4(); 26962 checkConvertInt2Ulong2(); 26963 checkConvertInt3Ulong3(); 26964 checkConvertInt4Ulong4(); 26965 checkConvertUint2Ulong2(); 26966 checkConvertUint3Ulong3(); 26967 checkConvertUint4Ulong4(); 26968 checkConvertHalf2Half2(); 26969 checkConvertHalf3Half3(); 26970 checkConvertHalf4Half4(); 26971 checkConvertHalf2Float2(); 26972 checkConvertHalf3Float3(); 26973 checkConvertHalf4Float4(); 26974 checkConvertHalf2Double2(); 26975 checkConvertHalf3Double3(); 26976 checkConvertHalf4Double4(); 26977 checkConvertHalf2Char2(); 26978 checkConvertHalf3Char3(); 26979 checkConvertHalf4Char4(); 26980 checkConvertHalf2Uchar2(); 26981 checkConvertHalf3Uchar3(); 26982 checkConvertHalf4Uchar4(); 26983 checkConvertHalf2Short2(); 26984 checkConvertHalf3Short3(); 26985 checkConvertHalf4Short4(); 26986 checkConvertHalf2Ushort2(); 26987 checkConvertHalf3Ushort3(); 26988 checkConvertHalf4Ushort4(); 26989 checkConvertHalf2Int2(); 26990 checkConvertHalf3Int3(); 26991 checkConvertHalf4Int4(); 26992 checkConvertHalf2Uint2(); 26993 checkConvertHalf3Uint3(); 26994 checkConvertHalf4Uint4(); 26995 checkConvertHalf2Long2(); 26996 checkConvertHalf3Long3(); 26997 checkConvertHalf4Long4(); 26998 checkConvertHalf2Ulong2(); 26999 checkConvertHalf3Ulong3(); 27000 checkConvertHalf4Ulong4(); 27001 checkConvertFloat2Half2(); 27002 checkConvertFloat3Half3(); 27003 checkConvertFloat4Half4(); 27004 checkConvertDouble2Half2(); 27005 checkConvertDouble3Half3(); 27006 checkConvertDouble4Half4(); 27007 checkConvertChar2Half2(); 27008 checkConvertChar3Half3(); 27009 checkConvertChar4Half4(); 27010 checkConvertUchar2Half2(); 27011 checkConvertUchar3Half3(); 27012 checkConvertUchar4Half4(); 27013 checkConvertShort2Half2(); 27014 checkConvertShort3Half3(); 27015 checkConvertShort4Half4(); 27016 checkConvertUshort2Half2(); 27017 checkConvertUshort3Half3(); 27018 checkConvertUshort4Half4(); 27019 checkConvertInt2Half2(); 27020 checkConvertInt3Half3(); 27021 checkConvertInt4Half4(); 27022 checkConvertUint2Half2(); 27023 checkConvertUint3Half3(); 27024 checkConvertUint4Half4(); 27025 checkConvertLong2Half2(); 27026 checkConvertLong3Half3(); 27027 checkConvertLong4Half4(); 27028 checkConvertUlong2Half2(); 27029 checkConvertUlong3Half3(); 27030 checkConvertUlong4Half4(); 27031 } 27032 } 27033