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 setUp()34 protected void setUp() throws Exception { 35 super.setUp(); 36 script = new ScriptC_TestConvert(mRS); 37 scriptRelaxed = new ScriptC_TestConvertRelaxed(mRS); 38 } 39 40 public class ArgumentsFloatFloat { 41 public float inV; 42 public Target.Floaty out; 43 } 44 checkConvertFloat2Float2()45 private void checkConvertFloat2Float2() { 46 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4e1f6ac6l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 47 try { 48 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 49 script.forEach_testConvertFloat2Float2Float2(inV, out); 50 verifyResultsConvertFloat2Float2(inV, out, false); 51 } catch (Exception e) { 52 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString()); 53 } 54 try { 55 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 56 scriptRelaxed.forEach_testConvertFloat2Float2Float2(inV, out); 57 verifyResultsConvertFloat2Float2(inV, out, true); 58 } catch (Exception e) { 59 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString()); 60 } 61 } 62 verifyResultsConvertFloat2Float2(Allocation inV, Allocation out, boolean relaxed)63 private void verifyResultsConvertFloat2Float2(Allocation inV, Allocation out, boolean relaxed) { 64 float[] arrayInV = new float[INPUTSIZE * 2]; 65 Arrays.fill(arrayInV, (float) 42); 66 inV.copyTo(arrayInV); 67 float[] arrayOut = new float[INPUTSIZE * 2]; 68 Arrays.fill(arrayOut, (float) 42); 69 out.copyTo(arrayOut); 70 StringBuilder message = new StringBuilder(); 71 boolean errorFound = false; 72 for (int i = 0; i < INPUTSIZE; i++) { 73 for (int j = 0; j < 2 ; j++) { 74 // Extract the inputs. 75 ArgumentsFloatFloat args = new ArgumentsFloatFloat(); 76 args.inV = arrayInV[i * 2 + j]; 77 // Figure out what the outputs should have been. 78 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 79 CoreMathVerifier.computeConvert(args, target); 80 // Validate the outputs. 81 boolean valid = true; 82 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 83 valid = false; 84 } 85 if (!valid) { 86 if (!errorFound) { 87 errorFound = true; 88 message.append("Input inV: "); 89 appendVariableToMessage(message, args.inV); 90 message.append("\n"); 91 message.append("Expected output out: "); 92 appendVariableToMessage(message, args.out); 93 message.append("\n"); 94 message.append("Actual output out: "); 95 appendVariableToMessage(message, arrayOut[i * 2 + j]); 96 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 97 message.append(" FAIL"); 98 } 99 message.append("\n"); 100 message.append("Errors at"); 101 } 102 message.append(" ["); 103 message.append(Integer.toString(i)); 104 message.append(", "); 105 message.append(Integer.toString(j)); 106 message.append("]"); 107 } 108 } 109 } 110 assertFalse("Incorrect output for checkConvertFloat2Float2" + 111 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 112 } 113 checkConvertFloat3Float3()114 private void checkConvertFloat3Float3() { 115 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x443a8ba4l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 116 try { 117 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 118 script.forEach_testConvertFloat3Float3Float3(inV, out); 119 verifyResultsConvertFloat3Float3(inV, out, false); 120 } catch (Exception e) { 121 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString()); 122 } 123 try { 124 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 125 scriptRelaxed.forEach_testConvertFloat3Float3Float3(inV, out); 126 verifyResultsConvertFloat3Float3(inV, out, true); 127 } catch (Exception e) { 128 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString()); 129 } 130 } 131 verifyResultsConvertFloat3Float3(Allocation inV, Allocation out, boolean relaxed)132 private void verifyResultsConvertFloat3Float3(Allocation inV, Allocation out, boolean relaxed) { 133 float[] arrayInV = new float[INPUTSIZE * 4]; 134 Arrays.fill(arrayInV, (float) 42); 135 inV.copyTo(arrayInV); 136 float[] arrayOut = new float[INPUTSIZE * 4]; 137 Arrays.fill(arrayOut, (float) 42); 138 out.copyTo(arrayOut); 139 StringBuilder message = new StringBuilder(); 140 boolean errorFound = false; 141 for (int i = 0; i < INPUTSIZE; i++) { 142 for (int j = 0; j < 3 ; j++) { 143 // Extract the inputs. 144 ArgumentsFloatFloat args = new ArgumentsFloatFloat(); 145 args.inV = arrayInV[i * 4 + j]; 146 // Figure out what the outputs should have been. 147 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 148 CoreMathVerifier.computeConvert(args, target); 149 // Validate the outputs. 150 boolean valid = true; 151 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 152 valid = false; 153 } 154 if (!valid) { 155 if (!errorFound) { 156 errorFound = true; 157 message.append("Input inV: "); 158 appendVariableToMessage(message, args.inV); 159 message.append("\n"); 160 message.append("Expected output out: "); 161 appendVariableToMessage(message, args.out); 162 message.append("\n"); 163 message.append("Actual output out: "); 164 appendVariableToMessage(message, arrayOut[i * 4 + j]); 165 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 166 message.append(" FAIL"); 167 } 168 message.append("\n"); 169 message.append("Errors at"); 170 } 171 message.append(" ["); 172 message.append(Integer.toString(i)); 173 message.append(", "); 174 message.append(Integer.toString(j)); 175 message.append("]"); 176 } 177 } 178 } 179 assertFalse("Incorrect output for checkConvertFloat3Float3" + 180 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 181 } 182 checkConvertFloat4Float4()183 private void checkConvertFloat4Float4() { 184 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3a55ac82l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 185 try { 186 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 187 script.forEach_testConvertFloat4Float4Float4(inV, out); 188 verifyResultsConvertFloat4Float4(inV, out, false); 189 } catch (Exception e) { 190 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString()); 191 } 192 try { 193 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 194 scriptRelaxed.forEach_testConvertFloat4Float4Float4(inV, out); 195 verifyResultsConvertFloat4Float4(inV, out, true); 196 } catch (Exception e) { 197 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString()); 198 } 199 } 200 verifyResultsConvertFloat4Float4(Allocation inV, Allocation out, boolean relaxed)201 private void verifyResultsConvertFloat4Float4(Allocation inV, Allocation out, boolean relaxed) { 202 float[] arrayInV = new float[INPUTSIZE * 4]; 203 Arrays.fill(arrayInV, (float) 42); 204 inV.copyTo(arrayInV); 205 float[] arrayOut = new float[INPUTSIZE * 4]; 206 Arrays.fill(arrayOut, (float) 42); 207 out.copyTo(arrayOut); 208 StringBuilder message = new StringBuilder(); 209 boolean errorFound = false; 210 for (int i = 0; i < INPUTSIZE; i++) { 211 for (int j = 0; j < 4 ; j++) { 212 // Extract the inputs. 213 ArgumentsFloatFloat args = new ArgumentsFloatFloat(); 214 args.inV = arrayInV[i * 4 + j]; 215 // Figure out what the outputs should have been. 216 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 217 CoreMathVerifier.computeConvert(args, target); 218 // Validate the outputs. 219 boolean valid = true; 220 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 221 valid = false; 222 } 223 if (!valid) { 224 if (!errorFound) { 225 errorFound = true; 226 message.append("Input inV: "); 227 appendVariableToMessage(message, args.inV); 228 message.append("\n"); 229 message.append("Expected output out: "); 230 appendVariableToMessage(message, args.out); 231 message.append("\n"); 232 message.append("Actual output out: "); 233 appendVariableToMessage(message, arrayOut[i * 4 + j]); 234 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 235 message.append(" FAIL"); 236 } 237 message.append("\n"); 238 message.append("Errors at"); 239 } 240 message.append(" ["); 241 message.append(Integer.toString(i)); 242 message.append(", "); 243 message.append(Integer.toString(j)); 244 message.append("]"); 245 } 246 } 247 } 248 assertFalse("Incorrect output for checkConvertFloat4Float4" + 249 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 250 } 251 252 public class ArgumentsCharFloat { 253 public byte inV; 254 public Target.Floaty out; 255 } 256 checkConvertChar2Float2()257 private void checkConvertChar2Float2() { 258 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x1f489286l, true, 7); 259 try { 260 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 261 script.forEach_testConvertFloat2Char2Float2(inV, out); 262 verifyResultsConvertChar2Float2(inV, out, false); 263 } catch (Exception e) { 264 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString()); 265 } 266 try { 267 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 268 scriptRelaxed.forEach_testConvertFloat2Char2Float2(inV, out); 269 verifyResultsConvertChar2Float2(inV, out, true); 270 } catch (Exception e) { 271 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString()); 272 } 273 } 274 verifyResultsConvertChar2Float2(Allocation inV, Allocation out, boolean relaxed)275 private void verifyResultsConvertChar2Float2(Allocation inV, Allocation out, boolean relaxed) { 276 byte[] arrayInV = new byte[INPUTSIZE * 2]; 277 Arrays.fill(arrayInV, (byte) 42); 278 inV.copyTo(arrayInV); 279 float[] arrayOut = new float[INPUTSIZE * 2]; 280 Arrays.fill(arrayOut, (float) 42); 281 out.copyTo(arrayOut); 282 StringBuilder message = new StringBuilder(); 283 boolean errorFound = false; 284 for (int i = 0; i < INPUTSIZE; i++) { 285 for (int j = 0; j < 2 ; j++) { 286 // Extract the inputs. 287 ArgumentsCharFloat args = new ArgumentsCharFloat(); 288 args.inV = arrayInV[i * 2 + j]; 289 // Figure out what the outputs should have been. 290 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 291 CoreMathVerifier.computeConvert(args, target); 292 // Validate the outputs. 293 boolean valid = true; 294 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 295 valid = false; 296 } 297 if (!valid) { 298 if (!errorFound) { 299 errorFound = true; 300 message.append("Input inV: "); 301 appendVariableToMessage(message, args.inV); 302 message.append("\n"); 303 message.append("Expected output out: "); 304 appendVariableToMessage(message, args.out); 305 message.append("\n"); 306 message.append("Actual output out: "); 307 appendVariableToMessage(message, arrayOut[i * 2 + j]); 308 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 309 message.append(" FAIL"); 310 } 311 message.append("\n"); 312 message.append("Errors at"); 313 } 314 message.append(" ["); 315 message.append(Integer.toString(i)); 316 message.append(", "); 317 message.append(Integer.toString(j)); 318 message.append("]"); 319 } 320 } 321 } 322 assertFalse("Incorrect output for checkConvertChar2Float2" + 323 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 324 } 325 checkConvertChar3Float3()326 private void checkConvertChar3Float3() { 327 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x1563b364l, true, 7); 328 try { 329 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 330 script.forEach_testConvertFloat3Char3Float3(inV, out); 331 verifyResultsConvertChar3Float3(inV, out, false); 332 } catch (Exception e) { 333 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString()); 334 } 335 try { 336 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 337 scriptRelaxed.forEach_testConvertFloat3Char3Float3(inV, out); 338 verifyResultsConvertChar3Float3(inV, out, true); 339 } catch (Exception e) { 340 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString()); 341 } 342 } 343 verifyResultsConvertChar3Float3(Allocation inV, Allocation out, boolean relaxed)344 private void verifyResultsConvertChar3Float3(Allocation inV, Allocation out, boolean relaxed) { 345 byte[] arrayInV = new byte[INPUTSIZE * 4]; 346 Arrays.fill(arrayInV, (byte) 42); 347 inV.copyTo(arrayInV); 348 float[] arrayOut = new float[INPUTSIZE * 4]; 349 Arrays.fill(arrayOut, (float) 42); 350 out.copyTo(arrayOut); 351 StringBuilder message = new StringBuilder(); 352 boolean errorFound = false; 353 for (int i = 0; i < INPUTSIZE; i++) { 354 for (int j = 0; j < 3 ; j++) { 355 // Extract the inputs. 356 ArgumentsCharFloat args = new ArgumentsCharFloat(); 357 args.inV = arrayInV[i * 4 + j]; 358 // Figure out what the outputs should have been. 359 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 360 CoreMathVerifier.computeConvert(args, target); 361 // Validate the outputs. 362 boolean valid = true; 363 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 364 valid = false; 365 } 366 if (!valid) { 367 if (!errorFound) { 368 errorFound = true; 369 message.append("Input inV: "); 370 appendVariableToMessage(message, args.inV); 371 message.append("\n"); 372 message.append("Expected output out: "); 373 appendVariableToMessage(message, args.out); 374 message.append("\n"); 375 message.append("Actual output out: "); 376 appendVariableToMessage(message, arrayOut[i * 4 + j]); 377 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 378 message.append(" FAIL"); 379 } 380 message.append("\n"); 381 message.append("Errors at"); 382 } 383 message.append(" ["); 384 message.append(Integer.toString(i)); 385 message.append(", "); 386 message.append(Integer.toString(j)); 387 message.append("]"); 388 } 389 } 390 } 391 assertFalse("Incorrect output for checkConvertChar3Float3" + 392 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 393 } 394 checkConvertChar4Float4()395 private void checkConvertChar4Float4() { 396 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xb7ed442l, true, 7); 397 try { 398 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 399 script.forEach_testConvertFloat4Char4Float4(inV, out); 400 verifyResultsConvertChar4Float4(inV, out, false); 401 } catch (Exception e) { 402 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString()); 403 } 404 try { 405 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 406 scriptRelaxed.forEach_testConvertFloat4Char4Float4(inV, out); 407 verifyResultsConvertChar4Float4(inV, out, true); 408 } catch (Exception e) { 409 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString()); 410 } 411 } 412 verifyResultsConvertChar4Float4(Allocation inV, Allocation out, boolean relaxed)413 private void verifyResultsConvertChar4Float4(Allocation inV, Allocation out, boolean relaxed) { 414 byte[] arrayInV = new byte[INPUTSIZE * 4]; 415 Arrays.fill(arrayInV, (byte) 42); 416 inV.copyTo(arrayInV); 417 float[] arrayOut = new float[INPUTSIZE * 4]; 418 Arrays.fill(arrayOut, (float) 42); 419 out.copyTo(arrayOut); 420 StringBuilder message = new StringBuilder(); 421 boolean errorFound = false; 422 for (int i = 0; i < INPUTSIZE; i++) { 423 for (int j = 0; j < 4 ; j++) { 424 // Extract the inputs. 425 ArgumentsCharFloat args = new ArgumentsCharFloat(); 426 args.inV = arrayInV[i * 4 + j]; 427 // Figure out what the outputs should have been. 428 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 429 CoreMathVerifier.computeConvert(args, target); 430 // Validate the outputs. 431 boolean valid = true; 432 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 433 valid = false; 434 } 435 if (!valid) { 436 if (!errorFound) { 437 errorFound = true; 438 message.append("Input inV: "); 439 appendVariableToMessage(message, args.inV); 440 message.append("\n"); 441 message.append("Expected output out: "); 442 appendVariableToMessage(message, args.out); 443 message.append("\n"); 444 message.append("Actual output out: "); 445 appendVariableToMessage(message, arrayOut[i * 4 + j]); 446 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 447 message.append(" FAIL"); 448 } 449 message.append("\n"); 450 message.append("Errors at"); 451 } 452 message.append(" ["); 453 message.append(Integer.toString(i)); 454 message.append(", "); 455 message.append(Integer.toString(j)); 456 message.append("]"); 457 } 458 } 459 } 460 assertFalse("Incorrect output for checkConvertChar4Float4" + 461 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 462 } 463 464 public class ArgumentsUcharFloat { 465 public byte inV; 466 public Target.Floaty out; 467 } 468 checkConvertUchar2Float2()469 private void checkConvertUchar2Float2() { 470 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbb20ac31l, false, 8); 471 try { 472 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 473 script.forEach_testConvertFloat2Uchar2Float2(inV, out); 474 verifyResultsConvertUchar2Float2(inV, out, false); 475 } catch (Exception e) { 476 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString()); 477 } 478 try { 479 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 480 scriptRelaxed.forEach_testConvertFloat2Uchar2Float2(inV, out); 481 verifyResultsConvertUchar2Float2(inV, out, true); 482 } catch (Exception e) { 483 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString()); 484 } 485 } 486 verifyResultsConvertUchar2Float2(Allocation inV, Allocation out, boolean relaxed)487 private void verifyResultsConvertUchar2Float2(Allocation inV, Allocation out, boolean relaxed) { 488 byte[] arrayInV = new byte[INPUTSIZE * 2]; 489 Arrays.fill(arrayInV, (byte) 42); 490 inV.copyTo(arrayInV); 491 float[] arrayOut = new float[INPUTSIZE * 2]; 492 Arrays.fill(arrayOut, (float) 42); 493 out.copyTo(arrayOut); 494 StringBuilder message = new StringBuilder(); 495 boolean errorFound = false; 496 for (int i = 0; i < INPUTSIZE; i++) { 497 for (int j = 0; j < 2 ; j++) { 498 // Extract the inputs. 499 ArgumentsUcharFloat args = new ArgumentsUcharFloat(); 500 args.inV = arrayInV[i * 2 + j]; 501 // Figure out what the outputs should have been. 502 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 503 CoreMathVerifier.computeConvert(args, target); 504 // Validate the outputs. 505 boolean valid = true; 506 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 507 valid = false; 508 } 509 if (!valid) { 510 if (!errorFound) { 511 errorFound = true; 512 message.append("Input inV: "); 513 appendVariableToMessage(message, args.inV); 514 message.append("\n"); 515 message.append("Expected output out: "); 516 appendVariableToMessage(message, args.out); 517 message.append("\n"); 518 message.append("Actual output out: "); 519 appendVariableToMessage(message, arrayOut[i * 2 + j]); 520 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 521 message.append(" FAIL"); 522 } 523 message.append("\n"); 524 message.append("Errors at"); 525 } 526 message.append(" ["); 527 message.append(Integer.toString(i)); 528 message.append(", "); 529 message.append(Integer.toString(j)); 530 message.append("]"); 531 } 532 } 533 } 534 assertFalse("Incorrect output for checkConvertUchar2Float2" + 535 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 536 } 537 checkConvertUchar3Float3()538 private void checkConvertUchar3Float3() { 539 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb13bcd0fl, false, 8); 540 try { 541 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 542 script.forEach_testConvertFloat3Uchar3Float3(inV, out); 543 verifyResultsConvertUchar3Float3(inV, out, false); 544 } catch (Exception e) { 545 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString()); 546 } 547 try { 548 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 549 scriptRelaxed.forEach_testConvertFloat3Uchar3Float3(inV, out); 550 verifyResultsConvertUchar3Float3(inV, out, true); 551 } catch (Exception e) { 552 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString()); 553 } 554 } 555 verifyResultsConvertUchar3Float3(Allocation inV, Allocation out, boolean relaxed)556 private void verifyResultsConvertUchar3Float3(Allocation inV, Allocation out, boolean relaxed) { 557 byte[] arrayInV = new byte[INPUTSIZE * 4]; 558 Arrays.fill(arrayInV, (byte) 42); 559 inV.copyTo(arrayInV); 560 float[] arrayOut = new float[INPUTSIZE * 4]; 561 Arrays.fill(arrayOut, (float) 42); 562 out.copyTo(arrayOut); 563 StringBuilder message = new StringBuilder(); 564 boolean errorFound = false; 565 for (int i = 0; i < INPUTSIZE; i++) { 566 for (int j = 0; j < 3 ; j++) { 567 // Extract the inputs. 568 ArgumentsUcharFloat args = new ArgumentsUcharFloat(); 569 args.inV = arrayInV[i * 4 + j]; 570 // Figure out what the outputs should have been. 571 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 572 CoreMathVerifier.computeConvert(args, target); 573 // Validate the outputs. 574 boolean valid = true; 575 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 576 valid = false; 577 } 578 if (!valid) { 579 if (!errorFound) { 580 errorFound = true; 581 message.append("Input inV: "); 582 appendVariableToMessage(message, args.inV); 583 message.append("\n"); 584 message.append("Expected output out: "); 585 appendVariableToMessage(message, args.out); 586 message.append("\n"); 587 message.append("Actual output out: "); 588 appendVariableToMessage(message, arrayOut[i * 4 + j]); 589 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 590 message.append(" FAIL"); 591 } 592 message.append("\n"); 593 message.append("Errors at"); 594 } 595 message.append(" ["); 596 message.append(Integer.toString(i)); 597 message.append(", "); 598 message.append(Integer.toString(j)); 599 message.append("]"); 600 } 601 } 602 } 603 assertFalse("Incorrect output for checkConvertUchar3Float3" + 604 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 605 } 606 checkConvertUchar4Float4()607 private void checkConvertUchar4Float4() { 608 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa756ededl, false, 8); 609 try { 610 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 611 script.forEach_testConvertFloat4Uchar4Float4(inV, out); 612 verifyResultsConvertUchar4Float4(inV, out, false); 613 } catch (Exception e) { 614 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString()); 615 } 616 try { 617 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 618 scriptRelaxed.forEach_testConvertFloat4Uchar4Float4(inV, out); 619 verifyResultsConvertUchar4Float4(inV, out, true); 620 } catch (Exception e) { 621 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString()); 622 } 623 } 624 verifyResultsConvertUchar4Float4(Allocation inV, Allocation out, boolean relaxed)625 private void verifyResultsConvertUchar4Float4(Allocation inV, Allocation out, boolean relaxed) { 626 byte[] arrayInV = new byte[INPUTSIZE * 4]; 627 Arrays.fill(arrayInV, (byte) 42); 628 inV.copyTo(arrayInV); 629 float[] arrayOut = new float[INPUTSIZE * 4]; 630 Arrays.fill(arrayOut, (float) 42); 631 out.copyTo(arrayOut); 632 StringBuilder message = new StringBuilder(); 633 boolean errorFound = false; 634 for (int i = 0; i < INPUTSIZE; i++) { 635 for (int j = 0; j < 4 ; j++) { 636 // Extract the inputs. 637 ArgumentsUcharFloat args = new ArgumentsUcharFloat(); 638 args.inV = arrayInV[i * 4 + j]; 639 // Figure out what the outputs should have been. 640 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 641 CoreMathVerifier.computeConvert(args, target); 642 // Validate the outputs. 643 boolean valid = true; 644 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 645 valid = false; 646 } 647 if (!valid) { 648 if (!errorFound) { 649 errorFound = true; 650 message.append("Input inV: "); 651 appendVariableToMessage(message, args.inV); 652 message.append("\n"); 653 message.append("Expected output out: "); 654 appendVariableToMessage(message, args.out); 655 message.append("\n"); 656 message.append("Actual output out: "); 657 appendVariableToMessage(message, arrayOut[i * 4 + j]); 658 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 659 message.append(" FAIL"); 660 } 661 message.append("\n"); 662 message.append("Errors at"); 663 } 664 message.append(" ["); 665 message.append(Integer.toString(i)); 666 message.append(", "); 667 message.append(Integer.toString(j)); 668 message.append("]"); 669 } 670 } 671 } 672 assertFalse("Incorrect output for checkConvertUchar4Float4" + 673 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 674 } 675 676 public class ArgumentsShortFloat { 677 public short inV; 678 public Target.Floaty out; 679 } 680 checkConvertShort2Float2()681 private void checkConvertShort2Float2() { 682 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xff219172l, true, 15); 683 try { 684 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 685 script.forEach_testConvertFloat2Short2Float2(inV, out); 686 verifyResultsConvertShort2Float2(inV, out, false); 687 } catch (Exception e) { 688 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString()); 689 } 690 try { 691 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 692 scriptRelaxed.forEach_testConvertFloat2Short2Float2(inV, out); 693 verifyResultsConvertShort2Float2(inV, out, true); 694 } catch (Exception e) { 695 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString()); 696 } 697 } 698 verifyResultsConvertShort2Float2(Allocation inV, Allocation out, boolean relaxed)699 private void verifyResultsConvertShort2Float2(Allocation inV, Allocation out, boolean relaxed) { 700 short[] arrayInV = new short[INPUTSIZE * 2]; 701 Arrays.fill(arrayInV, (short) 42); 702 inV.copyTo(arrayInV); 703 float[] arrayOut = new float[INPUTSIZE * 2]; 704 Arrays.fill(arrayOut, (float) 42); 705 out.copyTo(arrayOut); 706 StringBuilder message = new StringBuilder(); 707 boolean errorFound = false; 708 for (int i = 0; i < INPUTSIZE; i++) { 709 for (int j = 0; j < 2 ; j++) { 710 // Extract the inputs. 711 ArgumentsShortFloat args = new ArgumentsShortFloat(); 712 args.inV = arrayInV[i * 2 + j]; 713 // Figure out what the outputs should have been. 714 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 715 CoreMathVerifier.computeConvert(args, target); 716 // Validate the outputs. 717 boolean valid = true; 718 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 719 valid = false; 720 } 721 if (!valid) { 722 if (!errorFound) { 723 errorFound = true; 724 message.append("Input inV: "); 725 appendVariableToMessage(message, args.inV); 726 message.append("\n"); 727 message.append("Expected output out: "); 728 appendVariableToMessage(message, args.out); 729 message.append("\n"); 730 message.append("Actual output out: "); 731 appendVariableToMessage(message, arrayOut[i * 2 + j]); 732 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 733 message.append(" FAIL"); 734 } 735 message.append("\n"); 736 message.append("Errors at"); 737 } 738 message.append(" ["); 739 message.append(Integer.toString(i)); 740 message.append(", "); 741 message.append(Integer.toString(j)); 742 message.append("]"); 743 } 744 } 745 } 746 assertFalse("Incorrect output for checkConvertShort2Float2" + 747 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 748 } 749 checkConvertShort3Float3()750 private void checkConvertShort3Float3() { 751 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf53cb250l, true, 15); 752 try { 753 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 754 script.forEach_testConvertFloat3Short3Float3(inV, out); 755 verifyResultsConvertShort3Float3(inV, out, false); 756 } catch (Exception e) { 757 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString()); 758 } 759 try { 760 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 761 scriptRelaxed.forEach_testConvertFloat3Short3Float3(inV, out); 762 verifyResultsConvertShort3Float3(inV, out, true); 763 } catch (Exception e) { 764 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString()); 765 } 766 } 767 verifyResultsConvertShort3Float3(Allocation inV, Allocation out, boolean relaxed)768 private void verifyResultsConvertShort3Float3(Allocation inV, Allocation out, boolean relaxed) { 769 short[] arrayInV = new short[INPUTSIZE * 4]; 770 Arrays.fill(arrayInV, (short) 42); 771 inV.copyTo(arrayInV); 772 float[] arrayOut = new float[INPUTSIZE * 4]; 773 Arrays.fill(arrayOut, (float) 42); 774 out.copyTo(arrayOut); 775 StringBuilder message = new StringBuilder(); 776 boolean errorFound = false; 777 for (int i = 0; i < INPUTSIZE; i++) { 778 for (int j = 0; j < 3 ; j++) { 779 // Extract the inputs. 780 ArgumentsShortFloat args = new ArgumentsShortFloat(); 781 args.inV = arrayInV[i * 4 + j]; 782 // Figure out what the outputs should have been. 783 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 784 CoreMathVerifier.computeConvert(args, target); 785 // Validate the outputs. 786 boolean valid = true; 787 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 788 valid = false; 789 } 790 if (!valid) { 791 if (!errorFound) { 792 errorFound = true; 793 message.append("Input inV: "); 794 appendVariableToMessage(message, args.inV); 795 message.append("\n"); 796 message.append("Expected output out: "); 797 appendVariableToMessage(message, args.out); 798 message.append("\n"); 799 message.append("Actual output out: "); 800 appendVariableToMessage(message, arrayOut[i * 4 + j]); 801 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 802 message.append(" FAIL"); 803 } 804 message.append("\n"); 805 message.append("Errors at"); 806 } 807 message.append(" ["); 808 message.append(Integer.toString(i)); 809 message.append(", "); 810 message.append(Integer.toString(j)); 811 message.append("]"); 812 } 813 } 814 } 815 assertFalse("Incorrect output for checkConvertShort3Float3" + 816 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 817 } 818 checkConvertShort4Float4()819 private void checkConvertShort4Float4() { 820 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xeb57d32el, true, 15); 821 try { 822 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 823 script.forEach_testConvertFloat4Short4Float4(inV, out); 824 verifyResultsConvertShort4Float4(inV, out, false); 825 } catch (Exception e) { 826 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString()); 827 } 828 try { 829 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 830 scriptRelaxed.forEach_testConvertFloat4Short4Float4(inV, out); 831 verifyResultsConvertShort4Float4(inV, out, true); 832 } catch (Exception e) { 833 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString()); 834 } 835 } 836 verifyResultsConvertShort4Float4(Allocation inV, Allocation out, boolean relaxed)837 private void verifyResultsConvertShort4Float4(Allocation inV, Allocation out, boolean relaxed) { 838 short[] arrayInV = new short[INPUTSIZE * 4]; 839 Arrays.fill(arrayInV, (short) 42); 840 inV.copyTo(arrayInV); 841 float[] arrayOut = new float[INPUTSIZE * 4]; 842 Arrays.fill(arrayOut, (float) 42); 843 out.copyTo(arrayOut); 844 StringBuilder message = new StringBuilder(); 845 boolean errorFound = false; 846 for (int i = 0; i < INPUTSIZE; i++) { 847 for (int j = 0; j < 4 ; j++) { 848 // Extract the inputs. 849 ArgumentsShortFloat args = new ArgumentsShortFloat(); 850 args.inV = arrayInV[i * 4 + j]; 851 // Figure out what the outputs should have been. 852 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 853 CoreMathVerifier.computeConvert(args, target); 854 // Validate the outputs. 855 boolean valid = true; 856 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 857 valid = false; 858 } 859 if (!valid) { 860 if (!errorFound) { 861 errorFound = true; 862 message.append("Input inV: "); 863 appendVariableToMessage(message, args.inV); 864 message.append("\n"); 865 message.append("Expected output out: "); 866 appendVariableToMessage(message, args.out); 867 message.append("\n"); 868 message.append("Actual output out: "); 869 appendVariableToMessage(message, arrayOut[i * 4 + j]); 870 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 871 message.append(" FAIL"); 872 } 873 message.append("\n"); 874 message.append("Errors at"); 875 } 876 message.append(" ["); 877 message.append(Integer.toString(i)); 878 message.append(", "); 879 message.append(Integer.toString(j)); 880 message.append("]"); 881 } 882 } 883 } 884 assertFalse("Incorrect output for checkConvertShort4Float4" + 885 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 886 } 887 888 public class ArgumentsUshortFloat { 889 public short inV; 890 public Target.Floaty out; 891 } 892 checkConvertUshort2Float2()893 private void checkConvertUshort2Float2() { 894 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2c6de12bl, false, 16); 895 try { 896 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 897 script.forEach_testConvertFloat2Ushort2Float2(inV, out); 898 verifyResultsConvertUshort2Float2(inV, out, false); 899 } catch (Exception e) { 900 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString()); 901 } 902 try { 903 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 904 scriptRelaxed.forEach_testConvertFloat2Ushort2Float2(inV, out); 905 verifyResultsConvertUshort2Float2(inV, out, true); 906 } catch (Exception e) { 907 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString()); 908 } 909 } 910 verifyResultsConvertUshort2Float2(Allocation inV, Allocation out, boolean relaxed)911 private void verifyResultsConvertUshort2Float2(Allocation inV, Allocation out, boolean relaxed) { 912 short[] arrayInV = new short[INPUTSIZE * 2]; 913 Arrays.fill(arrayInV, (short) 42); 914 inV.copyTo(arrayInV); 915 float[] arrayOut = new float[INPUTSIZE * 2]; 916 Arrays.fill(arrayOut, (float) 42); 917 out.copyTo(arrayOut); 918 StringBuilder message = new StringBuilder(); 919 boolean errorFound = false; 920 for (int i = 0; i < INPUTSIZE; i++) { 921 for (int j = 0; j < 2 ; j++) { 922 // Extract the inputs. 923 ArgumentsUshortFloat args = new ArgumentsUshortFloat(); 924 args.inV = arrayInV[i * 2 + j]; 925 // Figure out what the outputs should have been. 926 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 927 CoreMathVerifier.computeConvert(args, target); 928 // Validate the outputs. 929 boolean valid = true; 930 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 931 valid = false; 932 } 933 if (!valid) { 934 if (!errorFound) { 935 errorFound = true; 936 message.append("Input inV: "); 937 appendVariableToMessage(message, args.inV); 938 message.append("\n"); 939 message.append("Expected output out: "); 940 appendVariableToMessage(message, args.out); 941 message.append("\n"); 942 message.append("Actual output out: "); 943 appendVariableToMessage(message, arrayOut[i * 2 + j]); 944 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 945 message.append(" FAIL"); 946 } 947 message.append("\n"); 948 message.append("Errors at"); 949 } 950 message.append(" ["); 951 message.append(Integer.toString(i)); 952 message.append(", "); 953 message.append(Integer.toString(j)); 954 message.append("]"); 955 } 956 } 957 } 958 assertFalse("Incorrect output for checkConvertUshort2Float2" + 959 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 960 } 961 checkConvertUshort3Float3()962 private void checkConvertUshort3Float3() { 963 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x22890209l, false, 16); 964 try { 965 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 966 script.forEach_testConvertFloat3Ushort3Float3(inV, out); 967 verifyResultsConvertUshort3Float3(inV, out, false); 968 } catch (Exception e) { 969 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString()); 970 } 971 try { 972 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 973 scriptRelaxed.forEach_testConvertFloat3Ushort3Float3(inV, out); 974 verifyResultsConvertUshort3Float3(inV, out, true); 975 } catch (Exception e) { 976 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString()); 977 } 978 } 979 verifyResultsConvertUshort3Float3(Allocation inV, Allocation out, boolean relaxed)980 private void verifyResultsConvertUshort3Float3(Allocation inV, Allocation out, boolean relaxed) { 981 short[] arrayInV = new short[INPUTSIZE * 4]; 982 Arrays.fill(arrayInV, (short) 42); 983 inV.copyTo(arrayInV); 984 float[] arrayOut = new float[INPUTSIZE * 4]; 985 Arrays.fill(arrayOut, (float) 42); 986 out.copyTo(arrayOut); 987 StringBuilder message = new StringBuilder(); 988 boolean errorFound = false; 989 for (int i = 0; i < INPUTSIZE; i++) { 990 for (int j = 0; j < 3 ; j++) { 991 // Extract the inputs. 992 ArgumentsUshortFloat args = new ArgumentsUshortFloat(); 993 args.inV = arrayInV[i * 4 + j]; 994 // Figure out what the outputs should have been. 995 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 996 CoreMathVerifier.computeConvert(args, target); 997 // Validate the outputs. 998 boolean valid = true; 999 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1000 valid = false; 1001 } 1002 if (!valid) { 1003 if (!errorFound) { 1004 errorFound = true; 1005 message.append("Input inV: "); 1006 appendVariableToMessage(message, args.inV); 1007 message.append("\n"); 1008 message.append("Expected output out: "); 1009 appendVariableToMessage(message, args.out); 1010 message.append("\n"); 1011 message.append("Actual output out: "); 1012 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1013 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1014 message.append(" FAIL"); 1015 } 1016 message.append("\n"); 1017 message.append("Errors at"); 1018 } 1019 message.append(" ["); 1020 message.append(Integer.toString(i)); 1021 message.append(", "); 1022 message.append(Integer.toString(j)); 1023 message.append("]"); 1024 } 1025 } 1026 } 1027 assertFalse("Incorrect output for checkConvertUshort3Float3" + 1028 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1029 } 1030 checkConvertUshort4Float4()1031 private void checkConvertUshort4Float4() { 1032 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x18a422e7l, false, 16); 1033 try { 1034 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1035 script.forEach_testConvertFloat4Ushort4Float4(inV, out); 1036 verifyResultsConvertUshort4Float4(inV, out, false); 1037 } catch (Exception e) { 1038 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString()); 1039 } 1040 try { 1041 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1042 scriptRelaxed.forEach_testConvertFloat4Ushort4Float4(inV, out); 1043 verifyResultsConvertUshort4Float4(inV, out, true); 1044 } catch (Exception e) { 1045 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString()); 1046 } 1047 } 1048 verifyResultsConvertUshort4Float4(Allocation inV, Allocation out, boolean relaxed)1049 private void verifyResultsConvertUshort4Float4(Allocation inV, Allocation out, boolean relaxed) { 1050 short[] arrayInV = new short[INPUTSIZE * 4]; 1051 Arrays.fill(arrayInV, (short) 42); 1052 inV.copyTo(arrayInV); 1053 float[] arrayOut = new float[INPUTSIZE * 4]; 1054 Arrays.fill(arrayOut, (float) 42); 1055 out.copyTo(arrayOut); 1056 StringBuilder message = new StringBuilder(); 1057 boolean errorFound = false; 1058 for (int i = 0; i < INPUTSIZE; i++) { 1059 for (int j = 0; j < 4 ; j++) { 1060 // Extract the inputs. 1061 ArgumentsUshortFloat args = new ArgumentsUshortFloat(); 1062 args.inV = arrayInV[i * 4 + j]; 1063 // Figure out what the outputs should have been. 1064 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1065 CoreMathVerifier.computeConvert(args, target); 1066 // Validate the outputs. 1067 boolean valid = true; 1068 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1069 valid = false; 1070 } 1071 if (!valid) { 1072 if (!errorFound) { 1073 errorFound = true; 1074 message.append("Input inV: "); 1075 appendVariableToMessage(message, args.inV); 1076 message.append("\n"); 1077 message.append("Expected output out: "); 1078 appendVariableToMessage(message, args.out); 1079 message.append("\n"); 1080 message.append("Actual output out: "); 1081 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1082 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1083 message.append(" FAIL"); 1084 } 1085 message.append("\n"); 1086 message.append("Errors at"); 1087 } 1088 message.append(" ["); 1089 message.append(Integer.toString(i)); 1090 message.append(", "); 1091 message.append(Integer.toString(j)); 1092 message.append("]"); 1093 } 1094 } 1095 } 1096 assertFalse("Incorrect output for checkConvertUshort4Float4" + 1097 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1098 } 1099 1100 public class ArgumentsIntFloat { 1101 public int inV; 1102 public Target.Floaty out; 1103 } 1104 checkConvertInt2Float2()1105 private void checkConvertInt2Float2() { 1106 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7402bfc5l, true, 31); 1107 try { 1108 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1109 script.forEach_testConvertFloat2Int2Float2(inV, out); 1110 verifyResultsConvertInt2Float2(inV, out, false); 1111 } catch (Exception e) { 1112 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString()); 1113 } 1114 try { 1115 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1116 scriptRelaxed.forEach_testConvertFloat2Int2Float2(inV, out); 1117 verifyResultsConvertInt2Float2(inV, out, true); 1118 } catch (Exception e) { 1119 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString()); 1120 } 1121 } 1122 verifyResultsConvertInt2Float2(Allocation inV, Allocation out, boolean relaxed)1123 private void verifyResultsConvertInt2Float2(Allocation inV, Allocation out, boolean relaxed) { 1124 int[] arrayInV = new int[INPUTSIZE * 2]; 1125 Arrays.fill(arrayInV, (int) 42); 1126 inV.copyTo(arrayInV); 1127 float[] arrayOut = new float[INPUTSIZE * 2]; 1128 Arrays.fill(arrayOut, (float) 42); 1129 out.copyTo(arrayOut); 1130 StringBuilder message = new StringBuilder(); 1131 boolean errorFound = false; 1132 for (int i = 0; i < INPUTSIZE; i++) { 1133 for (int j = 0; j < 2 ; j++) { 1134 // Extract the inputs. 1135 ArgumentsIntFloat args = new ArgumentsIntFloat(); 1136 args.inV = arrayInV[i * 2 + j]; 1137 // Figure out what the outputs should have been. 1138 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1139 CoreMathVerifier.computeConvert(args, target); 1140 // Validate the outputs. 1141 boolean valid = true; 1142 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1143 valid = false; 1144 } 1145 if (!valid) { 1146 if (!errorFound) { 1147 errorFound = true; 1148 message.append("Input inV: "); 1149 appendVariableToMessage(message, args.inV); 1150 message.append("\n"); 1151 message.append("Expected output out: "); 1152 appendVariableToMessage(message, args.out); 1153 message.append("\n"); 1154 message.append("Actual output out: "); 1155 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1156 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1157 message.append(" FAIL"); 1158 } 1159 message.append("\n"); 1160 message.append("Errors at"); 1161 } 1162 message.append(" ["); 1163 message.append(Integer.toString(i)); 1164 message.append(", "); 1165 message.append(Integer.toString(j)); 1166 message.append("]"); 1167 } 1168 } 1169 } 1170 assertFalse("Incorrect output for checkConvertInt2Float2" + 1171 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1172 } 1173 checkConvertInt3Float3()1174 private void checkConvertInt3Float3() { 1175 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6a1de0a3l, true, 31); 1176 try { 1177 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1178 script.forEach_testConvertFloat3Int3Float3(inV, out); 1179 verifyResultsConvertInt3Float3(inV, out, false); 1180 } catch (Exception e) { 1181 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString()); 1182 } 1183 try { 1184 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1185 scriptRelaxed.forEach_testConvertFloat3Int3Float3(inV, out); 1186 verifyResultsConvertInt3Float3(inV, out, true); 1187 } catch (Exception e) { 1188 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString()); 1189 } 1190 } 1191 verifyResultsConvertInt3Float3(Allocation inV, Allocation out, boolean relaxed)1192 private void verifyResultsConvertInt3Float3(Allocation inV, Allocation out, boolean relaxed) { 1193 int[] arrayInV = new int[INPUTSIZE * 4]; 1194 Arrays.fill(arrayInV, (int) 42); 1195 inV.copyTo(arrayInV); 1196 float[] arrayOut = new float[INPUTSIZE * 4]; 1197 Arrays.fill(arrayOut, (float) 42); 1198 out.copyTo(arrayOut); 1199 StringBuilder message = new StringBuilder(); 1200 boolean errorFound = false; 1201 for (int i = 0; i < INPUTSIZE; i++) { 1202 for (int j = 0; j < 3 ; j++) { 1203 // Extract the inputs. 1204 ArgumentsIntFloat args = new ArgumentsIntFloat(); 1205 args.inV = arrayInV[i * 4 + j]; 1206 // Figure out what the outputs should have been. 1207 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1208 CoreMathVerifier.computeConvert(args, target); 1209 // Validate the outputs. 1210 boolean valid = true; 1211 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1212 valid = false; 1213 } 1214 if (!valid) { 1215 if (!errorFound) { 1216 errorFound = true; 1217 message.append("Input inV: "); 1218 appendVariableToMessage(message, args.inV); 1219 message.append("\n"); 1220 message.append("Expected output out: "); 1221 appendVariableToMessage(message, args.out); 1222 message.append("\n"); 1223 message.append("Actual output out: "); 1224 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1225 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1226 message.append(" FAIL"); 1227 } 1228 message.append("\n"); 1229 message.append("Errors at"); 1230 } 1231 message.append(" ["); 1232 message.append(Integer.toString(i)); 1233 message.append(", "); 1234 message.append(Integer.toString(j)); 1235 message.append("]"); 1236 } 1237 } 1238 } 1239 assertFalse("Incorrect output for checkConvertInt3Float3" + 1240 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1241 } 1242 checkConvertInt4Float4()1243 private void checkConvertInt4Float4() { 1244 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x60390181l, true, 31); 1245 try { 1246 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1247 script.forEach_testConvertFloat4Int4Float4(inV, out); 1248 verifyResultsConvertInt4Float4(inV, out, false); 1249 } catch (Exception e) { 1250 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString()); 1251 } 1252 try { 1253 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1254 scriptRelaxed.forEach_testConvertFloat4Int4Float4(inV, out); 1255 verifyResultsConvertInt4Float4(inV, out, true); 1256 } catch (Exception e) { 1257 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString()); 1258 } 1259 } 1260 verifyResultsConvertInt4Float4(Allocation inV, Allocation out, boolean relaxed)1261 private void verifyResultsConvertInt4Float4(Allocation inV, Allocation out, boolean relaxed) { 1262 int[] arrayInV = new int[INPUTSIZE * 4]; 1263 Arrays.fill(arrayInV, (int) 42); 1264 inV.copyTo(arrayInV); 1265 float[] arrayOut = new float[INPUTSIZE * 4]; 1266 Arrays.fill(arrayOut, (float) 42); 1267 out.copyTo(arrayOut); 1268 StringBuilder message = new StringBuilder(); 1269 boolean errorFound = false; 1270 for (int i = 0; i < INPUTSIZE; i++) { 1271 for (int j = 0; j < 4 ; j++) { 1272 // Extract the inputs. 1273 ArgumentsIntFloat args = new ArgumentsIntFloat(); 1274 args.inV = arrayInV[i * 4 + j]; 1275 // Figure out what the outputs should have been. 1276 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1277 CoreMathVerifier.computeConvert(args, target); 1278 // Validate the outputs. 1279 boolean valid = true; 1280 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1281 valid = false; 1282 } 1283 if (!valid) { 1284 if (!errorFound) { 1285 errorFound = true; 1286 message.append("Input inV: "); 1287 appendVariableToMessage(message, args.inV); 1288 message.append("\n"); 1289 message.append("Expected output out: "); 1290 appendVariableToMessage(message, args.out); 1291 message.append("\n"); 1292 message.append("Actual output out: "); 1293 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1294 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1295 message.append(" FAIL"); 1296 } 1297 message.append("\n"); 1298 message.append("Errors at"); 1299 } 1300 message.append(" ["); 1301 message.append(Integer.toString(i)); 1302 message.append(", "); 1303 message.append(Integer.toString(j)); 1304 message.append("]"); 1305 } 1306 } 1307 } 1308 assertFalse("Incorrect output for checkConvertInt4Float4" + 1309 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1310 } 1311 1312 public class ArgumentsUintFloat { 1313 public int inV; 1314 public Target.Floaty out; 1315 } 1316 checkConvertUint2Float2()1317 private void checkConvertUint2Float2() { 1318 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x684cc46l, false, 32); 1319 try { 1320 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1321 script.forEach_testConvertFloat2Uint2Float2(inV, out); 1322 verifyResultsConvertUint2Float2(inV, out, false); 1323 } catch (Exception e) { 1324 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString()); 1325 } 1326 try { 1327 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 1328 scriptRelaxed.forEach_testConvertFloat2Uint2Float2(inV, out); 1329 verifyResultsConvertUint2Float2(inV, out, true); 1330 } catch (Exception e) { 1331 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString()); 1332 } 1333 } 1334 verifyResultsConvertUint2Float2(Allocation inV, Allocation out, boolean relaxed)1335 private void verifyResultsConvertUint2Float2(Allocation inV, Allocation out, boolean relaxed) { 1336 int[] arrayInV = new int[INPUTSIZE * 2]; 1337 Arrays.fill(arrayInV, (int) 42); 1338 inV.copyTo(arrayInV); 1339 float[] arrayOut = new float[INPUTSIZE * 2]; 1340 Arrays.fill(arrayOut, (float) 42); 1341 out.copyTo(arrayOut); 1342 StringBuilder message = new StringBuilder(); 1343 boolean errorFound = false; 1344 for (int i = 0; i < INPUTSIZE; i++) { 1345 for (int j = 0; j < 2 ; j++) { 1346 // Extract the inputs. 1347 ArgumentsUintFloat args = new ArgumentsUintFloat(); 1348 args.inV = arrayInV[i * 2 + j]; 1349 // Figure out what the outputs should have been. 1350 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1351 CoreMathVerifier.computeConvert(args, target); 1352 // Validate the outputs. 1353 boolean valid = true; 1354 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1355 valid = false; 1356 } 1357 if (!valid) { 1358 if (!errorFound) { 1359 errorFound = true; 1360 message.append("Input inV: "); 1361 appendVariableToMessage(message, args.inV); 1362 message.append("\n"); 1363 message.append("Expected output out: "); 1364 appendVariableToMessage(message, args.out); 1365 message.append("\n"); 1366 message.append("Actual output out: "); 1367 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1368 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 1369 message.append(" FAIL"); 1370 } 1371 message.append("\n"); 1372 message.append("Errors at"); 1373 } 1374 message.append(" ["); 1375 message.append(Integer.toString(i)); 1376 message.append(", "); 1377 message.append(Integer.toString(j)); 1378 message.append("]"); 1379 } 1380 } 1381 } 1382 assertFalse("Incorrect output for checkConvertUint2Float2" + 1383 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1384 } 1385 checkConvertUint3Float3()1386 private void checkConvertUint3Float3() { 1387 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xfc9fed24l, false, 32); 1388 try { 1389 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1390 script.forEach_testConvertFloat3Uint3Float3(inV, out); 1391 verifyResultsConvertUint3Float3(inV, out, false); 1392 } catch (Exception e) { 1393 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString()); 1394 } 1395 try { 1396 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 1397 scriptRelaxed.forEach_testConvertFloat3Uint3Float3(inV, out); 1398 verifyResultsConvertUint3Float3(inV, out, true); 1399 } catch (Exception e) { 1400 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString()); 1401 } 1402 } 1403 verifyResultsConvertUint3Float3(Allocation inV, Allocation out, boolean relaxed)1404 private void verifyResultsConvertUint3Float3(Allocation inV, Allocation out, boolean relaxed) { 1405 int[] arrayInV = new int[INPUTSIZE * 4]; 1406 Arrays.fill(arrayInV, (int) 42); 1407 inV.copyTo(arrayInV); 1408 float[] arrayOut = new float[INPUTSIZE * 4]; 1409 Arrays.fill(arrayOut, (float) 42); 1410 out.copyTo(arrayOut); 1411 StringBuilder message = new StringBuilder(); 1412 boolean errorFound = false; 1413 for (int i = 0; i < INPUTSIZE; i++) { 1414 for (int j = 0; j < 3 ; j++) { 1415 // Extract the inputs. 1416 ArgumentsUintFloat args = new ArgumentsUintFloat(); 1417 args.inV = arrayInV[i * 4 + j]; 1418 // Figure out what the outputs should have been. 1419 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1420 CoreMathVerifier.computeConvert(args, target); 1421 // Validate the outputs. 1422 boolean valid = true; 1423 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1424 valid = false; 1425 } 1426 if (!valid) { 1427 if (!errorFound) { 1428 errorFound = true; 1429 message.append("Input inV: "); 1430 appendVariableToMessage(message, args.inV); 1431 message.append("\n"); 1432 message.append("Expected output out: "); 1433 appendVariableToMessage(message, args.out); 1434 message.append("\n"); 1435 message.append("Actual output out: "); 1436 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1437 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1438 message.append(" FAIL"); 1439 } 1440 message.append("\n"); 1441 message.append("Errors at"); 1442 } 1443 message.append(" ["); 1444 message.append(Integer.toString(i)); 1445 message.append(", "); 1446 message.append(Integer.toString(j)); 1447 message.append("]"); 1448 } 1449 } 1450 } 1451 assertFalse("Incorrect output for checkConvertUint3Float3" + 1452 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1453 } 1454 checkConvertUint4Float4()1455 private void checkConvertUint4Float4() { 1456 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf2bb0e02l, false, 32); 1457 try { 1458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1459 script.forEach_testConvertFloat4Uint4Float4(inV, out); 1460 verifyResultsConvertUint4Float4(inV, out, false); 1461 } catch (Exception e) { 1462 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString()); 1463 } 1464 try { 1465 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 1466 scriptRelaxed.forEach_testConvertFloat4Uint4Float4(inV, out); 1467 verifyResultsConvertUint4Float4(inV, out, true); 1468 } catch (Exception e) { 1469 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString()); 1470 } 1471 } 1472 verifyResultsConvertUint4Float4(Allocation inV, Allocation out, boolean relaxed)1473 private void verifyResultsConvertUint4Float4(Allocation inV, Allocation out, boolean relaxed) { 1474 int[] arrayInV = new int[INPUTSIZE * 4]; 1475 Arrays.fill(arrayInV, (int) 42); 1476 inV.copyTo(arrayInV); 1477 float[] arrayOut = new float[INPUTSIZE * 4]; 1478 Arrays.fill(arrayOut, (float) 42); 1479 out.copyTo(arrayOut); 1480 StringBuilder message = new StringBuilder(); 1481 boolean errorFound = false; 1482 for (int i = 0; i < INPUTSIZE; i++) { 1483 for (int j = 0; j < 4 ; j++) { 1484 // Extract the inputs. 1485 ArgumentsUintFloat args = new ArgumentsUintFloat(); 1486 args.inV = arrayInV[i * 4 + j]; 1487 // Figure out what the outputs should have been. 1488 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 1489 CoreMathVerifier.computeConvert(args, target); 1490 // Validate the outputs. 1491 boolean valid = true; 1492 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1493 valid = false; 1494 } 1495 if (!valid) { 1496 if (!errorFound) { 1497 errorFound = true; 1498 message.append("Input inV: "); 1499 appendVariableToMessage(message, args.inV); 1500 message.append("\n"); 1501 message.append("Expected output out: "); 1502 appendVariableToMessage(message, args.out); 1503 message.append("\n"); 1504 message.append("Actual output out: "); 1505 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1506 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 1507 message.append(" FAIL"); 1508 } 1509 message.append("\n"); 1510 message.append("Errors at"); 1511 } 1512 message.append(" ["); 1513 message.append(Integer.toString(i)); 1514 message.append(", "); 1515 message.append(Integer.toString(j)); 1516 message.append("]"); 1517 } 1518 } 1519 } 1520 assertFalse("Incorrect output for checkConvertUint4Float4" + 1521 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1522 } 1523 1524 public class ArgumentsFloatChar { 1525 public float inV; 1526 public byte out; 1527 } 1528 checkConvertFloat2Char2()1529 private void checkConvertFloat2Char2() { 1530 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x29789662l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 1531 try { 1532 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1533 script.forEach_testConvertChar2Float2Char2(inV, out); 1534 verifyResultsConvertFloat2Char2(inV, out, false); 1535 } catch (Exception e) { 1536 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString()); 1537 } 1538 try { 1539 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1540 scriptRelaxed.forEach_testConvertChar2Float2Char2(inV, out); 1541 verifyResultsConvertFloat2Char2(inV, out, true); 1542 } catch (Exception e) { 1543 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString()); 1544 } 1545 } 1546 verifyResultsConvertFloat2Char2(Allocation inV, Allocation out, boolean relaxed)1547 private void verifyResultsConvertFloat2Char2(Allocation inV, Allocation out, boolean relaxed) { 1548 float[] arrayInV = new float[INPUTSIZE * 2]; 1549 Arrays.fill(arrayInV, (float) 42); 1550 inV.copyTo(arrayInV); 1551 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1552 Arrays.fill(arrayOut, (byte) 42); 1553 out.copyTo(arrayOut); 1554 StringBuilder message = new StringBuilder(); 1555 boolean errorFound = false; 1556 for (int i = 0; i < INPUTSIZE; i++) { 1557 for (int j = 0; j < 2 ; j++) { 1558 // Extract the inputs. 1559 ArgumentsFloatChar args = new ArgumentsFloatChar(); 1560 args.inV = arrayInV[i * 2 + j]; 1561 // Figure out what the outputs should have been. 1562 CoreMathVerifier.computeConvert(args); 1563 // Validate the outputs. 1564 boolean valid = true; 1565 if (args.out != arrayOut[i * 2 + j]) { 1566 valid = false; 1567 } 1568 if (!valid) { 1569 if (!errorFound) { 1570 errorFound = true; 1571 message.append("Input inV: "); 1572 appendVariableToMessage(message, args.inV); 1573 message.append("\n"); 1574 message.append("Expected output out: "); 1575 appendVariableToMessage(message, args.out); 1576 message.append("\n"); 1577 message.append("Actual output out: "); 1578 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1579 if (args.out != arrayOut[i * 2 + j]) { 1580 message.append(" FAIL"); 1581 } 1582 message.append("\n"); 1583 message.append("Errors at"); 1584 } 1585 message.append(" ["); 1586 message.append(Integer.toString(i)); 1587 message.append(", "); 1588 message.append(Integer.toString(j)); 1589 message.append("]"); 1590 } 1591 } 1592 } 1593 assertFalse("Incorrect output for checkConvertFloat2Char2" + 1594 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1595 } 1596 checkConvertFloat3Char3()1597 private void checkConvertFloat3Char3() { 1598 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x88805b56l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 1599 try { 1600 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1601 script.forEach_testConvertChar3Float3Char3(inV, out); 1602 verifyResultsConvertFloat3Char3(inV, out, false); 1603 } catch (Exception e) { 1604 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString()); 1605 } 1606 try { 1607 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1608 scriptRelaxed.forEach_testConvertChar3Float3Char3(inV, out); 1609 verifyResultsConvertFloat3Char3(inV, out, true); 1610 } catch (Exception e) { 1611 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString()); 1612 } 1613 } 1614 verifyResultsConvertFloat3Char3(Allocation inV, Allocation out, boolean relaxed)1615 private void verifyResultsConvertFloat3Char3(Allocation inV, Allocation out, boolean relaxed) { 1616 float[] arrayInV = new float[INPUTSIZE * 4]; 1617 Arrays.fill(arrayInV, (float) 42); 1618 inV.copyTo(arrayInV); 1619 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1620 Arrays.fill(arrayOut, (byte) 42); 1621 out.copyTo(arrayOut); 1622 StringBuilder message = new StringBuilder(); 1623 boolean errorFound = false; 1624 for (int i = 0; i < INPUTSIZE; i++) { 1625 for (int j = 0; j < 3 ; j++) { 1626 // Extract the inputs. 1627 ArgumentsFloatChar args = new ArgumentsFloatChar(); 1628 args.inV = arrayInV[i * 4 + j]; 1629 // Figure out what the outputs should have been. 1630 CoreMathVerifier.computeConvert(args); 1631 // Validate the outputs. 1632 boolean valid = true; 1633 if (args.out != arrayOut[i * 4 + j]) { 1634 valid = false; 1635 } 1636 if (!valid) { 1637 if (!errorFound) { 1638 errorFound = true; 1639 message.append("Input inV: "); 1640 appendVariableToMessage(message, args.inV); 1641 message.append("\n"); 1642 message.append("Expected output out: "); 1643 appendVariableToMessage(message, args.out); 1644 message.append("\n"); 1645 message.append("Actual output out: "); 1646 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1647 if (args.out != arrayOut[i * 4 + j]) { 1648 message.append(" FAIL"); 1649 } 1650 message.append("\n"); 1651 message.append("Errors at"); 1652 } 1653 message.append(" ["); 1654 message.append(Integer.toString(i)); 1655 message.append(", "); 1656 message.append(Integer.toString(j)); 1657 message.append("]"); 1658 } 1659 } 1660 } 1661 assertFalse("Incorrect output for checkConvertFloat3Char3" + 1662 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1663 } 1664 checkConvertFloat4Char4()1665 private void checkConvertFloat4Char4() { 1666 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe788204al, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 1667 try { 1668 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1669 script.forEach_testConvertChar4Float4Char4(inV, out); 1670 verifyResultsConvertFloat4Char4(inV, out, false); 1671 } catch (Exception e) { 1672 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString()); 1673 } 1674 try { 1675 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1676 scriptRelaxed.forEach_testConvertChar4Float4Char4(inV, out); 1677 verifyResultsConvertFloat4Char4(inV, out, true); 1678 } catch (Exception e) { 1679 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString()); 1680 } 1681 } 1682 verifyResultsConvertFloat4Char4(Allocation inV, Allocation out, boolean relaxed)1683 private void verifyResultsConvertFloat4Char4(Allocation inV, Allocation out, boolean relaxed) { 1684 float[] arrayInV = new float[INPUTSIZE * 4]; 1685 Arrays.fill(arrayInV, (float) 42); 1686 inV.copyTo(arrayInV); 1687 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1688 Arrays.fill(arrayOut, (byte) 42); 1689 out.copyTo(arrayOut); 1690 StringBuilder message = new StringBuilder(); 1691 boolean errorFound = false; 1692 for (int i = 0; i < INPUTSIZE; i++) { 1693 for (int j = 0; j < 4 ; j++) { 1694 // Extract the inputs. 1695 ArgumentsFloatChar args = new ArgumentsFloatChar(); 1696 args.inV = arrayInV[i * 4 + j]; 1697 // Figure out what the outputs should have been. 1698 CoreMathVerifier.computeConvert(args); 1699 // Validate the outputs. 1700 boolean valid = true; 1701 if (args.out != arrayOut[i * 4 + j]) { 1702 valid = false; 1703 } 1704 if (!valid) { 1705 if (!errorFound) { 1706 errorFound = true; 1707 message.append("Input inV: "); 1708 appendVariableToMessage(message, args.inV); 1709 message.append("\n"); 1710 message.append("Expected output out: "); 1711 appendVariableToMessage(message, args.out); 1712 message.append("\n"); 1713 message.append("Actual output out: "); 1714 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1715 if (args.out != arrayOut[i * 4 + j]) { 1716 message.append(" FAIL"); 1717 } 1718 message.append("\n"); 1719 message.append("Errors at"); 1720 } 1721 message.append(" ["); 1722 message.append(Integer.toString(i)); 1723 message.append(", "); 1724 message.append(Integer.toString(j)); 1725 message.append("]"); 1726 } 1727 } 1728 } 1729 assertFalse("Incorrect output for checkConvertFloat4Char4" + 1730 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1731 } 1732 1733 public class ArgumentsCharChar { 1734 public byte inV; 1735 public byte out; 1736 } 1737 checkConvertChar2Char2()1738 private void checkConvertChar2Char2() { 1739 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd5086da2l, true, 7); 1740 try { 1741 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1742 script.forEach_testConvertChar2Char2Char2(inV, out); 1743 verifyResultsConvertChar2Char2(inV, out, false); 1744 } catch (Exception e) { 1745 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString()); 1746 } 1747 try { 1748 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1749 scriptRelaxed.forEach_testConvertChar2Char2Char2(inV, out); 1750 verifyResultsConvertChar2Char2(inV, out, true); 1751 } catch (Exception e) { 1752 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString()); 1753 } 1754 } 1755 verifyResultsConvertChar2Char2(Allocation inV, Allocation out, boolean relaxed)1756 private void verifyResultsConvertChar2Char2(Allocation inV, Allocation out, boolean relaxed) { 1757 byte[] arrayInV = new byte[INPUTSIZE * 2]; 1758 Arrays.fill(arrayInV, (byte) 42); 1759 inV.copyTo(arrayInV); 1760 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1761 Arrays.fill(arrayOut, (byte) 42); 1762 out.copyTo(arrayOut); 1763 StringBuilder message = new StringBuilder(); 1764 boolean errorFound = false; 1765 for (int i = 0; i < INPUTSIZE; i++) { 1766 for (int j = 0; j < 2 ; j++) { 1767 // Extract the inputs. 1768 ArgumentsCharChar args = new ArgumentsCharChar(); 1769 args.inV = arrayInV[i * 2 + j]; 1770 // Figure out what the outputs should have been. 1771 CoreMathVerifier.computeConvert(args); 1772 // Validate the outputs. 1773 boolean valid = true; 1774 if (args.out != arrayOut[i * 2 + j]) { 1775 valid = false; 1776 } 1777 if (!valid) { 1778 if (!errorFound) { 1779 errorFound = true; 1780 message.append("Input inV: "); 1781 appendVariableToMessage(message, args.inV); 1782 message.append("\n"); 1783 message.append("Expected output out: "); 1784 appendVariableToMessage(message, args.out); 1785 message.append("\n"); 1786 message.append("Actual output out: "); 1787 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1788 if (args.out != arrayOut[i * 2 + j]) { 1789 message.append(" FAIL"); 1790 } 1791 message.append("\n"); 1792 message.append("Errors at"); 1793 } 1794 message.append(" ["); 1795 message.append(Integer.toString(i)); 1796 message.append(", "); 1797 message.append(Integer.toString(j)); 1798 message.append("]"); 1799 } 1800 } 1801 } 1802 assertFalse("Incorrect output for checkConvertChar2Char2" + 1803 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1804 } 1805 checkConvertChar3Char3()1806 private void checkConvertChar3Char3() { 1807 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x34103296l, true, 7); 1808 try { 1809 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1810 script.forEach_testConvertChar3Char3Char3(inV, out); 1811 verifyResultsConvertChar3Char3(inV, out, false); 1812 } catch (Exception e) { 1813 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString()); 1814 } 1815 try { 1816 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 1817 scriptRelaxed.forEach_testConvertChar3Char3Char3(inV, out); 1818 verifyResultsConvertChar3Char3(inV, out, true); 1819 } catch (Exception e) { 1820 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString()); 1821 } 1822 } 1823 verifyResultsConvertChar3Char3(Allocation inV, Allocation out, boolean relaxed)1824 private void verifyResultsConvertChar3Char3(Allocation inV, Allocation out, boolean relaxed) { 1825 byte[] arrayInV = new byte[INPUTSIZE * 4]; 1826 Arrays.fill(arrayInV, (byte) 42); 1827 inV.copyTo(arrayInV); 1828 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1829 Arrays.fill(arrayOut, (byte) 42); 1830 out.copyTo(arrayOut); 1831 StringBuilder message = new StringBuilder(); 1832 boolean errorFound = false; 1833 for (int i = 0; i < INPUTSIZE; i++) { 1834 for (int j = 0; j < 3 ; j++) { 1835 // Extract the inputs. 1836 ArgumentsCharChar args = new ArgumentsCharChar(); 1837 args.inV = arrayInV[i * 4 + j]; 1838 // Figure out what the outputs should have been. 1839 CoreMathVerifier.computeConvert(args); 1840 // Validate the outputs. 1841 boolean valid = true; 1842 if (args.out != arrayOut[i * 4 + j]) { 1843 valid = false; 1844 } 1845 if (!valid) { 1846 if (!errorFound) { 1847 errorFound = true; 1848 message.append("Input inV: "); 1849 appendVariableToMessage(message, args.inV); 1850 message.append("\n"); 1851 message.append("Expected output out: "); 1852 appendVariableToMessage(message, args.out); 1853 message.append("\n"); 1854 message.append("Actual output out: "); 1855 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1856 if (args.out != arrayOut[i * 4 + j]) { 1857 message.append(" FAIL"); 1858 } 1859 message.append("\n"); 1860 message.append("Errors at"); 1861 } 1862 message.append(" ["); 1863 message.append(Integer.toString(i)); 1864 message.append(", "); 1865 message.append(Integer.toString(j)); 1866 message.append("]"); 1867 } 1868 } 1869 } 1870 assertFalse("Incorrect output for checkConvertChar3Char3" + 1871 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1872 } 1873 checkConvertChar4Char4()1874 private void checkConvertChar4Char4() { 1875 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x9317f78al, true, 7); 1876 try { 1877 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1878 script.forEach_testConvertChar4Char4Char4(inV, out); 1879 verifyResultsConvertChar4Char4(inV, out, false); 1880 } catch (Exception e) { 1881 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString()); 1882 } 1883 try { 1884 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 1885 scriptRelaxed.forEach_testConvertChar4Char4Char4(inV, out); 1886 verifyResultsConvertChar4Char4(inV, out, true); 1887 } catch (Exception e) { 1888 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString()); 1889 } 1890 } 1891 verifyResultsConvertChar4Char4(Allocation inV, Allocation out, boolean relaxed)1892 private void verifyResultsConvertChar4Char4(Allocation inV, Allocation out, boolean relaxed) { 1893 byte[] arrayInV = new byte[INPUTSIZE * 4]; 1894 Arrays.fill(arrayInV, (byte) 42); 1895 inV.copyTo(arrayInV); 1896 byte[] arrayOut = new byte[INPUTSIZE * 4]; 1897 Arrays.fill(arrayOut, (byte) 42); 1898 out.copyTo(arrayOut); 1899 StringBuilder message = new StringBuilder(); 1900 boolean errorFound = false; 1901 for (int i = 0; i < INPUTSIZE; i++) { 1902 for (int j = 0; j < 4 ; j++) { 1903 // Extract the inputs. 1904 ArgumentsCharChar args = new ArgumentsCharChar(); 1905 args.inV = arrayInV[i * 4 + j]; 1906 // Figure out what the outputs should have been. 1907 CoreMathVerifier.computeConvert(args); 1908 // Validate the outputs. 1909 boolean valid = true; 1910 if (args.out != arrayOut[i * 4 + j]) { 1911 valid = false; 1912 } 1913 if (!valid) { 1914 if (!errorFound) { 1915 errorFound = true; 1916 message.append("Input inV: "); 1917 appendVariableToMessage(message, args.inV); 1918 message.append("\n"); 1919 message.append("Expected output out: "); 1920 appendVariableToMessage(message, args.out); 1921 message.append("\n"); 1922 message.append("Actual output out: "); 1923 appendVariableToMessage(message, arrayOut[i * 4 + j]); 1924 if (args.out != arrayOut[i * 4 + j]) { 1925 message.append(" FAIL"); 1926 } 1927 message.append("\n"); 1928 message.append("Errors at"); 1929 } 1930 message.append(" ["); 1931 message.append(Integer.toString(i)); 1932 message.append(", "); 1933 message.append(Integer.toString(j)); 1934 message.append("]"); 1935 } 1936 } 1937 } 1938 assertFalse("Incorrect output for checkConvertChar4Char4" + 1939 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 1940 } 1941 1942 public class ArgumentsUcharChar { 1943 public byte inV; 1944 public byte out; 1945 } 1946 checkConvertUchar2Char2()1947 private void checkConvertUchar2Char2() { 1948 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x678a7a23l, false, 7); 1949 try { 1950 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1951 script.forEach_testConvertChar2Uchar2Char2(inV, out); 1952 verifyResultsConvertUchar2Char2(inV, out, false); 1953 } catch (Exception e) { 1954 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString()); 1955 } 1956 try { 1957 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 1958 scriptRelaxed.forEach_testConvertChar2Uchar2Char2(inV, out); 1959 verifyResultsConvertUchar2Char2(inV, out, true); 1960 } catch (Exception e) { 1961 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString()); 1962 } 1963 } 1964 verifyResultsConvertUchar2Char2(Allocation inV, Allocation out, boolean relaxed)1965 private void verifyResultsConvertUchar2Char2(Allocation inV, Allocation out, boolean relaxed) { 1966 byte[] arrayInV = new byte[INPUTSIZE * 2]; 1967 Arrays.fill(arrayInV, (byte) 42); 1968 inV.copyTo(arrayInV); 1969 byte[] arrayOut = new byte[INPUTSIZE * 2]; 1970 Arrays.fill(arrayOut, (byte) 42); 1971 out.copyTo(arrayOut); 1972 StringBuilder message = new StringBuilder(); 1973 boolean errorFound = false; 1974 for (int i = 0; i < INPUTSIZE; i++) { 1975 for (int j = 0; j < 2 ; j++) { 1976 // Extract the inputs. 1977 ArgumentsUcharChar args = new ArgumentsUcharChar(); 1978 args.inV = arrayInV[i * 2 + j]; 1979 // Figure out what the outputs should have been. 1980 CoreMathVerifier.computeConvert(args); 1981 // Validate the outputs. 1982 boolean valid = true; 1983 if (args.out != arrayOut[i * 2 + j]) { 1984 valid = false; 1985 } 1986 if (!valid) { 1987 if (!errorFound) { 1988 errorFound = true; 1989 message.append("Input inV: "); 1990 appendVariableToMessage(message, args.inV); 1991 message.append("\n"); 1992 message.append("Expected output out: "); 1993 appendVariableToMessage(message, args.out); 1994 message.append("\n"); 1995 message.append("Actual output out: "); 1996 appendVariableToMessage(message, arrayOut[i * 2 + j]); 1997 if (args.out != arrayOut[i * 2 + j]) { 1998 message.append(" FAIL"); 1999 } 2000 message.append("\n"); 2001 message.append("Errors at"); 2002 } 2003 message.append(" ["); 2004 message.append(Integer.toString(i)); 2005 message.append(", "); 2006 message.append(Integer.toString(j)); 2007 message.append("]"); 2008 } 2009 } 2010 } 2011 assertFalse("Incorrect output for checkConvertUchar2Char2" + 2012 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2013 } 2014 checkConvertUchar3Char3()2015 private void checkConvertUchar3Char3() { 2016 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xc6923f17l, false, 7); 2017 try { 2018 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2019 script.forEach_testConvertChar3Uchar3Char3(inV, out); 2020 verifyResultsConvertUchar3Char3(inV, out, false); 2021 } catch (Exception e) { 2022 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString()); 2023 } 2024 try { 2025 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2026 scriptRelaxed.forEach_testConvertChar3Uchar3Char3(inV, out); 2027 verifyResultsConvertUchar3Char3(inV, out, true); 2028 } catch (Exception e) { 2029 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString()); 2030 } 2031 } 2032 verifyResultsConvertUchar3Char3(Allocation inV, Allocation out, boolean relaxed)2033 private void verifyResultsConvertUchar3Char3(Allocation inV, Allocation out, boolean relaxed) { 2034 byte[] arrayInV = new byte[INPUTSIZE * 4]; 2035 Arrays.fill(arrayInV, (byte) 42); 2036 inV.copyTo(arrayInV); 2037 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2038 Arrays.fill(arrayOut, (byte) 42); 2039 out.copyTo(arrayOut); 2040 StringBuilder message = new StringBuilder(); 2041 boolean errorFound = false; 2042 for (int i = 0; i < INPUTSIZE; i++) { 2043 for (int j = 0; j < 3 ; j++) { 2044 // Extract the inputs. 2045 ArgumentsUcharChar args = new ArgumentsUcharChar(); 2046 args.inV = arrayInV[i * 4 + j]; 2047 // Figure out what the outputs should have been. 2048 CoreMathVerifier.computeConvert(args); 2049 // Validate the outputs. 2050 boolean valid = true; 2051 if (args.out != arrayOut[i * 4 + j]) { 2052 valid = false; 2053 } 2054 if (!valid) { 2055 if (!errorFound) { 2056 errorFound = true; 2057 message.append("Input inV: "); 2058 appendVariableToMessage(message, args.inV); 2059 message.append("\n"); 2060 message.append("Expected output out: "); 2061 appendVariableToMessage(message, args.out); 2062 message.append("\n"); 2063 message.append("Actual output out: "); 2064 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2065 if (args.out != arrayOut[i * 4 + j]) { 2066 message.append(" FAIL"); 2067 } 2068 message.append("\n"); 2069 message.append("Errors at"); 2070 } 2071 message.append(" ["); 2072 message.append(Integer.toString(i)); 2073 message.append(", "); 2074 message.append(Integer.toString(j)); 2075 message.append("]"); 2076 } 2077 } 2078 } 2079 assertFalse("Incorrect output for checkConvertUchar3Char3" + 2080 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2081 } 2082 checkConvertUchar4Char4()2083 private void checkConvertUchar4Char4() { 2084 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x259a040bl, false, 7); 2085 try { 2086 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2087 script.forEach_testConvertChar4Uchar4Char4(inV, out); 2088 verifyResultsConvertUchar4Char4(inV, out, false); 2089 } catch (Exception e) { 2090 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString()); 2091 } 2092 try { 2093 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2094 scriptRelaxed.forEach_testConvertChar4Uchar4Char4(inV, out); 2095 verifyResultsConvertUchar4Char4(inV, out, true); 2096 } catch (Exception e) { 2097 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString()); 2098 } 2099 } 2100 verifyResultsConvertUchar4Char4(Allocation inV, Allocation out, boolean relaxed)2101 private void verifyResultsConvertUchar4Char4(Allocation inV, Allocation out, boolean relaxed) { 2102 byte[] arrayInV = new byte[INPUTSIZE * 4]; 2103 Arrays.fill(arrayInV, (byte) 42); 2104 inV.copyTo(arrayInV); 2105 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2106 Arrays.fill(arrayOut, (byte) 42); 2107 out.copyTo(arrayOut); 2108 StringBuilder message = new StringBuilder(); 2109 boolean errorFound = false; 2110 for (int i = 0; i < INPUTSIZE; i++) { 2111 for (int j = 0; j < 4 ; j++) { 2112 // Extract the inputs. 2113 ArgumentsUcharChar args = new ArgumentsUcharChar(); 2114 args.inV = arrayInV[i * 4 + j]; 2115 // Figure out what the outputs should have been. 2116 CoreMathVerifier.computeConvert(args); 2117 // Validate the outputs. 2118 boolean valid = true; 2119 if (args.out != arrayOut[i * 4 + j]) { 2120 valid = false; 2121 } 2122 if (!valid) { 2123 if (!errorFound) { 2124 errorFound = true; 2125 message.append("Input inV: "); 2126 appendVariableToMessage(message, args.inV); 2127 message.append("\n"); 2128 message.append("Expected output out: "); 2129 appendVariableToMessage(message, args.out); 2130 message.append("\n"); 2131 message.append("Actual output out: "); 2132 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2133 if (args.out != arrayOut[i * 4 + j]) { 2134 message.append(" FAIL"); 2135 } 2136 message.append("\n"); 2137 message.append("Errors at"); 2138 } 2139 message.append(" ["); 2140 message.append(Integer.toString(i)); 2141 message.append(", "); 2142 message.append(Integer.toString(j)); 2143 message.append("]"); 2144 } 2145 } 2146 } 2147 assertFalse("Incorrect output for checkConvertUchar4Char4" + 2148 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2149 } 2150 2151 public class ArgumentsShortChar { 2152 public short inV; 2153 public byte out; 2154 } 2155 checkConvertShort2Char2()2156 private void checkConvertShort2Char2() { 2157 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x15c60866l, true, 7); 2158 try { 2159 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2160 script.forEach_testConvertChar2Short2Char2(inV, out); 2161 verifyResultsConvertShort2Char2(inV, out, false); 2162 } catch (Exception e) { 2163 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString()); 2164 } 2165 try { 2166 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2167 scriptRelaxed.forEach_testConvertChar2Short2Char2(inV, out); 2168 verifyResultsConvertShort2Char2(inV, out, true); 2169 } catch (Exception e) { 2170 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString()); 2171 } 2172 } 2173 verifyResultsConvertShort2Char2(Allocation inV, Allocation out, boolean relaxed)2174 private void verifyResultsConvertShort2Char2(Allocation inV, Allocation out, boolean relaxed) { 2175 short[] arrayInV = new short[INPUTSIZE * 2]; 2176 Arrays.fill(arrayInV, (short) 42); 2177 inV.copyTo(arrayInV); 2178 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2179 Arrays.fill(arrayOut, (byte) 42); 2180 out.copyTo(arrayOut); 2181 StringBuilder message = new StringBuilder(); 2182 boolean errorFound = false; 2183 for (int i = 0; i < INPUTSIZE; i++) { 2184 for (int j = 0; j < 2 ; j++) { 2185 // Extract the inputs. 2186 ArgumentsShortChar args = new ArgumentsShortChar(); 2187 args.inV = arrayInV[i * 2 + j]; 2188 // Figure out what the outputs should have been. 2189 CoreMathVerifier.computeConvert(args); 2190 // Validate the outputs. 2191 boolean valid = true; 2192 if (args.out != arrayOut[i * 2 + j]) { 2193 valid = false; 2194 } 2195 if (!valid) { 2196 if (!errorFound) { 2197 errorFound = true; 2198 message.append("Input inV: "); 2199 appendVariableToMessage(message, args.inV); 2200 message.append("\n"); 2201 message.append("Expected output out: "); 2202 appendVariableToMessage(message, args.out); 2203 message.append("\n"); 2204 message.append("Actual output out: "); 2205 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2206 if (args.out != arrayOut[i * 2 + j]) { 2207 message.append(" FAIL"); 2208 } 2209 message.append("\n"); 2210 message.append("Errors at"); 2211 } 2212 message.append(" ["); 2213 message.append(Integer.toString(i)); 2214 message.append(", "); 2215 message.append(Integer.toString(j)); 2216 message.append("]"); 2217 } 2218 } 2219 } 2220 assertFalse("Incorrect output for checkConvertShort2Char2" + 2221 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2222 } 2223 checkConvertShort3Char3()2224 private void checkConvertShort3Char3() { 2225 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x74cdcd5al, true, 7); 2226 try { 2227 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2228 script.forEach_testConvertChar3Short3Char3(inV, out); 2229 verifyResultsConvertShort3Char3(inV, out, false); 2230 } catch (Exception e) { 2231 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString()); 2232 } 2233 try { 2234 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2235 scriptRelaxed.forEach_testConvertChar3Short3Char3(inV, out); 2236 verifyResultsConvertShort3Char3(inV, out, true); 2237 } catch (Exception e) { 2238 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString()); 2239 } 2240 } 2241 verifyResultsConvertShort3Char3(Allocation inV, Allocation out, boolean relaxed)2242 private void verifyResultsConvertShort3Char3(Allocation inV, Allocation out, boolean relaxed) { 2243 short[] arrayInV = new short[INPUTSIZE * 4]; 2244 Arrays.fill(arrayInV, (short) 42); 2245 inV.copyTo(arrayInV); 2246 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2247 Arrays.fill(arrayOut, (byte) 42); 2248 out.copyTo(arrayOut); 2249 StringBuilder message = new StringBuilder(); 2250 boolean errorFound = false; 2251 for (int i = 0; i < INPUTSIZE; i++) { 2252 for (int j = 0; j < 3 ; j++) { 2253 // Extract the inputs. 2254 ArgumentsShortChar args = new ArgumentsShortChar(); 2255 args.inV = arrayInV[i * 4 + j]; 2256 // Figure out what the outputs should have been. 2257 CoreMathVerifier.computeConvert(args); 2258 // Validate the outputs. 2259 boolean valid = true; 2260 if (args.out != arrayOut[i * 4 + j]) { 2261 valid = false; 2262 } 2263 if (!valid) { 2264 if (!errorFound) { 2265 errorFound = true; 2266 message.append("Input inV: "); 2267 appendVariableToMessage(message, args.inV); 2268 message.append("\n"); 2269 message.append("Expected output out: "); 2270 appendVariableToMessage(message, args.out); 2271 message.append("\n"); 2272 message.append("Actual output out: "); 2273 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2274 if (args.out != arrayOut[i * 4 + j]) { 2275 message.append(" FAIL"); 2276 } 2277 message.append("\n"); 2278 message.append("Errors at"); 2279 } 2280 message.append(" ["); 2281 message.append(Integer.toString(i)); 2282 message.append(", "); 2283 message.append(Integer.toString(j)); 2284 message.append("]"); 2285 } 2286 } 2287 } 2288 assertFalse("Incorrect output for checkConvertShort3Char3" + 2289 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2290 } 2291 checkConvertShort4Char4()2292 private void checkConvertShort4Char4() { 2293 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xd3d5924el, true, 7); 2294 try { 2295 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2296 script.forEach_testConvertChar4Short4Char4(inV, out); 2297 verifyResultsConvertShort4Char4(inV, out, false); 2298 } catch (Exception e) { 2299 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString()); 2300 } 2301 try { 2302 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2303 scriptRelaxed.forEach_testConvertChar4Short4Char4(inV, out); 2304 verifyResultsConvertShort4Char4(inV, out, true); 2305 } catch (Exception e) { 2306 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString()); 2307 } 2308 } 2309 verifyResultsConvertShort4Char4(Allocation inV, Allocation out, boolean relaxed)2310 private void verifyResultsConvertShort4Char4(Allocation inV, Allocation out, boolean relaxed) { 2311 short[] arrayInV = new short[INPUTSIZE * 4]; 2312 Arrays.fill(arrayInV, (short) 42); 2313 inV.copyTo(arrayInV); 2314 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2315 Arrays.fill(arrayOut, (byte) 42); 2316 out.copyTo(arrayOut); 2317 StringBuilder message = new StringBuilder(); 2318 boolean errorFound = false; 2319 for (int i = 0; i < INPUTSIZE; i++) { 2320 for (int j = 0; j < 4 ; j++) { 2321 // Extract the inputs. 2322 ArgumentsShortChar args = new ArgumentsShortChar(); 2323 args.inV = arrayInV[i * 4 + j]; 2324 // Figure out what the outputs should have been. 2325 CoreMathVerifier.computeConvert(args); 2326 // Validate the outputs. 2327 boolean valid = true; 2328 if (args.out != arrayOut[i * 4 + j]) { 2329 valid = false; 2330 } 2331 if (!valid) { 2332 if (!errorFound) { 2333 errorFound = true; 2334 message.append("Input inV: "); 2335 appendVariableToMessage(message, args.inV); 2336 message.append("\n"); 2337 message.append("Expected output out: "); 2338 appendVariableToMessage(message, args.out); 2339 message.append("\n"); 2340 message.append("Actual output out: "); 2341 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2342 if (args.out != arrayOut[i * 4 + j]) { 2343 message.append(" FAIL"); 2344 } 2345 message.append("\n"); 2346 message.append("Errors at"); 2347 } 2348 message.append(" ["); 2349 message.append(Integer.toString(i)); 2350 message.append(", "); 2351 message.append(Integer.toString(j)); 2352 message.append("]"); 2353 } 2354 } 2355 } 2356 assertFalse("Incorrect output for checkConvertShort4Char4" + 2357 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2358 } 2359 2360 public class ArgumentsUshortChar { 2361 public short inV; 2362 public byte out; 2363 } 2364 checkConvertUshort2Char2()2365 private void checkConvertUshort2Char2() { 2366 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb19e2211l, false, 7); 2367 try { 2368 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2369 script.forEach_testConvertChar2Ushort2Char2(inV, out); 2370 verifyResultsConvertUshort2Char2(inV, out, false); 2371 } catch (Exception e) { 2372 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString()); 2373 } 2374 try { 2375 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2376 scriptRelaxed.forEach_testConvertChar2Ushort2Char2(inV, out); 2377 verifyResultsConvertUshort2Char2(inV, out, true); 2378 } catch (Exception e) { 2379 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString()); 2380 } 2381 } 2382 verifyResultsConvertUshort2Char2(Allocation inV, Allocation out, boolean relaxed)2383 private void verifyResultsConvertUshort2Char2(Allocation inV, Allocation out, boolean relaxed) { 2384 short[] arrayInV = new short[INPUTSIZE * 2]; 2385 Arrays.fill(arrayInV, (short) 42); 2386 inV.copyTo(arrayInV); 2387 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2388 Arrays.fill(arrayOut, (byte) 42); 2389 out.copyTo(arrayOut); 2390 StringBuilder message = new StringBuilder(); 2391 boolean errorFound = false; 2392 for (int i = 0; i < INPUTSIZE; i++) { 2393 for (int j = 0; j < 2 ; j++) { 2394 // Extract the inputs. 2395 ArgumentsUshortChar args = new ArgumentsUshortChar(); 2396 args.inV = arrayInV[i * 2 + j]; 2397 // Figure out what the outputs should have been. 2398 CoreMathVerifier.computeConvert(args); 2399 // Validate the outputs. 2400 boolean valid = true; 2401 if (args.out != arrayOut[i * 2 + j]) { 2402 valid = false; 2403 } 2404 if (!valid) { 2405 if (!errorFound) { 2406 errorFound = true; 2407 message.append("Input inV: "); 2408 appendVariableToMessage(message, args.inV); 2409 message.append("\n"); 2410 message.append("Expected output out: "); 2411 appendVariableToMessage(message, args.out); 2412 message.append("\n"); 2413 message.append("Actual output out: "); 2414 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2415 if (args.out != arrayOut[i * 2 + j]) { 2416 message.append(" FAIL"); 2417 } 2418 message.append("\n"); 2419 message.append("Errors at"); 2420 } 2421 message.append(" ["); 2422 message.append(Integer.toString(i)); 2423 message.append(", "); 2424 message.append(Integer.toString(j)); 2425 message.append("]"); 2426 } 2427 } 2428 } 2429 assertFalse("Incorrect output for checkConvertUshort2Char2" + 2430 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2431 } 2432 checkConvertUshort3Char3()2433 private void checkConvertUshort3Char3() { 2434 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x10a5e705l, false, 7); 2435 try { 2436 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2437 script.forEach_testConvertChar3Ushort3Char3(inV, out); 2438 verifyResultsConvertUshort3Char3(inV, out, false); 2439 } catch (Exception e) { 2440 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString()); 2441 } 2442 try { 2443 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2444 scriptRelaxed.forEach_testConvertChar3Ushort3Char3(inV, out); 2445 verifyResultsConvertUshort3Char3(inV, out, true); 2446 } catch (Exception e) { 2447 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString()); 2448 } 2449 } 2450 verifyResultsConvertUshort3Char3(Allocation inV, Allocation out, boolean relaxed)2451 private void verifyResultsConvertUshort3Char3(Allocation inV, Allocation out, boolean relaxed) { 2452 short[] arrayInV = new short[INPUTSIZE * 4]; 2453 Arrays.fill(arrayInV, (short) 42); 2454 inV.copyTo(arrayInV); 2455 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2456 Arrays.fill(arrayOut, (byte) 42); 2457 out.copyTo(arrayOut); 2458 StringBuilder message = new StringBuilder(); 2459 boolean errorFound = false; 2460 for (int i = 0; i < INPUTSIZE; i++) { 2461 for (int j = 0; j < 3 ; j++) { 2462 // Extract the inputs. 2463 ArgumentsUshortChar args = new ArgumentsUshortChar(); 2464 args.inV = arrayInV[i * 4 + j]; 2465 // Figure out what the outputs should have been. 2466 CoreMathVerifier.computeConvert(args); 2467 // Validate the outputs. 2468 boolean valid = true; 2469 if (args.out != arrayOut[i * 4 + j]) { 2470 valid = false; 2471 } 2472 if (!valid) { 2473 if (!errorFound) { 2474 errorFound = true; 2475 message.append("Input inV: "); 2476 appendVariableToMessage(message, args.inV); 2477 message.append("\n"); 2478 message.append("Expected output out: "); 2479 appendVariableToMessage(message, args.out); 2480 message.append("\n"); 2481 message.append("Actual output out: "); 2482 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2483 if (args.out != arrayOut[i * 4 + j]) { 2484 message.append(" FAIL"); 2485 } 2486 message.append("\n"); 2487 message.append("Errors at"); 2488 } 2489 message.append(" ["); 2490 message.append(Integer.toString(i)); 2491 message.append(", "); 2492 message.append(Integer.toString(j)); 2493 message.append("]"); 2494 } 2495 } 2496 } 2497 assertFalse("Incorrect output for checkConvertUshort3Char3" + 2498 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2499 } 2500 checkConvertUshort4Char4()2501 private void checkConvertUshort4Char4() { 2502 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x6fadabf9l, false, 7); 2503 try { 2504 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2505 script.forEach_testConvertChar4Ushort4Char4(inV, out); 2506 verifyResultsConvertUshort4Char4(inV, out, false); 2507 } catch (Exception e) { 2508 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString()); 2509 } 2510 try { 2511 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2512 scriptRelaxed.forEach_testConvertChar4Ushort4Char4(inV, out); 2513 verifyResultsConvertUshort4Char4(inV, out, true); 2514 } catch (Exception e) { 2515 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString()); 2516 } 2517 } 2518 verifyResultsConvertUshort4Char4(Allocation inV, Allocation out, boolean relaxed)2519 private void verifyResultsConvertUshort4Char4(Allocation inV, Allocation out, boolean relaxed) { 2520 short[] arrayInV = new short[INPUTSIZE * 4]; 2521 Arrays.fill(arrayInV, (short) 42); 2522 inV.copyTo(arrayInV); 2523 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2524 Arrays.fill(arrayOut, (byte) 42); 2525 out.copyTo(arrayOut); 2526 StringBuilder message = new StringBuilder(); 2527 boolean errorFound = false; 2528 for (int i = 0; i < INPUTSIZE; i++) { 2529 for (int j = 0; j < 4 ; j++) { 2530 // Extract the inputs. 2531 ArgumentsUshortChar args = new ArgumentsUshortChar(); 2532 args.inV = arrayInV[i * 4 + j]; 2533 // Figure out what the outputs should have been. 2534 CoreMathVerifier.computeConvert(args); 2535 // Validate the outputs. 2536 boolean valid = true; 2537 if (args.out != arrayOut[i * 4 + j]) { 2538 valid = false; 2539 } 2540 if (!valid) { 2541 if (!errorFound) { 2542 errorFound = true; 2543 message.append("Input inV: "); 2544 appendVariableToMessage(message, args.inV); 2545 message.append("\n"); 2546 message.append("Expected output out: "); 2547 appendVariableToMessage(message, args.out); 2548 message.append("\n"); 2549 message.append("Actual output out: "); 2550 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2551 if (args.out != arrayOut[i * 4 + j]) { 2552 message.append(" FAIL"); 2553 } 2554 message.append("\n"); 2555 message.append("Errors at"); 2556 } 2557 message.append(" ["); 2558 message.append(Integer.toString(i)); 2559 message.append(", "); 2560 message.append(Integer.toString(j)); 2561 message.append("]"); 2562 } 2563 } 2564 } 2565 assertFalse("Incorrect output for checkConvertUshort4Char4" + 2566 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2567 } 2568 2569 public class ArgumentsIntChar { 2570 public int inV; 2571 public byte out; 2572 } 2573 checkConvertInt2Char2()2574 private void checkConvertInt2Char2() { 2575 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x364256dfl, true, 7); 2576 try { 2577 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2578 script.forEach_testConvertChar2Int2Char2(inV, out); 2579 verifyResultsConvertInt2Char2(inV, out, false); 2580 } catch (Exception e) { 2581 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString()); 2582 } 2583 try { 2584 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2585 scriptRelaxed.forEach_testConvertChar2Int2Char2(inV, out); 2586 verifyResultsConvertInt2Char2(inV, out, true); 2587 } catch (Exception e) { 2588 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString()); 2589 } 2590 } 2591 verifyResultsConvertInt2Char2(Allocation inV, Allocation out, boolean relaxed)2592 private void verifyResultsConvertInt2Char2(Allocation inV, Allocation out, boolean relaxed) { 2593 int[] arrayInV = new int[INPUTSIZE * 2]; 2594 Arrays.fill(arrayInV, (int) 42); 2595 inV.copyTo(arrayInV); 2596 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2597 Arrays.fill(arrayOut, (byte) 42); 2598 out.copyTo(arrayOut); 2599 StringBuilder message = new StringBuilder(); 2600 boolean errorFound = false; 2601 for (int i = 0; i < INPUTSIZE; i++) { 2602 for (int j = 0; j < 2 ; j++) { 2603 // Extract the inputs. 2604 ArgumentsIntChar args = new ArgumentsIntChar(); 2605 args.inV = arrayInV[i * 2 + j]; 2606 // Figure out what the outputs should have been. 2607 CoreMathVerifier.computeConvert(args); 2608 // Validate the outputs. 2609 boolean valid = true; 2610 if (args.out != arrayOut[i * 2 + j]) { 2611 valid = false; 2612 } 2613 if (!valid) { 2614 if (!errorFound) { 2615 errorFound = true; 2616 message.append("Input inV: "); 2617 appendVariableToMessage(message, args.inV); 2618 message.append("\n"); 2619 message.append("Expected output out: "); 2620 appendVariableToMessage(message, args.out); 2621 message.append("\n"); 2622 message.append("Actual output out: "); 2623 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2624 if (args.out != arrayOut[i * 2 + j]) { 2625 message.append(" FAIL"); 2626 } 2627 message.append("\n"); 2628 message.append("Errors at"); 2629 } 2630 message.append(" ["); 2631 message.append(Integer.toString(i)); 2632 message.append(", "); 2633 message.append(Integer.toString(j)); 2634 message.append("]"); 2635 } 2636 } 2637 } 2638 assertFalse("Incorrect output for checkConvertInt2Char2" + 2639 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2640 } 2641 checkConvertInt3Char3()2642 private void checkConvertInt3Char3() { 2643 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x954a1bd3l, true, 7); 2644 try { 2645 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2646 script.forEach_testConvertChar3Int3Char3(inV, out); 2647 verifyResultsConvertInt3Char3(inV, out, false); 2648 } catch (Exception e) { 2649 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString()); 2650 } 2651 try { 2652 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2653 scriptRelaxed.forEach_testConvertChar3Int3Char3(inV, out); 2654 verifyResultsConvertInt3Char3(inV, out, true); 2655 } catch (Exception e) { 2656 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString()); 2657 } 2658 } 2659 verifyResultsConvertInt3Char3(Allocation inV, Allocation out, boolean relaxed)2660 private void verifyResultsConvertInt3Char3(Allocation inV, Allocation out, boolean relaxed) { 2661 int[] arrayInV = new int[INPUTSIZE * 4]; 2662 Arrays.fill(arrayInV, (int) 42); 2663 inV.copyTo(arrayInV); 2664 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2665 Arrays.fill(arrayOut, (byte) 42); 2666 out.copyTo(arrayOut); 2667 StringBuilder message = new StringBuilder(); 2668 boolean errorFound = false; 2669 for (int i = 0; i < INPUTSIZE; i++) { 2670 for (int j = 0; j < 3 ; j++) { 2671 // Extract the inputs. 2672 ArgumentsIntChar args = new ArgumentsIntChar(); 2673 args.inV = arrayInV[i * 4 + j]; 2674 // Figure out what the outputs should have been. 2675 CoreMathVerifier.computeConvert(args); 2676 // Validate the outputs. 2677 boolean valid = true; 2678 if (args.out != arrayOut[i * 4 + j]) { 2679 valid = false; 2680 } 2681 if (!valid) { 2682 if (!errorFound) { 2683 errorFound = true; 2684 message.append("Input inV: "); 2685 appendVariableToMessage(message, args.inV); 2686 message.append("\n"); 2687 message.append("Expected output out: "); 2688 appendVariableToMessage(message, args.out); 2689 message.append("\n"); 2690 message.append("Actual output out: "); 2691 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2692 if (args.out != arrayOut[i * 4 + j]) { 2693 message.append(" FAIL"); 2694 } 2695 message.append("\n"); 2696 message.append("Errors at"); 2697 } 2698 message.append(" ["); 2699 message.append(Integer.toString(i)); 2700 message.append(", "); 2701 message.append(Integer.toString(j)); 2702 message.append("]"); 2703 } 2704 } 2705 } 2706 assertFalse("Incorrect output for checkConvertInt3Char3" + 2707 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2708 } 2709 checkConvertInt4Char4()2710 private void checkConvertInt4Char4() { 2711 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xf451e0c7l, true, 7); 2712 try { 2713 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2714 script.forEach_testConvertChar4Int4Char4(inV, out); 2715 verifyResultsConvertInt4Char4(inV, out, false); 2716 } catch (Exception e) { 2717 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString()); 2718 } 2719 try { 2720 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2721 scriptRelaxed.forEach_testConvertChar4Int4Char4(inV, out); 2722 verifyResultsConvertInt4Char4(inV, out, true); 2723 } catch (Exception e) { 2724 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString()); 2725 } 2726 } 2727 verifyResultsConvertInt4Char4(Allocation inV, Allocation out, boolean relaxed)2728 private void verifyResultsConvertInt4Char4(Allocation inV, Allocation out, boolean relaxed) { 2729 int[] arrayInV = new int[INPUTSIZE * 4]; 2730 Arrays.fill(arrayInV, (int) 42); 2731 inV.copyTo(arrayInV); 2732 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2733 Arrays.fill(arrayOut, (byte) 42); 2734 out.copyTo(arrayOut); 2735 StringBuilder message = new StringBuilder(); 2736 boolean errorFound = false; 2737 for (int i = 0; i < INPUTSIZE; i++) { 2738 for (int j = 0; j < 4 ; j++) { 2739 // Extract the inputs. 2740 ArgumentsIntChar args = new ArgumentsIntChar(); 2741 args.inV = arrayInV[i * 4 + j]; 2742 // Figure out what the outputs should have been. 2743 CoreMathVerifier.computeConvert(args); 2744 // Validate the outputs. 2745 boolean valid = true; 2746 if (args.out != arrayOut[i * 4 + j]) { 2747 valid = false; 2748 } 2749 if (!valid) { 2750 if (!errorFound) { 2751 errorFound = true; 2752 message.append("Input inV: "); 2753 appendVariableToMessage(message, args.inV); 2754 message.append("\n"); 2755 message.append("Expected output out: "); 2756 appendVariableToMessage(message, args.out); 2757 message.append("\n"); 2758 message.append("Actual output out: "); 2759 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2760 if (args.out != arrayOut[i * 4 + j]) { 2761 message.append(" FAIL"); 2762 } 2763 message.append("\n"); 2764 message.append("Errors at"); 2765 } 2766 message.append(" ["); 2767 message.append(Integer.toString(i)); 2768 message.append(", "); 2769 message.append(Integer.toString(j)); 2770 message.append("]"); 2771 } 2772 } 2773 } 2774 assertFalse("Incorrect output for checkConvertInt4Char4" + 2775 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2776 } 2777 2778 public class ArgumentsUintChar { 2779 public int inV; 2780 public byte out; 2781 } 2782 checkConvertUint2Char2()2783 private void checkConvertUint2Char2() { 2784 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x33b67ae2l, false, 7); 2785 try { 2786 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2787 script.forEach_testConvertChar2Uint2Char2(inV, out); 2788 verifyResultsConvertUint2Char2(inV, out, false); 2789 } catch (Exception e) { 2790 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString()); 2791 } 2792 try { 2793 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 2794 scriptRelaxed.forEach_testConvertChar2Uint2Char2(inV, out); 2795 verifyResultsConvertUint2Char2(inV, out, true); 2796 } catch (Exception e) { 2797 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString()); 2798 } 2799 } 2800 verifyResultsConvertUint2Char2(Allocation inV, Allocation out, boolean relaxed)2801 private void verifyResultsConvertUint2Char2(Allocation inV, Allocation out, boolean relaxed) { 2802 int[] arrayInV = new int[INPUTSIZE * 2]; 2803 Arrays.fill(arrayInV, (int) 42); 2804 inV.copyTo(arrayInV); 2805 byte[] arrayOut = new byte[INPUTSIZE * 2]; 2806 Arrays.fill(arrayOut, (byte) 42); 2807 out.copyTo(arrayOut); 2808 StringBuilder message = new StringBuilder(); 2809 boolean errorFound = false; 2810 for (int i = 0; i < INPUTSIZE; i++) { 2811 for (int j = 0; j < 2 ; j++) { 2812 // Extract the inputs. 2813 ArgumentsUintChar args = new ArgumentsUintChar(); 2814 args.inV = arrayInV[i * 2 + j]; 2815 // Figure out what the outputs should have been. 2816 CoreMathVerifier.computeConvert(args); 2817 // Validate the outputs. 2818 boolean valid = true; 2819 if (args.out != arrayOut[i * 2 + j]) { 2820 valid = false; 2821 } 2822 if (!valid) { 2823 if (!errorFound) { 2824 errorFound = true; 2825 message.append("Input inV: "); 2826 appendVariableToMessage(message, args.inV); 2827 message.append("\n"); 2828 message.append("Expected output out: "); 2829 appendVariableToMessage(message, args.out); 2830 message.append("\n"); 2831 message.append("Actual output out: "); 2832 appendVariableToMessage(message, arrayOut[i * 2 + j]); 2833 if (args.out != arrayOut[i * 2 + j]) { 2834 message.append(" FAIL"); 2835 } 2836 message.append("\n"); 2837 message.append("Errors at"); 2838 } 2839 message.append(" ["); 2840 message.append(Integer.toString(i)); 2841 message.append(", "); 2842 message.append(Integer.toString(j)); 2843 message.append("]"); 2844 } 2845 } 2846 } 2847 assertFalse("Incorrect output for checkConvertUint2Char2" + 2848 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2849 } 2850 checkConvertUint3Char3()2851 private void checkConvertUint3Char3() { 2852 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x92be3fd6l, false, 7); 2853 try { 2854 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2855 script.forEach_testConvertChar3Uint3Char3(inV, out); 2856 verifyResultsConvertUint3Char3(inV, out, false); 2857 } catch (Exception e) { 2858 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString()); 2859 } 2860 try { 2861 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 2862 scriptRelaxed.forEach_testConvertChar3Uint3Char3(inV, out); 2863 verifyResultsConvertUint3Char3(inV, out, true); 2864 } catch (Exception e) { 2865 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString()); 2866 } 2867 } 2868 verifyResultsConvertUint3Char3(Allocation inV, Allocation out, boolean relaxed)2869 private void verifyResultsConvertUint3Char3(Allocation inV, Allocation out, boolean relaxed) { 2870 int[] arrayInV = new int[INPUTSIZE * 4]; 2871 Arrays.fill(arrayInV, (int) 42); 2872 inV.copyTo(arrayInV); 2873 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2874 Arrays.fill(arrayOut, (byte) 42); 2875 out.copyTo(arrayOut); 2876 StringBuilder message = new StringBuilder(); 2877 boolean errorFound = false; 2878 for (int i = 0; i < INPUTSIZE; i++) { 2879 for (int j = 0; j < 3 ; j++) { 2880 // Extract the inputs. 2881 ArgumentsUintChar args = new ArgumentsUintChar(); 2882 args.inV = arrayInV[i * 4 + j]; 2883 // Figure out what the outputs should have been. 2884 CoreMathVerifier.computeConvert(args); 2885 // Validate the outputs. 2886 boolean valid = true; 2887 if (args.out != arrayOut[i * 4 + j]) { 2888 valid = false; 2889 } 2890 if (!valid) { 2891 if (!errorFound) { 2892 errorFound = true; 2893 message.append("Input inV: "); 2894 appendVariableToMessage(message, args.inV); 2895 message.append("\n"); 2896 message.append("Expected output out: "); 2897 appendVariableToMessage(message, args.out); 2898 message.append("\n"); 2899 message.append("Actual output out: "); 2900 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2901 if (args.out != arrayOut[i * 4 + j]) { 2902 message.append(" FAIL"); 2903 } 2904 message.append("\n"); 2905 message.append("Errors at"); 2906 } 2907 message.append(" ["); 2908 message.append(Integer.toString(i)); 2909 message.append(", "); 2910 message.append(Integer.toString(j)); 2911 message.append("]"); 2912 } 2913 } 2914 } 2915 assertFalse("Incorrect output for checkConvertUint3Char3" + 2916 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2917 } 2918 checkConvertUint4Char4()2919 private void checkConvertUint4Char4() { 2920 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf1c604cal, false, 7); 2921 try { 2922 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2923 script.forEach_testConvertChar4Uint4Char4(inV, out); 2924 verifyResultsConvertUint4Char4(inV, out, false); 2925 } catch (Exception e) { 2926 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString()); 2927 } 2928 try { 2929 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 2930 scriptRelaxed.forEach_testConvertChar4Uint4Char4(inV, out); 2931 verifyResultsConvertUint4Char4(inV, out, true); 2932 } catch (Exception e) { 2933 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString()); 2934 } 2935 } 2936 verifyResultsConvertUint4Char4(Allocation inV, Allocation out, boolean relaxed)2937 private void verifyResultsConvertUint4Char4(Allocation inV, Allocation out, boolean relaxed) { 2938 int[] arrayInV = new int[INPUTSIZE * 4]; 2939 Arrays.fill(arrayInV, (int) 42); 2940 inV.copyTo(arrayInV); 2941 byte[] arrayOut = new byte[INPUTSIZE * 4]; 2942 Arrays.fill(arrayOut, (byte) 42); 2943 out.copyTo(arrayOut); 2944 StringBuilder message = new StringBuilder(); 2945 boolean errorFound = false; 2946 for (int i = 0; i < INPUTSIZE; i++) { 2947 for (int j = 0; j < 4 ; j++) { 2948 // Extract the inputs. 2949 ArgumentsUintChar args = new ArgumentsUintChar(); 2950 args.inV = arrayInV[i * 4 + j]; 2951 // Figure out what the outputs should have been. 2952 CoreMathVerifier.computeConvert(args); 2953 // Validate the outputs. 2954 boolean valid = true; 2955 if (args.out != arrayOut[i * 4 + j]) { 2956 valid = false; 2957 } 2958 if (!valid) { 2959 if (!errorFound) { 2960 errorFound = true; 2961 message.append("Input inV: "); 2962 appendVariableToMessage(message, args.inV); 2963 message.append("\n"); 2964 message.append("Expected output out: "); 2965 appendVariableToMessage(message, args.out); 2966 message.append("\n"); 2967 message.append("Actual output out: "); 2968 appendVariableToMessage(message, arrayOut[i * 4 + j]); 2969 if (args.out != arrayOut[i * 4 + j]) { 2970 message.append(" FAIL"); 2971 } 2972 message.append("\n"); 2973 message.append("Errors at"); 2974 } 2975 message.append(" ["); 2976 message.append(Integer.toString(i)); 2977 message.append(", "); 2978 message.append(Integer.toString(j)); 2979 message.append("]"); 2980 } 2981 } 2982 } 2983 assertFalse("Incorrect output for checkConvertUint4Char4" + 2984 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 2985 } 2986 2987 public class ArgumentsFloatUchar { 2988 public float inV; 2989 public byte out; 2990 } 2991 checkConvertFloat2Uchar2()2992 private void checkConvertFloat2Uchar2() { 2993 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfac15b79l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 2994 try { 2995 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 2996 script.forEach_testConvertUchar2Float2Uchar2(inV, out); 2997 verifyResultsConvertFloat2Uchar2(inV, out, false); 2998 } catch (Exception e) { 2999 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString()); 3000 } 3001 try { 3002 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3003 scriptRelaxed.forEach_testConvertUchar2Float2Uchar2(inV, out); 3004 verifyResultsConvertFloat2Uchar2(inV, out, true); 3005 } catch (Exception e) { 3006 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString()); 3007 } 3008 } 3009 verifyResultsConvertFloat2Uchar2(Allocation inV, Allocation out, boolean relaxed)3010 private void verifyResultsConvertFloat2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3011 float[] arrayInV = new float[INPUTSIZE * 2]; 3012 Arrays.fill(arrayInV, (float) 42); 3013 inV.copyTo(arrayInV); 3014 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3015 Arrays.fill(arrayOut, (byte) 42); 3016 out.copyTo(arrayOut); 3017 StringBuilder message = new StringBuilder(); 3018 boolean errorFound = false; 3019 for (int i = 0; i < INPUTSIZE; i++) { 3020 for (int j = 0; j < 2 ; j++) { 3021 // Extract the inputs. 3022 ArgumentsFloatUchar args = new ArgumentsFloatUchar(); 3023 args.inV = arrayInV[i * 2 + j]; 3024 // Figure out what the outputs should have been. 3025 CoreMathVerifier.computeConvert(args); 3026 // Validate the outputs. 3027 boolean valid = true; 3028 if (args.out != arrayOut[i * 2 + j]) { 3029 valid = false; 3030 } 3031 if (!valid) { 3032 if (!errorFound) { 3033 errorFound = true; 3034 message.append("Input inV: "); 3035 appendVariableToMessage(message, args.inV); 3036 message.append("\n"); 3037 message.append("Expected output out: "); 3038 appendVariableToMessage(message, args.out); 3039 message.append("\n"); 3040 message.append("Actual output out: "); 3041 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3042 if (args.out != arrayOut[i * 2 + j]) { 3043 message.append(" FAIL"); 3044 } 3045 message.append("\n"); 3046 message.append("Errors at"); 3047 } 3048 message.append(" ["); 3049 message.append(Integer.toString(i)); 3050 message.append(", "); 3051 message.append(Integer.toString(j)); 3052 message.append("]"); 3053 } 3054 } 3055 } 3056 assertFalse("Incorrect output for checkConvertFloat2Uchar2" + 3057 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3058 } 3059 checkConvertFloat3Uchar3()3060 private void checkConvertFloat3Uchar3() { 3061 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf0dc7c57l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 3062 try { 3063 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3064 script.forEach_testConvertUchar3Float3Uchar3(inV, out); 3065 verifyResultsConvertFloat3Uchar3(inV, out, false); 3066 } catch (Exception e) { 3067 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString()); 3068 } 3069 try { 3070 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3071 scriptRelaxed.forEach_testConvertUchar3Float3Uchar3(inV, out); 3072 verifyResultsConvertFloat3Uchar3(inV, out, true); 3073 } catch (Exception e) { 3074 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString()); 3075 } 3076 } 3077 verifyResultsConvertFloat3Uchar3(Allocation inV, Allocation out, boolean relaxed)3078 private void verifyResultsConvertFloat3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3079 float[] arrayInV = new float[INPUTSIZE * 4]; 3080 Arrays.fill(arrayInV, (float) 42); 3081 inV.copyTo(arrayInV); 3082 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3083 Arrays.fill(arrayOut, (byte) 42); 3084 out.copyTo(arrayOut); 3085 StringBuilder message = new StringBuilder(); 3086 boolean errorFound = false; 3087 for (int i = 0; i < INPUTSIZE; i++) { 3088 for (int j = 0; j < 3 ; j++) { 3089 // Extract the inputs. 3090 ArgumentsFloatUchar args = new ArgumentsFloatUchar(); 3091 args.inV = arrayInV[i * 4 + j]; 3092 // Figure out what the outputs should have been. 3093 CoreMathVerifier.computeConvert(args); 3094 // Validate the outputs. 3095 boolean valid = true; 3096 if (args.out != arrayOut[i * 4 + j]) { 3097 valid = false; 3098 } 3099 if (!valid) { 3100 if (!errorFound) { 3101 errorFound = true; 3102 message.append("Input inV: "); 3103 appendVariableToMessage(message, args.inV); 3104 message.append("\n"); 3105 message.append("Expected output out: "); 3106 appendVariableToMessage(message, args.out); 3107 message.append("\n"); 3108 message.append("Actual output out: "); 3109 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3110 if (args.out != arrayOut[i * 4 + j]) { 3111 message.append(" FAIL"); 3112 } 3113 message.append("\n"); 3114 message.append("Errors at"); 3115 } 3116 message.append(" ["); 3117 message.append(Integer.toString(i)); 3118 message.append(", "); 3119 message.append(Integer.toString(j)); 3120 message.append("]"); 3121 } 3122 } 3123 } 3124 assertFalse("Incorrect output for checkConvertFloat3Uchar3" + 3125 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3126 } 3127 checkConvertFloat4Uchar4()3128 private void checkConvertFloat4Uchar4() { 3129 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe6f79d35l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 3130 try { 3131 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3132 script.forEach_testConvertUchar4Float4Uchar4(inV, out); 3133 verifyResultsConvertFloat4Uchar4(inV, out, false); 3134 } catch (Exception e) { 3135 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString()); 3136 } 3137 try { 3138 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3139 scriptRelaxed.forEach_testConvertUchar4Float4Uchar4(inV, out); 3140 verifyResultsConvertFloat4Uchar4(inV, out, true); 3141 } catch (Exception e) { 3142 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString()); 3143 } 3144 } 3145 verifyResultsConvertFloat4Uchar4(Allocation inV, Allocation out, boolean relaxed)3146 private void verifyResultsConvertFloat4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3147 float[] arrayInV = new float[INPUTSIZE * 4]; 3148 Arrays.fill(arrayInV, (float) 42); 3149 inV.copyTo(arrayInV); 3150 byte[] arrayOut = new byte[INPUTSIZE * 4]; 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 < 4 ; j++) { 3157 // Extract the inputs. 3158 ArgumentsFloatUchar args = new ArgumentsFloatUchar(); 3159 args.inV = arrayInV[i * 4 + 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 * 4 + 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 * 4 + j]); 3178 if (args.out != arrayOut[i * 4 + 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 checkConvertFloat4Uchar4" + 3193 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3194 } 3195 3196 public class ArgumentsCharUchar { 3197 public byte inV; 3198 public byte out; 3199 } 3200 checkConvertChar2Uchar2()3201 private void checkConvertChar2Uchar2() { 3202 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xcbea8339l, false, 7); 3203 try { 3204 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3205 script.forEach_testConvertUchar2Char2Uchar2(inV, out); 3206 verifyResultsConvertChar2Uchar2(inV, out, false); 3207 } catch (Exception e) { 3208 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString()); 3209 } 3210 try { 3211 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3212 scriptRelaxed.forEach_testConvertUchar2Char2Uchar2(inV, out); 3213 verifyResultsConvertChar2Uchar2(inV, out, true); 3214 } catch (Exception e) { 3215 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString()); 3216 } 3217 } 3218 verifyResultsConvertChar2Uchar2(Allocation inV, Allocation out, boolean relaxed)3219 private void verifyResultsConvertChar2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3220 byte[] arrayInV = new byte[INPUTSIZE * 2]; 3221 Arrays.fill(arrayInV, (byte) 42); 3222 inV.copyTo(arrayInV); 3223 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3224 Arrays.fill(arrayOut, (byte) 42); 3225 out.copyTo(arrayOut); 3226 StringBuilder message = new StringBuilder(); 3227 boolean errorFound = false; 3228 for (int i = 0; i < INPUTSIZE; i++) { 3229 for (int j = 0; j < 2 ; j++) { 3230 // Extract the inputs. 3231 ArgumentsCharUchar args = new ArgumentsCharUchar(); 3232 args.inV = arrayInV[i * 2 + j]; 3233 // Figure out what the outputs should have been. 3234 CoreMathVerifier.computeConvert(args); 3235 // Validate the outputs. 3236 boolean valid = true; 3237 if (args.out != arrayOut[i * 2 + j]) { 3238 valid = false; 3239 } 3240 if (!valid) { 3241 if (!errorFound) { 3242 errorFound = true; 3243 message.append("Input inV: "); 3244 appendVariableToMessage(message, args.inV); 3245 message.append("\n"); 3246 message.append("Expected output out: "); 3247 appendVariableToMessage(message, args.out); 3248 message.append("\n"); 3249 message.append("Actual output out: "); 3250 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3251 if (args.out != arrayOut[i * 2 + j]) { 3252 message.append(" FAIL"); 3253 } 3254 message.append("\n"); 3255 message.append("Errors at"); 3256 } 3257 message.append(" ["); 3258 message.append(Integer.toString(i)); 3259 message.append(", "); 3260 message.append(Integer.toString(j)); 3261 message.append("]"); 3262 } 3263 } 3264 } 3265 assertFalse("Incorrect output for checkConvertChar2Uchar2" + 3266 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3267 } 3268 checkConvertChar3Uchar3()3269 private void checkConvertChar3Uchar3() { 3270 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xc205a417l, false, 7); 3271 try { 3272 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3273 script.forEach_testConvertUchar3Char3Uchar3(inV, out); 3274 verifyResultsConvertChar3Uchar3(inV, out, false); 3275 } catch (Exception e) { 3276 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString()); 3277 } 3278 try { 3279 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3280 scriptRelaxed.forEach_testConvertUchar3Char3Uchar3(inV, out); 3281 verifyResultsConvertChar3Uchar3(inV, out, true); 3282 } catch (Exception e) { 3283 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString()); 3284 } 3285 } 3286 verifyResultsConvertChar3Uchar3(Allocation inV, Allocation out, boolean relaxed)3287 private void verifyResultsConvertChar3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3288 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3289 Arrays.fill(arrayInV, (byte) 42); 3290 inV.copyTo(arrayInV); 3291 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3292 Arrays.fill(arrayOut, (byte) 42); 3293 out.copyTo(arrayOut); 3294 StringBuilder message = new StringBuilder(); 3295 boolean errorFound = false; 3296 for (int i = 0; i < INPUTSIZE; i++) { 3297 for (int j = 0; j < 3 ; j++) { 3298 // Extract the inputs. 3299 ArgumentsCharUchar args = new ArgumentsCharUchar(); 3300 args.inV = arrayInV[i * 4 + j]; 3301 // Figure out what the outputs should have been. 3302 CoreMathVerifier.computeConvert(args); 3303 // Validate the outputs. 3304 boolean valid = true; 3305 if (args.out != arrayOut[i * 4 + j]) { 3306 valid = false; 3307 } 3308 if (!valid) { 3309 if (!errorFound) { 3310 errorFound = true; 3311 message.append("Input inV: "); 3312 appendVariableToMessage(message, args.inV); 3313 message.append("\n"); 3314 message.append("Expected output out: "); 3315 appendVariableToMessage(message, args.out); 3316 message.append("\n"); 3317 message.append("Actual output out: "); 3318 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3319 if (args.out != arrayOut[i * 4 + j]) { 3320 message.append(" FAIL"); 3321 } 3322 message.append("\n"); 3323 message.append("Errors at"); 3324 } 3325 message.append(" ["); 3326 message.append(Integer.toString(i)); 3327 message.append(", "); 3328 message.append(Integer.toString(j)); 3329 message.append("]"); 3330 } 3331 } 3332 } 3333 assertFalse("Incorrect output for checkConvertChar3Uchar3" + 3334 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3335 } 3336 checkConvertChar4Uchar4()3337 private void checkConvertChar4Uchar4() { 3338 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xb820c4f5l, false, 7); 3339 try { 3340 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3341 script.forEach_testConvertUchar4Char4Uchar4(inV, out); 3342 verifyResultsConvertChar4Uchar4(inV, out, false); 3343 } catch (Exception e) { 3344 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString()); 3345 } 3346 try { 3347 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3348 scriptRelaxed.forEach_testConvertUchar4Char4Uchar4(inV, out); 3349 verifyResultsConvertChar4Uchar4(inV, out, true); 3350 } catch (Exception e) { 3351 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString()); 3352 } 3353 } 3354 verifyResultsConvertChar4Uchar4(Allocation inV, Allocation out, boolean relaxed)3355 private void verifyResultsConvertChar4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3356 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3357 Arrays.fill(arrayInV, (byte) 42); 3358 inV.copyTo(arrayInV); 3359 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3360 Arrays.fill(arrayOut, (byte) 42); 3361 out.copyTo(arrayOut); 3362 StringBuilder message = new StringBuilder(); 3363 boolean errorFound = false; 3364 for (int i = 0; i < INPUTSIZE; i++) { 3365 for (int j = 0; j < 4 ; j++) { 3366 // Extract the inputs. 3367 ArgumentsCharUchar args = new ArgumentsCharUchar(); 3368 args.inV = arrayInV[i * 4 + j]; 3369 // Figure out what the outputs should have been. 3370 CoreMathVerifier.computeConvert(args); 3371 // Validate the outputs. 3372 boolean valid = true; 3373 if (args.out != arrayOut[i * 4 + j]) { 3374 valid = false; 3375 } 3376 if (!valid) { 3377 if (!errorFound) { 3378 errorFound = true; 3379 message.append("Input inV: "); 3380 appendVariableToMessage(message, args.inV); 3381 message.append("\n"); 3382 message.append("Expected output out: "); 3383 appendVariableToMessage(message, args.out); 3384 message.append("\n"); 3385 message.append("Actual output out: "); 3386 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3387 if (args.out != arrayOut[i * 4 + j]) { 3388 message.append(" FAIL"); 3389 } 3390 message.append("\n"); 3391 message.append("Errors at"); 3392 } 3393 message.append(" ["); 3394 message.append(Integer.toString(i)); 3395 message.append(", "); 3396 message.append(Integer.toString(j)); 3397 message.append("]"); 3398 } 3399 } 3400 } 3401 assertFalse("Incorrect output for checkConvertChar4Uchar4" + 3402 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3403 } 3404 3405 public class ArgumentsUcharUchar { 3406 public byte inV; 3407 public byte out; 3408 } 3409 checkConvertUchar2Uchar2()3410 private void checkConvertUchar2Uchar2() { 3411 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x67c29ce4l, false, 8); 3412 try { 3413 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3414 script.forEach_testConvertUchar2Uchar2Uchar2(inV, out); 3415 verifyResultsConvertUchar2Uchar2(inV, out, false); 3416 } catch (Exception e) { 3417 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString()); 3418 } 3419 try { 3420 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3421 scriptRelaxed.forEach_testConvertUchar2Uchar2Uchar2(inV, out); 3422 verifyResultsConvertUchar2Uchar2(inV, out, true); 3423 } catch (Exception e) { 3424 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString()); 3425 } 3426 } 3427 verifyResultsConvertUchar2Uchar2(Allocation inV, Allocation out, boolean relaxed)3428 private void verifyResultsConvertUchar2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3429 byte[] arrayInV = new byte[INPUTSIZE * 2]; 3430 Arrays.fill(arrayInV, (byte) 42); 3431 inV.copyTo(arrayInV); 3432 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3433 Arrays.fill(arrayOut, (byte) 42); 3434 out.copyTo(arrayOut); 3435 StringBuilder message = new StringBuilder(); 3436 boolean errorFound = false; 3437 for (int i = 0; i < INPUTSIZE; i++) { 3438 for (int j = 0; j < 2 ; j++) { 3439 // Extract the inputs. 3440 ArgumentsUcharUchar args = new ArgumentsUcharUchar(); 3441 args.inV = arrayInV[i * 2 + j]; 3442 // Figure out what the outputs should have been. 3443 CoreMathVerifier.computeConvert(args); 3444 // Validate the outputs. 3445 boolean valid = true; 3446 if (args.out != arrayOut[i * 2 + j]) { 3447 valid = false; 3448 } 3449 if (!valid) { 3450 if (!errorFound) { 3451 errorFound = true; 3452 message.append("Input inV: "); 3453 appendVariableToMessage(message, args.inV); 3454 message.append("\n"); 3455 message.append("Expected output out: "); 3456 appendVariableToMessage(message, args.out); 3457 message.append("\n"); 3458 message.append("Actual output out: "); 3459 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3460 if (args.out != arrayOut[i * 2 + j]) { 3461 message.append(" FAIL"); 3462 } 3463 message.append("\n"); 3464 message.append("Errors at"); 3465 } 3466 message.append(" ["); 3467 message.append(Integer.toString(i)); 3468 message.append(", "); 3469 message.append(Integer.toString(j)); 3470 message.append("]"); 3471 } 3472 } 3473 } 3474 assertFalse("Incorrect output for checkConvertUchar2Uchar2" + 3475 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3476 } 3477 checkConvertUchar3Uchar3()3478 private void checkConvertUchar3Uchar3() { 3479 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x5dddbdc2l, false, 8); 3480 try { 3481 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3482 script.forEach_testConvertUchar3Uchar3Uchar3(inV, out); 3483 verifyResultsConvertUchar3Uchar3(inV, out, false); 3484 } catch (Exception e) { 3485 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString()); 3486 } 3487 try { 3488 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3489 scriptRelaxed.forEach_testConvertUchar3Uchar3Uchar3(inV, out); 3490 verifyResultsConvertUchar3Uchar3(inV, out, true); 3491 } catch (Exception e) { 3492 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString()); 3493 } 3494 } 3495 verifyResultsConvertUchar3Uchar3(Allocation inV, Allocation out, boolean relaxed)3496 private void verifyResultsConvertUchar3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3497 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3498 Arrays.fill(arrayInV, (byte) 42); 3499 inV.copyTo(arrayInV); 3500 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3501 Arrays.fill(arrayOut, (byte) 42); 3502 out.copyTo(arrayOut); 3503 StringBuilder message = new StringBuilder(); 3504 boolean errorFound = false; 3505 for (int i = 0; i < INPUTSIZE; i++) { 3506 for (int j = 0; j < 3 ; j++) { 3507 // Extract the inputs. 3508 ArgumentsUcharUchar args = new ArgumentsUcharUchar(); 3509 args.inV = arrayInV[i * 4 + j]; 3510 // Figure out what the outputs should have been. 3511 CoreMathVerifier.computeConvert(args); 3512 // Validate the outputs. 3513 boolean valid = true; 3514 if (args.out != arrayOut[i * 4 + j]) { 3515 valid = false; 3516 } 3517 if (!valid) { 3518 if (!errorFound) { 3519 errorFound = true; 3520 message.append("Input inV: "); 3521 appendVariableToMessage(message, args.inV); 3522 message.append("\n"); 3523 message.append("Expected output out: "); 3524 appendVariableToMessage(message, args.out); 3525 message.append("\n"); 3526 message.append("Actual output out: "); 3527 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3528 if (args.out != arrayOut[i * 4 + j]) { 3529 message.append(" FAIL"); 3530 } 3531 message.append("\n"); 3532 message.append("Errors at"); 3533 } 3534 message.append(" ["); 3535 message.append(Integer.toString(i)); 3536 message.append(", "); 3537 message.append(Integer.toString(j)); 3538 message.append("]"); 3539 } 3540 } 3541 } 3542 assertFalse("Incorrect output for checkConvertUchar3Uchar3" + 3543 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3544 } 3545 checkConvertUchar4Uchar4()3546 private void checkConvertUchar4Uchar4() { 3547 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x53f8dea0l, false, 8); 3548 try { 3549 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3550 script.forEach_testConvertUchar4Uchar4Uchar4(inV, out); 3551 verifyResultsConvertUchar4Uchar4(inV, out, false); 3552 } catch (Exception e) { 3553 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString()); 3554 } 3555 try { 3556 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3557 scriptRelaxed.forEach_testConvertUchar4Uchar4Uchar4(inV, out); 3558 verifyResultsConvertUchar4Uchar4(inV, out, true); 3559 } catch (Exception e) { 3560 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString()); 3561 } 3562 } 3563 verifyResultsConvertUchar4Uchar4(Allocation inV, Allocation out, boolean relaxed)3564 private void verifyResultsConvertUchar4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3565 byte[] arrayInV = new byte[INPUTSIZE * 4]; 3566 Arrays.fill(arrayInV, (byte) 42); 3567 inV.copyTo(arrayInV); 3568 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3569 Arrays.fill(arrayOut, (byte) 42); 3570 out.copyTo(arrayOut); 3571 StringBuilder message = new StringBuilder(); 3572 boolean errorFound = false; 3573 for (int i = 0; i < INPUTSIZE; i++) { 3574 for (int j = 0; j < 4 ; j++) { 3575 // Extract the inputs. 3576 ArgumentsUcharUchar args = new ArgumentsUcharUchar(); 3577 args.inV = arrayInV[i * 4 + j]; 3578 // Figure out what the outputs should have been. 3579 CoreMathVerifier.computeConvert(args); 3580 // Validate the outputs. 3581 boolean valid = true; 3582 if (args.out != arrayOut[i * 4 + j]) { 3583 valid = false; 3584 } 3585 if (!valid) { 3586 if (!errorFound) { 3587 errorFound = true; 3588 message.append("Input inV: "); 3589 appendVariableToMessage(message, args.inV); 3590 message.append("\n"); 3591 message.append("Expected output out: "); 3592 appendVariableToMessage(message, args.out); 3593 message.append("\n"); 3594 message.append("Actual output out: "); 3595 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3596 if (args.out != arrayOut[i * 4 + j]) { 3597 message.append(" FAIL"); 3598 } 3599 message.append("\n"); 3600 message.append("Errors at"); 3601 } 3602 message.append(" ["); 3603 message.append(Integer.toString(i)); 3604 message.append(", "); 3605 message.append(Integer.toString(j)); 3606 message.append("]"); 3607 } 3608 } 3609 } 3610 assertFalse("Incorrect output for checkConvertUchar4Uchar4" + 3611 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3612 } 3613 3614 public class ArgumentsShortUchar { 3615 public short inV; 3616 public byte out; 3617 } 3618 checkConvertShort2Uchar2()3619 private void checkConvertShort2Uchar2() { 3620 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xabc38225l, false, 8); 3621 try { 3622 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3623 script.forEach_testConvertUchar2Short2Uchar2(inV, out); 3624 verifyResultsConvertShort2Uchar2(inV, out, false); 3625 } catch (Exception e) { 3626 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString()); 3627 } 3628 try { 3629 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3630 scriptRelaxed.forEach_testConvertUchar2Short2Uchar2(inV, out); 3631 verifyResultsConvertShort2Uchar2(inV, out, true); 3632 } catch (Exception e) { 3633 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString()); 3634 } 3635 } 3636 verifyResultsConvertShort2Uchar2(Allocation inV, Allocation out, boolean relaxed)3637 private void verifyResultsConvertShort2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3638 short[] arrayInV = new short[INPUTSIZE * 2]; 3639 Arrays.fill(arrayInV, (short) 42); 3640 inV.copyTo(arrayInV); 3641 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3642 Arrays.fill(arrayOut, (byte) 42); 3643 out.copyTo(arrayOut); 3644 StringBuilder message = new StringBuilder(); 3645 boolean errorFound = false; 3646 for (int i = 0; i < INPUTSIZE; i++) { 3647 for (int j = 0; j < 2 ; j++) { 3648 // Extract the inputs. 3649 ArgumentsShortUchar args = new ArgumentsShortUchar(); 3650 args.inV = arrayInV[i * 2 + j]; 3651 // Figure out what the outputs should have been. 3652 CoreMathVerifier.computeConvert(args); 3653 // Validate the outputs. 3654 boolean valid = true; 3655 if (args.out != arrayOut[i * 2 + j]) { 3656 valid = false; 3657 } 3658 if (!valid) { 3659 if (!errorFound) { 3660 errorFound = true; 3661 message.append("Input inV: "); 3662 appendVariableToMessage(message, args.inV); 3663 message.append("\n"); 3664 message.append("Expected output out: "); 3665 appendVariableToMessage(message, args.out); 3666 message.append("\n"); 3667 message.append("Actual output out: "); 3668 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3669 if (args.out != arrayOut[i * 2 + j]) { 3670 message.append(" FAIL"); 3671 } 3672 message.append("\n"); 3673 message.append("Errors at"); 3674 } 3675 message.append(" ["); 3676 message.append(Integer.toString(i)); 3677 message.append(", "); 3678 message.append(Integer.toString(j)); 3679 message.append("]"); 3680 } 3681 } 3682 } 3683 assertFalse("Incorrect output for checkConvertShort2Uchar2" + 3684 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3685 } 3686 checkConvertShort3Uchar3()3687 private void checkConvertShort3Uchar3() { 3688 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xa1dea303l, false, 8); 3689 try { 3690 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3691 script.forEach_testConvertUchar3Short3Uchar3(inV, out); 3692 verifyResultsConvertShort3Uchar3(inV, out, false); 3693 } catch (Exception e) { 3694 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString()); 3695 } 3696 try { 3697 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3698 scriptRelaxed.forEach_testConvertUchar3Short3Uchar3(inV, out); 3699 verifyResultsConvertShort3Uchar3(inV, out, true); 3700 } catch (Exception e) { 3701 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString()); 3702 } 3703 } 3704 verifyResultsConvertShort3Uchar3(Allocation inV, Allocation out, boolean relaxed)3705 private void verifyResultsConvertShort3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3706 short[] arrayInV = new short[INPUTSIZE * 4]; 3707 Arrays.fill(arrayInV, (short) 42); 3708 inV.copyTo(arrayInV); 3709 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3710 Arrays.fill(arrayOut, (byte) 42); 3711 out.copyTo(arrayOut); 3712 StringBuilder message = new StringBuilder(); 3713 boolean errorFound = false; 3714 for (int i = 0; i < INPUTSIZE; i++) { 3715 for (int j = 0; j < 3 ; j++) { 3716 // Extract the inputs. 3717 ArgumentsShortUchar args = new ArgumentsShortUchar(); 3718 args.inV = arrayInV[i * 4 + j]; 3719 // Figure out what the outputs should have been. 3720 CoreMathVerifier.computeConvert(args); 3721 // Validate the outputs. 3722 boolean valid = true; 3723 if (args.out != arrayOut[i * 4 + j]) { 3724 valid = false; 3725 } 3726 if (!valid) { 3727 if (!errorFound) { 3728 errorFound = true; 3729 message.append("Input inV: "); 3730 appendVariableToMessage(message, args.inV); 3731 message.append("\n"); 3732 message.append("Expected output out: "); 3733 appendVariableToMessage(message, args.out); 3734 message.append("\n"); 3735 message.append("Actual output out: "); 3736 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3737 if (args.out != arrayOut[i * 4 + j]) { 3738 message.append(" FAIL"); 3739 } 3740 message.append("\n"); 3741 message.append("Errors at"); 3742 } 3743 message.append(" ["); 3744 message.append(Integer.toString(i)); 3745 message.append(", "); 3746 message.append(Integer.toString(j)); 3747 message.append("]"); 3748 } 3749 } 3750 } 3751 assertFalse("Incorrect output for checkConvertShort3Uchar3" + 3752 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3753 } 3754 checkConvertShort4Uchar4()3755 private void checkConvertShort4Uchar4() { 3756 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x97f9c3e1l, false, 8); 3757 try { 3758 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3759 script.forEach_testConvertUchar4Short4Uchar4(inV, out); 3760 verifyResultsConvertShort4Uchar4(inV, out, false); 3761 } catch (Exception e) { 3762 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString()); 3763 } 3764 try { 3765 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3766 scriptRelaxed.forEach_testConvertUchar4Short4Uchar4(inV, out); 3767 verifyResultsConvertShort4Uchar4(inV, out, true); 3768 } catch (Exception e) { 3769 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString()); 3770 } 3771 } 3772 verifyResultsConvertShort4Uchar4(Allocation inV, Allocation out, boolean relaxed)3773 private void verifyResultsConvertShort4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3774 short[] arrayInV = new short[INPUTSIZE * 4]; 3775 Arrays.fill(arrayInV, (short) 42); 3776 inV.copyTo(arrayInV); 3777 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3778 Arrays.fill(arrayOut, (byte) 42); 3779 out.copyTo(arrayOut); 3780 StringBuilder message = new StringBuilder(); 3781 boolean errorFound = false; 3782 for (int i = 0; i < INPUTSIZE; i++) { 3783 for (int j = 0; j < 4 ; j++) { 3784 // Extract the inputs. 3785 ArgumentsShortUchar args = new ArgumentsShortUchar(); 3786 args.inV = arrayInV[i * 4 + j]; 3787 // Figure out what the outputs should have been. 3788 CoreMathVerifier.computeConvert(args); 3789 // Validate the outputs. 3790 boolean valid = true; 3791 if (args.out != arrayOut[i * 4 + j]) { 3792 valid = false; 3793 } 3794 if (!valid) { 3795 if (!errorFound) { 3796 errorFound = true; 3797 message.append("Input inV: "); 3798 appendVariableToMessage(message, args.inV); 3799 message.append("\n"); 3800 message.append("Expected output out: "); 3801 appendVariableToMessage(message, args.out); 3802 message.append("\n"); 3803 message.append("Actual output out: "); 3804 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3805 if (args.out != arrayOut[i * 4 + j]) { 3806 message.append(" FAIL"); 3807 } 3808 message.append("\n"); 3809 message.append("Errors at"); 3810 } 3811 message.append(" ["); 3812 message.append(Integer.toString(i)); 3813 message.append(", "); 3814 message.append(Integer.toString(j)); 3815 message.append("]"); 3816 } 3817 } 3818 } 3819 assertFalse("Incorrect output for checkConvertShort4Uchar4" + 3820 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3821 } 3822 3823 public class ArgumentsUshortUchar { 3824 public short inV; 3825 public byte out; 3826 } 3827 checkConvertUshort2Uchar2()3828 private void checkConvertUshort2Uchar2() { 3829 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd90fd1del, false, 8); 3830 try { 3831 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3832 script.forEach_testConvertUchar2Ushort2Uchar2(inV, out); 3833 verifyResultsConvertUshort2Uchar2(inV, out, false); 3834 } catch (Exception e) { 3835 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString()); 3836 } 3837 try { 3838 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 3839 scriptRelaxed.forEach_testConvertUchar2Ushort2Uchar2(inV, out); 3840 verifyResultsConvertUshort2Uchar2(inV, out, true); 3841 } catch (Exception e) { 3842 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString()); 3843 } 3844 } 3845 verifyResultsConvertUshort2Uchar2(Allocation inV, Allocation out, boolean relaxed)3846 private void verifyResultsConvertUshort2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 3847 short[] arrayInV = new short[INPUTSIZE * 2]; 3848 Arrays.fill(arrayInV, (short) 42); 3849 inV.copyTo(arrayInV); 3850 byte[] arrayOut = new byte[INPUTSIZE * 2]; 3851 Arrays.fill(arrayOut, (byte) 42); 3852 out.copyTo(arrayOut); 3853 StringBuilder message = new StringBuilder(); 3854 boolean errorFound = false; 3855 for (int i = 0; i < INPUTSIZE; i++) { 3856 for (int j = 0; j < 2 ; j++) { 3857 // Extract the inputs. 3858 ArgumentsUshortUchar args = new ArgumentsUshortUchar(); 3859 args.inV = arrayInV[i * 2 + j]; 3860 // Figure out what the outputs should have been. 3861 CoreMathVerifier.computeConvert(args); 3862 // Validate the outputs. 3863 boolean valid = true; 3864 if (args.out != arrayOut[i * 2 + j]) { 3865 valid = false; 3866 } 3867 if (!valid) { 3868 if (!errorFound) { 3869 errorFound = true; 3870 message.append("Input inV: "); 3871 appendVariableToMessage(message, args.inV); 3872 message.append("\n"); 3873 message.append("Expected output out: "); 3874 appendVariableToMessage(message, args.out); 3875 message.append("\n"); 3876 message.append("Actual output out: "); 3877 appendVariableToMessage(message, arrayOut[i * 2 + j]); 3878 if (args.out != arrayOut[i * 2 + j]) { 3879 message.append(" FAIL"); 3880 } 3881 message.append("\n"); 3882 message.append("Errors at"); 3883 } 3884 message.append(" ["); 3885 message.append(Integer.toString(i)); 3886 message.append(", "); 3887 message.append(Integer.toString(j)); 3888 message.append("]"); 3889 } 3890 } 3891 } 3892 assertFalse("Incorrect output for checkConvertUshort2Uchar2" + 3893 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3894 } 3895 checkConvertUshort3Uchar3()3896 private void checkConvertUshort3Uchar3() { 3897 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xcf2af2bcl, false, 8); 3898 try { 3899 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3900 script.forEach_testConvertUchar3Ushort3Uchar3(inV, out); 3901 verifyResultsConvertUshort3Uchar3(inV, out, false); 3902 } catch (Exception e) { 3903 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString()); 3904 } 3905 try { 3906 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 3907 scriptRelaxed.forEach_testConvertUchar3Ushort3Uchar3(inV, out); 3908 verifyResultsConvertUshort3Uchar3(inV, out, true); 3909 } catch (Exception e) { 3910 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString()); 3911 } 3912 } 3913 verifyResultsConvertUshort3Uchar3(Allocation inV, Allocation out, boolean relaxed)3914 private void verifyResultsConvertUshort3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 3915 short[] arrayInV = new short[INPUTSIZE * 4]; 3916 Arrays.fill(arrayInV, (short) 42); 3917 inV.copyTo(arrayInV); 3918 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3919 Arrays.fill(arrayOut, (byte) 42); 3920 out.copyTo(arrayOut); 3921 StringBuilder message = new StringBuilder(); 3922 boolean errorFound = false; 3923 for (int i = 0; i < INPUTSIZE; i++) { 3924 for (int j = 0; j < 3 ; j++) { 3925 // Extract the inputs. 3926 ArgumentsUshortUchar args = new ArgumentsUshortUchar(); 3927 args.inV = arrayInV[i * 4 + j]; 3928 // Figure out what the outputs should have been. 3929 CoreMathVerifier.computeConvert(args); 3930 // Validate the outputs. 3931 boolean valid = true; 3932 if (args.out != arrayOut[i * 4 + j]) { 3933 valid = false; 3934 } 3935 if (!valid) { 3936 if (!errorFound) { 3937 errorFound = true; 3938 message.append("Input inV: "); 3939 appendVariableToMessage(message, args.inV); 3940 message.append("\n"); 3941 message.append("Expected output out: "); 3942 appendVariableToMessage(message, args.out); 3943 message.append("\n"); 3944 message.append("Actual output out: "); 3945 appendVariableToMessage(message, arrayOut[i * 4 + j]); 3946 if (args.out != arrayOut[i * 4 + j]) { 3947 message.append(" FAIL"); 3948 } 3949 message.append("\n"); 3950 message.append("Errors at"); 3951 } 3952 message.append(" ["); 3953 message.append(Integer.toString(i)); 3954 message.append(", "); 3955 message.append(Integer.toString(j)); 3956 message.append("]"); 3957 } 3958 } 3959 } 3960 assertFalse("Incorrect output for checkConvertUshort3Uchar3" + 3961 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 3962 } 3963 checkConvertUshort4Uchar4()3964 private void checkConvertUshort4Uchar4() { 3965 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc546139al, false, 8); 3966 try { 3967 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3968 script.forEach_testConvertUchar4Ushort4Uchar4(inV, out); 3969 verifyResultsConvertUshort4Uchar4(inV, out, false); 3970 } catch (Exception e) { 3971 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString()); 3972 } 3973 try { 3974 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 3975 scriptRelaxed.forEach_testConvertUchar4Ushort4Uchar4(inV, out); 3976 verifyResultsConvertUshort4Uchar4(inV, out, true); 3977 } catch (Exception e) { 3978 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString()); 3979 } 3980 } 3981 verifyResultsConvertUshort4Uchar4(Allocation inV, Allocation out, boolean relaxed)3982 private void verifyResultsConvertUshort4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 3983 short[] arrayInV = new short[INPUTSIZE * 4]; 3984 Arrays.fill(arrayInV, (short) 42); 3985 inV.copyTo(arrayInV); 3986 byte[] arrayOut = new byte[INPUTSIZE * 4]; 3987 Arrays.fill(arrayOut, (byte) 42); 3988 out.copyTo(arrayOut); 3989 StringBuilder message = new StringBuilder(); 3990 boolean errorFound = false; 3991 for (int i = 0; i < INPUTSIZE; i++) { 3992 for (int j = 0; j < 4 ; j++) { 3993 // Extract the inputs. 3994 ArgumentsUshortUchar args = new ArgumentsUshortUchar(); 3995 args.inV = arrayInV[i * 4 + j]; 3996 // Figure out what the outputs should have been. 3997 CoreMathVerifier.computeConvert(args); 3998 // Validate the outputs. 3999 boolean valid = true; 4000 if (args.out != arrayOut[i * 4 + j]) { 4001 valid = false; 4002 } 4003 if (!valid) { 4004 if (!errorFound) { 4005 errorFound = true; 4006 message.append("Input inV: "); 4007 appendVariableToMessage(message, args.inV); 4008 message.append("\n"); 4009 message.append("Expected output out: "); 4010 appendVariableToMessage(message, args.out); 4011 message.append("\n"); 4012 message.append("Actual output out: "); 4013 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4014 if (args.out != arrayOut[i * 4 + j]) { 4015 message.append(" FAIL"); 4016 } 4017 message.append("\n"); 4018 message.append("Errors at"); 4019 } 4020 message.append(" ["); 4021 message.append(Integer.toString(i)); 4022 message.append(", "); 4023 message.append(Integer.toString(j)); 4024 message.append("]"); 4025 } 4026 } 4027 } 4028 assertFalse("Incorrect output for checkConvertUshort4Uchar4" + 4029 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4030 } 4031 4032 public class ArgumentsIntUchar { 4033 public int inV; 4034 public byte out; 4035 } 4036 checkConvertInt2Uchar2()4037 private void checkConvertInt2Uchar2() { 4038 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x20a4b078l, false, 8); 4039 try { 4040 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4041 script.forEach_testConvertUchar2Int2Uchar2(inV, out); 4042 verifyResultsConvertInt2Uchar2(inV, out, false); 4043 } catch (Exception e) { 4044 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString()); 4045 } 4046 try { 4047 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4048 scriptRelaxed.forEach_testConvertUchar2Int2Uchar2(inV, out); 4049 verifyResultsConvertInt2Uchar2(inV, out, true); 4050 } catch (Exception e) { 4051 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString()); 4052 } 4053 } 4054 verifyResultsConvertInt2Uchar2(Allocation inV, Allocation out, boolean relaxed)4055 private void verifyResultsConvertInt2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 4056 int[] arrayInV = new int[INPUTSIZE * 2]; 4057 Arrays.fill(arrayInV, (int) 42); 4058 inV.copyTo(arrayInV); 4059 byte[] arrayOut = new byte[INPUTSIZE * 2]; 4060 Arrays.fill(arrayOut, (byte) 42); 4061 out.copyTo(arrayOut); 4062 StringBuilder message = new StringBuilder(); 4063 boolean errorFound = false; 4064 for (int i = 0; i < INPUTSIZE; i++) { 4065 for (int j = 0; j < 2 ; j++) { 4066 // Extract the inputs. 4067 ArgumentsIntUchar args = new ArgumentsIntUchar(); 4068 args.inV = arrayInV[i * 2 + j]; 4069 // Figure out what the outputs should have been. 4070 CoreMathVerifier.computeConvert(args); 4071 // Validate the outputs. 4072 boolean valid = true; 4073 if (args.out != arrayOut[i * 2 + j]) { 4074 valid = false; 4075 } 4076 if (!valid) { 4077 if (!errorFound) { 4078 errorFound = true; 4079 message.append("Input inV: "); 4080 appendVariableToMessage(message, args.inV); 4081 message.append("\n"); 4082 message.append("Expected output out: "); 4083 appendVariableToMessage(message, args.out); 4084 message.append("\n"); 4085 message.append("Actual output out: "); 4086 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4087 if (args.out != arrayOut[i * 2 + j]) { 4088 message.append(" FAIL"); 4089 } 4090 message.append("\n"); 4091 message.append("Errors at"); 4092 } 4093 message.append(" ["); 4094 message.append(Integer.toString(i)); 4095 message.append(", "); 4096 message.append(Integer.toString(j)); 4097 message.append("]"); 4098 } 4099 } 4100 } 4101 assertFalse("Incorrect output for checkConvertInt2Uchar2" + 4102 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4103 } 4104 checkConvertInt3Uchar3()4105 private void checkConvertInt3Uchar3() { 4106 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x16bfd156l, false, 8); 4107 try { 4108 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4109 script.forEach_testConvertUchar3Int3Uchar3(inV, out); 4110 verifyResultsConvertInt3Uchar3(inV, out, false); 4111 } catch (Exception e) { 4112 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString()); 4113 } 4114 try { 4115 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4116 scriptRelaxed.forEach_testConvertUchar3Int3Uchar3(inV, out); 4117 verifyResultsConvertInt3Uchar3(inV, out, true); 4118 } catch (Exception e) { 4119 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString()); 4120 } 4121 } 4122 verifyResultsConvertInt3Uchar3(Allocation inV, Allocation out, boolean relaxed)4123 private void verifyResultsConvertInt3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 4124 int[] arrayInV = new int[INPUTSIZE * 4]; 4125 Arrays.fill(arrayInV, (int) 42); 4126 inV.copyTo(arrayInV); 4127 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4128 Arrays.fill(arrayOut, (byte) 42); 4129 out.copyTo(arrayOut); 4130 StringBuilder message = new StringBuilder(); 4131 boolean errorFound = false; 4132 for (int i = 0; i < INPUTSIZE; i++) { 4133 for (int j = 0; j < 3 ; j++) { 4134 // Extract the inputs. 4135 ArgumentsIntUchar args = new ArgumentsIntUchar(); 4136 args.inV = arrayInV[i * 4 + j]; 4137 // Figure out what the outputs should have been. 4138 CoreMathVerifier.computeConvert(args); 4139 // Validate the outputs. 4140 boolean valid = true; 4141 if (args.out != arrayOut[i * 4 + j]) { 4142 valid = false; 4143 } 4144 if (!valid) { 4145 if (!errorFound) { 4146 errorFound = true; 4147 message.append("Input inV: "); 4148 appendVariableToMessage(message, args.inV); 4149 message.append("\n"); 4150 message.append("Expected output out: "); 4151 appendVariableToMessage(message, args.out); 4152 message.append("\n"); 4153 message.append("Actual output out: "); 4154 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4155 if (args.out != arrayOut[i * 4 + j]) { 4156 message.append(" FAIL"); 4157 } 4158 message.append("\n"); 4159 message.append("Errors at"); 4160 } 4161 message.append(" ["); 4162 message.append(Integer.toString(i)); 4163 message.append(", "); 4164 message.append(Integer.toString(j)); 4165 message.append("]"); 4166 } 4167 } 4168 } 4169 assertFalse("Incorrect output for checkConvertInt3Uchar3" + 4170 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4171 } 4172 checkConvertInt4Uchar4()4173 private void checkConvertInt4Uchar4() { 4174 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xcdaf234l, false, 8); 4175 try { 4176 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4177 script.forEach_testConvertUchar4Int4Uchar4(inV, out); 4178 verifyResultsConvertInt4Uchar4(inV, out, false); 4179 } catch (Exception e) { 4180 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString()); 4181 } 4182 try { 4183 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4184 scriptRelaxed.forEach_testConvertUchar4Int4Uchar4(inV, out); 4185 verifyResultsConvertInt4Uchar4(inV, out, true); 4186 } catch (Exception e) { 4187 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString()); 4188 } 4189 } 4190 verifyResultsConvertInt4Uchar4(Allocation inV, Allocation out, boolean relaxed)4191 private void verifyResultsConvertInt4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 4192 int[] arrayInV = new int[INPUTSIZE * 4]; 4193 Arrays.fill(arrayInV, (int) 42); 4194 inV.copyTo(arrayInV); 4195 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4196 Arrays.fill(arrayOut, (byte) 42); 4197 out.copyTo(arrayOut); 4198 StringBuilder message = new StringBuilder(); 4199 boolean errorFound = false; 4200 for (int i = 0; i < INPUTSIZE; i++) { 4201 for (int j = 0; j < 4 ; j++) { 4202 // Extract the inputs. 4203 ArgumentsIntUchar args = new ArgumentsIntUchar(); 4204 args.inV = arrayInV[i * 4 + j]; 4205 // Figure out what the outputs should have been. 4206 CoreMathVerifier.computeConvert(args); 4207 // Validate the outputs. 4208 boolean valid = true; 4209 if (args.out != arrayOut[i * 4 + j]) { 4210 valid = false; 4211 } 4212 if (!valid) { 4213 if (!errorFound) { 4214 errorFound = true; 4215 message.append("Input inV: "); 4216 appendVariableToMessage(message, args.inV); 4217 message.append("\n"); 4218 message.append("Expected output out: "); 4219 appendVariableToMessage(message, args.out); 4220 message.append("\n"); 4221 message.append("Actual output out: "); 4222 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4223 if (args.out != arrayOut[i * 4 + j]) { 4224 message.append(" FAIL"); 4225 } 4226 message.append("\n"); 4227 message.append("Errors at"); 4228 } 4229 message.append(" ["); 4230 message.append(Integer.toString(i)); 4231 message.append(", "); 4232 message.append(Integer.toString(j)); 4233 message.append("]"); 4234 } 4235 } 4236 } 4237 assertFalse("Incorrect output for checkConvertInt4Uchar4" + 4238 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4239 } 4240 4241 public class ArgumentsUintUchar { 4242 public int inV; 4243 public byte out; 4244 } 4245 checkConvertUint2Uchar2()4246 private void checkConvertUint2Uchar2() { 4247 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb326bcf9l, false, 8); 4248 try { 4249 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4250 script.forEach_testConvertUchar2Uint2Uchar2(inV, out); 4251 verifyResultsConvertUint2Uchar2(inV, out, false); 4252 } catch (Exception e) { 4253 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString()); 4254 } 4255 try { 4256 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 4257 scriptRelaxed.forEach_testConvertUchar2Uint2Uchar2(inV, out); 4258 verifyResultsConvertUint2Uchar2(inV, out, true); 4259 } catch (Exception e) { 4260 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString()); 4261 } 4262 } 4263 verifyResultsConvertUint2Uchar2(Allocation inV, Allocation out, boolean relaxed)4264 private void verifyResultsConvertUint2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 4265 int[] arrayInV = new int[INPUTSIZE * 2]; 4266 Arrays.fill(arrayInV, (int) 42); 4267 inV.copyTo(arrayInV); 4268 byte[] arrayOut = new byte[INPUTSIZE * 2]; 4269 Arrays.fill(arrayOut, (byte) 42); 4270 out.copyTo(arrayOut); 4271 StringBuilder message = new StringBuilder(); 4272 boolean errorFound = false; 4273 for (int i = 0; i < INPUTSIZE; i++) { 4274 for (int j = 0; j < 2 ; j++) { 4275 // Extract the inputs. 4276 ArgumentsUintUchar args = new ArgumentsUintUchar(); 4277 args.inV = arrayInV[i * 2 + j]; 4278 // Figure out what the outputs should have been. 4279 CoreMathVerifier.computeConvert(args); 4280 // Validate the outputs. 4281 boolean valid = true; 4282 if (args.out != arrayOut[i * 2 + j]) { 4283 valid = false; 4284 } 4285 if (!valid) { 4286 if (!errorFound) { 4287 errorFound = true; 4288 message.append("Input inV: "); 4289 appendVariableToMessage(message, args.inV); 4290 message.append("\n"); 4291 message.append("Expected output out: "); 4292 appendVariableToMessage(message, args.out); 4293 message.append("\n"); 4294 message.append("Actual output out: "); 4295 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4296 if (args.out != arrayOut[i * 2 + j]) { 4297 message.append(" FAIL"); 4298 } 4299 message.append("\n"); 4300 message.append("Errors at"); 4301 } 4302 message.append(" ["); 4303 message.append(Integer.toString(i)); 4304 message.append(", "); 4305 message.append(Integer.toString(j)); 4306 message.append("]"); 4307 } 4308 } 4309 } 4310 assertFalse("Incorrect output for checkConvertUint2Uchar2" + 4311 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4312 } 4313 checkConvertUint3Uchar3()4314 private void checkConvertUint3Uchar3() { 4315 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xa941ddd7l, false, 8); 4316 try { 4317 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4318 script.forEach_testConvertUchar3Uint3Uchar3(inV, out); 4319 verifyResultsConvertUint3Uchar3(inV, out, false); 4320 } catch (Exception e) { 4321 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString()); 4322 } 4323 try { 4324 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 4325 scriptRelaxed.forEach_testConvertUchar3Uint3Uchar3(inV, out); 4326 verifyResultsConvertUint3Uchar3(inV, out, true); 4327 } catch (Exception e) { 4328 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString()); 4329 } 4330 } 4331 verifyResultsConvertUint3Uchar3(Allocation inV, Allocation out, boolean relaxed)4332 private void verifyResultsConvertUint3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 4333 int[] arrayInV = new int[INPUTSIZE * 4]; 4334 Arrays.fill(arrayInV, (int) 42); 4335 inV.copyTo(arrayInV); 4336 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4337 Arrays.fill(arrayOut, (byte) 42); 4338 out.copyTo(arrayOut); 4339 StringBuilder message = new StringBuilder(); 4340 boolean errorFound = false; 4341 for (int i = 0; i < INPUTSIZE; i++) { 4342 for (int j = 0; j < 3 ; j++) { 4343 // Extract the inputs. 4344 ArgumentsUintUchar args = new ArgumentsUintUchar(); 4345 args.inV = arrayInV[i * 4 + j]; 4346 // Figure out what the outputs should have been. 4347 CoreMathVerifier.computeConvert(args); 4348 // Validate the outputs. 4349 boolean valid = true; 4350 if (args.out != arrayOut[i * 4 + j]) { 4351 valid = false; 4352 } 4353 if (!valid) { 4354 if (!errorFound) { 4355 errorFound = true; 4356 message.append("Input inV: "); 4357 appendVariableToMessage(message, args.inV); 4358 message.append("\n"); 4359 message.append("Expected output out: "); 4360 appendVariableToMessage(message, args.out); 4361 message.append("\n"); 4362 message.append("Actual output out: "); 4363 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4364 if (args.out != arrayOut[i * 4 + j]) { 4365 message.append(" FAIL"); 4366 } 4367 message.append("\n"); 4368 message.append("Errors at"); 4369 } 4370 message.append(" ["); 4371 message.append(Integer.toString(i)); 4372 message.append(", "); 4373 message.append(Integer.toString(j)); 4374 message.append("]"); 4375 } 4376 } 4377 } 4378 assertFalse("Incorrect output for checkConvertUint3Uchar3" + 4379 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4380 } 4381 checkConvertUint4Uchar4()4382 private void checkConvertUint4Uchar4() { 4383 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9f5cfeb5l, false, 8); 4384 try { 4385 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4386 script.forEach_testConvertUchar4Uint4Uchar4(inV, out); 4387 verifyResultsConvertUint4Uchar4(inV, out, false); 4388 } catch (Exception e) { 4389 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString()); 4390 } 4391 try { 4392 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 4393 scriptRelaxed.forEach_testConvertUchar4Uint4Uchar4(inV, out); 4394 verifyResultsConvertUint4Uchar4(inV, out, true); 4395 } catch (Exception e) { 4396 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString()); 4397 } 4398 } 4399 verifyResultsConvertUint4Uchar4(Allocation inV, Allocation out, boolean relaxed)4400 private void verifyResultsConvertUint4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 4401 int[] arrayInV = new int[INPUTSIZE * 4]; 4402 Arrays.fill(arrayInV, (int) 42); 4403 inV.copyTo(arrayInV); 4404 byte[] arrayOut = new byte[INPUTSIZE * 4]; 4405 Arrays.fill(arrayOut, (byte) 42); 4406 out.copyTo(arrayOut); 4407 StringBuilder message = new StringBuilder(); 4408 boolean errorFound = false; 4409 for (int i = 0; i < INPUTSIZE; i++) { 4410 for (int j = 0; j < 4 ; j++) { 4411 // Extract the inputs. 4412 ArgumentsUintUchar args = new ArgumentsUintUchar(); 4413 args.inV = arrayInV[i * 4 + j]; 4414 // Figure out what the outputs should have been. 4415 CoreMathVerifier.computeConvert(args); 4416 // Validate the outputs. 4417 boolean valid = true; 4418 if (args.out != arrayOut[i * 4 + j]) { 4419 valid = false; 4420 } 4421 if (!valid) { 4422 if (!errorFound) { 4423 errorFound = true; 4424 message.append("Input inV: "); 4425 appendVariableToMessage(message, args.inV); 4426 message.append("\n"); 4427 message.append("Expected output out: "); 4428 appendVariableToMessage(message, args.out); 4429 message.append("\n"); 4430 message.append("Actual output out: "); 4431 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4432 if (args.out != arrayOut[i * 4 + j]) { 4433 message.append(" FAIL"); 4434 } 4435 message.append("\n"); 4436 message.append("Errors at"); 4437 } 4438 message.append(" ["); 4439 message.append(Integer.toString(i)); 4440 message.append(", "); 4441 message.append(Integer.toString(j)); 4442 message.append("]"); 4443 } 4444 } 4445 } 4446 assertFalse("Incorrect output for checkConvertUint4Uchar4" + 4447 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4448 } 4449 4450 public class ArgumentsFloatShort { 4451 public float inV; 4452 public short out; 4453 } 4454 checkConvertFloat2Short2()4455 private void checkConvertFloat2Short2() { 4456 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fcf2692l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 4457 try { 4458 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4459 script.forEach_testConvertShort2Float2Short2(inV, out); 4460 verifyResultsConvertFloat2Short2(inV, out, false); 4461 } catch (Exception e) { 4462 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString()); 4463 } 4464 try { 4465 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4466 scriptRelaxed.forEach_testConvertShort2Float2Short2(inV, out); 4467 verifyResultsConvertFloat2Short2(inV, out, true); 4468 } catch (Exception e) { 4469 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString()); 4470 } 4471 } 4472 verifyResultsConvertFloat2Short2(Allocation inV, Allocation out, boolean relaxed)4473 private void verifyResultsConvertFloat2Short2(Allocation inV, Allocation out, boolean relaxed) { 4474 float[] arrayInV = new float[INPUTSIZE * 2]; 4475 Arrays.fill(arrayInV, (float) 42); 4476 inV.copyTo(arrayInV); 4477 short[] arrayOut = new short[INPUTSIZE * 2]; 4478 Arrays.fill(arrayOut, (short) 42); 4479 out.copyTo(arrayOut); 4480 StringBuilder message = new StringBuilder(); 4481 boolean errorFound = false; 4482 for (int i = 0; i < INPUTSIZE; i++) { 4483 for (int j = 0; j < 2 ; j++) { 4484 // Extract the inputs. 4485 ArgumentsFloatShort args = new ArgumentsFloatShort(); 4486 args.inV = arrayInV[i * 2 + j]; 4487 // Figure out what the outputs should have been. 4488 CoreMathVerifier.computeConvert(args); 4489 // Validate the outputs. 4490 boolean valid = true; 4491 if (args.out != arrayOut[i * 2 + j]) { 4492 valid = false; 4493 } 4494 if (!valid) { 4495 if (!errorFound) { 4496 errorFound = true; 4497 message.append("Input inV: "); 4498 appendVariableToMessage(message, args.inV); 4499 message.append("\n"); 4500 message.append("Expected output out: "); 4501 appendVariableToMessage(message, args.out); 4502 message.append("\n"); 4503 message.append("Actual output out: "); 4504 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4505 if (args.out != arrayOut[i * 2 + j]) { 4506 message.append(" FAIL"); 4507 } 4508 message.append("\n"); 4509 message.append("Errors at"); 4510 } 4511 message.append(" ["); 4512 message.append(Integer.toString(i)); 4513 message.append(", "); 4514 message.append(Integer.toString(j)); 4515 message.append("]"); 4516 } 4517 } 4518 } 4519 assertFalse("Incorrect output for checkConvertFloat2Short2" + 4520 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4521 } 4522 checkConvertFloat3Short3()4523 private void checkConvertFloat3Short3() { 4524 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x85ea4770l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 4525 try { 4526 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4527 script.forEach_testConvertShort3Float3Short3(inV, out); 4528 verifyResultsConvertFloat3Short3(inV, out, false); 4529 } catch (Exception e) { 4530 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString()); 4531 } 4532 try { 4533 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4534 scriptRelaxed.forEach_testConvertShort3Float3Short3(inV, out); 4535 verifyResultsConvertFloat3Short3(inV, out, true); 4536 } catch (Exception e) { 4537 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString()); 4538 } 4539 } 4540 verifyResultsConvertFloat3Short3(Allocation inV, Allocation out, boolean relaxed)4541 private void verifyResultsConvertFloat3Short3(Allocation inV, Allocation out, boolean relaxed) { 4542 float[] arrayInV = new float[INPUTSIZE * 4]; 4543 Arrays.fill(arrayInV, (float) 42); 4544 inV.copyTo(arrayInV); 4545 short[] arrayOut = new short[INPUTSIZE * 4]; 4546 Arrays.fill(arrayOut, (short) 42); 4547 out.copyTo(arrayOut); 4548 StringBuilder message = new StringBuilder(); 4549 boolean errorFound = false; 4550 for (int i = 0; i < INPUTSIZE; i++) { 4551 for (int j = 0; j < 3 ; j++) { 4552 // Extract the inputs. 4553 ArgumentsFloatShort args = new ArgumentsFloatShort(); 4554 args.inV = arrayInV[i * 4 + j]; 4555 // Figure out what the outputs should have been. 4556 CoreMathVerifier.computeConvert(args); 4557 // Validate the outputs. 4558 boolean valid = true; 4559 if (args.out != arrayOut[i * 4 + j]) { 4560 valid = false; 4561 } 4562 if (!valid) { 4563 if (!errorFound) { 4564 errorFound = true; 4565 message.append("Input inV: "); 4566 appendVariableToMessage(message, args.inV); 4567 message.append("\n"); 4568 message.append("Expected output out: "); 4569 appendVariableToMessage(message, args.out); 4570 message.append("\n"); 4571 message.append("Actual output out: "); 4572 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4573 if (args.out != arrayOut[i * 4 + j]) { 4574 message.append(" FAIL"); 4575 } 4576 message.append("\n"); 4577 message.append("Errors at"); 4578 } 4579 message.append(" ["); 4580 message.append(Integer.toString(i)); 4581 message.append(", "); 4582 message.append(Integer.toString(j)); 4583 message.append("]"); 4584 } 4585 } 4586 } 4587 assertFalse("Incorrect output for checkConvertFloat3Short3" + 4588 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4589 } 4590 checkConvertFloat4Short4()4591 private void checkConvertFloat4Short4() { 4592 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c05684el, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 4593 try { 4594 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 4595 script.forEach_testConvertShort4Float4Short4(inV, out); 4596 verifyResultsConvertFloat4Short4(inV, out, false); 4597 } catch (Exception e) { 4598 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString()); 4599 } 4600 try { 4601 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 4602 scriptRelaxed.forEach_testConvertShort4Float4Short4(inV, out); 4603 verifyResultsConvertFloat4Short4(inV, out, true); 4604 } catch (Exception e) { 4605 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString()); 4606 } 4607 } 4608 verifyResultsConvertFloat4Short4(Allocation inV, Allocation out, boolean relaxed)4609 private void verifyResultsConvertFloat4Short4(Allocation inV, Allocation out, boolean relaxed) { 4610 float[] arrayInV = new float[INPUTSIZE * 4]; 4611 Arrays.fill(arrayInV, (float) 42); 4612 inV.copyTo(arrayInV); 4613 short[] arrayOut = new short[INPUTSIZE * 4]; 4614 Arrays.fill(arrayOut, (short) 42); 4615 out.copyTo(arrayOut); 4616 StringBuilder message = new StringBuilder(); 4617 boolean errorFound = false; 4618 for (int i = 0; i < INPUTSIZE; i++) { 4619 for (int j = 0; j < 4 ; j++) { 4620 // Extract the inputs. 4621 ArgumentsFloatShort args = new ArgumentsFloatShort(); 4622 args.inV = arrayInV[i * 4 + j]; 4623 // Figure out what the outputs should have been. 4624 CoreMathVerifier.computeConvert(args); 4625 // Validate the outputs. 4626 boolean valid = true; 4627 if (args.out != arrayOut[i * 4 + j]) { 4628 valid = false; 4629 } 4630 if (!valid) { 4631 if (!errorFound) { 4632 errorFound = true; 4633 message.append("Input inV: "); 4634 appendVariableToMessage(message, args.inV); 4635 message.append("\n"); 4636 message.append("Expected output out: "); 4637 appendVariableToMessage(message, args.out); 4638 message.append("\n"); 4639 message.append("Actual output out: "); 4640 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4641 if (args.out != arrayOut[i * 4 + j]) { 4642 message.append(" FAIL"); 4643 } 4644 message.append("\n"); 4645 message.append("Errors at"); 4646 } 4647 message.append(" ["); 4648 message.append(Integer.toString(i)); 4649 message.append(", "); 4650 message.append(Integer.toString(j)); 4651 message.append("]"); 4652 } 4653 } 4654 } 4655 assertFalse("Incorrect output for checkConvertFloat4Short4" + 4656 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4657 } 4658 4659 public class ArgumentsCharShort { 4660 public byte inV; 4661 public short out; 4662 } 4663 checkConvertChar2Short2()4664 private void checkConvertChar2Short2() { 4665 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x60f84e52l, true, 7); 4666 try { 4667 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4668 script.forEach_testConvertShort2Char2Short2(inV, out); 4669 verifyResultsConvertChar2Short2(inV, out, false); 4670 } catch (Exception e) { 4671 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString()); 4672 } 4673 try { 4674 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4675 scriptRelaxed.forEach_testConvertShort2Char2Short2(inV, out); 4676 verifyResultsConvertChar2Short2(inV, out, true); 4677 } catch (Exception e) { 4678 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString()); 4679 } 4680 } 4681 verifyResultsConvertChar2Short2(Allocation inV, Allocation out, boolean relaxed)4682 private void verifyResultsConvertChar2Short2(Allocation inV, Allocation out, boolean relaxed) { 4683 byte[] arrayInV = new byte[INPUTSIZE * 2]; 4684 Arrays.fill(arrayInV, (byte) 42); 4685 inV.copyTo(arrayInV); 4686 short[] arrayOut = new short[INPUTSIZE * 2]; 4687 Arrays.fill(arrayOut, (short) 42); 4688 out.copyTo(arrayOut); 4689 StringBuilder message = new StringBuilder(); 4690 boolean errorFound = false; 4691 for (int i = 0; i < INPUTSIZE; i++) { 4692 for (int j = 0; j < 2 ; j++) { 4693 // Extract the inputs. 4694 ArgumentsCharShort args = new ArgumentsCharShort(); 4695 args.inV = arrayInV[i * 2 + j]; 4696 // Figure out what the outputs should have been. 4697 CoreMathVerifier.computeConvert(args); 4698 // Validate the outputs. 4699 boolean valid = true; 4700 if (args.out != arrayOut[i * 2 + j]) { 4701 valid = false; 4702 } 4703 if (!valid) { 4704 if (!errorFound) { 4705 errorFound = true; 4706 message.append("Input inV: "); 4707 appendVariableToMessage(message, args.inV); 4708 message.append("\n"); 4709 message.append("Expected output out: "); 4710 appendVariableToMessage(message, args.out); 4711 message.append("\n"); 4712 message.append("Actual output out: "); 4713 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4714 if (args.out != arrayOut[i * 2 + j]) { 4715 message.append(" FAIL"); 4716 } 4717 message.append("\n"); 4718 message.append("Errors at"); 4719 } 4720 message.append(" ["); 4721 message.append(Integer.toString(i)); 4722 message.append(", "); 4723 message.append(Integer.toString(j)); 4724 message.append("]"); 4725 } 4726 } 4727 } 4728 assertFalse("Incorrect output for checkConvertChar2Short2" + 4729 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4730 } 4731 checkConvertChar3Short3()4732 private void checkConvertChar3Short3() { 4733 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x57136f30l, true, 7); 4734 try { 4735 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4736 script.forEach_testConvertShort3Char3Short3(inV, out); 4737 verifyResultsConvertChar3Short3(inV, out, false); 4738 } catch (Exception e) { 4739 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString()); 4740 } 4741 try { 4742 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4743 scriptRelaxed.forEach_testConvertShort3Char3Short3(inV, out); 4744 verifyResultsConvertChar3Short3(inV, out, true); 4745 } catch (Exception e) { 4746 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString()); 4747 } 4748 } 4749 verifyResultsConvertChar3Short3(Allocation inV, Allocation out, boolean relaxed)4750 private void verifyResultsConvertChar3Short3(Allocation inV, Allocation out, boolean relaxed) { 4751 byte[] arrayInV = new byte[INPUTSIZE * 4]; 4752 Arrays.fill(arrayInV, (byte) 42); 4753 inV.copyTo(arrayInV); 4754 short[] arrayOut = new short[INPUTSIZE * 4]; 4755 Arrays.fill(arrayOut, (short) 42); 4756 out.copyTo(arrayOut); 4757 StringBuilder message = new StringBuilder(); 4758 boolean errorFound = false; 4759 for (int i = 0; i < INPUTSIZE; i++) { 4760 for (int j = 0; j < 3 ; j++) { 4761 // Extract the inputs. 4762 ArgumentsCharShort args = new ArgumentsCharShort(); 4763 args.inV = arrayInV[i * 4 + j]; 4764 // Figure out what the outputs should have been. 4765 CoreMathVerifier.computeConvert(args); 4766 // Validate the outputs. 4767 boolean valid = true; 4768 if (args.out != arrayOut[i * 4 + j]) { 4769 valid = false; 4770 } 4771 if (!valid) { 4772 if (!errorFound) { 4773 errorFound = true; 4774 message.append("Input inV: "); 4775 appendVariableToMessage(message, args.inV); 4776 message.append("\n"); 4777 message.append("Expected output out: "); 4778 appendVariableToMessage(message, args.out); 4779 message.append("\n"); 4780 message.append("Actual output out: "); 4781 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4782 if (args.out != arrayOut[i * 4 + j]) { 4783 message.append(" FAIL"); 4784 } 4785 message.append("\n"); 4786 message.append("Errors at"); 4787 } 4788 message.append(" ["); 4789 message.append(Integer.toString(i)); 4790 message.append(", "); 4791 message.append(Integer.toString(j)); 4792 message.append("]"); 4793 } 4794 } 4795 } 4796 assertFalse("Incorrect output for checkConvertChar3Short3" + 4797 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4798 } 4799 checkConvertChar4Short4()4800 private void checkConvertChar4Short4() { 4801 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x4d2e900el, true, 7); 4802 try { 4803 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 4804 script.forEach_testConvertShort4Char4Short4(inV, out); 4805 verifyResultsConvertChar4Short4(inV, out, false); 4806 } catch (Exception e) { 4807 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString()); 4808 } 4809 try { 4810 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 4811 scriptRelaxed.forEach_testConvertShort4Char4Short4(inV, out); 4812 verifyResultsConvertChar4Short4(inV, out, true); 4813 } catch (Exception e) { 4814 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString()); 4815 } 4816 } 4817 verifyResultsConvertChar4Short4(Allocation inV, Allocation out, boolean relaxed)4818 private void verifyResultsConvertChar4Short4(Allocation inV, Allocation out, boolean relaxed) { 4819 byte[] arrayInV = new byte[INPUTSIZE * 4]; 4820 Arrays.fill(arrayInV, (byte) 42); 4821 inV.copyTo(arrayInV); 4822 short[] arrayOut = new short[INPUTSIZE * 4]; 4823 Arrays.fill(arrayOut, (short) 42); 4824 out.copyTo(arrayOut); 4825 StringBuilder message = new StringBuilder(); 4826 boolean errorFound = false; 4827 for (int i = 0; i < INPUTSIZE; i++) { 4828 for (int j = 0; j < 4 ; j++) { 4829 // Extract the inputs. 4830 ArgumentsCharShort args = new ArgumentsCharShort(); 4831 args.inV = arrayInV[i * 4 + j]; 4832 // Figure out what the outputs should have been. 4833 CoreMathVerifier.computeConvert(args); 4834 // Validate the outputs. 4835 boolean valid = true; 4836 if (args.out != arrayOut[i * 4 + j]) { 4837 valid = false; 4838 } 4839 if (!valid) { 4840 if (!errorFound) { 4841 errorFound = true; 4842 message.append("Input inV: "); 4843 appendVariableToMessage(message, args.inV); 4844 message.append("\n"); 4845 message.append("Expected output out: "); 4846 appendVariableToMessage(message, args.out); 4847 message.append("\n"); 4848 message.append("Actual output out: "); 4849 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4850 if (args.out != arrayOut[i * 4 + j]) { 4851 message.append(" FAIL"); 4852 } 4853 message.append("\n"); 4854 message.append("Errors at"); 4855 } 4856 message.append(" ["); 4857 message.append(Integer.toString(i)); 4858 message.append(", "); 4859 message.append(Integer.toString(j)); 4860 message.append("]"); 4861 } 4862 } 4863 } 4864 assertFalse("Incorrect output for checkConvertChar4Short4" + 4865 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4866 } 4867 4868 public class ArgumentsUcharShort { 4869 public byte inV; 4870 public short out; 4871 } 4872 checkConvertUchar2Short2()4873 private void checkConvertUchar2Short2() { 4874 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xfcd067fdl, false, 8); 4875 try { 4876 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4877 script.forEach_testConvertShort2Uchar2Short2(inV, out); 4878 verifyResultsConvertUchar2Short2(inV, out, false); 4879 } catch (Exception e) { 4880 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString()); 4881 } 4882 try { 4883 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 4884 scriptRelaxed.forEach_testConvertShort2Uchar2Short2(inV, out); 4885 verifyResultsConvertUchar2Short2(inV, out, true); 4886 } catch (Exception e) { 4887 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString()); 4888 } 4889 } 4890 verifyResultsConvertUchar2Short2(Allocation inV, Allocation out, boolean relaxed)4891 private void verifyResultsConvertUchar2Short2(Allocation inV, Allocation out, boolean relaxed) { 4892 byte[] arrayInV = new byte[INPUTSIZE * 2]; 4893 Arrays.fill(arrayInV, (byte) 42); 4894 inV.copyTo(arrayInV); 4895 short[] arrayOut = new short[INPUTSIZE * 2]; 4896 Arrays.fill(arrayOut, (short) 42); 4897 out.copyTo(arrayOut); 4898 StringBuilder message = new StringBuilder(); 4899 boolean errorFound = false; 4900 for (int i = 0; i < INPUTSIZE; i++) { 4901 for (int j = 0; j < 2 ; j++) { 4902 // Extract the inputs. 4903 ArgumentsUcharShort args = new ArgumentsUcharShort(); 4904 args.inV = arrayInV[i * 2 + j]; 4905 // Figure out what the outputs should have been. 4906 CoreMathVerifier.computeConvert(args); 4907 // Validate the outputs. 4908 boolean valid = true; 4909 if (args.out != arrayOut[i * 2 + j]) { 4910 valid = false; 4911 } 4912 if (!valid) { 4913 if (!errorFound) { 4914 errorFound = true; 4915 message.append("Input inV: "); 4916 appendVariableToMessage(message, args.inV); 4917 message.append("\n"); 4918 message.append("Expected output out: "); 4919 appendVariableToMessage(message, args.out); 4920 message.append("\n"); 4921 message.append("Actual output out: "); 4922 appendVariableToMessage(message, arrayOut[i * 2 + j]); 4923 if (args.out != arrayOut[i * 2 + j]) { 4924 message.append(" FAIL"); 4925 } 4926 message.append("\n"); 4927 message.append("Errors at"); 4928 } 4929 message.append(" ["); 4930 message.append(Integer.toString(i)); 4931 message.append(", "); 4932 message.append(Integer.toString(j)); 4933 message.append("]"); 4934 } 4935 } 4936 } 4937 assertFalse("Incorrect output for checkConvertUchar2Short2" + 4938 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 4939 } 4940 checkConvertUchar3Short3()4941 private void checkConvertUchar3Short3() { 4942 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xf2eb88dbl, false, 8); 4943 try { 4944 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4945 script.forEach_testConvertShort3Uchar3Short3(inV, out); 4946 verifyResultsConvertUchar3Short3(inV, out, false); 4947 } catch (Exception e) { 4948 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString()); 4949 } 4950 try { 4951 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 4952 scriptRelaxed.forEach_testConvertShort3Uchar3Short3(inV, out); 4953 verifyResultsConvertUchar3Short3(inV, out, true); 4954 } catch (Exception e) { 4955 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString()); 4956 } 4957 } 4958 verifyResultsConvertUchar3Short3(Allocation inV, Allocation out, boolean relaxed)4959 private void verifyResultsConvertUchar3Short3(Allocation inV, Allocation out, boolean relaxed) { 4960 byte[] arrayInV = new byte[INPUTSIZE * 4]; 4961 Arrays.fill(arrayInV, (byte) 42); 4962 inV.copyTo(arrayInV); 4963 short[] arrayOut = new short[INPUTSIZE * 4]; 4964 Arrays.fill(arrayOut, (short) 42); 4965 out.copyTo(arrayOut); 4966 StringBuilder message = new StringBuilder(); 4967 boolean errorFound = false; 4968 for (int i = 0; i < INPUTSIZE; i++) { 4969 for (int j = 0; j < 3 ; j++) { 4970 // Extract the inputs. 4971 ArgumentsUcharShort args = new ArgumentsUcharShort(); 4972 args.inV = arrayInV[i * 4 + j]; 4973 // Figure out what the outputs should have been. 4974 CoreMathVerifier.computeConvert(args); 4975 // Validate the outputs. 4976 boolean valid = true; 4977 if (args.out != arrayOut[i * 4 + j]) { 4978 valid = false; 4979 } 4980 if (!valid) { 4981 if (!errorFound) { 4982 errorFound = true; 4983 message.append("Input inV: "); 4984 appendVariableToMessage(message, args.inV); 4985 message.append("\n"); 4986 message.append("Expected output out: "); 4987 appendVariableToMessage(message, args.out); 4988 message.append("\n"); 4989 message.append("Actual output out: "); 4990 appendVariableToMessage(message, arrayOut[i * 4 + j]); 4991 if (args.out != arrayOut[i * 4 + j]) { 4992 message.append(" FAIL"); 4993 } 4994 message.append("\n"); 4995 message.append("Errors at"); 4996 } 4997 message.append(" ["); 4998 message.append(Integer.toString(i)); 4999 message.append(", "); 5000 message.append(Integer.toString(j)); 5001 message.append("]"); 5002 } 5003 } 5004 } 5005 assertFalse("Incorrect output for checkConvertUchar3Short3" + 5006 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5007 } 5008 checkConvertUchar4Short4()5009 private void checkConvertUchar4Short4() { 5010 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe906a9b9l, false, 8); 5011 try { 5012 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5013 script.forEach_testConvertShort4Uchar4Short4(inV, out); 5014 verifyResultsConvertUchar4Short4(inV, out, false); 5015 } catch (Exception e) { 5016 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString()); 5017 } 5018 try { 5019 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5020 scriptRelaxed.forEach_testConvertShort4Uchar4Short4(inV, out); 5021 verifyResultsConvertUchar4Short4(inV, out, true); 5022 } catch (Exception e) { 5023 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString()); 5024 } 5025 } 5026 verifyResultsConvertUchar4Short4(Allocation inV, Allocation out, boolean relaxed)5027 private void verifyResultsConvertUchar4Short4(Allocation inV, Allocation out, boolean relaxed) { 5028 byte[] arrayInV = new byte[INPUTSIZE * 4]; 5029 Arrays.fill(arrayInV, (byte) 42); 5030 inV.copyTo(arrayInV); 5031 short[] arrayOut = new short[INPUTSIZE * 4]; 5032 Arrays.fill(arrayOut, (short) 42); 5033 out.copyTo(arrayOut); 5034 StringBuilder message = new StringBuilder(); 5035 boolean errorFound = false; 5036 for (int i = 0; i < INPUTSIZE; i++) { 5037 for (int j = 0; j < 4 ; j++) { 5038 // Extract the inputs. 5039 ArgumentsUcharShort args = new ArgumentsUcharShort(); 5040 args.inV = arrayInV[i * 4 + j]; 5041 // Figure out what the outputs should have been. 5042 CoreMathVerifier.computeConvert(args); 5043 // Validate the outputs. 5044 boolean valid = true; 5045 if (args.out != arrayOut[i * 4 + j]) { 5046 valid = false; 5047 } 5048 if (!valid) { 5049 if (!errorFound) { 5050 errorFound = true; 5051 message.append("Input inV: "); 5052 appendVariableToMessage(message, args.inV); 5053 message.append("\n"); 5054 message.append("Expected output out: "); 5055 appendVariableToMessage(message, args.out); 5056 message.append("\n"); 5057 message.append("Actual output out: "); 5058 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5059 if (args.out != arrayOut[i * 4 + j]) { 5060 message.append(" FAIL"); 5061 } 5062 message.append("\n"); 5063 message.append("Errors at"); 5064 } 5065 message.append(" ["); 5066 message.append(Integer.toString(i)); 5067 message.append(", "); 5068 message.append(Integer.toString(j)); 5069 message.append("]"); 5070 } 5071 } 5072 } 5073 assertFalse("Incorrect output for checkConvertUchar4Short4" + 5074 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5075 } 5076 5077 public class ArgumentsShortShort { 5078 public short inV; 5079 public short out; 5080 } 5081 checkConvertShort2Short2()5082 private void checkConvertShort2Short2() { 5083 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x40d14d3el, true, 15); 5084 try { 5085 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5086 script.forEach_testConvertShort2Short2Short2(inV, out); 5087 verifyResultsConvertShort2Short2(inV, out, false); 5088 } catch (Exception e) { 5089 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString()); 5090 } 5091 try { 5092 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5093 scriptRelaxed.forEach_testConvertShort2Short2Short2(inV, out); 5094 verifyResultsConvertShort2Short2(inV, out, true); 5095 } catch (Exception e) { 5096 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString()); 5097 } 5098 } 5099 verifyResultsConvertShort2Short2(Allocation inV, Allocation out, boolean relaxed)5100 private void verifyResultsConvertShort2Short2(Allocation inV, Allocation out, boolean relaxed) { 5101 short[] arrayInV = new short[INPUTSIZE * 2]; 5102 Arrays.fill(arrayInV, (short) 42); 5103 inV.copyTo(arrayInV); 5104 short[] arrayOut = new short[INPUTSIZE * 2]; 5105 Arrays.fill(arrayOut, (short) 42); 5106 out.copyTo(arrayOut); 5107 StringBuilder message = new StringBuilder(); 5108 boolean errorFound = false; 5109 for (int i = 0; i < INPUTSIZE; i++) { 5110 for (int j = 0; j < 2 ; j++) { 5111 // Extract the inputs. 5112 ArgumentsShortShort args = new ArgumentsShortShort(); 5113 args.inV = arrayInV[i * 2 + j]; 5114 // Figure out what the outputs should have been. 5115 CoreMathVerifier.computeConvert(args); 5116 // Validate the outputs. 5117 boolean valid = true; 5118 if (args.out != arrayOut[i * 2 + j]) { 5119 valid = false; 5120 } 5121 if (!valid) { 5122 if (!errorFound) { 5123 errorFound = true; 5124 message.append("Input inV: "); 5125 appendVariableToMessage(message, args.inV); 5126 message.append("\n"); 5127 message.append("Expected output out: "); 5128 appendVariableToMessage(message, args.out); 5129 message.append("\n"); 5130 message.append("Actual output out: "); 5131 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5132 if (args.out != arrayOut[i * 2 + j]) { 5133 message.append(" FAIL"); 5134 } 5135 message.append("\n"); 5136 message.append("Errors at"); 5137 } 5138 message.append(" ["); 5139 message.append(Integer.toString(i)); 5140 message.append(", "); 5141 message.append(Integer.toString(j)); 5142 message.append("]"); 5143 } 5144 } 5145 } 5146 assertFalse("Incorrect output for checkConvertShort2Short2" + 5147 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5148 } 5149 checkConvertShort3Short3()5150 private void checkConvertShort3Short3() { 5151 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x36ec6e1cl, true, 15); 5152 try { 5153 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5154 script.forEach_testConvertShort3Short3Short3(inV, out); 5155 verifyResultsConvertShort3Short3(inV, out, false); 5156 } catch (Exception e) { 5157 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString()); 5158 } 5159 try { 5160 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5161 scriptRelaxed.forEach_testConvertShort3Short3Short3(inV, out); 5162 verifyResultsConvertShort3Short3(inV, out, true); 5163 } catch (Exception e) { 5164 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString()); 5165 } 5166 } 5167 verifyResultsConvertShort3Short3(Allocation inV, Allocation out, boolean relaxed)5168 private void verifyResultsConvertShort3Short3(Allocation inV, Allocation out, boolean relaxed) { 5169 short[] arrayInV = new short[INPUTSIZE * 4]; 5170 Arrays.fill(arrayInV, (short) 42); 5171 inV.copyTo(arrayInV); 5172 short[] arrayOut = new short[INPUTSIZE * 4]; 5173 Arrays.fill(arrayOut, (short) 42); 5174 out.copyTo(arrayOut); 5175 StringBuilder message = new StringBuilder(); 5176 boolean errorFound = false; 5177 for (int i = 0; i < INPUTSIZE; i++) { 5178 for (int j = 0; j < 3 ; j++) { 5179 // Extract the inputs. 5180 ArgumentsShortShort args = new ArgumentsShortShort(); 5181 args.inV = arrayInV[i * 4 + j]; 5182 // Figure out what the outputs should have been. 5183 CoreMathVerifier.computeConvert(args); 5184 // Validate the outputs. 5185 boolean valid = true; 5186 if (args.out != arrayOut[i * 4 + j]) { 5187 valid = false; 5188 } 5189 if (!valid) { 5190 if (!errorFound) { 5191 errorFound = true; 5192 message.append("Input inV: "); 5193 appendVariableToMessage(message, args.inV); 5194 message.append("\n"); 5195 message.append("Expected output out: "); 5196 appendVariableToMessage(message, args.out); 5197 message.append("\n"); 5198 message.append("Actual output out: "); 5199 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5200 if (args.out != arrayOut[i * 4 + j]) { 5201 message.append(" FAIL"); 5202 } 5203 message.append("\n"); 5204 message.append("Errors at"); 5205 } 5206 message.append(" ["); 5207 message.append(Integer.toString(i)); 5208 message.append(", "); 5209 message.append(Integer.toString(j)); 5210 message.append("]"); 5211 } 5212 } 5213 } 5214 assertFalse("Incorrect output for checkConvertShort3Short3" + 5215 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5216 } 5217 checkConvertShort4Short4()5218 private void checkConvertShort4Short4() { 5219 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x2d078efal, true, 15); 5220 try { 5221 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5222 script.forEach_testConvertShort4Short4Short4(inV, out); 5223 verifyResultsConvertShort4Short4(inV, out, false); 5224 } catch (Exception e) { 5225 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString()); 5226 } 5227 try { 5228 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5229 scriptRelaxed.forEach_testConvertShort4Short4Short4(inV, out); 5230 verifyResultsConvertShort4Short4(inV, out, true); 5231 } catch (Exception e) { 5232 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString()); 5233 } 5234 } 5235 verifyResultsConvertShort4Short4(Allocation inV, Allocation out, boolean relaxed)5236 private void verifyResultsConvertShort4Short4(Allocation inV, Allocation out, boolean relaxed) { 5237 short[] arrayInV = new short[INPUTSIZE * 4]; 5238 Arrays.fill(arrayInV, (short) 42); 5239 inV.copyTo(arrayInV); 5240 short[] arrayOut = new short[INPUTSIZE * 4]; 5241 Arrays.fill(arrayOut, (short) 42); 5242 out.copyTo(arrayOut); 5243 StringBuilder message = new StringBuilder(); 5244 boolean errorFound = false; 5245 for (int i = 0; i < INPUTSIZE; i++) { 5246 for (int j = 0; j < 4 ; j++) { 5247 // Extract the inputs. 5248 ArgumentsShortShort args = new ArgumentsShortShort(); 5249 args.inV = arrayInV[i * 4 + j]; 5250 // Figure out what the outputs should have been. 5251 CoreMathVerifier.computeConvert(args); 5252 // Validate the outputs. 5253 boolean valid = true; 5254 if (args.out != arrayOut[i * 4 + j]) { 5255 valid = false; 5256 } 5257 if (!valid) { 5258 if (!errorFound) { 5259 errorFound = true; 5260 message.append("Input inV: "); 5261 appendVariableToMessage(message, args.inV); 5262 message.append("\n"); 5263 message.append("Expected output out: "); 5264 appendVariableToMessage(message, args.out); 5265 message.append("\n"); 5266 message.append("Actual output out: "); 5267 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5268 if (args.out != arrayOut[i * 4 + j]) { 5269 message.append(" FAIL"); 5270 } 5271 message.append("\n"); 5272 message.append("Errors at"); 5273 } 5274 message.append(" ["); 5275 message.append(Integer.toString(i)); 5276 message.append(", "); 5277 message.append(Integer.toString(j)); 5278 message.append("]"); 5279 } 5280 } 5281 } 5282 assertFalse("Incorrect output for checkConvertShort4Short4" + 5283 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5284 } 5285 5286 public class ArgumentsUshortShort { 5287 public short inV; 5288 public short out; 5289 } 5290 checkConvertUshort2Short2()5291 private void checkConvertUshort2Short2() { 5292 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x6e1d9cf7l, false, 15); 5293 try { 5294 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5295 script.forEach_testConvertShort2Ushort2Short2(inV, out); 5296 verifyResultsConvertUshort2Short2(inV, out, false); 5297 } catch (Exception e) { 5298 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString()); 5299 } 5300 try { 5301 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5302 scriptRelaxed.forEach_testConvertShort2Ushort2Short2(inV, out); 5303 verifyResultsConvertUshort2Short2(inV, out, true); 5304 } catch (Exception e) { 5305 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString()); 5306 } 5307 } 5308 verifyResultsConvertUshort2Short2(Allocation inV, Allocation out, boolean relaxed)5309 private void verifyResultsConvertUshort2Short2(Allocation inV, Allocation out, boolean relaxed) { 5310 short[] arrayInV = new short[INPUTSIZE * 2]; 5311 Arrays.fill(arrayInV, (short) 42); 5312 inV.copyTo(arrayInV); 5313 short[] arrayOut = new short[INPUTSIZE * 2]; 5314 Arrays.fill(arrayOut, (short) 42); 5315 out.copyTo(arrayOut); 5316 StringBuilder message = new StringBuilder(); 5317 boolean errorFound = false; 5318 for (int i = 0; i < INPUTSIZE; i++) { 5319 for (int j = 0; j < 2 ; j++) { 5320 // Extract the inputs. 5321 ArgumentsUshortShort args = new ArgumentsUshortShort(); 5322 args.inV = arrayInV[i * 2 + j]; 5323 // Figure out what the outputs should have been. 5324 CoreMathVerifier.computeConvert(args); 5325 // Validate the outputs. 5326 boolean valid = true; 5327 if (args.out != arrayOut[i * 2 + j]) { 5328 valid = false; 5329 } 5330 if (!valid) { 5331 if (!errorFound) { 5332 errorFound = true; 5333 message.append("Input inV: "); 5334 appendVariableToMessage(message, args.inV); 5335 message.append("\n"); 5336 message.append("Expected output out: "); 5337 appendVariableToMessage(message, args.out); 5338 message.append("\n"); 5339 message.append("Actual output out: "); 5340 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5341 if (args.out != arrayOut[i * 2 + j]) { 5342 message.append(" FAIL"); 5343 } 5344 message.append("\n"); 5345 message.append("Errors at"); 5346 } 5347 message.append(" ["); 5348 message.append(Integer.toString(i)); 5349 message.append(", "); 5350 message.append(Integer.toString(j)); 5351 message.append("]"); 5352 } 5353 } 5354 } 5355 assertFalse("Incorrect output for checkConvertUshort2Short2" + 5356 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5357 } 5358 checkConvertUshort3Short3()5359 private void checkConvertUshort3Short3() { 5360 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6438bdd5l, false, 15); 5361 try { 5362 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5363 script.forEach_testConvertShort3Ushort3Short3(inV, out); 5364 verifyResultsConvertUshort3Short3(inV, out, false); 5365 } catch (Exception e) { 5366 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString()); 5367 } 5368 try { 5369 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5370 scriptRelaxed.forEach_testConvertShort3Ushort3Short3(inV, out); 5371 verifyResultsConvertUshort3Short3(inV, out, true); 5372 } catch (Exception e) { 5373 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString()); 5374 } 5375 } 5376 verifyResultsConvertUshort3Short3(Allocation inV, Allocation out, boolean relaxed)5377 private void verifyResultsConvertUshort3Short3(Allocation inV, Allocation out, boolean relaxed) { 5378 short[] arrayInV = new short[INPUTSIZE * 4]; 5379 Arrays.fill(arrayInV, (short) 42); 5380 inV.copyTo(arrayInV); 5381 short[] arrayOut = new short[INPUTSIZE * 4]; 5382 Arrays.fill(arrayOut, (short) 42); 5383 out.copyTo(arrayOut); 5384 StringBuilder message = new StringBuilder(); 5385 boolean errorFound = false; 5386 for (int i = 0; i < INPUTSIZE; i++) { 5387 for (int j = 0; j < 3 ; j++) { 5388 // Extract the inputs. 5389 ArgumentsUshortShort args = new ArgumentsUshortShort(); 5390 args.inV = arrayInV[i * 4 + j]; 5391 // Figure out what the outputs should have been. 5392 CoreMathVerifier.computeConvert(args); 5393 // Validate the outputs. 5394 boolean valid = true; 5395 if (args.out != arrayOut[i * 4 + j]) { 5396 valid = false; 5397 } 5398 if (!valid) { 5399 if (!errorFound) { 5400 errorFound = true; 5401 message.append("Input inV: "); 5402 appendVariableToMessage(message, args.inV); 5403 message.append("\n"); 5404 message.append("Expected output out: "); 5405 appendVariableToMessage(message, args.out); 5406 message.append("\n"); 5407 message.append("Actual output out: "); 5408 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5409 if (args.out != arrayOut[i * 4 + j]) { 5410 message.append(" FAIL"); 5411 } 5412 message.append("\n"); 5413 message.append("Errors at"); 5414 } 5415 message.append(" ["); 5416 message.append(Integer.toString(i)); 5417 message.append(", "); 5418 message.append(Integer.toString(j)); 5419 message.append("]"); 5420 } 5421 } 5422 } 5423 assertFalse("Incorrect output for checkConvertUshort3Short3" + 5424 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5425 } 5426 checkConvertUshort4Short4()5427 private void checkConvertUshort4Short4() { 5428 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x5a53deb3l, false, 15); 5429 try { 5430 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5431 script.forEach_testConvertShort4Ushort4Short4(inV, out); 5432 verifyResultsConvertUshort4Short4(inV, out, false); 5433 } catch (Exception e) { 5434 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString()); 5435 } 5436 try { 5437 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5438 scriptRelaxed.forEach_testConvertShort4Ushort4Short4(inV, out); 5439 verifyResultsConvertUshort4Short4(inV, out, true); 5440 } catch (Exception e) { 5441 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString()); 5442 } 5443 } 5444 verifyResultsConvertUshort4Short4(Allocation inV, Allocation out, boolean relaxed)5445 private void verifyResultsConvertUshort4Short4(Allocation inV, Allocation out, boolean relaxed) { 5446 short[] arrayInV = new short[INPUTSIZE * 4]; 5447 Arrays.fill(arrayInV, (short) 42); 5448 inV.copyTo(arrayInV); 5449 short[] arrayOut = new short[INPUTSIZE * 4]; 5450 Arrays.fill(arrayOut, (short) 42); 5451 out.copyTo(arrayOut); 5452 StringBuilder message = new StringBuilder(); 5453 boolean errorFound = false; 5454 for (int i = 0; i < INPUTSIZE; i++) { 5455 for (int j = 0; j < 4 ; j++) { 5456 // Extract the inputs. 5457 ArgumentsUshortShort args = new ArgumentsUshortShort(); 5458 args.inV = arrayInV[i * 4 + j]; 5459 // Figure out what the outputs should have been. 5460 CoreMathVerifier.computeConvert(args); 5461 // Validate the outputs. 5462 boolean valid = true; 5463 if (args.out != arrayOut[i * 4 + j]) { 5464 valid = false; 5465 } 5466 if (!valid) { 5467 if (!errorFound) { 5468 errorFound = true; 5469 message.append("Input inV: "); 5470 appendVariableToMessage(message, args.inV); 5471 message.append("\n"); 5472 message.append("Expected output out: "); 5473 appendVariableToMessage(message, args.out); 5474 message.append("\n"); 5475 message.append("Actual output out: "); 5476 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5477 if (args.out != arrayOut[i * 4 + j]) { 5478 message.append(" FAIL"); 5479 } 5480 message.append("\n"); 5481 message.append("Errors at"); 5482 } 5483 message.append(" ["); 5484 message.append(Integer.toString(i)); 5485 message.append(", "); 5486 message.append(Integer.toString(j)); 5487 message.append("]"); 5488 } 5489 } 5490 } 5491 assertFalse("Incorrect output for checkConvertUshort4Short4" + 5492 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5493 } 5494 5495 public class ArgumentsIntShort { 5496 public int inV; 5497 public short out; 5498 } 5499 checkConvertInt2Short2()5500 private void checkConvertInt2Short2() { 5501 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xb5b27b91l, true, 15); 5502 try { 5503 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5504 script.forEach_testConvertShort2Int2Short2(inV, out); 5505 verifyResultsConvertInt2Short2(inV, out, false); 5506 } catch (Exception e) { 5507 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString()); 5508 } 5509 try { 5510 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5511 scriptRelaxed.forEach_testConvertShort2Int2Short2(inV, out); 5512 verifyResultsConvertInt2Short2(inV, out, true); 5513 } catch (Exception e) { 5514 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString()); 5515 } 5516 } 5517 verifyResultsConvertInt2Short2(Allocation inV, Allocation out, boolean relaxed)5518 private void verifyResultsConvertInt2Short2(Allocation inV, Allocation out, boolean relaxed) { 5519 int[] arrayInV = new int[INPUTSIZE * 2]; 5520 Arrays.fill(arrayInV, (int) 42); 5521 inV.copyTo(arrayInV); 5522 short[] arrayOut = new short[INPUTSIZE * 2]; 5523 Arrays.fill(arrayOut, (short) 42); 5524 out.copyTo(arrayOut); 5525 StringBuilder message = new StringBuilder(); 5526 boolean errorFound = false; 5527 for (int i = 0; i < INPUTSIZE; i++) { 5528 for (int j = 0; j < 2 ; j++) { 5529 // Extract the inputs. 5530 ArgumentsIntShort args = new ArgumentsIntShort(); 5531 args.inV = arrayInV[i * 2 + j]; 5532 // Figure out what the outputs should have been. 5533 CoreMathVerifier.computeConvert(args); 5534 // Validate the outputs. 5535 boolean valid = true; 5536 if (args.out != arrayOut[i * 2 + j]) { 5537 valid = false; 5538 } 5539 if (!valid) { 5540 if (!errorFound) { 5541 errorFound = true; 5542 message.append("Input inV: "); 5543 appendVariableToMessage(message, args.inV); 5544 message.append("\n"); 5545 message.append("Expected output out: "); 5546 appendVariableToMessage(message, args.out); 5547 message.append("\n"); 5548 message.append("Actual output out: "); 5549 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5550 if (args.out != arrayOut[i * 2 + j]) { 5551 message.append(" FAIL"); 5552 } 5553 message.append("\n"); 5554 message.append("Errors at"); 5555 } 5556 message.append(" ["); 5557 message.append(Integer.toString(i)); 5558 message.append(", "); 5559 message.append(Integer.toString(j)); 5560 message.append("]"); 5561 } 5562 } 5563 } 5564 assertFalse("Incorrect output for checkConvertInt2Short2" + 5565 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5566 } 5567 checkConvertInt3Short3()5568 private void checkConvertInt3Short3() { 5569 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xabcd9c6fl, true, 15); 5570 try { 5571 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5572 script.forEach_testConvertShort3Int3Short3(inV, out); 5573 verifyResultsConvertInt3Short3(inV, out, false); 5574 } catch (Exception e) { 5575 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString()); 5576 } 5577 try { 5578 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5579 scriptRelaxed.forEach_testConvertShort3Int3Short3(inV, out); 5580 verifyResultsConvertInt3Short3(inV, out, true); 5581 } catch (Exception e) { 5582 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString()); 5583 } 5584 } 5585 verifyResultsConvertInt3Short3(Allocation inV, Allocation out, boolean relaxed)5586 private void verifyResultsConvertInt3Short3(Allocation inV, Allocation out, boolean relaxed) { 5587 int[] arrayInV = new int[INPUTSIZE * 4]; 5588 Arrays.fill(arrayInV, (int) 42); 5589 inV.copyTo(arrayInV); 5590 short[] arrayOut = new short[INPUTSIZE * 4]; 5591 Arrays.fill(arrayOut, (short) 42); 5592 out.copyTo(arrayOut); 5593 StringBuilder message = new StringBuilder(); 5594 boolean errorFound = false; 5595 for (int i = 0; i < INPUTSIZE; i++) { 5596 for (int j = 0; j < 3 ; j++) { 5597 // Extract the inputs. 5598 ArgumentsIntShort args = new ArgumentsIntShort(); 5599 args.inV = arrayInV[i * 4 + j]; 5600 // Figure out what the outputs should have been. 5601 CoreMathVerifier.computeConvert(args); 5602 // Validate the outputs. 5603 boolean valid = true; 5604 if (args.out != arrayOut[i * 4 + j]) { 5605 valid = false; 5606 } 5607 if (!valid) { 5608 if (!errorFound) { 5609 errorFound = true; 5610 message.append("Input inV: "); 5611 appendVariableToMessage(message, args.inV); 5612 message.append("\n"); 5613 message.append("Expected output out: "); 5614 appendVariableToMessage(message, args.out); 5615 message.append("\n"); 5616 message.append("Actual output out: "); 5617 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5618 if (args.out != arrayOut[i * 4 + j]) { 5619 message.append(" FAIL"); 5620 } 5621 message.append("\n"); 5622 message.append("Errors at"); 5623 } 5624 message.append(" ["); 5625 message.append(Integer.toString(i)); 5626 message.append(", "); 5627 message.append(Integer.toString(j)); 5628 message.append("]"); 5629 } 5630 } 5631 } 5632 assertFalse("Incorrect output for checkConvertInt3Short3" + 5633 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5634 } 5635 checkConvertInt4Short4()5636 private void checkConvertInt4Short4() { 5637 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa1e8bd4dl, true, 15); 5638 try { 5639 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5640 script.forEach_testConvertShort4Int4Short4(inV, out); 5641 verifyResultsConvertInt4Short4(inV, out, false); 5642 } catch (Exception e) { 5643 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString()); 5644 } 5645 try { 5646 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5647 scriptRelaxed.forEach_testConvertShort4Int4Short4(inV, out); 5648 verifyResultsConvertInt4Short4(inV, out, true); 5649 } catch (Exception e) { 5650 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString()); 5651 } 5652 } 5653 verifyResultsConvertInt4Short4(Allocation inV, Allocation out, boolean relaxed)5654 private void verifyResultsConvertInt4Short4(Allocation inV, Allocation out, boolean relaxed) { 5655 int[] arrayInV = new int[INPUTSIZE * 4]; 5656 Arrays.fill(arrayInV, (int) 42); 5657 inV.copyTo(arrayInV); 5658 short[] arrayOut = new short[INPUTSIZE * 4]; 5659 Arrays.fill(arrayOut, (short) 42); 5660 out.copyTo(arrayOut); 5661 StringBuilder message = new StringBuilder(); 5662 boolean errorFound = false; 5663 for (int i = 0; i < INPUTSIZE; i++) { 5664 for (int j = 0; j < 4 ; j++) { 5665 // Extract the inputs. 5666 ArgumentsIntShort args = new ArgumentsIntShort(); 5667 args.inV = arrayInV[i * 4 + j]; 5668 // Figure out what the outputs should have been. 5669 CoreMathVerifier.computeConvert(args); 5670 // Validate the outputs. 5671 boolean valid = true; 5672 if (args.out != arrayOut[i * 4 + j]) { 5673 valid = false; 5674 } 5675 if (!valid) { 5676 if (!errorFound) { 5677 errorFound = true; 5678 message.append("Input inV: "); 5679 appendVariableToMessage(message, args.inV); 5680 message.append("\n"); 5681 message.append("Expected output out: "); 5682 appendVariableToMessage(message, args.out); 5683 message.append("\n"); 5684 message.append("Actual output out: "); 5685 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5686 if (args.out != arrayOut[i * 4 + j]) { 5687 message.append(" FAIL"); 5688 } 5689 message.append("\n"); 5690 message.append("Errors at"); 5691 } 5692 message.append(" ["); 5693 message.append(Integer.toString(i)); 5694 message.append(", "); 5695 message.append(Integer.toString(j)); 5696 message.append("]"); 5697 } 5698 } 5699 } 5700 assertFalse("Incorrect output for checkConvertInt4Short4" + 5701 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5702 } 5703 5704 public class ArgumentsUintShort { 5705 public int inV; 5706 public short out; 5707 } 5708 checkConvertUint2Short2()5709 private void checkConvertUint2Short2() { 5710 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x48348812l, false, 15); 5711 try { 5712 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5713 script.forEach_testConvertShort2Uint2Short2(inV, out); 5714 verifyResultsConvertUint2Short2(inV, out, false); 5715 } catch (Exception e) { 5716 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString()); 5717 } 5718 try { 5719 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 5720 scriptRelaxed.forEach_testConvertShort2Uint2Short2(inV, out); 5721 verifyResultsConvertUint2Short2(inV, out, true); 5722 } catch (Exception e) { 5723 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString()); 5724 } 5725 } 5726 verifyResultsConvertUint2Short2(Allocation inV, Allocation out, boolean relaxed)5727 private void verifyResultsConvertUint2Short2(Allocation inV, Allocation out, boolean relaxed) { 5728 int[] arrayInV = new int[INPUTSIZE * 2]; 5729 Arrays.fill(arrayInV, (int) 42); 5730 inV.copyTo(arrayInV); 5731 short[] arrayOut = new short[INPUTSIZE * 2]; 5732 Arrays.fill(arrayOut, (short) 42); 5733 out.copyTo(arrayOut); 5734 StringBuilder message = new StringBuilder(); 5735 boolean errorFound = false; 5736 for (int i = 0; i < INPUTSIZE; i++) { 5737 for (int j = 0; j < 2 ; j++) { 5738 // Extract the inputs. 5739 ArgumentsUintShort args = new ArgumentsUintShort(); 5740 args.inV = arrayInV[i * 2 + j]; 5741 // Figure out what the outputs should have been. 5742 CoreMathVerifier.computeConvert(args); 5743 // Validate the outputs. 5744 boolean valid = true; 5745 if (args.out != arrayOut[i * 2 + j]) { 5746 valid = false; 5747 } 5748 if (!valid) { 5749 if (!errorFound) { 5750 errorFound = true; 5751 message.append("Input inV: "); 5752 appendVariableToMessage(message, args.inV); 5753 message.append("\n"); 5754 message.append("Expected output out: "); 5755 appendVariableToMessage(message, args.out); 5756 message.append("\n"); 5757 message.append("Actual output out: "); 5758 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5759 if (args.out != arrayOut[i * 2 + j]) { 5760 message.append(" FAIL"); 5761 } 5762 message.append("\n"); 5763 message.append("Errors at"); 5764 } 5765 message.append(" ["); 5766 message.append(Integer.toString(i)); 5767 message.append(", "); 5768 message.append(Integer.toString(j)); 5769 message.append("]"); 5770 } 5771 } 5772 } 5773 assertFalse("Incorrect output for checkConvertUint2Short2" + 5774 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5775 } 5776 checkConvertUint3Short3()5777 private void checkConvertUint3Short3() { 5778 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x3e4fa8f0l, false, 15); 5779 try { 5780 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5781 script.forEach_testConvertShort3Uint3Short3(inV, out); 5782 verifyResultsConvertUint3Short3(inV, out, false); 5783 } catch (Exception e) { 5784 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString()); 5785 } 5786 try { 5787 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 5788 scriptRelaxed.forEach_testConvertShort3Uint3Short3(inV, out); 5789 verifyResultsConvertUint3Short3(inV, out, true); 5790 } catch (Exception e) { 5791 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString()); 5792 } 5793 } 5794 verifyResultsConvertUint3Short3(Allocation inV, Allocation out, boolean relaxed)5795 private void verifyResultsConvertUint3Short3(Allocation inV, Allocation out, boolean relaxed) { 5796 int[] arrayInV = new int[INPUTSIZE * 4]; 5797 Arrays.fill(arrayInV, (int) 42); 5798 inV.copyTo(arrayInV); 5799 short[] arrayOut = new short[INPUTSIZE * 4]; 5800 Arrays.fill(arrayOut, (short) 42); 5801 out.copyTo(arrayOut); 5802 StringBuilder message = new StringBuilder(); 5803 boolean errorFound = false; 5804 for (int i = 0; i < INPUTSIZE; i++) { 5805 for (int j = 0; j < 3 ; j++) { 5806 // Extract the inputs. 5807 ArgumentsUintShort args = new ArgumentsUintShort(); 5808 args.inV = arrayInV[i * 4 + j]; 5809 // Figure out what the outputs should have been. 5810 CoreMathVerifier.computeConvert(args); 5811 // Validate the outputs. 5812 boolean valid = true; 5813 if (args.out != arrayOut[i * 4 + j]) { 5814 valid = false; 5815 } 5816 if (!valid) { 5817 if (!errorFound) { 5818 errorFound = true; 5819 message.append("Input inV: "); 5820 appendVariableToMessage(message, args.inV); 5821 message.append("\n"); 5822 message.append("Expected output out: "); 5823 appendVariableToMessage(message, args.out); 5824 message.append("\n"); 5825 message.append("Actual output out: "); 5826 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5827 if (args.out != arrayOut[i * 4 + j]) { 5828 message.append(" FAIL"); 5829 } 5830 message.append("\n"); 5831 message.append("Errors at"); 5832 } 5833 message.append(" ["); 5834 message.append(Integer.toString(i)); 5835 message.append(", "); 5836 message.append(Integer.toString(j)); 5837 message.append("]"); 5838 } 5839 } 5840 } 5841 assertFalse("Incorrect output for checkConvertUint3Short3" + 5842 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5843 } 5844 checkConvertUint4Short4()5845 private void checkConvertUint4Short4() { 5846 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x346ac9cel, false, 15); 5847 try { 5848 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5849 script.forEach_testConvertShort4Uint4Short4(inV, out); 5850 verifyResultsConvertUint4Short4(inV, out, false); 5851 } catch (Exception e) { 5852 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString()); 5853 } 5854 try { 5855 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 5856 scriptRelaxed.forEach_testConvertShort4Uint4Short4(inV, out); 5857 verifyResultsConvertUint4Short4(inV, out, true); 5858 } catch (Exception e) { 5859 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString()); 5860 } 5861 } 5862 verifyResultsConvertUint4Short4(Allocation inV, Allocation out, boolean relaxed)5863 private void verifyResultsConvertUint4Short4(Allocation inV, Allocation out, boolean relaxed) { 5864 int[] arrayInV = new int[INPUTSIZE * 4]; 5865 Arrays.fill(arrayInV, (int) 42); 5866 inV.copyTo(arrayInV); 5867 short[] arrayOut = new short[INPUTSIZE * 4]; 5868 Arrays.fill(arrayOut, (short) 42); 5869 out.copyTo(arrayOut); 5870 StringBuilder message = new StringBuilder(); 5871 boolean errorFound = false; 5872 for (int i = 0; i < INPUTSIZE; i++) { 5873 for (int j = 0; j < 4 ; j++) { 5874 // Extract the inputs. 5875 ArgumentsUintShort args = new ArgumentsUintShort(); 5876 args.inV = arrayInV[i * 4 + j]; 5877 // Figure out what the outputs should have been. 5878 CoreMathVerifier.computeConvert(args); 5879 // Validate the outputs. 5880 boolean valid = true; 5881 if (args.out != arrayOut[i * 4 + j]) { 5882 valid = false; 5883 } 5884 if (!valid) { 5885 if (!errorFound) { 5886 errorFound = true; 5887 message.append("Input inV: "); 5888 appendVariableToMessage(message, args.inV); 5889 message.append("\n"); 5890 message.append("Expected output out: "); 5891 appendVariableToMessage(message, args.out); 5892 message.append("\n"); 5893 message.append("Actual output out: "); 5894 appendVariableToMessage(message, arrayOut[i * 4 + j]); 5895 if (args.out != arrayOut[i * 4 + j]) { 5896 message.append(" FAIL"); 5897 } 5898 message.append("\n"); 5899 message.append("Errors at"); 5900 } 5901 message.append(" ["); 5902 message.append(Integer.toString(i)); 5903 message.append(", "); 5904 message.append(Integer.toString(j)); 5905 message.append("]"); 5906 } 5907 } 5908 } 5909 assertFalse("Incorrect output for checkConvertUint4Short4" + 5910 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5911 } 5912 5913 public class ArgumentsFloatUshort { 5914 public float inV; 5915 public short out; 5916 } 5917 checkConvertFloat2Ushort2()5918 private void checkConvertFloat2Ushort2() { 5919 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb708416fl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 5920 try { 5921 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 5922 script.forEach_testConvertUshort2Float2Ushort2(inV, out); 5923 verifyResultsConvertFloat2Ushort2(inV, out, false); 5924 } catch (Exception e) { 5925 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString()); 5926 } 5927 try { 5928 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 5929 scriptRelaxed.forEach_testConvertUshort2Float2Ushort2(inV, out); 5930 verifyResultsConvertFloat2Ushort2(inV, out, true); 5931 } catch (Exception e) { 5932 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString()); 5933 } 5934 } 5935 verifyResultsConvertFloat2Ushort2(Allocation inV, Allocation out, boolean relaxed)5936 private void verifyResultsConvertFloat2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 5937 float[] arrayInV = new float[INPUTSIZE * 2]; 5938 Arrays.fill(arrayInV, (float) 42); 5939 inV.copyTo(arrayInV); 5940 short[] arrayOut = new short[INPUTSIZE * 2]; 5941 Arrays.fill(arrayOut, (short) 42); 5942 out.copyTo(arrayOut); 5943 StringBuilder message = new StringBuilder(); 5944 boolean errorFound = false; 5945 for (int i = 0; i < INPUTSIZE; i++) { 5946 for (int j = 0; j < 2 ; j++) { 5947 // Extract the inputs. 5948 ArgumentsFloatUshort args = new ArgumentsFloatUshort(); 5949 args.inV = arrayInV[i * 2 + j]; 5950 // Figure out what the outputs should have been. 5951 CoreMathVerifier.computeConvert(args); 5952 // Validate the outputs. 5953 boolean valid = true; 5954 if (args.out != arrayOut[i * 2 + j]) { 5955 valid = false; 5956 } 5957 if (!valid) { 5958 if (!errorFound) { 5959 errorFound = true; 5960 message.append("Input inV: "); 5961 appendVariableToMessage(message, args.inV); 5962 message.append("\n"); 5963 message.append("Expected output out: "); 5964 appendVariableToMessage(message, args.out); 5965 message.append("\n"); 5966 message.append("Actual output out: "); 5967 appendVariableToMessage(message, arrayOut[i * 2 + j]); 5968 if (args.out != arrayOut[i * 2 + j]) { 5969 message.append(" FAIL"); 5970 } 5971 message.append("\n"); 5972 message.append("Errors at"); 5973 } 5974 message.append(" ["); 5975 message.append(Integer.toString(i)); 5976 message.append(", "); 5977 message.append(Integer.toString(j)); 5978 message.append("]"); 5979 } 5980 } 5981 } 5982 assertFalse("Incorrect output for checkConvertFloat2Ushort2" + 5983 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 5984 } 5985 checkConvertFloat3Ushort3()5986 private void checkConvertFloat3Ushort3() { 5987 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd63d29bl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 5988 try { 5989 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 5990 script.forEach_testConvertUshort3Float3Ushort3(inV, out); 5991 verifyResultsConvertFloat3Ushort3(inV, out, false); 5992 } catch (Exception e) { 5993 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString()); 5994 } 5995 try { 5996 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 5997 scriptRelaxed.forEach_testConvertUshort3Float3Ushort3(inV, out); 5998 verifyResultsConvertFloat3Ushort3(inV, out, true); 5999 } catch (Exception e) { 6000 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString()); 6001 } 6002 } 6003 verifyResultsConvertFloat3Ushort3(Allocation inV, Allocation out, boolean relaxed)6004 private void verifyResultsConvertFloat3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6005 float[] arrayInV = new float[INPUTSIZE * 4]; 6006 Arrays.fill(arrayInV, (float) 42); 6007 inV.copyTo(arrayInV); 6008 short[] arrayOut = new short[INPUTSIZE * 4]; 6009 Arrays.fill(arrayOut, (short) 42); 6010 out.copyTo(arrayOut); 6011 StringBuilder message = new StringBuilder(); 6012 boolean errorFound = false; 6013 for (int i = 0; i < INPUTSIZE; i++) { 6014 for (int j = 0; j < 3 ; j++) { 6015 // Extract the inputs. 6016 ArgumentsFloatUshort args = new ArgumentsFloatUshort(); 6017 args.inV = arrayInV[i * 4 + j]; 6018 // Figure out what the outputs should have been. 6019 CoreMathVerifier.computeConvert(args); 6020 // Validate the outputs. 6021 boolean valid = true; 6022 if (args.out != arrayOut[i * 4 + j]) { 6023 valid = false; 6024 } 6025 if (!valid) { 6026 if (!errorFound) { 6027 errorFound = true; 6028 message.append("Input inV: "); 6029 appendVariableToMessage(message, args.inV); 6030 message.append("\n"); 6031 message.append("Expected output out: "); 6032 appendVariableToMessage(message, args.out); 6033 message.append("\n"); 6034 message.append("Actual output out: "); 6035 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6036 if (args.out != arrayOut[i * 4 + j]) { 6037 message.append(" FAIL"); 6038 } 6039 message.append("\n"); 6040 message.append("Errors at"); 6041 } 6042 message.append(" ["); 6043 message.append(Integer.toString(i)); 6044 message.append(", "); 6045 message.append(Integer.toString(j)); 6046 message.append("]"); 6047 } 6048 } 6049 } 6050 assertFalse("Incorrect output for checkConvertFloat3Ushort3" + 6051 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6052 } 6053 checkConvertFloat4Ushort4()6054 private void checkConvertFloat4Ushort4() { 6055 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x63bf63c7l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 6056 try { 6057 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6058 script.forEach_testConvertUshort4Float4Ushort4(inV, out); 6059 verifyResultsConvertFloat4Ushort4(inV, out, false); 6060 } catch (Exception e) { 6061 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString()); 6062 } 6063 try { 6064 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6065 scriptRelaxed.forEach_testConvertUshort4Float4Ushort4(inV, out); 6066 verifyResultsConvertFloat4Ushort4(inV, out, true); 6067 } catch (Exception e) { 6068 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString()); 6069 } 6070 } 6071 verifyResultsConvertFloat4Ushort4(Allocation inV, Allocation out, boolean relaxed)6072 private void verifyResultsConvertFloat4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6073 float[] arrayInV = new float[INPUTSIZE * 4]; 6074 Arrays.fill(arrayInV, (float) 42); 6075 inV.copyTo(arrayInV); 6076 short[] arrayOut = new short[INPUTSIZE * 4]; 6077 Arrays.fill(arrayOut, (short) 42); 6078 out.copyTo(arrayOut); 6079 StringBuilder message = new StringBuilder(); 6080 boolean errorFound = false; 6081 for (int i = 0; i < INPUTSIZE; i++) { 6082 for (int j = 0; j < 4 ; j++) { 6083 // Extract the inputs. 6084 ArgumentsFloatUshort args = new ArgumentsFloatUshort(); 6085 args.inV = arrayInV[i * 4 + j]; 6086 // Figure out what the outputs should have been. 6087 CoreMathVerifier.computeConvert(args); 6088 // Validate the outputs. 6089 boolean valid = true; 6090 if (args.out != arrayOut[i * 4 + j]) { 6091 valid = false; 6092 } 6093 if (!valid) { 6094 if (!errorFound) { 6095 errorFound = true; 6096 message.append("Input inV: "); 6097 appendVariableToMessage(message, args.inV); 6098 message.append("\n"); 6099 message.append("Expected output out: "); 6100 appendVariableToMessage(message, args.out); 6101 message.append("\n"); 6102 message.append("Actual output out: "); 6103 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6104 if (args.out != arrayOut[i * 4 + j]) { 6105 message.append(" FAIL"); 6106 } 6107 message.append("\n"); 6108 message.append("Errors at"); 6109 } 6110 message.append(" ["); 6111 message.append(Integer.toString(i)); 6112 message.append(", "); 6113 message.append(Integer.toString(j)); 6114 message.append("]"); 6115 } 6116 } 6117 } 6118 assertFalse("Incorrect output for checkConvertFloat4Ushort4" + 6119 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6120 } 6121 6122 public class ArgumentsCharUshort { 6123 public byte inV; 6124 public short out; 6125 } 6126 checkConvertChar2Ushort2()6127 private void checkConvertChar2Ushort2() { 6128 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8f1eeafl, false, 7); 6129 try { 6130 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6131 script.forEach_testConvertUshort2Char2Ushort2(inV, out); 6132 verifyResultsConvertChar2Ushort2(inV, out, false); 6133 } catch (Exception e) { 6134 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString()); 6135 } 6136 try { 6137 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6138 scriptRelaxed.forEach_testConvertUshort2Char2Ushort2(inV, out); 6139 verifyResultsConvertChar2Ushort2(inV, out, true); 6140 } catch (Exception e) { 6141 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString()); 6142 } 6143 } 6144 verifyResultsConvertChar2Ushort2(Allocation inV, Allocation out, boolean relaxed)6145 private void verifyResultsConvertChar2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6146 byte[] arrayInV = new byte[INPUTSIZE * 2]; 6147 Arrays.fill(arrayInV, (byte) 42); 6148 inV.copyTo(arrayInV); 6149 short[] arrayOut = new short[INPUTSIZE * 2]; 6150 Arrays.fill(arrayOut, (short) 42); 6151 out.copyTo(arrayOut); 6152 StringBuilder message = new StringBuilder(); 6153 boolean errorFound = false; 6154 for (int i = 0; i < INPUTSIZE; i++) { 6155 for (int j = 0; j < 2 ; j++) { 6156 // Extract the inputs. 6157 ArgumentsCharUshort args = new ArgumentsCharUshort(); 6158 args.inV = arrayInV[i * 2 + j]; 6159 // Figure out what the outputs should have been. 6160 CoreMathVerifier.computeConvert(args); 6161 // Validate the outputs. 6162 boolean valid = true; 6163 if (args.out != arrayOut[i * 2 + j]) { 6164 valid = false; 6165 } 6166 if (!valid) { 6167 if (!errorFound) { 6168 errorFound = true; 6169 message.append("Input inV: "); 6170 appendVariableToMessage(message, args.inV); 6171 message.append("\n"); 6172 message.append("Expected output out: "); 6173 appendVariableToMessage(message, args.out); 6174 message.append("\n"); 6175 message.append("Actual output out: "); 6176 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6177 if (args.out != arrayOut[i * 2 + j]) { 6178 message.append(" FAIL"); 6179 } 6180 message.append("\n"); 6181 message.append("Errors at"); 6182 } 6183 message.append(" ["); 6184 message.append(Integer.toString(i)); 6185 message.append(", "); 6186 message.append(Integer.toString(j)); 6187 message.append("]"); 6188 } 6189 } 6190 } 6191 assertFalse("Incorrect output for checkConvertChar2Ushort2" + 6192 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6193 } 6194 checkConvertChar3Ushort3()6195 private void checkConvertChar3Ushort3() { 6196 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x2f4d7fdbl, false, 7); 6197 try { 6198 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6199 script.forEach_testConvertUshort3Char3Ushort3(inV, out); 6200 verifyResultsConvertChar3Ushort3(inV, out, false); 6201 } catch (Exception e) { 6202 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString()); 6203 } 6204 try { 6205 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6206 scriptRelaxed.forEach_testConvertUshort3Char3Ushort3(inV, out); 6207 verifyResultsConvertChar3Ushort3(inV, out, true); 6208 } catch (Exception e) { 6209 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString()); 6210 } 6211 } 6212 verifyResultsConvertChar3Ushort3(Allocation inV, Allocation out, boolean relaxed)6213 private void verifyResultsConvertChar3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6214 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6215 Arrays.fill(arrayInV, (byte) 42); 6216 inV.copyTo(arrayInV); 6217 short[] arrayOut = new short[INPUTSIZE * 4]; 6218 Arrays.fill(arrayOut, (short) 42); 6219 out.copyTo(arrayOut); 6220 StringBuilder message = new StringBuilder(); 6221 boolean errorFound = false; 6222 for (int i = 0; i < INPUTSIZE; i++) { 6223 for (int j = 0; j < 3 ; j++) { 6224 // Extract the inputs. 6225 ArgumentsCharUshort args = new ArgumentsCharUshort(); 6226 args.inV = arrayInV[i * 4 + j]; 6227 // Figure out what the outputs should have been. 6228 CoreMathVerifier.computeConvert(args); 6229 // Validate the outputs. 6230 boolean valid = true; 6231 if (args.out != arrayOut[i * 4 + j]) { 6232 valid = false; 6233 } 6234 if (!valid) { 6235 if (!errorFound) { 6236 errorFound = true; 6237 message.append("Input inV: "); 6238 appendVariableToMessage(message, args.inV); 6239 message.append("\n"); 6240 message.append("Expected output out: "); 6241 appendVariableToMessage(message, args.out); 6242 message.append("\n"); 6243 message.append("Actual output out: "); 6244 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6245 if (args.out != arrayOut[i * 4 + j]) { 6246 message.append(" FAIL"); 6247 } 6248 message.append("\n"); 6249 message.append("Errors at"); 6250 } 6251 message.append(" ["); 6252 message.append(Integer.toString(i)); 6253 message.append(", "); 6254 message.append(Integer.toString(j)); 6255 message.append("]"); 6256 } 6257 } 6258 } 6259 assertFalse("Incorrect output for checkConvertChar3Ushort3" + 6260 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6261 } 6262 checkConvertChar4Ushort4()6263 private void checkConvertChar4Ushort4() { 6264 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x85a91107l, false, 7); 6265 try { 6266 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6267 script.forEach_testConvertUshort4Char4Ushort4(inV, out); 6268 verifyResultsConvertChar4Ushort4(inV, out, false); 6269 } catch (Exception e) { 6270 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString()); 6271 } 6272 try { 6273 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6274 scriptRelaxed.forEach_testConvertUshort4Char4Ushort4(inV, out); 6275 verifyResultsConvertChar4Ushort4(inV, out, true); 6276 } catch (Exception e) { 6277 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString()); 6278 } 6279 } 6280 verifyResultsConvertChar4Ushort4(Allocation inV, Allocation out, boolean relaxed)6281 private void verifyResultsConvertChar4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6282 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6283 Arrays.fill(arrayInV, (byte) 42); 6284 inV.copyTo(arrayInV); 6285 short[] arrayOut = new short[INPUTSIZE * 4]; 6286 Arrays.fill(arrayOut, (short) 42); 6287 out.copyTo(arrayOut); 6288 StringBuilder message = new StringBuilder(); 6289 boolean errorFound = false; 6290 for (int i = 0; i < INPUTSIZE; i++) { 6291 for (int j = 0; j < 4 ; j++) { 6292 // Extract the inputs. 6293 ArgumentsCharUshort args = new ArgumentsCharUshort(); 6294 args.inV = arrayInV[i * 4 + j]; 6295 // Figure out what the outputs should have been. 6296 CoreMathVerifier.computeConvert(args); 6297 // Validate the outputs. 6298 boolean valid = true; 6299 if (args.out != arrayOut[i * 4 + j]) { 6300 valid = false; 6301 } 6302 if (!valid) { 6303 if (!errorFound) { 6304 errorFound = true; 6305 message.append("Input inV: "); 6306 appendVariableToMessage(message, args.inV); 6307 message.append("\n"); 6308 message.append("Expected output out: "); 6309 appendVariableToMessage(message, args.out); 6310 message.append("\n"); 6311 message.append("Actual output out: "); 6312 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6313 if (args.out != arrayOut[i * 4 + j]) { 6314 message.append(" FAIL"); 6315 } 6316 message.append("\n"); 6317 message.append("Errors at"); 6318 } 6319 message.append(" ["); 6320 message.append(Integer.toString(i)); 6321 message.append(", "); 6322 message.append(Integer.toString(j)); 6323 message.append("]"); 6324 } 6325 } 6326 } 6327 assertFalse("Incorrect output for checkConvertChar4Ushort4" + 6328 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6329 } 6330 6331 public class ArgumentsUcharUshort { 6332 public byte inV; 6333 public short out; 6334 } 6335 checkConvertUchar2Ushort2()6336 private void checkConvertUchar2Ushort2() { 6337 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x63e3e68l, false, 8); 6338 try { 6339 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6340 script.forEach_testConvertUshort2Uchar2Ushort2(inV, out); 6341 verifyResultsConvertUchar2Ushort2(inV, out, false); 6342 } catch (Exception e) { 6343 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString()); 6344 } 6345 try { 6346 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6347 scriptRelaxed.forEach_testConvertUshort2Uchar2Ushort2(inV, out); 6348 verifyResultsConvertUchar2Ushort2(inV, out, true); 6349 } catch (Exception e) { 6350 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString()); 6351 } 6352 } 6353 verifyResultsConvertUchar2Ushort2(Allocation inV, Allocation out, boolean relaxed)6354 private void verifyResultsConvertUchar2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6355 byte[] arrayInV = new byte[INPUTSIZE * 2]; 6356 Arrays.fill(arrayInV, (byte) 42); 6357 inV.copyTo(arrayInV); 6358 short[] arrayOut = new short[INPUTSIZE * 2]; 6359 Arrays.fill(arrayOut, (short) 42); 6360 out.copyTo(arrayOut); 6361 StringBuilder message = new StringBuilder(); 6362 boolean errorFound = false; 6363 for (int i = 0; i < INPUTSIZE; i++) { 6364 for (int j = 0; j < 2 ; j++) { 6365 // Extract the inputs. 6366 ArgumentsUcharUshort args = new ArgumentsUcharUshort(); 6367 args.inV = arrayInV[i * 2 + j]; 6368 // Figure out what the outputs should have been. 6369 CoreMathVerifier.computeConvert(args); 6370 // Validate the outputs. 6371 boolean valid = true; 6372 if (args.out != arrayOut[i * 2 + j]) { 6373 valid = false; 6374 } 6375 if (!valid) { 6376 if (!errorFound) { 6377 errorFound = true; 6378 message.append("Input inV: "); 6379 appendVariableToMessage(message, args.inV); 6380 message.append("\n"); 6381 message.append("Expected output out: "); 6382 appendVariableToMessage(message, args.out); 6383 message.append("\n"); 6384 message.append("Actual output out: "); 6385 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6386 if (args.out != arrayOut[i * 2 + j]) { 6387 message.append(" FAIL"); 6388 } 6389 message.append("\n"); 6390 message.append("Errors at"); 6391 } 6392 message.append(" ["); 6393 message.append(Integer.toString(i)); 6394 message.append(", "); 6395 message.append(Integer.toString(j)); 6396 message.append("]"); 6397 } 6398 } 6399 } 6400 assertFalse("Incorrect output for checkConvertUchar2Ushort2" + 6401 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6402 } 6403 checkConvertUchar3Ushort3()6404 private void checkConvertUchar3Ushort3() { 6405 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x5c99cf94l, false, 8); 6406 try { 6407 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6408 script.forEach_testConvertUshort3Uchar3Ushort3(inV, out); 6409 verifyResultsConvertUchar3Ushort3(inV, out, false); 6410 } catch (Exception e) { 6411 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString()); 6412 } 6413 try { 6414 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6415 scriptRelaxed.forEach_testConvertUshort3Uchar3Ushort3(inV, out); 6416 verifyResultsConvertUchar3Ushort3(inV, out, true); 6417 } catch (Exception e) { 6418 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString()); 6419 } 6420 } 6421 verifyResultsConvertUchar3Ushort3(Allocation inV, Allocation out, boolean relaxed)6422 private void verifyResultsConvertUchar3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6423 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6424 Arrays.fill(arrayInV, (byte) 42); 6425 inV.copyTo(arrayInV); 6426 short[] arrayOut = new short[INPUTSIZE * 4]; 6427 Arrays.fill(arrayOut, (short) 42); 6428 out.copyTo(arrayOut); 6429 StringBuilder message = new StringBuilder(); 6430 boolean errorFound = false; 6431 for (int i = 0; i < INPUTSIZE; i++) { 6432 for (int j = 0; j < 3 ; j++) { 6433 // Extract the inputs. 6434 ArgumentsUcharUshort args = new ArgumentsUcharUshort(); 6435 args.inV = arrayInV[i * 4 + j]; 6436 // Figure out what the outputs should have been. 6437 CoreMathVerifier.computeConvert(args); 6438 // Validate the outputs. 6439 boolean valid = true; 6440 if (args.out != arrayOut[i * 4 + j]) { 6441 valid = false; 6442 } 6443 if (!valid) { 6444 if (!errorFound) { 6445 errorFound = true; 6446 message.append("Input inV: "); 6447 appendVariableToMessage(message, args.inV); 6448 message.append("\n"); 6449 message.append("Expected output out: "); 6450 appendVariableToMessage(message, args.out); 6451 message.append("\n"); 6452 message.append("Actual output out: "); 6453 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6454 if (args.out != arrayOut[i * 4 + j]) { 6455 message.append(" FAIL"); 6456 } 6457 message.append("\n"); 6458 message.append("Errors at"); 6459 } 6460 message.append(" ["); 6461 message.append(Integer.toString(i)); 6462 message.append(", "); 6463 message.append(Integer.toString(j)); 6464 message.append("]"); 6465 } 6466 } 6467 } 6468 assertFalse("Incorrect output for checkConvertUchar3Ushort3" + 6469 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6470 } 6471 checkConvertUchar4Ushort4()6472 private void checkConvertUchar4Ushort4() { 6473 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xb2f560c0l, false, 8); 6474 try { 6475 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6476 script.forEach_testConvertUshort4Uchar4Ushort4(inV, out); 6477 verifyResultsConvertUchar4Ushort4(inV, out, false); 6478 } catch (Exception e) { 6479 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString()); 6480 } 6481 try { 6482 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6483 scriptRelaxed.forEach_testConvertUshort4Uchar4Ushort4(inV, out); 6484 verifyResultsConvertUchar4Ushort4(inV, out, true); 6485 } catch (Exception e) { 6486 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString()); 6487 } 6488 } 6489 verifyResultsConvertUchar4Ushort4(Allocation inV, Allocation out, boolean relaxed)6490 private void verifyResultsConvertUchar4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6491 byte[] arrayInV = new byte[INPUTSIZE * 4]; 6492 Arrays.fill(arrayInV, (byte) 42); 6493 inV.copyTo(arrayInV); 6494 short[] arrayOut = new short[INPUTSIZE * 4]; 6495 Arrays.fill(arrayOut, (short) 42); 6496 out.copyTo(arrayOut); 6497 StringBuilder message = new StringBuilder(); 6498 boolean errorFound = false; 6499 for (int i = 0; i < INPUTSIZE; i++) { 6500 for (int j = 0; j < 4 ; j++) { 6501 // Extract the inputs. 6502 ArgumentsUcharUshort args = new ArgumentsUcharUshort(); 6503 args.inV = arrayInV[i * 4 + j]; 6504 // Figure out what the outputs should have been. 6505 CoreMathVerifier.computeConvert(args); 6506 // Validate the outputs. 6507 boolean valid = true; 6508 if (args.out != arrayOut[i * 4 + j]) { 6509 valid = false; 6510 } 6511 if (!valid) { 6512 if (!errorFound) { 6513 errorFound = true; 6514 message.append("Input inV: "); 6515 appendVariableToMessage(message, args.inV); 6516 message.append("\n"); 6517 message.append("Expected output out: "); 6518 appendVariableToMessage(message, args.out); 6519 message.append("\n"); 6520 message.append("Actual output out: "); 6521 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6522 if (args.out != arrayOut[i * 4 + j]) { 6523 message.append(" FAIL"); 6524 } 6525 message.append("\n"); 6526 message.append("Errors at"); 6527 } 6528 message.append(" ["); 6529 message.append(Integer.toString(i)); 6530 message.append(", "); 6531 message.append(Integer.toString(j)); 6532 message.append("]"); 6533 } 6534 } 6535 } 6536 assertFalse("Incorrect output for checkConvertUchar4Ushort4" + 6537 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6538 } 6539 6540 public class ArgumentsShortUshort { 6541 public short inV; 6542 public short out; 6543 } 6544 checkConvertShort2Ushort2()6545 private void checkConvertShort2Ushort2() { 6546 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7264c053l, false, 15); 6547 try { 6548 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6549 script.forEach_testConvertUshort2Short2Ushort2(inV, out); 6550 verifyResultsConvertShort2Ushort2(inV, out, false); 6551 } catch (Exception e) { 6552 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString()); 6553 } 6554 try { 6555 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6556 scriptRelaxed.forEach_testConvertUshort2Short2Ushort2(inV, out); 6557 verifyResultsConvertShort2Ushort2(inV, out, true); 6558 } catch (Exception e) { 6559 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString()); 6560 } 6561 } 6562 verifyResultsConvertShort2Ushort2(Allocation inV, Allocation out, boolean relaxed)6563 private void verifyResultsConvertShort2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6564 short[] arrayInV = new short[INPUTSIZE * 2]; 6565 Arrays.fill(arrayInV, (short) 42); 6566 inV.copyTo(arrayInV); 6567 short[] arrayOut = new short[INPUTSIZE * 2]; 6568 Arrays.fill(arrayOut, (short) 42); 6569 out.copyTo(arrayOut); 6570 StringBuilder message = new StringBuilder(); 6571 boolean errorFound = false; 6572 for (int i = 0; i < INPUTSIZE; i++) { 6573 for (int j = 0; j < 2 ; j++) { 6574 // Extract the inputs. 6575 ArgumentsShortUshort args = new ArgumentsShortUshort(); 6576 args.inV = arrayInV[i * 2 + j]; 6577 // Figure out what the outputs should have been. 6578 CoreMathVerifier.computeConvert(args); 6579 // Validate the outputs. 6580 boolean valid = true; 6581 if (args.out != arrayOut[i * 2 + j]) { 6582 valid = false; 6583 } 6584 if (!valid) { 6585 if (!errorFound) { 6586 errorFound = true; 6587 message.append("Input inV: "); 6588 appendVariableToMessage(message, args.inV); 6589 message.append("\n"); 6590 message.append("Expected output out: "); 6591 appendVariableToMessage(message, args.out); 6592 message.append("\n"); 6593 message.append("Actual output out: "); 6594 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6595 if (args.out != arrayOut[i * 2 + j]) { 6596 message.append(" FAIL"); 6597 } 6598 message.append("\n"); 6599 message.append("Errors at"); 6600 } 6601 message.append(" ["); 6602 message.append(Integer.toString(i)); 6603 message.append(", "); 6604 message.append(Integer.toString(j)); 6605 message.append("]"); 6606 } 6607 } 6608 } 6609 assertFalse("Incorrect output for checkConvertShort2Ushort2" + 6610 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6611 } 6612 checkConvertShort3Ushort3()6613 private void checkConvertShort3Ushort3() { 6614 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xc8c0517fl, false, 15); 6615 try { 6616 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6617 script.forEach_testConvertUshort3Short3Ushort3(inV, out); 6618 verifyResultsConvertShort3Ushort3(inV, out, false); 6619 } catch (Exception e) { 6620 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString()); 6621 } 6622 try { 6623 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6624 scriptRelaxed.forEach_testConvertUshort3Short3Ushort3(inV, out); 6625 verifyResultsConvertShort3Ushort3(inV, out, true); 6626 } catch (Exception e) { 6627 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString()); 6628 } 6629 } 6630 verifyResultsConvertShort3Ushort3(Allocation inV, Allocation out, boolean relaxed)6631 private void verifyResultsConvertShort3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6632 short[] arrayInV = new short[INPUTSIZE * 4]; 6633 Arrays.fill(arrayInV, (short) 42); 6634 inV.copyTo(arrayInV); 6635 short[] arrayOut = new short[INPUTSIZE * 4]; 6636 Arrays.fill(arrayOut, (short) 42); 6637 out.copyTo(arrayOut); 6638 StringBuilder message = new StringBuilder(); 6639 boolean errorFound = false; 6640 for (int i = 0; i < INPUTSIZE; i++) { 6641 for (int j = 0; j < 3 ; j++) { 6642 // Extract the inputs. 6643 ArgumentsShortUshort args = new ArgumentsShortUshort(); 6644 args.inV = arrayInV[i * 4 + j]; 6645 // Figure out what the outputs should have been. 6646 CoreMathVerifier.computeConvert(args); 6647 // Validate the outputs. 6648 boolean valid = true; 6649 if (args.out != arrayOut[i * 4 + j]) { 6650 valid = false; 6651 } 6652 if (!valid) { 6653 if (!errorFound) { 6654 errorFound = true; 6655 message.append("Input inV: "); 6656 appendVariableToMessage(message, args.inV); 6657 message.append("\n"); 6658 message.append("Expected output out: "); 6659 appendVariableToMessage(message, args.out); 6660 message.append("\n"); 6661 message.append("Actual output out: "); 6662 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6663 if (args.out != arrayOut[i * 4 + j]) { 6664 message.append(" FAIL"); 6665 } 6666 message.append("\n"); 6667 message.append("Errors at"); 6668 } 6669 message.append(" ["); 6670 message.append(Integer.toString(i)); 6671 message.append(", "); 6672 message.append(Integer.toString(j)); 6673 message.append("]"); 6674 } 6675 } 6676 } 6677 assertFalse("Incorrect output for checkConvertShort3Ushort3" + 6678 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6679 } 6680 checkConvertShort4Ushort4()6681 private void checkConvertShort4Ushort4() { 6682 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x1f1be2abl, false, 15); 6683 try { 6684 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6685 script.forEach_testConvertUshort4Short4Ushort4(inV, out); 6686 verifyResultsConvertShort4Ushort4(inV, out, false); 6687 } catch (Exception e) { 6688 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString()); 6689 } 6690 try { 6691 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6692 scriptRelaxed.forEach_testConvertUshort4Short4Ushort4(inV, out); 6693 verifyResultsConvertShort4Ushort4(inV, out, true); 6694 } catch (Exception e) { 6695 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString()); 6696 } 6697 } 6698 verifyResultsConvertShort4Ushort4(Allocation inV, Allocation out, boolean relaxed)6699 private void verifyResultsConvertShort4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6700 short[] arrayInV = new short[INPUTSIZE * 4]; 6701 Arrays.fill(arrayInV, (short) 42); 6702 inV.copyTo(arrayInV); 6703 short[] arrayOut = new short[INPUTSIZE * 4]; 6704 Arrays.fill(arrayOut, (short) 42); 6705 out.copyTo(arrayOut); 6706 StringBuilder message = new StringBuilder(); 6707 boolean errorFound = false; 6708 for (int i = 0; i < INPUTSIZE; i++) { 6709 for (int j = 0; j < 4 ; j++) { 6710 // Extract the inputs. 6711 ArgumentsShortUshort args = new ArgumentsShortUshort(); 6712 args.inV = arrayInV[i * 4 + j]; 6713 // Figure out what the outputs should have been. 6714 CoreMathVerifier.computeConvert(args); 6715 // Validate the outputs. 6716 boolean valid = true; 6717 if (args.out != arrayOut[i * 4 + j]) { 6718 valid = false; 6719 } 6720 if (!valid) { 6721 if (!errorFound) { 6722 errorFound = true; 6723 message.append("Input inV: "); 6724 appendVariableToMessage(message, args.inV); 6725 message.append("\n"); 6726 message.append("Expected output out: "); 6727 appendVariableToMessage(message, args.out); 6728 message.append("\n"); 6729 message.append("Actual output out: "); 6730 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6731 if (args.out != arrayOut[i * 4 + j]) { 6732 message.append(" FAIL"); 6733 } 6734 message.append("\n"); 6735 message.append("Errors at"); 6736 } 6737 message.append(" ["); 6738 message.append(Integer.toString(i)); 6739 message.append(", "); 6740 message.append(Integer.toString(j)); 6741 message.append("]"); 6742 } 6743 } 6744 } 6745 assertFalse("Incorrect output for checkConvertShort4Ushort4" + 6746 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6747 } 6748 6749 public class ArgumentsUshortUshort { 6750 public short inV; 6751 public short out; 6752 } 6753 checkConvertUshort2Ushort2()6754 private void checkConvertUshort2Ushort2() { 6755 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xe362466l, false, 16); 6756 try { 6757 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6758 script.forEach_testConvertUshort2Ushort2Ushort2(inV, out); 6759 verifyResultsConvertUshort2Ushort2(inV, out, false); 6760 } catch (Exception e) { 6761 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString()); 6762 } 6763 try { 6764 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6765 scriptRelaxed.forEach_testConvertUshort2Ushort2Ushort2(inV, out); 6766 verifyResultsConvertUshort2Ushort2(inV, out, true); 6767 } catch (Exception e) { 6768 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString()); 6769 } 6770 } 6771 verifyResultsConvertUshort2Ushort2(Allocation inV, Allocation out, boolean relaxed)6772 private void verifyResultsConvertUshort2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6773 short[] arrayInV = new short[INPUTSIZE * 2]; 6774 Arrays.fill(arrayInV, (short) 42); 6775 inV.copyTo(arrayInV); 6776 short[] arrayOut = new short[INPUTSIZE * 2]; 6777 Arrays.fill(arrayOut, (short) 42); 6778 out.copyTo(arrayOut); 6779 StringBuilder message = new StringBuilder(); 6780 boolean errorFound = false; 6781 for (int i = 0; i < INPUTSIZE; i++) { 6782 for (int j = 0; j < 2 ; j++) { 6783 // Extract the inputs. 6784 ArgumentsUshortUshort args = new ArgumentsUshortUshort(); 6785 args.inV = arrayInV[i * 2 + j]; 6786 // Figure out what the outputs should have been. 6787 CoreMathVerifier.computeConvert(args); 6788 // Validate the outputs. 6789 boolean valid = true; 6790 if (args.out != arrayOut[i * 2 + j]) { 6791 valid = false; 6792 } 6793 if (!valid) { 6794 if (!errorFound) { 6795 errorFound = true; 6796 message.append("Input inV: "); 6797 appendVariableToMessage(message, args.inV); 6798 message.append("\n"); 6799 message.append("Expected output out: "); 6800 appendVariableToMessage(message, args.out); 6801 message.append("\n"); 6802 message.append("Actual output out: "); 6803 appendVariableToMessage(message, arrayOut[i * 2 + j]); 6804 if (args.out != arrayOut[i * 2 + j]) { 6805 message.append(" FAIL"); 6806 } 6807 message.append("\n"); 6808 message.append("Errors at"); 6809 } 6810 message.append(" ["); 6811 message.append(Integer.toString(i)); 6812 message.append(", "); 6813 message.append(Integer.toString(j)); 6814 message.append("]"); 6815 } 6816 } 6817 } 6818 assertFalse("Incorrect output for checkConvertUshort2Ushort2" + 6819 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6820 } 6821 checkConvertUshort3Ushort3()6822 private void checkConvertUshort3Ushort3() { 6823 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6491b592l, false, 16); 6824 try { 6825 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6826 script.forEach_testConvertUshort3Ushort3Ushort3(inV, out); 6827 verifyResultsConvertUshort3Ushort3(inV, out, false); 6828 } catch (Exception e) { 6829 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString()); 6830 } 6831 try { 6832 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 6833 scriptRelaxed.forEach_testConvertUshort3Ushort3Ushort3(inV, out); 6834 verifyResultsConvertUshort3Ushort3(inV, out, true); 6835 } catch (Exception e) { 6836 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString()); 6837 } 6838 } 6839 verifyResultsConvertUshort3Ushort3(Allocation inV, Allocation out, boolean relaxed)6840 private void verifyResultsConvertUshort3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 6841 short[] arrayInV = new short[INPUTSIZE * 4]; 6842 Arrays.fill(arrayInV, (short) 42); 6843 inV.copyTo(arrayInV); 6844 short[] arrayOut = new short[INPUTSIZE * 4]; 6845 Arrays.fill(arrayOut, (short) 42); 6846 out.copyTo(arrayOut); 6847 StringBuilder message = new StringBuilder(); 6848 boolean errorFound = false; 6849 for (int i = 0; i < INPUTSIZE; i++) { 6850 for (int j = 0; j < 3 ; j++) { 6851 // Extract the inputs. 6852 ArgumentsUshortUshort args = new ArgumentsUshortUshort(); 6853 args.inV = arrayInV[i * 4 + j]; 6854 // Figure out what the outputs should have been. 6855 CoreMathVerifier.computeConvert(args); 6856 // Validate the outputs. 6857 boolean valid = true; 6858 if (args.out != arrayOut[i * 4 + j]) { 6859 valid = false; 6860 } 6861 if (!valid) { 6862 if (!errorFound) { 6863 errorFound = true; 6864 message.append("Input inV: "); 6865 appendVariableToMessage(message, args.inV); 6866 message.append("\n"); 6867 message.append("Expected output out: "); 6868 appendVariableToMessage(message, args.out); 6869 message.append("\n"); 6870 message.append("Actual output out: "); 6871 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6872 if (args.out != arrayOut[i * 4 + j]) { 6873 message.append(" FAIL"); 6874 } 6875 message.append("\n"); 6876 message.append("Errors at"); 6877 } 6878 message.append(" ["); 6879 message.append(Integer.toString(i)); 6880 message.append(", "); 6881 message.append(Integer.toString(j)); 6882 message.append("]"); 6883 } 6884 } 6885 } 6886 assertFalse("Incorrect output for checkConvertUshort3Ushort3" + 6887 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6888 } 6889 checkConvertUshort4Ushort4()6890 private void checkConvertUshort4Ushort4() { 6891 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xbaed46bel, false, 16); 6892 try { 6893 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6894 script.forEach_testConvertUshort4Ushort4Ushort4(inV, out); 6895 verifyResultsConvertUshort4Ushort4(inV, out, false); 6896 } catch (Exception e) { 6897 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString()); 6898 } 6899 try { 6900 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 6901 scriptRelaxed.forEach_testConvertUshort4Ushort4Ushort4(inV, out); 6902 verifyResultsConvertUshort4Ushort4(inV, out, true); 6903 } catch (Exception e) { 6904 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString()); 6905 } 6906 } 6907 verifyResultsConvertUshort4Ushort4(Allocation inV, Allocation out, boolean relaxed)6908 private void verifyResultsConvertUshort4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 6909 short[] arrayInV = new short[INPUTSIZE * 4]; 6910 Arrays.fill(arrayInV, (short) 42); 6911 inV.copyTo(arrayInV); 6912 short[] arrayOut = new short[INPUTSIZE * 4]; 6913 Arrays.fill(arrayOut, (short) 42); 6914 out.copyTo(arrayOut); 6915 StringBuilder message = new StringBuilder(); 6916 boolean errorFound = false; 6917 for (int i = 0; i < INPUTSIZE; i++) { 6918 for (int j = 0; j < 4 ; j++) { 6919 // Extract the inputs. 6920 ArgumentsUshortUshort args = new ArgumentsUshortUshort(); 6921 args.inV = arrayInV[i * 4 + j]; 6922 // Figure out what the outputs should have been. 6923 CoreMathVerifier.computeConvert(args); 6924 // Validate the outputs. 6925 boolean valid = true; 6926 if (args.out != arrayOut[i * 4 + j]) { 6927 valid = false; 6928 } 6929 if (!valid) { 6930 if (!errorFound) { 6931 errorFound = true; 6932 message.append("Input inV: "); 6933 appendVariableToMessage(message, args.inV); 6934 message.append("\n"); 6935 message.append("Expected output out: "); 6936 appendVariableToMessage(message, args.out); 6937 message.append("\n"); 6938 message.append("Actual output out: "); 6939 appendVariableToMessage(message, arrayOut[i * 4 + j]); 6940 if (args.out != arrayOut[i * 4 + j]) { 6941 message.append(" FAIL"); 6942 } 6943 message.append("\n"); 6944 message.append("Errors at"); 6945 } 6946 message.append(" ["); 6947 message.append(Integer.toString(i)); 6948 message.append(", "); 6949 message.append(Integer.toString(j)); 6950 message.append("]"); 6951 } 6952 } 6953 } 6954 assertFalse("Incorrect output for checkConvertUshort4Ushort4" + 6955 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 6956 } 6957 6958 public class ArgumentsIntUshort { 6959 public int inV; 6960 public short out; 6961 } 6962 checkConvertInt2Ushort2()6963 private void checkConvertInt2Ushort2() { 6964 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x14378844l, false, 16); 6965 try { 6966 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6967 script.forEach_testConvertUshort2Int2Ushort2(inV, out); 6968 verifyResultsConvertInt2Ushort2(inV, out, false); 6969 } catch (Exception e) { 6970 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString()); 6971 } 6972 try { 6973 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 6974 scriptRelaxed.forEach_testConvertUshort2Int2Ushort2(inV, out); 6975 verifyResultsConvertInt2Ushort2(inV, out, true); 6976 } catch (Exception e) { 6977 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString()); 6978 } 6979 } 6980 verifyResultsConvertInt2Ushort2(Allocation inV, Allocation out, boolean relaxed)6981 private void verifyResultsConvertInt2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 6982 int[] arrayInV = new int[INPUTSIZE * 2]; 6983 Arrays.fill(arrayInV, (int) 42); 6984 inV.copyTo(arrayInV); 6985 short[] arrayOut = new short[INPUTSIZE * 2]; 6986 Arrays.fill(arrayOut, (short) 42); 6987 out.copyTo(arrayOut); 6988 StringBuilder message = new StringBuilder(); 6989 boolean errorFound = false; 6990 for (int i = 0; i < INPUTSIZE; i++) { 6991 for (int j = 0; j < 2 ; j++) { 6992 // Extract the inputs. 6993 ArgumentsIntUshort args = new ArgumentsIntUshort(); 6994 args.inV = arrayInV[i * 2 + j]; 6995 // Figure out what the outputs should have been. 6996 CoreMathVerifier.computeConvert(args); 6997 // Validate the outputs. 6998 boolean valid = true; 6999 if (args.out != arrayOut[i * 2 + j]) { 7000 valid = false; 7001 } 7002 if (!valid) { 7003 if (!errorFound) { 7004 errorFound = true; 7005 message.append("Input inV: "); 7006 appendVariableToMessage(message, args.inV); 7007 message.append("\n"); 7008 message.append("Expected output out: "); 7009 appendVariableToMessage(message, args.out); 7010 message.append("\n"); 7011 message.append("Actual output out: "); 7012 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7013 if (args.out != arrayOut[i * 2 + j]) { 7014 message.append(" FAIL"); 7015 } 7016 message.append("\n"); 7017 message.append("Errors at"); 7018 } 7019 message.append(" ["); 7020 message.append(Integer.toString(i)); 7021 message.append(", "); 7022 message.append(Integer.toString(j)); 7023 message.append("]"); 7024 } 7025 } 7026 } 7027 assertFalse("Incorrect output for checkConvertInt2Ushort2" + 7028 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7029 } 7030 checkConvertInt3Ushort3()7031 private void checkConvertInt3Ushort3() { 7032 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6a931970l, false, 16); 7033 try { 7034 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7035 script.forEach_testConvertUshort3Int3Ushort3(inV, out); 7036 verifyResultsConvertInt3Ushort3(inV, out, false); 7037 } catch (Exception e) { 7038 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString()); 7039 } 7040 try { 7041 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7042 scriptRelaxed.forEach_testConvertUshort3Int3Ushort3(inV, out); 7043 verifyResultsConvertInt3Ushort3(inV, out, true); 7044 } catch (Exception e) { 7045 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString()); 7046 } 7047 } 7048 verifyResultsConvertInt3Ushort3(Allocation inV, Allocation out, boolean relaxed)7049 private void verifyResultsConvertInt3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 7050 int[] arrayInV = new int[INPUTSIZE * 4]; 7051 Arrays.fill(arrayInV, (int) 42); 7052 inV.copyTo(arrayInV); 7053 short[] arrayOut = new short[INPUTSIZE * 4]; 7054 Arrays.fill(arrayOut, (short) 42); 7055 out.copyTo(arrayOut); 7056 StringBuilder message = new StringBuilder(); 7057 boolean errorFound = false; 7058 for (int i = 0; i < INPUTSIZE; i++) { 7059 for (int j = 0; j < 3 ; j++) { 7060 // Extract the inputs. 7061 ArgumentsIntUshort args = new ArgumentsIntUshort(); 7062 args.inV = arrayInV[i * 4 + j]; 7063 // Figure out what the outputs should have been. 7064 CoreMathVerifier.computeConvert(args); 7065 // Validate the outputs. 7066 boolean valid = true; 7067 if (args.out != arrayOut[i * 4 + j]) { 7068 valid = false; 7069 } 7070 if (!valid) { 7071 if (!errorFound) { 7072 errorFound = true; 7073 message.append("Input inV: "); 7074 appendVariableToMessage(message, args.inV); 7075 message.append("\n"); 7076 message.append("Expected output out: "); 7077 appendVariableToMessage(message, args.out); 7078 message.append("\n"); 7079 message.append("Actual output out: "); 7080 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7081 if (args.out != arrayOut[i * 4 + j]) { 7082 message.append(" FAIL"); 7083 } 7084 message.append("\n"); 7085 message.append("Errors at"); 7086 } 7087 message.append(" ["); 7088 message.append(Integer.toString(i)); 7089 message.append(", "); 7090 message.append(Integer.toString(j)); 7091 message.append("]"); 7092 } 7093 } 7094 } 7095 assertFalse("Incorrect output for checkConvertInt3Ushort3" + 7096 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7097 } 7098 checkConvertInt4Ushort4()7099 private void checkConvertInt4Ushort4() { 7100 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xc0eeaa9cl, false, 16); 7101 try { 7102 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7103 script.forEach_testConvertUshort4Int4Ushort4(inV, out); 7104 verifyResultsConvertInt4Ushort4(inV, out, false); 7105 } catch (Exception e) { 7106 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString()); 7107 } 7108 try { 7109 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7110 scriptRelaxed.forEach_testConvertUshort4Int4Ushort4(inV, out); 7111 verifyResultsConvertInt4Ushort4(inV, out, true); 7112 } catch (Exception e) { 7113 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString()); 7114 } 7115 } 7116 verifyResultsConvertInt4Ushort4(Allocation inV, Allocation out, boolean relaxed)7117 private void verifyResultsConvertInt4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 7118 int[] arrayInV = new int[INPUTSIZE * 4]; 7119 Arrays.fill(arrayInV, (int) 42); 7120 inV.copyTo(arrayInV); 7121 short[] arrayOut = new short[INPUTSIZE * 4]; 7122 Arrays.fill(arrayOut, (short) 42); 7123 out.copyTo(arrayOut); 7124 StringBuilder message = new StringBuilder(); 7125 boolean errorFound = false; 7126 for (int i = 0; i < INPUTSIZE; i++) { 7127 for (int j = 0; j < 4 ; j++) { 7128 // Extract the inputs. 7129 ArgumentsIntUshort args = new ArgumentsIntUshort(); 7130 args.inV = arrayInV[i * 4 + j]; 7131 // Figure out what the outputs should have been. 7132 CoreMathVerifier.computeConvert(args); 7133 // Validate the outputs. 7134 boolean valid = true; 7135 if (args.out != arrayOut[i * 4 + j]) { 7136 valid = false; 7137 } 7138 if (!valid) { 7139 if (!errorFound) { 7140 errorFound = true; 7141 message.append("Input inV: "); 7142 appendVariableToMessage(message, args.inV); 7143 message.append("\n"); 7144 message.append("Expected output out: "); 7145 appendVariableToMessage(message, args.out); 7146 message.append("\n"); 7147 message.append("Actual output out: "); 7148 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7149 if (args.out != arrayOut[i * 4 + j]) { 7150 message.append(" FAIL"); 7151 } 7152 message.append("\n"); 7153 message.append("Errors at"); 7154 } 7155 message.append(" ["); 7156 message.append(Integer.toString(i)); 7157 message.append(", "); 7158 message.append(Integer.toString(j)); 7159 message.append("]"); 7160 } 7161 } 7162 } 7163 assertFalse("Incorrect output for checkConvertInt4Ushort4" + 7164 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7165 } 7166 7167 public class ArgumentsUintUshort { 7168 public int inV; 7169 public short out; 7170 } 7171 checkConvertUint2Ushort2()7172 private void checkConvertUint2Ushort2() { 7173 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb00fa1efl, false, 16); 7174 try { 7175 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7176 script.forEach_testConvertUshort2Uint2Ushort2(inV, out); 7177 verifyResultsConvertUint2Ushort2(inV, out, false); 7178 } catch (Exception e) { 7179 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString()); 7180 } 7181 try { 7182 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 7183 scriptRelaxed.forEach_testConvertUshort2Uint2Ushort2(inV, out); 7184 verifyResultsConvertUint2Ushort2(inV, out, true); 7185 } catch (Exception e) { 7186 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString()); 7187 } 7188 } 7189 verifyResultsConvertUint2Ushort2(Allocation inV, Allocation out, boolean relaxed)7190 private void verifyResultsConvertUint2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 7191 int[] arrayInV = new int[INPUTSIZE * 2]; 7192 Arrays.fill(arrayInV, (int) 42); 7193 inV.copyTo(arrayInV); 7194 short[] arrayOut = new short[INPUTSIZE * 2]; 7195 Arrays.fill(arrayOut, (short) 42); 7196 out.copyTo(arrayOut); 7197 StringBuilder message = new StringBuilder(); 7198 boolean errorFound = false; 7199 for (int i = 0; i < INPUTSIZE; i++) { 7200 for (int j = 0; j < 2 ; j++) { 7201 // Extract the inputs. 7202 ArgumentsUintUshort args = new ArgumentsUintUshort(); 7203 args.inV = arrayInV[i * 2 + j]; 7204 // Figure out what the outputs should have been. 7205 CoreMathVerifier.computeConvert(args); 7206 // Validate the outputs. 7207 boolean valid = true; 7208 if (args.out != arrayOut[i * 2 + j]) { 7209 valid = false; 7210 } 7211 if (!valid) { 7212 if (!errorFound) { 7213 errorFound = true; 7214 message.append("Input inV: "); 7215 appendVariableToMessage(message, args.inV); 7216 message.append("\n"); 7217 message.append("Expected output out: "); 7218 appendVariableToMessage(message, args.out); 7219 message.append("\n"); 7220 message.append("Actual output out: "); 7221 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7222 if (args.out != arrayOut[i * 2 + j]) { 7223 message.append(" FAIL"); 7224 } 7225 message.append("\n"); 7226 message.append("Errors at"); 7227 } 7228 message.append(" ["); 7229 message.append(Integer.toString(i)); 7230 message.append(", "); 7231 message.append(Integer.toString(j)); 7232 message.append("]"); 7233 } 7234 } 7235 } 7236 assertFalse("Incorrect output for checkConvertUint2Ushort2" + 7237 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7238 } 7239 checkConvertUint3Ushort3()7240 private void checkConvertUint3Ushort3() { 7241 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x66b331bl, false, 16); 7242 try { 7243 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7244 script.forEach_testConvertUshort3Uint3Ushort3(inV, out); 7245 verifyResultsConvertUint3Ushort3(inV, out, false); 7246 } catch (Exception e) { 7247 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString()); 7248 } 7249 try { 7250 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 7251 scriptRelaxed.forEach_testConvertUshort3Uint3Ushort3(inV, out); 7252 verifyResultsConvertUint3Ushort3(inV, out, true); 7253 } catch (Exception e) { 7254 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString()); 7255 } 7256 } 7257 verifyResultsConvertUint3Ushort3(Allocation inV, Allocation out, boolean relaxed)7258 private void verifyResultsConvertUint3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 7259 int[] arrayInV = new int[INPUTSIZE * 4]; 7260 Arrays.fill(arrayInV, (int) 42); 7261 inV.copyTo(arrayInV); 7262 short[] arrayOut = new short[INPUTSIZE * 4]; 7263 Arrays.fill(arrayOut, (short) 42); 7264 out.copyTo(arrayOut); 7265 StringBuilder message = new StringBuilder(); 7266 boolean errorFound = false; 7267 for (int i = 0; i < INPUTSIZE; i++) { 7268 for (int j = 0; j < 3 ; j++) { 7269 // Extract the inputs. 7270 ArgumentsUintUshort args = new ArgumentsUintUshort(); 7271 args.inV = arrayInV[i * 4 + j]; 7272 // Figure out what the outputs should have been. 7273 CoreMathVerifier.computeConvert(args); 7274 // Validate the outputs. 7275 boolean valid = true; 7276 if (args.out != arrayOut[i * 4 + j]) { 7277 valid = false; 7278 } 7279 if (!valid) { 7280 if (!errorFound) { 7281 errorFound = true; 7282 message.append("Input inV: "); 7283 appendVariableToMessage(message, args.inV); 7284 message.append("\n"); 7285 message.append("Expected output out: "); 7286 appendVariableToMessage(message, args.out); 7287 message.append("\n"); 7288 message.append("Actual output out: "); 7289 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7290 if (args.out != arrayOut[i * 4 + j]) { 7291 message.append(" FAIL"); 7292 } 7293 message.append("\n"); 7294 message.append("Errors at"); 7295 } 7296 message.append(" ["); 7297 message.append(Integer.toString(i)); 7298 message.append(", "); 7299 message.append(Integer.toString(j)); 7300 message.append("]"); 7301 } 7302 } 7303 } 7304 assertFalse("Incorrect output for checkConvertUint3Ushort3" + 7305 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7306 } 7307 checkConvertUint4Ushort4()7308 private void checkConvertUint4Ushort4() { 7309 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x5cc6c447l, false, 16); 7310 try { 7311 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7312 script.forEach_testConvertUshort4Uint4Ushort4(inV, out); 7313 verifyResultsConvertUint4Ushort4(inV, out, false); 7314 } catch (Exception e) { 7315 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString()); 7316 } 7317 try { 7318 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 7319 scriptRelaxed.forEach_testConvertUshort4Uint4Ushort4(inV, out); 7320 verifyResultsConvertUint4Ushort4(inV, out, true); 7321 } catch (Exception e) { 7322 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString()); 7323 } 7324 } 7325 verifyResultsConvertUint4Ushort4(Allocation inV, Allocation out, boolean relaxed)7326 private void verifyResultsConvertUint4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 7327 int[] arrayInV = new int[INPUTSIZE * 4]; 7328 Arrays.fill(arrayInV, (int) 42); 7329 inV.copyTo(arrayInV); 7330 short[] arrayOut = new short[INPUTSIZE * 4]; 7331 Arrays.fill(arrayOut, (short) 42); 7332 out.copyTo(arrayOut); 7333 StringBuilder message = new StringBuilder(); 7334 boolean errorFound = false; 7335 for (int i = 0; i < INPUTSIZE; i++) { 7336 for (int j = 0; j < 4 ; j++) { 7337 // Extract the inputs. 7338 ArgumentsUintUshort args = new ArgumentsUintUshort(); 7339 args.inV = arrayInV[i * 4 + j]; 7340 // Figure out what the outputs should have been. 7341 CoreMathVerifier.computeConvert(args); 7342 // Validate the outputs. 7343 boolean valid = true; 7344 if (args.out != arrayOut[i * 4 + j]) { 7345 valid = false; 7346 } 7347 if (!valid) { 7348 if (!errorFound) { 7349 errorFound = true; 7350 message.append("Input inV: "); 7351 appendVariableToMessage(message, args.inV); 7352 message.append("\n"); 7353 message.append("Expected output out: "); 7354 appendVariableToMessage(message, args.out); 7355 message.append("\n"); 7356 message.append("Actual output out: "); 7357 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7358 if (args.out != arrayOut[i * 4 + j]) { 7359 message.append(" FAIL"); 7360 } 7361 message.append("\n"); 7362 message.append("Errors at"); 7363 } 7364 message.append(" ["); 7365 message.append(Integer.toString(i)); 7366 message.append(", "); 7367 message.append(Integer.toString(j)); 7368 message.append("]"); 7369 } 7370 } 7371 } 7372 assertFalse("Incorrect output for checkConvertUint4Ushort4" + 7373 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7374 } 7375 7376 public class ArgumentsFloatInt { 7377 public float inV; 7378 public int out; 7379 } 7380 checkConvertFloat2Int2()7381 private void checkConvertFloat2Int2() { 7382 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc069dd5dl, -2.1474835210000000000e+09, 2.1474835200000000000e+09); 7383 try { 7384 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7385 script.forEach_testConvertInt2Float2Int2(inV, out); 7386 verifyResultsConvertFloat2Int2(inV, out, false); 7387 } catch (Exception e) { 7388 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString()); 7389 } 7390 try { 7391 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7392 scriptRelaxed.forEach_testConvertInt2Float2Int2(inV, out); 7393 verifyResultsConvertFloat2Int2(inV, out, true); 7394 } catch (Exception e) { 7395 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString()); 7396 } 7397 } 7398 verifyResultsConvertFloat2Int2(Allocation inV, Allocation out, boolean relaxed)7399 private void verifyResultsConvertFloat2Int2(Allocation inV, Allocation out, boolean relaxed) { 7400 float[] arrayInV = new float[INPUTSIZE * 2]; 7401 Arrays.fill(arrayInV, (float) 42); 7402 inV.copyTo(arrayInV); 7403 int[] arrayOut = new int[INPUTSIZE * 2]; 7404 Arrays.fill(arrayOut, (int) 42); 7405 out.copyTo(arrayOut); 7406 StringBuilder message = new StringBuilder(); 7407 boolean errorFound = false; 7408 for (int i = 0; i < INPUTSIZE; i++) { 7409 for (int j = 0; j < 2 ; j++) { 7410 // Extract the inputs. 7411 ArgumentsFloatInt args = new ArgumentsFloatInt(); 7412 args.inV = arrayInV[i * 2 + j]; 7413 // Figure out what the outputs should have been. 7414 CoreMathVerifier.computeConvert(args); 7415 // Validate the outputs. 7416 boolean valid = true; 7417 if (args.out != arrayOut[i * 2 + j]) { 7418 valid = false; 7419 } 7420 if (!valid) { 7421 if (!errorFound) { 7422 errorFound = true; 7423 message.append("Input inV: "); 7424 appendVariableToMessage(message, args.inV); 7425 message.append("\n"); 7426 message.append("Expected output out: "); 7427 appendVariableToMessage(message, args.out); 7428 message.append("\n"); 7429 message.append("Actual output out: "); 7430 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7431 if (args.out != arrayOut[i * 2 + j]) { 7432 message.append(" FAIL"); 7433 } 7434 message.append("\n"); 7435 message.append("Errors at"); 7436 } 7437 message.append(" ["); 7438 message.append(Integer.toString(i)); 7439 message.append(", "); 7440 message.append(Integer.toString(j)); 7441 message.append("]"); 7442 } 7443 } 7444 } 7445 assertFalse("Incorrect output for checkConvertFloat2Int2" + 7446 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7447 } 7448 checkConvertFloat3Int3()7449 private void checkConvertFloat3Int3() { 7450 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa11ed93l, -2.1474835210000000000e+09, 2.1474835200000000000e+09); 7451 try { 7452 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7453 script.forEach_testConvertInt3Float3Int3(inV, out); 7454 verifyResultsConvertFloat3Int3(inV, out, false); 7455 } catch (Exception e) { 7456 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString()); 7457 } 7458 try { 7459 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7460 scriptRelaxed.forEach_testConvertInt3Float3Int3(inV, out); 7461 verifyResultsConvertFloat3Int3(inV, out, true); 7462 } catch (Exception e) { 7463 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString()); 7464 } 7465 } 7466 verifyResultsConvertFloat3Int3(Allocation inV, Allocation out, boolean relaxed)7467 private void verifyResultsConvertFloat3Int3(Allocation inV, Allocation out, boolean relaxed) { 7468 float[] arrayInV = new float[INPUTSIZE * 4]; 7469 Arrays.fill(arrayInV, (float) 42); 7470 inV.copyTo(arrayInV); 7471 int[] arrayOut = new int[INPUTSIZE * 4]; 7472 Arrays.fill(arrayOut, (int) 42); 7473 out.copyTo(arrayOut); 7474 StringBuilder message = new StringBuilder(); 7475 boolean errorFound = false; 7476 for (int i = 0; i < INPUTSIZE; i++) { 7477 for (int j = 0; j < 3 ; j++) { 7478 // Extract the inputs. 7479 ArgumentsFloatInt args = new ArgumentsFloatInt(); 7480 args.inV = arrayInV[i * 4 + j]; 7481 // Figure out what the outputs should have been. 7482 CoreMathVerifier.computeConvert(args); 7483 // Validate the outputs. 7484 boolean valid = true; 7485 if (args.out != arrayOut[i * 4 + j]) { 7486 valid = false; 7487 } 7488 if (!valid) { 7489 if (!errorFound) { 7490 errorFound = true; 7491 message.append("Input inV: "); 7492 appendVariableToMessage(message, args.inV); 7493 message.append("\n"); 7494 message.append("Expected output out: "); 7495 appendVariableToMessage(message, args.out); 7496 message.append("\n"); 7497 message.append("Actual output out: "); 7498 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7499 if (args.out != arrayOut[i * 4 + j]) { 7500 message.append(" FAIL"); 7501 } 7502 message.append("\n"); 7503 message.append("Errors at"); 7504 } 7505 message.append(" ["); 7506 message.append(Integer.toString(i)); 7507 message.append(", "); 7508 message.append(Integer.toString(j)); 7509 message.append("]"); 7510 } 7511 } 7512 } 7513 assertFalse("Incorrect output for checkConvertFloat3Int3" + 7514 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7515 } 7516 checkConvertFloat4Int4()7517 private void checkConvertFloat4Int4() { 7518 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x53b9fdc9l, -2.1474835210000000000e+09, 2.1474835200000000000e+09); 7519 try { 7520 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7521 script.forEach_testConvertInt4Float4Int4(inV, out); 7522 verifyResultsConvertFloat4Int4(inV, out, false); 7523 } catch (Exception e) { 7524 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString()); 7525 } 7526 try { 7527 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7528 scriptRelaxed.forEach_testConvertInt4Float4Int4(inV, out); 7529 verifyResultsConvertFloat4Int4(inV, out, true); 7530 } catch (Exception e) { 7531 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString()); 7532 } 7533 } 7534 verifyResultsConvertFloat4Int4(Allocation inV, Allocation out, boolean relaxed)7535 private void verifyResultsConvertFloat4Int4(Allocation inV, Allocation out, boolean relaxed) { 7536 float[] arrayInV = new float[INPUTSIZE * 4]; 7537 Arrays.fill(arrayInV, (float) 42); 7538 inV.copyTo(arrayInV); 7539 int[] arrayOut = new int[INPUTSIZE * 4]; 7540 Arrays.fill(arrayOut, (int) 42); 7541 out.copyTo(arrayOut); 7542 StringBuilder message = new StringBuilder(); 7543 boolean errorFound = false; 7544 for (int i = 0; i < INPUTSIZE; i++) { 7545 for (int j = 0; j < 4 ; j++) { 7546 // Extract the inputs. 7547 ArgumentsFloatInt args = new ArgumentsFloatInt(); 7548 args.inV = arrayInV[i * 4 + j]; 7549 // Figure out what the outputs should have been. 7550 CoreMathVerifier.computeConvert(args); 7551 // Validate the outputs. 7552 boolean valid = true; 7553 if (args.out != arrayOut[i * 4 + j]) { 7554 valid = false; 7555 } 7556 if (!valid) { 7557 if (!errorFound) { 7558 errorFound = true; 7559 message.append("Input inV: "); 7560 appendVariableToMessage(message, args.inV); 7561 message.append("\n"); 7562 message.append("Expected output out: "); 7563 appendVariableToMessage(message, args.out); 7564 message.append("\n"); 7565 message.append("Actual output out: "); 7566 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7567 if (args.out != arrayOut[i * 4 + j]) { 7568 message.append(" FAIL"); 7569 } 7570 message.append("\n"); 7571 message.append("Errors at"); 7572 } 7573 message.append(" ["); 7574 message.append(Integer.toString(i)); 7575 message.append(", "); 7576 message.append(Integer.toString(j)); 7577 message.append("]"); 7578 } 7579 } 7580 } 7581 assertFalse("Incorrect output for checkConvertFloat4Int4" + 7582 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7583 } 7584 7585 public class ArgumentsCharInt { 7586 public byte inV; 7587 public int out; 7588 } 7589 checkConvertChar2Int2()7590 private void checkConvertChar2Int2() { 7591 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x94c6831dl, true, 7); 7592 try { 7593 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7594 script.forEach_testConvertInt2Char2Int2(inV, out); 7595 verifyResultsConvertChar2Int2(inV, out, false); 7596 } catch (Exception e) { 7597 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString()); 7598 } 7599 try { 7600 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7601 scriptRelaxed.forEach_testConvertInt2Char2Int2(inV, out); 7602 verifyResultsConvertChar2Int2(inV, out, true); 7603 } catch (Exception e) { 7604 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString()); 7605 } 7606 } 7607 verifyResultsConvertChar2Int2(Allocation inV, Allocation out, boolean relaxed)7608 private void verifyResultsConvertChar2Int2(Allocation inV, Allocation out, boolean relaxed) { 7609 byte[] arrayInV = new byte[INPUTSIZE * 2]; 7610 Arrays.fill(arrayInV, (byte) 42); 7611 inV.copyTo(arrayInV); 7612 int[] arrayOut = new int[INPUTSIZE * 2]; 7613 Arrays.fill(arrayOut, (int) 42); 7614 out.copyTo(arrayOut); 7615 StringBuilder message = new StringBuilder(); 7616 boolean errorFound = false; 7617 for (int i = 0; i < INPUTSIZE; i++) { 7618 for (int j = 0; j < 2 ; j++) { 7619 // Extract the inputs. 7620 ArgumentsCharInt args = new ArgumentsCharInt(); 7621 args.inV = arrayInV[i * 2 + j]; 7622 // Figure out what the outputs should have been. 7623 CoreMathVerifier.computeConvert(args); 7624 // Validate the outputs. 7625 boolean valid = true; 7626 if (args.out != arrayOut[i * 2 + j]) { 7627 valid = false; 7628 } 7629 if (!valid) { 7630 if (!errorFound) { 7631 errorFound = true; 7632 message.append("Input inV: "); 7633 appendVariableToMessage(message, args.inV); 7634 message.append("\n"); 7635 message.append("Expected output out: "); 7636 appendVariableToMessage(message, args.out); 7637 message.append("\n"); 7638 message.append("Actual output out: "); 7639 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7640 if (args.out != arrayOut[i * 2 + j]) { 7641 message.append(" FAIL"); 7642 } 7643 message.append("\n"); 7644 message.append("Errors at"); 7645 } 7646 message.append(" ["); 7647 message.append(Integer.toString(i)); 7648 message.append(", "); 7649 message.append(Integer.toString(j)); 7650 message.append("]"); 7651 } 7652 } 7653 } 7654 assertFalse("Incorrect output for checkConvertChar2Int2" + 7655 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7656 } 7657 checkConvertChar3Int3()7658 private void checkConvertChar3Int3() { 7659 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xde6e9353l, true, 7); 7660 try { 7661 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7662 script.forEach_testConvertInt3Char3Int3(inV, out); 7663 verifyResultsConvertChar3Int3(inV, out, false); 7664 } catch (Exception e) { 7665 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString()); 7666 } 7667 try { 7668 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7669 scriptRelaxed.forEach_testConvertInt3Char3Int3(inV, out); 7670 verifyResultsConvertChar3Int3(inV, out, true); 7671 } catch (Exception e) { 7672 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString()); 7673 } 7674 } 7675 verifyResultsConvertChar3Int3(Allocation inV, Allocation out, boolean relaxed)7676 private void verifyResultsConvertChar3Int3(Allocation inV, Allocation out, boolean relaxed) { 7677 byte[] arrayInV = new byte[INPUTSIZE * 4]; 7678 Arrays.fill(arrayInV, (byte) 42); 7679 inV.copyTo(arrayInV); 7680 int[] arrayOut = new int[INPUTSIZE * 4]; 7681 Arrays.fill(arrayOut, (int) 42); 7682 out.copyTo(arrayOut); 7683 StringBuilder message = new StringBuilder(); 7684 boolean errorFound = false; 7685 for (int i = 0; i < INPUTSIZE; i++) { 7686 for (int j = 0; j < 3 ; j++) { 7687 // Extract the inputs. 7688 ArgumentsCharInt args = new ArgumentsCharInt(); 7689 args.inV = arrayInV[i * 4 + j]; 7690 // Figure out what the outputs should have been. 7691 CoreMathVerifier.computeConvert(args); 7692 // Validate the outputs. 7693 boolean valid = true; 7694 if (args.out != arrayOut[i * 4 + j]) { 7695 valid = false; 7696 } 7697 if (!valid) { 7698 if (!errorFound) { 7699 errorFound = true; 7700 message.append("Input inV: "); 7701 appendVariableToMessage(message, args.inV); 7702 message.append("\n"); 7703 message.append("Expected output out: "); 7704 appendVariableToMessage(message, args.out); 7705 message.append("\n"); 7706 message.append("Actual output out: "); 7707 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7708 if (args.out != arrayOut[i * 4 + j]) { 7709 message.append(" FAIL"); 7710 } 7711 message.append("\n"); 7712 message.append("Errors at"); 7713 } 7714 message.append(" ["); 7715 message.append(Integer.toString(i)); 7716 message.append(", "); 7717 message.append(Integer.toString(j)); 7718 message.append("]"); 7719 } 7720 } 7721 } 7722 assertFalse("Incorrect output for checkConvertChar3Int3" + 7723 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7724 } 7725 checkConvertChar4Int4()7726 private void checkConvertChar4Int4() { 7727 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x2816a389l, true, 7); 7728 try { 7729 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7730 script.forEach_testConvertInt4Char4Int4(inV, out); 7731 verifyResultsConvertChar4Int4(inV, out, false); 7732 } catch (Exception e) { 7733 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString()); 7734 } 7735 try { 7736 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7737 scriptRelaxed.forEach_testConvertInt4Char4Int4(inV, out); 7738 verifyResultsConvertChar4Int4(inV, out, true); 7739 } catch (Exception e) { 7740 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString()); 7741 } 7742 } 7743 verifyResultsConvertChar4Int4(Allocation inV, Allocation out, boolean relaxed)7744 private void verifyResultsConvertChar4Int4(Allocation inV, Allocation out, boolean relaxed) { 7745 byte[] arrayInV = new byte[INPUTSIZE * 4]; 7746 Arrays.fill(arrayInV, (byte) 42); 7747 inV.copyTo(arrayInV); 7748 int[] arrayOut = new int[INPUTSIZE * 4]; 7749 Arrays.fill(arrayOut, (int) 42); 7750 out.copyTo(arrayOut); 7751 StringBuilder message = new StringBuilder(); 7752 boolean errorFound = false; 7753 for (int i = 0; i < INPUTSIZE; i++) { 7754 for (int j = 0; j < 4 ; j++) { 7755 // Extract the inputs. 7756 ArgumentsCharInt args = new ArgumentsCharInt(); 7757 args.inV = arrayInV[i * 4 + j]; 7758 // Figure out what the outputs should have been. 7759 CoreMathVerifier.computeConvert(args); 7760 // Validate the outputs. 7761 boolean valid = true; 7762 if (args.out != arrayOut[i * 4 + j]) { 7763 valid = false; 7764 } 7765 if (!valid) { 7766 if (!errorFound) { 7767 errorFound = true; 7768 message.append("Input inV: "); 7769 appendVariableToMessage(message, args.inV); 7770 message.append("\n"); 7771 message.append("Expected output out: "); 7772 appendVariableToMessage(message, args.out); 7773 message.append("\n"); 7774 message.append("Actual output out: "); 7775 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7776 if (args.out != arrayOut[i * 4 + j]) { 7777 message.append(" FAIL"); 7778 } 7779 message.append("\n"); 7780 message.append("Errors at"); 7781 } 7782 message.append(" ["); 7783 message.append(Integer.toString(i)); 7784 message.append(", "); 7785 message.append(Integer.toString(j)); 7786 message.append("]"); 7787 } 7788 } 7789 } 7790 assertFalse("Incorrect output for checkConvertChar4Int4" + 7791 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7792 } 7793 7794 public class ArgumentsUcharInt { 7795 public byte inV; 7796 public int out; 7797 } 7798 checkConvertUchar2Int2()7799 private void checkConvertUchar2Int2() { 7800 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x923aa720l, false, 8); 7801 try { 7802 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7803 script.forEach_testConvertInt2Uchar2Int2(inV, out); 7804 verifyResultsConvertUchar2Int2(inV, out, false); 7805 } catch (Exception e) { 7806 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString()); 7807 } 7808 try { 7809 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 7810 scriptRelaxed.forEach_testConvertInt2Uchar2Int2(inV, out); 7811 verifyResultsConvertUchar2Int2(inV, out, true); 7812 } catch (Exception e) { 7813 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString()); 7814 } 7815 } 7816 verifyResultsConvertUchar2Int2(Allocation inV, Allocation out, boolean relaxed)7817 private void verifyResultsConvertUchar2Int2(Allocation inV, Allocation out, boolean relaxed) { 7818 byte[] arrayInV = new byte[INPUTSIZE * 2]; 7819 Arrays.fill(arrayInV, (byte) 42); 7820 inV.copyTo(arrayInV); 7821 int[] arrayOut = new int[INPUTSIZE * 2]; 7822 Arrays.fill(arrayOut, (int) 42); 7823 out.copyTo(arrayOut); 7824 StringBuilder message = new StringBuilder(); 7825 boolean errorFound = false; 7826 for (int i = 0; i < INPUTSIZE; i++) { 7827 for (int j = 0; j < 2 ; j++) { 7828 // Extract the inputs. 7829 ArgumentsUcharInt args = new ArgumentsUcharInt(); 7830 args.inV = arrayInV[i * 2 + j]; 7831 // Figure out what the outputs should have been. 7832 CoreMathVerifier.computeConvert(args); 7833 // Validate the outputs. 7834 boolean valid = true; 7835 if (args.out != arrayOut[i * 2 + j]) { 7836 valid = false; 7837 } 7838 if (!valid) { 7839 if (!errorFound) { 7840 errorFound = true; 7841 message.append("Input inV: "); 7842 appendVariableToMessage(message, args.inV); 7843 message.append("\n"); 7844 message.append("Expected output out: "); 7845 appendVariableToMessage(message, args.out); 7846 message.append("\n"); 7847 message.append("Actual output out: "); 7848 appendVariableToMessage(message, arrayOut[i * 2 + j]); 7849 if (args.out != arrayOut[i * 2 + j]) { 7850 message.append(" FAIL"); 7851 } 7852 message.append("\n"); 7853 message.append("Errors at"); 7854 } 7855 message.append(" ["); 7856 message.append(Integer.toString(i)); 7857 message.append(", "); 7858 message.append(Integer.toString(j)); 7859 message.append("]"); 7860 } 7861 } 7862 } 7863 assertFalse("Incorrect output for checkConvertUchar2Int2" + 7864 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7865 } 7866 checkConvertUchar3Int3()7867 private void checkConvertUchar3Int3() { 7868 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xdbe2b756l, false, 8); 7869 try { 7870 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7871 script.forEach_testConvertInt3Uchar3Int3(inV, out); 7872 verifyResultsConvertUchar3Int3(inV, out, false); 7873 } catch (Exception e) { 7874 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString()); 7875 } 7876 try { 7877 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 7878 scriptRelaxed.forEach_testConvertInt3Uchar3Int3(inV, out); 7879 verifyResultsConvertUchar3Int3(inV, out, true); 7880 } catch (Exception e) { 7881 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString()); 7882 } 7883 } 7884 verifyResultsConvertUchar3Int3(Allocation inV, Allocation out, boolean relaxed)7885 private void verifyResultsConvertUchar3Int3(Allocation inV, Allocation out, boolean relaxed) { 7886 byte[] arrayInV = new byte[INPUTSIZE * 4]; 7887 Arrays.fill(arrayInV, (byte) 42); 7888 inV.copyTo(arrayInV); 7889 int[] arrayOut = new int[INPUTSIZE * 4]; 7890 Arrays.fill(arrayOut, (int) 42); 7891 out.copyTo(arrayOut); 7892 StringBuilder message = new StringBuilder(); 7893 boolean errorFound = false; 7894 for (int i = 0; i < INPUTSIZE; i++) { 7895 for (int j = 0; j < 3 ; j++) { 7896 // Extract the inputs. 7897 ArgumentsUcharInt args = new ArgumentsUcharInt(); 7898 args.inV = arrayInV[i * 4 + j]; 7899 // Figure out what the outputs should have been. 7900 CoreMathVerifier.computeConvert(args); 7901 // Validate the outputs. 7902 boolean valid = true; 7903 if (args.out != arrayOut[i * 4 + j]) { 7904 valid = false; 7905 } 7906 if (!valid) { 7907 if (!errorFound) { 7908 errorFound = true; 7909 message.append("Input inV: "); 7910 appendVariableToMessage(message, args.inV); 7911 message.append("\n"); 7912 message.append("Expected output out: "); 7913 appendVariableToMessage(message, args.out); 7914 message.append("\n"); 7915 message.append("Actual output out: "); 7916 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7917 if (args.out != arrayOut[i * 4 + j]) { 7918 message.append(" FAIL"); 7919 } 7920 message.append("\n"); 7921 message.append("Errors at"); 7922 } 7923 message.append(" ["); 7924 message.append(Integer.toString(i)); 7925 message.append(", "); 7926 message.append(Integer.toString(j)); 7927 message.append("]"); 7928 } 7929 } 7930 } 7931 assertFalse("Incorrect output for checkConvertUchar3Int3" + 7932 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 7933 } 7934 checkConvertUchar4Int4()7935 private void checkConvertUchar4Int4() { 7936 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x258ac78cl, false, 8); 7937 try { 7938 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7939 script.forEach_testConvertInt4Uchar4Int4(inV, out); 7940 verifyResultsConvertUchar4Int4(inV, out, false); 7941 } catch (Exception e) { 7942 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString()); 7943 } 7944 try { 7945 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 7946 scriptRelaxed.forEach_testConvertInt4Uchar4Int4(inV, out); 7947 verifyResultsConvertUchar4Int4(inV, out, true); 7948 } catch (Exception e) { 7949 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString()); 7950 } 7951 } 7952 verifyResultsConvertUchar4Int4(Allocation inV, Allocation out, boolean relaxed)7953 private void verifyResultsConvertUchar4Int4(Allocation inV, Allocation out, boolean relaxed) { 7954 byte[] arrayInV = new byte[INPUTSIZE * 4]; 7955 Arrays.fill(arrayInV, (byte) 42); 7956 inV.copyTo(arrayInV); 7957 int[] arrayOut = new int[INPUTSIZE * 4]; 7958 Arrays.fill(arrayOut, (int) 42); 7959 out.copyTo(arrayOut); 7960 StringBuilder message = new StringBuilder(); 7961 boolean errorFound = false; 7962 for (int i = 0; i < INPUTSIZE; i++) { 7963 for (int j = 0; j < 4 ; j++) { 7964 // Extract the inputs. 7965 ArgumentsUcharInt args = new ArgumentsUcharInt(); 7966 args.inV = arrayInV[i * 4 + j]; 7967 // Figure out what the outputs should have been. 7968 CoreMathVerifier.computeConvert(args); 7969 // Validate the outputs. 7970 boolean valid = true; 7971 if (args.out != arrayOut[i * 4 + j]) { 7972 valid = false; 7973 } 7974 if (!valid) { 7975 if (!errorFound) { 7976 errorFound = true; 7977 message.append("Input inV: "); 7978 appendVariableToMessage(message, args.inV); 7979 message.append("\n"); 7980 message.append("Expected output out: "); 7981 appendVariableToMessage(message, args.out); 7982 message.append("\n"); 7983 message.append("Actual output out: "); 7984 appendVariableToMessage(message, arrayOut[i * 4 + j]); 7985 if (args.out != arrayOut[i * 4 + j]) { 7986 message.append(" FAIL"); 7987 } 7988 message.append("\n"); 7989 message.append("Errors at"); 7990 } 7991 message.append(" ["); 7992 message.append(Integer.toString(i)); 7993 message.append(", "); 7994 message.append(Integer.toString(j)); 7995 message.append("]"); 7996 } 7997 } 7998 } 7999 assertFalse("Incorrect output for checkConvertUchar4Int4" + 8000 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8001 } 8002 8003 public class ArgumentsShortInt { 8004 public short inV; 8005 public int out; 8006 } 8007 checkConvertShort2Int2()8008 private void checkConvertShort2Int2() { 8009 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x252a2d69l, true, 15); 8010 try { 8011 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8012 script.forEach_testConvertInt2Short2Int2(inV, out); 8013 verifyResultsConvertShort2Int2(inV, out, false); 8014 } catch (Exception e) { 8015 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString()); 8016 } 8017 try { 8018 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8019 scriptRelaxed.forEach_testConvertInt2Short2Int2(inV, out); 8020 verifyResultsConvertShort2Int2(inV, out, true); 8021 } catch (Exception e) { 8022 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString()); 8023 } 8024 } 8025 verifyResultsConvertShort2Int2(Allocation inV, Allocation out, boolean relaxed)8026 private void verifyResultsConvertShort2Int2(Allocation inV, Allocation out, boolean relaxed) { 8027 short[] arrayInV = new short[INPUTSIZE * 2]; 8028 Arrays.fill(arrayInV, (short) 42); 8029 inV.copyTo(arrayInV); 8030 int[] arrayOut = new int[INPUTSIZE * 2]; 8031 Arrays.fill(arrayOut, (int) 42); 8032 out.copyTo(arrayOut); 8033 StringBuilder message = new StringBuilder(); 8034 boolean errorFound = false; 8035 for (int i = 0; i < INPUTSIZE; i++) { 8036 for (int j = 0; j < 2 ; j++) { 8037 // Extract the inputs. 8038 ArgumentsShortInt args = new ArgumentsShortInt(); 8039 args.inV = arrayInV[i * 2 + j]; 8040 // Figure out what the outputs should have been. 8041 CoreMathVerifier.computeConvert(args); 8042 // Validate the outputs. 8043 boolean valid = true; 8044 if (args.out != arrayOut[i * 2 + j]) { 8045 valid = false; 8046 } 8047 if (!valid) { 8048 if (!errorFound) { 8049 errorFound = true; 8050 message.append("Input inV: "); 8051 appendVariableToMessage(message, args.inV); 8052 message.append("\n"); 8053 message.append("Expected output out: "); 8054 appendVariableToMessage(message, args.out); 8055 message.append("\n"); 8056 message.append("Actual output out: "); 8057 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8058 if (args.out != arrayOut[i * 2 + j]) { 8059 message.append(" FAIL"); 8060 } 8061 message.append("\n"); 8062 message.append("Errors at"); 8063 } 8064 message.append(" ["); 8065 message.append(Integer.toString(i)); 8066 message.append(", "); 8067 message.append(Integer.toString(j)); 8068 message.append("]"); 8069 } 8070 } 8071 } 8072 assertFalse("Incorrect output for checkConvertShort2Int2" + 8073 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8074 } 8075 checkConvertShort3Int3()8076 private void checkConvertShort3Int3() { 8077 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6ed23d9fl, true, 15); 8078 try { 8079 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8080 script.forEach_testConvertInt3Short3Int3(inV, out); 8081 verifyResultsConvertShort3Int3(inV, out, false); 8082 } catch (Exception e) { 8083 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString()); 8084 } 8085 try { 8086 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8087 scriptRelaxed.forEach_testConvertInt3Short3Int3(inV, out); 8088 verifyResultsConvertShort3Int3(inV, out, true); 8089 } catch (Exception e) { 8090 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString()); 8091 } 8092 } 8093 verifyResultsConvertShort3Int3(Allocation inV, Allocation out, boolean relaxed)8094 private void verifyResultsConvertShort3Int3(Allocation inV, Allocation out, boolean relaxed) { 8095 short[] arrayInV = new short[INPUTSIZE * 4]; 8096 Arrays.fill(arrayInV, (short) 42); 8097 inV.copyTo(arrayInV); 8098 int[] arrayOut = new int[INPUTSIZE * 4]; 8099 Arrays.fill(arrayOut, (int) 42); 8100 out.copyTo(arrayOut); 8101 StringBuilder message = new StringBuilder(); 8102 boolean errorFound = false; 8103 for (int i = 0; i < INPUTSIZE; i++) { 8104 for (int j = 0; j < 3 ; j++) { 8105 // Extract the inputs. 8106 ArgumentsShortInt args = new ArgumentsShortInt(); 8107 args.inV = arrayInV[i * 4 + j]; 8108 // Figure out what the outputs should have been. 8109 CoreMathVerifier.computeConvert(args); 8110 // Validate the outputs. 8111 boolean valid = true; 8112 if (args.out != arrayOut[i * 4 + j]) { 8113 valid = false; 8114 } 8115 if (!valid) { 8116 if (!errorFound) { 8117 errorFound = true; 8118 message.append("Input inV: "); 8119 appendVariableToMessage(message, args.inV); 8120 message.append("\n"); 8121 message.append("Expected output out: "); 8122 appendVariableToMessage(message, args.out); 8123 message.append("\n"); 8124 message.append("Actual output out: "); 8125 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8126 if (args.out != arrayOut[i * 4 + j]) { 8127 message.append(" FAIL"); 8128 } 8129 message.append("\n"); 8130 message.append("Errors at"); 8131 } 8132 message.append(" ["); 8133 message.append(Integer.toString(i)); 8134 message.append(", "); 8135 message.append(Integer.toString(j)); 8136 message.append("]"); 8137 } 8138 } 8139 } 8140 assertFalse("Incorrect output for checkConvertShort3Int3" + 8141 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8142 } 8143 checkConvertShort4Int4()8144 private void checkConvertShort4Int4() { 8145 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xb87a4dd5l, true, 15); 8146 try { 8147 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8148 script.forEach_testConvertInt4Short4Int4(inV, out); 8149 verifyResultsConvertShort4Int4(inV, out, false); 8150 } catch (Exception e) { 8151 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString()); 8152 } 8153 try { 8154 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8155 scriptRelaxed.forEach_testConvertInt4Short4Int4(inV, out); 8156 verifyResultsConvertShort4Int4(inV, out, true); 8157 } catch (Exception e) { 8158 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString()); 8159 } 8160 } 8161 verifyResultsConvertShort4Int4(Allocation inV, Allocation out, boolean relaxed)8162 private void verifyResultsConvertShort4Int4(Allocation inV, Allocation out, boolean relaxed) { 8163 short[] arrayInV = new short[INPUTSIZE * 4]; 8164 Arrays.fill(arrayInV, (short) 42); 8165 inV.copyTo(arrayInV); 8166 int[] arrayOut = new int[INPUTSIZE * 4]; 8167 Arrays.fill(arrayOut, (int) 42); 8168 out.copyTo(arrayOut); 8169 StringBuilder message = new StringBuilder(); 8170 boolean errorFound = false; 8171 for (int i = 0; i < INPUTSIZE; i++) { 8172 for (int j = 0; j < 4 ; j++) { 8173 // Extract the inputs. 8174 ArgumentsShortInt args = new ArgumentsShortInt(); 8175 args.inV = arrayInV[i * 4 + j]; 8176 // Figure out what the outputs should have been. 8177 CoreMathVerifier.computeConvert(args); 8178 // Validate the outputs. 8179 boolean valid = true; 8180 if (args.out != arrayOut[i * 4 + j]) { 8181 valid = false; 8182 } 8183 if (!valid) { 8184 if (!errorFound) { 8185 errorFound = true; 8186 message.append("Input inV: "); 8187 appendVariableToMessage(message, args.inV); 8188 message.append("\n"); 8189 message.append("Expected output out: "); 8190 appendVariableToMessage(message, args.out); 8191 message.append("\n"); 8192 message.append("Actual output out: "); 8193 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8194 if (args.out != arrayOut[i * 4 + j]) { 8195 message.append(" FAIL"); 8196 } 8197 message.append("\n"); 8198 message.append("Errors at"); 8199 } 8200 message.append(" ["); 8201 message.append(Integer.toString(i)); 8202 message.append(", "); 8203 message.append(Integer.toString(j)); 8204 message.append("]"); 8205 } 8206 } 8207 } 8208 assertFalse("Incorrect output for checkConvertShort4Int4" + 8209 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8210 } 8211 8212 public class ArgumentsUshortInt { 8213 public short inV; 8214 public int out; 8215 } 8216 checkConvertUshort2Int2()8217 private void checkConvertUshort2Int2() { 8218 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb7ac39eal, false, 16); 8219 try { 8220 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8221 script.forEach_testConvertInt2Ushort2Int2(inV, out); 8222 verifyResultsConvertUshort2Int2(inV, out, false); 8223 } catch (Exception e) { 8224 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString()); 8225 } 8226 try { 8227 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8228 scriptRelaxed.forEach_testConvertInt2Ushort2Int2(inV, out); 8229 verifyResultsConvertUshort2Int2(inV, out, true); 8230 } catch (Exception e) { 8231 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString()); 8232 } 8233 } 8234 verifyResultsConvertUshort2Int2(Allocation inV, Allocation out, boolean relaxed)8235 private void verifyResultsConvertUshort2Int2(Allocation inV, Allocation out, boolean relaxed) { 8236 short[] arrayInV = new short[INPUTSIZE * 2]; 8237 Arrays.fill(arrayInV, (short) 42); 8238 inV.copyTo(arrayInV); 8239 int[] arrayOut = new int[INPUTSIZE * 2]; 8240 Arrays.fill(arrayOut, (int) 42); 8241 out.copyTo(arrayOut); 8242 StringBuilder message = new StringBuilder(); 8243 boolean errorFound = false; 8244 for (int i = 0; i < INPUTSIZE; i++) { 8245 for (int j = 0; j < 2 ; j++) { 8246 // Extract the inputs. 8247 ArgumentsUshortInt args = new ArgumentsUshortInt(); 8248 args.inV = arrayInV[i * 2 + j]; 8249 // Figure out what the outputs should have been. 8250 CoreMathVerifier.computeConvert(args); 8251 // Validate the outputs. 8252 boolean valid = true; 8253 if (args.out != arrayOut[i * 2 + j]) { 8254 valid = false; 8255 } 8256 if (!valid) { 8257 if (!errorFound) { 8258 errorFound = true; 8259 message.append("Input inV: "); 8260 appendVariableToMessage(message, args.inV); 8261 message.append("\n"); 8262 message.append("Expected output out: "); 8263 appendVariableToMessage(message, args.out); 8264 message.append("\n"); 8265 message.append("Actual output out: "); 8266 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8267 if (args.out != arrayOut[i * 2 + j]) { 8268 message.append(" FAIL"); 8269 } 8270 message.append("\n"); 8271 message.append("Errors at"); 8272 } 8273 message.append(" ["); 8274 message.append(Integer.toString(i)); 8275 message.append(", "); 8276 message.append(Integer.toString(j)); 8277 message.append("]"); 8278 } 8279 } 8280 } 8281 assertFalse("Incorrect output for checkConvertUshort2Int2" + 8282 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8283 } 8284 checkConvertUshort3Int3()8285 private void checkConvertUshort3Int3() { 8286 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x1544a20l, false, 16); 8287 try { 8288 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8289 script.forEach_testConvertInt3Ushort3Int3(inV, out); 8290 verifyResultsConvertUshort3Int3(inV, out, false); 8291 } catch (Exception e) { 8292 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString()); 8293 } 8294 try { 8295 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8296 scriptRelaxed.forEach_testConvertInt3Ushort3Int3(inV, out); 8297 verifyResultsConvertUshort3Int3(inV, out, true); 8298 } catch (Exception e) { 8299 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString()); 8300 } 8301 } 8302 verifyResultsConvertUshort3Int3(Allocation inV, Allocation out, boolean relaxed)8303 private void verifyResultsConvertUshort3Int3(Allocation inV, Allocation out, boolean relaxed) { 8304 short[] arrayInV = new short[INPUTSIZE * 4]; 8305 Arrays.fill(arrayInV, (short) 42); 8306 inV.copyTo(arrayInV); 8307 int[] arrayOut = new int[INPUTSIZE * 4]; 8308 Arrays.fill(arrayOut, (int) 42); 8309 out.copyTo(arrayOut); 8310 StringBuilder message = new StringBuilder(); 8311 boolean errorFound = false; 8312 for (int i = 0; i < INPUTSIZE; i++) { 8313 for (int j = 0; j < 3 ; j++) { 8314 // Extract the inputs. 8315 ArgumentsUshortInt args = new ArgumentsUshortInt(); 8316 args.inV = arrayInV[i * 4 + j]; 8317 // Figure out what the outputs should have been. 8318 CoreMathVerifier.computeConvert(args); 8319 // Validate the outputs. 8320 boolean valid = true; 8321 if (args.out != arrayOut[i * 4 + j]) { 8322 valid = false; 8323 } 8324 if (!valid) { 8325 if (!errorFound) { 8326 errorFound = true; 8327 message.append("Input inV: "); 8328 appendVariableToMessage(message, args.inV); 8329 message.append("\n"); 8330 message.append("Expected output out: "); 8331 appendVariableToMessage(message, args.out); 8332 message.append("\n"); 8333 message.append("Actual output out: "); 8334 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8335 if (args.out != arrayOut[i * 4 + j]) { 8336 message.append(" FAIL"); 8337 } 8338 message.append("\n"); 8339 message.append("Errors at"); 8340 } 8341 message.append(" ["); 8342 message.append(Integer.toString(i)); 8343 message.append(", "); 8344 message.append(Integer.toString(j)); 8345 message.append("]"); 8346 } 8347 } 8348 } 8349 assertFalse("Incorrect output for checkConvertUshort3Int3" + 8350 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8351 } 8352 checkConvertUshort4Int4()8353 private void checkConvertUshort4Int4() { 8354 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x4afc5a56l, false, 16); 8355 try { 8356 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8357 script.forEach_testConvertInt4Ushort4Int4(inV, out); 8358 verifyResultsConvertUshort4Int4(inV, out, false); 8359 } catch (Exception e) { 8360 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString()); 8361 } 8362 try { 8363 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8364 scriptRelaxed.forEach_testConvertInt4Ushort4Int4(inV, out); 8365 verifyResultsConvertUshort4Int4(inV, out, true); 8366 } catch (Exception e) { 8367 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString()); 8368 } 8369 } 8370 verifyResultsConvertUshort4Int4(Allocation inV, Allocation out, boolean relaxed)8371 private void verifyResultsConvertUshort4Int4(Allocation inV, Allocation out, boolean relaxed) { 8372 short[] arrayInV = new short[INPUTSIZE * 4]; 8373 Arrays.fill(arrayInV, (short) 42); 8374 inV.copyTo(arrayInV); 8375 int[] arrayOut = new int[INPUTSIZE * 4]; 8376 Arrays.fill(arrayOut, (int) 42); 8377 out.copyTo(arrayOut); 8378 StringBuilder message = new StringBuilder(); 8379 boolean errorFound = false; 8380 for (int i = 0; i < INPUTSIZE; i++) { 8381 for (int j = 0; j < 4 ; j++) { 8382 // Extract the inputs. 8383 ArgumentsUshortInt args = new ArgumentsUshortInt(); 8384 args.inV = arrayInV[i * 4 + j]; 8385 // Figure out what the outputs should have been. 8386 CoreMathVerifier.computeConvert(args); 8387 // Validate the outputs. 8388 boolean valid = true; 8389 if (args.out != arrayOut[i * 4 + j]) { 8390 valid = false; 8391 } 8392 if (!valid) { 8393 if (!errorFound) { 8394 errorFound = true; 8395 message.append("Input inV: "); 8396 appendVariableToMessage(message, args.inV); 8397 message.append("\n"); 8398 message.append("Expected output out: "); 8399 appendVariableToMessage(message, args.out); 8400 message.append("\n"); 8401 message.append("Actual output out: "); 8402 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8403 if (args.out != arrayOut[i * 4 + j]) { 8404 message.append(" FAIL"); 8405 } 8406 message.append("\n"); 8407 message.append("Errors at"); 8408 } 8409 message.append(" ["); 8410 message.append(Integer.toString(i)); 8411 message.append(", "); 8412 message.append(Integer.toString(j)); 8413 message.append("]"); 8414 } 8415 } 8416 } 8417 assertFalse("Incorrect output for checkConvertUshort4Int4" + 8418 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8419 } 8420 8421 public class ArgumentsIntInt { 8422 public int inV; 8423 public int out; 8424 } 8425 checkConvertInt2Int2()8426 private void checkConvertInt2Int2() { 8427 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x49a42354l, true, 31); 8428 try { 8429 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8430 script.forEach_testConvertInt2Int2Int2(inV, out); 8431 verifyResultsConvertInt2Int2(inV, out, false); 8432 } catch (Exception e) { 8433 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString()); 8434 } 8435 try { 8436 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8437 scriptRelaxed.forEach_testConvertInt2Int2Int2(inV, out); 8438 verifyResultsConvertInt2Int2(inV, out, true); 8439 } catch (Exception e) { 8440 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString()); 8441 } 8442 } 8443 verifyResultsConvertInt2Int2(Allocation inV, Allocation out, boolean relaxed)8444 private void verifyResultsConvertInt2Int2(Allocation inV, Allocation out, boolean relaxed) { 8445 int[] arrayInV = new int[INPUTSIZE * 2]; 8446 Arrays.fill(arrayInV, (int) 42); 8447 inV.copyTo(arrayInV); 8448 int[] arrayOut = new int[INPUTSIZE * 2]; 8449 Arrays.fill(arrayOut, (int) 42); 8450 out.copyTo(arrayOut); 8451 StringBuilder message = new StringBuilder(); 8452 boolean errorFound = false; 8453 for (int i = 0; i < INPUTSIZE; i++) { 8454 for (int j = 0; j < 2 ; j++) { 8455 // Extract the inputs. 8456 ArgumentsIntInt args = new ArgumentsIntInt(); 8457 args.inV = arrayInV[i * 2 + j]; 8458 // Figure out what the outputs should have been. 8459 CoreMathVerifier.computeConvert(args); 8460 // Validate the outputs. 8461 boolean valid = true; 8462 if (args.out != arrayOut[i * 2 + j]) { 8463 valid = false; 8464 } 8465 if (!valid) { 8466 if (!errorFound) { 8467 errorFound = true; 8468 message.append("Input inV: "); 8469 appendVariableToMessage(message, args.inV); 8470 message.append("\n"); 8471 message.append("Expected output out: "); 8472 appendVariableToMessage(message, args.out); 8473 message.append("\n"); 8474 message.append("Actual output out: "); 8475 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8476 if (args.out != arrayOut[i * 2 + j]) { 8477 message.append(" FAIL"); 8478 } 8479 message.append("\n"); 8480 message.append("Errors at"); 8481 } 8482 message.append(" ["); 8483 message.append(Integer.toString(i)); 8484 message.append(", "); 8485 message.append(Integer.toString(j)); 8486 message.append("]"); 8487 } 8488 } 8489 } 8490 assertFalse("Incorrect output for checkConvertInt2Int2" + 8491 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8492 } 8493 checkConvertInt3Int3()8494 private void checkConvertInt3Int3() { 8495 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x934c338al, true, 31); 8496 try { 8497 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8498 script.forEach_testConvertInt3Int3Int3(inV, out); 8499 verifyResultsConvertInt3Int3(inV, out, false); 8500 } catch (Exception e) { 8501 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString()); 8502 } 8503 try { 8504 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8505 scriptRelaxed.forEach_testConvertInt3Int3Int3(inV, out); 8506 verifyResultsConvertInt3Int3(inV, out, true); 8507 } catch (Exception e) { 8508 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString()); 8509 } 8510 } 8511 verifyResultsConvertInt3Int3(Allocation inV, Allocation out, boolean relaxed)8512 private void verifyResultsConvertInt3Int3(Allocation inV, Allocation out, boolean relaxed) { 8513 int[] arrayInV = new int[INPUTSIZE * 4]; 8514 Arrays.fill(arrayInV, (int) 42); 8515 inV.copyTo(arrayInV); 8516 int[] arrayOut = new int[INPUTSIZE * 4]; 8517 Arrays.fill(arrayOut, (int) 42); 8518 out.copyTo(arrayOut); 8519 StringBuilder message = new StringBuilder(); 8520 boolean errorFound = false; 8521 for (int i = 0; i < INPUTSIZE; i++) { 8522 for (int j = 0; j < 3 ; j++) { 8523 // Extract the inputs. 8524 ArgumentsIntInt args = new ArgumentsIntInt(); 8525 args.inV = arrayInV[i * 4 + j]; 8526 // Figure out what the outputs should have been. 8527 CoreMathVerifier.computeConvert(args); 8528 // Validate the outputs. 8529 boolean valid = true; 8530 if (args.out != arrayOut[i * 4 + j]) { 8531 valid = false; 8532 } 8533 if (!valid) { 8534 if (!errorFound) { 8535 errorFound = true; 8536 message.append("Input inV: "); 8537 appendVariableToMessage(message, args.inV); 8538 message.append("\n"); 8539 message.append("Expected output out: "); 8540 appendVariableToMessage(message, args.out); 8541 message.append("\n"); 8542 message.append("Actual output out: "); 8543 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8544 if (args.out != arrayOut[i * 4 + j]) { 8545 message.append(" FAIL"); 8546 } 8547 message.append("\n"); 8548 message.append("Errors at"); 8549 } 8550 message.append(" ["); 8551 message.append(Integer.toString(i)); 8552 message.append(", "); 8553 message.append(Integer.toString(j)); 8554 message.append("]"); 8555 } 8556 } 8557 } 8558 assertFalse("Incorrect output for checkConvertInt3Int3" + 8559 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8560 } 8561 checkConvertInt4Int4()8562 private void checkConvertInt4Int4() { 8563 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xdcf443c0l, true, 31); 8564 try { 8565 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8566 script.forEach_testConvertInt4Int4Int4(inV, out); 8567 verifyResultsConvertInt4Int4(inV, out, false); 8568 } catch (Exception e) { 8569 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString()); 8570 } 8571 try { 8572 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8573 scriptRelaxed.forEach_testConvertInt4Int4Int4(inV, out); 8574 verifyResultsConvertInt4Int4(inV, out, true); 8575 } catch (Exception e) { 8576 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString()); 8577 } 8578 } 8579 verifyResultsConvertInt4Int4(Allocation inV, Allocation out, boolean relaxed)8580 private void verifyResultsConvertInt4Int4(Allocation inV, Allocation out, boolean relaxed) { 8581 int[] arrayInV = new int[INPUTSIZE * 4]; 8582 Arrays.fill(arrayInV, (int) 42); 8583 inV.copyTo(arrayInV); 8584 int[] arrayOut = new int[INPUTSIZE * 4]; 8585 Arrays.fill(arrayOut, (int) 42); 8586 out.copyTo(arrayOut); 8587 StringBuilder message = new StringBuilder(); 8588 boolean errorFound = false; 8589 for (int i = 0; i < INPUTSIZE; i++) { 8590 for (int j = 0; j < 4 ; j++) { 8591 // Extract the inputs. 8592 ArgumentsIntInt args = new ArgumentsIntInt(); 8593 args.inV = arrayInV[i * 4 + j]; 8594 // Figure out what the outputs should have been. 8595 CoreMathVerifier.computeConvert(args); 8596 // Validate the outputs. 8597 boolean valid = true; 8598 if (args.out != arrayOut[i * 4 + j]) { 8599 valid = false; 8600 } 8601 if (!valid) { 8602 if (!errorFound) { 8603 errorFound = true; 8604 message.append("Input inV: "); 8605 appendVariableToMessage(message, args.inV); 8606 message.append("\n"); 8607 message.append("Expected output out: "); 8608 appendVariableToMessage(message, args.out); 8609 message.append("\n"); 8610 message.append("Actual output out: "); 8611 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8612 if (args.out != arrayOut[i * 4 + j]) { 8613 message.append(" FAIL"); 8614 } 8615 message.append("\n"); 8616 message.append("Errors at"); 8617 } 8618 message.append(" ["); 8619 message.append(Integer.toString(i)); 8620 message.append(", "); 8621 message.append(Integer.toString(j)); 8622 message.append("]"); 8623 } 8624 } 8625 } 8626 assertFalse("Incorrect output for checkConvertInt4Int4" + 8627 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8628 } 8629 8630 public class ArgumentsUintInt { 8631 public int inV; 8632 public int out; 8633 } 8634 checkConvertUint2Int2()8635 private void checkConvertUint2Int2() { 8636 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3daccaddl, false, 31); 8637 try { 8638 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8639 script.forEach_testConvertInt2Uint2Int2(inV, out); 8640 verifyResultsConvertUint2Int2(inV, out, false); 8641 } catch (Exception e) { 8642 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString()); 8643 } 8644 try { 8645 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 8646 scriptRelaxed.forEach_testConvertInt2Uint2Int2(inV, out); 8647 verifyResultsConvertUint2Int2(inV, out, true); 8648 } catch (Exception e) { 8649 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString()); 8650 } 8651 } 8652 verifyResultsConvertUint2Int2(Allocation inV, Allocation out, boolean relaxed)8653 private void verifyResultsConvertUint2Int2(Allocation inV, Allocation out, boolean relaxed) { 8654 int[] arrayInV = new int[INPUTSIZE * 2]; 8655 Arrays.fill(arrayInV, (int) 42); 8656 inV.copyTo(arrayInV); 8657 int[] arrayOut = new int[INPUTSIZE * 2]; 8658 Arrays.fill(arrayOut, (int) 42); 8659 out.copyTo(arrayOut); 8660 StringBuilder message = new StringBuilder(); 8661 boolean errorFound = false; 8662 for (int i = 0; i < INPUTSIZE; i++) { 8663 for (int j = 0; j < 2 ; j++) { 8664 // Extract the inputs. 8665 ArgumentsUintInt args = new ArgumentsUintInt(); 8666 args.inV = arrayInV[i * 2 + j]; 8667 // Figure out what the outputs should have been. 8668 CoreMathVerifier.computeConvert(args); 8669 // Validate the outputs. 8670 boolean valid = true; 8671 if (args.out != arrayOut[i * 2 + j]) { 8672 valid = false; 8673 } 8674 if (!valid) { 8675 if (!errorFound) { 8676 errorFound = true; 8677 message.append("Input inV: "); 8678 appendVariableToMessage(message, args.inV); 8679 message.append("\n"); 8680 message.append("Expected output out: "); 8681 appendVariableToMessage(message, args.out); 8682 message.append("\n"); 8683 message.append("Actual output out: "); 8684 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8685 if (args.out != arrayOut[i * 2 + j]) { 8686 message.append(" FAIL"); 8687 } 8688 message.append("\n"); 8689 message.append("Errors at"); 8690 } 8691 message.append(" ["); 8692 message.append(Integer.toString(i)); 8693 message.append(", "); 8694 message.append(Integer.toString(j)); 8695 message.append("]"); 8696 } 8697 } 8698 } 8699 assertFalse("Incorrect output for checkConvertUint2Int2" + 8700 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8701 } 8702 checkConvertUint3Int3()8703 private void checkConvertUint3Int3() { 8704 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8754db13l, false, 31); 8705 try { 8706 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8707 script.forEach_testConvertInt3Uint3Int3(inV, out); 8708 verifyResultsConvertUint3Int3(inV, out, false); 8709 } catch (Exception e) { 8710 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString()); 8711 } 8712 try { 8713 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 8714 scriptRelaxed.forEach_testConvertInt3Uint3Int3(inV, out); 8715 verifyResultsConvertUint3Int3(inV, out, true); 8716 } catch (Exception e) { 8717 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString()); 8718 } 8719 } 8720 verifyResultsConvertUint3Int3(Allocation inV, Allocation out, boolean relaxed)8721 private void verifyResultsConvertUint3Int3(Allocation inV, Allocation out, boolean relaxed) { 8722 int[] arrayInV = new int[INPUTSIZE * 4]; 8723 Arrays.fill(arrayInV, (int) 42); 8724 inV.copyTo(arrayInV); 8725 int[] arrayOut = new int[INPUTSIZE * 4]; 8726 Arrays.fill(arrayOut, (int) 42); 8727 out.copyTo(arrayOut); 8728 StringBuilder message = new StringBuilder(); 8729 boolean errorFound = false; 8730 for (int i = 0; i < INPUTSIZE; i++) { 8731 for (int j = 0; j < 3 ; j++) { 8732 // Extract the inputs. 8733 ArgumentsUintInt args = new ArgumentsUintInt(); 8734 args.inV = arrayInV[i * 4 + j]; 8735 // Figure out what the outputs should have been. 8736 CoreMathVerifier.computeConvert(args); 8737 // Validate the outputs. 8738 boolean valid = true; 8739 if (args.out != arrayOut[i * 4 + j]) { 8740 valid = false; 8741 } 8742 if (!valid) { 8743 if (!errorFound) { 8744 errorFound = true; 8745 message.append("Input inV: "); 8746 appendVariableToMessage(message, args.inV); 8747 message.append("\n"); 8748 message.append("Expected output out: "); 8749 appendVariableToMessage(message, args.out); 8750 message.append("\n"); 8751 message.append("Actual output out: "); 8752 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8753 if (args.out != arrayOut[i * 4 + j]) { 8754 message.append(" FAIL"); 8755 } 8756 message.append("\n"); 8757 message.append("Errors at"); 8758 } 8759 message.append(" ["); 8760 message.append(Integer.toString(i)); 8761 message.append(", "); 8762 message.append(Integer.toString(j)); 8763 message.append("]"); 8764 } 8765 } 8766 } 8767 assertFalse("Incorrect output for checkConvertUint3Int3" + 8768 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8769 } 8770 checkConvertUint4Int4()8771 private void checkConvertUint4Int4() { 8772 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd0fceb49l, false, 31); 8773 try { 8774 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8775 script.forEach_testConvertInt4Uint4Int4(inV, out); 8776 verifyResultsConvertUint4Int4(inV, out, false); 8777 } catch (Exception e) { 8778 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString()); 8779 } 8780 try { 8781 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 8782 scriptRelaxed.forEach_testConvertInt4Uint4Int4(inV, out); 8783 verifyResultsConvertUint4Int4(inV, out, true); 8784 } catch (Exception e) { 8785 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString()); 8786 } 8787 } 8788 verifyResultsConvertUint4Int4(Allocation inV, Allocation out, boolean relaxed)8789 private void verifyResultsConvertUint4Int4(Allocation inV, Allocation out, boolean relaxed) { 8790 int[] arrayInV = new int[INPUTSIZE * 4]; 8791 Arrays.fill(arrayInV, (int) 42); 8792 inV.copyTo(arrayInV); 8793 int[] arrayOut = new int[INPUTSIZE * 4]; 8794 Arrays.fill(arrayOut, (int) 42); 8795 out.copyTo(arrayOut); 8796 StringBuilder message = new StringBuilder(); 8797 boolean errorFound = false; 8798 for (int i = 0; i < INPUTSIZE; i++) { 8799 for (int j = 0; j < 4 ; j++) { 8800 // Extract the inputs. 8801 ArgumentsUintInt args = new ArgumentsUintInt(); 8802 args.inV = arrayInV[i * 4 + j]; 8803 // Figure out what the outputs should have been. 8804 CoreMathVerifier.computeConvert(args); 8805 // Validate the outputs. 8806 boolean valid = true; 8807 if (args.out != arrayOut[i * 4 + j]) { 8808 valid = false; 8809 } 8810 if (!valid) { 8811 if (!errorFound) { 8812 errorFound = true; 8813 message.append("Input inV: "); 8814 appendVariableToMessage(message, args.inV); 8815 message.append("\n"); 8816 message.append("Expected output out: "); 8817 appendVariableToMessage(message, args.out); 8818 message.append("\n"); 8819 message.append("Actual output out: "); 8820 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8821 if (args.out != arrayOut[i * 4 + j]) { 8822 message.append(" FAIL"); 8823 } 8824 message.append("\n"); 8825 message.append("Errors at"); 8826 } 8827 message.append(" ["); 8828 message.append(Integer.toString(i)); 8829 message.append(", "); 8830 message.append(Integer.toString(j)); 8831 message.append("]"); 8832 } 8833 } 8834 } 8835 assertFalse("Incorrect output for checkConvertUint4Int4" + 8836 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8837 } 8838 8839 public class ArgumentsFloatUint { 8840 public float inV; 8841 public int out; 8842 } 8843 checkConvertFloat2Uint2()8844 private void checkConvertFloat2Uint2() { 8845 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x424dca22l, 0.0000000000000000000e+00, 4.2949670400000000000e+09); 8846 try { 8847 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 8848 script.forEach_testConvertUint2Float2Uint2(inV, out); 8849 verifyResultsConvertFloat2Uint2(inV, out, false); 8850 } catch (Exception e) { 8851 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString()); 8852 } 8853 try { 8854 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 8855 scriptRelaxed.forEach_testConvertUint2Float2Uint2(inV, out); 8856 verifyResultsConvertFloat2Uint2(inV, out, true); 8857 } catch (Exception e) { 8858 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString()); 8859 } 8860 } 8861 verifyResultsConvertFloat2Uint2(Allocation inV, Allocation out, boolean relaxed)8862 private void verifyResultsConvertFloat2Uint2(Allocation inV, Allocation out, boolean relaxed) { 8863 float[] arrayInV = new float[INPUTSIZE * 2]; 8864 Arrays.fill(arrayInV, (float) 42); 8865 inV.copyTo(arrayInV); 8866 int[] arrayOut = new int[INPUTSIZE * 2]; 8867 Arrays.fill(arrayOut, (int) 42); 8868 out.copyTo(arrayOut); 8869 StringBuilder message = new StringBuilder(); 8870 boolean errorFound = false; 8871 for (int i = 0; i < INPUTSIZE; i++) { 8872 for (int j = 0; j < 2 ; j++) { 8873 // Extract the inputs. 8874 ArgumentsFloatUint args = new ArgumentsFloatUint(); 8875 args.inV = arrayInV[i * 2 + j]; 8876 // Figure out what the outputs should have been. 8877 CoreMathVerifier.computeConvert(args); 8878 // Validate the outputs. 8879 boolean valid = true; 8880 if (args.out != arrayOut[i * 2 + j]) { 8881 valid = false; 8882 } 8883 if (!valid) { 8884 if (!errorFound) { 8885 errorFound = true; 8886 message.append("Input inV: "); 8887 appendVariableToMessage(message, args.inV); 8888 message.append("\n"); 8889 message.append("Expected output out: "); 8890 appendVariableToMessage(message, args.out); 8891 message.append("\n"); 8892 message.append("Actual output out: "); 8893 appendVariableToMessage(message, arrayOut[i * 2 + j]); 8894 if (args.out != arrayOut[i * 2 + j]) { 8895 message.append(" FAIL"); 8896 } 8897 message.append("\n"); 8898 message.append("Errors at"); 8899 } 8900 message.append(" ["); 8901 message.append(Integer.toString(i)); 8902 message.append(", "); 8903 message.append(Integer.toString(j)); 8904 message.append("]"); 8905 } 8906 } 8907 } 8908 assertFalse("Incorrect output for checkConvertFloat2Uint2" + 8909 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8910 } 8911 checkConvertFloat3Uint3()8912 private void checkConvertFloat3Uint3() { 8913 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa1558f16l, 0.0000000000000000000e+00, 4.2949670400000000000e+09); 8914 try { 8915 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 8916 script.forEach_testConvertUint3Float3Uint3(inV, out); 8917 verifyResultsConvertFloat3Uint3(inV, out, false); 8918 } catch (Exception e) { 8919 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString()); 8920 } 8921 try { 8922 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 8923 scriptRelaxed.forEach_testConvertUint3Float3Uint3(inV, out); 8924 verifyResultsConvertFloat3Uint3(inV, out, true); 8925 } catch (Exception e) { 8926 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString()); 8927 } 8928 } 8929 verifyResultsConvertFloat3Uint3(Allocation inV, Allocation out, boolean relaxed)8930 private void verifyResultsConvertFloat3Uint3(Allocation inV, Allocation out, boolean relaxed) { 8931 float[] arrayInV = new float[INPUTSIZE * 4]; 8932 Arrays.fill(arrayInV, (float) 42); 8933 inV.copyTo(arrayInV); 8934 int[] arrayOut = new int[INPUTSIZE * 4]; 8935 Arrays.fill(arrayOut, (int) 42); 8936 out.copyTo(arrayOut); 8937 StringBuilder message = new StringBuilder(); 8938 boolean errorFound = false; 8939 for (int i = 0; i < INPUTSIZE; i++) { 8940 for (int j = 0; j < 3 ; j++) { 8941 // Extract the inputs. 8942 ArgumentsFloatUint args = new ArgumentsFloatUint(); 8943 args.inV = arrayInV[i * 4 + j]; 8944 // Figure out what the outputs should have been. 8945 CoreMathVerifier.computeConvert(args); 8946 // Validate the outputs. 8947 boolean valid = true; 8948 if (args.out != arrayOut[i * 4 + j]) { 8949 valid = false; 8950 } 8951 if (!valid) { 8952 if (!errorFound) { 8953 errorFound = true; 8954 message.append("Input inV: "); 8955 appendVariableToMessage(message, args.inV); 8956 message.append("\n"); 8957 message.append("Expected output out: "); 8958 appendVariableToMessage(message, args.out); 8959 message.append("\n"); 8960 message.append("Actual output out: "); 8961 appendVariableToMessage(message, arrayOut[i * 4 + j]); 8962 if (args.out != arrayOut[i * 4 + j]) { 8963 message.append(" FAIL"); 8964 } 8965 message.append("\n"); 8966 message.append("Errors at"); 8967 } 8968 message.append(" ["); 8969 message.append(Integer.toString(i)); 8970 message.append(", "); 8971 message.append(Integer.toString(j)); 8972 message.append("]"); 8973 } 8974 } 8975 } 8976 assertFalse("Incorrect output for checkConvertFloat3Uint3" + 8977 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 8978 } 8979 checkConvertFloat4Uint4()8980 private void checkConvertFloat4Uint4() { 8981 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5d540al, 0.0000000000000000000e+00, 4.2949670400000000000e+09); 8982 try { 8983 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 8984 script.forEach_testConvertUint4Float4Uint4(inV, out); 8985 verifyResultsConvertFloat4Uint4(inV, out, false); 8986 } catch (Exception e) { 8987 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString()); 8988 } 8989 try { 8990 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 8991 scriptRelaxed.forEach_testConvertUint4Float4Uint4(inV, out); 8992 verifyResultsConvertFloat4Uint4(inV, out, true); 8993 } catch (Exception e) { 8994 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString()); 8995 } 8996 } 8997 verifyResultsConvertFloat4Uint4(Allocation inV, Allocation out, boolean relaxed)8998 private void verifyResultsConvertFloat4Uint4(Allocation inV, Allocation out, boolean relaxed) { 8999 float[] arrayInV = new float[INPUTSIZE * 4]; 9000 Arrays.fill(arrayInV, (float) 42); 9001 inV.copyTo(arrayInV); 9002 int[] arrayOut = new int[INPUTSIZE * 4]; 9003 Arrays.fill(arrayOut, (int) 42); 9004 out.copyTo(arrayOut); 9005 StringBuilder message = new StringBuilder(); 9006 boolean errorFound = false; 9007 for (int i = 0; i < INPUTSIZE; i++) { 9008 for (int j = 0; j < 4 ; j++) { 9009 // Extract the inputs. 9010 ArgumentsFloatUint args = new ArgumentsFloatUint(); 9011 args.inV = arrayInV[i * 4 + j]; 9012 // Figure out what the outputs should have been. 9013 CoreMathVerifier.computeConvert(args); 9014 // Validate the outputs. 9015 boolean valid = true; 9016 if (args.out != arrayOut[i * 4 + j]) { 9017 valid = false; 9018 } 9019 if (!valid) { 9020 if (!errorFound) { 9021 errorFound = true; 9022 message.append("Input inV: "); 9023 appendVariableToMessage(message, args.inV); 9024 message.append("\n"); 9025 message.append("Expected output out: "); 9026 appendVariableToMessage(message, args.out); 9027 message.append("\n"); 9028 message.append("Actual output out: "); 9029 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9030 if (args.out != arrayOut[i * 4 + j]) { 9031 message.append(" FAIL"); 9032 } 9033 message.append("\n"); 9034 message.append("Errors at"); 9035 } 9036 message.append(" ["); 9037 message.append(Integer.toString(i)); 9038 message.append(", "); 9039 message.append(Integer.toString(j)); 9040 message.append("]"); 9041 } 9042 } 9043 } 9044 assertFalse("Incorrect output for checkConvertFloat4Uint4" + 9045 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9046 } 9047 9048 public class ArgumentsCharUint { 9049 public byte inV; 9050 public int out; 9051 } 9052 checkConvertChar2Uint2()9053 private void checkConvertChar2Uint2() { 9054 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xeddda162l, false, 7); 9055 try { 9056 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9057 script.forEach_testConvertUint2Char2Uint2(inV, out); 9058 verifyResultsConvertChar2Uint2(inV, out, false); 9059 } catch (Exception e) { 9060 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString()); 9061 } 9062 try { 9063 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9064 scriptRelaxed.forEach_testConvertUint2Char2Uint2(inV, out); 9065 verifyResultsConvertChar2Uint2(inV, out, true); 9066 } catch (Exception e) { 9067 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString()); 9068 } 9069 } 9070 verifyResultsConvertChar2Uint2(Allocation inV, Allocation out, boolean relaxed)9071 private void verifyResultsConvertChar2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9072 byte[] arrayInV = new byte[INPUTSIZE * 2]; 9073 Arrays.fill(arrayInV, (byte) 42); 9074 inV.copyTo(arrayInV); 9075 int[] arrayOut = new int[INPUTSIZE * 2]; 9076 Arrays.fill(arrayOut, (int) 42); 9077 out.copyTo(arrayOut); 9078 StringBuilder message = new StringBuilder(); 9079 boolean errorFound = false; 9080 for (int i = 0; i < INPUTSIZE; i++) { 9081 for (int j = 0; j < 2 ; j++) { 9082 // Extract the inputs. 9083 ArgumentsCharUint args = new ArgumentsCharUint(); 9084 args.inV = arrayInV[i * 2 + j]; 9085 // Figure out what the outputs should have been. 9086 CoreMathVerifier.computeConvert(args); 9087 // Validate the outputs. 9088 boolean valid = true; 9089 if (args.out != arrayOut[i * 2 + j]) { 9090 valid = false; 9091 } 9092 if (!valid) { 9093 if (!errorFound) { 9094 errorFound = true; 9095 message.append("Input inV: "); 9096 appendVariableToMessage(message, args.inV); 9097 message.append("\n"); 9098 message.append("Expected output out: "); 9099 appendVariableToMessage(message, args.out); 9100 message.append("\n"); 9101 message.append("Actual output out: "); 9102 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9103 if (args.out != arrayOut[i * 2 + j]) { 9104 message.append(" FAIL"); 9105 } 9106 message.append("\n"); 9107 message.append("Errors at"); 9108 } 9109 message.append(" ["); 9110 message.append(Integer.toString(i)); 9111 message.append(", "); 9112 message.append(Integer.toString(j)); 9113 message.append("]"); 9114 } 9115 } 9116 } 9117 assertFalse("Incorrect output for checkConvertChar2Uint2" + 9118 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9119 } 9120 checkConvertChar3Uint3()9121 private void checkConvertChar3Uint3() { 9122 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4ce56656l, false, 7); 9123 try { 9124 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9125 script.forEach_testConvertUint3Char3Uint3(inV, out); 9126 verifyResultsConvertChar3Uint3(inV, out, false); 9127 } catch (Exception e) { 9128 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString()); 9129 } 9130 try { 9131 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9132 scriptRelaxed.forEach_testConvertUint3Char3Uint3(inV, out); 9133 verifyResultsConvertChar3Uint3(inV, out, true); 9134 } catch (Exception e) { 9135 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString()); 9136 } 9137 } 9138 verifyResultsConvertChar3Uint3(Allocation inV, Allocation out, boolean relaxed)9139 private void verifyResultsConvertChar3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9140 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9141 Arrays.fill(arrayInV, (byte) 42); 9142 inV.copyTo(arrayInV); 9143 int[] arrayOut = new int[INPUTSIZE * 4]; 9144 Arrays.fill(arrayOut, (int) 42); 9145 out.copyTo(arrayOut); 9146 StringBuilder message = new StringBuilder(); 9147 boolean errorFound = false; 9148 for (int i = 0; i < INPUTSIZE; i++) { 9149 for (int j = 0; j < 3 ; j++) { 9150 // Extract the inputs. 9151 ArgumentsCharUint args = new ArgumentsCharUint(); 9152 args.inV = arrayInV[i * 4 + j]; 9153 // Figure out what the outputs should have been. 9154 CoreMathVerifier.computeConvert(args); 9155 // Validate the outputs. 9156 boolean valid = true; 9157 if (args.out != arrayOut[i * 4 + j]) { 9158 valid = false; 9159 } 9160 if (!valid) { 9161 if (!errorFound) { 9162 errorFound = true; 9163 message.append("Input inV: "); 9164 appendVariableToMessage(message, args.inV); 9165 message.append("\n"); 9166 message.append("Expected output out: "); 9167 appendVariableToMessage(message, args.out); 9168 message.append("\n"); 9169 message.append("Actual output out: "); 9170 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9171 if (args.out != arrayOut[i * 4 + j]) { 9172 message.append(" FAIL"); 9173 } 9174 message.append("\n"); 9175 message.append("Errors at"); 9176 } 9177 message.append(" ["); 9178 message.append(Integer.toString(i)); 9179 message.append(", "); 9180 message.append(Integer.toString(j)); 9181 message.append("]"); 9182 } 9183 } 9184 } 9185 assertFalse("Incorrect output for checkConvertChar3Uint3" + 9186 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9187 } 9188 checkConvertChar4Uint4()9189 private void checkConvertChar4Uint4() { 9190 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xabed2b4al, false, 7); 9191 try { 9192 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9193 script.forEach_testConvertUint4Char4Uint4(inV, out); 9194 verifyResultsConvertChar4Uint4(inV, out, false); 9195 } catch (Exception e) { 9196 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString()); 9197 } 9198 try { 9199 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9200 scriptRelaxed.forEach_testConvertUint4Char4Uint4(inV, out); 9201 verifyResultsConvertChar4Uint4(inV, out, true); 9202 } catch (Exception e) { 9203 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString()); 9204 } 9205 } 9206 verifyResultsConvertChar4Uint4(Allocation inV, Allocation out, boolean relaxed)9207 private void verifyResultsConvertChar4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9208 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9209 Arrays.fill(arrayInV, (byte) 42); 9210 inV.copyTo(arrayInV); 9211 int[] arrayOut = new int[INPUTSIZE * 4]; 9212 Arrays.fill(arrayOut, (int) 42); 9213 out.copyTo(arrayOut); 9214 StringBuilder message = new StringBuilder(); 9215 boolean errorFound = false; 9216 for (int i = 0; i < INPUTSIZE; i++) { 9217 for (int j = 0; j < 4 ; j++) { 9218 // Extract the inputs. 9219 ArgumentsCharUint args = new ArgumentsCharUint(); 9220 args.inV = arrayInV[i * 4 + j]; 9221 // Figure out what the outputs should have been. 9222 CoreMathVerifier.computeConvert(args); 9223 // Validate the outputs. 9224 boolean valid = true; 9225 if (args.out != arrayOut[i * 4 + j]) { 9226 valid = false; 9227 } 9228 if (!valid) { 9229 if (!errorFound) { 9230 errorFound = true; 9231 message.append("Input inV: "); 9232 appendVariableToMessage(message, args.inV); 9233 message.append("\n"); 9234 message.append("Expected output out: "); 9235 appendVariableToMessage(message, args.out); 9236 message.append("\n"); 9237 message.append("Actual output out: "); 9238 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9239 if (args.out != arrayOut[i * 4 + j]) { 9240 message.append(" FAIL"); 9241 } 9242 message.append("\n"); 9243 message.append("Errors at"); 9244 } 9245 message.append(" ["); 9246 message.append(Integer.toString(i)); 9247 message.append(", "); 9248 message.append(Integer.toString(j)); 9249 message.append("]"); 9250 } 9251 } 9252 } 9253 assertFalse("Incorrect output for checkConvertChar4Uint4" + 9254 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9255 } 9256 9257 public class ArgumentsUcharUint { 9258 public byte inV; 9259 public int out; 9260 } 9261 checkConvertUchar2Uint2()9262 private void checkConvertUchar2Uint2() { 9263 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x805fade3l, false, 8); 9264 try { 9265 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9266 script.forEach_testConvertUint2Uchar2Uint2(inV, out); 9267 verifyResultsConvertUchar2Uint2(inV, out, false); 9268 } catch (Exception e) { 9269 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString()); 9270 } 9271 try { 9272 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9273 scriptRelaxed.forEach_testConvertUint2Uchar2Uint2(inV, out); 9274 verifyResultsConvertUchar2Uint2(inV, out, true); 9275 } catch (Exception e) { 9276 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString()); 9277 } 9278 } 9279 verifyResultsConvertUchar2Uint2(Allocation inV, Allocation out, boolean relaxed)9280 private void verifyResultsConvertUchar2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9281 byte[] arrayInV = new byte[INPUTSIZE * 2]; 9282 Arrays.fill(arrayInV, (byte) 42); 9283 inV.copyTo(arrayInV); 9284 int[] arrayOut = new int[INPUTSIZE * 2]; 9285 Arrays.fill(arrayOut, (int) 42); 9286 out.copyTo(arrayOut); 9287 StringBuilder message = new StringBuilder(); 9288 boolean errorFound = false; 9289 for (int i = 0; i < INPUTSIZE; i++) { 9290 for (int j = 0; j < 2 ; j++) { 9291 // Extract the inputs. 9292 ArgumentsUcharUint args = new ArgumentsUcharUint(); 9293 args.inV = arrayInV[i * 2 + j]; 9294 // Figure out what the outputs should have been. 9295 CoreMathVerifier.computeConvert(args); 9296 // Validate the outputs. 9297 boolean valid = true; 9298 if (args.out != arrayOut[i * 2 + j]) { 9299 valid = false; 9300 } 9301 if (!valid) { 9302 if (!errorFound) { 9303 errorFound = true; 9304 message.append("Input inV: "); 9305 appendVariableToMessage(message, args.inV); 9306 message.append("\n"); 9307 message.append("Expected output out: "); 9308 appendVariableToMessage(message, args.out); 9309 message.append("\n"); 9310 message.append("Actual output out: "); 9311 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9312 if (args.out != arrayOut[i * 2 + j]) { 9313 message.append(" FAIL"); 9314 } 9315 message.append("\n"); 9316 message.append("Errors at"); 9317 } 9318 message.append(" ["); 9319 message.append(Integer.toString(i)); 9320 message.append(", "); 9321 message.append(Integer.toString(j)); 9322 message.append("]"); 9323 } 9324 } 9325 } 9326 assertFalse("Incorrect output for checkConvertUchar2Uint2" + 9327 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9328 } 9329 checkConvertUchar3Uint3()9330 private void checkConvertUchar3Uint3() { 9331 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xdf6772d7l, false, 8); 9332 try { 9333 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9334 script.forEach_testConvertUint3Uchar3Uint3(inV, out); 9335 verifyResultsConvertUchar3Uint3(inV, out, false); 9336 } catch (Exception e) { 9337 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString()); 9338 } 9339 try { 9340 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9341 scriptRelaxed.forEach_testConvertUint3Uchar3Uint3(inV, out); 9342 verifyResultsConvertUchar3Uint3(inV, out, true); 9343 } catch (Exception e) { 9344 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString()); 9345 } 9346 } 9347 verifyResultsConvertUchar3Uint3(Allocation inV, Allocation out, boolean relaxed)9348 private void verifyResultsConvertUchar3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9349 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9350 Arrays.fill(arrayInV, (byte) 42); 9351 inV.copyTo(arrayInV); 9352 int[] arrayOut = new int[INPUTSIZE * 4]; 9353 Arrays.fill(arrayOut, (int) 42); 9354 out.copyTo(arrayOut); 9355 StringBuilder message = new StringBuilder(); 9356 boolean errorFound = false; 9357 for (int i = 0; i < INPUTSIZE; i++) { 9358 for (int j = 0; j < 3 ; j++) { 9359 // Extract the inputs. 9360 ArgumentsUcharUint args = new ArgumentsUcharUint(); 9361 args.inV = arrayInV[i * 4 + j]; 9362 // Figure out what the outputs should have been. 9363 CoreMathVerifier.computeConvert(args); 9364 // Validate the outputs. 9365 boolean valid = true; 9366 if (args.out != arrayOut[i * 4 + j]) { 9367 valid = false; 9368 } 9369 if (!valid) { 9370 if (!errorFound) { 9371 errorFound = true; 9372 message.append("Input inV: "); 9373 appendVariableToMessage(message, args.inV); 9374 message.append("\n"); 9375 message.append("Expected output out: "); 9376 appendVariableToMessage(message, args.out); 9377 message.append("\n"); 9378 message.append("Actual output out: "); 9379 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9380 if (args.out != arrayOut[i * 4 + j]) { 9381 message.append(" FAIL"); 9382 } 9383 message.append("\n"); 9384 message.append("Errors at"); 9385 } 9386 message.append(" ["); 9387 message.append(Integer.toString(i)); 9388 message.append(", "); 9389 message.append(Integer.toString(j)); 9390 message.append("]"); 9391 } 9392 } 9393 } 9394 assertFalse("Incorrect output for checkConvertUchar3Uint3" + 9395 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9396 } 9397 checkConvertUchar4Uint4()9398 private void checkConvertUchar4Uint4() { 9399 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x3e6f37cbl, false, 8); 9400 try { 9401 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9402 script.forEach_testConvertUint4Uchar4Uint4(inV, out); 9403 verifyResultsConvertUchar4Uint4(inV, out, false); 9404 } catch (Exception e) { 9405 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString()); 9406 } 9407 try { 9408 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9409 scriptRelaxed.forEach_testConvertUint4Uchar4Uint4(inV, out); 9410 verifyResultsConvertUchar4Uint4(inV, out, true); 9411 } catch (Exception e) { 9412 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString()); 9413 } 9414 } 9415 verifyResultsConvertUchar4Uint4(Allocation inV, Allocation out, boolean relaxed)9416 private void verifyResultsConvertUchar4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9417 byte[] arrayInV = new byte[INPUTSIZE * 4]; 9418 Arrays.fill(arrayInV, (byte) 42); 9419 inV.copyTo(arrayInV); 9420 int[] arrayOut = new int[INPUTSIZE * 4]; 9421 Arrays.fill(arrayOut, (int) 42); 9422 out.copyTo(arrayOut); 9423 StringBuilder message = new StringBuilder(); 9424 boolean errorFound = false; 9425 for (int i = 0; i < INPUTSIZE; i++) { 9426 for (int j = 0; j < 4 ; j++) { 9427 // Extract the inputs. 9428 ArgumentsUcharUint args = new ArgumentsUcharUint(); 9429 args.inV = arrayInV[i * 4 + j]; 9430 // Figure out what the outputs should have been. 9431 CoreMathVerifier.computeConvert(args); 9432 // Validate the outputs. 9433 boolean valid = true; 9434 if (args.out != arrayOut[i * 4 + j]) { 9435 valid = false; 9436 } 9437 if (!valid) { 9438 if (!errorFound) { 9439 errorFound = true; 9440 message.append("Input inV: "); 9441 appendVariableToMessage(message, args.inV); 9442 message.append("\n"); 9443 message.append("Expected output out: "); 9444 appendVariableToMessage(message, args.out); 9445 message.append("\n"); 9446 message.append("Actual output out: "); 9447 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9448 if (args.out != arrayOut[i * 4 + j]) { 9449 message.append(" FAIL"); 9450 } 9451 message.append("\n"); 9452 message.append("Errors at"); 9453 } 9454 message.append(" ["); 9455 message.append(Integer.toString(i)); 9456 message.append(", "); 9457 message.append(Integer.toString(j)); 9458 message.append("]"); 9459 } 9460 } 9461 } 9462 assertFalse("Incorrect output for checkConvertUchar4Uint4" + 9463 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9464 } 9465 9466 public class ArgumentsShortUint { 9467 public short inV; 9468 public int out; 9469 } 9470 checkConvertShort2Uint2()9471 private void checkConvertShort2Uint2() { 9472 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x2e9b3c26l, false, 15); 9473 try { 9474 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9475 script.forEach_testConvertUint2Short2Uint2(inV, out); 9476 verifyResultsConvertShort2Uint2(inV, out, false); 9477 } catch (Exception e) { 9478 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString()); 9479 } 9480 try { 9481 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9482 scriptRelaxed.forEach_testConvertUint2Short2Uint2(inV, out); 9483 verifyResultsConvertShort2Uint2(inV, out, true); 9484 } catch (Exception e) { 9485 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString()); 9486 } 9487 } 9488 verifyResultsConvertShort2Uint2(Allocation inV, Allocation out, boolean relaxed)9489 private void verifyResultsConvertShort2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9490 short[] arrayInV = new short[INPUTSIZE * 2]; 9491 Arrays.fill(arrayInV, (short) 42); 9492 inV.copyTo(arrayInV); 9493 int[] arrayOut = new int[INPUTSIZE * 2]; 9494 Arrays.fill(arrayOut, (int) 42); 9495 out.copyTo(arrayOut); 9496 StringBuilder message = new StringBuilder(); 9497 boolean errorFound = false; 9498 for (int i = 0; i < INPUTSIZE; i++) { 9499 for (int j = 0; j < 2 ; j++) { 9500 // Extract the inputs. 9501 ArgumentsShortUint args = new ArgumentsShortUint(); 9502 args.inV = arrayInV[i * 2 + j]; 9503 // Figure out what the outputs should have been. 9504 CoreMathVerifier.computeConvert(args); 9505 // Validate the outputs. 9506 boolean valid = true; 9507 if (args.out != arrayOut[i * 2 + j]) { 9508 valid = false; 9509 } 9510 if (!valid) { 9511 if (!errorFound) { 9512 errorFound = true; 9513 message.append("Input inV: "); 9514 appendVariableToMessage(message, args.inV); 9515 message.append("\n"); 9516 message.append("Expected output out: "); 9517 appendVariableToMessage(message, args.out); 9518 message.append("\n"); 9519 message.append("Actual output out: "); 9520 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9521 if (args.out != arrayOut[i * 2 + j]) { 9522 message.append(" FAIL"); 9523 } 9524 message.append("\n"); 9525 message.append("Errors at"); 9526 } 9527 message.append(" ["); 9528 message.append(Integer.toString(i)); 9529 message.append(", "); 9530 message.append(Integer.toString(j)); 9531 message.append("]"); 9532 } 9533 } 9534 } 9535 assertFalse("Incorrect output for checkConvertShort2Uint2" + 9536 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9537 } 9538 checkConvertShort3Uint3()9539 private void checkConvertShort3Uint3() { 9540 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x8da3011al, false, 15); 9541 try { 9542 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9543 script.forEach_testConvertUint3Short3Uint3(inV, out); 9544 verifyResultsConvertShort3Uint3(inV, out, false); 9545 } catch (Exception e) { 9546 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString()); 9547 } 9548 try { 9549 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9550 scriptRelaxed.forEach_testConvertUint3Short3Uint3(inV, out); 9551 verifyResultsConvertShort3Uint3(inV, out, true); 9552 } catch (Exception e) { 9553 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString()); 9554 } 9555 } 9556 verifyResultsConvertShort3Uint3(Allocation inV, Allocation out, boolean relaxed)9557 private void verifyResultsConvertShort3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9558 short[] arrayInV = new short[INPUTSIZE * 4]; 9559 Arrays.fill(arrayInV, (short) 42); 9560 inV.copyTo(arrayInV); 9561 int[] arrayOut = new int[INPUTSIZE * 4]; 9562 Arrays.fill(arrayOut, (int) 42); 9563 out.copyTo(arrayOut); 9564 StringBuilder message = new StringBuilder(); 9565 boolean errorFound = false; 9566 for (int i = 0; i < INPUTSIZE; i++) { 9567 for (int j = 0; j < 3 ; j++) { 9568 // Extract the inputs. 9569 ArgumentsShortUint args = new ArgumentsShortUint(); 9570 args.inV = arrayInV[i * 4 + j]; 9571 // Figure out what the outputs should have been. 9572 CoreMathVerifier.computeConvert(args); 9573 // Validate the outputs. 9574 boolean valid = true; 9575 if (args.out != arrayOut[i * 4 + j]) { 9576 valid = false; 9577 } 9578 if (!valid) { 9579 if (!errorFound) { 9580 errorFound = true; 9581 message.append("Input inV: "); 9582 appendVariableToMessage(message, args.inV); 9583 message.append("\n"); 9584 message.append("Expected output out: "); 9585 appendVariableToMessage(message, args.out); 9586 message.append("\n"); 9587 message.append("Actual output out: "); 9588 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9589 if (args.out != arrayOut[i * 4 + j]) { 9590 message.append(" FAIL"); 9591 } 9592 message.append("\n"); 9593 message.append("Errors at"); 9594 } 9595 message.append(" ["); 9596 message.append(Integer.toString(i)); 9597 message.append(", "); 9598 message.append(Integer.toString(j)); 9599 message.append("]"); 9600 } 9601 } 9602 } 9603 assertFalse("Incorrect output for checkConvertShort3Uint3" + 9604 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9605 } 9606 checkConvertShort4Uint4()9607 private void checkConvertShort4Uint4() { 9608 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xecaac60el, false, 15); 9609 try { 9610 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9611 script.forEach_testConvertUint4Short4Uint4(inV, out); 9612 verifyResultsConvertShort4Uint4(inV, out, false); 9613 } catch (Exception e) { 9614 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString()); 9615 } 9616 try { 9617 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9618 scriptRelaxed.forEach_testConvertUint4Short4Uint4(inV, out); 9619 verifyResultsConvertShort4Uint4(inV, out, true); 9620 } catch (Exception e) { 9621 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString()); 9622 } 9623 } 9624 verifyResultsConvertShort4Uint4(Allocation inV, Allocation out, boolean relaxed)9625 private void verifyResultsConvertShort4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9626 short[] arrayInV = new short[INPUTSIZE * 4]; 9627 Arrays.fill(arrayInV, (short) 42); 9628 inV.copyTo(arrayInV); 9629 int[] arrayOut = new int[INPUTSIZE * 4]; 9630 Arrays.fill(arrayOut, (int) 42); 9631 out.copyTo(arrayOut); 9632 StringBuilder message = new StringBuilder(); 9633 boolean errorFound = false; 9634 for (int i = 0; i < INPUTSIZE; i++) { 9635 for (int j = 0; j < 4 ; j++) { 9636 // Extract the inputs. 9637 ArgumentsShortUint args = new ArgumentsShortUint(); 9638 args.inV = arrayInV[i * 4 + j]; 9639 // Figure out what the outputs should have been. 9640 CoreMathVerifier.computeConvert(args); 9641 // Validate the outputs. 9642 boolean valid = true; 9643 if (args.out != arrayOut[i * 4 + j]) { 9644 valid = false; 9645 } 9646 if (!valid) { 9647 if (!errorFound) { 9648 errorFound = true; 9649 message.append("Input inV: "); 9650 appendVariableToMessage(message, args.inV); 9651 message.append("\n"); 9652 message.append("Expected output out: "); 9653 appendVariableToMessage(message, args.out); 9654 message.append("\n"); 9655 message.append("Actual output out: "); 9656 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9657 if (args.out != arrayOut[i * 4 + j]) { 9658 message.append(" FAIL"); 9659 } 9660 message.append("\n"); 9661 message.append("Errors at"); 9662 } 9663 message.append(" ["); 9664 message.append(Integer.toString(i)); 9665 message.append(", "); 9666 message.append(Integer.toString(j)); 9667 message.append("]"); 9668 } 9669 } 9670 } 9671 assertFalse("Incorrect output for checkConvertShort4Uint4" + 9672 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9673 } 9674 9675 public class ArgumentsUshortUint { 9676 public short inV; 9677 public int out; 9678 } 9679 checkConvertUshort2Uint2()9680 private void checkConvertUshort2Uint2() { 9681 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xca7355d1l, false, 16); 9682 try { 9683 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9684 script.forEach_testConvertUint2Ushort2Uint2(inV, out); 9685 verifyResultsConvertUshort2Uint2(inV, out, false); 9686 } catch (Exception e) { 9687 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString()); 9688 } 9689 try { 9690 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9691 scriptRelaxed.forEach_testConvertUint2Ushort2Uint2(inV, out); 9692 verifyResultsConvertUshort2Uint2(inV, out, true); 9693 } catch (Exception e) { 9694 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString()); 9695 } 9696 } 9697 verifyResultsConvertUshort2Uint2(Allocation inV, Allocation out, boolean relaxed)9698 private void verifyResultsConvertUshort2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9699 short[] arrayInV = new short[INPUTSIZE * 2]; 9700 Arrays.fill(arrayInV, (short) 42); 9701 inV.copyTo(arrayInV); 9702 int[] arrayOut = new int[INPUTSIZE * 2]; 9703 Arrays.fill(arrayOut, (int) 42); 9704 out.copyTo(arrayOut); 9705 StringBuilder message = new StringBuilder(); 9706 boolean errorFound = false; 9707 for (int i = 0; i < INPUTSIZE; i++) { 9708 for (int j = 0; j < 2 ; j++) { 9709 // Extract the inputs. 9710 ArgumentsUshortUint args = new ArgumentsUshortUint(); 9711 args.inV = arrayInV[i * 2 + j]; 9712 // Figure out what the outputs should have been. 9713 CoreMathVerifier.computeConvert(args); 9714 // Validate the outputs. 9715 boolean valid = true; 9716 if (args.out != arrayOut[i * 2 + j]) { 9717 valid = false; 9718 } 9719 if (!valid) { 9720 if (!errorFound) { 9721 errorFound = true; 9722 message.append("Input inV: "); 9723 appendVariableToMessage(message, args.inV); 9724 message.append("\n"); 9725 message.append("Expected output out: "); 9726 appendVariableToMessage(message, args.out); 9727 message.append("\n"); 9728 message.append("Actual output out: "); 9729 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9730 if (args.out != arrayOut[i * 2 + j]) { 9731 message.append(" FAIL"); 9732 } 9733 message.append("\n"); 9734 message.append("Errors at"); 9735 } 9736 message.append(" ["); 9737 message.append(Integer.toString(i)); 9738 message.append(", "); 9739 message.append(Integer.toString(j)); 9740 message.append("]"); 9741 } 9742 } 9743 } 9744 assertFalse("Incorrect output for checkConvertUshort2Uint2" + 9745 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9746 } 9747 checkConvertUshort3Uint3()9748 private void checkConvertUshort3Uint3() { 9749 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x297b1ac5l, false, 16); 9750 try { 9751 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9752 script.forEach_testConvertUint3Ushort3Uint3(inV, out); 9753 verifyResultsConvertUshort3Uint3(inV, out, false); 9754 } catch (Exception e) { 9755 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString()); 9756 } 9757 try { 9758 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9759 scriptRelaxed.forEach_testConvertUint3Ushort3Uint3(inV, out); 9760 verifyResultsConvertUshort3Uint3(inV, out, true); 9761 } catch (Exception e) { 9762 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString()); 9763 } 9764 } 9765 verifyResultsConvertUshort3Uint3(Allocation inV, Allocation out, boolean relaxed)9766 private void verifyResultsConvertUshort3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9767 short[] arrayInV = new short[INPUTSIZE * 4]; 9768 Arrays.fill(arrayInV, (short) 42); 9769 inV.copyTo(arrayInV); 9770 int[] arrayOut = new int[INPUTSIZE * 4]; 9771 Arrays.fill(arrayOut, (int) 42); 9772 out.copyTo(arrayOut); 9773 StringBuilder message = new StringBuilder(); 9774 boolean errorFound = false; 9775 for (int i = 0; i < INPUTSIZE; i++) { 9776 for (int j = 0; j < 3 ; j++) { 9777 // Extract the inputs. 9778 ArgumentsUshortUint args = new ArgumentsUshortUint(); 9779 args.inV = arrayInV[i * 4 + j]; 9780 // Figure out what the outputs should have been. 9781 CoreMathVerifier.computeConvert(args); 9782 // Validate the outputs. 9783 boolean valid = true; 9784 if (args.out != arrayOut[i * 4 + j]) { 9785 valid = false; 9786 } 9787 if (!valid) { 9788 if (!errorFound) { 9789 errorFound = true; 9790 message.append("Input inV: "); 9791 appendVariableToMessage(message, args.inV); 9792 message.append("\n"); 9793 message.append("Expected output out: "); 9794 appendVariableToMessage(message, args.out); 9795 message.append("\n"); 9796 message.append("Actual output out: "); 9797 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9798 if (args.out != arrayOut[i * 4 + j]) { 9799 message.append(" FAIL"); 9800 } 9801 message.append("\n"); 9802 message.append("Errors at"); 9803 } 9804 message.append(" ["); 9805 message.append(Integer.toString(i)); 9806 message.append(", "); 9807 message.append(Integer.toString(j)); 9808 message.append("]"); 9809 } 9810 } 9811 } 9812 assertFalse("Incorrect output for checkConvertUshort3Uint3" + 9813 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9814 } 9815 checkConvertUshort4Uint4()9816 private void checkConvertUshort4Uint4() { 9817 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8882dfb9l, false, 16); 9818 try { 9819 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9820 script.forEach_testConvertUint4Ushort4Uint4(inV, out); 9821 verifyResultsConvertUshort4Uint4(inV, out, false); 9822 } catch (Exception e) { 9823 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString()); 9824 } 9825 try { 9826 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 9827 scriptRelaxed.forEach_testConvertUint4Ushort4Uint4(inV, out); 9828 verifyResultsConvertUshort4Uint4(inV, out, true); 9829 } catch (Exception e) { 9830 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString()); 9831 } 9832 } 9833 verifyResultsConvertUshort4Uint4(Allocation inV, Allocation out, boolean relaxed)9834 private void verifyResultsConvertUshort4Uint4(Allocation inV, Allocation out, boolean relaxed) { 9835 short[] arrayInV = new short[INPUTSIZE * 4]; 9836 Arrays.fill(arrayInV, (short) 42); 9837 inV.copyTo(arrayInV); 9838 int[] arrayOut = new int[INPUTSIZE * 4]; 9839 Arrays.fill(arrayOut, (int) 42); 9840 out.copyTo(arrayOut); 9841 StringBuilder message = new StringBuilder(); 9842 boolean errorFound = false; 9843 for (int i = 0; i < INPUTSIZE; i++) { 9844 for (int j = 0; j < 4 ; j++) { 9845 // Extract the inputs. 9846 ArgumentsUshortUint args = new ArgumentsUshortUint(); 9847 args.inV = arrayInV[i * 4 + j]; 9848 // Figure out what the outputs should have been. 9849 CoreMathVerifier.computeConvert(args); 9850 // Validate the outputs. 9851 boolean valid = true; 9852 if (args.out != arrayOut[i * 4 + j]) { 9853 valid = false; 9854 } 9855 if (!valid) { 9856 if (!errorFound) { 9857 errorFound = true; 9858 message.append("Input inV: "); 9859 appendVariableToMessage(message, args.inV); 9860 message.append("\n"); 9861 message.append("Expected output out: "); 9862 appendVariableToMessage(message, args.out); 9863 message.append("\n"); 9864 message.append("Actual output out: "); 9865 appendVariableToMessage(message, arrayOut[i * 4 + j]); 9866 if (args.out != arrayOut[i * 4 + j]) { 9867 message.append(" FAIL"); 9868 } 9869 message.append("\n"); 9870 message.append("Errors at"); 9871 } 9872 message.append(" ["); 9873 message.append(Integer.toString(i)); 9874 message.append(", "); 9875 message.append(Integer.toString(j)); 9876 message.append("]"); 9877 } 9878 } 9879 } 9880 assertFalse("Incorrect output for checkConvertUshort4Uint4" + 9881 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9882 } 9883 9884 public class ArgumentsIntUint { 9885 public int inV; 9886 public int out; 9887 } 9888 checkConvertInt2Uint2()9889 private void checkConvertInt2Uint2() { 9890 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4f178a9fl, false, 31); 9891 try { 9892 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9893 script.forEach_testConvertUint2Int2Uint2(inV, out); 9894 verifyResultsConvertInt2Uint2(inV, out, false); 9895 } catch (Exception e) { 9896 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString()); 9897 } 9898 try { 9899 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 9900 scriptRelaxed.forEach_testConvertUint2Int2Uint2(inV, out); 9901 verifyResultsConvertInt2Uint2(inV, out, true); 9902 } catch (Exception e) { 9903 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString()); 9904 } 9905 } 9906 verifyResultsConvertInt2Uint2(Allocation inV, Allocation out, boolean relaxed)9907 private void verifyResultsConvertInt2Uint2(Allocation inV, Allocation out, boolean relaxed) { 9908 int[] arrayInV = new int[INPUTSIZE * 2]; 9909 Arrays.fill(arrayInV, (int) 42); 9910 inV.copyTo(arrayInV); 9911 int[] arrayOut = new int[INPUTSIZE * 2]; 9912 Arrays.fill(arrayOut, (int) 42); 9913 out.copyTo(arrayOut); 9914 StringBuilder message = new StringBuilder(); 9915 boolean errorFound = false; 9916 for (int i = 0; i < INPUTSIZE; i++) { 9917 for (int j = 0; j < 2 ; j++) { 9918 // Extract the inputs. 9919 ArgumentsIntUint args = new ArgumentsIntUint(); 9920 args.inV = arrayInV[i * 2 + j]; 9921 // Figure out what the outputs should have been. 9922 CoreMathVerifier.computeConvert(args); 9923 // Validate the outputs. 9924 boolean valid = true; 9925 if (args.out != arrayOut[i * 2 + j]) { 9926 valid = false; 9927 } 9928 if (!valid) { 9929 if (!errorFound) { 9930 errorFound = true; 9931 message.append("Input inV: "); 9932 appendVariableToMessage(message, args.inV); 9933 message.append("\n"); 9934 message.append("Expected output out: "); 9935 appendVariableToMessage(message, args.out); 9936 message.append("\n"); 9937 message.append("Actual output out: "); 9938 appendVariableToMessage(message, arrayOut[i * 2 + j]); 9939 if (args.out != arrayOut[i * 2 + j]) { 9940 message.append(" FAIL"); 9941 } 9942 message.append("\n"); 9943 message.append("Errors at"); 9944 } 9945 message.append(" ["); 9946 message.append(Integer.toString(i)); 9947 message.append(", "); 9948 message.append(Integer.toString(j)); 9949 message.append("]"); 9950 } 9951 } 9952 } 9953 assertFalse("Incorrect output for checkConvertInt2Uint2" + 9954 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 9955 } 9956 checkConvertInt3Uint3()9957 private void checkConvertInt3Uint3() { 9958 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xae1f4f93l, false, 31); 9959 try { 9960 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9961 script.forEach_testConvertUint3Int3Uint3(inV, out); 9962 verifyResultsConvertInt3Uint3(inV, out, false); 9963 } catch (Exception e) { 9964 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString()); 9965 } 9966 try { 9967 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 9968 scriptRelaxed.forEach_testConvertUint3Int3Uint3(inV, out); 9969 verifyResultsConvertInt3Uint3(inV, out, true); 9970 } catch (Exception e) { 9971 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString()); 9972 } 9973 } 9974 verifyResultsConvertInt3Uint3(Allocation inV, Allocation out, boolean relaxed)9975 private void verifyResultsConvertInt3Uint3(Allocation inV, Allocation out, boolean relaxed) { 9976 int[] arrayInV = new int[INPUTSIZE * 4]; 9977 Arrays.fill(arrayInV, (int) 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 ArgumentsIntUint args = new ArgumentsIntUint(); 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 checkConvertInt3Uint3" + 10022 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10023 } 10024 checkConvertInt4Uint4()10025 private void checkConvertInt4Uint4() { 10026 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd271487l, false, 31); 10027 try { 10028 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10029 script.forEach_testConvertUint4Int4Uint4(inV, out); 10030 verifyResultsConvertInt4Uint4(inV, out, false); 10031 } catch (Exception e) { 10032 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString()); 10033 } 10034 try { 10035 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10036 scriptRelaxed.forEach_testConvertUint4Int4Uint4(inV, out); 10037 verifyResultsConvertInt4Uint4(inV, out, true); 10038 } catch (Exception e) { 10039 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString()); 10040 } 10041 } 10042 verifyResultsConvertInt4Uint4(Allocation inV, Allocation out, boolean relaxed)10043 private void verifyResultsConvertInt4Uint4(Allocation inV, Allocation out, boolean relaxed) { 10044 int[] arrayInV = new int[INPUTSIZE * 4]; 10045 Arrays.fill(arrayInV, (int) 42); 10046 inV.copyTo(arrayInV); 10047 int[] arrayOut = new int[INPUTSIZE * 4]; 10048 Arrays.fill(arrayOut, (int) 42); 10049 out.copyTo(arrayOut); 10050 StringBuilder message = new StringBuilder(); 10051 boolean errorFound = false; 10052 for (int i = 0; i < INPUTSIZE; i++) { 10053 for (int j = 0; j < 4 ; j++) { 10054 // Extract the inputs. 10055 ArgumentsIntUint args = new ArgumentsIntUint(); 10056 args.inV = arrayInV[i * 4 + j]; 10057 // Figure out what the outputs should have been. 10058 CoreMathVerifier.computeConvert(args); 10059 // Validate the outputs. 10060 boolean valid = true; 10061 if (args.out != arrayOut[i * 4 + j]) { 10062 valid = false; 10063 } 10064 if (!valid) { 10065 if (!errorFound) { 10066 errorFound = true; 10067 message.append("Input inV: "); 10068 appendVariableToMessage(message, args.inV); 10069 message.append("\n"); 10070 message.append("Expected output out: "); 10071 appendVariableToMessage(message, args.out); 10072 message.append("\n"); 10073 message.append("Actual output out: "); 10074 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10075 if (args.out != arrayOut[i * 4 + j]) { 10076 message.append(" FAIL"); 10077 } 10078 message.append("\n"); 10079 message.append("Errors at"); 10080 } 10081 message.append(" ["); 10082 message.append(Integer.toString(i)); 10083 message.append(", "); 10084 message.append(Integer.toString(j)); 10085 message.append("]"); 10086 } 10087 } 10088 } 10089 assertFalse("Incorrect output for checkConvertInt4Uint4" + 10090 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10091 } 10092 10093 public class ArgumentsUintUint { 10094 public int inV; 10095 public int out; 10096 } 10097 checkConvertUint2Uint2()10098 private void checkConvertUint2Uint2() { 10099 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x4c8baea2l, false, 32); 10100 try { 10101 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10102 script.forEach_testConvertUint2Uint2Uint2(inV, out); 10103 verifyResultsConvertUint2Uint2(inV, out, false); 10104 } catch (Exception e) { 10105 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString()); 10106 } 10107 try { 10108 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 10109 scriptRelaxed.forEach_testConvertUint2Uint2Uint2(inV, out); 10110 verifyResultsConvertUint2Uint2(inV, out, true); 10111 } catch (Exception e) { 10112 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString()); 10113 } 10114 } 10115 verifyResultsConvertUint2Uint2(Allocation inV, Allocation out, boolean relaxed)10116 private void verifyResultsConvertUint2Uint2(Allocation inV, Allocation out, boolean relaxed) { 10117 int[] arrayInV = new int[INPUTSIZE * 2]; 10118 Arrays.fill(arrayInV, (int) 42); 10119 inV.copyTo(arrayInV); 10120 int[] arrayOut = new int[INPUTSIZE * 2]; 10121 Arrays.fill(arrayOut, (int) 42); 10122 out.copyTo(arrayOut); 10123 StringBuilder message = new StringBuilder(); 10124 boolean errorFound = false; 10125 for (int i = 0; i < INPUTSIZE; i++) { 10126 for (int j = 0; j < 2 ; j++) { 10127 // Extract the inputs. 10128 ArgumentsUintUint args = new ArgumentsUintUint(); 10129 args.inV = arrayInV[i * 2 + j]; 10130 // Figure out what the outputs should have been. 10131 CoreMathVerifier.computeConvert(args); 10132 // Validate the outputs. 10133 boolean valid = true; 10134 if (args.out != arrayOut[i * 2 + j]) { 10135 valid = false; 10136 } 10137 if (!valid) { 10138 if (!errorFound) { 10139 errorFound = true; 10140 message.append("Input inV: "); 10141 appendVariableToMessage(message, args.inV); 10142 message.append("\n"); 10143 message.append("Expected output out: "); 10144 appendVariableToMessage(message, args.out); 10145 message.append("\n"); 10146 message.append("Actual output out: "); 10147 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10148 if (args.out != arrayOut[i * 2 + j]) { 10149 message.append(" FAIL"); 10150 } 10151 message.append("\n"); 10152 message.append("Errors at"); 10153 } 10154 message.append(" ["); 10155 message.append(Integer.toString(i)); 10156 message.append(", "); 10157 message.append(Integer.toString(j)); 10158 message.append("]"); 10159 } 10160 } 10161 } 10162 assertFalse("Incorrect output for checkConvertUint2Uint2" + 10163 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10164 } 10165 checkConvertUint3Uint3()10166 private void checkConvertUint3Uint3() { 10167 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xab937396l, false, 32); 10168 try { 10169 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10170 script.forEach_testConvertUint3Uint3Uint3(inV, out); 10171 verifyResultsConvertUint3Uint3(inV, out, false); 10172 } catch (Exception e) { 10173 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString()); 10174 } 10175 try { 10176 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 10177 scriptRelaxed.forEach_testConvertUint3Uint3Uint3(inV, out); 10178 verifyResultsConvertUint3Uint3(inV, out, true); 10179 } catch (Exception e) { 10180 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString()); 10181 } 10182 } 10183 verifyResultsConvertUint3Uint3(Allocation inV, Allocation out, boolean relaxed)10184 private void verifyResultsConvertUint3Uint3(Allocation inV, Allocation out, boolean relaxed) { 10185 int[] arrayInV = new int[INPUTSIZE * 4]; 10186 Arrays.fill(arrayInV, (int) 42); 10187 inV.copyTo(arrayInV); 10188 int[] arrayOut = new int[INPUTSIZE * 4]; 10189 Arrays.fill(arrayOut, (int) 42); 10190 out.copyTo(arrayOut); 10191 StringBuilder message = new StringBuilder(); 10192 boolean errorFound = false; 10193 for (int i = 0; i < INPUTSIZE; i++) { 10194 for (int j = 0; j < 3 ; j++) { 10195 // Extract the inputs. 10196 ArgumentsUintUint args = new ArgumentsUintUint(); 10197 args.inV = arrayInV[i * 4 + j]; 10198 // Figure out what the outputs should have been. 10199 CoreMathVerifier.computeConvert(args); 10200 // Validate the outputs. 10201 boolean valid = true; 10202 if (args.out != arrayOut[i * 4 + j]) { 10203 valid = false; 10204 } 10205 if (!valid) { 10206 if (!errorFound) { 10207 errorFound = true; 10208 message.append("Input inV: "); 10209 appendVariableToMessage(message, args.inV); 10210 message.append("\n"); 10211 message.append("Expected output out: "); 10212 appendVariableToMessage(message, args.out); 10213 message.append("\n"); 10214 message.append("Actual output out: "); 10215 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10216 if (args.out != arrayOut[i * 4 + j]) { 10217 message.append(" FAIL"); 10218 } 10219 message.append("\n"); 10220 message.append("Errors at"); 10221 } 10222 message.append(" ["); 10223 message.append(Integer.toString(i)); 10224 message.append(", "); 10225 message.append(Integer.toString(j)); 10226 message.append("]"); 10227 } 10228 } 10229 } 10230 assertFalse("Incorrect output for checkConvertUint3Uint3" + 10231 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10232 } 10233 checkConvertUint4Uint4()10234 private void checkConvertUint4Uint4() { 10235 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xa9b388al, false, 32); 10236 try { 10237 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10238 script.forEach_testConvertUint4Uint4Uint4(inV, out); 10239 verifyResultsConvertUint4Uint4(inV, out, false); 10240 } catch (Exception e) { 10241 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString()); 10242 } 10243 try { 10244 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 10245 scriptRelaxed.forEach_testConvertUint4Uint4Uint4(inV, out); 10246 verifyResultsConvertUint4Uint4(inV, out, true); 10247 } catch (Exception e) { 10248 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString()); 10249 } 10250 } 10251 verifyResultsConvertUint4Uint4(Allocation inV, Allocation out, boolean relaxed)10252 private void verifyResultsConvertUint4Uint4(Allocation inV, Allocation out, boolean relaxed) { 10253 int[] arrayInV = new int[INPUTSIZE * 4]; 10254 Arrays.fill(arrayInV, (int) 42); 10255 inV.copyTo(arrayInV); 10256 int[] arrayOut = new int[INPUTSIZE * 4]; 10257 Arrays.fill(arrayOut, (int) 42); 10258 out.copyTo(arrayOut); 10259 StringBuilder message = new StringBuilder(); 10260 boolean errorFound = false; 10261 for (int i = 0; i < INPUTSIZE; i++) { 10262 for (int j = 0; j < 4 ; j++) { 10263 // Extract the inputs. 10264 ArgumentsUintUint args = new ArgumentsUintUint(); 10265 args.inV = arrayInV[i * 4 + j]; 10266 // Figure out what the outputs should have been. 10267 CoreMathVerifier.computeConvert(args); 10268 // Validate the outputs. 10269 boolean valid = true; 10270 if (args.out != arrayOut[i * 4 + j]) { 10271 valid = false; 10272 } 10273 if (!valid) { 10274 if (!errorFound) { 10275 errorFound = true; 10276 message.append("Input inV: "); 10277 appendVariableToMessage(message, args.inV); 10278 message.append("\n"); 10279 message.append("Expected output out: "); 10280 appendVariableToMessage(message, args.out); 10281 message.append("\n"); 10282 message.append("Actual output out: "); 10283 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10284 if (args.out != arrayOut[i * 4 + j]) { 10285 message.append(" FAIL"); 10286 } 10287 message.append("\n"); 10288 message.append("Errors at"); 10289 } 10290 message.append(" ["); 10291 message.append(Integer.toString(i)); 10292 message.append(", "); 10293 message.append(Integer.toString(j)); 10294 message.append("]"); 10295 } 10296 } 10297 } 10298 assertFalse("Incorrect output for checkConvertUint4Uint4" + 10299 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10300 } 10301 10302 public class ArgumentsDoubleDouble { 10303 public double inV; 10304 public Target.Floaty out; 10305 } 10306 checkConvertDouble2Double2()10307 private void checkConvertDouble2Double2() { 10308 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x3902786el, -8.5390423905960001625e+307, 8.5390423905960001625e+307); 10309 try { 10310 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10311 script.forEach_testConvertDouble2Double2Double2(inV, out); 10312 verifyResultsConvertDouble2Double2(inV, out, false); 10313 } catch (Exception e) { 10314 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString()); 10315 } 10316 try { 10317 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10318 scriptRelaxed.forEach_testConvertDouble2Double2Double2(inV, out); 10319 verifyResultsConvertDouble2Double2(inV, out, true); 10320 } catch (Exception e) { 10321 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString()); 10322 } 10323 } 10324 verifyResultsConvertDouble2Double2(Allocation inV, Allocation out, boolean relaxed)10325 private void verifyResultsConvertDouble2Double2(Allocation inV, Allocation out, boolean relaxed) { 10326 double[] arrayInV = new double[INPUTSIZE * 2]; 10327 Arrays.fill(arrayInV, (double) 42); 10328 inV.copyTo(arrayInV); 10329 double[] arrayOut = new double[INPUTSIZE * 2]; 10330 Arrays.fill(arrayOut, (double) 42); 10331 out.copyTo(arrayOut); 10332 StringBuilder message = new StringBuilder(); 10333 boolean errorFound = false; 10334 for (int i = 0; i < INPUTSIZE; i++) { 10335 for (int j = 0; j < 2 ; j++) { 10336 // Extract the inputs. 10337 ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); 10338 args.inV = arrayInV[i * 2 + j]; 10339 // Figure out what the outputs should have been. 10340 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10341 CoreMathVerifier.computeConvert(args, target); 10342 // Validate the outputs. 10343 boolean valid = true; 10344 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10345 valid = false; 10346 } 10347 if (!valid) { 10348 if (!errorFound) { 10349 errorFound = true; 10350 message.append("Input inV: "); 10351 appendVariableToMessage(message, args.inV); 10352 message.append("\n"); 10353 message.append("Expected output out: "); 10354 appendVariableToMessage(message, args.out); 10355 message.append("\n"); 10356 message.append("Actual output out: "); 10357 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10358 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10359 message.append(" FAIL"); 10360 } 10361 message.append("\n"); 10362 message.append("Errors at"); 10363 } 10364 message.append(" ["); 10365 message.append(Integer.toString(i)); 10366 message.append(", "); 10367 message.append(Integer.toString(j)); 10368 message.append("]"); 10369 } 10370 } 10371 } 10372 assertFalse("Incorrect output for checkConvertDouble2Double2" + 10373 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10374 } 10375 checkConvertDouble3Double3()10376 private void checkConvertDouble3Double3() { 10377 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x8f5e099al, -8.5390423905960001625e+307, 8.5390423905960001625e+307); 10378 try { 10379 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10380 script.forEach_testConvertDouble3Double3Double3(inV, out); 10381 verifyResultsConvertDouble3Double3(inV, out, false); 10382 } catch (Exception e) { 10383 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString()); 10384 } 10385 try { 10386 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10387 scriptRelaxed.forEach_testConvertDouble3Double3Double3(inV, out); 10388 verifyResultsConvertDouble3Double3(inV, out, true); 10389 } catch (Exception e) { 10390 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString()); 10391 } 10392 } 10393 verifyResultsConvertDouble3Double3(Allocation inV, Allocation out, boolean relaxed)10394 private void verifyResultsConvertDouble3Double3(Allocation inV, Allocation out, boolean relaxed) { 10395 double[] arrayInV = new double[INPUTSIZE * 4]; 10396 Arrays.fill(arrayInV, (double) 42); 10397 inV.copyTo(arrayInV); 10398 double[] arrayOut = new double[INPUTSIZE * 4]; 10399 Arrays.fill(arrayOut, (double) 42); 10400 out.copyTo(arrayOut); 10401 StringBuilder message = new StringBuilder(); 10402 boolean errorFound = false; 10403 for (int i = 0; i < INPUTSIZE; i++) { 10404 for (int j = 0; j < 3 ; j++) { 10405 // Extract the inputs. 10406 ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); 10407 args.inV = arrayInV[i * 4 + j]; 10408 // Figure out what the outputs should have been. 10409 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10410 CoreMathVerifier.computeConvert(args, target); 10411 // Validate the outputs. 10412 boolean valid = true; 10413 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10414 valid = false; 10415 } 10416 if (!valid) { 10417 if (!errorFound) { 10418 errorFound = true; 10419 message.append("Input inV: "); 10420 appendVariableToMessage(message, args.inV); 10421 message.append("\n"); 10422 message.append("Expected output out: "); 10423 appendVariableToMessage(message, args.out); 10424 message.append("\n"); 10425 message.append("Actual output out: "); 10426 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10427 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10428 message.append(" FAIL"); 10429 } 10430 message.append("\n"); 10431 message.append("Errors at"); 10432 } 10433 message.append(" ["); 10434 message.append(Integer.toString(i)); 10435 message.append(", "); 10436 message.append(Integer.toString(j)); 10437 message.append("]"); 10438 } 10439 } 10440 } 10441 assertFalse("Incorrect output for checkConvertDouble3Double3" + 10442 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10443 } 10444 checkConvertDouble4Double4()10445 private void checkConvertDouble4Double4() { 10446 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xe5b99ac6l, -8.5390423905960001625e+307, 8.5390423905960001625e+307); 10447 try { 10448 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10449 script.forEach_testConvertDouble4Double4Double4(inV, out); 10450 verifyResultsConvertDouble4Double4(inV, out, false); 10451 } catch (Exception e) { 10452 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString()); 10453 } 10454 try { 10455 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10456 scriptRelaxed.forEach_testConvertDouble4Double4Double4(inV, out); 10457 verifyResultsConvertDouble4Double4(inV, out, true); 10458 } catch (Exception e) { 10459 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString()); 10460 } 10461 } 10462 verifyResultsConvertDouble4Double4(Allocation inV, Allocation out, boolean relaxed)10463 private void verifyResultsConvertDouble4Double4(Allocation inV, Allocation out, boolean relaxed) { 10464 double[] arrayInV = new double[INPUTSIZE * 4]; 10465 Arrays.fill(arrayInV, (double) 42); 10466 inV.copyTo(arrayInV); 10467 double[] arrayOut = new double[INPUTSIZE * 4]; 10468 Arrays.fill(arrayOut, (double) 42); 10469 out.copyTo(arrayOut); 10470 StringBuilder message = new StringBuilder(); 10471 boolean errorFound = false; 10472 for (int i = 0; i < INPUTSIZE; i++) { 10473 for (int j = 0; j < 4 ; j++) { 10474 // Extract the inputs. 10475 ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); 10476 args.inV = arrayInV[i * 4 + j]; 10477 // Figure out what the outputs should have been. 10478 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10479 CoreMathVerifier.computeConvert(args, target); 10480 // Validate the outputs. 10481 boolean valid = true; 10482 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10483 valid = false; 10484 } 10485 if (!valid) { 10486 if (!errorFound) { 10487 errorFound = true; 10488 message.append("Input inV: "); 10489 appendVariableToMessage(message, args.inV); 10490 message.append("\n"); 10491 message.append("Expected output out: "); 10492 appendVariableToMessage(message, args.out); 10493 message.append("\n"); 10494 message.append("Actual output out: "); 10495 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10496 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10497 message.append(" FAIL"); 10498 } 10499 message.append("\n"); 10500 message.append("Errors at"); 10501 } 10502 message.append(" ["); 10503 message.append(Integer.toString(i)); 10504 message.append(", "); 10505 message.append(Integer.toString(j)); 10506 message.append("]"); 10507 } 10508 } 10509 } 10510 assertFalse("Incorrect output for checkConvertDouble4Double4" + 10511 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10512 } 10513 10514 public class ArgumentsLongDouble { 10515 public long inV; 10516 public Target.Floaty out; 10517 } 10518 checkConvertLong2Double2()10519 private void checkConvertLong2Double2() { 10520 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x4c70299bl, true, 63); 10521 try { 10522 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10523 script.forEach_testConvertDouble2Long2Double2(inV, out); 10524 verifyResultsConvertLong2Double2(inV, out, false); 10525 } catch (Exception e) { 10526 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString()); 10527 } 10528 try { 10529 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10530 scriptRelaxed.forEach_testConvertDouble2Long2Double2(inV, out); 10531 verifyResultsConvertLong2Double2(inV, out, true); 10532 } catch (Exception e) { 10533 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString()); 10534 } 10535 } 10536 verifyResultsConvertLong2Double2(Allocation inV, Allocation out, boolean relaxed)10537 private void verifyResultsConvertLong2Double2(Allocation inV, Allocation out, boolean relaxed) { 10538 long[] arrayInV = new long[INPUTSIZE * 2]; 10539 Arrays.fill(arrayInV, (long) 42); 10540 inV.copyTo(arrayInV); 10541 double[] arrayOut = new double[INPUTSIZE * 2]; 10542 Arrays.fill(arrayOut, (double) 42); 10543 out.copyTo(arrayOut); 10544 StringBuilder message = new StringBuilder(); 10545 boolean errorFound = false; 10546 for (int i = 0; i < INPUTSIZE; i++) { 10547 for (int j = 0; j < 2 ; j++) { 10548 // Extract the inputs. 10549 ArgumentsLongDouble args = new ArgumentsLongDouble(); 10550 args.inV = arrayInV[i * 2 + j]; 10551 // Figure out what the outputs should have been. 10552 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10553 CoreMathVerifier.computeConvert(args, target); 10554 // Validate the outputs. 10555 boolean valid = true; 10556 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10557 valid = false; 10558 } 10559 if (!valid) { 10560 if (!errorFound) { 10561 errorFound = true; 10562 message.append("Input inV: "); 10563 appendVariableToMessage(message, args.inV); 10564 message.append("\n"); 10565 message.append("Expected output out: "); 10566 appendVariableToMessage(message, args.out); 10567 message.append("\n"); 10568 message.append("Actual output out: "); 10569 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10570 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10571 message.append(" FAIL"); 10572 } 10573 message.append("\n"); 10574 message.append("Errors at"); 10575 } 10576 message.append(" ["); 10577 message.append(Integer.toString(i)); 10578 message.append(", "); 10579 message.append(Integer.toString(j)); 10580 message.append("]"); 10581 } 10582 } 10583 } 10584 assertFalse("Incorrect output for checkConvertLong2Double2" + 10585 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10586 } 10587 checkConvertLong3Double3()10588 private void checkConvertLong3Double3() { 10589 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xa2cbbac7l, true, 63); 10590 try { 10591 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10592 script.forEach_testConvertDouble3Long3Double3(inV, out); 10593 verifyResultsConvertLong3Double3(inV, out, false); 10594 } catch (Exception e) { 10595 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString()); 10596 } 10597 try { 10598 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10599 scriptRelaxed.forEach_testConvertDouble3Long3Double3(inV, out); 10600 verifyResultsConvertLong3Double3(inV, out, true); 10601 } catch (Exception e) { 10602 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString()); 10603 } 10604 } 10605 verifyResultsConvertLong3Double3(Allocation inV, Allocation out, boolean relaxed)10606 private void verifyResultsConvertLong3Double3(Allocation inV, Allocation out, boolean relaxed) { 10607 long[] arrayInV = new long[INPUTSIZE * 4]; 10608 Arrays.fill(arrayInV, (long) 42); 10609 inV.copyTo(arrayInV); 10610 double[] arrayOut = new double[INPUTSIZE * 4]; 10611 Arrays.fill(arrayOut, (double) 42); 10612 out.copyTo(arrayOut); 10613 StringBuilder message = new StringBuilder(); 10614 boolean errorFound = false; 10615 for (int i = 0; i < INPUTSIZE; i++) { 10616 for (int j = 0; j < 3 ; j++) { 10617 // Extract the inputs. 10618 ArgumentsLongDouble args = new ArgumentsLongDouble(); 10619 args.inV = arrayInV[i * 4 + j]; 10620 // Figure out what the outputs should have been. 10621 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10622 CoreMathVerifier.computeConvert(args, target); 10623 // Validate the outputs. 10624 boolean valid = true; 10625 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10626 valid = false; 10627 } 10628 if (!valid) { 10629 if (!errorFound) { 10630 errorFound = true; 10631 message.append("Input inV: "); 10632 appendVariableToMessage(message, args.inV); 10633 message.append("\n"); 10634 message.append("Expected output out: "); 10635 appendVariableToMessage(message, args.out); 10636 message.append("\n"); 10637 message.append("Actual output out: "); 10638 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10639 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10640 message.append(" FAIL"); 10641 } 10642 message.append("\n"); 10643 message.append("Errors at"); 10644 } 10645 message.append(" ["); 10646 message.append(Integer.toString(i)); 10647 message.append(", "); 10648 message.append(Integer.toString(j)); 10649 message.append("]"); 10650 } 10651 } 10652 } 10653 assertFalse("Incorrect output for checkConvertLong3Double3" + 10654 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10655 } 10656 checkConvertLong4Double4()10657 private void checkConvertLong4Double4() { 10658 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xf9274bf3l, true, 63); 10659 try { 10660 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10661 script.forEach_testConvertDouble4Long4Double4(inV, out); 10662 verifyResultsConvertLong4Double4(inV, out, false); 10663 } catch (Exception e) { 10664 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString()); 10665 } 10666 try { 10667 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10668 scriptRelaxed.forEach_testConvertDouble4Long4Double4(inV, out); 10669 verifyResultsConvertLong4Double4(inV, out, true); 10670 } catch (Exception e) { 10671 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString()); 10672 } 10673 } 10674 verifyResultsConvertLong4Double4(Allocation inV, Allocation out, boolean relaxed)10675 private void verifyResultsConvertLong4Double4(Allocation inV, Allocation out, boolean relaxed) { 10676 long[] arrayInV = new long[INPUTSIZE * 4]; 10677 Arrays.fill(arrayInV, (long) 42); 10678 inV.copyTo(arrayInV); 10679 double[] arrayOut = new double[INPUTSIZE * 4]; 10680 Arrays.fill(arrayOut, (double) 42); 10681 out.copyTo(arrayOut); 10682 StringBuilder message = new StringBuilder(); 10683 boolean errorFound = false; 10684 for (int i = 0; i < INPUTSIZE; i++) { 10685 for (int j = 0; j < 4 ; j++) { 10686 // Extract the inputs. 10687 ArgumentsLongDouble args = new ArgumentsLongDouble(); 10688 args.inV = arrayInV[i * 4 + j]; 10689 // Figure out what the outputs should have been. 10690 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10691 CoreMathVerifier.computeConvert(args, target); 10692 // Validate the outputs. 10693 boolean valid = true; 10694 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10695 valid = false; 10696 } 10697 if (!valid) { 10698 if (!errorFound) { 10699 errorFound = true; 10700 message.append("Input inV: "); 10701 appendVariableToMessage(message, args.inV); 10702 message.append("\n"); 10703 message.append("Expected output out: "); 10704 appendVariableToMessage(message, args.out); 10705 message.append("\n"); 10706 message.append("Actual output out: "); 10707 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10708 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10709 message.append(" FAIL"); 10710 } 10711 message.append("\n"); 10712 message.append("Errors at"); 10713 } 10714 message.append(" ["); 10715 message.append(Integer.toString(i)); 10716 message.append(", "); 10717 message.append(Integer.toString(j)); 10718 message.append("]"); 10719 } 10720 } 10721 } 10722 assertFalse("Incorrect output for checkConvertLong4Double4" + 10723 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10724 } 10725 10726 public class ArgumentsUlongDouble { 10727 public long inV; 10728 public Target.Floaty out; 10729 } 10730 checkConvertUlong2Double2()10731 private void checkConvertUlong2Double2() { 10732 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x79bc7954l, false, 64); 10733 try { 10734 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10735 script.forEach_testConvertDouble2Ulong2Double2(inV, out); 10736 verifyResultsConvertUlong2Double2(inV, out, false); 10737 } catch (Exception e) { 10738 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString()); 10739 } 10740 try { 10741 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 10742 scriptRelaxed.forEach_testConvertDouble2Ulong2Double2(inV, out); 10743 verifyResultsConvertUlong2Double2(inV, out, true); 10744 } catch (Exception e) { 10745 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString()); 10746 } 10747 } 10748 verifyResultsConvertUlong2Double2(Allocation inV, Allocation out, boolean relaxed)10749 private void verifyResultsConvertUlong2Double2(Allocation inV, Allocation out, boolean relaxed) { 10750 long[] arrayInV = new long[INPUTSIZE * 2]; 10751 Arrays.fill(arrayInV, (long) 42); 10752 inV.copyTo(arrayInV); 10753 double[] arrayOut = new double[INPUTSIZE * 2]; 10754 Arrays.fill(arrayOut, (double) 42); 10755 out.copyTo(arrayOut); 10756 StringBuilder message = new StringBuilder(); 10757 boolean errorFound = false; 10758 for (int i = 0; i < INPUTSIZE; i++) { 10759 for (int j = 0; j < 2 ; j++) { 10760 // Extract the inputs. 10761 ArgumentsUlongDouble args = new ArgumentsUlongDouble(); 10762 args.inV = arrayInV[i * 2 + j]; 10763 // Figure out what the outputs should have been. 10764 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10765 CoreMathVerifier.computeConvert(args, target); 10766 // Validate the outputs. 10767 boolean valid = true; 10768 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10769 valid = false; 10770 } 10771 if (!valid) { 10772 if (!errorFound) { 10773 errorFound = true; 10774 message.append("Input inV: "); 10775 appendVariableToMessage(message, args.inV); 10776 message.append("\n"); 10777 message.append("Expected output out: "); 10778 appendVariableToMessage(message, args.out); 10779 message.append("\n"); 10780 message.append("Actual output out: "); 10781 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10782 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 10783 message.append(" FAIL"); 10784 } 10785 message.append("\n"); 10786 message.append("Errors at"); 10787 } 10788 message.append(" ["); 10789 message.append(Integer.toString(i)); 10790 message.append(", "); 10791 message.append(Integer.toString(j)); 10792 message.append("]"); 10793 } 10794 } 10795 } 10796 assertFalse("Incorrect output for checkConvertUlong2Double2" + 10797 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10798 } 10799 checkConvertUlong3Double3()10800 private void checkConvertUlong3Double3() { 10801 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xd0180a80l, false, 64); 10802 try { 10803 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10804 script.forEach_testConvertDouble3Ulong3Double3(inV, out); 10805 verifyResultsConvertUlong3Double3(inV, out, false); 10806 } catch (Exception e) { 10807 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString()); 10808 } 10809 try { 10810 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 10811 scriptRelaxed.forEach_testConvertDouble3Ulong3Double3(inV, out); 10812 verifyResultsConvertUlong3Double3(inV, out, true); 10813 } catch (Exception e) { 10814 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString()); 10815 } 10816 } 10817 verifyResultsConvertUlong3Double3(Allocation inV, Allocation out, boolean relaxed)10818 private void verifyResultsConvertUlong3Double3(Allocation inV, Allocation out, boolean relaxed) { 10819 long[] arrayInV = new long[INPUTSIZE * 4]; 10820 Arrays.fill(arrayInV, (long) 42); 10821 inV.copyTo(arrayInV); 10822 double[] arrayOut = new double[INPUTSIZE * 4]; 10823 Arrays.fill(arrayOut, (double) 42); 10824 out.copyTo(arrayOut); 10825 StringBuilder message = new StringBuilder(); 10826 boolean errorFound = false; 10827 for (int i = 0; i < INPUTSIZE; i++) { 10828 for (int j = 0; j < 3 ; j++) { 10829 // Extract the inputs. 10830 ArgumentsUlongDouble args = new ArgumentsUlongDouble(); 10831 args.inV = arrayInV[i * 4 + j]; 10832 // Figure out what the outputs should have been. 10833 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10834 CoreMathVerifier.computeConvert(args, target); 10835 // Validate the outputs. 10836 boolean valid = true; 10837 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10838 valid = false; 10839 } 10840 if (!valid) { 10841 if (!errorFound) { 10842 errorFound = true; 10843 message.append("Input inV: "); 10844 appendVariableToMessage(message, args.inV); 10845 message.append("\n"); 10846 message.append("Expected output out: "); 10847 appendVariableToMessage(message, args.out); 10848 message.append("\n"); 10849 message.append("Actual output out: "); 10850 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10851 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10852 message.append(" FAIL"); 10853 } 10854 message.append("\n"); 10855 message.append("Errors at"); 10856 } 10857 message.append(" ["); 10858 message.append(Integer.toString(i)); 10859 message.append(", "); 10860 message.append(Integer.toString(j)); 10861 message.append("]"); 10862 } 10863 } 10864 } 10865 assertFalse("Incorrect output for checkConvertUlong3Double3" + 10866 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10867 } 10868 checkConvertUlong4Double4()10869 private void checkConvertUlong4Double4() { 10870 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x26739bacl, false, 64); 10871 try { 10872 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10873 script.forEach_testConvertDouble4Ulong4Double4(inV, out); 10874 verifyResultsConvertUlong4Double4(inV, out, false); 10875 } catch (Exception e) { 10876 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString()); 10877 } 10878 try { 10879 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 10880 scriptRelaxed.forEach_testConvertDouble4Ulong4Double4(inV, out); 10881 verifyResultsConvertUlong4Double4(inV, out, true); 10882 } catch (Exception e) { 10883 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString()); 10884 } 10885 } 10886 verifyResultsConvertUlong4Double4(Allocation inV, Allocation out, boolean relaxed)10887 private void verifyResultsConvertUlong4Double4(Allocation inV, Allocation out, boolean relaxed) { 10888 long[] arrayInV = new long[INPUTSIZE * 4]; 10889 Arrays.fill(arrayInV, (long) 42); 10890 inV.copyTo(arrayInV); 10891 double[] arrayOut = new double[INPUTSIZE * 4]; 10892 Arrays.fill(arrayOut, (double) 42); 10893 out.copyTo(arrayOut); 10894 StringBuilder message = new StringBuilder(); 10895 boolean errorFound = false; 10896 for (int i = 0; i < INPUTSIZE; i++) { 10897 for (int j = 0; j < 4 ; j++) { 10898 // Extract the inputs. 10899 ArgumentsUlongDouble args = new ArgumentsUlongDouble(); 10900 args.inV = arrayInV[i * 4 + j]; 10901 // Figure out what the outputs should have been. 10902 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 10903 CoreMathVerifier.computeConvert(args, target); 10904 // Validate the outputs. 10905 boolean valid = true; 10906 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10907 valid = false; 10908 } 10909 if (!valid) { 10910 if (!errorFound) { 10911 errorFound = true; 10912 message.append("Input inV: "); 10913 appendVariableToMessage(message, args.inV); 10914 message.append("\n"); 10915 message.append("Expected output out: "); 10916 appendVariableToMessage(message, args.out); 10917 message.append("\n"); 10918 message.append("Actual output out: "); 10919 appendVariableToMessage(message, arrayOut[i * 4 + j]); 10920 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 10921 message.append(" FAIL"); 10922 } 10923 message.append("\n"); 10924 message.append("Errors at"); 10925 } 10926 message.append(" ["); 10927 message.append(Integer.toString(i)); 10928 message.append(", "); 10929 message.append(Integer.toString(j)); 10930 message.append("]"); 10931 } 10932 } 10933 } 10934 assertFalse("Incorrect output for checkConvertUlong4Double4" + 10935 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 10936 } 10937 10938 public class ArgumentsDoubleLong { 10939 public double inV; 10940 public long out; 10941 } 10942 checkConvertDouble2Long2()10943 private void checkConvertDouble2Long2() { 10944 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x430cbe95l, -9.2233720368547747840e+18, 9.2233720368547747840e+18); 10945 try { 10946 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 10947 script.forEach_testConvertLong2Double2Long2(inV, out); 10948 verifyResultsConvertDouble2Long2(inV, out, false); 10949 } catch (Exception e) { 10950 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString()); 10951 } 10952 try { 10953 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 10954 scriptRelaxed.forEach_testConvertLong2Double2Long2(inV, out); 10955 verifyResultsConvertDouble2Long2(inV, out, true); 10956 } catch (Exception e) { 10957 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString()); 10958 } 10959 } 10960 verifyResultsConvertDouble2Long2(Allocation inV, Allocation out, boolean relaxed)10961 private void verifyResultsConvertDouble2Long2(Allocation inV, Allocation out, boolean relaxed) { 10962 double[] arrayInV = new double[INPUTSIZE * 2]; 10963 Arrays.fill(arrayInV, (double) 42); 10964 inV.copyTo(arrayInV); 10965 long[] arrayOut = new long[INPUTSIZE * 2]; 10966 Arrays.fill(arrayOut, (long) 42); 10967 out.copyTo(arrayOut); 10968 StringBuilder message = new StringBuilder(); 10969 boolean errorFound = false; 10970 for (int i = 0; i < INPUTSIZE; i++) { 10971 for (int j = 0; j < 2 ; j++) { 10972 // Extract the inputs. 10973 ArgumentsDoubleLong args = new ArgumentsDoubleLong(); 10974 args.inV = arrayInV[i * 2 + j]; 10975 // Figure out what the outputs should have been. 10976 CoreMathVerifier.computeConvert(args); 10977 // Validate the outputs. 10978 boolean valid = true; 10979 if (args.out != arrayOut[i * 2 + j]) { 10980 valid = false; 10981 } 10982 if (!valid) { 10983 if (!errorFound) { 10984 errorFound = true; 10985 message.append("Input inV: "); 10986 appendVariableToMessage(message, args.inV); 10987 message.append("\n"); 10988 message.append("Expected output out: "); 10989 appendVariableToMessage(message, args.out); 10990 message.append("\n"); 10991 message.append("Actual output out: "); 10992 appendVariableToMessage(message, arrayOut[i * 2 + j]); 10993 if (args.out != arrayOut[i * 2 + j]) { 10994 message.append(" FAIL"); 10995 } 10996 message.append("\n"); 10997 message.append("Errors at"); 10998 } 10999 message.append(" ["); 11000 message.append(Integer.toString(i)); 11001 message.append(", "); 11002 message.append(Integer.toString(j)); 11003 message.append("]"); 11004 } 11005 } 11006 } 11007 assertFalse("Incorrect output for checkConvertDouble2Long2" + 11008 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11009 } 11010 checkConvertDouble3Long3()11011 private void checkConvertDouble3Long3() { 11012 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xa2148389l, -9.2233720368547747840e+18, 9.2233720368547747840e+18); 11013 try { 11014 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11015 script.forEach_testConvertLong3Double3Long3(inV, out); 11016 verifyResultsConvertDouble3Long3(inV, out, false); 11017 } catch (Exception e) { 11018 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString()); 11019 } 11020 try { 11021 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11022 scriptRelaxed.forEach_testConvertLong3Double3Long3(inV, out); 11023 verifyResultsConvertDouble3Long3(inV, out, true); 11024 } catch (Exception e) { 11025 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString()); 11026 } 11027 } 11028 verifyResultsConvertDouble3Long3(Allocation inV, Allocation out, boolean relaxed)11029 private void verifyResultsConvertDouble3Long3(Allocation inV, Allocation out, boolean relaxed) { 11030 double[] arrayInV = new double[INPUTSIZE * 4]; 11031 Arrays.fill(arrayInV, (double) 42); 11032 inV.copyTo(arrayInV); 11033 long[] arrayOut = new long[INPUTSIZE * 4]; 11034 Arrays.fill(arrayOut, (long) 42); 11035 out.copyTo(arrayOut); 11036 StringBuilder message = new StringBuilder(); 11037 boolean errorFound = false; 11038 for (int i = 0; i < INPUTSIZE; i++) { 11039 for (int j = 0; j < 3 ; j++) { 11040 // Extract the inputs. 11041 ArgumentsDoubleLong args = new ArgumentsDoubleLong(); 11042 args.inV = arrayInV[i * 4 + j]; 11043 // Figure out what the outputs should have been. 11044 CoreMathVerifier.computeConvert(args); 11045 // Validate the outputs. 11046 boolean valid = true; 11047 if (args.out != arrayOut[i * 4 + j]) { 11048 valid = false; 11049 } 11050 if (!valid) { 11051 if (!errorFound) { 11052 errorFound = true; 11053 message.append("Input inV: "); 11054 appendVariableToMessage(message, args.inV); 11055 message.append("\n"); 11056 message.append("Expected output out: "); 11057 appendVariableToMessage(message, args.out); 11058 message.append("\n"); 11059 message.append("Actual output out: "); 11060 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11061 if (args.out != arrayOut[i * 4 + j]) { 11062 message.append(" FAIL"); 11063 } 11064 message.append("\n"); 11065 message.append("Errors at"); 11066 } 11067 message.append(" ["); 11068 message.append(Integer.toString(i)); 11069 message.append(", "); 11070 message.append(Integer.toString(j)); 11071 message.append("]"); 11072 } 11073 } 11074 } 11075 assertFalse("Incorrect output for checkConvertDouble3Long3" + 11076 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11077 } 11078 checkConvertDouble4Long4()11079 private void checkConvertDouble4Long4() { 11080 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x11c487dl, -9.2233720368547747840e+18, 9.2233720368547747840e+18); 11081 try { 11082 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11083 script.forEach_testConvertLong4Double4Long4(inV, out); 11084 verifyResultsConvertDouble4Long4(inV, out, false); 11085 } catch (Exception e) { 11086 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString()); 11087 } 11088 try { 11089 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11090 scriptRelaxed.forEach_testConvertLong4Double4Long4(inV, out); 11091 verifyResultsConvertDouble4Long4(inV, out, true); 11092 } catch (Exception e) { 11093 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString()); 11094 } 11095 } 11096 verifyResultsConvertDouble4Long4(Allocation inV, Allocation out, boolean relaxed)11097 private void verifyResultsConvertDouble4Long4(Allocation inV, Allocation out, boolean relaxed) { 11098 double[] arrayInV = new double[INPUTSIZE * 4]; 11099 Arrays.fill(arrayInV, (double) 42); 11100 inV.copyTo(arrayInV); 11101 long[] arrayOut = new long[INPUTSIZE * 4]; 11102 Arrays.fill(arrayOut, (long) 42); 11103 out.copyTo(arrayOut); 11104 StringBuilder message = new StringBuilder(); 11105 boolean errorFound = false; 11106 for (int i = 0; i < INPUTSIZE; i++) { 11107 for (int j = 0; j < 4 ; j++) { 11108 // Extract the inputs. 11109 ArgumentsDoubleLong args = new ArgumentsDoubleLong(); 11110 args.inV = arrayInV[i * 4 + j]; 11111 // Figure out what the outputs should have been. 11112 CoreMathVerifier.computeConvert(args); 11113 // Validate the outputs. 11114 boolean valid = true; 11115 if (args.out != arrayOut[i * 4 + j]) { 11116 valid = false; 11117 } 11118 if (!valid) { 11119 if (!errorFound) { 11120 errorFound = true; 11121 message.append("Input inV: "); 11122 appendVariableToMessage(message, args.inV); 11123 message.append("\n"); 11124 message.append("Expected output out: "); 11125 appendVariableToMessage(message, args.out); 11126 message.append("\n"); 11127 message.append("Actual output out: "); 11128 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11129 if (args.out != arrayOut[i * 4 + j]) { 11130 message.append(" FAIL"); 11131 } 11132 message.append("\n"); 11133 message.append("Errors at"); 11134 } 11135 message.append(" ["); 11136 message.append(Integer.toString(i)); 11137 message.append(", "); 11138 message.append(Integer.toString(j)); 11139 message.append("]"); 11140 } 11141 } 11142 } 11143 assertFalse("Incorrect output for checkConvertDouble4Long4" + 11144 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11145 } 11146 11147 public class ArgumentsLongLong { 11148 public long inV; 11149 public long out; 11150 } 11151 checkConvertLong2Long2()11152 private void checkConvertLong2Long2() { 11153 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc81d242al, true, 63); 11154 try { 11155 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11156 script.forEach_testConvertLong2Long2Long2(inV, out); 11157 verifyResultsConvertLong2Long2(inV, out, false); 11158 } catch (Exception e) { 11159 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString()); 11160 } 11161 try { 11162 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11163 scriptRelaxed.forEach_testConvertLong2Long2Long2(inV, out); 11164 verifyResultsConvertLong2Long2(inV, out, true); 11165 } catch (Exception e) { 11166 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString()); 11167 } 11168 } 11169 verifyResultsConvertLong2Long2(Allocation inV, Allocation out, boolean relaxed)11170 private void verifyResultsConvertLong2Long2(Allocation inV, Allocation out, boolean relaxed) { 11171 long[] arrayInV = new long[INPUTSIZE * 2]; 11172 Arrays.fill(arrayInV, (long) 42); 11173 inV.copyTo(arrayInV); 11174 long[] arrayOut = new long[INPUTSIZE * 2]; 11175 Arrays.fill(arrayOut, (long) 42); 11176 out.copyTo(arrayOut); 11177 StringBuilder message = new StringBuilder(); 11178 boolean errorFound = false; 11179 for (int i = 0; i < INPUTSIZE; i++) { 11180 for (int j = 0; j < 2 ; j++) { 11181 // Extract the inputs. 11182 ArgumentsLongLong args = new ArgumentsLongLong(); 11183 args.inV = arrayInV[i * 2 + j]; 11184 // Figure out what the outputs should have been. 11185 CoreMathVerifier.computeConvert(args); 11186 // Validate the outputs. 11187 boolean valid = true; 11188 if (args.out != arrayOut[i * 2 + j]) { 11189 valid = false; 11190 } 11191 if (!valid) { 11192 if (!errorFound) { 11193 errorFound = true; 11194 message.append("Input inV: "); 11195 appendVariableToMessage(message, args.inV); 11196 message.append("\n"); 11197 message.append("Expected output out: "); 11198 appendVariableToMessage(message, args.out); 11199 message.append("\n"); 11200 message.append("Actual output out: "); 11201 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11202 if (args.out != arrayOut[i * 2 + j]) { 11203 message.append(" FAIL"); 11204 } 11205 message.append("\n"); 11206 message.append("Errors at"); 11207 } 11208 message.append(" ["); 11209 message.append(Integer.toString(i)); 11210 message.append(", "); 11211 message.append(Integer.toString(j)); 11212 message.append("]"); 11213 } 11214 } 11215 } 11216 assertFalse("Incorrect output for checkConvertLong2Long2" + 11217 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11218 } 11219 checkConvertLong3Long3()11220 private void checkConvertLong3Long3() { 11221 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2724e91el, true, 63); 11222 try { 11223 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11224 script.forEach_testConvertLong3Long3Long3(inV, out); 11225 verifyResultsConvertLong3Long3(inV, out, false); 11226 } catch (Exception e) { 11227 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString()); 11228 } 11229 try { 11230 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11231 scriptRelaxed.forEach_testConvertLong3Long3Long3(inV, out); 11232 verifyResultsConvertLong3Long3(inV, out, true); 11233 } catch (Exception e) { 11234 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString()); 11235 } 11236 } 11237 verifyResultsConvertLong3Long3(Allocation inV, Allocation out, boolean relaxed)11238 private void verifyResultsConvertLong3Long3(Allocation inV, Allocation out, boolean relaxed) { 11239 long[] arrayInV = new long[INPUTSIZE * 4]; 11240 Arrays.fill(arrayInV, (long) 42); 11241 inV.copyTo(arrayInV); 11242 long[] arrayOut = new long[INPUTSIZE * 4]; 11243 Arrays.fill(arrayOut, (long) 42); 11244 out.copyTo(arrayOut); 11245 StringBuilder message = new StringBuilder(); 11246 boolean errorFound = false; 11247 for (int i = 0; i < INPUTSIZE; i++) { 11248 for (int j = 0; j < 3 ; j++) { 11249 // Extract the inputs. 11250 ArgumentsLongLong args = new ArgumentsLongLong(); 11251 args.inV = arrayInV[i * 4 + j]; 11252 // Figure out what the outputs should have been. 11253 CoreMathVerifier.computeConvert(args); 11254 // Validate the outputs. 11255 boolean valid = true; 11256 if (args.out != arrayOut[i * 4 + j]) { 11257 valid = false; 11258 } 11259 if (!valid) { 11260 if (!errorFound) { 11261 errorFound = true; 11262 message.append("Input inV: "); 11263 appendVariableToMessage(message, args.inV); 11264 message.append("\n"); 11265 message.append("Expected output out: "); 11266 appendVariableToMessage(message, args.out); 11267 message.append("\n"); 11268 message.append("Actual output out: "); 11269 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11270 if (args.out != arrayOut[i * 4 + j]) { 11271 message.append(" FAIL"); 11272 } 11273 message.append("\n"); 11274 message.append("Errors at"); 11275 } 11276 message.append(" ["); 11277 message.append(Integer.toString(i)); 11278 message.append(", "); 11279 message.append(Integer.toString(j)); 11280 message.append("]"); 11281 } 11282 } 11283 } 11284 assertFalse("Incorrect output for checkConvertLong3Long3" + 11285 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11286 } 11287 checkConvertLong4Long4()11288 private void checkConvertLong4Long4() { 11289 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x862cae12l, true, 63); 11290 try { 11291 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11292 script.forEach_testConvertLong4Long4Long4(inV, out); 11293 verifyResultsConvertLong4Long4(inV, out, false); 11294 } catch (Exception e) { 11295 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString()); 11296 } 11297 try { 11298 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11299 scriptRelaxed.forEach_testConvertLong4Long4Long4(inV, out); 11300 verifyResultsConvertLong4Long4(inV, out, true); 11301 } catch (Exception e) { 11302 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString()); 11303 } 11304 } 11305 verifyResultsConvertLong4Long4(Allocation inV, Allocation out, boolean relaxed)11306 private void verifyResultsConvertLong4Long4(Allocation inV, Allocation out, boolean relaxed) { 11307 long[] arrayInV = new long[INPUTSIZE * 4]; 11308 Arrays.fill(arrayInV, (long) 42); 11309 inV.copyTo(arrayInV); 11310 long[] arrayOut = new long[INPUTSIZE * 4]; 11311 Arrays.fill(arrayOut, (long) 42); 11312 out.copyTo(arrayOut); 11313 StringBuilder message = new StringBuilder(); 11314 boolean errorFound = false; 11315 for (int i = 0; i < INPUTSIZE; i++) { 11316 for (int j = 0; j < 4 ; j++) { 11317 // Extract the inputs. 11318 ArgumentsLongLong args = new ArgumentsLongLong(); 11319 args.inV = arrayInV[i * 4 + j]; 11320 // Figure out what the outputs should have been. 11321 CoreMathVerifier.computeConvert(args); 11322 // Validate the outputs. 11323 boolean valid = true; 11324 if (args.out != arrayOut[i * 4 + j]) { 11325 valid = false; 11326 } 11327 if (!valid) { 11328 if (!errorFound) { 11329 errorFound = true; 11330 message.append("Input inV: "); 11331 appendVariableToMessage(message, args.inV); 11332 message.append("\n"); 11333 message.append("Expected output out: "); 11334 appendVariableToMessage(message, args.out); 11335 message.append("\n"); 11336 message.append("Actual output out: "); 11337 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11338 if (args.out != arrayOut[i * 4 + j]) { 11339 message.append(" FAIL"); 11340 } 11341 message.append("\n"); 11342 message.append("Errors at"); 11343 } 11344 message.append(" ["); 11345 message.append(Integer.toString(i)); 11346 message.append(", "); 11347 message.append(Integer.toString(j)); 11348 message.append("]"); 11349 } 11350 } 11351 } 11352 assertFalse("Incorrect output for checkConvertLong4Long4" + 11353 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11354 } 11355 11356 public class ArgumentsUlongLong { 11357 public long inV; 11358 public long out; 11359 } 11360 checkConvertUlong2Long2()11361 private void checkConvertUlong2Long2() { 11362 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5a9f30abl, false, 63); 11363 try { 11364 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11365 script.forEach_testConvertLong2Ulong2Long2(inV, out); 11366 verifyResultsConvertUlong2Long2(inV, out, false); 11367 } catch (Exception e) { 11368 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString()); 11369 } 11370 try { 11371 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 11372 scriptRelaxed.forEach_testConvertLong2Ulong2Long2(inV, out); 11373 verifyResultsConvertUlong2Long2(inV, out, true); 11374 } catch (Exception e) { 11375 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString()); 11376 } 11377 } 11378 verifyResultsConvertUlong2Long2(Allocation inV, Allocation out, boolean relaxed)11379 private void verifyResultsConvertUlong2Long2(Allocation inV, Allocation out, boolean relaxed) { 11380 long[] arrayInV = new long[INPUTSIZE * 2]; 11381 Arrays.fill(arrayInV, (long) 42); 11382 inV.copyTo(arrayInV); 11383 long[] arrayOut = new long[INPUTSIZE * 2]; 11384 Arrays.fill(arrayOut, (long) 42); 11385 out.copyTo(arrayOut); 11386 StringBuilder message = new StringBuilder(); 11387 boolean errorFound = false; 11388 for (int i = 0; i < INPUTSIZE; i++) { 11389 for (int j = 0; j < 2 ; j++) { 11390 // Extract the inputs. 11391 ArgumentsUlongLong args = new ArgumentsUlongLong(); 11392 args.inV = arrayInV[i * 2 + j]; 11393 // Figure out what the outputs should have been. 11394 CoreMathVerifier.computeConvert(args); 11395 // Validate the outputs. 11396 boolean valid = true; 11397 if (args.out != arrayOut[i * 2 + j]) { 11398 valid = false; 11399 } 11400 if (!valid) { 11401 if (!errorFound) { 11402 errorFound = true; 11403 message.append("Input inV: "); 11404 appendVariableToMessage(message, args.inV); 11405 message.append("\n"); 11406 message.append("Expected output out: "); 11407 appendVariableToMessage(message, args.out); 11408 message.append("\n"); 11409 message.append("Actual output out: "); 11410 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11411 if (args.out != arrayOut[i * 2 + j]) { 11412 message.append(" FAIL"); 11413 } 11414 message.append("\n"); 11415 message.append("Errors at"); 11416 } 11417 message.append(" ["); 11418 message.append(Integer.toString(i)); 11419 message.append(", "); 11420 message.append(Integer.toString(j)); 11421 message.append("]"); 11422 } 11423 } 11424 } 11425 assertFalse("Incorrect output for checkConvertUlong2Long2" + 11426 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11427 } 11428 checkConvertUlong3Long3()11429 private void checkConvertUlong3Long3() { 11430 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xb9a6f59fl, false, 63); 11431 try { 11432 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11433 script.forEach_testConvertLong3Ulong3Long3(inV, out); 11434 verifyResultsConvertUlong3Long3(inV, out, false); 11435 } catch (Exception e) { 11436 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString()); 11437 } 11438 try { 11439 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 11440 scriptRelaxed.forEach_testConvertLong3Ulong3Long3(inV, out); 11441 verifyResultsConvertUlong3Long3(inV, out, true); 11442 } catch (Exception e) { 11443 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString()); 11444 } 11445 } 11446 verifyResultsConvertUlong3Long3(Allocation inV, Allocation out, boolean relaxed)11447 private void verifyResultsConvertUlong3Long3(Allocation inV, Allocation out, boolean relaxed) { 11448 long[] arrayInV = new long[INPUTSIZE * 4]; 11449 Arrays.fill(arrayInV, (long) 42); 11450 inV.copyTo(arrayInV); 11451 long[] arrayOut = new long[INPUTSIZE * 4]; 11452 Arrays.fill(arrayOut, (long) 42); 11453 out.copyTo(arrayOut); 11454 StringBuilder message = new StringBuilder(); 11455 boolean errorFound = false; 11456 for (int i = 0; i < INPUTSIZE; i++) { 11457 for (int j = 0; j < 3 ; j++) { 11458 // Extract the inputs. 11459 ArgumentsUlongLong args = new ArgumentsUlongLong(); 11460 args.inV = arrayInV[i * 4 + j]; 11461 // Figure out what the outputs should have been. 11462 CoreMathVerifier.computeConvert(args); 11463 // Validate the outputs. 11464 boolean valid = true; 11465 if (args.out != arrayOut[i * 4 + j]) { 11466 valid = false; 11467 } 11468 if (!valid) { 11469 if (!errorFound) { 11470 errorFound = true; 11471 message.append("Input inV: "); 11472 appendVariableToMessage(message, args.inV); 11473 message.append("\n"); 11474 message.append("Expected output out: "); 11475 appendVariableToMessage(message, args.out); 11476 message.append("\n"); 11477 message.append("Actual output out: "); 11478 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11479 if (args.out != arrayOut[i * 4 + j]) { 11480 message.append(" FAIL"); 11481 } 11482 message.append("\n"); 11483 message.append("Errors at"); 11484 } 11485 message.append(" ["); 11486 message.append(Integer.toString(i)); 11487 message.append(", "); 11488 message.append(Integer.toString(j)); 11489 message.append("]"); 11490 } 11491 } 11492 } 11493 assertFalse("Incorrect output for checkConvertUlong3Long3" + 11494 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11495 } 11496 checkConvertUlong4Long4()11497 private void checkConvertUlong4Long4() { 11498 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x18aeba93l, false, 63); 11499 try { 11500 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11501 script.forEach_testConvertLong4Ulong4Long4(inV, out); 11502 verifyResultsConvertUlong4Long4(inV, out, false); 11503 } catch (Exception e) { 11504 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString()); 11505 } 11506 try { 11507 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 11508 scriptRelaxed.forEach_testConvertLong4Ulong4Long4(inV, out); 11509 verifyResultsConvertUlong4Long4(inV, out, true); 11510 } catch (Exception e) { 11511 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString()); 11512 } 11513 } 11514 verifyResultsConvertUlong4Long4(Allocation inV, Allocation out, boolean relaxed)11515 private void verifyResultsConvertUlong4Long4(Allocation inV, Allocation out, boolean relaxed) { 11516 long[] arrayInV = new long[INPUTSIZE * 4]; 11517 Arrays.fill(arrayInV, (long) 42); 11518 inV.copyTo(arrayInV); 11519 long[] arrayOut = new long[INPUTSIZE * 4]; 11520 Arrays.fill(arrayOut, (long) 42); 11521 out.copyTo(arrayOut); 11522 StringBuilder message = new StringBuilder(); 11523 boolean errorFound = false; 11524 for (int i = 0; i < INPUTSIZE; i++) { 11525 for (int j = 0; j < 4 ; j++) { 11526 // Extract the inputs. 11527 ArgumentsUlongLong args = new ArgumentsUlongLong(); 11528 args.inV = arrayInV[i * 4 + j]; 11529 // Figure out what the outputs should have been. 11530 CoreMathVerifier.computeConvert(args); 11531 // Validate the outputs. 11532 boolean valid = true; 11533 if (args.out != arrayOut[i * 4 + j]) { 11534 valid = false; 11535 } 11536 if (!valid) { 11537 if (!errorFound) { 11538 errorFound = true; 11539 message.append("Input inV: "); 11540 appendVariableToMessage(message, args.inV); 11541 message.append("\n"); 11542 message.append("Expected output out: "); 11543 appendVariableToMessage(message, args.out); 11544 message.append("\n"); 11545 message.append("Actual output out: "); 11546 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11547 if (args.out != arrayOut[i * 4 + j]) { 11548 message.append(" FAIL"); 11549 } 11550 message.append("\n"); 11551 message.append("Errors at"); 11552 } 11553 message.append(" ["); 11554 message.append(Integer.toString(i)); 11555 message.append(", "); 11556 message.append(Integer.toString(j)); 11557 message.append("]"); 11558 } 11559 } 11560 } 11561 assertFalse("Incorrect output for checkConvertUlong4Long4" + 11562 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11563 } 11564 11565 public class ArgumentsDoubleUlong { 11566 public double inV; 11567 public long out; 11568 } 11569 checkConvertDouble2Ulong2()11570 private void checkConvertDouble2Ulong2() { 11571 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7e12ff5el, 0.0000000000000000000e+00, 1.8446744073709549568e+19); 11572 try { 11573 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 11574 script.forEach_testConvertUlong2Double2Ulong2(inV, out); 11575 verifyResultsConvertDouble2Ulong2(inV, out, false); 11576 } catch (Exception e) { 11577 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString()); 11578 } 11579 try { 11580 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 11581 scriptRelaxed.forEach_testConvertUlong2Double2Ulong2(inV, out); 11582 verifyResultsConvertDouble2Ulong2(inV, out, true); 11583 } catch (Exception e) { 11584 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString()); 11585 } 11586 } 11587 verifyResultsConvertDouble2Ulong2(Allocation inV, Allocation out, boolean relaxed)11588 private void verifyResultsConvertDouble2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 11589 double[] arrayInV = new double[INPUTSIZE * 2]; 11590 Arrays.fill(arrayInV, (double) 42); 11591 inV.copyTo(arrayInV); 11592 long[] arrayOut = new long[INPUTSIZE * 2]; 11593 Arrays.fill(arrayOut, (long) 42); 11594 out.copyTo(arrayOut); 11595 StringBuilder message = new StringBuilder(); 11596 boolean errorFound = false; 11597 for (int i = 0; i < INPUTSIZE; i++) { 11598 for (int j = 0; j < 2 ; j++) { 11599 // Extract the inputs. 11600 ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); 11601 args.inV = arrayInV[i * 2 + j]; 11602 // Figure out what the outputs should have been. 11603 CoreMathVerifier.computeConvert(args); 11604 // Validate the outputs. 11605 boolean valid = true; 11606 if (args.out != arrayOut[i * 2 + j]) { 11607 valid = false; 11608 } 11609 if (!valid) { 11610 if (!errorFound) { 11611 errorFound = true; 11612 message.append("Input inV: "); 11613 appendVariableToMessage(message, args.inV); 11614 message.append("\n"); 11615 message.append("Expected output out: "); 11616 appendVariableToMessage(message, args.out); 11617 message.append("\n"); 11618 message.append("Actual output out: "); 11619 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11620 if (args.out != arrayOut[i * 2 + j]) { 11621 message.append(" FAIL"); 11622 } 11623 message.append("\n"); 11624 message.append("Errors at"); 11625 } 11626 message.append(" ["); 11627 message.append(Integer.toString(i)); 11628 message.append(", "); 11629 message.append(Integer.toString(j)); 11630 message.append("]"); 11631 } 11632 } 11633 } 11634 assertFalse("Incorrect output for checkConvertDouble2Ulong2" + 11635 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11636 } 11637 checkConvertDouble3Ulong3()11638 private void checkConvertDouble3Ulong3() { 11639 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x742e203cl, 0.0000000000000000000e+00, 1.8446744073709549568e+19); 11640 try { 11641 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 11642 script.forEach_testConvertUlong3Double3Ulong3(inV, out); 11643 verifyResultsConvertDouble3Ulong3(inV, out, false); 11644 } catch (Exception e) { 11645 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString()); 11646 } 11647 try { 11648 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 11649 scriptRelaxed.forEach_testConvertUlong3Double3Ulong3(inV, out); 11650 verifyResultsConvertDouble3Ulong3(inV, out, true); 11651 } catch (Exception e) { 11652 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString()); 11653 } 11654 } 11655 verifyResultsConvertDouble3Ulong3(Allocation inV, Allocation out, boolean relaxed)11656 private void verifyResultsConvertDouble3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 11657 double[] arrayInV = new double[INPUTSIZE * 4]; 11658 Arrays.fill(arrayInV, (double) 42); 11659 inV.copyTo(arrayInV); 11660 long[] arrayOut = new long[INPUTSIZE * 4]; 11661 Arrays.fill(arrayOut, (long) 42); 11662 out.copyTo(arrayOut); 11663 StringBuilder message = new StringBuilder(); 11664 boolean errorFound = false; 11665 for (int i = 0; i < INPUTSIZE; i++) { 11666 for (int j = 0; j < 3 ; j++) { 11667 // Extract the inputs. 11668 ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); 11669 args.inV = arrayInV[i * 4 + j]; 11670 // Figure out what the outputs should have been. 11671 CoreMathVerifier.computeConvert(args); 11672 // Validate the outputs. 11673 boolean valid = true; 11674 if (args.out != arrayOut[i * 4 + j]) { 11675 valid = false; 11676 } 11677 if (!valid) { 11678 if (!errorFound) { 11679 errorFound = true; 11680 message.append("Input inV: "); 11681 appendVariableToMessage(message, args.inV); 11682 message.append("\n"); 11683 message.append("Expected output out: "); 11684 appendVariableToMessage(message, args.out); 11685 message.append("\n"); 11686 message.append("Actual output out: "); 11687 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11688 if (args.out != arrayOut[i * 4 + j]) { 11689 message.append(" FAIL"); 11690 } 11691 message.append("\n"); 11692 message.append("Errors at"); 11693 } 11694 message.append(" ["); 11695 message.append(Integer.toString(i)); 11696 message.append(", "); 11697 message.append(Integer.toString(j)); 11698 message.append("]"); 11699 } 11700 } 11701 } 11702 assertFalse("Incorrect output for checkConvertDouble3Ulong3" + 11703 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11704 } 11705 checkConvertDouble4Ulong4()11706 private void checkConvertDouble4Ulong4() { 11707 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x6a49411al, 0.0000000000000000000e+00, 1.8446744073709549568e+19); 11708 try { 11709 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 11710 script.forEach_testConvertUlong4Double4Ulong4(inV, out); 11711 verifyResultsConvertDouble4Ulong4(inV, out, false); 11712 } catch (Exception e) { 11713 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString()); 11714 } 11715 try { 11716 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 11717 scriptRelaxed.forEach_testConvertUlong4Double4Ulong4(inV, out); 11718 verifyResultsConvertDouble4Ulong4(inV, out, true); 11719 } catch (Exception e) { 11720 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString()); 11721 } 11722 } 11723 verifyResultsConvertDouble4Ulong4(Allocation inV, Allocation out, boolean relaxed)11724 private void verifyResultsConvertDouble4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 11725 double[] arrayInV = new double[INPUTSIZE * 4]; 11726 Arrays.fill(arrayInV, (double) 42); 11727 inV.copyTo(arrayInV); 11728 long[] arrayOut = new long[INPUTSIZE * 4]; 11729 Arrays.fill(arrayOut, (long) 42); 11730 out.copyTo(arrayOut); 11731 StringBuilder message = new StringBuilder(); 11732 boolean errorFound = false; 11733 for (int i = 0; i < INPUTSIZE; i++) { 11734 for (int j = 0; j < 4 ; j++) { 11735 // Extract the inputs. 11736 ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); 11737 args.inV = arrayInV[i * 4 + j]; 11738 // Figure out what the outputs should have been. 11739 CoreMathVerifier.computeConvert(args); 11740 // Validate the outputs. 11741 boolean valid = true; 11742 if (args.out != arrayOut[i * 4 + j]) { 11743 valid = false; 11744 } 11745 if (!valid) { 11746 if (!errorFound) { 11747 errorFound = true; 11748 message.append("Input inV: "); 11749 appendVariableToMessage(message, args.inV); 11750 message.append("\n"); 11751 message.append("Expected output out: "); 11752 appendVariableToMessage(message, args.out); 11753 message.append("\n"); 11754 message.append("Actual output out: "); 11755 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11756 if (args.out != arrayOut[i * 4 + j]) { 11757 message.append(" FAIL"); 11758 } 11759 message.append("\n"); 11760 message.append("Errors at"); 11761 } 11762 message.append(" ["); 11763 message.append(Integer.toString(i)); 11764 message.append(", "); 11765 message.append(Integer.toString(j)); 11766 message.append("]"); 11767 } 11768 } 11769 } 11770 assertFalse("Incorrect output for checkConvertDouble4Ulong4" + 11771 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11772 } 11773 11774 public class ArgumentsLongUlong { 11775 public long inV; 11776 public long out; 11777 } 11778 checkConvertLong2Ulong2()11779 private void checkConvertLong2Ulong2() { 11780 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xd7d40f65l, false, 63); 11781 try { 11782 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 11783 script.forEach_testConvertUlong2Long2Ulong2(inV, out); 11784 verifyResultsConvertLong2Ulong2(inV, out, false); 11785 } catch (Exception e) { 11786 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString()); 11787 } 11788 try { 11789 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 11790 scriptRelaxed.forEach_testConvertUlong2Long2Ulong2(inV, out); 11791 verifyResultsConvertLong2Ulong2(inV, out, true); 11792 } catch (Exception e) { 11793 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString()); 11794 } 11795 } 11796 verifyResultsConvertLong2Ulong2(Allocation inV, Allocation out, boolean relaxed)11797 private void verifyResultsConvertLong2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 11798 long[] arrayInV = new long[INPUTSIZE * 2]; 11799 Arrays.fill(arrayInV, (long) 42); 11800 inV.copyTo(arrayInV); 11801 long[] arrayOut = new long[INPUTSIZE * 2]; 11802 Arrays.fill(arrayOut, (long) 42); 11803 out.copyTo(arrayOut); 11804 StringBuilder message = new StringBuilder(); 11805 boolean errorFound = false; 11806 for (int i = 0; i < INPUTSIZE; i++) { 11807 for (int j = 0; j < 2 ; j++) { 11808 // Extract the inputs. 11809 ArgumentsLongUlong args = new ArgumentsLongUlong(); 11810 args.inV = arrayInV[i * 2 + j]; 11811 // Figure out what the outputs should have been. 11812 CoreMathVerifier.computeConvert(args); 11813 // Validate the outputs. 11814 boolean valid = true; 11815 if (args.out != arrayOut[i * 2 + j]) { 11816 valid = false; 11817 } 11818 if (!valid) { 11819 if (!errorFound) { 11820 errorFound = true; 11821 message.append("Input inV: "); 11822 appendVariableToMessage(message, args.inV); 11823 message.append("\n"); 11824 message.append("Expected output out: "); 11825 appendVariableToMessage(message, args.out); 11826 message.append("\n"); 11827 message.append("Actual output out: "); 11828 appendVariableToMessage(message, arrayOut[i * 2 + j]); 11829 if (args.out != arrayOut[i * 2 + j]) { 11830 message.append(" FAIL"); 11831 } 11832 message.append("\n"); 11833 message.append("Errors at"); 11834 } 11835 message.append(" ["); 11836 message.append(Integer.toString(i)); 11837 message.append(", "); 11838 message.append(Integer.toString(j)); 11839 message.append("]"); 11840 } 11841 } 11842 } 11843 assertFalse("Incorrect output for checkConvertLong2Ulong2" + 11844 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11845 } 11846 checkConvertLong3Ulong3()11847 private void checkConvertLong3Ulong3() { 11848 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcdef3043l, false, 63); 11849 try { 11850 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 11851 script.forEach_testConvertUlong3Long3Ulong3(inV, out); 11852 verifyResultsConvertLong3Ulong3(inV, out, false); 11853 } catch (Exception e) { 11854 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString()); 11855 } 11856 try { 11857 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 11858 scriptRelaxed.forEach_testConvertUlong3Long3Ulong3(inV, out); 11859 verifyResultsConvertLong3Ulong3(inV, out, true); 11860 } catch (Exception e) { 11861 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString()); 11862 } 11863 } 11864 verifyResultsConvertLong3Ulong3(Allocation inV, Allocation out, boolean relaxed)11865 private void verifyResultsConvertLong3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 11866 long[] arrayInV = new long[INPUTSIZE * 4]; 11867 Arrays.fill(arrayInV, (long) 42); 11868 inV.copyTo(arrayInV); 11869 long[] arrayOut = new long[INPUTSIZE * 4]; 11870 Arrays.fill(arrayOut, (long) 42); 11871 out.copyTo(arrayOut); 11872 StringBuilder message = new StringBuilder(); 11873 boolean errorFound = false; 11874 for (int i = 0; i < INPUTSIZE; i++) { 11875 for (int j = 0; j < 3 ; j++) { 11876 // Extract the inputs. 11877 ArgumentsLongUlong args = new ArgumentsLongUlong(); 11878 args.inV = arrayInV[i * 4 + j]; 11879 // Figure out what the outputs should have been. 11880 CoreMathVerifier.computeConvert(args); 11881 // Validate the outputs. 11882 boolean valid = true; 11883 if (args.out != arrayOut[i * 4 + j]) { 11884 valid = false; 11885 } 11886 if (!valid) { 11887 if (!errorFound) { 11888 errorFound = true; 11889 message.append("Input inV: "); 11890 appendVariableToMessage(message, args.inV); 11891 message.append("\n"); 11892 message.append("Expected output out: "); 11893 appendVariableToMessage(message, args.out); 11894 message.append("\n"); 11895 message.append("Actual output out: "); 11896 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11897 if (args.out != arrayOut[i * 4 + j]) { 11898 message.append(" FAIL"); 11899 } 11900 message.append("\n"); 11901 message.append("Errors at"); 11902 } 11903 message.append(" ["); 11904 message.append(Integer.toString(i)); 11905 message.append(", "); 11906 message.append(Integer.toString(j)); 11907 message.append("]"); 11908 } 11909 } 11910 } 11911 assertFalse("Incorrect output for checkConvertLong3Ulong3" + 11912 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11913 } 11914 checkConvertLong4Ulong4()11915 private void checkConvertLong4Ulong4() { 11916 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xc40a5121l, false, 63); 11917 try { 11918 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 11919 script.forEach_testConvertUlong4Long4Ulong4(inV, out); 11920 verifyResultsConvertLong4Ulong4(inV, out, false); 11921 } catch (Exception e) { 11922 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString()); 11923 } 11924 try { 11925 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 11926 scriptRelaxed.forEach_testConvertUlong4Long4Ulong4(inV, out); 11927 verifyResultsConvertLong4Ulong4(inV, out, true); 11928 } catch (Exception e) { 11929 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString()); 11930 } 11931 } 11932 verifyResultsConvertLong4Ulong4(Allocation inV, Allocation out, boolean relaxed)11933 private void verifyResultsConvertLong4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 11934 long[] arrayInV = new long[INPUTSIZE * 4]; 11935 Arrays.fill(arrayInV, (long) 42); 11936 inV.copyTo(arrayInV); 11937 long[] arrayOut = new long[INPUTSIZE * 4]; 11938 Arrays.fill(arrayOut, (long) 42); 11939 out.copyTo(arrayOut); 11940 StringBuilder message = new StringBuilder(); 11941 boolean errorFound = false; 11942 for (int i = 0; i < INPUTSIZE; i++) { 11943 for (int j = 0; j < 4 ; j++) { 11944 // Extract the inputs. 11945 ArgumentsLongUlong args = new ArgumentsLongUlong(); 11946 args.inV = arrayInV[i * 4 + j]; 11947 // Figure out what the outputs should have been. 11948 CoreMathVerifier.computeConvert(args); 11949 // Validate the outputs. 11950 boolean valid = true; 11951 if (args.out != arrayOut[i * 4 + j]) { 11952 valid = false; 11953 } 11954 if (!valid) { 11955 if (!errorFound) { 11956 errorFound = true; 11957 message.append("Input inV: "); 11958 appendVariableToMessage(message, args.inV); 11959 message.append("\n"); 11960 message.append("Expected output out: "); 11961 appendVariableToMessage(message, args.out); 11962 message.append("\n"); 11963 message.append("Actual output out: "); 11964 appendVariableToMessage(message, arrayOut[i * 4 + j]); 11965 if (args.out != arrayOut[i * 4 + j]) { 11966 message.append(" FAIL"); 11967 } 11968 message.append("\n"); 11969 message.append("Errors at"); 11970 } 11971 message.append(" ["); 11972 message.append(Integer.toString(i)); 11973 message.append(", "); 11974 message.append(Integer.toString(j)); 11975 message.append("]"); 11976 } 11977 } 11978 } 11979 assertFalse("Incorrect output for checkConvertLong4Ulong4" + 11980 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 11981 } 11982 11983 public class ArgumentsUlongUlong { 11984 public long inV; 11985 public long out; 11986 } 11987 checkConvertUlong2Ulong2()11988 private void checkConvertUlong2Ulong2() { 11989 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x73ac2910l, false, 64); 11990 try { 11991 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 11992 script.forEach_testConvertUlong2Ulong2Ulong2(inV, out); 11993 verifyResultsConvertUlong2Ulong2(inV, out, false); 11994 } catch (Exception e) { 11995 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString()); 11996 } 11997 try { 11998 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 11999 scriptRelaxed.forEach_testConvertUlong2Ulong2Ulong2(inV, out); 12000 verifyResultsConvertUlong2Ulong2(inV, out, true); 12001 } catch (Exception e) { 12002 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString()); 12003 } 12004 } 12005 verifyResultsConvertUlong2Ulong2(Allocation inV, Allocation out, boolean relaxed)12006 private void verifyResultsConvertUlong2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 12007 long[] arrayInV = new long[INPUTSIZE * 2]; 12008 Arrays.fill(arrayInV, (long) 42); 12009 inV.copyTo(arrayInV); 12010 long[] arrayOut = new long[INPUTSIZE * 2]; 12011 Arrays.fill(arrayOut, (long) 42); 12012 out.copyTo(arrayOut); 12013 StringBuilder message = new StringBuilder(); 12014 boolean errorFound = false; 12015 for (int i = 0; i < INPUTSIZE; i++) { 12016 for (int j = 0; j < 2 ; j++) { 12017 // Extract the inputs. 12018 ArgumentsUlongUlong args = new ArgumentsUlongUlong(); 12019 args.inV = arrayInV[i * 2 + j]; 12020 // Figure out what the outputs should have been. 12021 CoreMathVerifier.computeConvert(args); 12022 // Validate the outputs. 12023 boolean valid = true; 12024 if (args.out != arrayOut[i * 2 + j]) { 12025 valid = false; 12026 } 12027 if (!valid) { 12028 if (!errorFound) { 12029 errorFound = true; 12030 message.append("Input inV: "); 12031 appendVariableToMessage(message, args.inV); 12032 message.append("\n"); 12033 message.append("Expected output out: "); 12034 appendVariableToMessage(message, args.out); 12035 message.append("\n"); 12036 message.append("Actual output out: "); 12037 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12038 if (args.out != arrayOut[i * 2 + j]) { 12039 message.append(" FAIL"); 12040 } 12041 message.append("\n"); 12042 message.append("Errors at"); 12043 } 12044 message.append(" ["); 12045 message.append(Integer.toString(i)); 12046 message.append(", "); 12047 message.append(Integer.toString(j)); 12048 message.append("]"); 12049 } 12050 } 12051 } 12052 assertFalse("Incorrect output for checkConvertUlong2Ulong2" + 12053 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12054 } 12055 checkConvertUlong3Ulong3()12056 private void checkConvertUlong3Ulong3() { 12057 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x69c749eel, false, 64); 12058 try { 12059 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12060 script.forEach_testConvertUlong3Ulong3Ulong3(inV, out); 12061 verifyResultsConvertUlong3Ulong3(inV, out, false); 12062 } catch (Exception e) { 12063 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString()); 12064 } 12065 try { 12066 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 12067 scriptRelaxed.forEach_testConvertUlong3Ulong3Ulong3(inV, out); 12068 verifyResultsConvertUlong3Ulong3(inV, out, true); 12069 } catch (Exception e) { 12070 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString()); 12071 } 12072 } 12073 verifyResultsConvertUlong3Ulong3(Allocation inV, Allocation out, boolean relaxed)12074 private void verifyResultsConvertUlong3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 12075 long[] arrayInV = new long[INPUTSIZE * 4]; 12076 Arrays.fill(arrayInV, (long) 42); 12077 inV.copyTo(arrayInV); 12078 long[] arrayOut = new long[INPUTSIZE * 4]; 12079 Arrays.fill(arrayOut, (long) 42); 12080 out.copyTo(arrayOut); 12081 StringBuilder message = new StringBuilder(); 12082 boolean errorFound = false; 12083 for (int i = 0; i < INPUTSIZE; i++) { 12084 for (int j = 0; j < 3 ; j++) { 12085 // Extract the inputs. 12086 ArgumentsUlongUlong args = new ArgumentsUlongUlong(); 12087 args.inV = arrayInV[i * 4 + j]; 12088 // Figure out what the outputs should have been. 12089 CoreMathVerifier.computeConvert(args); 12090 // Validate the outputs. 12091 boolean valid = true; 12092 if (args.out != arrayOut[i * 4 + j]) { 12093 valid = false; 12094 } 12095 if (!valid) { 12096 if (!errorFound) { 12097 errorFound = true; 12098 message.append("Input inV: "); 12099 appendVariableToMessage(message, args.inV); 12100 message.append("\n"); 12101 message.append("Expected output out: "); 12102 appendVariableToMessage(message, args.out); 12103 message.append("\n"); 12104 message.append("Actual output out: "); 12105 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12106 if (args.out != arrayOut[i * 4 + j]) { 12107 message.append(" FAIL"); 12108 } 12109 message.append("\n"); 12110 message.append("Errors at"); 12111 } 12112 message.append(" ["); 12113 message.append(Integer.toString(i)); 12114 message.append(", "); 12115 message.append(Integer.toString(j)); 12116 message.append("]"); 12117 } 12118 } 12119 } 12120 assertFalse("Incorrect output for checkConvertUlong3Ulong3" + 12121 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12122 } 12123 checkConvertUlong4Ulong4()12124 private void checkConvertUlong4Ulong4() { 12125 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5fe26accl, false, 64); 12126 try { 12127 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12128 script.forEach_testConvertUlong4Ulong4Ulong4(inV, out); 12129 verifyResultsConvertUlong4Ulong4(inV, out, false); 12130 } catch (Exception e) { 12131 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString()); 12132 } 12133 try { 12134 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 12135 scriptRelaxed.forEach_testConvertUlong4Ulong4Ulong4(inV, out); 12136 verifyResultsConvertUlong4Ulong4(inV, out, true); 12137 } catch (Exception e) { 12138 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString()); 12139 } 12140 } 12141 verifyResultsConvertUlong4Ulong4(Allocation inV, Allocation out, boolean relaxed)12142 private void verifyResultsConvertUlong4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 12143 long[] arrayInV = new long[INPUTSIZE * 4]; 12144 Arrays.fill(arrayInV, (long) 42); 12145 inV.copyTo(arrayInV); 12146 long[] arrayOut = new long[INPUTSIZE * 4]; 12147 Arrays.fill(arrayOut, (long) 42); 12148 out.copyTo(arrayOut); 12149 StringBuilder message = new StringBuilder(); 12150 boolean errorFound = false; 12151 for (int i = 0; i < INPUTSIZE; i++) { 12152 for (int j = 0; j < 4 ; j++) { 12153 // Extract the inputs. 12154 ArgumentsUlongUlong args = new ArgumentsUlongUlong(); 12155 args.inV = arrayInV[i * 4 + j]; 12156 // Figure out what the outputs should have been. 12157 CoreMathVerifier.computeConvert(args); 12158 // Validate the outputs. 12159 boolean valid = true; 12160 if (args.out != arrayOut[i * 4 + j]) { 12161 valid = false; 12162 } 12163 if (!valid) { 12164 if (!errorFound) { 12165 errorFound = true; 12166 message.append("Input inV: "); 12167 appendVariableToMessage(message, args.inV); 12168 message.append("\n"); 12169 message.append("Expected output out: "); 12170 appendVariableToMessage(message, args.out); 12171 message.append("\n"); 12172 message.append("Actual output out: "); 12173 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12174 if (args.out != arrayOut[i * 4 + j]) { 12175 message.append(" FAIL"); 12176 } 12177 message.append("\n"); 12178 message.append("Errors at"); 12179 } 12180 message.append(" ["); 12181 message.append(Integer.toString(i)); 12182 message.append(", "); 12183 message.append(Integer.toString(j)); 12184 message.append("]"); 12185 } 12186 } 12187 } 12188 assertFalse("Incorrect output for checkConvertUlong4Ulong4" + 12189 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12190 } 12191 12192 public class ArgumentsDoubleFloat { 12193 public double inV; 12194 public Target.Floaty out; 12195 } 12196 checkConvertDouble2Float2()12197 private void checkConvertDouble2Float2() { 12198 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7d6d9a2dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 12199 try { 12200 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12201 script.forEach_testConvertFloat2Double2Float2(inV, out); 12202 verifyResultsConvertDouble2Float2(inV, out, false); 12203 } catch (Exception e) { 12204 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString()); 12205 } 12206 try { 12207 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12208 scriptRelaxed.forEach_testConvertFloat2Double2Float2(inV, out); 12209 verifyResultsConvertDouble2Float2(inV, out, true); 12210 } catch (Exception e) { 12211 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString()); 12212 } 12213 } 12214 verifyResultsConvertDouble2Float2(Allocation inV, Allocation out, boolean relaxed)12215 private void verifyResultsConvertDouble2Float2(Allocation inV, Allocation out, boolean relaxed) { 12216 double[] arrayInV = new double[INPUTSIZE * 2]; 12217 Arrays.fill(arrayInV, (double) 42); 12218 inV.copyTo(arrayInV); 12219 float[] arrayOut = new float[INPUTSIZE * 2]; 12220 Arrays.fill(arrayOut, (float) 42); 12221 out.copyTo(arrayOut); 12222 StringBuilder message = new StringBuilder(); 12223 boolean errorFound = false; 12224 for (int i = 0; i < INPUTSIZE; i++) { 12225 for (int j = 0; j < 2 ; j++) { 12226 // Extract the inputs. 12227 ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); 12228 args.inV = arrayInV[i * 2 + j]; 12229 // Figure out what the outputs should have been. 12230 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12231 CoreMathVerifier.computeConvert(args, target); 12232 // Validate the outputs. 12233 boolean valid = true; 12234 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12235 valid = false; 12236 } 12237 if (!valid) { 12238 if (!errorFound) { 12239 errorFound = true; 12240 message.append("Input inV: "); 12241 appendVariableToMessage(message, args.inV); 12242 message.append("\n"); 12243 message.append("Expected output out: "); 12244 appendVariableToMessage(message, args.out); 12245 message.append("\n"); 12246 message.append("Actual output out: "); 12247 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12248 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12249 message.append(" FAIL"); 12250 } 12251 message.append("\n"); 12252 message.append("Errors at"); 12253 } 12254 message.append(" ["); 12255 message.append(Integer.toString(i)); 12256 message.append(", "); 12257 message.append(Integer.toString(j)); 12258 message.append("]"); 12259 } 12260 } 12261 } 12262 assertFalse("Incorrect output for checkConvertDouble2Float2" + 12263 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12264 } 12265 checkConvertDouble3Float3()12266 private void checkConvertDouble3Float3() { 12267 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x7388bb0bl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 12268 try { 12269 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12270 script.forEach_testConvertFloat3Double3Float3(inV, out); 12271 verifyResultsConvertDouble3Float3(inV, out, false); 12272 } catch (Exception e) { 12273 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString()); 12274 } 12275 try { 12276 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12277 scriptRelaxed.forEach_testConvertFloat3Double3Float3(inV, out); 12278 verifyResultsConvertDouble3Float3(inV, out, true); 12279 } catch (Exception e) { 12280 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString()); 12281 } 12282 } 12283 verifyResultsConvertDouble3Float3(Allocation inV, Allocation out, boolean relaxed)12284 private void verifyResultsConvertDouble3Float3(Allocation inV, Allocation out, boolean relaxed) { 12285 double[] arrayInV = new double[INPUTSIZE * 4]; 12286 Arrays.fill(arrayInV, (double) 42); 12287 inV.copyTo(arrayInV); 12288 float[] arrayOut = new float[INPUTSIZE * 4]; 12289 Arrays.fill(arrayOut, (float) 42); 12290 out.copyTo(arrayOut); 12291 StringBuilder message = new StringBuilder(); 12292 boolean errorFound = false; 12293 for (int i = 0; i < INPUTSIZE; i++) { 12294 for (int j = 0; j < 3 ; j++) { 12295 // Extract the inputs. 12296 ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); 12297 args.inV = arrayInV[i * 4 + j]; 12298 // Figure out what the outputs should have been. 12299 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12300 CoreMathVerifier.computeConvert(args, target); 12301 // Validate the outputs. 12302 boolean valid = true; 12303 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12304 valid = false; 12305 } 12306 if (!valid) { 12307 if (!errorFound) { 12308 errorFound = true; 12309 message.append("Input inV: "); 12310 appendVariableToMessage(message, args.inV); 12311 message.append("\n"); 12312 message.append("Expected output out: "); 12313 appendVariableToMessage(message, args.out); 12314 message.append("\n"); 12315 message.append("Actual output out: "); 12316 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12317 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12318 message.append(" FAIL"); 12319 } 12320 message.append("\n"); 12321 message.append("Errors at"); 12322 } 12323 message.append(" ["); 12324 message.append(Integer.toString(i)); 12325 message.append(", "); 12326 message.append(Integer.toString(j)); 12327 message.append("]"); 12328 } 12329 } 12330 } 12331 assertFalse("Incorrect output for checkConvertDouble3Float3" + 12332 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12333 } 12334 checkConvertDouble4Float4()12335 private void checkConvertDouble4Float4() { 12336 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x69a3dbe9l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 12337 try { 12338 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12339 script.forEach_testConvertFloat4Double4Float4(inV, out); 12340 verifyResultsConvertDouble4Float4(inV, out, false); 12341 } catch (Exception e) { 12342 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString()); 12343 } 12344 try { 12345 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12346 scriptRelaxed.forEach_testConvertFloat4Double4Float4(inV, out); 12347 verifyResultsConvertDouble4Float4(inV, out, true); 12348 } catch (Exception e) { 12349 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString()); 12350 } 12351 } 12352 verifyResultsConvertDouble4Float4(Allocation inV, Allocation out, boolean relaxed)12353 private void verifyResultsConvertDouble4Float4(Allocation inV, Allocation out, boolean relaxed) { 12354 double[] arrayInV = new double[INPUTSIZE * 4]; 12355 Arrays.fill(arrayInV, (double) 42); 12356 inV.copyTo(arrayInV); 12357 float[] arrayOut = new float[INPUTSIZE * 4]; 12358 Arrays.fill(arrayOut, (float) 42); 12359 out.copyTo(arrayOut); 12360 StringBuilder message = new StringBuilder(); 12361 boolean errorFound = false; 12362 for (int i = 0; i < INPUTSIZE; i++) { 12363 for (int j = 0; j < 4 ; j++) { 12364 // Extract the inputs. 12365 ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); 12366 args.inV = arrayInV[i * 4 + j]; 12367 // Figure out what the outputs should have been. 12368 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12369 CoreMathVerifier.computeConvert(args, target); 12370 // Validate the outputs. 12371 boolean valid = true; 12372 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12373 valid = false; 12374 } 12375 if (!valid) { 12376 if (!errorFound) { 12377 errorFound = true; 12378 message.append("Input inV: "); 12379 appendVariableToMessage(message, args.inV); 12380 message.append("\n"); 12381 message.append("Expected output out: "); 12382 appendVariableToMessage(message, args.out); 12383 message.append("\n"); 12384 message.append("Actual output out: "); 12385 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12386 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12387 message.append(" FAIL"); 12388 } 12389 message.append("\n"); 12390 message.append("Errors at"); 12391 } 12392 message.append(" ["); 12393 message.append(Integer.toString(i)); 12394 message.append(", "); 12395 message.append(Integer.toString(j)); 12396 message.append("]"); 12397 } 12398 } 12399 } 12400 assertFalse("Incorrect output for checkConvertDouble4Float4" + 12401 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12402 } 12403 12404 public class ArgumentsLongFloat { 12405 public long inV; 12406 public Target.Floaty out; 12407 } 12408 checkConvertLong2Float2()12409 private void checkConvertLong2Float2() { 12410 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xd72eaa34l, true, 63); 12411 try { 12412 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12413 script.forEach_testConvertFloat2Long2Float2(inV, out); 12414 verifyResultsConvertLong2Float2(inV, out, false); 12415 } catch (Exception e) { 12416 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString()); 12417 } 12418 try { 12419 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12420 scriptRelaxed.forEach_testConvertFloat2Long2Float2(inV, out); 12421 verifyResultsConvertLong2Float2(inV, out, true); 12422 } catch (Exception e) { 12423 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString()); 12424 } 12425 } 12426 verifyResultsConvertLong2Float2(Allocation inV, Allocation out, boolean relaxed)12427 private void verifyResultsConvertLong2Float2(Allocation inV, Allocation out, boolean relaxed) { 12428 long[] arrayInV = new long[INPUTSIZE * 2]; 12429 Arrays.fill(arrayInV, (long) 42); 12430 inV.copyTo(arrayInV); 12431 float[] arrayOut = new float[INPUTSIZE * 2]; 12432 Arrays.fill(arrayOut, (float) 42); 12433 out.copyTo(arrayOut); 12434 StringBuilder message = new StringBuilder(); 12435 boolean errorFound = false; 12436 for (int i = 0; i < INPUTSIZE; i++) { 12437 for (int j = 0; j < 2 ; j++) { 12438 // Extract the inputs. 12439 ArgumentsLongFloat args = new ArgumentsLongFloat(); 12440 args.inV = arrayInV[i * 2 + j]; 12441 // Figure out what the outputs should have been. 12442 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12443 CoreMathVerifier.computeConvert(args, target); 12444 // Validate the outputs. 12445 boolean valid = true; 12446 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12447 valid = false; 12448 } 12449 if (!valid) { 12450 if (!errorFound) { 12451 errorFound = true; 12452 message.append("Input inV: "); 12453 appendVariableToMessage(message, args.inV); 12454 message.append("\n"); 12455 message.append("Expected output out: "); 12456 appendVariableToMessage(message, args.out); 12457 message.append("\n"); 12458 message.append("Actual output out: "); 12459 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12460 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12461 message.append(" FAIL"); 12462 } 12463 message.append("\n"); 12464 message.append("Errors at"); 12465 } 12466 message.append(" ["); 12467 message.append(Integer.toString(i)); 12468 message.append(", "); 12469 message.append(Integer.toString(j)); 12470 message.append("]"); 12471 } 12472 } 12473 } 12474 assertFalse("Incorrect output for checkConvertLong2Float2" + 12475 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12476 } 12477 checkConvertLong3Float3()12478 private void checkConvertLong3Float3() { 12479 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcd49cb12l, true, 63); 12480 try { 12481 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12482 script.forEach_testConvertFloat3Long3Float3(inV, out); 12483 verifyResultsConvertLong3Float3(inV, out, false); 12484 } catch (Exception e) { 12485 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString()); 12486 } 12487 try { 12488 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12489 scriptRelaxed.forEach_testConvertFloat3Long3Float3(inV, out); 12490 verifyResultsConvertLong3Float3(inV, out, true); 12491 } catch (Exception e) { 12492 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString()); 12493 } 12494 } 12495 verifyResultsConvertLong3Float3(Allocation inV, Allocation out, boolean relaxed)12496 private void verifyResultsConvertLong3Float3(Allocation inV, Allocation out, boolean relaxed) { 12497 long[] arrayInV = new long[INPUTSIZE * 4]; 12498 Arrays.fill(arrayInV, (long) 42); 12499 inV.copyTo(arrayInV); 12500 float[] arrayOut = new float[INPUTSIZE * 4]; 12501 Arrays.fill(arrayOut, (float) 42); 12502 out.copyTo(arrayOut); 12503 StringBuilder message = new StringBuilder(); 12504 boolean errorFound = false; 12505 for (int i = 0; i < INPUTSIZE; i++) { 12506 for (int j = 0; j < 3 ; j++) { 12507 // Extract the inputs. 12508 ArgumentsLongFloat args = new ArgumentsLongFloat(); 12509 args.inV = arrayInV[i * 4 + j]; 12510 // Figure out what the outputs should have been. 12511 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12512 CoreMathVerifier.computeConvert(args, target); 12513 // Validate the outputs. 12514 boolean valid = true; 12515 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12516 valid = false; 12517 } 12518 if (!valid) { 12519 if (!errorFound) { 12520 errorFound = true; 12521 message.append("Input inV: "); 12522 appendVariableToMessage(message, args.inV); 12523 message.append("\n"); 12524 message.append("Expected output out: "); 12525 appendVariableToMessage(message, args.out); 12526 message.append("\n"); 12527 message.append("Actual output out: "); 12528 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12529 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12530 message.append(" FAIL"); 12531 } 12532 message.append("\n"); 12533 message.append("Errors at"); 12534 } 12535 message.append(" ["); 12536 message.append(Integer.toString(i)); 12537 message.append(", "); 12538 message.append(Integer.toString(j)); 12539 message.append("]"); 12540 } 12541 } 12542 } 12543 assertFalse("Incorrect output for checkConvertLong3Float3" + 12544 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12545 } 12546 checkConvertLong4Float4()12547 private void checkConvertLong4Float4() { 12548 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xc364ebf0l, true, 63); 12549 try { 12550 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12551 script.forEach_testConvertFloat4Long4Float4(inV, out); 12552 verifyResultsConvertLong4Float4(inV, out, false); 12553 } catch (Exception e) { 12554 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString()); 12555 } 12556 try { 12557 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12558 scriptRelaxed.forEach_testConvertFloat4Long4Float4(inV, out); 12559 verifyResultsConvertLong4Float4(inV, out, true); 12560 } catch (Exception e) { 12561 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString()); 12562 } 12563 } 12564 verifyResultsConvertLong4Float4(Allocation inV, Allocation out, boolean relaxed)12565 private void verifyResultsConvertLong4Float4(Allocation inV, Allocation out, boolean relaxed) { 12566 long[] arrayInV = new long[INPUTSIZE * 4]; 12567 Arrays.fill(arrayInV, (long) 42); 12568 inV.copyTo(arrayInV); 12569 float[] arrayOut = new float[INPUTSIZE * 4]; 12570 Arrays.fill(arrayOut, (float) 42); 12571 out.copyTo(arrayOut); 12572 StringBuilder message = new StringBuilder(); 12573 boolean errorFound = false; 12574 for (int i = 0; i < INPUTSIZE; i++) { 12575 for (int j = 0; j < 4 ; j++) { 12576 // Extract the inputs. 12577 ArgumentsLongFloat args = new ArgumentsLongFloat(); 12578 args.inV = arrayInV[i * 4 + j]; 12579 // Figure out what the outputs should have been. 12580 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12581 CoreMathVerifier.computeConvert(args, target); 12582 // Validate the outputs. 12583 boolean valid = true; 12584 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12585 valid = false; 12586 } 12587 if (!valid) { 12588 if (!errorFound) { 12589 errorFound = true; 12590 message.append("Input inV: "); 12591 appendVariableToMessage(message, args.inV); 12592 message.append("\n"); 12593 message.append("Expected output out: "); 12594 appendVariableToMessage(message, args.out); 12595 message.append("\n"); 12596 message.append("Actual output out: "); 12597 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12598 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12599 message.append(" FAIL"); 12600 } 12601 message.append("\n"); 12602 message.append("Errors at"); 12603 } 12604 message.append(" ["); 12605 message.append(Integer.toString(i)); 12606 message.append(", "); 12607 message.append(Integer.toString(j)); 12608 message.append("]"); 12609 } 12610 } 12611 } 12612 assertFalse("Incorrect output for checkConvertLong4Float4" + 12613 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12614 } 12615 12616 public class ArgumentsUlongFloat { 12617 public long inV; 12618 public Target.Floaty out; 12619 } 12620 checkConvertUlong2Float2()12621 private void checkConvertUlong2Float2() { 12622 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x7306c3dfl, false, 64); 12623 try { 12624 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12625 script.forEach_testConvertFloat2Ulong2Float2(inV, out); 12626 verifyResultsConvertUlong2Float2(inV, out, false); 12627 } catch (Exception e) { 12628 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString()); 12629 } 12630 try { 12631 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 12632 scriptRelaxed.forEach_testConvertFloat2Ulong2Float2(inV, out); 12633 verifyResultsConvertUlong2Float2(inV, out, true); 12634 } catch (Exception e) { 12635 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString()); 12636 } 12637 } 12638 verifyResultsConvertUlong2Float2(Allocation inV, Allocation out, boolean relaxed)12639 private void verifyResultsConvertUlong2Float2(Allocation inV, Allocation out, boolean relaxed) { 12640 long[] arrayInV = new long[INPUTSIZE * 2]; 12641 Arrays.fill(arrayInV, (long) 42); 12642 inV.copyTo(arrayInV); 12643 float[] arrayOut = new float[INPUTSIZE * 2]; 12644 Arrays.fill(arrayOut, (float) 42); 12645 out.copyTo(arrayOut); 12646 StringBuilder message = new StringBuilder(); 12647 boolean errorFound = false; 12648 for (int i = 0; i < INPUTSIZE; i++) { 12649 for (int j = 0; j < 2 ; j++) { 12650 // Extract the inputs. 12651 ArgumentsUlongFloat args = new ArgumentsUlongFloat(); 12652 args.inV = arrayInV[i * 2 + j]; 12653 // Figure out what the outputs should have been. 12654 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12655 CoreMathVerifier.computeConvert(args, target); 12656 // Validate the outputs. 12657 boolean valid = true; 12658 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12659 valid = false; 12660 } 12661 if (!valid) { 12662 if (!errorFound) { 12663 errorFound = true; 12664 message.append("Input inV: "); 12665 appendVariableToMessage(message, args.inV); 12666 message.append("\n"); 12667 message.append("Expected output out: "); 12668 appendVariableToMessage(message, args.out); 12669 message.append("\n"); 12670 message.append("Actual output out: "); 12671 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12672 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 12673 message.append(" FAIL"); 12674 } 12675 message.append("\n"); 12676 message.append("Errors at"); 12677 } 12678 message.append(" ["); 12679 message.append(Integer.toString(i)); 12680 message.append(", "); 12681 message.append(Integer.toString(j)); 12682 message.append("]"); 12683 } 12684 } 12685 } 12686 assertFalse("Incorrect output for checkConvertUlong2Float2" + 12687 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12688 } 12689 checkConvertUlong3Float3()12690 private void checkConvertUlong3Float3() { 12691 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6921e4bdl, false, 64); 12692 try { 12693 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12694 script.forEach_testConvertFloat3Ulong3Float3(inV, out); 12695 verifyResultsConvertUlong3Float3(inV, out, false); 12696 } catch (Exception e) { 12697 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString()); 12698 } 12699 try { 12700 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 12701 scriptRelaxed.forEach_testConvertFloat3Ulong3Float3(inV, out); 12702 verifyResultsConvertUlong3Float3(inV, out, true); 12703 } catch (Exception e) { 12704 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString()); 12705 } 12706 } 12707 verifyResultsConvertUlong3Float3(Allocation inV, Allocation out, boolean relaxed)12708 private void verifyResultsConvertUlong3Float3(Allocation inV, Allocation out, boolean relaxed) { 12709 long[] arrayInV = new long[INPUTSIZE * 4]; 12710 Arrays.fill(arrayInV, (long) 42); 12711 inV.copyTo(arrayInV); 12712 float[] arrayOut = new float[INPUTSIZE * 4]; 12713 Arrays.fill(arrayOut, (float) 42); 12714 out.copyTo(arrayOut); 12715 StringBuilder message = new StringBuilder(); 12716 boolean errorFound = false; 12717 for (int i = 0; i < INPUTSIZE; i++) { 12718 for (int j = 0; j < 3 ; j++) { 12719 // Extract the inputs. 12720 ArgumentsUlongFloat args = new ArgumentsUlongFloat(); 12721 args.inV = arrayInV[i * 4 + j]; 12722 // Figure out what the outputs should have been. 12723 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12724 CoreMathVerifier.computeConvert(args, target); 12725 // Validate the outputs. 12726 boolean valid = true; 12727 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12728 valid = false; 12729 } 12730 if (!valid) { 12731 if (!errorFound) { 12732 errorFound = true; 12733 message.append("Input inV: "); 12734 appendVariableToMessage(message, args.inV); 12735 message.append("\n"); 12736 message.append("Expected output out: "); 12737 appendVariableToMessage(message, args.out); 12738 message.append("\n"); 12739 message.append("Actual output out: "); 12740 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12741 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12742 message.append(" FAIL"); 12743 } 12744 message.append("\n"); 12745 message.append("Errors at"); 12746 } 12747 message.append(" ["); 12748 message.append(Integer.toString(i)); 12749 message.append(", "); 12750 message.append(Integer.toString(j)); 12751 message.append("]"); 12752 } 12753 } 12754 } 12755 assertFalse("Incorrect output for checkConvertUlong3Float3" + 12756 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12757 } 12758 checkConvertUlong4Float4()12759 private void checkConvertUlong4Float4() { 12760 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5f3d059bl, false, 64); 12761 try { 12762 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12763 script.forEach_testConvertFloat4Ulong4Float4(inV, out); 12764 verifyResultsConvertUlong4Float4(inV, out, false); 12765 } catch (Exception e) { 12766 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString()); 12767 } 12768 try { 12769 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 12770 scriptRelaxed.forEach_testConvertFloat4Ulong4Float4(inV, out); 12771 verifyResultsConvertUlong4Float4(inV, out, true); 12772 } catch (Exception e) { 12773 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString()); 12774 } 12775 } 12776 verifyResultsConvertUlong4Float4(Allocation inV, Allocation out, boolean relaxed)12777 private void verifyResultsConvertUlong4Float4(Allocation inV, Allocation out, boolean relaxed) { 12778 long[] arrayInV = new long[INPUTSIZE * 4]; 12779 Arrays.fill(arrayInV, (long) 42); 12780 inV.copyTo(arrayInV); 12781 float[] arrayOut = new float[INPUTSIZE * 4]; 12782 Arrays.fill(arrayOut, (float) 42); 12783 out.copyTo(arrayOut); 12784 StringBuilder message = new StringBuilder(); 12785 boolean errorFound = false; 12786 for (int i = 0; i < INPUTSIZE; i++) { 12787 for (int j = 0; j < 4 ; j++) { 12788 // Extract the inputs. 12789 ArgumentsUlongFloat args = new ArgumentsUlongFloat(); 12790 args.inV = arrayInV[i * 4 + j]; 12791 // Figure out what the outputs should have been. 12792 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 12793 CoreMathVerifier.computeConvert(args, target); 12794 // Validate the outputs. 12795 boolean valid = true; 12796 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12797 valid = false; 12798 } 12799 if (!valid) { 12800 if (!errorFound) { 12801 errorFound = true; 12802 message.append("Input inV: "); 12803 appendVariableToMessage(message, args.inV); 12804 message.append("\n"); 12805 message.append("Expected output out: "); 12806 appendVariableToMessage(message, args.out); 12807 message.append("\n"); 12808 message.append("Actual output out: "); 12809 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12810 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 12811 message.append(" FAIL"); 12812 } 12813 message.append("\n"); 12814 message.append("Errors at"); 12815 } 12816 message.append(" ["); 12817 message.append(Integer.toString(i)); 12818 message.append(", "); 12819 message.append(Integer.toString(j)); 12820 message.append("]"); 12821 } 12822 } 12823 } 12824 assertFalse("Incorrect output for checkConvertUlong4Float4" + 12825 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12826 } 12827 12828 public class ArgumentsDoubleChar { 12829 public double inV; 12830 public byte out; 12831 } 12832 checkConvertDouble2Char2()12833 private void checkConvertDouble2Char2() { 12834 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xef094a17l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 12835 try { 12836 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 12837 script.forEach_testConvertChar2Double2Char2(inV, out); 12838 verifyResultsConvertDouble2Char2(inV, out, false); 12839 } catch (Exception e) { 12840 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString()); 12841 } 12842 try { 12843 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 12844 scriptRelaxed.forEach_testConvertChar2Double2Char2(inV, out); 12845 verifyResultsConvertDouble2Char2(inV, out, true); 12846 } catch (Exception e) { 12847 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString()); 12848 } 12849 } 12850 verifyResultsConvertDouble2Char2(Allocation inV, Allocation out, boolean relaxed)12851 private void verifyResultsConvertDouble2Char2(Allocation inV, Allocation out, boolean relaxed) { 12852 double[] arrayInV = new double[INPUTSIZE * 2]; 12853 Arrays.fill(arrayInV, (double) 42); 12854 inV.copyTo(arrayInV); 12855 byte[] arrayOut = new byte[INPUTSIZE * 2]; 12856 Arrays.fill(arrayOut, (byte) 42); 12857 out.copyTo(arrayOut); 12858 StringBuilder message = new StringBuilder(); 12859 boolean errorFound = false; 12860 for (int i = 0; i < INPUTSIZE; i++) { 12861 for (int j = 0; j < 2 ; j++) { 12862 // Extract the inputs. 12863 ArgumentsDoubleChar args = new ArgumentsDoubleChar(); 12864 args.inV = arrayInV[i * 2 + j]; 12865 // Figure out what the outputs should have been. 12866 CoreMathVerifier.computeConvert(args); 12867 // Validate the outputs. 12868 boolean valid = true; 12869 if (args.out != arrayOut[i * 2 + j]) { 12870 valid = false; 12871 } 12872 if (!valid) { 12873 if (!errorFound) { 12874 errorFound = true; 12875 message.append("Input inV: "); 12876 appendVariableToMessage(message, args.inV); 12877 message.append("\n"); 12878 message.append("Expected output out: "); 12879 appendVariableToMessage(message, args.out); 12880 message.append("\n"); 12881 message.append("Actual output out: "); 12882 appendVariableToMessage(message, arrayOut[i * 2 + j]); 12883 if (args.out != arrayOut[i * 2 + j]) { 12884 message.append(" FAIL"); 12885 } 12886 message.append("\n"); 12887 message.append("Errors at"); 12888 } 12889 message.append(" ["); 12890 message.append(Integer.toString(i)); 12891 message.append(", "); 12892 message.append(Integer.toString(j)); 12893 message.append("]"); 12894 } 12895 } 12896 } 12897 assertFalse("Incorrect output for checkConvertDouble2Char2" + 12898 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12899 } 12900 checkConvertDouble3Char3()12901 private void checkConvertDouble3Char3() { 12902 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x4e110f0bl, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 12903 try { 12904 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 12905 script.forEach_testConvertChar3Double3Char3(inV, out); 12906 verifyResultsConvertDouble3Char3(inV, out, false); 12907 } catch (Exception e) { 12908 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString()); 12909 } 12910 try { 12911 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 12912 scriptRelaxed.forEach_testConvertChar3Double3Char3(inV, out); 12913 verifyResultsConvertDouble3Char3(inV, out, true); 12914 } catch (Exception e) { 12915 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString()); 12916 } 12917 } 12918 verifyResultsConvertDouble3Char3(Allocation inV, Allocation out, boolean relaxed)12919 private void verifyResultsConvertDouble3Char3(Allocation inV, Allocation out, boolean relaxed) { 12920 double[] arrayInV = new double[INPUTSIZE * 4]; 12921 Arrays.fill(arrayInV, (double) 42); 12922 inV.copyTo(arrayInV); 12923 byte[] arrayOut = new byte[INPUTSIZE * 4]; 12924 Arrays.fill(arrayOut, (byte) 42); 12925 out.copyTo(arrayOut); 12926 StringBuilder message = new StringBuilder(); 12927 boolean errorFound = false; 12928 for (int i = 0; i < INPUTSIZE; i++) { 12929 for (int j = 0; j < 3 ; j++) { 12930 // Extract the inputs. 12931 ArgumentsDoubleChar args = new ArgumentsDoubleChar(); 12932 args.inV = arrayInV[i * 4 + j]; 12933 // Figure out what the outputs should have been. 12934 CoreMathVerifier.computeConvert(args); 12935 // Validate the outputs. 12936 boolean valid = true; 12937 if (args.out != arrayOut[i * 4 + j]) { 12938 valid = false; 12939 } 12940 if (!valid) { 12941 if (!errorFound) { 12942 errorFound = true; 12943 message.append("Input inV: "); 12944 appendVariableToMessage(message, args.inV); 12945 message.append("\n"); 12946 message.append("Expected output out: "); 12947 appendVariableToMessage(message, args.out); 12948 message.append("\n"); 12949 message.append("Actual output out: "); 12950 appendVariableToMessage(message, arrayOut[i * 4 + j]); 12951 if (args.out != arrayOut[i * 4 + j]) { 12952 message.append(" FAIL"); 12953 } 12954 message.append("\n"); 12955 message.append("Errors at"); 12956 } 12957 message.append(" ["); 12958 message.append(Integer.toString(i)); 12959 message.append(", "); 12960 message.append(Integer.toString(j)); 12961 message.append("]"); 12962 } 12963 } 12964 } 12965 assertFalse("Incorrect output for checkConvertDouble3Char3" + 12966 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 12967 } 12968 checkConvertDouble4Char4()12969 private void checkConvertDouble4Char4() { 12970 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xad18d3ffl, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 12971 try { 12972 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 12973 script.forEach_testConvertChar4Double4Char4(inV, out); 12974 verifyResultsConvertDouble4Char4(inV, out, false); 12975 } catch (Exception e) { 12976 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString()); 12977 } 12978 try { 12979 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 12980 scriptRelaxed.forEach_testConvertChar4Double4Char4(inV, out); 12981 verifyResultsConvertDouble4Char4(inV, out, true); 12982 } catch (Exception e) { 12983 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString()); 12984 } 12985 } 12986 verifyResultsConvertDouble4Char4(Allocation inV, Allocation out, boolean relaxed)12987 private void verifyResultsConvertDouble4Char4(Allocation inV, Allocation out, boolean relaxed) { 12988 double[] arrayInV = new double[INPUTSIZE * 4]; 12989 Arrays.fill(arrayInV, (double) 42); 12990 inV.copyTo(arrayInV); 12991 byte[] arrayOut = new byte[INPUTSIZE * 4]; 12992 Arrays.fill(arrayOut, (byte) 42); 12993 out.copyTo(arrayOut); 12994 StringBuilder message = new StringBuilder(); 12995 boolean errorFound = false; 12996 for (int i = 0; i < INPUTSIZE; i++) { 12997 for (int j = 0; j < 4 ; j++) { 12998 // Extract the inputs. 12999 ArgumentsDoubleChar args = new ArgumentsDoubleChar(); 13000 args.inV = arrayInV[i * 4 + j]; 13001 // Figure out what the outputs should have been. 13002 CoreMathVerifier.computeConvert(args); 13003 // Validate the outputs. 13004 boolean valid = true; 13005 if (args.out != arrayOut[i * 4 + j]) { 13006 valid = false; 13007 } 13008 if (!valid) { 13009 if (!errorFound) { 13010 errorFound = true; 13011 message.append("Input inV: "); 13012 appendVariableToMessage(message, args.inV); 13013 message.append("\n"); 13014 message.append("Expected output out: "); 13015 appendVariableToMessage(message, args.out); 13016 message.append("\n"); 13017 message.append("Actual output out: "); 13018 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13019 if (args.out != arrayOut[i * 4 + j]) { 13020 message.append(" FAIL"); 13021 } 13022 message.append("\n"); 13023 message.append("Errors at"); 13024 } 13025 message.append(" ["); 13026 message.append(Integer.toString(i)); 13027 message.append(", "); 13028 message.append(Integer.toString(j)); 13029 message.append("]"); 13030 } 13031 } 13032 } 13033 assertFalse("Incorrect output for checkConvertDouble4Char4" + 13034 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13035 } 13036 13037 public class ArgumentsLongChar { 13038 public long inV; 13039 public byte out; 13040 } 13041 checkConvertLong2Char2()13042 private void checkConvertLong2Char2() { 13043 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7419afacl, true, 7); 13044 try { 13045 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13046 script.forEach_testConvertChar2Long2Char2(inV, out); 13047 verifyResultsConvertLong2Char2(inV, out, false); 13048 } catch (Exception e) { 13049 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString()); 13050 } 13051 try { 13052 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13053 scriptRelaxed.forEach_testConvertChar2Long2Char2(inV, out); 13054 verifyResultsConvertLong2Char2(inV, out, true); 13055 } catch (Exception e) { 13056 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString()); 13057 } 13058 } 13059 verifyResultsConvertLong2Char2(Allocation inV, Allocation out, boolean relaxed)13060 private void verifyResultsConvertLong2Char2(Allocation inV, Allocation out, boolean relaxed) { 13061 long[] arrayInV = new long[INPUTSIZE * 2]; 13062 Arrays.fill(arrayInV, (long) 42); 13063 inV.copyTo(arrayInV); 13064 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13065 Arrays.fill(arrayOut, (byte) 42); 13066 out.copyTo(arrayOut); 13067 StringBuilder message = new StringBuilder(); 13068 boolean errorFound = false; 13069 for (int i = 0; i < INPUTSIZE; i++) { 13070 for (int j = 0; j < 2 ; j++) { 13071 // Extract the inputs. 13072 ArgumentsLongChar args = new ArgumentsLongChar(); 13073 args.inV = arrayInV[i * 2 + j]; 13074 // Figure out what the outputs should have been. 13075 CoreMathVerifier.computeConvert(args); 13076 // Validate the outputs. 13077 boolean valid = true; 13078 if (args.out != arrayOut[i * 2 + j]) { 13079 valid = false; 13080 } 13081 if (!valid) { 13082 if (!errorFound) { 13083 errorFound = true; 13084 message.append("Input inV: "); 13085 appendVariableToMessage(message, args.inV); 13086 message.append("\n"); 13087 message.append("Expected output out: "); 13088 appendVariableToMessage(message, args.out); 13089 message.append("\n"); 13090 message.append("Actual output out: "); 13091 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13092 if (args.out != arrayOut[i * 2 + j]) { 13093 message.append(" FAIL"); 13094 } 13095 message.append("\n"); 13096 message.append("Errors at"); 13097 } 13098 message.append(" ["); 13099 message.append(Integer.toString(i)); 13100 message.append(", "); 13101 message.append(Integer.toString(j)); 13102 message.append("]"); 13103 } 13104 } 13105 } 13106 assertFalse("Incorrect output for checkConvertLong2Char2" + 13107 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13108 } 13109 checkConvertLong3Char3()13110 private void checkConvertLong3Char3() { 13111 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xd32174a0l, true, 7); 13112 try { 13113 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13114 script.forEach_testConvertChar3Long3Char3(inV, out); 13115 verifyResultsConvertLong3Char3(inV, out, false); 13116 } catch (Exception e) { 13117 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString()); 13118 } 13119 try { 13120 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13121 scriptRelaxed.forEach_testConvertChar3Long3Char3(inV, out); 13122 verifyResultsConvertLong3Char3(inV, out, true); 13123 } catch (Exception e) { 13124 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString()); 13125 } 13126 } 13127 verifyResultsConvertLong3Char3(Allocation inV, Allocation out, boolean relaxed)13128 private void verifyResultsConvertLong3Char3(Allocation inV, Allocation out, boolean relaxed) { 13129 long[] arrayInV = new long[INPUTSIZE * 4]; 13130 Arrays.fill(arrayInV, (long) 42); 13131 inV.copyTo(arrayInV); 13132 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13133 Arrays.fill(arrayOut, (byte) 42); 13134 out.copyTo(arrayOut); 13135 StringBuilder message = new StringBuilder(); 13136 boolean errorFound = false; 13137 for (int i = 0; i < INPUTSIZE; i++) { 13138 for (int j = 0; j < 3 ; j++) { 13139 // Extract the inputs. 13140 ArgumentsLongChar args = new ArgumentsLongChar(); 13141 args.inV = arrayInV[i * 4 + j]; 13142 // Figure out what the outputs should have been. 13143 CoreMathVerifier.computeConvert(args); 13144 // Validate the outputs. 13145 boolean valid = true; 13146 if (args.out != arrayOut[i * 4 + j]) { 13147 valid = false; 13148 } 13149 if (!valid) { 13150 if (!errorFound) { 13151 errorFound = true; 13152 message.append("Input inV: "); 13153 appendVariableToMessage(message, args.inV); 13154 message.append("\n"); 13155 message.append("Expected output out: "); 13156 appendVariableToMessage(message, args.out); 13157 message.append("\n"); 13158 message.append("Actual output out: "); 13159 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13160 if (args.out != arrayOut[i * 4 + j]) { 13161 message.append(" FAIL"); 13162 } 13163 message.append("\n"); 13164 message.append("Errors at"); 13165 } 13166 message.append(" ["); 13167 message.append(Integer.toString(i)); 13168 message.append(", "); 13169 message.append(Integer.toString(j)); 13170 message.append("]"); 13171 } 13172 } 13173 } 13174 assertFalse("Incorrect output for checkConvertLong3Char3" + 13175 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13176 } 13177 checkConvertLong4Char4()13178 private void checkConvertLong4Char4() { 13179 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x32293994l, true, 7); 13180 try { 13181 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13182 script.forEach_testConvertChar4Long4Char4(inV, out); 13183 verifyResultsConvertLong4Char4(inV, out, false); 13184 } catch (Exception e) { 13185 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString()); 13186 } 13187 try { 13188 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13189 scriptRelaxed.forEach_testConvertChar4Long4Char4(inV, out); 13190 verifyResultsConvertLong4Char4(inV, out, true); 13191 } catch (Exception e) { 13192 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString()); 13193 } 13194 } 13195 verifyResultsConvertLong4Char4(Allocation inV, Allocation out, boolean relaxed)13196 private void verifyResultsConvertLong4Char4(Allocation inV, Allocation out, boolean relaxed) { 13197 long[] arrayInV = new long[INPUTSIZE * 4]; 13198 Arrays.fill(arrayInV, (long) 42); 13199 inV.copyTo(arrayInV); 13200 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13201 Arrays.fill(arrayOut, (byte) 42); 13202 out.copyTo(arrayOut); 13203 StringBuilder message = new StringBuilder(); 13204 boolean errorFound = false; 13205 for (int i = 0; i < INPUTSIZE; i++) { 13206 for (int j = 0; j < 4 ; j++) { 13207 // Extract the inputs. 13208 ArgumentsLongChar args = new ArgumentsLongChar(); 13209 args.inV = arrayInV[i * 4 + j]; 13210 // Figure out what the outputs should have been. 13211 CoreMathVerifier.computeConvert(args); 13212 // Validate the outputs. 13213 boolean valid = true; 13214 if (args.out != arrayOut[i * 4 + j]) { 13215 valid = false; 13216 } 13217 if (!valid) { 13218 if (!errorFound) { 13219 errorFound = true; 13220 message.append("Input inV: "); 13221 appendVariableToMessage(message, args.inV); 13222 message.append("\n"); 13223 message.append("Expected output out: "); 13224 appendVariableToMessage(message, args.out); 13225 message.append("\n"); 13226 message.append("Actual output out: "); 13227 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13228 if (args.out != arrayOut[i * 4 + j]) { 13229 message.append(" FAIL"); 13230 } 13231 message.append("\n"); 13232 message.append("Errors at"); 13233 } 13234 message.append(" ["); 13235 message.append(Integer.toString(i)); 13236 message.append(", "); 13237 message.append(Integer.toString(j)); 13238 message.append("]"); 13239 } 13240 } 13241 } 13242 assertFalse("Incorrect output for checkConvertLong4Char4" + 13243 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13244 } 13245 13246 public class ArgumentsUlongChar { 13247 public long inV; 13248 public byte out; 13249 } 13250 checkConvertUlong2Char2()13251 private void checkConvertUlong2Char2() { 13252 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x69bbc2dl, false, 7); 13253 try { 13254 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13255 script.forEach_testConvertChar2Ulong2Char2(inV, out); 13256 verifyResultsConvertUlong2Char2(inV, out, false); 13257 } catch (Exception e) { 13258 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString()); 13259 } 13260 try { 13261 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 13262 scriptRelaxed.forEach_testConvertChar2Ulong2Char2(inV, out); 13263 verifyResultsConvertUlong2Char2(inV, out, true); 13264 } catch (Exception e) { 13265 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString()); 13266 } 13267 } 13268 verifyResultsConvertUlong2Char2(Allocation inV, Allocation out, boolean relaxed)13269 private void verifyResultsConvertUlong2Char2(Allocation inV, Allocation out, boolean relaxed) { 13270 long[] arrayInV = new long[INPUTSIZE * 2]; 13271 Arrays.fill(arrayInV, (long) 42); 13272 inV.copyTo(arrayInV); 13273 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13274 Arrays.fill(arrayOut, (byte) 42); 13275 out.copyTo(arrayOut); 13276 StringBuilder message = new StringBuilder(); 13277 boolean errorFound = false; 13278 for (int i = 0; i < INPUTSIZE; i++) { 13279 for (int j = 0; j < 2 ; j++) { 13280 // Extract the inputs. 13281 ArgumentsUlongChar args = new ArgumentsUlongChar(); 13282 args.inV = arrayInV[i * 2 + j]; 13283 // Figure out what the outputs should have been. 13284 CoreMathVerifier.computeConvert(args); 13285 // Validate the outputs. 13286 boolean valid = true; 13287 if (args.out != arrayOut[i * 2 + j]) { 13288 valid = false; 13289 } 13290 if (!valid) { 13291 if (!errorFound) { 13292 errorFound = true; 13293 message.append("Input inV: "); 13294 appendVariableToMessage(message, args.inV); 13295 message.append("\n"); 13296 message.append("Expected output out: "); 13297 appendVariableToMessage(message, args.out); 13298 message.append("\n"); 13299 message.append("Actual output out: "); 13300 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13301 if (args.out != arrayOut[i * 2 + j]) { 13302 message.append(" FAIL"); 13303 } 13304 message.append("\n"); 13305 message.append("Errors at"); 13306 } 13307 message.append(" ["); 13308 message.append(Integer.toString(i)); 13309 message.append(", "); 13310 message.append(Integer.toString(j)); 13311 message.append("]"); 13312 } 13313 } 13314 } 13315 assertFalse("Incorrect output for checkConvertUlong2Char2" + 13316 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13317 } 13318 checkConvertUlong3Char3()13319 private void checkConvertUlong3Char3() { 13320 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x65a38121l, false, 7); 13321 try { 13322 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13323 script.forEach_testConvertChar3Ulong3Char3(inV, out); 13324 verifyResultsConvertUlong3Char3(inV, out, false); 13325 } catch (Exception e) { 13326 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString()); 13327 } 13328 try { 13329 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 13330 scriptRelaxed.forEach_testConvertChar3Ulong3Char3(inV, out); 13331 verifyResultsConvertUlong3Char3(inV, out, true); 13332 } catch (Exception e) { 13333 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString()); 13334 } 13335 } 13336 verifyResultsConvertUlong3Char3(Allocation inV, Allocation out, boolean relaxed)13337 private void verifyResultsConvertUlong3Char3(Allocation inV, Allocation out, boolean relaxed) { 13338 long[] arrayInV = new long[INPUTSIZE * 4]; 13339 Arrays.fill(arrayInV, (long) 42); 13340 inV.copyTo(arrayInV); 13341 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13342 Arrays.fill(arrayOut, (byte) 42); 13343 out.copyTo(arrayOut); 13344 StringBuilder message = new StringBuilder(); 13345 boolean errorFound = false; 13346 for (int i = 0; i < INPUTSIZE; i++) { 13347 for (int j = 0; j < 3 ; j++) { 13348 // Extract the inputs. 13349 ArgumentsUlongChar args = new ArgumentsUlongChar(); 13350 args.inV = arrayInV[i * 4 + j]; 13351 // Figure out what the outputs should have been. 13352 CoreMathVerifier.computeConvert(args); 13353 // Validate the outputs. 13354 boolean valid = true; 13355 if (args.out != arrayOut[i * 4 + j]) { 13356 valid = false; 13357 } 13358 if (!valid) { 13359 if (!errorFound) { 13360 errorFound = true; 13361 message.append("Input inV: "); 13362 appendVariableToMessage(message, args.inV); 13363 message.append("\n"); 13364 message.append("Expected output out: "); 13365 appendVariableToMessage(message, args.out); 13366 message.append("\n"); 13367 message.append("Actual output out: "); 13368 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13369 if (args.out != arrayOut[i * 4 + j]) { 13370 message.append(" FAIL"); 13371 } 13372 message.append("\n"); 13373 message.append("Errors at"); 13374 } 13375 message.append(" ["); 13376 message.append(Integer.toString(i)); 13377 message.append(", "); 13378 message.append(Integer.toString(j)); 13379 message.append("]"); 13380 } 13381 } 13382 } 13383 assertFalse("Incorrect output for checkConvertUlong3Char3" + 13384 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13385 } 13386 checkConvertUlong4Char4()13387 private void checkConvertUlong4Char4() { 13388 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xc4ab4615l, false, 7); 13389 try { 13390 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13391 script.forEach_testConvertChar4Ulong4Char4(inV, out); 13392 verifyResultsConvertUlong4Char4(inV, out, false); 13393 } catch (Exception e) { 13394 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString()); 13395 } 13396 try { 13397 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 13398 scriptRelaxed.forEach_testConvertChar4Ulong4Char4(inV, out); 13399 verifyResultsConvertUlong4Char4(inV, out, true); 13400 } catch (Exception e) { 13401 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString()); 13402 } 13403 } 13404 verifyResultsConvertUlong4Char4(Allocation inV, Allocation out, boolean relaxed)13405 private void verifyResultsConvertUlong4Char4(Allocation inV, Allocation out, boolean relaxed) { 13406 long[] arrayInV = new long[INPUTSIZE * 4]; 13407 Arrays.fill(arrayInV, (long) 42); 13408 inV.copyTo(arrayInV); 13409 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13410 Arrays.fill(arrayOut, (byte) 42); 13411 out.copyTo(arrayOut); 13412 StringBuilder message = new StringBuilder(); 13413 boolean errorFound = false; 13414 for (int i = 0; i < INPUTSIZE; i++) { 13415 for (int j = 0; j < 4 ; j++) { 13416 // Extract the inputs. 13417 ArgumentsUlongChar args = new ArgumentsUlongChar(); 13418 args.inV = arrayInV[i * 4 + j]; 13419 // Figure out what the outputs should have been. 13420 CoreMathVerifier.computeConvert(args); 13421 // Validate the outputs. 13422 boolean valid = true; 13423 if (args.out != arrayOut[i * 4 + j]) { 13424 valid = false; 13425 } 13426 if (!valid) { 13427 if (!errorFound) { 13428 errorFound = true; 13429 message.append("Input inV: "); 13430 appendVariableToMessage(message, args.inV); 13431 message.append("\n"); 13432 message.append("Expected output out: "); 13433 appendVariableToMessage(message, args.out); 13434 message.append("\n"); 13435 message.append("Actual output out: "); 13436 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13437 if (args.out != arrayOut[i * 4 + j]) { 13438 message.append(" FAIL"); 13439 } 13440 message.append("\n"); 13441 message.append("Errors at"); 13442 } 13443 message.append(" ["); 13444 message.append(Integer.toString(i)); 13445 message.append(", "); 13446 message.append(Integer.toString(j)); 13447 message.append("]"); 13448 } 13449 } 13450 } 13451 assertFalse("Incorrect output for checkConvertUlong4Char4" + 13452 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13453 } 13454 13455 public class ArgumentsDoubleUchar { 13456 public double inV; 13457 public byte out; 13458 } 13459 checkConvertDouble2Uchar2()13460 private void checkConvertDouble2Uchar2() { 13461 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x2a0f8ae0l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 13462 try { 13463 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 13464 script.forEach_testConvertUchar2Double2Uchar2(inV, out); 13465 verifyResultsConvertDouble2Uchar2(inV, out, false); 13466 } catch (Exception e) { 13467 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString()); 13468 } 13469 try { 13470 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 13471 scriptRelaxed.forEach_testConvertUchar2Double2Uchar2(inV, out); 13472 verifyResultsConvertDouble2Uchar2(inV, out, true); 13473 } catch (Exception e) { 13474 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString()); 13475 } 13476 } 13477 verifyResultsConvertDouble2Uchar2(Allocation inV, Allocation out, boolean relaxed)13478 private void verifyResultsConvertDouble2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 13479 double[] arrayInV = new double[INPUTSIZE * 2]; 13480 Arrays.fill(arrayInV, (double) 42); 13481 inV.copyTo(arrayInV); 13482 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13483 Arrays.fill(arrayOut, (byte) 42); 13484 out.copyTo(arrayOut); 13485 StringBuilder message = new StringBuilder(); 13486 boolean errorFound = false; 13487 for (int i = 0; i < INPUTSIZE; i++) { 13488 for (int j = 0; j < 2 ; j++) { 13489 // Extract the inputs. 13490 ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); 13491 args.inV = arrayInV[i * 2 + j]; 13492 // Figure out what the outputs should have been. 13493 CoreMathVerifier.computeConvert(args); 13494 // Validate the outputs. 13495 boolean valid = true; 13496 if (args.out != arrayOut[i * 2 + j]) { 13497 valid = false; 13498 } 13499 if (!valid) { 13500 if (!errorFound) { 13501 errorFound = true; 13502 message.append("Input inV: "); 13503 appendVariableToMessage(message, args.inV); 13504 message.append("\n"); 13505 message.append("Expected output out: "); 13506 appendVariableToMessage(message, args.out); 13507 message.append("\n"); 13508 message.append("Actual output out: "); 13509 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13510 if (args.out != arrayOut[i * 2 + j]) { 13511 message.append(" FAIL"); 13512 } 13513 message.append("\n"); 13514 message.append("Errors at"); 13515 } 13516 message.append(" ["); 13517 message.append(Integer.toString(i)); 13518 message.append(", "); 13519 message.append(Integer.toString(j)); 13520 message.append("]"); 13521 } 13522 } 13523 } 13524 assertFalse("Incorrect output for checkConvertDouble2Uchar2" + 13525 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13526 } 13527 checkConvertDouble3Uchar3()13528 private void checkConvertDouble3Uchar3() { 13529 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x202aabbel, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 13530 try { 13531 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 13532 script.forEach_testConvertUchar3Double3Uchar3(inV, out); 13533 verifyResultsConvertDouble3Uchar3(inV, out, false); 13534 } catch (Exception e) { 13535 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString()); 13536 } 13537 try { 13538 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 13539 scriptRelaxed.forEach_testConvertUchar3Double3Uchar3(inV, out); 13540 verifyResultsConvertDouble3Uchar3(inV, out, true); 13541 } catch (Exception e) { 13542 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString()); 13543 } 13544 } 13545 verifyResultsConvertDouble3Uchar3(Allocation inV, Allocation out, boolean relaxed)13546 private void verifyResultsConvertDouble3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 13547 double[] arrayInV = new double[INPUTSIZE * 4]; 13548 Arrays.fill(arrayInV, (double) 42); 13549 inV.copyTo(arrayInV); 13550 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13551 Arrays.fill(arrayOut, (byte) 42); 13552 out.copyTo(arrayOut); 13553 StringBuilder message = new StringBuilder(); 13554 boolean errorFound = false; 13555 for (int i = 0; i < INPUTSIZE; i++) { 13556 for (int j = 0; j < 3 ; j++) { 13557 // Extract the inputs. 13558 ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); 13559 args.inV = arrayInV[i * 4 + j]; 13560 // Figure out what the outputs should have been. 13561 CoreMathVerifier.computeConvert(args); 13562 // Validate the outputs. 13563 boolean valid = true; 13564 if (args.out != arrayOut[i * 4 + j]) { 13565 valid = false; 13566 } 13567 if (!valid) { 13568 if (!errorFound) { 13569 errorFound = true; 13570 message.append("Input inV: "); 13571 appendVariableToMessage(message, args.inV); 13572 message.append("\n"); 13573 message.append("Expected output out: "); 13574 appendVariableToMessage(message, args.out); 13575 message.append("\n"); 13576 message.append("Actual output out: "); 13577 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13578 if (args.out != arrayOut[i * 4 + j]) { 13579 message.append(" FAIL"); 13580 } 13581 message.append("\n"); 13582 message.append("Errors at"); 13583 } 13584 message.append(" ["); 13585 message.append(Integer.toString(i)); 13586 message.append(", "); 13587 message.append(Integer.toString(j)); 13588 message.append("]"); 13589 } 13590 } 13591 } 13592 assertFalse("Incorrect output for checkConvertDouble3Uchar3" + 13593 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13594 } 13595 checkConvertDouble4Uchar4()13596 private void checkConvertDouble4Uchar4() { 13597 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x1645cc9cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 13598 try { 13599 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 13600 script.forEach_testConvertUchar4Double4Uchar4(inV, out); 13601 verifyResultsConvertDouble4Uchar4(inV, out, false); 13602 } catch (Exception e) { 13603 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString()); 13604 } 13605 try { 13606 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 13607 scriptRelaxed.forEach_testConvertUchar4Double4Uchar4(inV, out); 13608 verifyResultsConvertDouble4Uchar4(inV, out, true); 13609 } catch (Exception e) { 13610 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString()); 13611 } 13612 } 13613 verifyResultsConvertDouble4Uchar4(Allocation inV, Allocation out, boolean relaxed)13614 private void verifyResultsConvertDouble4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 13615 double[] arrayInV = new double[INPUTSIZE * 4]; 13616 Arrays.fill(arrayInV, (double) 42); 13617 inV.copyTo(arrayInV); 13618 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13619 Arrays.fill(arrayOut, (byte) 42); 13620 out.copyTo(arrayOut); 13621 StringBuilder message = new StringBuilder(); 13622 boolean errorFound = false; 13623 for (int i = 0; i < INPUTSIZE; i++) { 13624 for (int j = 0; j < 4 ; j++) { 13625 // Extract the inputs. 13626 ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); 13627 args.inV = arrayInV[i * 4 + j]; 13628 // Figure out what the outputs should have been. 13629 CoreMathVerifier.computeConvert(args); 13630 // Validate the outputs. 13631 boolean valid = true; 13632 if (args.out != arrayOut[i * 4 + j]) { 13633 valid = false; 13634 } 13635 if (!valid) { 13636 if (!errorFound) { 13637 errorFound = true; 13638 message.append("Input inV: "); 13639 appendVariableToMessage(message, args.inV); 13640 message.append("\n"); 13641 message.append("Expected output out: "); 13642 appendVariableToMessage(message, args.out); 13643 message.append("\n"); 13644 message.append("Actual output out: "); 13645 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13646 if (args.out != arrayOut[i * 4 + j]) { 13647 message.append(" FAIL"); 13648 } 13649 message.append("\n"); 13650 message.append("Errors at"); 13651 } 13652 message.append(" ["); 13653 message.append(Integer.toString(i)); 13654 message.append(", "); 13655 message.append(Integer.toString(j)); 13656 message.append("]"); 13657 } 13658 } 13659 } 13660 assertFalse("Incorrect output for checkConvertDouble4Uchar4" + 13661 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13662 } 13663 13664 public class ArgumentsLongUchar { 13665 public long inV; 13666 public byte out; 13667 } 13668 checkConvertLong2Uchar2()13669 private void checkConvertLong2Uchar2() { 13670 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x83d09ae7l, false, 8); 13671 try { 13672 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 13673 script.forEach_testConvertUchar2Long2Uchar2(inV, out); 13674 verifyResultsConvertLong2Uchar2(inV, out, false); 13675 } catch (Exception e) { 13676 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString()); 13677 } 13678 try { 13679 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 13680 scriptRelaxed.forEach_testConvertUchar2Long2Uchar2(inV, out); 13681 verifyResultsConvertLong2Uchar2(inV, out, true); 13682 } catch (Exception e) { 13683 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString()); 13684 } 13685 } 13686 verifyResultsConvertLong2Uchar2(Allocation inV, Allocation out, boolean relaxed)13687 private void verifyResultsConvertLong2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 13688 long[] arrayInV = new long[INPUTSIZE * 2]; 13689 Arrays.fill(arrayInV, (long) 42); 13690 inV.copyTo(arrayInV); 13691 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13692 Arrays.fill(arrayOut, (byte) 42); 13693 out.copyTo(arrayOut); 13694 StringBuilder message = new StringBuilder(); 13695 boolean errorFound = false; 13696 for (int i = 0; i < INPUTSIZE; i++) { 13697 for (int j = 0; j < 2 ; j++) { 13698 // Extract the inputs. 13699 ArgumentsLongUchar args = new ArgumentsLongUchar(); 13700 args.inV = arrayInV[i * 2 + j]; 13701 // Figure out what the outputs should have been. 13702 CoreMathVerifier.computeConvert(args); 13703 // Validate the outputs. 13704 boolean valid = true; 13705 if (args.out != arrayOut[i * 2 + j]) { 13706 valid = false; 13707 } 13708 if (!valid) { 13709 if (!errorFound) { 13710 errorFound = true; 13711 message.append("Input inV: "); 13712 appendVariableToMessage(message, args.inV); 13713 message.append("\n"); 13714 message.append("Expected output out: "); 13715 appendVariableToMessage(message, args.out); 13716 message.append("\n"); 13717 message.append("Actual output out: "); 13718 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13719 if (args.out != arrayOut[i * 2 + j]) { 13720 message.append(" FAIL"); 13721 } 13722 message.append("\n"); 13723 message.append("Errors at"); 13724 } 13725 message.append(" ["); 13726 message.append(Integer.toString(i)); 13727 message.append(", "); 13728 message.append(Integer.toString(j)); 13729 message.append("]"); 13730 } 13731 } 13732 } 13733 assertFalse("Incorrect output for checkConvertLong2Uchar2" + 13734 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13735 } 13736 checkConvertLong3Uchar3()13737 private void checkConvertLong3Uchar3() { 13738 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79ebbbc5l, false, 8); 13739 try { 13740 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 13741 script.forEach_testConvertUchar3Long3Uchar3(inV, out); 13742 verifyResultsConvertLong3Uchar3(inV, out, false); 13743 } catch (Exception e) { 13744 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString()); 13745 } 13746 try { 13747 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 13748 scriptRelaxed.forEach_testConvertUchar3Long3Uchar3(inV, out); 13749 verifyResultsConvertLong3Uchar3(inV, out, true); 13750 } catch (Exception e) { 13751 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString()); 13752 } 13753 } 13754 verifyResultsConvertLong3Uchar3(Allocation inV, Allocation out, boolean relaxed)13755 private void verifyResultsConvertLong3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 13756 long[] arrayInV = new long[INPUTSIZE * 4]; 13757 Arrays.fill(arrayInV, (long) 42); 13758 inV.copyTo(arrayInV); 13759 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13760 Arrays.fill(arrayOut, (byte) 42); 13761 out.copyTo(arrayOut); 13762 StringBuilder message = new StringBuilder(); 13763 boolean errorFound = false; 13764 for (int i = 0; i < INPUTSIZE; i++) { 13765 for (int j = 0; j < 3 ; j++) { 13766 // Extract the inputs. 13767 ArgumentsLongUchar args = new ArgumentsLongUchar(); 13768 args.inV = arrayInV[i * 4 + j]; 13769 // Figure out what the outputs should have been. 13770 CoreMathVerifier.computeConvert(args); 13771 // Validate the outputs. 13772 boolean valid = true; 13773 if (args.out != arrayOut[i * 4 + j]) { 13774 valid = false; 13775 } 13776 if (!valid) { 13777 if (!errorFound) { 13778 errorFound = true; 13779 message.append("Input inV: "); 13780 appendVariableToMessage(message, args.inV); 13781 message.append("\n"); 13782 message.append("Expected output out: "); 13783 appendVariableToMessage(message, args.out); 13784 message.append("\n"); 13785 message.append("Actual output out: "); 13786 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13787 if (args.out != arrayOut[i * 4 + j]) { 13788 message.append(" FAIL"); 13789 } 13790 message.append("\n"); 13791 message.append("Errors at"); 13792 } 13793 message.append(" ["); 13794 message.append(Integer.toString(i)); 13795 message.append(", "); 13796 message.append(Integer.toString(j)); 13797 message.append("]"); 13798 } 13799 } 13800 } 13801 assertFalse("Incorrect output for checkConvertLong3Uchar3" + 13802 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13803 } 13804 checkConvertLong4Uchar4()13805 private void checkConvertLong4Uchar4() { 13806 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7006dca3l, false, 8); 13807 try { 13808 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 13809 script.forEach_testConvertUchar4Long4Uchar4(inV, out); 13810 verifyResultsConvertLong4Uchar4(inV, out, false); 13811 } catch (Exception e) { 13812 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString()); 13813 } 13814 try { 13815 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 13816 scriptRelaxed.forEach_testConvertUchar4Long4Uchar4(inV, out); 13817 verifyResultsConvertLong4Uchar4(inV, out, true); 13818 } catch (Exception e) { 13819 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString()); 13820 } 13821 } 13822 verifyResultsConvertLong4Uchar4(Allocation inV, Allocation out, boolean relaxed)13823 private void verifyResultsConvertLong4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 13824 long[] arrayInV = new long[INPUTSIZE * 4]; 13825 Arrays.fill(arrayInV, (long) 42); 13826 inV.copyTo(arrayInV); 13827 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13828 Arrays.fill(arrayOut, (byte) 42); 13829 out.copyTo(arrayOut); 13830 StringBuilder message = new StringBuilder(); 13831 boolean errorFound = false; 13832 for (int i = 0; i < INPUTSIZE; i++) { 13833 for (int j = 0; j < 4 ; j++) { 13834 // Extract the inputs. 13835 ArgumentsLongUchar args = new ArgumentsLongUchar(); 13836 args.inV = arrayInV[i * 4 + j]; 13837 // Figure out what the outputs should have been. 13838 CoreMathVerifier.computeConvert(args); 13839 // Validate the outputs. 13840 boolean valid = true; 13841 if (args.out != arrayOut[i * 4 + j]) { 13842 valid = false; 13843 } 13844 if (!valid) { 13845 if (!errorFound) { 13846 errorFound = true; 13847 message.append("Input inV: "); 13848 appendVariableToMessage(message, args.inV); 13849 message.append("\n"); 13850 message.append("Expected output out: "); 13851 appendVariableToMessage(message, args.out); 13852 message.append("\n"); 13853 message.append("Actual output out: "); 13854 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13855 if (args.out != arrayOut[i * 4 + j]) { 13856 message.append(" FAIL"); 13857 } 13858 message.append("\n"); 13859 message.append("Errors at"); 13860 } 13861 message.append(" ["); 13862 message.append(Integer.toString(i)); 13863 message.append(", "); 13864 message.append(Integer.toString(j)); 13865 message.append("]"); 13866 } 13867 } 13868 } 13869 assertFalse("Incorrect output for checkConvertLong4Uchar4" + 13870 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13871 } 13872 13873 public class ArgumentsUlongUchar { 13874 public long inV; 13875 public byte out; 13876 } 13877 checkConvertUlong2Uchar2()13878 private void checkConvertUlong2Uchar2() { 13879 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x1fa8b492l, false, 8); 13880 try { 13881 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 13882 script.forEach_testConvertUchar2Ulong2Uchar2(inV, out); 13883 verifyResultsConvertUlong2Uchar2(inV, out, false); 13884 } catch (Exception e) { 13885 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString()); 13886 } 13887 try { 13888 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 13889 scriptRelaxed.forEach_testConvertUchar2Ulong2Uchar2(inV, out); 13890 verifyResultsConvertUlong2Uchar2(inV, out, true); 13891 } catch (Exception e) { 13892 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString()); 13893 } 13894 } 13895 verifyResultsConvertUlong2Uchar2(Allocation inV, Allocation out, boolean relaxed)13896 private void verifyResultsConvertUlong2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 13897 long[] arrayInV = new long[INPUTSIZE * 2]; 13898 Arrays.fill(arrayInV, (long) 42); 13899 inV.copyTo(arrayInV); 13900 byte[] arrayOut = new byte[INPUTSIZE * 2]; 13901 Arrays.fill(arrayOut, (byte) 42); 13902 out.copyTo(arrayOut); 13903 StringBuilder message = new StringBuilder(); 13904 boolean errorFound = false; 13905 for (int i = 0; i < INPUTSIZE; i++) { 13906 for (int j = 0; j < 2 ; j++) { 13907 // Extract the inputs. 13908 ArgumentsUlongUchar args = new ArgumentsUlongUchar(); 13909 args.inV = arrayInV[i * 2 + j]; 13910 // Figure out what the outputs should have been. 13911 CoreMathVerifier.computeConvert(args); 13912 // Validate the outputs. 13913 boolean valid = true; 13914 if (args.out != arrayOut[i * 2 + j]) { 13915 valid = false; 13916 } 13917 if (!valid) { 13918 if (!errorFound) { 13919 errorFound = true; 13920 message.append("Input inV: "); 13921 appendVariableToMessage(message, args.inV); 13922 message.append("\n"); 13923 message.append("Expected output out: "); 13924 appendVariableToMessage(message, args.out); 13925 message.append("\n"); 13926 message.append("Actual output out: "); 13927 appendVariableToMessage(message, arrayOut[i * 2 + j]); 13928 if (args.out != arrayOut[i * 2 + j]) { 13929 message.append(" FAIL"); 13930 } 13931 message.append("\n"); 13932 message.append("Errors at"); 13933 } 13934 message.append(" ["); 13935 message.append(Integer.toString(i)); 13936 message.append(", "); 13937 message.append(Integer.toString(j)); 13938 message.append("]"); 13939 } 13940 } 13941 } 13942 assertFalse("Incorrect output for checkConvertUlong2Uchar2" + 13943 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 13944 } 13945 checkConvertUlong3Uchar3()13946 private void checkConvertUlong3Uchar3() { 13947 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x15c3d570l, false, 8); 13948 try { 13949 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 13950 script.forEach_testConvertUchar3Ulong3Uchar3(inV, out); 13951 verifyResultsConvertUlong3Uchar3(inV, out, false); 13952 } catch (Exception e) { 13953 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString()); 13954 } 13955 try { 13956 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 13957 scriptRelaxed.forEach_testConvertUchar3Ulong3Uchar3(inV, out); 13958 verifyResultsConvertUlong3Uchar3(inV, out, true); 13959 } catch (Exception e) { 13960 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString()); 13961 } 13962 } 13963 verifyResultsConvertUlong3Uchar3(Allocation inV, Allocation out, boolean relaxed)13964 private void verifyResultsConvertUlong3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 13965 long[] arrayInV = new long[INPUTSIZE * 4]; 13966 Arrays.fill(arrayInV, (long) 42); 13967 inV.copyTo(arrayInV); 13968 byte[] arrayOut = new byte[INPUTSIZE * 4]; 13969 Arrays.fill(arrayOut, (byte) 42); 13970 out.copyTo(arrayOut); 13971 StringBuilder message = new StringBuilder(); 13972 boolean errorFound = false; 13973 for (int i = 0; i < INPUTSIZE; i++) { 13974 for (int j = 0; j < 3 ; j++) { 13975 // Extract the inputs. 13976 ArgumentsUlongUchar args = new ArgumentsUlongUchar(); 13977 args.inV = arrayInV[i * 4 + j]; 13978 // Figure out what the outputs should have been. 13979 CoreMathVerifier.computeConvert(args); 13980 // Validate the outputs. 13981 boolean valid = true; 13982 if (args.out != arrayOut[i * 4 + j]) { 13983 valid = false; 13984 } 13985 if (!valid) { 13986 if (!errorFound) { 13987 errorFound = true; 13988 message.append("Input inV: "); 13989 appendVariableToMessage(message, args.inV); 13990 message.append("\n"); 13991 message.append("Expected output out: "); 13992 appendVariableToMessage(message, args.out); 13993 message.append("\n"); 13994 message.append("Actual output out: "); 13995 appendVariableToMessage(message, arrayOut[i * 4 + j]); 13996 if (args.out != arrayOut[i * 4 + j]) { 13997 message.append(" FAIL"); 13998 } 13999 message.append("\n"); 14000 message.append("Errors at"); 14001 } 14002 message.append(" ["); 14003 message.append(Integer.toString(i)); 14004 message.append(", "); 14005 message.append(Integer.toString(j)); 14006 message.append("]"); 14007 } 14008 } 14009 } 14010 assertFalse("Incorrect output for checkConvertUlong3Uchar3" + 14011 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14012 } 14013 checkConvertUlong4Uchar4()14014 private void checkConvertUlong4Uchar4() { 14015 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xbdef64el, false, 8); 14016 try { 14017 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14018 script.forEach_testConvertUchar4Ulong4Uchar4(inV, out); 14019 verifyResultsConvertUlong4Uchar4(inV, out, false); 14020 } catch (Exception e) { 14021 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString()); 14022 } 14023 try { 14024 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 14025 scriptRelaxed.forEach_testConvertUchar4Ulong4Uchar4(inV, out); 14026 verifyResultsConvertUlong4Uchar4(inV, out, true); 14027 } catch (Exception e) { 14028 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString()); 14029 } 14030 } 14031 verifyResultsConvertUlong4Uchar4(Allocation inV, Allocation out, boolean relaxed)14032 private void verifyResultsConvertUlong4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 14033 long[] arrayInV = new long[INPUTSIZE * 4]; 14034 Arrays.fill(arrayInV, (long) 42); 14035 inV.copyTo(arrayInV); 14036 byte[] arrayOut = new byte[INPUTSIZE * 4]; 14037 Arrays.fill(arrayOut, (byte) 42); 14038 out.copyTo(arrayOut); 14039 StringBuilder message = new StringBuilder(); 14040 boolean errorFound = false; 14041 for (int i = 0; i < INPUTSIZE; i++) { 14042 for (int j = 0; j < 4 ; j++) { 14043 // Extract the inputs. 14044 ArgumentsUlongUchar args = new ArgumentsUlongUchar(); 14045 args.inV = arrayInV[i * 4 + j]; 14046 // Figure out what the outputs should have been. 14047 CoreMathVerifier.computeConvert(args); 14048 // Validate the outputs. 14049 boolean valid = true; 14050 if (args.out != arrayOut[i * 4 + j]) { 14051 valid = false; 14052 } 14053 if (!valid) { 14054 if (!errorFound) { 14055 errorFound = true; 14056 message.append("Input inV: "); 14057 appendVariableToMessage(message, args.inV); 14058 message.append("\n"); 14059 message.append("Expected output out: "); 14060 appendVariableToMessage(message, args.out); 14061 message.append("\n"); 14062 message.append("Actual output out: "); 14063 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14064 if (args.out != arrayOut[i * 4 + j]) { 14065 message.append(" FAIL"); 14066 } 14067 message.append("\n"); 14068 message.append("Errors at"); 14069 } 14070 message.append(" ["); 14071 message.append(Integer.toString(i)); 14072 message.append(", "); 14073 message.append(Integer.toString(j)); 14074 message.append("]"); 14075 } 14076 } 14077 } 14078 assertFalse("Incorrect output for checkConvertUlong4Uchar4" + 14079 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14080 } 14081 14082 public class ArgumentsDoubleShort { 14083 public double inV; 14084 public short out; 14085 } 14086 checkConvertDouble2Short2()14087 private void checkConvertDouble2Short2() { 14088 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xbf1d55f9l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 14089 try { 14090 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14091 script.forEach_testConvertShort2Double2Short2(inV, out); 14092 verifyResultsConvertDouble2Short2(inV, out, false); 14093 } catch (Exception e) { 14094 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString()); 14095 } 14096 try { 14097 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14098 scriptRelaxed.forEach_testConvertShort2Double2Short2(inV, out); 14099 verifyResultsConvertDouble2Short2(inV, out, true); 14100 } catch (Exception e) { 14101 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString()); 14102 } 14103 } 14104 verifyResultsConvertDouble2Short2(Allocation inV, Allocation out, boolean relaxed)14105 private void verifyResultsConvertDouble2Short2(Allocation inV, Allocation out, boolean relaxed) { 14106 double[] arrayInV = new double[INPUTSIZE * 2]; 14107 Arrays.fill(arrayInV, (double) 42); 14108 inV.copyTo(arrayInV); 14109 short[] arrayOut = new short[INPUTSIZE * 2]; 14110 Arrays.fill(arrayOut, (short) 42); 14111 out.copyTo(arrayOut); 14112 StringBuilder message = new StringBuilder(); 14113 boolean errorFound = false; 14114 for (int i = 0; i < INPUTSIZE; i++) { 14115 for (int j = 0; j < 2 ; j++) { 14116 // Extract the inputs. 14117 ArgumentsDoubleShort args = new ArgumentsDoubleShort(); 14118 args.inV = arrayInV[i * 2 + j]; 14119 // Figure out what the outputs should have been. 14120 CoreMathVerifier.computeConvert(args); 14121 // Validate the outputs. 14122 boolean valid = true; 14123 if (args.out != arrayOut[i * 2 + j]) { 14124 valid = false; 14125 } 14126 if (!valid) { 14127 if (!errorFound) { 14128 errorFound = true; 14129 message.append("Input inV: "); 14130 appendVariableToMessage(message, args.inV); 14131 message.append("\n"); 14132 message.append("Expected output out: "); 14133 appendVariableToMessage(message, args.out); 14134 message.append("\n"); 14135 message.append("Actual output out: "); 14136 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14137 if (args.out != arrayOut[i * 2 + j]) { 14138 message.append(" FAIL"); 14139 } 14140 message.append("\n"); 14141 message.append("Errors at"); 14142 } 14143 message.append(" ["); 14144 message.append(Integer.toString(i)); 14145 message.append(", "); 14146 message.append(Integer.toString(j)); 14147 message.append("]"); 14148 } 14149 } 14150 } 14151 assertFalse("Incorrect output for checkConvertDouble2Short2" + 14152 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14153 } 14154 checkConvertDouble3Short3()14155 private void checkConvertDouble3Short3() { 14156 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xb53876d7l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 14157 try { 14158 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14159 script.forEach_testConvertShort3Double3Short3(inV, out); 14160 verifyResultsConvertDouble3Short3(inV, out, false); 14161 } catch (Exception e) { 14162 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString()); 14163 } 14164 try { 14165 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14166 scriptRelaxed.forEach_testConvertShort3Double3Short3(inV, out); 14167 verifyResultsConvertDouble3Short3(inV, out, true); 14168 } catch (Exception e) { 14169 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString()); 14170 } 14171 } 14172 verifyResultsConvertDouble3Short3(Allocation inV, Allocation out, boolean relaxed)14173 private void verifyResultsConvertDouble3Short3(Allocation inV, Allocation out, boolean relaxed) { 14174 double[] arrayInV = new double[INPUTSIZE * 4]; 14175 Arrays.fill(arrayInV, (double) 42); 14176 inV.copyTo(arrayInV); 14177 short[] arrayOut = new short[INPUTSIZE * 4]; 14178 Arrays.fill(arrayOut, (short) 42); 14179 out.copyTo(arrayOut); 14180 StringBuilder message = new StringBuilder(); 14181 boolean errorFound = false; 14182 for (int i = 0; i < INPUTSIZE; i++) { 14183 for (int j = 0; j < 3 ; j++) { 14184 // Extract the inputs. 14185 ArgumentsDoubleShort args = new ArgumentsDoubleShort(); 14186 args.inV = arrayInV[i * 4 + j]; 14187 // Figure out what the outputs should have been. 14188 CoreMathVerifier.computeConvert(args); 14189 // Validate the outputs. 14190 boolean valid = true; 14191 if (args.out != arrayOut[i * 4 + j]) { 14192 valid = false; 14193 } 14194 if (!valid) { 14195 if (!errorFound) { 14196 errorFound = true; 14197 message.append("Input inV: "); 14198 appendVariableToMessage(message, args.inV); 14199 message.append("\n"); 14200 message.append("Expected output out: "); 14201 appendVariableToMessage(message, args.out); 14202 message.append("\n"); 14203 message.append("Actual output out: "); 14204 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14205 if (args.out != arrayOut[i * 4 + j]) { 14206 message.append(" FAIL"); 14207 } 14208 message.append("\n"); 14209 message.append("Errors at"); 14210 } 14211 message.append(" ["); 14212 message.append(Integer.toString(i)); 14213 message.append(", "); 14214 message.append(Integer.toString(j)); 14215 message.append("]"); 14216 } 14217 } 14218 } 14219 assertFalse("Incorrect output for checkConvertDouble3Short3" + 14220 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14221 } 14222 checkConvertDouble4Short4()14223 private void checkConvertDouble4Short4() { 14224 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xab5397b5l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); 14225 try { 14226 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14227 script.forEach_testConvertShort4Double4Short4(inV, out); 14228 verifyResultsConvertDouble4Short4(inV, out, false); 14229 } catch (Exception e) { 14230 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString()); 14231 } 14232 try { 14233 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14234 scriptRelaxed.forEach_testConvertShort4Double4Short4(inV, out); 14235 verifyResultsConvertDouble4Short4(inV, out, true); 14236 } catch (Exception e) { 14237 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString()); 14238 } 14239 } 14240 verifyResultsConvertDouble4Short4(Allocation inV, Allocation out, boolean relaxed)14241 private void verifyResultsConvertDouble4Short4(Allocation inV, Allocation out, boolean relaxed) { 14242 double[] arrayInV = new double[INPUTSIZE * 4]; 14243 Arrays.fill(arrayInV, (double) 42); 14244 inV.copyTo(arrayInV); 14245 short[] arrayOut = new short[INPUTSIZE * 4]; 14246 Arrays.fill(arrayOut, (short) 42); 14247 out.copyTo(arrayOut); 14248 StringBuilder message = new StringBuilder(); 14249 boolean errorFound = false; 14250 for (int i = 0; i < INPUTSIZE; i++) { 14251 for (int j = 0; j < 4 ; j++) { 14252 // Extract the inputs. 14253 ArgumentsDoubleShort args = new ArgumentsDoubleShort(); 14254 args.inV = arrayInV[i * 4 + j]; 14255 // Figure out what the outputs should have been. 14256 CoreMathVerifier.computeConvert(args); 14257 // Validate the outputs. 14258 boolean valid = true; 14259 if (args.out != arrayOut[i * 4 + j]) { 14260 valid = false; 14261 } 14262 if (!valid) { 14263 if (!errorFound) { 14264 errorFound = true; 14265 message.append("Input inV: "); 14266 appendVariableToMessage(message, args.inV); 14267 message.append("\n"); 14268 message.append("Expected output out: "); 14269 appendVariableToMessage(message, args.out); 14270 message.append("\n"); 14271 message.append("Actual output out: "); 14272 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14273 if (args.out != arrayOut[i * 4 + j]) { 14274 message.append(" FAIL"); 14275 } 14276 message.append("\n"); 14277 message.append("Errors at"); 14278 } 14279 message.append(" ["); 14280 message.append(Integer.toString(i)); 14281 message.append(", "); 14282 message.append(Integer.toString(j)); 14283 message.append("]"); 14284 } 14285 } 14286 } 14287 assertFalse("Incorrect output for checkConvertDouble4Short4" + 14288 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14289 } 14290 14291 public class ArgumentsLongShort { 14292 public long inV; 14293 public short out; 14294 } 14295 checkConvertLong2Short2()14296 private void checkConvertLong2Short2() { 14297 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x18de6600l, true, 15); 14298 try { 14299 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14300 script.forEach_testConvertShort2Long2Short2(inV, out); 14301 verifyResultsConvertLong2Short2(inV, out, false); 14302 } catch (Exception e) { 14303 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString()); 14304 } 14305 try { 14306 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14307 scriptRelaxed.forEach_testConvertShort2Long2Short2(inV, out); 14308 verifyResultsConvertLong2Short2(inV, out, true); 14309 } catch (Exception e) { 14310 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString()); 14311 } 14312 } 14313 verifyResultsConvertLong2Short2(Allocation inV, Allocation out, boolean relaxed)14314 private void verifyResultsConvertLong2Short2(Allocation inV, Allocation out, boolean relaxed) { 14315 long[] arrayInV = new long[INPUTSIZE * 2]; 14316 Arrays.fill(arrayInV, (long) 42); 14317 inV.copyTo(arrayInV); 14318 short[] arrayOut = new short[INPUTSIZE * 2]; 14319 Arrays.fill(arrayOut, (short) 42); 14320 out.copyTo(arrayOut); 14321 StringBuilder message = new StringBuilder(); 14322 boolean errorFound = false; 14323 for (int i = 0; i < INPUTSIZE; i++) { 14324 for (int j = 0; j < 2 ; j++) { 14325 // Extract the inputs. 14326 ArgumentsLongShort args = new ArgumentsLongShort(); 14327 args.inV = arrayInV[i * 2 + j]; 14328 // Figure out what the outputs should have been. 14329 CoreMathVerifier.computeConvert(args); 14330 // Validate the outputs. 14331 boolean valid = true; 14332 if (args.out != arrayOut[i * 2 + j]) { 14333 valid = false; 14334 } 14335 if (!valid) { 14336 if (!errorFound) { 14337 errorFound = true; 14338 message.append("Input inV: "); 14339 appendVariableToMessage(message, args.inV); 14340 message.append("\n"); 14341 message.append("Expected output out: "); 14342 appendVariableToMessage(message, args.out); 14343 message.append("\n"); 14344 message.append("Actual output out: "); 14345 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14346 if (args.out != arrayOut[i * 2 + j]) { 14347 message.append(" FAIL"); 14348 } 14349 message.append("\n"); 14350 message.append("Errors at"); 14351 } 14352 message.append(" ["); 14353 message.append(Integer.toString(i)); 14354 message.append(", "); 14355 message.append(Integer.toString(j)); 14356 message.append("]"); 14357 } 14358 } 14359 } 14360 assertFalse("Incorrect output for checkConvertLong2Short2" + 14361 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14362 } 14363 checkConvertLong3Short3()14364 private void checkConvertLong3Short3() { 14365 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xef986del, true, 15); 14366 try { 14367 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14368 script.forEach_testConvertShort3Long3Short3(inV, out); 14369 verifyResultsConvertLong3Short3(inV, out, false); 14370 } catch (Exception e) { 14371 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString()); 14372 } 14373 try { 14374 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14375 scriptRelaxed.forEach_testConvertShort3Long3Short3(inV, out); 14376 verifyResultsConvertLong3Short3(inV, out, true); 14377 } catch (Exception e) { 14378 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString()); 14379 } 14380 } 14381 verifyResultsConvertLong3Short3(Allocation inV, Allocation out, boolean relaxed)14382 private void verifyResultsConvertLong3Short3(Allocation inV, Allocation out, boolean relaxed) { 14383 long[] arrayInV = new long[INPUTSIZE * 4]; 14384 Arrays.fill(arrayInV, (long) 42); 14385 inV.copyTo(arrayInV); 14386 short[] arrayOut = new short[INPUTSIZE * 4]; 14387 Arrays.fill(arrayOut, (short) 42); 14388 out.copyTo(arrayOut); 14389 StringBuilder message = new StringBuilder(); 14390 boolean errorFound = false; 14391 for (int i = 0; i < INPUTSIZE; i++) { 14392 for (int j = 0; j < 3 ; j++) { 14393 // Extract the inputs. 14394 ArgumentsLongShort args = new ArgumentsLongShort(); 14395 args.inV = arrayInV[i * 4 + j]; 14396 // Figure out what the outputs should have been. 14397 CoreMathVerifier.computeConvert(args); 14398 // Validate the outputs. 14399 boolean valid = true; 14400 if (args.out != arrayOut[i * 4 + j]) { 14401 valid = false; 14402 } 14403 if (!valid) { 14404 if (!errorFound) { 14405 errorFound = true; 14406 message.append("Input inV: "); 14407 appendVariableToMessage(message, args.inV); 14408 message.append("\n"); 14409 message.append("Expected output out: "); 14410 appendVariableToMessage(message, args.out); 14411 message.append("\n"); 14412 message.append("Actual output out: "); 14413 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14414 if (args.out != arrayOut[i * 4 + j]) { 14415 message.append(" FAIL"); 14416 } 14417 message.append("\n"); 14418 message.append("Errors at"); 14419 } 14420 message.append(" ["); 14421 message.append(Integer.toString(i)); 14422 message.append(", "); 14423 message.append(Integer.toString(j)); 14424 message.append("]"); 14425 } 14426 } 14427 } 14428 assertFalse("Incorrect output for checkConvertLong3Short3" + 14429 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14430 } 14431 checkConvertLong4Short4()14432 private void checkConvertLong4Short4() { 14433 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x514a7bcl, true, 15); 14434 try { 14435 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14436 script.forEach_testConvertShort4Long4Short4(inV, out); 14437 verifyResultsConvertLong4Short4(inV, out, false); 14438 } catch (Exception e) { 14439 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString()); 14440 } 14441 try { 14442 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14443 scriptRelaxed.forEach_testConvertShort4Long4Short4(inV, out); 14444 verifyResultsConvertLong4Short4(inV, out, true); 14445 } catch (Exception e) { 14446 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString()); 14447 } 14448 } 14449 verifyResultsConvertLong4Short4(Allocation inV, Allocation out, boolean relaxed)14450 private void verifyResultsConvertLong4Short4(Allocation inV, Allocation out, boolean relaxed) { 14451 long[] arrayInV = new long[INPUTSIZE * 4]; 14452 Arrays.fill(arrayInV, (long) 42); 14453 inV.copyTo(arrayInV); 14454 short[] arrayOut = new short[INPUTSIZE * 4]; 14455 Arrays.fill(arrayOut, (short) 42); 14456 out.copyTo(arrayOut); 14457 StringBuilder message = new StringBuilder(); 14458 boolean errorFound = false; 14459 for (int i = 0; i < INPUTSIZE; i++) { 14460 for (int j = 0; j < 4 ; j++) { 14461 // Extract the inputs. 14462 ArgumentsLongShort args = new ArgumentsLongShort(); 14463 args.inV = arrayInV[i * 4 + j]; 14464 // Figure out what the outputs should have been. 14465 CoreMathVerifier.computeConvert(args); 14466 // Validate the outputs. 14467 boolean valid = true; 14468 if (args.out != arrayOut[i * 4 + j]) { 14469 valid = false; 14470 } 14471 if (!valid) { 14472 if (!errorFound) { 14473 errorFound = true; 14474 message.append("Input inV: "); 14475 appendVariableToMessage(message, args.inV); 14476 message.append("\n"); 14477 message.append("Expected output out: "); 14478 appendVariableToMessage(message, args.out); 14479 message.append("\n"); 14480 message.append("Actual output out: "); 14481 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14482 if (args.out != arrayOut[i * 4 + j]) { 14483 message.append(" FAIL"); 14484 } 14485 message.append("\n"); 14486 message.append("Errors at"); 14487 } 14488 message.append(" ["); 14489 message.append(Integer.toString(i)); 14490 message.append(", "); 14491 message.append(Integer.toString(j)); 14492 message.append("]"); 14493 } 14494 } 14495 } 14496 assertFalse("Incorrect output for checkConvertLong4Short4" + 14497 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14498 } 14499 14500 public class ArgumentsUlongShort { 14501 public long inV; 14502 public short out; 14503 } 14504 checkConvertUlong2Short2()14505 private void checkConvertUlong2Short2() { 14506 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xb4b67fabl, false, 15); 14507 try { 14508 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14509 script.forEach_testConvertShort2Ulong2Short2(inV, out); 14510 verifyResultsConvertUlong2Short2(inV, out, false); 14511 } catch (Exception e) { 14512 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString()); 14513 } 14514 try { 14515 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 14516 scriptRelaxed.forEach_testConvertShort2Ulong2Short2(inV, out); 14517 verifyResultsConvertUlong2Short2(inV, out, true); 14518 } catch (Exception e) { 14519 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString()); 14520 } 14521 } 14522 verifyResultsConvertUlong2Short2(Allocation inV, Allocation out, boolean relaxed)14523 private void verifyResultsConvertUlong2Short2(Allocation inV, Allocation out, boolean relaxed) { 14524 long[] arrayInV = new long[INPUTSIZE * 2]; 14525 Arrays.fill(arrayInV, (long) 42); 14526 inV.copyTo(arrayInV); 14527 short[] arrayOut = new short[INPUTSIZE * 2]; 14528 Arrays.fill(arrayOut, (short) 42); 14529 out.copyTo(arrayOut); 14530 StringBuilder message = new StringBuilder(); 14531 boolean errorFound = false; 14532 for (int i = 0; i < INPUTSIZE; i++) { 14533 for (int j = 0; j < 2 ; j++) { 14534 // Extract the inputs. 14535 ArgumentsUlongShort args = new ArgumentsUlongShort(); 14536 args.inV = arrayInV[i * 2 + j]; 14537 // Figure out what the outputs should have been. 14538 CoreMathVerifier.computeConvert(args); 14539 // Validate the outputs. 14540 boolean valid = true; 14541 if (args.out != arrayOut[i * 2 + j]) { 14542 valid = false; 14543 } 14544 if (!valid) { 14545 if (!errorFound) { 14546 errorFound = true; 14547 message.append("Input inV: "); 14548 appendVariableToMessage(message, args.inV); 14549 message.append("\n"); 14550 message.append("Expected output out: "); 14551 appendVariableToMessage(message, args.out); 14552 message.append("\n"); 14553 message.append("Actual output out: "); 14554 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14555 if (args.out != arrayOut[i * 2 + j]) { 14556 message.append(" FAIL"); 14557 } 14558 message.append("\n"); 14559 message.append("Errors at"); 14560 } 14561 message.append(" ["); 14562 message.append(Integer.toString(i)); 14563 message.append(", "); 14564 message.append(Integer.toString(j)); 14565 message.append("]"); 14566 } 14567 } 14568 } 14569 assertFalse("Incorrect output for checkConvertUlong2Short2" + 14570 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14571 } 14572 checkConvertUlong3Short3()14573 private void checkConvertUlong3Short3() { 14574 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaad1a089l, false, 15); 14575 try { 14576 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14577 script.forEach_testConvertShort3Ulong3Short3(inV, out); 14578 verifyResultsConvertUlong3Short3(inV, out, false); 14579 } catch (Exception e) { 14580 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString()); 14581 } 14582 try { 14583 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 14584 scriptRelaxed.forEach_testConvertShort3Ulong3Short3(inV, out); 14585 verifyResultsConvertUlong3Short3(inV, out, true); 14586 } catch (Exception e) { 14587 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString()); 14588 } 14589 } 14590 verifyResultsConvertUlong3Short3(Allocation inV, Allocation out, boolean relaxed)14591 private void verifyResultsConvertUlong3Short3(Allocation inV, Allocation out, boolean relaxed) { 14592 long[] arrayInV = new long[INPUTSIZE * 4]; 14593 Arrays.fill(arrayInV, (long) 42); 14594 inV.copyTo(arrayInV); 14595 short[] arrayOut = new short[INPUTSIZE * 4]; 14596 Arrays.fill(arrayOut, (short) 42); 14597 out.copyTo(arrayOut); 14598 StringBuilder message = new StringBuilder(); 14599 boolean errorFound = false; 14600 for (int i = 0; i < INPUTSIZE; i++) { 14601 for (int j = 0; j < 3 ; j++) { 14602 // Extract the inputs. 14603 ArgumentsUlongShort args = new ArgumentsUlongShort(); 14604 args.inV = arrayInV[i * 4 + j]; 14605 // Figure out what the outputs should have been. 14606 CoreMathVerifier.computeConvert(args); 14607 // Validate the outputs. 14608 boolean valid = true; 14609 if (args.out != arrayOut[i * 4 + j]) { 14610 valid = false; 14611 } 14612 if (!valid) { 14613 if (!errorFound) { 14614 errorFound = true; 14615 message.append("Input inV: "); 14616 appendVariableToMessage(message, args.inV); 14617 message.append("\n"); 14618 message.append("Expected output out: "); 14619 appendVariableToMessage(message, args.out); 14620 message.append("\n"); 14621 message.append("Actual output out: "); 14622 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14623 if (args.out != arrayOut[i * 4 + j]) { 14624 message.append(" FAIL"); 14625 } 14626 message.append("\n"); 14627 message.append("Errors at"); 14628 } 14629 message.append(" ["); 14630 message.append(Integer.toString(i)); 14631 message.append(", "); 14632 message.append(Integer.toString(j)); 14633 message.append("]"); 14634 } 14635 } 14636 } 14637 assertFalse("Incorrect output for checkConvertUlong3Short3" + 14638 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14639 } 14640 checkConvertUlong4Short4()14641 private void checkConvertUlong4Short4() { 14642 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xa0ecc167l, false, 15); 14643 try { 14644 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14645 script.forEach_testConvertShort4Ulong4Short4(inV, out); 14646 verifyResultsConvertUlong4Short4(inV, out, false); 14647 } catch (Exception e) { 14648 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString()); 14649 } 14650 try { 14651 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 14652 scriptRelaxed.forEach_testConvertShort4Ulong4Short4(inV, out); 14653 verifyResultsConvertUlong4Short4(inV, out, true); 14654 } catch (Exception e) { 14655 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString()); 14656 } 14657 } 14658 verifyResultsConvertUlong4Short4(Allocation inV, Allocation out, boolean relaxed)14659 private void verifyResultsConvertUlong4Short4(Allocation inV, Allocation out, boolean relaxed) { 14660 long[] arrayInV = new long[INPUTSIZE * 4]; 14661 Arrays.fill(arrayInV, (long) 42); 14662 inV.copyTo(arrayInV); 14663 short[] arrayOut = new short[INPUTSIZE * 4]; 14664 Arrays.fill(arrayOut, (short) 42); 14665 out.copyTo(arrayOut); 14666 StringBuilder message = new StringBuilder(); 14667 boolean errorFound = false; 14668 for (int i = 0; i < INPUTSIZE; i++) { 14669 for (int j = 0; j < 4 ; j++) { 14670 // Extract the inputs. 14671 ArgumentsUlongShort args = new ArgumentsUlongShort(); 14672 args.inV = arrayInV[i * 4 + j]; 14673 // Figure out what the outputs should have been. 14674 CoreMathVerifier.computeConvert(args); 14675 // Validate the outputs. 14676 boolean valid = true; 14677 if (args.out != arrayOut[i * 4 + j]) { 14678 valid = false; 14679 } 14680 if (!valid) { 14681 if (!errorFound) { 14682 errorFound = true; 14683 message.append("Input inV: "); 14684 appendVariableToMessage(message, args.inV); 14685 message.append("\n"); 14686 message.append("Expected output out: "); 14687 appendVariableToMessage(message, args.out); 14688 message.append("\n"); 14689 message.append("Actual output out: "); 14690 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14691 if (args.out != arrayOut[i * 4 + j]) { 14692 message.append(" FAIL"); 14693 } 14694 message.append("\n"); 14695 message.append("Errors at"); 14696 } 14697 message.append(" ["); 14698 message.append(Integer.toString(i)); 14699 message.append(", "); 14700 message.append(Integer.toString(j)); 14701 message.append("]"); 14702 } 14703 } 14704 } 14705 assertFalse("Incorrect output for checkConvertUlong4Short4" + 14706 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14707 } 14708 14709 public class ArgumentsDoubleUshort { 14710 public double inV; 14711 public short out; 14712 } 14713 checkConvertDouble2Ushort2()14714 private void checkConvertDouble2Ushort2() { 14715 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xa92a37bcl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 14716 try { 14717 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 14718 script.forEach_testConvertUshort2Double2Ushort2(inV, out); 14719 verifyResultsConvertDouble2Ushort2(inV, out, false); 14720 } catch (Exception e) { 14721 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString()); 14722 } 14723 try { 14724 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 14725 scriptRelaxed.forEach_testConvertUshort2Double2Ushort2(inV, out); 14726 verifyResultsConvertDouble2Ushort2(inV, out, true); 14727 } catch (Exception e) { 14728 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString()); 14729 } 14730 } 14731 verifyResultsConvertDouble2Ushort2(Allocation inV, Allocation out, boolean relaxed)14732 private void verifyResultsConvertDouble2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 14733 double[] arrayInV = new double[INPUTSIZE * 2]; 14734 Arrays.fill(arrayInV, (double) 42); 14735 inV.copyTo(arrayInV); 14736 short[] arrayOut = new short[INPUTSIZE * 2]; 14737 Arrays.fill(arrayOut, (short) 42); 14738 out.copyTo(arrayOut); 14739 StringBuilder message = new StringBuilder(); 14740 boolean errorFound = false; 14741 for (int i = 0; i < INPUTSIZE; i++) { 14742 for (int j = 0; j < 2 ; j++) { 14743 // Extract the inputs. 14744 ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); 14745 args.inV = arrayInV[i * 2 + j]; 14746 // Figure out what the outputs should have been. 14747 CoreMathVerifier.computeConvert(args); 14748 // Validate the outputs. 14749 boolean valid = true; 14750 if (args.out != arrayOut[i * 2 + j]) { 14751 valid = false; 14752 } 14753 if (!valid) { 14754 if (!errorFound) { 14755 errorFound = true; 14756 message.append("Input inV: "); 14757 appendVariableToMessage(message, args.inV); 14758 message.append("\n"); 14759 message.append("Expected output out: "); 14760 appendVariableToMessage(message, args.out); 14761 message.append("\n"); 14762 message.append("Actual output out: "); 14763 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14764 if (args.out != arrayOut[i * 2 + j]) { 14765 message.append(" FAIL"); 14766 } 14767 message.append("\n"); 14768 message.append("Errors at"); 14769 } 14770 message.append(" ["); 14771 message.append(Integer.toString(i)); 14772 message.append(", "); 14773 message.append(Integer.toString(j)); 14774 message.append("]"); 14775 } 14776 } 14777 } 14778 assertFalse("Incorrect output for checkConvertDouble2Ushort2" + 14779 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14780 } 14781 checkConvertDouble3Ushort3()14782 private void checkConvertDouble3Ushort3() { 14783 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xff85c8e8l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 14784 try { 14785 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 14786 script.forEach_testConvertUshort3Double3Ushort3(inV, out); 14787 verifyResultsConvertDouble3Ushort3(inV, out, false); 14788 } catch (Exception e) { 14789 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString()); 14790 } 14791 try { 14792 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 14793 scriptRelaxed.forEach_testConvertUshort3Double3Ushort3(inV, out); 14794 verifyResultsConvertDouble3Ushort3(inV, out, true); 14795 } catch (Exception e) { 14796 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString()); 14797 } 14798 } 14799 verifyResultsConvertDouble3Ushort3(Allocation inV, Allocation out, boolean relaxed)14800 private void verifyResultsConvertDouble3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 14801 double[] arrayInV = new double[INPUTSIZE * 4]; 14802 Arrays.fill(arrayInV, (double) 42); 14803 inV.copyTo(arrayInV); 14804 short[] arrayOut = new short[INPUTSIZE * 4]; 14805 Arrays.fill(arrayOut, (short) 42); 14806 out.copyTo(arrayOut); 14807 StringBuilder message = new StringBuilder(); 14808 boolean errorFound = false; 14809 for (int i = 0; i < INPUTSIZE; i++) { 14810 for (int j = 0; j < 3 ; j++) { 14811 // Extract the inputs. 14812 ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); 14813 args.inV = arrayInV[i * 4 + j]; 14814 // Figure out what the outputs should have been. 14815 CoreMathVerifier.computeConvert(args); 14816 // Validate the outputs. 14817 boolean valid = true; 14818 if (args.out != arrayOut[i * 4 + j]) { 14819 valid = false; 14820 } 14821 if (!valid) { 14822 if (!errorFound) { 14823 errorFound = true; 14824 message.append("Input inV: "); 14825 appendVariableToMessage(message, args.inV); 14826 message.append("\n"); 14827 message.append("Expected output out: "); 14828 appendVariableToMessage(message, args.out); 14829 message.append("\n"); 14830 message.append("Actual output out: "); 14831 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14832 if (args.out != arrayOut[i * 4 + j]) { 14833 message.append(" FAIL"); 14834 } 14835 message.append("\n"); 14836 message.append("Errors at"); 14837 } 14838 message.append(" ["); 14839 message.append(Integer.toString(i)); 14840 message.append(", "); 14841 message.append(Integer.toString(j)); 14842 message.append("]"); 14843 } 14844 } 14845 } 14846 assertFalse("Incorrect output for checkConvertDouble3Ushort3" + 14847 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14848 } 14849 checkConvertDouble4Ushort4()14850 private void checkConvertDouble4Ushort4() { 14851 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x55e15a14l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); 14852 try { 14853 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 14854 script.forEach_testConvertUshort4Double4Ushort4(inV, out); 14855 verifyResultsConvertDouble4Ushort4(inV, out, false); 14856 } catch (Exception e) { 14857 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString()); 14858 } 14859 try { 14860 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 14861 scriptRelaxed.forEach_testConvertUshort4Double4Ushort4(inV, out); 14862 verifyResultsConvertDouble4Ushort4(inV, out, true); 14863 } catch (Exception e) { 14864 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString()); 14865 } 14866 } 14867 verifyResultsConvertDouble4Ushort4(Allocation inV, Allocation out, boolean relaxed)14868 private void verifyResultsConvertDouble4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 14869 double[] arrayInV = new double[INPUTSIZE * 4]; 14870 Arrays.fill(arrayInV, (double) 42); 14871 inV.copyTo(arrayInV); 14872 short[] arrayOut = new short[INPUTSIZE * 4]; 14873 Arrays.fill(arrayOut, (short) 42); 14874 out.copyTo(arrayOut); 14875 StringBuilder message = new StringBuilder(); 14876 boolean errorFound = false; 14877 for (int i = 0; i < INPUTSIZE; i++) { 14878 for (int j = 0; j < 4 ; j++) { 14879 // Extract the inputs. 14880 ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); 14881 args.inV = arrayInV[i * 4 + j]; 14882 // Figure out what the outputs should have been. 14883 CoreMathVerifier.computeConvert(args); 14884 // Validate the outputs. 14885 boolean valid = true; 14886 if (args.out != arrayOut[i * 4 + j]) { 14887 valid = false; 14888 } 14889 if (!valid) { 14890 if (!errorFound) { 14891 errorFound = true; 14892 message.append("Input inV: "); 14893 appendVariableToMessage(message, args.inV); 14894 message.append("\n"); 14895 message.append("Expected output out: "); 14896 appendVariableToMessage(message, args.out); 14897 message.append("\n"); 14898 message.append("Actual output out: "); 14899 appendVariableToMessage(message, arrayOut[i * 4 + j]); 14900 if (args.out != arrayOut[i * 4 + j]) { 14901 message.append(" FAIL"); 14902 } 14903 message.append("\n"); 14904 message.append("Errors at"); 14905 } 14906 message.append(" ["); 14907 message.append(Integer.toString(i)); 14908 message.append(", "); 14909 message.append(Integer.toString(j)); 14910 message.append("]"); 14911 } 14912 } 14913 } 14914 assertFalse("Incorrect output for checkConvertDouble4Ushort4" + 14915 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14916 } 14917 14918 public class ArgumentsLongUshort { 14919 public long inV; 14920 public short out; 14921 } 14922 checkConvertLong2Ushort2()14923 private void checkConvertLong2Ushort2() { 14924 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xbc97e8e9l, false, 16); 14925 try { 14926 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 14927 script.forEach_testConvertUshort2Long2Ushort2(inV, out); 14928 verifyResultsConvertLong2Ushort2(inV, out, false); 14929 } catch (Exception e) { 14930 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString()); 14931 } 14932 try { 14933 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 14934 scriptRelaxed.forEach_testConvertUshort2Long2Ushort2(inV, out); 14935 verifyResultsConvertLong2Ushort2(inV, out, true); 14936 } catch (Exception e) { 14937 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString()); 14938 } 14939 } 14940 verifyResultsConvertLong2Ushort2(Allocation inV, Allocation out, boolean relaxed)14941 private void verifyResultsConvertLong2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 14942 long[] arrayInV = new long[INPUTSIZE * 2]; 14943 Arrays.fill(arrayInV, (long) 42); 14944 inV.copyTo(arrayInV); 14945 short[] arrayOut = new short[INPUTSIZE * 2]; 14946 Arrays.fill(arrayOut, (short) 42); 14947 out.copyTo(arrayOut); 14948 StringBuilder message = new StringBuilder(); 14949 boolean errorFound = false; 14950 for (int i = 0; i < INPUTSIZE; i++) { 14951 for (int j = 0; j < 2 ; j++) { 14952 // Extract the inputs. 14953 ArgumentsLongUshort args = new ArgumentsLongUshort(); 14954 args.inV = arrayInV[i * 2 + j]; 14955 // Figure out what the outputs should have been. 14956 CoreMathVerifier.computeConvert(args); 14957 // Validate the outputs. 14958 boolean valid = true; 14959 if (args.out != arrayOut[i * 2 + j]) { 14960 valid = false; 14961 } 14962 if (!valid) { 14963 if (!errorFound) { 14964 errorFound = true; 14965 message.append("Input inV: "); 14966 appendVariableToMessage(message, args.inV); 14967 message.append("\n"); 14968 message.append("Expected output out: "); 14969 appendVariableToMessage(message, args.out); 14970 message.append("\n"); 14971 message.append("Actual output out: "); 14972 appendVariableToMessage(message, arrayOut[i * 2 + j]); 14973 if (args.out != arrayOut[i * 2 + j]) { 14974 message.append(" FAIL"); 14975 } 14976 message.append("\n"); 14977 message.append("Errors at"); 14978 } 14979 message.append(" ["); 14980 message.append(Integer.toString(i)); 14981 message.append(", "); 14982 message.append(Integer.toString(j)); 14983 message.append("]"); 14984 } 14985 } 14986 } 14987 assertFalse("Incorrect output for checkConvertLong2Ushort2" + 14988 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 14989 } 14990 checkConvertLong3Ushort3()14991 private void checkConvertLong3Ushort3() { 14992 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x12f37a15l, false, 16); 14993 try { 14994 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 14995 script.forEach_testConvertUshort3Long3Ushort3(inV, out); 14996 verifyResultsConvertLong3Ushort3(inV, out, false); 14997 } catch (Exception e) { 14998 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString()); 14999 } 15000 try { 15001 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15002 scriptRelaxed.forEach_testConvertUshort3Long3Ushort3(inV, out); 15003 verifyResultsConvertLong3Ushort3(inV, out, true); 15004 } catch (Exception e) { 15005 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString()); 15006 } 15007 } 15008 verifyResultsConvertLong3Ushort3(Allocation inV, Allocation out, boolean relaxed)15009 private void verifyResultsConvertLong3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 15010 long[] arrayInV = new long[INPUTSIZE * 4]; 15011 Arrays.fill(arrayInV, (long) 42); 15012 inV.copyTo(arrayInV); 15013 short[] arrayOut = new short[INPUTSIZE * 4]; 15014 Arrays.fill(arrayOut, (short) 42); 15015 out.copyTo(arrayOut); 15016 StringBuilder message = new StringBuilder(); 15017 boolean errorFound = false; 15018 for (int i = 0; i < INPUTSIZE; i++) { 15019 for (int j = 0; j < 3 ; j++) { 15020 // Extract the inputs. 15021 ArgumentsLongUshort args = new ArgumentsLongUshort(); 15022 args.inV = arrayInV[i * 4 + j]; 15023 // Figure out what the outputs should have been. 15024 CoreMathVerifier.computeConvert(args); 15025 // Validate the outputs. 15026 boolean valid = true; 15027 if (args.out != arrayOut[i * 4 + j]) { 15028 valid = false; 15029 } 15030 if (!valid) { 15031 if (!errorFound) { 15032 errorFound = true; 15033 message.append("Input inV: "); 15034 appendVariableToMessage(message, args.inV); 15035 message.append("\n"); 15036 message.append("Expected output out: "); 15037 appendVariableToMessage(message, args.out); 15038 message.append("\n"); 15039 message.append("Actual output out: "); 15040 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15041 if (args.out != arrayOut[i * 4 + j]) { 15042 message.append(" FAIL"); 15043 } 15044 message.append("\n"); 15045 message.append("Errors at"); 15046 } 15047 message.append(" ["); 15048 message.append(Integer.toString(i)); 15049 message.append(", "); 15050 message.append(Integer.toString(j)); 15051 message.append("]"); 15052 } 15053 } 15054 } 15055 assertFalse("Incorrect output for checkConvertLong3Ushort3" + 15056 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15057 } 15058 checkConvertLong4Ushort4()15059 private void checkConvertLong4Ushort4() { 15060 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x694f0b41l, false, 16); 15061 try { 15062 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15063 script.forEach_testConvertUshort4Long4Ushort4(inV, out); 15064 verifyResultsConvertLong4Ushort4(inV, out, false); 15065 } catch (Exception e) { 15066 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString()); 15067 } 15068 try { 15069 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15070 scriptRelaxed.forEach_testConvertUshort4Long4Ushort4(inV, out); 15071 verifyResultsConvertLong4Ushort4(inV, out, true); 15072 } catch (Exception e) { 15073 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString()); 15074 } 15075 } 15076 verifyResultsConvertLong4Ushort4(Allocation inV, Allocation out, boolean relaxed)15077 private void verifyResultsConvertLong4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 15078 long[] arrayInV = new long[INPUTSIZE * 4]; 15079 Arrays.fill(arrayInV, (long) 42); 15080 inV.copyTo(arrayInV); 15081 short[] arrayOut = new short[INPUTSIZE * 4]; 15082 Arrays.fill(arrayOut, (short) 42); 15083 out.copyTo(arrayOut); 15084 StringBuilder message = new StringBuilder(); 15085 boolean errorFound = false; 15086 for (int i = 0; i < INPUTSIZE; i++) { 15087 for (int j = 0; j < 4 ; j++) { 15088 // Extract the inputs. 15089 ArgumentsLongUshort args = new ArgumentsLongUshort(); 15090 args.inV = arrayInV[i * 4 + j]; 15091 // Figure out what the outputs should have been. 15092 CoreMathVerifier.computeConvert(args); 15093 // Validate the outputs. 15094 boolean valid = true; 15095 if (args.out != arrayOut[i * 4 + j]) { 15096 valid = false; 15097 } 15098 if (!valid) { 15099 if (!errorFound) { 15100 errorFound = true; 15101 message.append("Input inV: "); 15102 appendVariableToMessage(message, args.inV); 15103 message.append("\n"); 15104 message.append("Expected output out: "); 15105 appendVariableToMessage(message, args.out); 15106 message.append("\n"); 15107 message.append("Actual output out: "); 15108 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15109 if (args.out != arrayOut[i * 4 + j]) { 15110 message.append(" FAIL"); 15111 } 15112 message.append("\n"); 15113 message.append("Errors at"); 15114 } 15115 message.append(" ["); 15116 message.append(Integer.toString(i)); 15117 message.append(", "); 15118 message.append(Integer.toString(j)); 15119 message.append("]"); 15120 } 15121 } 15122 } 15123 assertFalse("Incorrect output for checkConvertLong4Ushort4" + 15124 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15125 } 15126 15127 public class ArgumentsUlongUshort { 15128 public long inV; 15129 public short out; 15130 } 15131 checkConvertUlong2Ushort2()15132 private void checkConvertUlong2Ushort2() { 15133 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe9e438a2l, false, 16); 15134 try { 15135 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15136 script.forEach_testConvertUshort2Ulong2Ushort2(inV, out); 15137 verifyResultsConvertUlong2Ushort2(inV, out, false); 15138 } catch (Exception e) { 15139 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString()); 15140 } 15141 try { 15142 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 15143 scriptRelaxed.forEach_testConvertUshort2Ulong2Ushort2(inV, out); 15144 verifyResultsConvertUlong2Ushort2(inV, out, true); 15145 } catch (Exception e) { 15146 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString()); 15147 } 15148 } 15149 verifyResultsConvertUlong2Ushort2(Allocation inV, Allocation out, boolean relaxed)15150 private void verifyResultsConvertUlong2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 15151 long[] arrayInV = new long[INPUTSIZE * 2]; 15152 Arrays.fill(arrayInV, (long) 42); 15153 inV.copyTo(arrayInV); 15154 short[] arrayOut = new short[INPUTSIZE * 2]; 15155 Arrays.fill(arrayOut, (short) 42); 15156 out.copyTo(arrayOut); 15157 StringBuilder message = new StringBuilder(); 15158 boolean errorFound = false; 15159 for (int i = 0; i < INPUTSIZE; i++) { 15160 for (int j = 0; j < 2 ; j++) { 15161 // Extract the inputs. 15162 ArgumentsUlongUshort args = new ArgumentsUlongUshort(); 15163 args.inV = arrayInV[i * 2 + j]; 15164 // Figure out what the outputs should have been. 15165 CoreMathVerifier.computeConvert(args); 15166 // Validate the outputs. 15167 boolean valid = true; 15168 if (args.out != arrayOut[i * 2 + j]) { 15169 valid = false; 15170 } 15171 if (!valid) { 15172 if (!errorFound) { 15173 errorFound = true; 15174 message.append("Input inV: "); 15175 appendVariableToMessage(message, args.inV); 15176 message.append("\n"); 15177 message.append("Expected output out: "); 15178 appendVariableToMessage(message, args.out); 15179 message.append("\n"); 15180 message.append("Actual output out: "); 15181 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15182 if (args.out != arrayOut[i * 2 + j]) { 15183 message.append(" FAIL"); 15184 } 15185 message.append("\n"); 15186 message.append("Errors at"); 15187 } 15188 message.append(" ["); 15189 message.append(Integer.toString(i)); 15190 message.append(", "); 15191 message.append(Integer.toString(j)); 15192 message.append("]"); 15193 } 15194 } 15195 } 15196 assertFalse("Incorrect output for checkConvertUlong2Ushort2" + 15197 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15198 } 15199 checkConvertUlong3Ushort3()15200 private void checkConvertUlong3Ushort3() { 15201 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x403fc9cel, false, 16); 15202 try { 15203 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15204 script.forEach_testConvertUshort3Ulong3Ushort3(inV, out); 15205 verifyResultsConvertUlong3Ushort3(inV, out, false); 15206 } catch (Exception e) { 15207 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString()); 15208 } 15209 try { 15210 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 15211 scriptRelaxed.forEach_testConvertUshort3Ulong3Ushort3(inV, out); 15212 verifyResultsConvertUlong3Ushort3(inV, out, true); 15213 } catch (Exception e) { 15214 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString()); 15215 } 15216 } 15217 verifyResultsConvertUlong3Ushort3(Allocation inV, Allocation out, boolean relaxed)15218 private void verifyResultsConvertUlong3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 15219 long[] arrayInV = new long[INPUTSIZE * 4]; 15220 Arrays.fill(arrayInV, (long) 42); 15221 inV.copyTo(arrayInV); 15222 short[] arrayOut = new short[INPUTSIZE * 4]; 15223 Arrays.fill(arrayOut, (short) 42); 15224 out.copyTo(arrayOut); 15225 StringBuilder message = new StringBuilder(); 15226 boolean errorFound = false; 15227 for (int i = 0; i < INPUTSIZE; i++) { 15228 for (int j = 0; j < 3 ; j++) { 15229 // Extract the inputs. 15230 ArgumentsUlongUshort args = new ArgumentsUlongUshort(); 15231 args.inV = arrayInV[i * 4 + j]; 15232 // Figure out what the outputs should have been. 15233 CoreMathVerifier.computeConvert(args); 15234 // Validate the outputs. 15235 boolean valid = true; 15236 if (args.out != arrayOut[i * 4 + j]) { 15237 valid = false; 15238 } 15239 if (!valid) { 15240 if (!errorFound) { 15241 errorFound = true; 15242 message.append("Input inV: "); 15243 appendVariableToMessage(message, args.inV); 15244 message.append("\n"); 15245 message.append("Expected output out: "); 15246 appendVariableToMessage(message, args.out); 15247 message.append("\n"); 15248 message.append("Actual output out: "); 15249 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15250 if (args.out != arrayOut[i * 4 + j]) { 15251 message.append(" FAIL"); 15252 } 15253 message.append("\n"); 15254 message.append("Errors at"); 15255 } 15256 message.append(" ["); 15257 message.append(Integer.toString(i)); 15258 message.append(", "); 15259 message.append(Integer.toString(j)); 15260 message.append("]"); 15261 } 15262 } 15263 } 15264 assertFalse("Incorrect output for checkConvertUlong3Ushort3" + 15265 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15266 } 15267 checkConvertUlong4Ushort4()15268 private void checkConvertUlong4Ushort4() { 15269 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x969b5afal, false, 16); 15270 try { 15271 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15272 script.forEach_testConvertUshort4Ulong4Ushort4(inV, out); 15273 verifyResultsConvertUlong4Ushort4(inV, out, false); 15274 } catch (Exception e) { 15275 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString()); 15276 } 15277 try { 15278 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 15279 scriptRelaxed.forEach_testConvertUshort4Ulong4Ushort4(inV, out); 15280 verifyResultsConvertUlong4Ushort4(inV, out, true); 15281 } catch (Exception e) { 15282 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString()); 15283 } 15284 } 15285 verifyResultsConvertUlong4Ushort4(Allocation inV, Allocation out, boolean relaxed)15286 private void verifyResultsConvertUlong4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 15287 long[] arrayInV = new long[INPUTSIZE * 4]; 15288 Arrays.fill(arrayInV, (long) 42); 15289 inV.copyTo(arrayInV); 15290 short[] arrayOut = new short[INPUTSIZE * 4]; 15291 Arrays.fill(arrayOut, (short) 42); 15292 out.copyTo(arrayOut); 15293 StringBuilder message = new StringBuilder(); 15294 boolean errorFound = false; 15295 for (int i = 0; i < INPUTSIZE; i++) { 15296 for (int j = 0; j < 4 ; j++) { 15297 // Extract the inputs. 15298 ArgumentsUlongUshort args = new ArgumentsUlongUshort(); 15299 args.inV = arrayInV[i * 4 + j]; 15300 // Figure out what the outputs should have been. 15301 CoreMathVerifier.computeConvert(args); 15302 // Validate the outputs. 15303 boolean valid = true; 15304 if (args.out != arrayOut[i * 4 + j]) { 15305 valid = false; 15306 } 15307 if (!valid) { 15308 if (!errorFound) { 15309 errorFound = true; 15310 message.append("Input inV: "); 15311 appendVariableToMessage(message, args.inV); 15312 message.append("\n"); 15313 message.append("Expected output out: "); 15314 appendVariableToMessage(message, args.out); 15315 message.append("\n"); 15316 message.append("Actual output out: "); 15317 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15318 if (args.out != arrayOut[i * 4 + j]) { 15319 message.append(" FAIL"); 15320 } 15321 message.append("\n"); 15322 message.append("Errors at"); 15323 } 15324 message.append(" ["); 15325 message.append(Integer.toString(i)); 15326 message.append(", "); 15327 message.append(Integer.toString(j)); 15328 message.append("]"); 15329 } 15330 } 15331 } 15332 assertFalse("Incorrect output for checkConvertUlong4Ushort4" + 15333 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15334 } 15335 15336 public class ArgumentsDoubleInt { 15337 public double inV; 15338 public int out; 15339 } 15340 checkConvertDouble2Int2()15341 private void checkConvertDouble2Int2() { 15342 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcaf628fcl, -2.1474836480000000000e+09, 2.1474836470000000000e+09); 15343 try { 15344 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 15345 script.forEach_testConvertInt2Double2Int2(inV, out); 15346 verifyResultsConvertDouble2Int2(inV, out, false); 15347 } catch (Exception e) { 15348 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString()); 15349 } 15350 try { 15351 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 15352 scriptRelaxed.forEach_testConvertInt2Double2Int2(inV, out); 15353 verifyResultsConvertDouble2Int2(inV, out, true); 15354 } catch (Exception e) { 15355 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString()); 15356 } 15357 } 15358 verifyResultsConvertDouble2Int2(Allocation inV, Allocation out, boolean relaxed)15359 private void verifyResultsConvertDouble2Int2(Allocation inV, Allocation out, boolean relaxed) { 15360 double[] arrayInV = new double[INPUTSIZE * 2]; 15361 Arrays.fill(arrayInV, (double) 42); 15362 inV.copyTo(arrayInV); 15363 int[] arrayOut = new int[INPUTSIZE * 2]; 15364 Arrays.fill(arrayOut, (int) 42); 15365 out.copyTo(arrayOut); 15366 StringBuilder message = new StringBuilder(); 15367 boolean errorFound = false; 15368 for (int i = 0; i < INPUTSIZE; i++) { 15369 for (int j = 0; j < 2 ; j++) { 15370 // Extract the inputs. 15371 ArgumentsDoubleInt args = new ArgumentsDoubleInt(); 15372 args.inV = arrayInV[i * 2 + j]; 15373 // Figure out what the outputs should have been. 15374 CoreMathVerifier.computeConvert(args); 15375 // Validate the outputs. 15376 boolean valid = true; 15377 if (args.out != arrayOut[i * 2 + j]) { 15378 valid = false; 15379 } 15380 if (!valid) { 15381 if (!errorFound) { 15382 errorFound = true; 15383 message.append("Input inV: "); 15384 appendVariableToMessage(message, args.inV); 15385 message.append("\n"); 15386 message.append("Expected output out: "); 15387 appendVariableToMessage(message, args.out); 15388 message.append("\n"); 15389 message.append("Actual output out: "); 15390 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15391 if (args.out != arrayOut[i * 2 + j]) { 15392 message.append(" FAIL"); 15393 } 15394 message.append("\n"); 15395 message.append("Errors at"); 15396 } 15397 message.append(" ["); 15398 message.append(Integer.toString(i)); 15399 message.append(", "); 15400 message.append(Integer.toString(j)); 15401 message.append("]"); 15402 } 15403 } 15404 } 15405 assertFalse("Incorrect output for checkConvertDouble2Int2" + 15406 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15407 } 15408 checkConvertDouble3Int3()15409 private void checkConvertDouble3Int3() { 15410 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x149e3932l, -2.1474836480000000000e+09, 2.1474836470000000000e+09); 15411 try { 15412 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 15413 script.forEach_testConvertInt3Double3Int3(inV, out); 15414 verifyResultsConvertDouble3Int3(inV, out, false); 15415 } catch (Exception e) { 15416 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString()); 15417 } 15418 try { 15419 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 15420 scriptRelaxed.forEach_testConvertInt3Double3Int3(inV, out); 15421 verifyResultsConvertDouble3Int3(inV, out, true); 15422 } catch (Exception e) { 15423 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString()); 15424 } 15425 } 15426 verifyResultsConvertDouble3Int3(Allocation inV, Allocation out, boolean relaxed)15427 private void verifyResultsConvertDouble3Int3(Allocation inV, Allocation out, boolean relaxed) { 15428 double[] arrayInV = new double[INPUTSIZE * 4]; 15429 Arrays.fill(arrayInV, (double) 42); 15430 inV.copyTo(arrayInV); 15431 int[] arrayOut = new int[INPUTSIZE * 4]; 15432 Arrays.fill(arrayOut, (int) 42); 15433 out.copyTo(arrayOut); 15434 StringBuilder message = new StringBuilder(); 15435 boolean errorFound = false; 15436 for (int i = 0; i < INPUTSIZE; i++) { 15437 for (int j = 0; j < 3 ; j++) { 15438 // Extract the inputs. 15439 ArgumentsDoubleInt args = new ArgumentsDoubleInt(); 15440 args.inV = arrayInV[i * 4 + j]; 15441 // Figure out what the outputs should have been. 15442 CoreMathVerifier.computeConvert(args); 15443 // Validate the outputs. 15444 boolean valid = true; 15445 if (args.out != arrayOut[i * 4 + j]) { 15446 valid = false; 15447 } 15448 if (!valid) { 15449 if (!errorFound) { 15450 errorFound = true; 15451 message.append("Input inV: "); 15452 appendVariableToMessage(message, args.inV); 15453 message.append("\n"); 15454 message.append("Expected output out: "); 15455 appendVariableToMessage(message, args.out); 15456 message.append("\n"); 15457 message.append("Actual output out: "); 15458 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15459 if (args.out != arrayOut[i * 4 + j]) { 15460 message.append(" FAIL"); 15461 } 15462 message.append("\n"); 15463 message.append("Errors at"); 15464 } 15465 message.append(" ["); 15466 message.append(Integer.toString(i)); 15467 message.append(", "); 15468 message.append(Integer.toString(j)); 15469 message.append("]"); 15470 } 15471 } 15472 } 15473 assertFalse("Incorrect output for checkConvertDouble3Int3" + 15474 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15475 } 15476 checkConvertDouble4Int4()15477 private void checkConvertDouble4Int4() { 15478 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x5e464968l, -2.1474836480000000000e+09, 2.1474836470000000000e+09); 15479 try { 15480 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 15481 script.forEach_testConvertInt4Double4Int4(inV, out); 15482 verifyResultsConvertDouble4Int4(inV, out, false); 15483 } catch (Exception e) { 15484 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString()); 15485 } 15486 try { 15487 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 15488 scriptRelaxed.forEach_testConvertInt4Double4Int4(inV, out); 15489 verifyResultsConvertDouble4Int4(inV, out, true); 15490 } catch (Exception e) { 15491 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString()); 15492 } 15493 } 15494 verifyResultsConvertDouble4Int4(Allocation inV, Allocation out, boolean relaxed)15495 private void verifyResultsConvertDouble4Int4(Allocation inV, Allocation out, boolean relaxed) { 15496 double[] arrayInV = new double[INPUTSIZE * 4]; 15497 Arrays.fill(arrayInV, (double) 42); 15498 inV.copyTo(arrayInV); 15499 int[] arrayOut = new int[INPUTSIZE * 4]; 15500 Arrays.fill(arrayOut, (int) 42); 15501 out.copyTo(arrayOut); 15502 StringBuilder message = new StringBuilder(); 15503 boolean errorFound = false; 15504 for (int i = 0; i < INPUTSIZE; i++) { 15505 for (int j = 0; j < 4 ; j++) { 15506 // Extract the inputs. 15507 ArgumentsDoubleInt args = new ArgumentsDoubleInt(); 15508 args.inV = arrayInV[i * 4 + j]; 15509 // Figure out what the outputs should have been. 15510 CoreMathVerifier.computeConvert(args); 15511 // Validate the outputs. 15512 boolean valid = true; 15513 if (args.out != arrayOut[i * 4 + j]) { 15514 valid = false; 15515 } 15516 if (!valid) { 15517 if (!errorFound) { 15518 errorFound = true; 15519 message.append("Input inV: "); 15520 appendVariableToMessage(message, args.inV); 15521 message.append("\n"); 15522 message.append("Expected output out: "); 15523 appendVariableToMessage(message, args.out); 15524 message.append("\n"); 15525 message.append("Actual output out: "); 15526 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15527 if (args.out != arrayOut[i * 4 + j]) { 15528 message.append(" FAIL"); 15529 } 15530 message.append("\n"); 15531 message.append("Errors at"); 15532 } 15533 message.append(" ["); 15534 message.append(Integer.toString(i)); 15535 message.append(", "); 15536 message.append(Integer.toString(j)); 15537 message.append("]"); 15538 } 15539 } 15540 } 15541 assertFalse("Incorrect output for checkConvertDouble4Int4" + 15542 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15543 } 15544 15545 public class ArgumentsLongInt { 15546 public long inV; 15547 public int out; 15548 } 15549 checkConvertLong2Int2()15550 private void checkConvertLong2Int2() { 15551 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe5deba3bl, true, 31); 15552 try { 15553 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 15554 script.forEach_testConvertInt2Long2Int2(inV, out); 15555 verifyResultsConvertLong2Int2(inV, out, false); 15556 } catch (Exception e) { 15557 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString()); 15558 } 15559 try { 15560 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 15561 scriptRelaxed.forEach_testConvertInt2Long2Int2(inV, out); 15562 verifyResultsConvertLong2Int2(inV, out, true); 15563 } catch (Exception e) { 15564 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString()); 15565 } 15566 } 15567 verifyResultsConvertLong2Int2(Allocation inV, Allocation out, boolean relaxed)15568 private void verifyResultsConvertLong2Int2(Allocation inV, Allocation out, boolean relaxed) { 15569 long[] arrayInV = new long[INPUTSIZE * 2]; 15570 Arrays.fill(arrayInV, (long) 42); 15571 inV.copyTo(arrayInV); 15572 int[] arrayOut = new int[INPUTSIZE * 2]; 15573 Arrays.fill(arrayOut, (int) 42); 15574 out.copyTo(arrayOut); 15575 StringBuilder message = new StringBuilder(); 15576 boolean errorFound = false; 15577 for (int i = 0; i < INPUTSIZE; i++) { 15578 for (int j = 0; j < 2 ; j++) { 15579 // Extract the inputs. 15580 ArgumentsLongInt args = new ArgumentsLongInt(); 15581 args.inV = arrayInV[i * 2 + j]; 15582 // Figure out what the outputs should have been. 15583 CoreMathVerifier.computeConvert(args); 15584 // Validate the outputs. 15585 boolean valid = true; 15586 if (args.out != arrayOut[i * 2 + j]) { 15587 valid = false; 15588 } 15589 if (!valid) { 15590 if (!errorFound) { 15591 errorFound = true; 15592 message.append("Input inV: "); 15593 appendVariableToMessage(message, args.inV); 15594 message.append("\n"); 15595 message.append("Expected output out: "); 15596 appendVariableToMessage(message, args.out); 15597 message.append("\n"); 15598 message.append("Actual output out: "); 15599 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15600 if (args.out != arrayOut[i * 2 + j]) { 15601 message.append(" FAIL"); 15602 } 15603 message.append("\n"); 15604 message.append("Errors at"); 15605 } 15606 message.append(" ["); 15607 message.append(Integer.toString(i)); 15608 message.append(", "); 15609 message.append(Integer.toString(j)); 15610 message.append("]"); 15611 } 15612 } 15613 } 15614 assertFalse("Incorrect output for checkConvertLong2Int2" + 15615 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15616 } 15617 checkConvertLong3Int3()15618 private void checkConvertLong3Int3() { 15619 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2f86ca71l, true, 31); 15620 try { 15621 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 15622 script.forEach_testConvertInt3Long3Int3(inV, out); 15623 verifyResultsConvertLong3Int3(inV, out, false); 15624 } catch (Exception e) { 15625 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString()); 15626 } 15627 try { 15628 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 15629 scriptRelaxed.forEach_testConvertInt3Long3Int3(inV, out); 15630 verifyResultsConvertLong3Int3(inV, out, true); 15631 } catch (Exception e) { 15632 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString()); 15633 } 15634 } 15635 verifyResultsConvertLong3Int3(Allocation inV, Allocation out, boolean relaxed)15636 private void verifyResultsConvertLong3Int3(Allocation inV, Allocation out, boolean relaxed) { 15637 long[] arrayInV = new long[INPUTSIZE * 4]; 15638 Arrays.fill(arrayInV, (long) 42); 15639 inV.copyTo(arrayInV); 15640 int[] arrayOut = new int[INPUTSIZE * 4]; 15641 Arrays.fill(arrayOut, (int) 42); 15642 out.copyTo(arrayOut); 15643 StringBuilder message = new StringBuilder(); 15644 boolean errorFound = false; 15645 for (int i = 0; i < INPUTSIZE; i++) { 15646 for (int j = 0; j < 3 ; j++) { 15647 // Extract the inputs. 15648 ArgumentsLongInt args = new ArgumentsLongInt(); 15649 args.inV = arrayInV[i * 4 + j]; 15650 // Figure out what the outputs should have been. 15651 CoreMathVerifier.computeConvert(args); 15652 // Validate the outputs. 15653 boolean valid = true; 15654 if (args.out != arrayOut[i * 4 + j]) { 15655 valid = false; 15656 } 15657 if (!valid) { 15658 if (!errorFound) { 15659 errorFound = true; 15660 message.append("Input inV: "); 15661 appendVariableToMessage(message, args.inV); 15662 message.append("\n"); 15663 message.append("Expected output out: "); 15664 appendVariableToMessage(message, args.out); 15665 message.append("\n"); 15666 message.append("Actual output out: "); 15667 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15668 if (args.out != arrayOut[i * 4 + j]) { 15669 message.append(" FAIL"); 15670 } 15671 message.append("\n"); 15672 message.append("Errors at"); 15673 } 15674 message.append(" ["); 15675 message.append(Integer.toString(i)); 15676 message.append(", "); 15677 message.append(Integer.toString(j)); 15678 message.append("]"); 15679 } 15680 } 15681 } 15682 assertFalse("Incorrect output for checkConvertLong3Int3" + 15683 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15684 } 15685 checkConvertLong4Int4()15686 private void checkConvertLong4Int4() { 15687 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x792edaa7l, true, 31); 15688 try { 15689 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 15690 script.forEach_testConvertInt4Long4Int4(inV, out); 15691 verifyResultsConvertLong4Int4(inV, out, false); 15692 } catch (Exception e) { 15693 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString()); 15694 } 15695 try { 15696 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 15697 scriptRelaxed.forEach_testConvertInt4Long4Int4(inV, out); 15698 verifyResultsConvertLong4Int4(inV, out, true); 15699 } catch (Exception e) { 15700 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString()); 15701 } 15702 } 15703 verifyResultsConvertLong4Int4(Allocation inV, Allocation out, boolean relaxed)15704 private void verifyResultsConvertLong4Int4(Allocation inV, Allocation out, boolean relaxed) { 15705 long[] arrayInV = new long[INPUTSIZE * 4]; 15706 Arrays.fill(arrayInV, (long) 42); 15707 inV.copyTo(arrayInV); 15708 int[] arrayOut = new int[INPUTSIZE * 4]; 15709 Arrays.fill(arrayOut, (int) 42); 15710 out.copyTo(arrayOut); 15711 StringBuilder message = new StringBuilder(); 15712 boolean errorFound = false; 15713 for (int i = 0; i < INPUTSIZE; i++) { 15714 for (int j = 0; j < 4 ; j++) { 15715 // Extract the inputs. 15716 ArgumentsLongInt args = new ArgumentsLongInt(); 15717 args.inV = arrayInV[i * 4 + j]; 15718 // Figure out what the outputs should have been. 15719 CoreMathVerifier.computeConvert(args); 15720 // Validate the outputs. 15721 boolean valid = true; 15722 if (args.out != arrayOut[i * 4 + j]) { 15723 valid = false; 15724 } 15725 if (!valid) { 15726 if (!errorFound) { 15727 errorFound = true; 15728 message.append("Input inV: "); 15729 appendVariableToMessage(message, args.inV); 15730 message.append("\n"); 15731 message.append("Expected output out: "); 15732 appendVariableToMessage(message, args.out); 15733 message.append("\n"); 15734 message.append("Actual output out: "); 15735 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15736 if (args.out != arrayOut[i * 4 + j]) { 15737 message.append(" FAIL"); 15738 } 15739 message.append("\n"); 15740 message.append("Errors at"); 15741 } 15742 message.append(" ["); 15743 message.append(Integer.toString(i)); 15744 message.append(", "); 15745 message.append(Integer.toString(j)); 15746 message.append("]"); 15747 } 15748 } 15749 } 15750 assertFalse("Incorrect output for checkConvertLong4Int4" + 15751 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15752 } 15753 15754 public class ArgumentsUlongInt { 15755 public long inV; 15756 public int out; 15757 } 15758 checkConvertUlong2Int2()15759 private void checkConvertUlong2Int2() { 15760 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe352de3el, false, 31); 15761 try { 15762 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 15763 script.forEach_testConvertInt2Ulong2Int2(inV, out); 15764 verifyResultsConvertUlong2Int2(inV, out, false); 15765 } catch (Exception e) { 15766 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString()); 15767 } 15768 try { 15769 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 15770 scriptRelaxed.forEach_testConvertInt2Ulong2Int2(inV, out); 15771 verifyResultsConvertUlong2Int2(inV, out, true); 15772 } catch (Exception e) { 15773 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString()); 15774 } 15775 } 15776 verifyResultsConvertUlong2Int2(Allocation inV, Allocation out, boolean relaxed)15777 private void verifyResultsConvertUlong2Int2(Allocation inV, Allocation out, boolean relaxed) { 15778 long[] arrayInV = new long[INPUTSIZE * 2]; 15779 Arrays.fill(arrayInV, (long) 42); 15780 inV.copyTo(arrayInV); 15781 int[] arrayOut = new int[INPUTSIZE * 2]; 15782 Arrays.fill(arrayOut, (int) 42); 15783 out.copyTo(arrayOut); 15784 StringBuilder message = new StringBuilder(); 15785 boolean errorFound = false; 15786 for (int i = 0; i < INPUTSIZE; i++) { 15787 for (int j = 0; j < 2 ; j++) { 15788 // Extract the inputs. 15789 ArgumentsUlongInt args = new ArgumentsUlongInt(); 15790 args.inV = arrayInV[i * 2 + j]; 15791 // Figure out what the outputs should have been. 15792 CoreMathVerifier.computeConvert(args); 15793 // Validate the outputs. 15794 boolean valid = true; 15795 if (args.out != arrayOut[i * 2 + j]) { 15796 valid = false; 15797 } 15798 if (!valid) { 15799 if (!errorFound) { 15800 errorFound = true; 15801 message.append("Input inV: "); 15802 appendVariableToMessage(message, args.inV); 15803 message.append("\n"); 15804 message.append("Expected output out: "); 15805 appendVariableToMessage(message, args.out); 15806 message.append("\n"); 15807 message.append("Actual output out: "); 15808 appendVariableToMessage(message, arrayOut[i * 2 + j]); 15809 if (args.out != arrayOut[i * 2 + j]) { 15810 message.append(" FAIL"); 15811 } 15812 message.append("\n"); 15813 message.append("Errors at"); 15814 } 15815 message.append(" ["); 15816 message.append(Integer.toString(i)); 15817 message.append(", "); 15818 message.append(Integer.toString(j)); 15819 message.append("]"); 15820 } 15821 } 15822 } 15823 assertFalse("Incorrect output for checkConvertUlong2Int2" + 15824 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15825 } 15826 checkConvertUlong3Int3()15827 private void checkConvertUlong3Int3() { 15828 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2cfaee74l, false, 31); 15829 try { 15830 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 15831 script.forEach_testConvertInt3Ulong3Int3(inV, out); 15832 verifyResultsConvertUlong3Int3(inV, out, false); 15833 } catch (Exception e) { 15834 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString()); 15835 } 15836 try { 15837 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 15838 scriptRelaxed.forEach_testConvertInt3Ulong3Int3(inV, out); 15839 verifyResultsConvertUlong3Int3(inV, out, true); 15840 } catch (Exception e) { 15841 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString()); 15842 } 15843 } 15844 verifyResultsConvertUlong3Int3(Allocation inV, Allocation out, boolean relaxed)15845 private void verifyResultsConvertUlong3Int3(Allocation inV, Allocation out, boolean relaxed) { 15846 long[] arrayInV = new long[INPUTSIZE * 4]; 15847 Arrays.fill(arrayInV, (long) 42); 15848 inV.copyTo(arrayInV); 15849 int[] arrayOut = new int[INPUTSIZE * 4]; 15850 Arrays.fill(arrayOut, (int) 42); 15851 out.copyTo(arrayOut); 15852 StringBuilder message = new StringBuilder(); 15853 boolean errorFound = false; 15854 for (int i = 0; i < INPUTSIZE; i++) { 15855 for (int j = 0; j < 3 ; j++) { 15856 // Extract the inputs. 15857 ArgumentsUlongInt args = new ArgumentsUlongInt(); 15858 args.inV = arrayInV[i * 4 + j]; 15859 // Figure out what the outputs should have been. 15860 CoreMathVerifier.computeConvert(args); 15861 // Validate the outputs. 15862 boolean valid = true; 15863 if (args.out != arrayOut[i * 4 + j]) { 15864 valid = false; 15865 } 15866 if (!valid) { 15867 if (!errorFound) { 15868 errorFound = true; 15869 message.append("Input inV: "); 15870 appendVariableToMessage(message, args.inV); 15871 message.append("\n"); 15872 message.append("Expected output out: "); 15873 appendVariableToMessage(message, args.out); 15874 message.append("\n"); 15875 message.append("Actual output out: "); 15876 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15877 if (args.out != arrayOut[i * 4 + j]) { 15878 message.append(" FAIL"); 15879 } 15880 message.append("\n"); 15881 message.append("Errors at"); 15882 } 15883 message.append(" ["); 15884 message.append(Integer.toString(i)); 15885 message.append(", "); 15886 message.append(Integer.toString(j)); 15887 message.append("]"); 15888 } 15889 } 15890 } 15891 assertFalse("Incorrect output for checkConvertUlong3Int3" + 15892 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15893 } 15894 checkConvertUlong4Int4()15895 private void checkConvertUlong4Int4() { 15896 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x76a2feaal, false, 31); 15897 try { 15898 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 15899 script.forEach_testConvertInt4Ulong4Int4(inV, out); 15900 verifyResultsConvertUlong4Int4(inV, out, false); 15901 } catch (Exception e) { 15902 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString()); 15903 } 15904 try { 15905 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 15906 scriptRelaxed.forEach_testConvertInt4Ulong4Int4(inV, out); 15907 verifyResultsConvertUlong4Int4(inV, out, true); 15908 } catch (Exception e) { 15909 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString()); 15910 } 15911 } 15912 verifyResultsConvertUlong4Int4(Allocation inV, Allocation out, boolean relaxed)15913 private void verifyResultsConvertUlong4Int4(Allocation inV, Allocation out, boolean relaxed) { 15914 long[] arrayInV = new long[INPUTSIZE * 4]; 15915 Arrays.fill(arrayInV, (long) 42); 15916 inV.copyTo(arrayInV); 15917 int[] arrayOut = new int[INPUTSIZE * 4]; 15918 Arrays.fill(arrayOut, (int) 42); 15919 out.copyTo(arrayOut); 15920 StringBuilder message = new StringBuilder(); 15921 boolean errorFound = false; 15922 for (int i = 0; i < INPUTSIZE; i++) { 15923 for (int j = 0; j < 4 ; j++) { 15924 // Extract the inputs. 15925 ArgumentsUlongInt args = new ArgumentsUlongInt(); 15926 args.inV = arrayInV[i * 4 + j]; 15927 // Figure out what the outputs should have been. 15928 CoreMathVerifier.computeConvert(args); 15929 // Validate the outputs. 15930 boolean valid = true; 15931 if (args.out != arrayOut[i * 4 + j]) { 15932 valid = false; 15933 } 15934 if (!valid) { 15935 if (!errorFound) { 15936 errorFound = true; 15937 message.append("Input inV: "); 15938 appendVariableToMessage(message, args.inV); 15939 message.append("\n"); 15940 message.append("Expected output out: "); 15941 appendVariableToMessage(message, args.out); 15942 message.append("\n"); 15943 message.append("Actual output out: "); 15944 appendVariableToMessage(message, arrayOut[i * 4 + j]); 15945 if (args.out != arrayOut[i * 4 + j]) { 15946 message.append(" FAIL"); 15947 } 15948 message.append("\n"); 15949 message.append("Errors at"); 15950 } 15951 message.append(" ["); 15952 message.append(Integer.toString(i)); 15953 message.append(", "); 15954 message.append(Integer.toString(j)); 15955 message.append("]"); 15956 } 15957 } 15958 } 15959 assertFalse("Incorrect output for checkConvertUlong4Int4" + 15960 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 15961 } 15962 15963 public class ArgumentsDoubleUint { 15964 public double inV; 15965 public int out; 15966 } 15967 checkConvertDouble2Uint2()15968 private void checkConvertDouble2Uint2() { 15969 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7de7dd7l, 0.0000000000000000000e+00, 4.2949672950000000000e+09); 15970 try { 15971 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 15972 script.forEach_testConvertUint2Double2Uint2(inV, out); 15973 verifyResultsConvertDouble2Uint2(inV, out, false); 15974 } catch (Exception e) { 15975 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString()); 15976 } 15977 try { 15978 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 15979 scriptRelaxed.forEach_testConvertUint2Double2Uint2(inV, out); 15980 verifyResultsConvertDouble2Uint2(inV, out, true); 15981 } catch (Exception e) { 15982 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString()); 15983 } 15984 } 15985 verifyResultsConvertDouble2Uint2(Allocation inV, Allocation out, boolean relaxed)15986 private void verifyResultsConvertDouble2Uint2(Allocation inV, Allocation out, boolean relaxed) { 15987 double[] arrayInV = new double[INPUTSIZE * 2]; 15988 Arrays.fill(arrayInV, (double) 42); 15989 inV.copyTo(arrayInV); 15990 int[] arrayOut = new int[INPUTSIZE * 2]; 15991 Arrays.fill(arrayOut, (int) 42); 15992 out.copyTo(arrayOut); 15993 StringBuilder message = new StringBuilder(); 15994 boolean errorFound = false; 15995 for (int i = 0; i < INPUTSIZE; i++) { 15996 for (int j = 0; j < 2 ; j++) { 15997 // Extract the inputs. 15998 ArgumentsDoubleUint args = new ArgumentsDoubleUint(); 15999 args.inV = arrayInV[i * 2 + j]; 16000 // Figure out what the outputs should have been. 16001 CoreMathVerifier.computeConvert(args); 16002 // Validate the outputs. 16003 boolean valid = true; 16004 if (args.out != arrayOut[i * 2 + j]) { 16005 valid = false; 16006 } 16007 if (!valid) { 16008 if (!errorFound) { 16009 errorFound = true; 16010 message.append("Input inV: "); 16011 appendVariableToMessage(message, args.inV); 16012 message.append("\n"); 16013 message.append("Expected output out: "); 16014 appendVariableToMessage(message, args.out); 16015 message.append("\n"); 16016 message.append("Actual output out: "); 16017 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16018 if (args.out != arrayOut[i * 2 + j]) { 16019 message.append(" FAIL"); 16020 } 16021 message.append("\n"); 16022 message.append("Errors at"); 16023 } 16024 message.append(" ["); 16025 message.append(Integer.toString(i)); 16026 message.append(", "); 16027 message.append(Integer.toString(j)); 16028 message.append("]"); 16029 } 16030 } 16031 } 16032 assertFalse("Incorrect output for checkConvertDouble2Uint2" + 16033 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16034 } 16035 checkConvertDouble3Uint3()16036 private void checkConvertDouble3Uint3() { 16037 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x66e642cbl, 0.0000000000000000000e+00, 4.2949672950000000000e+09); 16038 try { 16039 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16040 script.forEach_testConvertUint3Double3Uint3(inV, out); 16041 verifyResultsConvertDouble3Uint3(inV, out, false); 16042 } catch (Exception e) { 16043 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString()); 16044 } 16045 try { 16046 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16047 scriptRelaxed.forEach_testConvertUint3Double3Uint3(inV, out); 16048 verifyResultsConvertDouble3Uint3(inV, out, true); 16049 } catch (Exception e) { 16050 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString()); 16051 } 16052 } 16053 verifyResultsConvertDouble3Uint3(Allocation inV, Allocation out, boolean relaxed)16054 private void verifyResultsConvertDouble3Uint3(Allocation inV, Allocation out, boolean relaxed) { 16055 double[] arrayInV = new double[INPUTSIZE * 4]; 16056 Arrays.fill(arrayInV, (double) 42); 16057 inV.copyTo(arrayInV); 16058 int[] arrayOut = new int[INPUTSIZE * 4]; 16059 Arrays.fill(arrayOut, (int) 42); 16060 out.copyTo(arrayOut); 16061 StringBuilder message = new StringBuilder(); 16062 boolean errorFound = false; 16063 for (int i = 0; i < INPUTSIZE; i++) { 16064 for (int j = 0; j < 3 ; j++) { 16065 // Extract the inputs. 16066 ArgumentsDoubleUint args = new ArgumentsDoubleUint(); 16067 args.inV = arrayInV[i * 4 + j]; 16068 // Figure out what the outputs should have been. 16069 CoreMathVerifier.computeConvert(args); 16070 // Validate the outputs. 16071 boolean valid = true; 16072 if (args.out != arrayOut[i * 4 + j]) { 16073 valid = false; 16074 } 16075 if (!valid) { 16076 if (!errorFound) { 16077 errorFound = true; 16078 message.append("Input inV: "); 16079 appendVariableToMessage(message, args.inV); 16080 message.append("\n"); 16081 message.append("Expected output out: "); 16082 appendVariableToMessage(message, args.out); 16083 message.append("\n"); 16084 message.append("Actual output out: "); 16085 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16086 if (args.out != arrayOut[i * 4 + j]) { 16087 message.append(" FAIL"); 16088 } 16089 message.append("\n"); 16090 message.append("Errors at"); 16091 } 16092 message.append(" ["); 16093 message.append(Integer.toString(i)); 16094 message.append(", "); 16095 message.append(Integer.toString(j)); 16096 message.append("]"); 16097 } 16098 } 16099 } 16100 assertFalse("Incorrect output for checkConvertDouble3Uint3" + 16101 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16102 } 16103 checkConvertDouble4Uint4()16104 private void checkConvertDouble4Uint4() { 16105 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xc5ee07bfl, 0.0000000000000000000e+00, 4.2949672950000000000e+09); 16106 try { 16107 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16108 script.forEach_testConvertUint4Double4Uint4(inV, out); 16109 verifyResultsConvertDouble4Uint4(inV, out, false); 16110 } catch (Exception e) { 16111 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString()); 16112 } 16113 try { 16114 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16115 scriptRelaxed.forEach_testConvertUint4Double4Uint4(inV, out); 16116 verifyResultsConvertDouble4Uint4(inV, out, true); 16117 } catch (Exception e) { 16118 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString()); 16119 } 16120 } 16121 verifyResultsConvertDouble4Uint4(Allocation inV, Allocation out, boolean relaxed)16122 private void verifyResultsConvertDouble4Uint4(Allocation inV, Allocation out, boolean relaxed) { 16123 double[] arrayInV = new double[INPUTSIZE * 4]; 16124 Arrays.fill(arrayInV, (double) 42); 16125 inV.copyTo(arrayInV); 16126 int[] arrayOut = new int[INPUTSIZE * 4]; 16127 Arrays.fill(arrayOut, (int) 42); 16128 out.copyTo(arrayOut); 16129 StringBuilder message = new StringBuilder(); 16130 boolean errorFound = false; 16131 for (int i = 0; i < INPUTSIZE; i++) { 16132 for (int j = 0; j < 4 ; j++) { 16133 // Extract the inputs. 16134 ArgumentsDoubleUint args = new ArgumentsDoubleUint(); 16135 args.inV = arrayInV[i * 4 + j]; 16136 // Figure out what the outputs should have been. 16137 CoreMathVerifier.computeConvert(args); 16138 // Validate the outputs. 16139 boolean valid = true; 16140 if (args.out != arrayOut[i * 4 + j]) { 16141 valid = false; 16142 } 16143 if (!valid) { 16144 if (!errorFound) { 16145 errorFound = true; 16146 message.append("Input inV: "); 16147 appendVariableToMessage(message, args.inV); 16148 message.append("\n"); 16149 message.append("Expected output out: "); 16150 appendVariableToMessage(message, args.out); 16151 message.append("\n"); 16152 message.append("Actual output out: "); 16153 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16154 if (args.out != arrayOut[i * 4 + j]) { 16155 message.append(" FAIL"); 16156 } 16157 message.append("\n"); 16158 message.append("Errors at"); 16159 } 16160 message.append(" ["); 16161 message.append(Integer.toString(i)); 16162 message.append(", "); 16163 message.append(Integer.toString(j)); 16164 message.append("]"); 16165 } 16166 } 16167 } 16168 assertFalse("Incorrect output for checkConvertDouble4Uint4" + 16169 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16170 } 16171 16172 public class ArgumentsLongUint { 16173 public long inV; 16174 public int out; 16175 } 16176 checkConvertLong2Uint2()16177 private void checkConvertLong2Uint2() { 16178 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x8ceee36cl, false, 32); 16179 try { 16180 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16181 script.forEach_testConvertUint2Long2Uint2(inV, out); 16182 verifyResultsConvertLong2Uint2(inV, out, false); 16183 } catch (Exception e) { 16184 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString()); 16185 } 16186 try { 16187 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16188 scriptRelaxed.forEach_testConvertUint2Long2Uint2(inV, out); 16189 verifyResultsConvertLong2Uint2(inV, out, true); 16190 } catch (Exception e) { 16191 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString()); 16192 } 16193 } 16194 verifyResultsConvertLong2Uint2(Allocation inV, Allocation out, boolean relaxed)16195 private void verifyResultsConvertLong2Uint2(Allocation inV, Allocation out, boolean relaxed) { 16196 long[] arrayInV = new long[INPUTSIZE * 2]; 16197 Arrays.fill(arrayInV, (long) 42); 16198 inV.copyTo(arrayInV); 16199 int[] arrayOut = new int[INPUTSIZE * 2]; 16200 Arrays.fill(arrayOut, (int) 42); 16201 out.copyTo(arrayOut); 16202 StringBuilder message = new StringBuilder(); 16203 boolean errorFound = false; 16204 for (int i = 0; i < INPUTSIZE; i++) { 16205 for (int j = 0; j < 2 ; j++) { 16206 // Extract the inputs. 16207 ArgumentsLongUint args = new ArgumentsLongUint(); 16208 args.inV = arrayInV[i * 2 + j]; 16209 // Figure out what the outputs should have been. 16210 CoreMathVerifier.computeConvert(args); 16211 // Validate the outputs. 16212 boolean valid = true; 16213 if (args.out != arrayOut[i * 2 + j]) { 16214 valid = false; 16215 } 16216 if (!valid) { 16217 if (!errorFound) { 16218 errorFound = true; 16219 message.append("Input inV: "); 16220 appendVariableToMessage(message, args.inV); 16221 message.append("\n"); 16222 message.append("Expected output out: "); 16223 appendVariableToMessage(message, args.out); 16224 message.append("\n"); 16225 message.append("Actual output out: "); 16226 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16227 if (args.out != arrayOut[i * 2 + j]) { 16228 message.append(" FAIL"); 16229 } 16230 message.append("\n"); 16231 message.append("Errors at"); 16232 } 16233 message.append(" ["); 16234 message.append(Integer.toString(i)); 16235 message.append(", "); 16236 message.append(Integer.toString(j)); 16237 message.append("]"); 16238 } 16239 } 16240 } 16241 assertFalse("Incorrect output for checkConvertLong2Uint2" + 16242 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16243 } 16244 checkConvertLong3Uint3()16245 private void checkConvertLong3Uint3() { 16246 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xebf6a860l, false, 32); 16247 try { 16248 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16249 script.forEach_testConvertUint3Long3Uint3(inV, out); 16250 verifyResultsConvertLong3Uint3(inV, out, false); 16251 } catch (Exception e) { 16252 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString()); 16253 } 16254 try { 16255 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16256 scriptRelaxed.forEach_testConvertUint3Long3Uint3(inV, out); 16257 verifyResultsConvertLong3Uint3(inV, out, true); 16258 } catch (Exception e) { 16259 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString()); 16260 } 16261 } 16262 verifyResultsConvertLong3Uint3(Allocation inV, Allocation out, boolean relaxed)16263 private void verifyResultsConvertLong3Uint3(Allocation inV, Allocation out, boolean relaxed) { 16264 long[] arrayInV = new long[INPUTSIZE * 4]; 16265 Arrays.fill(arrayInV, (long) 42); 16266 inV.copyTo(arrayInV); 16267 int[] arrayOut = new int[INPUTSIZE * 4]; 16268 Arrays.fill(arrayOut, (int) 42); 16269 out.copyTo(arrayOut); 16270 StringBuilder message = new StringBuilder(); 16271 boolean errorFound = false; 16272 for (int i = 0; i < INPUTSIZE; i++) { 16273 for (int j = 0; j < 3 ; j++) { 16274 // Extract the inputs. 16275 ArgumentsLongUint args = new ArgumentsLongUint(); 16276 args.inV = arrayInV[i * 4 + j]; 16277 // Figure out what the outputs should have been. 16278 CoreMathVerifier.computeConvert(args); 16279 // Validate the outputs. 16280 boolean valid = true; 16281 if (args.out != arrayOut[i * 4 + j]) { 16282 valid = false; 16283 } 16284 if (!valid) { 16285 if (!errorFound) { 16286 errorFound = true; 16287 message.append("Input inV: "); 16288 appendVariableToMessage(message, args.inV); 16289 message.append("\n"); 16290 message.append("Expected output out: "); 16291 appendVariableToMessage(message, args.out); 16292 message.append("\n"); 16293 message.append("Actual output out: "); 16294 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16295 if (args.out != arrayOut[i * 4 + j]) { 16296 message.append(" FAIL"); 16297 } 16298 message.append("\n"); 16299 message.append("Errors at"); 16300 } 16301 message.append(" ["); 16302 message.append(Integer.toString(i)); 16303 message.append(", "); 16304 message.append(Integer.toString(j)); 16305 message.append("]"); 16306 } 16307 } 16308 } 16309 assertFalse("Incorrect output for checkConvertLong3Uint3" + 16310 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16311 } 16312 checkConvertLong4Uint4()16313 private void checkConvertLong4Uint4() { 16314 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x4afe6d54l, false, 32); 16315 try { 16316 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16317 script.forEach_testConvertUint4Long4Uint4(inV, out); 16318 verifyResultsConvertLong4Uint4(inV, out, false); 16319 } catch (Exception e) { 16320 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString()); 16321 } 16322 try { 16323 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16324 scriptRelaxed.forEach_testConvertUint4Long4Uint4(inV, out); 16325 verifyResultsConvertLong4Uint4(inV, out, true); 16326 } catch (Exception e) { 16327 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString()); 16328 } 16329 } 16330 verifyResultsConvertLong4Uint4(Allocation inV, Allocation out, boolean relaxed)16331 private void verifyResultsConvertLong4Uint4(Allocation inV, Allocation out, boolean relaxed) { 16332 long[] arrayInV = new long[INPUTSIZE * 4]; 16333 Arrays.fill(arrayInV, (long) 42); 16334 inV.copyTo(arrayInV); 16335 int[] arrayOut = new int[INPUTSIZE * 4]; 16336 Arrays.fill(arrayOut, (int) 42); 16337 out.copyTo(arrayOut); 16338 StringBuilder message = new StringBuilder(); 16339 boolean errorFound = false; 16340 for (int i = 0; i < INPUTSIZE; i++) { 16341 for (int j = 0; j < 4 ; j++) { 16342 // Extract the inputs. 16343 ArgumentsLongUint args = new ArgumentsLongUint(); 16344 args.inV = arrayInV[i * 4 + j]; 16345 // Figure out what the outputs should have been. 16346 CoreMathVerifier.computeConvert(args); 16347 // Validate the outputs. 16348 boolean valid = true; 16349 if (args.out != arrayOut[i * 4 + j]) { 16350 valid = false; 16351 } 16352 if (!valid) { 16353 if (!errorFound) { 16354 errorFound = true; 16355 message.append("Input inV: "); 16356 appendVariableToMessage(message, args.inV); 16357 message.append("\n"); 16358 message.append("Expected output out: "); 16359 appendVariableToMessage(message, args.out); 16360 message.append("\n"); 16361 message.append("Actual output out: "); 16362 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16363 if (args.out != arrayOut[i * 4 + j]) { 16364 message.append(" FAIL"); 16365 } 16366 message.append("\n"); 16367 message.append("Errors at"); 16368 } 16369 message.append(" ["); 16370 message.append(Integer.toString(i)); 16371 message.append(", "); 16372 message.append(Integer.toString(j)); 16373 message.append("]"); 16374 } 16375 } 16376 } 16377 assertFalse("Incorrect output for checkConvertLong4Uint4" + 16378 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16379 } 16380 16381 public class ArgumentsUlongUint { 16382 public long inV; 16383 public int out; 16384 } 16385 checkConvertUlong2Uint2()16386 private void checkConvertUlong2Uint2() { 16387 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x1f70efedl, false, 32); 16388 try { 16389 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16390 script.forEach_testConvertUint2Ulong2Uint2(inV, out); 16391 verifyResultsConvertUlong2Uint2(inV, out, false); 16392 } catch (Exception e) { 16393 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString()); 16394 } 16395 try { 16396 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 16397 scriptRelaxed.forEach_testConvertUint2Ulong2Uint2(inV, out); 16398 verifyResultsConvertUlong2Uint2(inV, out, true); 16399 } catch (Exception e) { 16400 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString()); 16401 } 16402 } 16403 verifyResultsConvertUlong2Uint2(Allocation inV, Allocation out, boolean relaxed)16404 private void verifyResultsConvertUlong2Uint2(Allocation inV, Allocation out, boolean relaxed) { 16405 long[] arrayInV = new long[INPUTSIZE * 2]; 16406 Arrays.fill(arrayInV, (long) 42); 16407 inV.copyTo(arrayInV); 16408 int[] arrayOut = new int[INPUTSIZE * 2]; 16409 Arrays.fill(arrayOut, (int) 42); 16410 out.copyTo(arrayOut); 16411 StringBuilder message = new StringBuilder(); 16412 boolean errorFound = false; 16413 for (int i = 0; i < INPUTSIZE; i++) { 16414 for (int j = 0; j < 2 ; j++) { 16415 // Extract the inputs. 16416 ArgumentsUlongUint args = new ArgumentsUlongUint(); 16417 args.inV = arrayInV[i * 2 + j]; 16418 // Figure out what the outputs should have been. 16419 CoreMathVerifier.computeConvert(args); 16420 // Validate the outputs. 16421 boolean valid = true; 16422 if (args.out != arrayOut[i * 2 + j]) { 16423 valid = false; 16424 } 16425 if (!valid) { 16426 if (!errorFound) { 16427 errorFound = true; 16428 message.append("Input inV: "); 16429 appendVariableToMessage(message, args.inV); 16430 message.append("\n"); 16431 message.append("Expected output out: "); 16432 appendVariableToMessage(message, args.out); 16433 message.append("\n"); 16434 message.append("Actual output out: "); 16435 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16436 if (args.out != arrayOut[i * 2 + j]) { 16437 message.append(" FAIL"); 16438 } 16439 message.append("\n"); 16440 message.append("Errors at"); 16441 } 16442 message.append(" ["); 16443 message.append(Integer.toString(i)); 16444 message.append(", "); 16445 message.append(Integer.toString(j)); 16446 message.append("]"); 16447 } 16448 } 16449 } 16450 assertFalse("Incorrect output for checkConvertUlong2Uint2" + 16451 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16452 } 16453 checkConvertUlong3Uint3()16454 private void checkConvertUlong3Uint3() { 16455 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x7e78b4e1l, false, 32); 16456 try { 16457 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16458 script.forEach_testConvertUint3Ulong3Uint3(inV, out); 16459 verifyResultsConvertUlong3Uint3(inV, out, false); 16460 } catch (Exception e) { 16461 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString()); 16462 } 16463 try { 16464 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 16465 scriptRelaxed.forEach_testConvertUint3Ulong3Uint3(inV, out); 16466 verifyResultsConvertUlong3Uint3(inV, out, true); 16467 } catch (Exception e) { 16468 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString()); 16469 } 16470 } 16471 verifyResultsConvertUlong3Uint3(Allocation inV, Allocation out, boolean relaxed)16472 private void verifyResultsConvertUlong3Uint3(Allocation inV, Allocation out, boolean relaxed) { 16473 long[] arrayInV = new long[INPUTSIZE * 4]; 16474 Arrays.fill(arrayInV, (long) 42); 16475 inV.copyTo(arrayInV); 16476 int[] arrayOut = new int[INPUTSIZE * 4]; 16477 Arrays.fill(arrayOut, (int) 42); 16478 out.copyTo(arrayOut); 16479 StringBuilder message = new StringBuilder(); 16480 boolean errorFound = false; 16481 for (int i = 0; i < INPUTSIZE; i++) { 16482 for (int j = 0; j < 3 ; j++) { 16483 // Extract the inputs. 16484 ArgumentsUlongUint args = new ArgumentsUlongUint(); 16485 args.inV = arrayInV[i * 4 + j]; 16486 // Figure out what the outputs should have been. 16487 CoreMathVerifier.computeConvert(args); 16488 // Validate the outputs. 16489 boolean valid = true; 16490 if (args.out != arrayOut[i * 4 + j]) { 16491 valid = false; 16492 } 16493 if (!valid) { 16494 if (!errorFound) { 16495 errorFound = true; 16496 message.append("Input inV: "); 16497 appendVariableToMessage(message, args.inV); 16498 message.append("\n"); 16499 message.append("Expected output out: "); 16500 appendVariableToMessage(message, args.out); 16501 message.append("\n"); 16502 message.append("Actual output out: "); 16503 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16504 if (args.out != arrayOut[i * 4 + j]) { 16505 message.append(" FAIL"); 16506 } 16507 message.append("\n"); 16508 message.append("Errors at"); 16509 } 16510 message.append(" ["); 16511 message.append(Integer.toString(i)); 16512 message.append(", "); 16513 message.append(Integer.toString(j)); 16514 message.append("]"); 16515 } 16516 } 16517 } 16518 assertFalse("Incorrect output for checkConvertUlong3Uint3" + 16519 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16520 } 16521 checkConvertUlong4Uint4()16522 private void checkConvertUlong4Uint4() { 16523 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xdd8079d5l, false, 32); 16524 try { 16525 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16526 script.forEach_testConvertUint4Ulong4Uint4(inV, out); 16527 verifyResultsConvertUlong4Uint4(inV, out, false); 16528 } catch (Exception e) { 16529 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString()); 16530 } 16531 try { 16532 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 16533 scriptRelaxed.forEach_testConvertUint4Ulong4Uint4(inV, out); 16534 verifyResultsConvertUlong4Uint4(inV, out, true); 16535 } catch (Exception e) { 16536 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString()); 16537 } 16538 } 16539 verifyResultsConvertUlong4Uint4(Allocation inV, Allocation out, boolean relaxed)16540 private void verifyResultsConvertUlong4Uint4(Allocation inV, Allocation out, boolean relaxed) { 16541 long[] arrayInV = new long[INPUTSIZE * 4]; 16542 Arrays.fill(arrayInV, (long) 42); 16543 inV.copyTo(arrayInV); 16544 int[] arrayOut = new int[INPUTSIZE * 4]; 16545 Arrays.fill(arrayOut, (int) 42); 16546 out.copyTo(arrayOut); 16547 StringBuilder message = new StringBuilder(); 16548 boolean errorFound = false; 16549 for (int i = 0; i < INPUTSIZE; i++) { 16550 for (int j = 0; j < 4 ; j++) { 16551 // Extract the inputs. 16552 ArgumentsUlongUint args = new ArgumentsUlongUint(); 16553 args.inV = arrayInV[i * 4 + j]; 16554 // Figure out what the outputs should have been. 16555 CoreMathVerifier.computeConvert(args); 16556 // Validate the outputs. 16557 boolean valid = true; 16558 if (args.out != arrayOut[i * 4 + j]) { 16559 valid = false; 16560 } 16561 if (!valid) { 16562 if (!errorFound) { 16563 errorFound = true; 16564 message.append("Input inV: "); 16565 appendVariableToMessage(message, args.inV); 16566 message.append("\n"); 16567 message.append("Expected output out: "); 16568 appendVariableToMessage(message, args.out); 16569 message.append("\n"); 16570 message.append("Actual output out: "); 16571 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16572 if (args.out != arrayOut[i * 4 + j]) { 16573 message.append(" FAIL"); 16574 } 16575 message.append("\n"); 16576 message.append("Errors at"); 16577 } 16578 message.append(" ["); 16579 message.append(Integer.toString(i)); 16580 message.append(", "); 16581 message.append(Integer.toString(j)); 16582 message.append("]"); 16583 } 16584 } 16585 } 16586 assertFalse("Incorrect output for checkConvertUlong4Uint4" + 16587 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16588 } 16589 16590 public class ArgumentsFloatDouble { 16591 public float inV; 16592 public Target.Floaty out; 16593 } 16594 checkConvertFloat2Double2()16595 private void checkConvertFloat2Double2() { 16596 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x46e08221l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 16597 try { 16598 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 16599 script.forEach_testConvertDouble2Float2Double2(inV, out); 16600 verifyResultsConvertFloat2Double2(inV, out, false); 16601 } catch (Exception e) { 16602 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString()); 16603 } 16604 try { 16605 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 16606 scriptRelaxed.forEach_testConvertDouble2Float2Double2(inV, out); 16607 verifyResultsConvertFloat2Double2(inV, out, true); 16608 } catch (Exception e) { 16609 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString()); 16610 } 16611 } 16612 verifyResultsConvertFloat2Double2(Allocation inV, Allocation out, boolean relaxed)16613 private void verifyResultsConvertFloat2Double2(Allocation inV, Allocation out, boolean relaxed) { 16614 float[] arrayInV = new float[INPUTSIZE * 2]; 16615 Arrays.fill(arrayInV, (float) 42); 16616 inV.copyTo(arrayInV); 16617 double[] arrayOut = new double[INPUTSIZE * 2]; 16618 Arrays.fill(arrayOut, (double) 42); 16619 out.copyTo(arrayOut); 16620 StringBuilder message = new StringBuilder(); 16621 boolean errorFound = false; 16622 for (int i = 0; i < INPUTSIZE; i++) { 16623 for (int j = 0; j < 2 ; j++) { 16624 // Extract the inputs. 16625 ArgumentsFloatDouble args = new ArgumentsFloatDouble(); 16626 args.inV = arrayInV[i * 2 + j]; 16627 // Figure out what the outputs should have been. 16628 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 16629 CoreMathVerifier.computeConvert(args, target); 16630 // Validate the outputs. 16631 boolean valid = true; 16632 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 16633 valid = false; 16634 } 16635 if (!valid) { 16636 if (!errorFound) { 16637 errorFound = true; 16638 message.append("Input inV: "); 16639 appendVariableToMessage(message, args.inV); 16640 message.append("\n"); 16641 message.append("Expected output out: "); 16642 appendVariableToMessage(message, args.out); 16643 message.append("\n"); 16644 message.append("Actual output out: "); 16645 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16646 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 16647 message.append(" FAIL"); 16648 } 16649 message.append("\n"); 16650 message.append("Errors at"); 16651 } 16652 message.append(" ["); 16653 message.append(Integer.toString(i)); 16654 message.append(", "); 16655 message.append(Integer.toString(j)); 16656 message.append("]"); 16657 } 16658 } 16659 } 16660 assertFalse("Incorrect output for checkConvertFloat2Double2" + 16661 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16662 } 16663 checkConvertFloat3Double3()16664 private void checkConvertFloat3Double3() { 16665 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9d3c134dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 16666 try { 16667 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 16668 script.forEach_testConvertDouble3Float3Double3(inV, out); 16669 verifyResultsConvertFloat3Double3(inV, out, false); 16670 } catch (Exception e) { 16671 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString()); 16672 } 16673 try { 16674 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 16675 scriptRelaxed.forEach_testConvertDouble3Float3Double3(inV, out); 16676 verifyResultsConvertFloat3Double3(inV, out, true); 16677 } catch (Exception e) { 16678 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString()); 16679 } 16680 } 16681 verifyResultsConvertFloat3Double3(Allocation inV, Allocation out, boolean relaxed)16682 private void verifyResultsConvertFloat3Double3(Allocation inV, Allocation out, boolean relaxed) { 16683 float[] arrayInV = new float[INPUTSIZE * 4]; 16684 Arrays.fill(arrayInV, (float) 42); 16685 inV.copyTo(arrayInV); 16686 double[] arrayOut = new double[INPUTSIZE * 4]; 16687 Arrays.fill(arrayOut, (double) 42); 16688 out.copyTo(arrayOut); 16689 StringBuilder message = new StringBuilder(); 16690 boolean errorFound = false; 16691 for (int i = 0; i < INPUTSIZE; i++) { 16692 for (int j = 0; j < 3 ; j++) { 16693 // Extract the inputs. 16694 ArgumentsFloatDouble args = new ArgumentsFloatDouble(); 16695 args.inV = arrayInV[i * 4 + j]; 16696 // Figure out what the outputs should have been. 16697 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 16698 CoreMathVerifier.computeConvert(args, target); 16699 // Validate the outputs. 16700 boolean valid = true; 16701 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16702 valid = false; 16703 } 16704 if (!valid) { 16705 if (!errorFound) { 16706 errorFound = true; 16707 message.append("Input inV: "); 16708 appendVariableToMessage(message, args.inV); 16709 message.append("\n"); 16710 message.append("Expected output out: "); 16711 appendVariableToMessage(message, args.out); 16712 message.append("\n"); 16713 message.append("Actual output out: "); 16714 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16715 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16716 message.append(" FAIL"); 16717 } 16718 message.append("\n"); 16719 message.append("Errors at"); 16720 } 16721 message.append(" ["); 16722 message.append(Integer.toString(i)); 16723 message.append(", "); 16724 message.append(Integer.toString(j)); 16725 message.append("]"); 16726 } 16727 } 16728 } 16729 assertFalse("Incorrect output for checkConvertFloat3Double3" + 16730 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16731 } 16732 checkConvertFloat4Double4()16733 private void checkConvertFloat4Double4() { 16734 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf397a479l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); 16735 try { 16736 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 16737 script.forEach_testConvertDouble4Float4Double4(inV, out); 16738 verifyResultsConvertFloat4Double4(inV, out, false); 16739 } catch (Exception e) { 16740 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString()); 16741 } 16742 try { 16743 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 16744 scriptRelaxed.forEach_testConvertDouble4Float4Double4(inV, out); 16745 verifyResultsConvertFloat4Double4(inV, out, true); 16746 } catch (Exception e) { 16747 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString()); 16748 } 16749 } 16750 verifyResultsConvertFloat4Double4(Allocation inV, Allocation out, boolean relaxed)16751 private void verifyResultsConvertFloat4Double4(Allocation inV, Allocation out, boolean relaxed) { 16752 float[] arrayInV = new float[INPUTSIZE * 4]; 16753 Arrays.fill(arrayInV, (float) 42); 16754 inV.copyTo(arrayInV); 16755 double[] arrayOut = new double[INPUTSIZE * 4]; 16756 Arrays.fill(arrayOut, (double) 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 < 4 ; j++) { 16762 // Extract the inputs. 16763 ArgumentsFloatDouble args = new ArgumentsFloatDouble(); 16764 args.inV = arrayInV[i * 4 + j]; 16765 // Figure out what the outputs should have been. 16766 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 16767 CoreMathVerifier.computeConvert(args, target); 16768 // Validate the outputs. 16769 boolean valid = true; 16770 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16771 valid = false; 16772 } 16773 if (!valid) { 16774 if (!errorFound) { 16775 errorFound = true; 16776 message.append("Input inV: "); 16777 appendVariableToMessage(message, args.inV); 16778 message.append("\n"); 16779 message.append("Expected output out: "); 16780 appendVariableToMessage(message, args.out); 16781 message.append("\n"); 16782 message.append("Actual output out: "); 16783 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16784 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16785 message.append(" FAIL"); 16786 } 16787 message.append("\n"); 16788 message.append("Errors at"); 16789 } 16790 message.append(" ["); 16791 message.append(Integer.toString(i)); 16792 message.append(", "); 16793 message.append(Integer.toString(j)); 16794 message.append("]"); 16795 } 16796 } 16797 } 16798 assertFalse("Incorrect output for checkConvertFloat4Double4" + 16799 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16800 } 16801 16802 public class ArgumentsCharDouble { 16803 public byte inV; 16804 public Target.Floaty out; 16805 } 16806 checkConvertChar2Double2()16807 private void checkConvertChar2Double2() { 16808 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x68ca2f61l, true, 7); 16809 try { 16810 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 16811 script.forEach_testConvertDouble2Char2Double2(inV, out); 16812 verifyResultsConvertChar2Double2(inV, out, false); 16813 } catch (Exception e) { 16814 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString()); 16815 } 16816 try { 16817 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 16818 scriptRelaxed.forEach_testConvertDouble2Char2Double2(inV, out); 16819 verifyResultsConvertChar2Double2(inV, out, true); 16820 } catch (Exception e) { 16821 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString()); 16822 } 16823 } 16824 verifyResultsConvertChar2Double2(Allocation inV, Allocation out, boolean relaxed)16825 private void verifyResultsConvertChar2Double2(Allocation inV, Allocation out, boolean relaxed) { 16826 byte[] arrayInV = new byte[INPUTSIZE * 2]; 16827 Arrays.fill(arrayInV, (byte) 42); 16828 inV.copyTo(arrayInV); 16829 double[] arrayOut = new double[INPUTSIZE * 2]; 16830 Arrays.fill(arrayOut, (double) 42); 16831 out.copyTo(arrayOut); 16832 StringBuilder message = new StringBuilder(); 16833 boolean errorFound = false; 16834 for (int i = 0; i < INPUTSIZE; i++) { 16835 for (int j = 0; j < 2 ; j++) { 16836 // Extract the inputs. 16837 ArgumentsCharDouble args = new ArgumentsCharDouble(); 16838 args.inV = arrayInV[i * 2 + j]; 16839 // Figure out what the outputs should have been. 16840 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 16841 CoreMathVerifier.computeConvert(args, target); 16842 // Validate the outputs. 16843 boolean valid = true; 16844 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 16845 valid = false; 16846 } 16847 if (!valid) { 16848 if (!errorFound) { 16849 errorFound = true; 16850 message.append("Input inV: "); 16851 appendVariableToMessage(message, args.inV); 16852 message.append("\n"); 16853 message.append("Expected output out: "); 16854 appendVariableToMessage(message, args.out); 16855 message.append("\n"); 16856 message.append("Actual output out: "); 16857 appendVariableToMessage(message, arrayOut[i * 2 + j]); 16858 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 16859 message.append(" FAIL"); 16860 } 16861 message.append("\n"); 16862 message.append("Errors at"); 16863 } 16864 message.append(" ["); 16865 message.append(Integer.toString(i)); 16866 message.append(", "); 16867 message.append(Integer.toString(j)); 16868 message.append("]"); 16869 } 16870 } 16871 } 16872 assertFalse("Incorrect output for checkConvertChar2Double2" + 16873 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16874 } 16875 checkConvertChar3Double3()16876 private void checkConvertChar3Double3() { 16877 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xbf25c08dl, true, 7); 16878 try { 16879 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 16880 script.forEach_testConvertDouble3Char3Double3(inV, out); 16881 verifyResultsConvertChar3Double3(inV, out, false); 16882 } catch (Exception e) { 16883 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString()); 16884 } 16885 try { 16886 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 16887 scriptRelaxed.forEach_testConvertDouble3Char3Double3(inV, out); 16888 verifyResultsConvertChar3Double3(inV, out, true); 16889 } catch (Exception e) { 16890 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString()); 16891 } 16892 } 16893 verifyResultsConvertChar3Double3(Allocation inV, Allocation out, boolean relaxed)16894 private void verifyResultsConvertChar3Double3(Allocation inV, Allocation out, boolean relaxed) { 16895 byte[] arrayInV = new byte[INPUTSIZE * 4]; 16896 Arrays.fill(arrayInV, (byte) 42); 16897 inV.copyTo(arrayInV); 16898 double[] arrayOut = new double[INPUTSIZE * 4]; 16899 Arrays.fill(arrayOut, (double) 42); 16900 out.copyTo(arrayOut); 16901 StringBuilder message = new StringBuilder(); 16902 boolean errorFound = false; 16903 for (int i = 0; i < INPUTSIZE; i++) { 16904 for (int j = 0; j < 3 ; j++) { 16905 // Extract the inputs. 16906 ArgumentsCharDouble args = new ArgumentsCharDouble(); 16907 args.inV = arrayInV[i * 4 + j]; 16908 // Figure out what the outputs should have been. 16909 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 16910 CoreMathVerifier.computeConvert(args, target); 16911 // Validate the outputs. 16912 boolean valid = true; 16913 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16914 valid = false; 16915 } 16916 if (!valid) { 16917 if (!errorFound) { 16918 errorFound = true; 16919 message.append("Input inV: "); 16920 appendVariableToMessage(message, args.inV); 16921 message.append("\n"); 16922 message.append("Expected output out: "); 16923 appendVariableToMessage(message, args.out); 16924 message.append("\n"); 16925 message.append("Actual output out: "); 16926 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16927 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16928 message.append(" FAIL"); 16929 } 16930 message.append("\n"); 16931 message.append("Errors at"); 16932 } 16933 message.append(" ["); 16934 message.append(Integer.toString(i)); 16935 message.append(", "); 16936 message.append(Integer.toString(j)); 16937 message.append("]"); 16938 } 16939 } 16940 } 16941 assertFalse("Incorrect output for checkConvertChar3Double3" + 16942 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 16943 } 16944 checkConvertChar4Double4()16945 private void checkConvertChar4Double4() { 16946 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x158151b9l, true, 7); 16947 try { 16948 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 16949 script.forEach_testConvertDouble4Char4Double4(inV, out); 16950 verifyResultsConvertChar4Double4(inV, out, false); 16951 } catch (Exception e) { 16952 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString()); 16953 } 16954 try { 16955 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 16956 scriptRelaxed.forEach_testConvertDouble4Char4Double4(inV, out); 16957 verifyResultsConvertChar4Double4(inV, out, true); 16958 } catch (Exception e) { 16959 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString()); 16960 } 16961 } 16962 verifyResultsConvertChar4Double4(Allocation inV, Allocation out, boolean relaxed)16963 private void verifyResultsConvertChar4Double4(Allocation inV, Allocation out, boolean relaxed) { 16964 byte[] arrayInV = new byte[INPUTSIZE * 4]; 16965 Arrays.fill(arrayInV, (byte) 42); 16966 inV.copyTo(arrayInV); 16967 double[] arrayOut = new double[INPUTSIZE * 4]; 16968 Arrays.fill(arrayOut, (double) 42); 16969 out.copyTo(arrayOut); 16970 StringBuilder message = new StringBuilder(); 16971 boolean errorFound = false; 16972 for (int i = 0; i < INPUTSIZE; i++) { 16973 for (int j = 0; j < 4 ; j++) { 16974 // Extract the inputs. 16975 ArgumentsCharDouble args = new ArgumentsCharDouble(); 16976 args.inV = arrayInV[i * 4 + j]; 16977 // Figure out what the outputs should have been. 16978 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 16979 CoreMathVerifier.computeConvert(args, target); 16980 // Validate the outputs. 16981 boolean valid = true; 16982 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16983 valid = false; 16984 } 16985 if (!valid) { 16986 if (!errorFound) { 16987 errorFound = true; 16988 message.append("Input inV: "); 16989 appendVariableToMessage(message, args.inV); 16990 message.append("\n"); 16991 message.append("Expected output out: "); 16992 appendVariableToMessage(message, args.out); 16993 message.append("\n"); 16994 message.append("Actual output out: "); 16995 appendVariableToMessage(message, arrayOut[i * 4 + j]); 16996 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 16997 message.append(" FAIL"); 16998 } 16999 message.append("\n"); 17000 message.append("Errors at"); 17001 } 17002 message.append(" ["); 17003 message.append(Integer.toString(i)); 17004 message.append(", "); 17005 message.append(Integer.toString(j)); 17006 message.append("]"); 17007 } 17008 } 17009 } 17010 assertFalse("Incorrect output for checkConvertChar4Double4" + 17011 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17012 } 17013 17014 public class ArgumentsUcharDouble { 17015 public byte inV; 17016 public Target.Floaty out; 17017 } 17018 checkConvertUchar2Double2()17019 private void checkConvertUchar2Double2() { 17020 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x96167f1al, false, 8); 17021 try { 17022 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17023 script.forEach_testConvertDouble2Uchar2Double2(inV, out); 17024 verifyResultsConvertUchar2Double2(inV, out, false); 17025 } catch (Exception e) { 17026 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString()); 17027 } 17028 try { 17029 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17030 scriptRelaxed.forEach_testConvertDouble2Uchar2Double2(inV, out); 17031 verifyResultsConvertUchar2Double2(inV, out, true); 17032 } catch (Exception e) { 17033 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString()); 17034 } 17035 } 17036 verifyResultsConvertUchar2Double2(Allocation inV, Allocation out, boolean relaxed)17037 private void verifyResultsConvertUchar2Double2(Allocation inV, Allocation out, boolean relaxed) { 17038 byte[] arrayInV = new byte[INPUTSIZE * 2]; 17039 Arrays.fill(arrayInV, (byte) 42); 17040 inV.copyTo(arrayInV); 17041 double[] arrayOut = new double[INPUTSIZE * 2]; 17042 Arrays.fill(arrayOut, (double) 42); 17043 out.copyTo(arrayOut); 17044 StringBuilder message = new StringBuilder(); 17045 boolean errorFound = false; 17046 for (int i = 0; i < INPUTSIZE; i++) { 17047 for (int j = 0; j < 2 ; j++) { 17048 // Extract the inputs. 17049 ArgumentsUcharDouble args = new ArgumentsUcharDouble(); 17050 args.inV = arrayInV[i * 2 + j]; 17051 // Figure out what the outputs should have been. 17052 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17053 CoreMathVerifier.computeConvert(args, target); 17054 // Validate the outputs. 17055 boolean valid = true; 17056 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17057 valid = false; 17058 } 17059 if (!valid) { 17060 if (!errorFound) { 17061 errorFound = true; 17062 message.append("Input inV: "); 17063 appendVariableToMessage(message, args.inV); 17064 message.append("\n"); 17065 message.append("Expected output out: "); 17066 appendVariableToMessage(message, args.out); 17067 message.append("\n"); 17068 message.append("Actual output out: "); 17069 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17070 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17071 message.append(" FAIL"); 17072 } 17073 message.append("\n"); 17074 message.append("Errors at"); 17075 } 17076 message.append(" ["); 17077 message.append(Integer.toString(i)); 17078 message.append(", "); 17079 message.append(Integer.toString(j)); 17080 message.append("]"); 17081 } 17082 } 17083 } 17084 assertFalse("Incorrect output for checkConvertUchar2Double2" + 17085 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17086 } 17087 checkConvertUchar3Double3()17088 private void checkConvertUchar3Double3() { 17089 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xec721046l, false, 8); 17090 try { 17091 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17092 script.forEach_testConvertDouble3Uchar3Double3(inV, out); 17093 verifyResultsConvertUchar3Double3(inV, out, false); 17094 } catch (Exception e) { 17095 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString()); 17096 } 17097 try { 17098 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17099 scriptRelaxed.forEach_testConvertDouble3Uchar3Double3(inV, out); 17100 verifyResultsConvertUchar3Double3(inV, out, true); 17101 } catch (Exception e) { 17102 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString()); 17103 } 17104 } 17105 verifyResultsConvertUchar3Double3(Allocation inV, Allocation out, boolean relaxed)17106 private void verifyResultsConvertUchar3Double3(Allocation inV, Allocation out, boolean relaxed) { 17107 byte[] arrayInV = new byte[INPUTSIZE * 4]; 17108 Arrays.fill(arrayInV, (byte) 42); 17109 inV.copyTo(arrayInV); 17110 double[] arrayOut = new double[INPUTSIZE * 4]; 17111 Arrays.fill(arrayOut, (double) 42); 17112 out.copyTo(arrayOut); 17113 StringBuilder message = new StringBuilder(); 17114 boolean errorFound = false; 17115 for (int i = 0; i < INPUTSIZE; i++) { 17116 for (int j = 0; j < 3 ; j++) { 17117 // Extract the inputs. 17118 ArgumentsUcharDouble args = new ArgumentsUcharDouble(); 17119 args.inV = arrayInV[i * 4 + j]; 17120 // Figure out what the outputs should have been. 17121 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17122 CoreMathVerifier.computeConvert(args, target); 17123 // Validate the outputs. 17124 boolean valid = true; 17125 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17126 valid = false; 17127 } 17128 if (!valid) { 17129 if (!errorFound) { 17130 errorFound = true; 17131 message.append("Input inV: "); 17132 appendVariableToMessage(message, args.inV); 17133 message.append("\n"); 17134 message.append("Expected output out: "); 17135 appendVariableToMessage(message, args.out); 17136 message.append("\n"); 17137 message.append("Actual output out: "); 17138 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17139 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17140 message.append(" FAIL"); 17141 } 17142 message.append("\n"); 17143 message.append("Errors at"); 17144 } 17145 message.append(" ["); 17146 message.append(Integer.toString(i)); 17147 message.append(", "); 17148 message.append(Integer.toString(j)); 17149 message.append("]"); 17150 } 17151 } 17152 } 17153 assertFalse("Incorrect output for checkConvertUchar3Double3" + 17154 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17155 } 17156 checkConvertUchar4Double4()17157 private void checkConvertUchar4Double4() { 17158 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x42cda172l, false, 8); 17159 try { 17160 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17161 script.forEach_testConvertDouble4Uchar4Double4(inV, out); 17162 verifyResultsConvertUchar4Double4(inV, out, false); 17163 } catch (Exception e) { 17164 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString()); 17165 } 17166 try { 17167 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17168 scriptRelaxed.forEach_testConvertDouble4Uchar4Double4(inV, out); 17169 verifyResultsConvertUchar4Double4(inV, out, true); 17170 } catch (Exception e) { 17171 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString()); 17172 } 17173 } 17174 verifyResultsConvertUchar4Double4(Allocation inV, Allocation out, boolean relaxed)17175 private void verifyResultsConvertUchar4Double4(Allocation inV, Allocation out, boolean relaxed) { 17176 byte[] arrayInV = new byte[INPUTSIZE * 4]; 17177 Arrays.fill(arrayInV, (byte) 42); 17178 inV.copyTo(arrayInV); 17179 double[] arrayOut = new double[INPUTSIZE * 4]; 17180 Arrays.fill(arrayOut, (double) 42); 17181 out.copyTo(arrayOut); 17182 StringBuilder message = new StringBuilder(); 17183 boolean errorFound = false; 17184 for (int i = 0; i < INPUTSIZE; i++) { 17185 for (int j = 0; j < 4 ; j++) { 17186 // Extract the inputs. 17187 ArgumentsUcharDouble args = new ArgumentsUcharDouble(); 17188 args.inV = arrayInV[i * 4 + j]; 17189 // Figure out what the outputs should have been. 17190 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17191 CoreMathVerifier.computeConvert(args, target); 17192 // Validate the outputs. 17193 boolean valid = true; 17194 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17195 valid = false; 17196 } 17197 if (!valid) { 17198 if (!errorFound) { 17199 errorFound = true; 17200 message.append("Input inV: "); 17201 appendVariableToMessage(message, args.inV); 17202 message.append("\n"); 17203 message.append("Expected output out: "); 17204 appendVariableToMessage(message, args.out); 17205 message.append("\n"); 17206 message.append("Actual output out: "); 17207 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17208 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17209 message.append(" FAIL"); 17210 } 17211 message.append("\n"); 17212 message.append("Errors at"); 17213 } 17214 message.append(" ["); 17215 message.append(Integer.toString(i)); 17216 message.append(", "); 17217 message.append(Integer.toString(j)); 17218 message.append("]"); 17219 } 17220 } 17221 } 17222 assertFalse("Incorrect output for checkConvertUchar4Double4" + 17223 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17224 } 17225 17226 public class ArgumentsShortDouble { 17227 public short inV; 17228 public Target.Floaty out; 17229 } 17230 checkConvertShort2Double2()17231 private void checkConvertShort2Double2() { 17232 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x23d0105l, true, 15); 17233 try { 17234 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17235 script.forEach_testConvertDouble2Short2Double2(inV, out); 17236 verifyResultsConvertShort2Double2(inV, out, false); 17237 } catch (Exception e) { 17238 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString()); 17239 } 17240 try { 17241 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17242 scriptRelaxed.forEach_testConvertDouble2Short2Double2(inV, out); 17243 verifyResultsConvertShort2Double2(inV, out, true); 17244 } catch (Exception e) { 17245 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString()); 17246 } 17247 } 17248 verifyResultsConvertShort2Double2(Allocation inV, Allocation out, boolean relaxed)17249 private void verifyResultsConvertShort2Double2(Allocation inV, Allocation out, boolean relaxed) { 17250 short[] arrayInV = new short[INPUTSIZE * 2]; 17251 Arrays.fill(arrayInV, (short) 42); 17252 inV.copyTo(arrayInV); 17253 double[] arrayOut = new double[INPUTSIZE * 2]; 17254 Arrays.fill(arrayOut, (double) 42); 17255 out.copyTo(arrayOut); 17256 StringBuilder message = new StringBuilder(); 17257 boolean errorFound = false; 17258 for (int i = 0; i < INPUTSIZE; i++) { 17259 for (int j = 0; j < 2 ; j++) { 17260 // Extract the inputs. 17261 ArgumentsShortDouble args = new ArgumentsShortDouble(); 17262 args.inV = arrayInV[i * 2 + j]; 17263 // Figure out what the outputs should have been. 17264 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17265 CoreMathVerifier.computeConvert(args, target); 17266 // Validate the outputs. 17267 boolean valid = true; 17268 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17269 valid = false; 17270 } 17271 if (!valid) { 17272 if (!errorFound) { 17273 errorFound = true; 17274 message.append("Input inV: "); 17275 appendVariableToMessage(message, args.inV); 17276 message.append("\n"); 17277 message.append("Expected output out: "); 17278 appendVariableToMessage(message, args.out); 17279 message.append("\n"); 17280 message.append("Actual output out: "); 17281 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17282 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17283 message.append(" FAIL"); 17284 } 17285 message.append("\n"); 17286 message.append("Errors at"); 17287 } 17288 message.append(" ["); 17289 message.append(Integer.toString(i)); 17290 message.append(", "); 17291 message.append(Integer.toString(j)); 17292 message.append("]"); 17293 } 17294 } 17295 } 17296 assertFalse("Incorrect output for checkConvertShort2Double2" + 17297 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17298 } 17299 checkConvertShort3Double3()17300 private void checkConvertShort3Double3() { 17301 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x58989231l, true, 15); 17302 try { 17303 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17304 script.forEach_testConvertDouble3Short3Double3(inV, out); 17305 verifyResultsConvertShort3Double3(inV, out, false); 17306 } catch (Exception e) { 17307 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString()); 17308 } 17309 try { 17310 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17311 scriptRelaxed.forEach_testConvertDouble3Short3Double3(inV, out); 17312 verifyResultsConvertShort3Double3(inV, out, true); 17313 } catch (Exception e) { 17314 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString()); 17315 } 17316 } 17317 verifyResultsConvertShort3Double3(Allocation inV, Allocation out, boolean relaxed)17318 private void verifyResultsConvertShort3Double3(Allocation inV, Allocation out, boolean relaxed) { 17319 short[] arrayInV = new short[INPUTSIZE * 4]; 17320 Arrays.fill(arrayInV, (short) 42); 17321 inV.copyTo(arrayInV); 17322 double[] arrayOut = new double[INPUTSIZE * 4]; 17323 Arrays.fill(arrayOut, (double) 42); 17324 out.copyTo(arrayOut); 17325 StringBuilder message = new StringBuilder(); 17326 boolean errorFound = false; 17327 for (int i = 0; i < INPUTSIZE; i++) { 17328 for (int j = 0; j < 3 ; j++) { 17329 // Extract the inputs. 17330 ArgumentsShortDouble args = new ArgumentsShortDouble(); 17331 args.inV = arrayInV[i * 4 + j]; 17332 // Figure out what the outputs should have been. 17333 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17334 CoreMathVerifier.computeConvert(args, target); 17335 // Validate the outputs. 17336 boolean valid = true; 17337 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17338 valid = false; 17339 } 17340 if (!valid) { 17341 if (!errorFound) { 17342 errorFound = true; 17343 message.append("Input inV: "); 17344 appendVariableToMessage(message, args.inV); 17345 message.append("\n"); 17346 message.append("Expected output out: "); 17347 appendVariableToMessage(message, args.out); 17348 message.append("\n"); 17349 message.append("Actual output out: "); 17350 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17351 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17352 message.append(" FAIL"); 17353 } 17354 message.append("\n"); 17355 message.append("Errors at"); 17356 } 17357 message.append(" ["); 17358 message.append(Integer.toString(i)); 17359 message.append(", "); 17360 message.append(Integer.toString(j)); 17361 message.append("]"); 17362 } 17363 } 17364 } 17365 assertFalse("Incorrect output for checkConvertShort3Double3" + 17366 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17367 } 17368 checkConvertShort4Double4()17369 private void checkConvertShort4Double4() { 17370 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xaef4235dl, true, 15); 17371 try { 17372 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17373 script.forEach_testConvertDouble4Short4Double4(inV, out); 17374 verifyResultsConvertShort4Double4(inV, out, false); 17375 } catch (Exception e) { 17376 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString()); 17377 } 17378 try { 17379 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17380 scriptRelaxed.forEach_testConvertDouble4Short4Double4(inV, out); 17381 verifyResultsConvertShort4Double4(inV, out, true); 17382 } catch (Exception e) { 17383 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString()); 17384 } 17385 } 17386 verifyResultsConvertShort4Double4(Allocation inV, Allocation out, boolean relaxed)17387 private void verifyResultsConvertShort4Double4(Allocation inV, Allocation out, boolean relaxed) { 17388 short[] arrayInV = new short[INPUTSIZE * 4]; 17389 Arrays.fill(arrayInV, (short) 42); 17390 inV.copyTo(arrayInV); 17391 double[] arrayOut = new double[INPUTSIZE * 4]; 17392 Arrays.fill(arrayOut, (double) 42); 17393 out.copyTo(arrayOut); 17394 StringBuilder message = new StringBuilder(); 17395 boolean errorFound = false; 17396 for (int i = 0; i < INPUTSIZE; i++) { 17397 for (int j = 0; j < 4 ; j++) { 17398 // Extract the inputs. 17399 ArgumentsShortDouble args = new ArgumentsShortDouble(); 17400 args.inV = arrayInV[i * 4 + j]; 17401 // Figure out what the outputs should have been. 17402 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17403 CoreMathVerifier.computeConvert(args, target); 17404 // Validate the outputs. 17405 boolean valid = true; 17406 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17407 valid = false; 17408 } 17409 if (!valid) { 17410 if (!errorFound) { 17411 errorFound = true; 17412 message.append("Input inV: "); 17413 appendVariableToMessage(message, args.inV); 17414 message.append("\n"); 17415 message.append("Expected output out: "); 17416 appendVariableToMessage(message, args.out); 17417 message.append("\n"); 17418 message.append("Actual output out: "); 17419 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17420 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17421 message.append(" FAIL"); 17422 } 17423 message.append("\n"); 17424 message.append("Errors at"); 17425 } 17426 message.append(" ["); 17427 message.append(Integer.toString(i)); 17428 message.append(", "); 17429 message.append(Integer.toString(j)); 17430 message.append("]"); 17431 } 17432 } 17433 } 17434 assertFalse("Incorrect output for checkConvertShort4Double4" + 17435 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17436 } 17437 17438 public class ArgumentsUshortDouble { 17439 public short inV; 17440 public Target.Floaty out; 17441 } 17442 checkConvertUshort2Double2()17443 private void checkConvertUshort2Double2() { 17444 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x9e0e6518l, false, 16); 17445 try { 17446 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17447 script.forEach_testConvertDouble2Ushort2Double2(inV, out); 17448 verifyResultsConvertUshort2Double2(inV, out, false); 17449 } catch (Exception e) { 17450 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString()); 17451 } 17452 try { 17453 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17454 scriptRelaxed.forEach_testConvertDouble2Ushort2Double2(inV, out); 17455 verifyResultsConvertUshort2Double2(inV, out, true); 17456 } catch (Exception e) { 17457 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString()); 17458 } 17459 } 17460 verifyResultsConvertUshort2Double2(Allocation inV, Allocation out, boolean relaxed)17461 private void verifyResultsConvertUshort2Double2(Allocation inV, Allocation out, boolean relaxed) { 17462 short[] arrayInV = new short[INPUTSIZE * 2]; 17463 Arrays.fill(arrayInV, (short) 42); 17464 inV.copyTo(arrayInV); 17465 double[] arrayOut = new double[INPUTSIZE * 2]; 17466 Arrays.fill(arrayOut, (double) 42); 17467 out.copyTo(arrayOut); 17468 StringBuilder message = new StringBuilder(); 17469 boolean errorFound = false; 17470 for (int i = 0; i < INPUTSIZE; i++) { 17471 for (int j = 0; j < 2 ; j++) { 17472 // Extract the inputs. 17473 ArgumentsUshortDouble args = new ArgumentsUshortDouble(); 17474 args.inV = arrayInV[i * 2 + j]; 17475 // Figure out what the outputs should have been. 17476 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17477 CoreMathVerifier.computeConvert(args, target); 17478 // Validate the outputs. 17479 boolean valid = true; 17480 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17481 valid = false; 17482 } 17483 if (!valid) { 17484 if (!errorFound) { 17485 errorFound = true; 17486 message.append("Input inV: "); 17487 appendVariableToMessage(message, args.inV); 17488 message.append("\n"); 17489 message.append("Expected output out: "); 17490 appendVariableToMessage(message, args.out); 17491 message.append("\n"); 17492 message.append("Actual output out: "); 17493 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17494 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17495 message.append(" FAIL"); 17496 } 17497 message.append("\n"); 17498 message.append("Errors at"); 17499 } 17500 message.append(" ["); 17501 message.append(Integer.toString(i)); 17502 message.append(", "); 17503 message.append(Integer.toString(j)); 17504 message.append("]"); 17505 } 17506 } 17507 } 17508 assertFalse("Incorrect output for checkConvertUshort2Double2" + 17509 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17510 } 17511 checkConvertUshort3Double3()17512 private void checkConvertUshort3Double3() { 17513 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xf469f644l, false, 16); 17514 try { 17515 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17516 script.forEach_testConvertDouble3Ushort3Double3(inV, out); 17517 verifyResultsConvertUshort3Double3(inV, out, false); 17518 } catch (Exception e) { 17519 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString()); 17520 } 17521 try { 17522 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17523 scriptRelaxed.forEach_testConvertDouble3Ushort3Double3(inV, out); 17524 verifyResultsConvertUshort3Double3(inV, out, true); 17525 } catch (Exception e) { 17526 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString()); 17527 } 17528 } 17529 verifyResultsConvertUshort3Double3(Allocation inV, Allocation out, boolean relaxed)17530 private void verifyResultsConvertUshort3Double3(Allocation inV, Allocation out, boolean relaxed) { 17531 short[] arrayInV = new short[INPUTSIZE * 4]; 17532 Arrays.fill(arrayInV, (short) 42); 17533 inV.copyTo(arrayInV); 17534 double[] arrayOut = new double[INPUTSIZE * 4]; 17535 Arrays.fill(arrayOut, (double) 42); 17536 out.copyTo(arrayOut); 17537 StringBuilder message = new StringBuilder(); 17538 boolean errorFound = false; 17539 for (int i = 0; i < INPUTSIZE; i++) { 17540 for (int j = 0; j < 3 ; j++) { 17541 // Extract the inputs. 17542 ArgumentsUshortDouble args = new ArgumentsUshortDouble(); 17543 args.inV = arrayInV[i * 4 + j]; 17544 // Figure out what the outputs should have been. 17545 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17546 CoreMathVerifier.computeConvert(args, target); 17547 // Validate the outputs. 17548 boolean valid = true; 17549 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17550 valid = false; 17551 } 17552 if (!valid) { 17553 if (!errorFound) { 17554 errorFound = true; 17555 message.append("Input inV: "); 17556 appendVariableToMessage(message, args.inV); 17557 message.append("\n"); 17558 message.append("Expected output out: "); 17559 appendVariableToMessage(message, args.out); 17560 message.append("\n"); 17561 message.append("Actual output out: "); 17562 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17563 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17564 message.append(" FAIL"); 17565 } 17566 message.append("\n"); 17567 message.append("Errors at"); 17568 } 17569 message.append(" ["); 17570 message.append(Integer.toString(i)); 17571 message.append(", "); 17572 message.append(Integer.toString(j)); 17573 message.append("]"); 17574 } 17575 } 17576 } 17577 assertFalse("Incorrect output for checkConvertUshort3Double3" + 17578 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17579 } 17580 checkConvertUshort4Double4()17581 private void checkConvertUshort4Double4() { 17582 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x4ac58770l, false, 16); 17583 try { 17584 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17585 script.forEach_testConvertDouble4Ushort4Double4(inV, out); 17586 verifyResultsConvertUshort4Double4(inV, out, false); 17587 } catch (Exception e) { 17588 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString()); 17589 } 17590 try { 17591 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17592 scriptRelaxed.forEach_testConvertDouble4Ushort4Double4(inV, out); 17593 verifyResultsConvertUshort4Double4(inV, out, true); 17594 } catch (Exception e) { 17595 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString()); 17596 } 17597 } 17598 verifyResultsConvertUshort4Double4(Allocation inV, Allocation out, boolean relaxed)17599 private void verifyResultsConvertUshort4Double4(Allocation inV, Allocation out, boolean relaxed) { 17600 short[] arrayInV = new short[INPUTSIZE * 4]; 17601 Arrays.fill(arrayInV, (short) 42); 17602 inV.copyTo(arrayInV); 17603 double[] arrayOut = new double[INPUTSIZE * 4]; 17604 Arrays.fill(arrayOut, (double) 42); 17605 out.copyTo(arrayOut); 17606 StringBuilder message = new StringBuilder(); 17607 boolean errorFound = false; 17608 for (int i = 0; i < INPUTSIZE; i++) { 17609 for (int j = 0; j < 4 ; j++) { 17610 // Extract the inputs. 17611 ArgumentsUshortDouble args = new ArgumentsUshortDouble(); 17612 args.inV = arrayInV[i * 4 + j]; 17613 // Figure out what the outputs should have been. 17614 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17615 CoreMathVerifier.computeConvert(args, target); 17616 // Validate the outputs. 17617 boolean valid = true; 17618 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17619 valid = false; 17620 } 17621 if (!valid) { 17622 if (!errorFound) { 17623 errorFound = true; 17624 message.append("Input inV: "); 17625 appendVariableToMessage(message, args.inV); 17626 message.append("\n"); 17627 message.append("Expected output out: "); 17628 appendVariableToMessage(message, args.out); 17629 message.append("\n"); 17630 message.append("Actual output out: "); 17631 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17632 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17633 message.append(" FAIL"); 17634 } 17635 message.append("\n"); 17636 message.append("Errors at"); 17637 } 17638 message.append(" ["); 17639 message.append(Integer.toString(i)); 17640 message.append(", "); 17641 message.append(Integer.toString(j)); 17642 message.append("]"); 17643 } 17644 } 17645 } 17646 assertFalse("Incorrect output for checkConvertUshort4Double4" + 17647 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17648 } 17649 17650 public class ArgumentsIntDouble { 17651 public int inV; 17652 public Target.Floaty out; 17653 } 17654 checkConvertInt2Double2()17655 private void checkConvertInt2Double2() { 17656 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xa40fc8f6l, true, 31); 17657 try { 17658 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17659 script.forEach_testConvertDouble2Int2Double2(inV, out); 17660 verifyResultsConvertInt2Double2(inV, out, false); 17661 } catch (Exception e) { 17662 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString()); 17663 } 17664 try { 17665 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17666 scriptRelaxed.forEach_testConvertDouble2Int2Double2(inV, out); 17667 verifyResultsConvertInt2Double2(inV, out, true); 17668 } catch (Exception e) { 17669 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString()); 17670 } 17671 } 17672 verifyResultsConvertInt2Double2(Allocation inV, Allocation out, boolean relaxed)17673 private void verifyResultsConvertInt2Double2(Allocation inV, Allocation out, boolean relaxed) { 17674 int[] arrayInV = new int[INPUTSIZE * 2]; 17675 Arrays.fill(arrayInV, (int) 42); 17676 inV.copyTo(arrayInV); 17677 double[] arrayOut = new double[INPUTSIZE * 2]; 17678 Arrays.fill(arrayOut, (double) 42); 17679 out.copyTo(arrayOut); 17680 StringBuilder message = new StringBuilder(); 17681 boolean errorFound = false; 17682 for (int i = 0; i < INPUTSIZE; i++) { 17683 for (int j = 0; j < 2 ; j++) { 17684 // Extract the inputs. 17685 ArgumentsIntDouble args = new ArgumentsIntDouble(); 17686 args.inV = arrayInV[i * 2 + j]; 17687 // Figure out what the outputs should have been. 17688 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17689 CoreMathVerifier.computeConvert(args, target); 17690 // Validate the outputs. 17691 boolean valid = true; 17692 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17693 valid = false; 17694 } 17695 if (!valid) { 17696 if (!errorFound) { 17697 errorFound = true; 17698 message.append("Input inV: "); 17699 appendVariableToMessage(message, args.inV); 17700 message.append("\n"); 17701 message.append("Expected output out: "); 17702 appendVariableToMessage(message, args.out); 17703 message.append("\n"); 17704 message.append("Actual output out: "); 17705 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17706 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17707 message.append(" FAIL"); 17708 } 17709 message.append("\n"); 17710 message.append("Errors at"); 17711 } 17712 message.append(" ["); 17713 message.append(Integer.toString(i)); 17714 message.append(", "); 17715 message.append(Integer.toString(j)); 17716 message.append("]"); 17717 } 17718 } 17719 } 17720 assertFalse("Incorrect output for checkConvertInt2Double2" + 17721 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17722 } 17723 checkConvertInt3Double3()17724 private void checkConvertInt3Double3() { 17725 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xfa6b5a22l, true, 31); 17726 try { 17727 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17728 script.forEach_testConvertDouble3Int3Double3(inV, out); 17729 verifyResultsConvertInt3Double3(inV, out, false); 17730 } catch (Exception e) { 17731 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString()); 17732 } 17733 try { 17734 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17735 scriptRelaxed.forEach_testConvertDouble3Int3Double3(inV, out); 17736 verifyResultsConvertInt3Double3(inV, out, true); 17737 } catch (Exception e) { 17738 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString()); 17739 } 17740 } 17741 verifyResultsConvertInt3Double3(Allocation inV, Allocation out, boolean relaxed)17742 private void verifyResultsConvertInt3Double3(Allocation inV, Allocation out, boolean relaxed) { 17743 int[] arrayInV = new int[INPUTSIZE * 4]; 17744 Arrays.fill(arrayInV, (int) 42); 17745 inV.copyTo(arrayInV); 17746 double[] arrayOut = new double[INPUTSIZE * 4]; 17747 Arrays.fill(arrayOut, (double) 42); 17748 out.copyTo(arrayOut); 17749 StringBuilder message = new StringBuilder(); 17750 boolean errorFound = false; 17751 for (int i = 0; i < INPUTSIZE; i++) { 17752 for (int j = 0; j < 3 ; j++) { 17753 // Extract the inputs. 17754 ArgumentsIntDouble args = new ArgumentsIntDouble(); 17755 args.inV = arrayInV[i * 4 + j]; 17756 // Figure out what the outputs should have been. 17757 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17758 CoreMathVerifier.computeConvert(args, target); 17759 // Validate the outputs. 17760 boolean valid = true; 17761 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17762 valid = false; 17763 } 17764 if (!valid) { 17765 if (!errorFound) { 17766 errorFound = true; 17767 message.append("Input inV: "); 17768 appendVariableToMessage(message, args.inV); 17769 message.append("\n"); 17770 message.append("Expected output out: "); 17771 appendVariableToMessage(message, args.out); 17772 message.append("\n"); 17773 message.append("Actual output out: "); 17774 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17775 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17776 message.append(" FAIL"); 17777 } 17778 message.append("\n"); 17779 message.append("Errors at"); 17780 } 17781 message.append(" ["); 17782 message.append(Integer.toString(i)); 17783 message.append(", "); 17784 message.append(Integer.toString(j)); 17785 message.append("]"); 17786 } 17787 } 17788 } 17789 assertFalse("Incorrect output for checkConvertInt3Double3" + 17790 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17791 } 17792 checkConvertInt4Double4()17793 private void checkConvertInt4Double4() { 17794 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x50c6eb4el, true, 31); 17795 try { 17796 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17797 script.forEach_testConvertDouble4Int4Double4(inV, out); 17798 verifyResultsConvertInt4Double4(inV, out, false); 17799 } catch (Exception e) { 17800 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString()); 17801 } 17802 try { 17803 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 17804 scriptRelaxed.forEach_testConvertDouble4Int4Double4(inV, out); 17805 verifyResultsConvertInt4Double4(inV, out, true); 17806 } catch (Exception e) { 17807 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString()); 17808 } 17809 } 17810 verifyResultsConvertInt4Double4(Allocation inV, Allocation out, boolean relaxed)17811 private void verifyResultsConvertInt4Double4(Allocation inV, Allocation out, boolean relaxed) { 17812 int[] arrayInV = new int[INPUTSIZE * 4]; 17813 Arrays.fill(arrayInV, (int) 42); 17814 inV.copyTo(arrayInV); 17815 double[] arrayOut = new double[INPUTSIZE * 4]; 17816 Arrays.fill(arrayOut, (double) 42); 17817 out.copyTo(arrayOut); 17818 StringBuilder message = new StringBuilder(); 17819 boolean errorFound = false; 17820 for (int i = 0; i < INPUTSIZE; i++) { 17821 for (int j = 0; j < 4 ; j++) { 17822 // Extract the inputs. 17823 ArgumentsIntDouble args = new ArgumentsIntDouble(); 17824 args.inV = arrayInV[i * 4 + j]; 17825 // Figure out what the outputs should have been. 17826 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17827 CoreMathVerifier.computeConvert(args, target); 17828 // Validate the outputs. 17829 boolean valid = true; 17830 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17831 valid = false; 17832 } 17833 if (!valid) { 17834 if (!errorFound) { 17835 errorFound = true; 17836 message.append("Input inV: "); 17837 appendVariableToMessage(message, args.inV); 17838 message.append("\n"); 17839 message.append("Expected output out: "); 17840 appendVariableToMessage(message, args.out); 17841 message.append("\n"); 17842 message.append("Actual output out: "); 17843 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17844 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17845 message.append(" FAIL"); 17846 } 17847 message.append("\n"); 17848 message.append("Errors at"); 17849 } 17850 message.append(" ["); 17851 message.append(Integer.toString(i)); 17852 message.append(", "); 17853 message.append(Integer.toString(j)); 17854 message.append("]"); 17855 } 17856 } 17857 } 17858 assertFalse("Incorrect output for checkConvertInt4Double4" + 17859 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17860 } 17861 17862 public class ArgumentsUintDouble { 17863 public int inV; 17864 public Target.Floaty out; 17865 } 17866 checkConvertUint2Double2()17867 private void checkConvertUint2Double2() { 17868 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3fe7e2a1l, false, 32); 17869 try { 17870 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17871 script.forEach_testConvertDouble2Uint2Double2(inV, out); 17872 verifyResultsConvertUint2Double2(inV, out, false); 17873 } catch (Exception e) { 17874 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString()); 17875 } 17876 try { 17877 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 17878 scriptRelaxed.forEach_testConvertDouble2Uint2Double2(inV, out); 17879 verifyResultsConvertUint2Double2(inV, out, true); 17880 } catch (Exception e) { 17881 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString()); 17882 } 17883 } 17884 verifyResultsConvertUint2Double2(Allocation inV, Allocation out, boolean relaxed)17885 private void verifyResultsConvertUint2Double2(Allocation inV, Allocation out, boolean relaxed) { 17886 int[] arrayInV = new int[INPUTSIZE * 2]; 17887 Arrays.fill(arrayInV, (int) 42); 17888 inV.copyTo(arrayInV); 17889 double[] arrayOut = new double[INPUTSIZE * 2]; 17890 Arrays.fill(arrayOut, (double) 42); 17891 out.copyTo(arrayOut); 17892 StringBuilder message = new StringBuilder(); 17893 boolean errorFound = false; 17894 for (int i = 0; i < INPUTSIZE; i++) { 17895 for (int j = 0; j < 2 ; j++) { 17896 // Extract the inputs. 17897 ArgumentsUintDouble args = new ArgumentsUintDouble(); 17898 args.inV = arrayInV[i * 2 + j]; 17899 // Figure out what the outputs should have been. 17900 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17901 CoreMathVerifier.computeConvert(args, target); 17902 // Validate the outputs. 17903 boolean valid = true; 17904 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17905 valid = false; 17906 } 17907 if (!valid) { 17908 if (!errorFound) { 17909 errorFound = true; 17910 message.append("Input inV: "); 17911 appendVariableToMessage(message, args.inV); 17912 message.append("\n"); 17913 message.append("Expected output out: "); 17914 appendVariableToMessage(message, args.out); 17915 message.append("\n"); 17916 message.append("Actual output out: "); 17917 appendVariableToMessage(message, arrayOut[i * 2 + j]); 17918 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 17919 message.append(" FAIL"); 17920 } 17921 message.append("\n"); 17922 message.append("Errors at"); 17923 } 17924 message.append(" ["); 17925 message.append(Integer.toString(i)); 17926 message.append(", "); 17927 message.append(Integer.toString(j)); 17928 message.append("]"); 17929 } 17930 } 17931 } 17932 assertFalse("Incorrect output for checkConvertUint2Double2" + 17933 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 17934 } 17935 checkConvertUint3Double3()17936 private void checkConvertUint3Double3() { 17937 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x964373cdl, false, 32); 17938 try { 17939 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17940 script.forEach_testConvertDouble3Uint3Double3(inV, out); 17941 verifyResultsConvertUint3Double3(inV, out, false); 17942 } catch (Exception e) { 17943 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString()); 17944 } 17945 try { 17946 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 17947 scriptRelaxed.forEach_testConvertDouble3Uint3Double3(inV, out); 17948 verifyResultsConvertUint3Double3(inV, out, true); 17949 } catch (Exception e) { 17950 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString()); 17951 } 17952 } 17953 verifyResultsConvertUint3Double3(Allocation inV, Allocation out, boolean relaxed)17954 private void verifyResultsConvertUint3Double3(Allocation inV, Allocation out, boolean relaxed) { 17955 int[] arrayInV = new int[INPUTSIZE * 4]; 17956 Arrays.fill(arrayInV, (int) 42); 17957 inV.copyTo(arrayInV); 17958 double[] arrayOut = new double[INPUTSIZE * 4]; 17959 Arrays.fill(arrayOut, (double) 42); 17960 out.copyTo(arrayOut); 17961 StringBuilder message = new StringBuilder(); 17962 boolean errorFound = false; 17963 for (int i = 0; i < INPUTSIZE; i++) { 17964 for (int j = 0; j < 3 ; j++) { 17965 // Extract the inputs. 17966 ArgumentsUintDouble args = new ArgumentsUintDouble(); 17967 args.inV = arrayInV[i * 4 + j]; 17968 // Figure out what the outputs should have been. 17969 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 17970 CoreMathVerifier.computeConvert(args, target); 17971 // Validate the outputs. 17972 boolean valid = true; 17973 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17974 valid = false; 17975 } 17976 if (!valid) { 17977 if (!errorFound) { 17978 errorFound = true; 17979 message.append("Input inV: "); 17980 appendVariableToMessage(message, args.inV); 17981 message.append("\n"); 17982 message.append("Expected output out: "); 17983 appendVariableToMessage(message, args.out); 17984 message.append("\n"); 17985 message.append("Actual output out: "); 17986 appendVariableToMessage(message, arrayOut[i * 4 + j]); 17987 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 17988 message.append(" FAIL"); 17989 } 17990 message.append("\n"); 17991 message.append("Errors at"); 17992 } 17993 message.append(" ["); 17994 message.append(Integer.toString(i)); 17995 message.append(", "); 17996 message.append(Integer.toString(j)); 17997 message.append("]"); 17998 } 17999 } 18000 } 18001 assertFalse("Incorrect output for checkConvertUint3Double3" + 18002 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18003 } 18004 checkConvertUint4Double4()18005 private void checkConvertUint4Double4() { 18006 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xec9f04f9l, false, 32); 18007 try { 18008 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18009 script.forEach_testConvertDouble4Uint4Double4(inV, out); 18010 verifyResultsConvertUint4Double4(inV, out, false); 18011 } catch (Exception e) { 18012 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString()); 18013 } 18014 try { 18015 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 18016 scriptRelaxed.forEach_testConvertDouble4Uint4Double4(inV, out); 18017 verifyResultsConvertUint4Double4(inV, out, true); 18018 } catch (Exception e) { 18019 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString()); 18020 } 18021 } 18022 verifyResultsConvertUint4Double4(Allocation inV, Allocation out, boolean relaxed)18023 private void verifyResultsConvertUint4Double4(Allocation inV, Allocation out, boolean relaxed) { 18024 int[] arrayInV = new int[INPUTSIZE * 4]; 18025 Arrays.fill(arrayInV, (int) 42); 18026 inV.copyTo(arrayInV); 18027 double[] arrayOut = new double[INPUTSIZE * 4]; 18028 Arrays.fill(arrayOut, (double) 42); 18029 out.copyTo(arrayOut); 18030 StringBuilder message = new StringBuilder(); 18031 boolean errorFound = false; 18032 for (int i = 0; i < INPUTSIZE; i++) { 18033 for (int j = 0; j < 4 ; j++) { 18034 // Extract the inputs. 18035 ArgumentsUintDouble args = new ArgumentsUintDouble(); 18036 args.inV = arrayInV[i * 4 + j]; 18037 // Figure out what the outputs should have been. 18038 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 18039 CoreMathVerifier.computeConvert(args, target); 18040 // Validate the outputs. 18041 boolean valid = true; 18042 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18043 valid = false; 18044 } 18045 if (!valid) { 18046 if (!errorFound) { 18047 errorFound = true; 18048 message.append("Input inV: "); 18049 appendVariableToMessage(message, args.inV); 18050 message.append("\n"); 18051 message.append("Expected output out: "); 18052 appendVariableToMessage(message, args.out); 18053 message.append("\n"); 18054 message.append("Actual output out: "); 18055 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18056 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 18057 message.append(" FAIL"); 18058 } 18059 message.append("\n"); 18060 message.append("Errors at"); 18061 } 18062 message.append(" ["); 18063 message.append(Integer.toString(i)); 18064 message.append(", "); 18065 message.append(Integer.toString(j)); 18066 message.append("]"); 18067 } 18068 } 18069 } 18070 assertFalse("Incorrect output for checkConvertUint4Double4" + 18071 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18072 } 18073 18074 public class ArgumentsFloatLong { 18075 public float inV; 18076 public long out; 18077 } 18078 checkConvertFloat2Long2()18079 private void checkConvertFloat2Long2() { 18080 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7d7c0ae0l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); 18081 try { 18082 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18083 script.forEach_testConvertLong2Float2Long2(inV, out); 18084 verifyResultsConvertFloat2Long2(inV, out, false); 18085 } catch (Exception e) { 18086 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString()); 18087 } 18088 try { 18089 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18090 scriptRelaxed.forEach_testConvertLong2Float2Long2(inV, out); 18091 verifyResultsConvertFloat2Long2(inV, out, true); 18092 } catch (Exception e) { 18093 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString()); 18094 } 18095 } 18096 verifyResultsConvertFloat2Long2(Allocation inV, Allocation out, boolean relaxed)18097 private void verifyResultsConvertFloat2Long2(Allocation inV, Allocation out, boolean relaxed) { 18098 float[] arrayInV = new float[INPUTSIZE * 2]; 18099 Arrays.fill(arrayInV, (float) 42); 18100 inV.copyTo(arrayInV); 18101 long[] arrayOut = new long[INPUTSIZE * 2]; 18102 Arrays.fill(arrayOut, (long) 42); 18103 out.copyTo(arrayOut); 18104 StringBuilder message = new StringBuilder(); 18105 boolean errorFound = false; 18106 for (int i = 0; i < INPUTSIZE; i++) { 18107 for (int j = 0; j < 2 ; j++) { 18108 // Extract the inputs. 18109 ArgumentsFloatLong args = new ArgumentsFloatLong(); 18110 args.inV = arrayInV[i * 2 + j]; 18111 // Figure out what the outputs should have been. 18112 CoreMathVerifier.computeConvert(args); 18113 // Validate the outputs. 18114 boolean valid = true; 18115 if (args.out != arrayOut[i * 2 + j]) { 18116 valid = false; 18117 } 18118 if (!valid) { 18119 if (!errorFound) { 18120 errorFound = true; 18121 message.append("Input inV: "); 18122 appendVariableToMessage(message, args.inV); 18123 message.append("\n"); 18124 message.append("Expected output out: "); 18125 appendVariableToMessage(message, args.out); 18126 message.append("\n"); 18127 message.append("Actual output out: "); 18128 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18129 if (args.out != arrayOut[i * 2 + j]) { 18130 message.append(" FAIL"); 18131 } 18132 message.append("\n"); 18133 message.append("Errors at"); 18134 } 18135 message.append(" ["); 18136 message.append(Integer.toString(i)); 18137 message.append(", "); 18138 message.append(Integer.toString(j)); 18139 message.append("]"); 18140 } 18141 } 18142 } 18143 assertFalse("Incorrect output for checkConvertFloat2Long2" + 18144 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18145 } 18146 checkConvertFloat3Long3()18147 private void checkConvertFloat3Long3() { 18148 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdc83cfd4l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); 18149 try { 18150 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18151 script.forEach_testConvertLong3Float3Long3(inV, out); 18152 verifyResultsConvertFloat3Long3(inV, out, false); 18153 } catch (Exception e) { 18154 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString()); 18155 } 18156 try { 18157 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18158 scriptRelaxed.forEach_testConvertLong3Float3Long3(inV, out); 18159 verifyResultsConvertFloat3Long3(inV, out, true); 18160 } catch (Exception e) { 18161 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString()); 18162 } 18163 } 18164 verifyResultsConvertFloat3Long3(Allocation inV, Allocation out, boolean relaxed)18165 private void verifyResultsConvertFloat3Long3(Allocation inV, Allocation out, boolean relaxed) { 18166 float[] arrayInV = new float[INPUTSIZE * 4]; 18167 Arrays.fill(arrayInV, (float) 42); 18168 inV.copyTo(arrayInV); 18169 long[] arrayOut = new long[INPUTSIZE * 4]; 18170 Arrays.fill(arrayOut, (long) 42); 18171 out.copyTo(arrayOut); 18172 StringBuilder message = new StringBuilder(); 18173 boolean errorFound = false; 18174 for (int i = 0; i < INPUTSIZE; i++) { 18175 for (int j = 0; j < 3 ; j++) { 18176 // Extract the inputs. 18177 ArgumentsFloatLong args = new ArgumentsFloatLong(); 18178 args.inV = arrayInV[i * 4 + j]; 18179 // Figure out what the outputs should have been. 18180 CoreMathVerifier.computeConvert(args); 18181 // Validate the outputs. 18182 boolean valid = true; 18183 if (args.out != arrayOut[i * 4 + j]) { 18184 valid = false; 18185 } 18186 if (!valid) { 18187 if (!errorFound) { 18188 errorFound = true; 18189 message.append("Input inV: "); 18190 appendVariableToMessage(message, args.inV); 18191 message.append("\n"); 18192 message.append("Expected output out: "); 18193 appendVariableToMessage(message, args.out); 18194 message.append("\n"); 18195 message.append("Actual output out: "); 18196 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18197 if (args.out != arrayOut[i * 4 + j]) { 18198 message.append(" FAIL"); 18199 } 18200 message.append("\n"); 18201 message.append("Errors at"); 18202 } 18203 message.append(" ["); 18204 message.append(Integer.toString(i)); 18205 message.append(", "); 18206 message.append(Integer.toString(j)); 18207 message.append("]"); 18208 } 18209 } 18210 } 18211 assertFalse("Incorrect output for checkConvertFloat3Long3" + 18212 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18213 } 18214 checkConvertFloat4Long4()18215 private void checkConvertFloat4Long4() { 18216 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b8b94c8l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); 18217 try { 18218 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18219 script.forEach_testConvertLong4Float4Long4(inV, out); 18220 verifyResultsConvertFloat4Long4(inV, out, false); 18221 } catch (Exception e) { 18222 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString()); 18223 } 18224 try { 18225 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18226 scriptRelaxed.forEach_testConvertLong4Float4Long4(inV, out); 18227 verifyResultsConvertFloat4Long4(inV, out, true); 18228 } catch (Exception e) { 18229 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString()); 18230 } 18231 } 18232 verifyResultsConvertFloat4Long4(Allocation inV, Allocation out, boolean relaxed)18233 private void verifyResultsConvertFloat4Long4(Allocation inV, Allocation out, boolean relaxed) { 18234 float[] arrayInV = new float[INPUTSIZE * 4]; 18235 Arrays.fill(arrayInV, (float) 42); 18236 inV.copyTo(arrayInV); 18237 long[] arrayOut = new long[INPUTSIZE * 4]; 18238 Arrays.fill(arrayOut, (long) 42); 18239 out.copyTo(arrayOut); 18240 StringBuilder message = new StringBuilder(); 18241 boolean errorFound = false; 18242 for (int i = 0; i < INPUTSIZE; i++) { 18243 for (int j = 0; j < 4 ; j++) { 18244 // Extract the inputs. 18245 ArgumentsFloatLong args = new ArgumentsFloatLong(); 18246 args.inV = arrayInV[i * 4 + j]; 18247 // Figure out what the outputs should have been. 18248 CoreMathVerifier.computeConvert(args); 18249 // Validate the outputs. 18250 boolean valid = true; 18251 if (args.out != arrayOut[i * 4 + j]) { 18252 valid = false; 18253 } 18254 if (!valid) { 18255 if (!errorFound) { 18256 errorFound = true; 18257 message.append("Input inV: "); 18258 appendVariableToMessage(message, args.inV); 18259 message.append("\n"); 18260 message.append("Expected output out: "); 18261 appendVariableToMessage(message, args.out); 18262 message.append("\n"); 18263 message.append("Actual output out: "); 18264 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18265 if (args.out != arrayOut[i * 4 + j]) { 18266 message.append(" FAIL"); 18267 } 18268 message.append("\n"); 18269 message.append("Errors at"); 18270 } 18271 message.append(" ["); 18272 message.append(Integer.toString(i)); 18273 message.append(", "); 18274 message.append(Integer.toString(j)); 18275 message.append("]"); 18276 } 18277 } 18278 } 18279 assertFalse("Incorrect output for checkConvertFloat4Long4" + 18280 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18281 } 18282 18283 public class ArgumentsCharLong { 18284 public byte inV; 18285 public long out; 18286 } 18287 checkConvertChar2Long2()18288 private void checkConvertChar2Long2() { 18289 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x290be220l, true, 7); 18290 try { 18291 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18292 script.forEach_testConvertLong2Char2Long2(inV, out); 18293 verifyResultsConvertChar2Long2(inV, out, false); 18294 } catch (Exception e) { 18295 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString()); 18296 } 18297 try { 18298 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18299 scriptRelaxed.forEach_testConvertLong2Char2Long2(inV, out); 18300 verifyResultsConvertChar2Long2(inV, out, true); 18301 } catch (Exception e) { 18302 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString()); 18303 } 18304 } 18305 verifyResultsConvertChar2Long2(Allocation inV, Allocation out, boolean relaxed)18306 private void verifyResultsConvertChar2Long2(Allocation inV, Allocation out, boolean relaxed) { 18307 byte[] arrayInV = new byte[INPUTSIZE * 2]; 18308 Arrays.fill(arrayInV, (byte) 42); 18309 inV.copyTo(arrayInV); 18310 long[] arrayOut = new long[INPUTSIZE * 2]; 18311 Arrays.fill(arrayOut, (long) 42); 18312 out.copyTo(arrayOut); 18313 StringBuilder message = new StringBuilder(); 18314 boolean errorFound = false; 18315 for (int i = 0; i < INPUTSIZE; i++) { 18316 for (int j = 0; j < 2 ; j++) { 18317 // Extract the inputs. 18318 ArgumentsCharLong args = new ArgumentsCharLong(); 18319 args.inV = arrayInV[i * 2 + j]; 18320 // Figure out what the outputs should have been. 18321 CoreMathVerifier.computeConvert(args); 18322 // Validate the outputs. 18323 boolean valid = true; 18324 if (args.out != arrayOut[i * 2 + j]) { 18325 valid = false; 18326 } 18327 if (!valid) { 18328 if (!errorFound) { 18329 errorFound = true; 18330 message.append("Input inV: "); 18331 appendVariableToMessage(message, args.inV); 18332 message.append("\n"); 18333 message.append("Expected output out: "); 18334 appendVariableToMessage(message, args.out); 18335 message.append("\n"); 18336 message.append("Actual output out: "); 18337 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18338 if (args.out != arrayOut[i * 2 + j]) { 18339 message.append(" FAIL"); 18340 } 18341 message.append("\n"); 18342 message.append("Errors at"); 18343 } 18344 message.append(" ["); 18345 message.append(Integer.toString(i)); 18346 message.append(", "); 18347 message.append(Integer.toString(j)); 18348 message.append("]"); 18349 } 18350 } 18351 } 18352 assertFalse("Incorrect output for checkConvertChar2Long2" + 18353 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18354 } 18355 checkConvertChar3Long3()18356 private void checkConvertChar3Long3() { 18357 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x8813a714l, true, 7); 18358 try { 18359 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18360 script.forEach_testConvertLong3Char3Long3(inV, out); 18361 verifyResultsConvertChar3Long3(inV, out, false); 18362 } catch (Exception e) { 18363 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString()); 18364 } 18365 try { 18366 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18367 scriptRelaxed.forEach_testConvertLong3Char3Long3(inV, out); 18368 verifyResultsConvertChar3Long3(inV, out, true); 18369 } catch (Exception e) { 18370 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString()); 18371 } 18372 } 18373 verifyResultsConvertChar3Long3(Allocation inV, Allocation out, boolean relaxed)18374 private void verifyResultsConvertChar3Long3(Allocation inV, Allocation out, boolean relaxed) { 18375 byte[] arrayInV = new byte[INPUTSIZE * 4]; 18376 Arrays.fill(arrayInV, (byte) 42); 18377 inV.copyTo(arrayInV); 18378 long[] arrayOut = new long[INPUTSIZE * 4]; 18379 Arrays.fill(arrayOut, (long) 42); 18380 out.copyTo(arrayOut); 18381 StringBuilder message = new StringBuilder(); 18382 boolean errorFound = false; 18383 for (int i = 0; i < INPUTSIZE; i++) { 18384 for (int j = 0; j < 3 ; j++) { 18385 // Extract the inputs. 18386 ArgumentsCharLong args = new ArgumentsCharLong(); 18387 args.inV = arrayInV[i * 4 + j]; 18388 // Figure out what the outputs should have been. 18389 CoreMathVerifier.computeConvert(args); 18390 // Validate the outputs. 18391 boolean valid = true; 18392 if (args.out != arrayOut[i * 4 + j]) { 18393 valid = false; 18394 } 18395 if (!valid) { 18396 if (!errorFound) { 18397 errorFound = true; 18398 message.append("Input inV: "); 18399 appendVariableToMessage(message, args.inV); 18400 message.append("\n"); 18401 message.append("Expected output out: "); 18402 appendVariableToMessage(message, args.out); 18403 message.append("\n"); 18404 message.append("Actual output out: "); 18405 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18406 if (args.out != arrayOut[i * 4 + j]) { 18407 message.append(" FAIL"); 18408 } 18409 message.append("\n"); 18410 message.append("Errors at"); 18411 } 18412 message.append(" ["); 18413 message.append(Integer.toString(i)); 18414 message.append(", "); 18415 message.append(Integer.toString(j)); 18416 message.append("]"); 18417 } 18418 } 18419 } 18420 assertFalse("Incorrect output for checkConvertChar3Long3" + 18421 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18422 } 18423 checkConvertChar4Long4()18424 private void checkConvertChar4Long4() { 18425 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xe71b6c08l, true, 7); 18426 try { 18427 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18428 script.forEach_testConvertLong4Char4Long4(inV, out); 18429 verifyResultsConvertChar4Long4(inV, out, false); 18430 } catch (Exception e) { 18431 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString()); 18432 } 18433 try { 18434 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18435 scriptRelaxed.forEach_testConvertLong4Char4Long4(inV, out); 18436 verifyResultsConvertChar4Long4(inV, out, true); 18437 } catch (Exception e) { 18438 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString()); 18439 } 18440 } 18441 verifyResultsConvertChar4Long4(Allocation inV, Allocation out, boolean relaxed)18442 private void verifyResultsConvertChar4Long4(Allocation inV, Allocation out, boolean relaxed) { 18443 byte[] arrayInV = new byte[INPUTSIZE * 4]; 18444 Arrays.fill(arrayInV, (byte) 42); 18445 inV.copyTo(arrayInV); 18446 long[] arrayOut = new long[INPUTSIZE * 4]; 18447 Arrays.fill(arrayOut, (long) 42); 18448 out.copyTo(arrayOut); 18449 StringBuilder message = new StringBuilder(); 18450 boolean errorFound = false; 18451 for (int i = 0; i < INPUTSIZE; i++) { 18452 for (int j = 0; j < 4 ; j++) { 18453 // Extract the inputs. 18454 ArgumentsCharLong args = new ArgumentsCharLong(); 18455 args.inV = arrayInV[i * 4 + j]; 18456 // Figure out what the outputs should have been. 18457 CoreMathVerifier.computeConvert(args); 18458 // Validate the outputs. 18459 boolean valid = true; 18460 if (args.out != arrayOut[i * 4 + j]) { 18461 valid = false; 18462 } 18463 if (!valid) { 18464 if (!errorFound) { 18465 errorFound = true; 18466 message.append("Input inV: "); 18467 appendVariableToMessage(message, args.inV); 18468 message.append("\n"); 18469 message.append("Expected output out: "); 18470 appendVariableToMessage(message, args.out); 18471 message.append("\n"); 18472 message.append("Actual output out: "); 18473 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18474 if (args.out != arrayOut[i * 4 + j]) { 18475 message.append(" FAIL"); 18476 } 18477 message.append("\n"); 18478 message.append("Errors at"); 18479 } 18480 message.append(" ["); 18481 message.append(Integer.toString(i)); 18482 message.append(", "); 18483 message.append(Integer.toString(j)); 18484 message.append("]"); 18485 } 18486 } 18487 } 18488 assertFalse("Incorrect output for checkConvertChar4Long4" + 18489 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18490 } 18491 18492 public class ArgumentsUcharLong { 18493 public byte inV; 18494 public long out; 18495 } 18496 checkConvertUchar2Long2()18497 private void checkConvertUchar2Long2() { 18498 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbb8deea1l, false, 8); 18499 try { 18500 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18501 script.forEach_testConvertLong2Uchar2Long2(inV, out); 18502 verifyResultsConvertUchar2Long2(inV, out, false); 18503 } catch (Exception e) { 18504 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString()); 18505 } 18506 try { 18507 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18508 scriptRelaxed.forEach_testConvertLong2Uchar2Long2(inV, out); 18509 verifyResultsConvertUchar2Long2(inV, out, true); 18510 } catch (Exception e) { 18511 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString()); 18512 } 18513 } 18514 verifyResultsConvertUchar2Long2(Allocation inV, Allocation out, boolean relaxed)18515 private void verifyResultsConvertUchar2Long2(Allocation inV, Allocation out, boolean relaxed) { 18516 byte[] arrayInV = new byte[INPUTSIZE * 2]; 18517 Arrays.fill(arrayInV, (byte) 42); 18518 inV.copyTo(arrayInV); 18519 long[] arrayOut = new long[INPUTSIZE * 2]; 18520 Arrays.fill(arrayOut, (long) 42); 18521 out.copyTo(arrayOut); 18522 StringBuilder message = new StringBuilder(); 18523 boolean errorFound = false; 18524 for (int i = 0; i < INPUTSIZE; i++) { 18525 for (int j = 0; j < 2 ; j++) { 18526 // Extract the inputs. 18527 ArgumentsUcharLong args = new ArgumentsUcharLong(); 18528 args.inV = arrayInV[i * 2 + j]; 18529 // Figure out what the outputs should have been. 18530 CoreMathVerifier.computeConvert(args); 18531 // Validate the outputs. 18532 boolean valid = true; 18533 if (args.out != arrayOut[i * 2 + j]) { 18534 valid = false; 18535 } 18536 if (!valid) { 18537 if (!errorFound) { 18538 errorFound = true; 18539 message.append("Input inV: "); 18540 appendVariableToMessage(message, args.inV); 18541 message.append("\n"); 18542 message.append("Expected output out: "); 18543 appendVariableToMessage(message, args.out); 18544 message.append("\n"); 18545 message.append("Actual output out: "); 18546 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18547 if (args.out != arrayOut[i * 2 + j]) { 18548 message.append(" FAIL"); 18549 } 18550 message.append("\n"); 18551 message.append("Errors at"); 18552 } 18553 message.append(" ["); 18554 message.append(Integer.toString(i)); 18555 message.append(", "); 18556 message.append(Integer.toString(j)); 18557 message.append("]"); 18558 } 18559 } 18560 } 18561 assertFalse("Incorrect output for checkConvertUchar2Long2" + 18562 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18563 } 18564 checkConvertUchar3Long3()18565 private void checkConvertUchar3Long3() { 18566 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x1a95b395l, false, 8); 18567 try { 18568 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18569 script.forEach_testConvertLong3Uchar3Long3(inV, out); 18570 verifyResultsConvertUchar3Long3(inV, out, false); 18571 } catch (Exception e) { 18572 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString()); 18573 } 18574 try { 18575 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18576 scriptRelaxed.forEach_testConvertLong3Uchar3Long3(inV, out); 18577 verifyResultsConvertUchar3Long3(inV, out, true); 18578 } catch (Exception e) { 18579 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString()); 18580 } 18581 } 18582 verifyResultsConvertUchar3Long3(Allocation inV, Allocation out, boolean relaxed)18583 private void verifyResultsConvertUchar3Long3(Allocation inV, Allocation out, boolean relaxed) { 18584 byte[] arrayInV = new byte[INPUTSIZE * 4]; 18585 Arrays.fill(arrayInV, (byte) 42); 18586 inV.copyTo(arrayInV); 18587 long[] arrayOut = new long[INPUTSIZE * 4]; 18588 Arrays.fill(arrayOut, (long) 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 < 3 ; j++) { 18594 // Extract the inputs. 18595 ArgumentsUcharLong args = new ArgumentsUcharLong(); 18596 args.inV = arrayInV[i * 4 + j]; 18597 // Figure out what the outputs should have been. 18598 CoreMathVerifier.computeConvert(args); 18599 // Validate the outputs. 18600 boolean valid = true; 18601 if (args.out != arrayOut[i * 4 + j]) { 18602 valid = false; 18603 } 18604 if (!valid) { 18605 if (!errorFound) { 18606 errorFound = true; 18607 message.append("Input inV: "); 18608 appendVariableToMessage(message, args.inV); 18609 message.append("\n"); 18610 message.append("Expected output out: "); 18611 appendVariableToMessage(message, args.out); 18612 message.append("\n"); 18613 message.append("Actual output out: "); 18614 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18615 if (args.out != arrayOut[i * 4 + j]) { 18616 message.append(" FAIL"); 18617 } 18618 message.append("\n"); 18619 message.append("Errors at"); 18620 } 18621 message.append(" ["); 18622 message.append(Integer.toString(i)); 18623 message.append(", "); 18624 message.append(Integer.toString(j)); 18625 message.append("]"); 18626 } 18627 } 18628 } 18629 assertFalse("Incorrect output for checkConvertUchar3Long3" + 18630 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18631 } 18632 checkConvertUchar4Long4()18633 private void checkConvertUchar4Long4() { 18634 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x799d7889l, false, 8); 18635 try { 18636 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18637 script.forEach_testConvertLong4Uchar4Long4(inV, out); 18638 verifyResultsConvertUchar4Long4(inV, out, false); 18639 } catch (Exception e) { 18640 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString()); 18641 } 18642 try { 18643 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18644 scriptRelaxed.forEach_testConvertLong4Uchar4Long4(inV, out); 18645 verifyResultsConvertUchar4Long4(inV, out, true); 18646 } catch (Exception e) { 18647 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString()); 18648 } 18649 } 18650 verifyResultsConvertUchar4Long4(Allocation inV, Allocation out, boolean relaxed)18651 private void verifyResultsConvertUchar4Long4(Allocation inV, Allocation out, boolean relaxed) { 18652 byte[] arrayInV = new byte[INPUTSIZE * 4]; 18653 Arrays.fill(arrayInV, (byte) 42); 18654 inV.copyTo(arrayInV); 18655 long[] arrayOut = new long[INPUTSIZE * 4]; 18656 Arrays.fill(arrayOut, (long) 42); 18657 out.copyTo(arrayOut); 18658 StringBuilder message = new StringBuilder(); 18659 boolean errorFound = false; 18660 for (int i = 0; i < INPUTSIZE; i++) { 18661 for (int j = 0; j < 4 ; j++) { 18662 // Extract the inputs. 18663 ArgumentsUcharLong args = new ArgumentsUcharLong(); 18664 args.inV = arrayInV[i * 4 + j]; 18665 // Figure out what the outputs should have been. 18666 CoreMathVerifier.computeConvert(args); 18667 // Validate the outputs. 18668 boolean valid = true; 18669 if (args.out != arrayOut[i * 4 + j]) { 18670 valid = false; 18671 } 18672 if (!valid) { 18673 if (!errorFound) { 18674 errorFound = true; 18675 message.append("Input inV: "); 18676 appendVariableToMessage(message, args.inV); 18677 message.append("\n"); 18678 message.append("Expected output out: "); 18679 appendVariableToMessage(message, args.out); 18680 message.append("\n"); 18681 message.append("Actual output out: "); 18682 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18683 if (args.out != arrayOut[i * 4 + j]) { 18684 message.append(" FAIL"); 18685 } 18686 message.append("\n"); 18687 message.append("Errors at"); 18688 } 18689 message.append(" ["); 18690 message.append(Integer.toString(i)); 18691 message.append(", "); 18692 message.append(Integer.toString(j)); 18693 message.append("]"); 18694 } 18695 } 18696 } 18697 assertFalse("Incorrect output for checkConvertUchar4Long4" + 18698 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18699 } 18700 18701 public class ArgumentsShortLong { 18702 public short inV; 18703 public long out; 18704 } 18705 checkConvertShort2Long2()18706 private void checkConvertShort2Long2() { 18707 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69c97ce4l, true, 15); 18708 try { 18709 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18710 script.forEach_testConvertLong2Short2Long2(inV, out); 18711 verifyResultsConvertShort2Long2(inV, out, false); 18712 } catch (Exception e) { 18713 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString()); 18714 } 18715 try { 18716 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18717 scriptRelaxed.forEach_testConvertLong2Short2Long2(inV, out); 18718 verifyResultsConvertShort2Long2(inV, out, true); 18719 } catch (Exception e) { 18720 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString()); 18721 } 18722 } 18723 verifyResultsConvertShort2Long2(Allocation inV, Allocation out, boolean relaxed)18724 private void verifyResultsConvertShort2Long2(Allocation inV, Allocation out, boolean relaxed) { 18725 short[] arrayInV = new short[INPUTSIZE * 2]; 18726 Arrays.fill(arrayInV, (short) 42); 18727 inV.copyTo(arrayInV); 18728 long[] arrayOut = new long[INPUTSIZE * 2]; 18729 Arrays.fill(arrayOut, (long) 42); 18730 out.copyTo(arrayOut); 18731 StringBuilder message = new StringBuilder(); 18732 boolean errorFound = false; 18733 for (int i = 0; i < INPUTSIZE; i++) { 18734 for (int j = 0; j < 2 ; j++) { 18735 // Extract the inputs. 18736 ArgumentsShortLong args = new ArgumentsShortLong(); 18737 args.inV = arrayInV[i * 2 + j]; 18738 // Figure out what the outputs should have been. 18739 CoreMathVerifier.computeConvert(args); 18740 // Validate the outputs. 18741 boolean valid = true; 18742 if (args.out != arrayOut[i * 2 + j]) { 18743 valid = false; 18744 } 18745 if (!valid) { 18746 if (!errorFound) { 18747 errorFound = true; 18748 message.append("Input inV: "); 18749 appendVariableToMessage(message, args.inV); 18750 message.append("\n"); 18751 message.append("Expected output out: "); 18752 appendVariableToMessage(message, args.out); 18753 message.append("\n"); 18754 message.append("Actual output out: "); 18755 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18756 if (args.out != arrayOut[i * 2 + j]) { 18757 message.append(" FAIL"); 18758 } 18759 message.append("\n"); 18760 message.append("Errors at"); 18761 } 18762 message.append(" ["); 18763 message.append(Integer.toString(i)); 18764 message.append(", "); 18765 message.append(Integer.toString(j)); 18766 message.append("]"); 18767 } 18768 } 18769 } 18770 assertFalse("Incorrect output for checkConvertShort2Long2" + 18771 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18772 } 18773 checkConvertShort3Long3()18774 private void checkConvertShort3Long3() { 18775 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xc8d141d8l, true, 15); 18776 try { 18777 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18778 script.forEach_testConvertLong3Short3Long3(inV, out); 18779 verifyResultsConvertShort3Long3(inV, out, false); 18780 } catch (Exception e) { 18781 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString()); 18782 } 18783 try { 18784 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18785 scriptRelaxed.forEach_testConvertLong3Short3Long3(inV, out); 18786 verifyResultsConvertShort3Long3(inV, out, true); 18787 } catch (Exception e) { 18788 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString()); 18789 } 18790 } 18791 verifyResultsConvertShort3Long3(Allocation inV, Allocation out, boolean relaxed)18792 private void verifyResultsConvertShort3Long3(Allocation inV, Allocation out, boolean relaxed) { 18793 short[] arrayInV = new short[INPUTSIZE * 4]; 18794 Arrays.fill(arrayInV, (short) 42); 18795 inV.copyTo(arrayInV); 18796 long[] arrayOut = new long[INPUTSIZE * 4]; 18797 Arrays.fill(arrayOut, (long) 42); 18798 out.copyTo(arrayOut); 18799 StringBuilder message = new StringBuilder(); 18800 boolean errorFound = false; 18801 for (int i = 0; i < INPUTSIZE; i++) { 18802 for (int j = 0; j < 3 ; j++) { 18803 // Extract the inputs. 18804 ArgumentsShortLong args = new ArgumentsShortLong(); 18805 args.inV = arrayInV[i * 4 + j]; 18806 // Figure out what the outputs should have been. 18807 CoreMathVerifier.computeConvert(args); 18808 // Validate the outputs. 18809 boolean valid = true; 18810 if (args.out != arrayOut[i * 4 + j]) { 18811 valid = false; 18812 } 18813 if (!valid) { 18814 if (!errorFound) { 18815 errorFound = true; 18816 message.append("Input inV: "); 18817 appendVariableToMessage(message, args.inV); 18818 message.append("\n"); 18819 message.append("Expected output out: "); 18820 appendVariableToMessage(message, args.out); 18821 message.append("\n"); 18822 message.append("Actual output out: "); 18823 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18824 if (args.out != arrayOut[i * 4 + j]) { 18825 message.append(" FAIL"); 18826 } 18827 message.append("\n"); 18828 message.append("Errors at"); 18829 } 18830 message.append(" ["); 18831 message.append(Integer.toString(i)); 18832 message.append(", "); 18833 message.append(Integer.toString(j)); 18834 message.append("]"); 18835 } 18836 } 18837 } 18838 assertFalse("Incorrect output for checkConvertShort3Long3" + 18839 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18840 } 18841 checkConvertShort4Long4()18842 private void checkConvertShort4Long4() { 18843 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x27d906ccl, true, 15); 18844 try { 18845 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18846 script.forEach_testConvertLong4Short4Long4(inV, out); 18847 verifyResultsConvertShort4Long4(inV, out, false); 18848 } catch (Exception e) { 18849 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString()); 18850 } 18851 try { 18852 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 18853 scriptRelaxed.forEach_testConvertLong4Short4Long4(inV, out); 18854 verifyResultsConvertShort4Long4(inV, out, true); 18855 } catch (Exception e) { 18856 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString()); 18857 } 18858 } 18859 verifyResultsConvertShort4Long4(Allocation inV, Allocation out, boolean relaxed)18860 private void verifyResultsConvertShort4Long4(Allocation inV, Allocation out, boolean relaxed) { 18861 short[] arrayInV = new short[INPUTSIZE * 4]; 18862 Arrays.fill(arrayInV, (short) 42); 18863 inV.copyTo(arrayInV); 18864 long[] arrayOut = new long[INPUTSIZE * 4]; 18865 Arrays.fill(arrayOut, (long) 42); 18866 out.copyTo(arrayOut); 18867 StringBuilder message = new StringBuilder(); 18868 boolean errorFound = false; 18869 for (int i = 0; i < INPUTSIZE; i++) { 18870 for (int j = 0; j < 4 ; j++) { 18871 // Extract the inputs. 18872 ArgumentsShortLong args = new ArgumentsShortLong(); 18873 args.inV = arrayInV[i * 4 + j]; 18874 // Figure out what the outputs should have been. 18875 CoreMathVerifier.computeConvert(args); 18876 // Validate the outputs. 18877 boolean valid = true; 18878 if (args.out != arrayOut[i * 4 + j]) { 18879 valid = false; 18880 } 18881 if (!valid) { 18882 if (!errorFound) { 18883 errorFound = true; 18884 message.append("Input inV: "); 18885 appendVariableToMessage(message, args.inV); 18886 message.append("\n"); 18887 message.append("Expected output out: "); 18888 appendVariableToMessage(message, args.out); 18889 message.append("\n"); 18890 message.append("Actual output out: "); 18891 appendVariableToMessage(message, arrayOut[i * 4 + j]); 18892 if (args.out != arrayOut[i * 4 + j]) { 18893 message.append(" FAIL"); 18894 } 18895 message.append("\n"); 18896 message.append("Errors at"); 18897 } 18898 message.append(" ["); 18899 message.append(Integer.toString(i)); 18900 message.append(", "); 18901 message.append(Integer.toString(j)); 18902 message.append("]"); 18903 } 18904 } 18905 } 18906 assertFalse("Incorrect output for checkConvertShort4Long4" + 18907 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18908 } 18909 18910 public class ArgumentsUshortLong { 18911 public short inV; 18912 public long out; 18913 } 18914 checkConvertUshort2Long2()18915 private void checkConvertUshort2Long2() { 18916 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x5a1968fl, false, 16); 18917 try { 18918 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18919 script.forEach_testConvertLong2Ushort2Long2(inV, out); 18920 verifyResultsConvertUshort2Long2(inV, out, false); 18921 } catch (Exception e) { 18922 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString()); 18923 } 18924 try { 18925 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 18926 scriptRelaxed.forEach_testConvertLong2Ushort2Long2(inV, out); 18927 verifyResultsConvertUshort2Long2(inV, out, true); 18928 } catch (Exception e) { 18929 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString()); 18930 } 18931 } 18932 verifyResultsConvertUshort2Long2(Allocation inV, Allocation out, boolean relaxed)18933 private void verifyResultsConvertUshort2Long2(Allocation inV, Allocation out, boolean relaxed) { 18934 short[] arrayInV = new short[INPUTSIZE * 2]; 18935 Arrays.fill(arrayInV, (short) 42); 18936 inV.copyTo(arrayInV); 18937 long[] arrayOut = new long[INPUTSIZE * 2]; 18938 Arrays.fill(arrayOut, (long) 42); 18939 out.copyTo(arrayOut); 18940 StringBuilder message = new StringBuilder(); 18941 boolean errorFound = false; 18942 for (int i = 0; i < INPUTSIZE; i++) { 18943 for (int j = 0; j < 2 ; j++) { 18944 // Extract the inputs. 18945 ArgumentsUshortLong args = new ArgumentsUshortLong(); 18946 args.inV = arrayInV[i * 2 + j]; 18947 // Figure out what the outputs should have been. 18948 CoreMathVerifier.computeConvert(args); 18949 // Validate the outputs. 18950 boolean valid = true; 18951 if (args.out != arrayOut[i * 2 + j]) { 18952 valid = false; 18953 } 18954 if (!valid) { 18955 if (!errorFound) { 18956 errorFound = true; 18957 message.append("Input inV: "); 18958 appendVariableToMessage(message, args.inV); 18959 message.append("\n"); 18960 message.append("Expected output out: "); 18961 appendVariableToMessage(message, args.out); 18962 message.append("\n"); 18963 message.append("Actual output out: "); 18964 appendVariableToMessage(message, arrayOut[i * 2 + j]); 18965 if (args.out != arrayOut[i * 2 + j]) { 18966 message.append(" FAIL"); 18967 } 18968 message.append("\n"); 18969 message.append("Errors at"); 18970 } 18971 message.append(" ["); 18972 message.append(Integer.toString(i)); 18973 message.append(", "); 18974 message.append(Integer.toString(j)); 18975 message.append("]"); 18976 } 18977 } 18978 } 18979 assertFalse("Incorrect output for checkConvertUshort2Long2" + 18980 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 18981 } 18982 checkConvertUshort3Long3()18983 private void checkConvertUshort3Long3() { 18984 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x64a95b83l, false, 16); 18985 try { 18986 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18987 script.forEach_testConvertLong3Ushort3Long3(inV, out); 18988 verifyResultsConvertUshort3Long3(inV, out, false); 18989 } catch (Exception e) { 18990 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString()); 18991 } 18992 try { 18993 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 18994 scriptRelaxed.forEach_testConvertLong3Ushort3Long3(inV, out); 18995 verifyResultsConvertUshort3Long3(inV, out, true); 18996 } catch (Exception e) { 18997 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString()); 18998 } 18999 } 19000 verifyResultsConvertUshort3Long3(Allocation inV, Allocation out, boolean relaxed)19001 private void verifyResultsConvertUshort3Long3(Allocation inV, Allocation out, boolean relaxed) { 19002 short[] arrayInV = new short[INPUTSIZE * 4]; 19003 Arrays.fill(arrayInV, (short) 42); 19004 inV.copyTo(arrayInV); 19005 long[] arrayOut = new long[INPUTSIZE * 4]; 19006 Arrays.fill(arrayOut, (long) 42); 19007 out.copyTo(arrayOut); 19008 StringBuilder message = new StringBuilder(); 19009 boolean errorFound = false; 19010 for (int i = 0; i < INPUTSIZE; i++) { 19011 for (int j = 0; j < 3 ; j++) { 19012 // Extract the inputs. 19013 ArgumentsUshortLong args = new ArgumentsUshortLong(); 19014 args.inV = arrayInV[i * 4 + j]; 19015 // Figure out what the outputs should have been. 19016 CoreMathVerifier.computeConvert(args); 19017 // Validate the outputs. 19018 boolean valid = true; 19019 if (args.out != arrayOut[i * 4 + j]) { 19020 valid = false; 19021 } 19022 if (!valid) { 19023 if (!errorFound) { 19024 errorFound = true; 19025 message.append("Input inV: "); 19026 appendVariableToMessage(message, args.inV); 19027 message.append("\n"); 19028 message.append("Expected output out: "); 19029 appendVariableToMessage(message, args.out); 19030 message.append("\n"); 19031 message.append("Actual output out: "); 19032 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19033 if (args.out != arrayOut[i * 4 + j]) { 19034 message.append(" FAIL"); 19035 } 19036 message.append("\n"); 19037 message.append("Errors at"); 19038 } 19039 message.append(" ["); 19040 message.append(Integer.toString(i)); 19041 message.append(", "); 19042 message.append(Integer.toString(j)); 19043 message.append("]"); 19044 } 19045 } 19046 } 19047 assertFalse("Incorrect output for checkConvertUshort3Long3" + 19048 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19049 } 19050 checkConvertUshort4Long4()19051 private void checkConvertUshort4Long4() { 19052 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc3b12077l, false, 16); 19053 try { 19054 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19055 script.forEach_testConvertLong4Ushort4Long4(inV, out); 19056 verifyResultsConvertUshort4Long4(inV, out, false); 19057 } catch (Exception e) { 19058 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString()); 19059 } 19060 try { 19061 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19062 scriptRelaxed.forEach_testConvertLong4Ushort4Long4(inV, out); 19063 verifyResultsConvertUshort4Long4(inV, out, true); 19064 } catch (Exception e) { 19065 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString()); 19066 } 19067 } 19068 verifyResultsConvertUshort4Long4(Allocation inV, Allocation out, boolean relaxed)19069 private void verifyResultsConvertUshort4Long4(Allocation inV, Allocation out, boolean relaxed) { 19070 short[] arrayInV = new short[INPUTSIZE * 4]; 19071 Arrays.fill(arrayInV, (short) 42); 19072 inV.copyTo(arrayInV); 19073 long[] arrayOut = new long[INPUTSIZE * 4]; 19074 Arrays.fill(arrayOut, (long) 42); 19075 out.copyTo(arrayOut); 19076 StringBuilder message = new StringBuilder(); 19077 boolean errorFound = false; 19078 for (int i = 0; i < INPUTSIZE; i++) { 19079 for (int j = 0; j < 4 ; j++) { 19080 // Extract the inputs. 19081 ArgumentsUshortLong args = new ArgumentsUshortLong(); 19082 args.inV = arrayInV[i * 4 + j]; 19083 // Figure out what the outputs should have been. 19084 CoreMathVerifier.computeConvert(args); 19085 // Validate the outputs. 19086 boolean valid = true; 19087 if (args.out != arrayOut[i * 4 + j]) { 19088 valid = false; 19089 } 19090 if (!valid) { 19091 if (!errorFound) { 19092 errorFound = true; 19093 message.append("Input inV: "); 19094 appendVariableToMessage(message, args.inV); 19095 message.append("\n"); 19096 message.append("Expected output out: "); 19097 appendVariableToMessage(message, args.out); 19098 message.append("\n"); 19099 message.append("Actual output out: "); 19100 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19101 if (args.out != arrayOut[i * 4 + j]) { 19102 message.append(" FAIL"); 19103 } 19104 message.append("\n"); 19105 message.append("Errors at"); 19106 } 19107 message.append(" ["); 19108 message.append(Integer.toString(i)); 19109 message.append(", "); 19110 message.append(Integer.toString(j)); 19111 message.append("]"); 19112 } 19113 } 19114 } 19115 assertFalse("Incorrect output for checkConvertUshort4Long4" + 19116 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19117 } 19118 19119 public class ArgumentsIntLong { 19120 public int inV; 19121 public long out; 19122 } 19123 checkConvertInt2Long2()19124 private void checkConvertInt2Long2() { 19125 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x8a45cb5dl, true, 31); 19126 try { 19127 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19128 script.forEach_testConvertLong2Int2Long2(inV, out); 19129 verifyResultsConvertInt2Long2(inV, out, false); 19130 } catch (Exception e) { 19131 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString()); 19132 } 19133 try { 19134 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19135 scriptRelaxed.forEach_testConvertLong2Int2Long2(inV, out); 19136 verifyResultsConvertInt2Long2(inV, out, true); 19137 } catch (Exception e) { 19138 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString()); 19139 } 19140 } 19141 verifyResultsConvertInt2Long2(Allocation inV, Allocation out, boolean relaxed)19142 private void verifyResultsConvertInt2Long2(Allocation inV, Allocation out, boolean relaxed) { 19143 int[] arrayInV = new int[INPUTSIZE * 2]; 19144 Arrays.fill(arrayInV, (int) 42); 19145 inV.copyTo(arrayInV); 19146 long[] arrayOut = new long[INPUTSIZE * 2]; 19147 Arrays.fill(arrayOut, (long) 42); 19148 out.copyTo(arrayOut); 19149 StringBuilder message = new StringBuilder(); 19150 boolean errorFound = false; 19151 for (int i = 0; i < INPUTSIZE; i++) { 19152 for (int j = 0; j < 2 ; j++) { 19153 // Extract the inputs. 19154 ArgumentsIntLong args = new ArgumentsIntLong(); 19155 args.inV = arrayInV[i * 2 + j]; 19156 // Figure out what the outputs should have been. 19157 CoreMathVerifier.computeConvert(args); 19158 // Validate the outputs. 19159 boolean valid = true; 19160 if (args.out != arrayOut[i * 2 + j]) { 19161 valid = false; 19162 } 19163 if (!valid) { 19164 if (!errorFound) { 19165 errorFound = true; 19166 message.append("Input inV: "); 19167 appendVariableToMessage(message, args.inV); 19168 message.append("\n"); 19169 message.append("Expected output out: "); 19170 appendVariableToMessage(message, args.out); 19171 message.append("\n"); 19172 message.append("Actual output out: "); 19173 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19174 if (args.out != arrayOut[i * 2 + j]) { 19175 message.append(" FAIL"); 19176 } 19177 message.append("\n"); 19178 message.append("Errors at"); 19179 } 19180 message.append(" ["); 19181 message.append(Integer.toString(i)); 19182 message.append(", "); 19183 message.append(Integer.toString(j)); 19184 message.append("]"); 19185 } 19186 } 19187 } 19188 assertFalse("Incorrect output for checkConvertInt2Long2" + 19189 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19190 } 19191 checkConvertInt3Long3()19192 private void checkConvertInt3Long3() { 19193 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xe94d9051l, true, 31); 19194 try { 19195 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19196 script.forEach_testConvertLong3Int3Long3(inV, out); 19197 verifyResultsConvertInt3Long3(inV, out, false); 19198 } catch (Exception e) { 19199 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString()); 19200 } 19201 try { 19202 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19203 scriptRelaxed.forEach_testConvertLong3Int3Long3(inV, out); 19204 verifyResultsConvertInt3Long3(inV, out, true); 19205 } catch (Exception e) { 19206 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString()); 19207 } 19208 } 19209 verifyResultsConvertInt3Long3(Allocation inV, Allocation out, boolean relaxed)19210 private void verifyResultsConvertInt3Long3(Allocation inV, Allocation out, boolean relaxed) { 19211 int[] arrayInV = new int[INPUTSIZE * 4]; 19212 Arrays.fill(arrayInV, (int) 42); 19213 inV.copyTo(arrayInV); 19214 long[] arrayOut = new long[INPUTSIZE * 4]; 19215 Arrays.fill(arrayOut, (long) 42); 19216 out.copyTo(arrayOut); 19217 StringBuilder message = new StringBuilder(); 19218 boolean errorFound = false; 19219 for (int i = 0; i < INPUTSIZE; i++) { 19220 for (int j = 0; j < 3 ; j++) { 19221 // Extract the inputs. 19222 ArgumentsIntLong args = new ArgumentsIntLong(); 19223 args.inV = arrayInV[i * 4 + j]; 19224 // Figure out what the outputs should have been. 19225 CoreMathVerifier.computeConvert(args); 19226 // Validate the outputs. 19227 boolean valid = true; 19228 if (args.out != arrayOut[i * 4 + j]) { 19229 valid = false; 19230 } 19231 if (!valid) { 19232 if (!errorFound) { 19233 errorFound = true; 19234 message.append("Input inV: "); 19235 appendVariableToMessage(message, args.inV); 19236 message.append("\n"); 19237 message.append("Expected output out: "); 19238 appendVariableToMessage(message, args.out); 19239 message.append("\n"); 19240 message.append("Actual output out: "); 19241 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19242 if (args.out != arrayOut[i * 4 + j]) { 19243 message.append(" FAIL"); 19244 } 19245 message.append("\n"); 19246 message.append("Errors at"); 19247 } 19248 message.append(" ["); 19249 message.append(Integer.toString(i)); 19250 message.append(", "); 19251 message.append(Integer.toString(j)); 19252 message.append("]"); 19253 } 19254 } 19255 } 19256 assertFalse("Incorrect output for checkConvertInt3Long3" + 19257 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19258 } 19259 checkConvertInt4Long4()19260 private void checkConvertInt4Long4() { 19261 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x48555545l, true, 31); 19262 try { 19263 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19264 script.forEach_testConvertLong4Int4Long4(inV, out); 19265 verifyResultsConvertInt4Long4(inV, out, false); 19266 } catch (Exception e) { 19267 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString()); 19268 } 19269 try { 19270 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19271 scriptRelaxed.forEach_testConvertLong4Int4Long4(inV, out); 19272 verifyResultsConvertInt4Long4(inV, out, true); 19273 } catch (Exception e) { 19274 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString()); 19275 } 19276 } 19277 verifyResultsConvertInt4Long4(Allocation inV, Allocation out, boolean relaxed)19278 private void verifyResultsConvertInt4Long4(Allocation inV, Allocation out, boolean relaxed) { 19279 int[] arrayInV = new int[INPUTSIZE * 4]; 19280 Arrays.fill(arrayInV, (int) 42); 19281 inV.copyTo(arrayInV); 19282 long[] arrayOut = new long[INPUTSIZE * 4]; 19283 Arrays.fill(arrayOut, (long) 42); 19284 out.copyTo(arrayOut); 19285 StringBuilder message = new StringBuilder(); 19286 boolean errorFound = false; 19287 for (int i = 0; i < INPUTSIZE; i++) { 19288 for (int j = 0; j < 4 ; j++) { 19289 // Extract the inputs. 19290 ArgumentsIntLong args = new ArgumentsIntLong(); 19291 args.inV = arrayInV[i * 4 + j]; 19292 // Figure out what the outputs should have been. 19293 CoreMathVerifier.computeConvert(args); 19294 // Validate the outputs. 19295 boolean valid = true; 19296 if (args.out != arrayOut[i * 4 + j]) { 19297 valid = false; 19298 } 19299 if (!valid) { 19300 if (!errorFound) { 19301 errorFound = true; 19302 message.append("Input inV: "); 19303 appendVariableToMessage(message, args.inV); 19304 message.append("\n"); 19305 message.append("Expected output out: "); 19306 appendVariableToMessage(message, args.out); 19307 message.append("\n"); 19308 message.append("Actual output out: "); 19309 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19310 if (args.out != arrayOut[i * 4 + j]) { 19311 message.append(" FAIL"); 19312 } 19313 message.append("\n"); 19314 message.append("Errors at"); 19315 } 19316 message.append(" ["); 19317 message.append(Integer.toString(i)); 19318 message.append(", "); 19319 message.append(Integer.toString(j)); 19320 message.append("]"); 19321 } 19322 } 19323 } 19324 assertFalse("Incorrect output for checkConvertInt4Long4" + 19325 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19326 } 19327 19328 public class ArgumentsUintLong { 19329 public int inV; 19330 public long out; 19331 } 19332 checkConvertUint2Long2()19333 private void checkConvertUint2Long2() { 19334 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x87b9ef60l, false, 32); 19335 try { 19336 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19337 script.forEach_testConvertLong2Uint2Long2(inV, out); 19338 verifyResultsConvertUint2Long2(inV, out, false); 19339 } catch (Exception e) { 19340 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString()); 19341 } 19342 try { 19343 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 19344 scriptRelaxed.forEach_testConvertLong2Uint2Long2(inV, out); 19345 verifyResultsConvertUint2Long2(inV, out, true); 19346 } catch (Exception e) { 19347 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString()); 19348 } 19349 } 19350 verifyResultsConvertUint2Long2(Allocation inV, Allocation out, boolean relaxed)19351 private void verifyResultsConvertUint2Long2(Allocation inV, Allocation out, boolean relaxed) { 19352 int[] arrayInV = new int[INPUTSIZE * 2]; 19353 Arrays.fill(arrayInV, (int) 42); 19354 inV.copyTo(arrayInV); 19355 long[] arrayOut = new long[INPUTSIZE * 2]; 19356 Arrays.fill(arrayOut, (long) 42); 19357 out.copyTo(arrayOut); 19358 StringBuilder message = new StringBuilder(); 19359 boolean errorFound = false; 19360 for (int i = 0; i < INPUTSIZE; i++) { 19361 for (int j = 0; j < 2 ; j++) { 19362 // Extract the inputs. 19363 ArgumentsUintLong args = new ArgumentsUintLong(); 19364 args.inV = arrayInV[i * 2 + j]; 19365 // Figure out what the outputs should have been. 19366 CoreMathVerifier.computeConvert(args); 19367 // Validate the outputs. 19368 boolean valid = true; 19369 if (args.out != arrayOut[i * 2 + j]) { 19370 valid = false; 19371 } 19372 if (!valid) { 19373 if (!errorFound) { 19374 errorFound = true; 19375 message.append("Input inV: "); 19376 appendVariableToMessage(message, args.inV); 19377 message.append("\n"); 19378 message.append("Expected output out: "); 19379 appendVariableToMessage(message, args.out); 19380 message.append("\n"); 19381 message.append("Actual output out: "); 19382 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19383 if (args.out != arrayOut[i * 2 + j]) { 19384 message.append(" FAIL"); 19385 } 19386 message.append("\n"); 19387 message.append("Errors at"); 19388 } 19389 message.append(" ["); 19390 message.append(Integer.toString(i)); 19391 message.append(", "); 19392 message.append(Integer.toString(j)); 19393 message.append("]"); 19394 } 19395 } 19396 } 19397 assertFalse("Incorrect output for checkConvertUint2Long2" + 19398 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19399 } 19400 checkConvertUint3Long3()19401 private void checkConvertUint3Long3() { 19402 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe6c1b454l, false, 32); 19403 try { 19404 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19405 script.forEach_testConvertLong3Uint3Long3(inV, out); 19406 verifyResultsConvertUint3Long3(inV, out, false); 19407 } catch (Exception e) { 19408 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString()); 19409 } 19410 try { 19411 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 19412 scriptRelaxed.forEach_testConvertLong3Uint3Long3(inV, out); 19413 verifyResultsConvertUint3Long3(inV, out, true); 19414 } catch (Exception e) { 19415 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString()); 19416 } 19417 } 19418 verifyResultsConvertUint3Long3(Allocation inV, Allocation out, boolean relaxed)19419 private void verifyResultsConvertUint3Long3(Allocation inV, Allocation out, boolean relaxed) { 19420 int[] arrayInV = new int[INPUTSIZE * 4]; 19421 Arrays.fill(arrayInV, (int) 42); 19422 inV.copyTo(arrayInV); 19423 long[] arrayOut = new long[INPUTSIZE * 4]; 19424 Arrays.fill(arrayOut, (long) 42); 19425 out.copyTo(arrayOut); 19426 StringBuilder message = new StringBuilder(); 19427 boolean errorFound = false; 19428 for (int i = 0; i < INPUTSIZE; i++) { 19429 for (int j = 0; j < 3 ; j++) { 19430 // Extract the inputs. 19431 ArgumentsUintLong args = new ArgumentsUintLong(); 19432 args.inV = arrayInV[i * 4 + j]; 19433 // Figure out what the outputs should have been. 19434 CoreMathVerifier.computeConvert(args); 19435 // Validate the outputs. 19436 boolean valid = true; 19437 if (args.out != arrayOut[i * 4 + j]) { 19438 valid = false; 19439 } 19440 if (!valid) { 19441 if (!errorFound) { 19442 errorFound = true; 19443 message.append("Input inV: "); 19444 appendVariableToMessage(message, args.inV); 19445 message.append("\n"); 19446 message.append("Expected output out: "); 19447 appendVariableToMessage(message, args.out); 19448 message.append("\n"); 19449 message.append("Actual output out: "); 19450 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19451 if (args.out != arrayOut[i * 4 + j]) { 19452 message.append(" FAIL"); 19453 } 19454 message.append("\n"); 19455 message.append("Errors at"); 19456 } 19457 message.append(" ["); 19458 message.append(Integer.toString(i)); 19459 message.append(", "); 19460 message.append(Integer.toString(j)); 19461 message.append("]"); 19462 } 19463 } 19464 } 19465 assertFalse("Incorrect output for checkConvertUint3Long3" + 19466 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19467 } 19468 checkConvertUint4Long4()19469 private void checkConvertUint4Long4() { 19470 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x45c97948l, false, 32); 19471 try { 19472 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19473 script.forEach_testConvertLong4Uint4Long4(inV, out); 19474 verifyResultsConvertUint4Long4(inV, out, false); 19475 } catch (Exception e) { 19476 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString()); 19477 } 19478 try { 19479 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 19480 scriptRelaxed.forEach_testConvertLong4Uint4Long4(inV, out); 19481 verifyResultsConvertUint4Long4(inV, out, true); 19482 } catch (Exception e) { 19483 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString()); 19484 } 19485 } 19486 verifyResultsConvertUint4Long4(Allocation inV, Allocation out, boolean relaxed)19487 private void verifyResultsConvertUint4Long4(Allocation inV, Allocation out, boolean relaxed) { 19488 int[] arrayInV = new int[INPUTSIZE * 4]; 19489 Arrays.fill(arrayInV, (int) 42); 19490 inV.copyTo(arrayInV); 19491 long[] arrayOut = new long[INPUTSIZE * 4]; 19492 Arrays.fill(arrayOut, (long) 42); 19493 out.copyTo(arrayOut); 19494 StringBuilder message = new StringBuilder(); 19495 boolean errorFound = false; 19496 for (int i = 0; i < INPUTSIZE; i++) { 19497 for (int j = 0; j < 4 ; j++) { 19498 // Extract the inputs. 19499 ArgumentsUintLong args = new ArgumentsUintLong(); 19500 args.inV = arrayInV[i * 4 + j]; 19501 // Figure out what the outputs should have been. 19502 CoreMathVerifier.computeConvert(args); 19503 // Validate the outputs. 19504 boolean valid = true; 19505 if (args.out != arrayOut[i * 4 + j]) { 19506 valid = false; 19507 } 19508 if (!valid) { 19509 if (!errorFound) { 19510 errorFound = true; 19511 message.append("Input inV: "); 19512 appendVariableToMessage(message, args.inV); 19513 message.append("\n"); 19514 message.append("Expected output out: "); 19515 appendVariableToMessage(message, args.out); 19516 message.append("\n"); 19517 message.append("Actual output out: "); 19518 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19519 if (args.out != arrayOut[i * 4 + j]) { 19520 message.append(" FAIL"); 19521 } 19522 message.append("\n"); 19523 message.append("Errors at"); 19524 } 19525 message.append(" ["); 19526 message.append(Integer.toString(i)); 19527 message.append(", "); 19528 message.append(Integer.toString(j)); 19529 message.append("]"); 19530 } 19531 } 19532 } 19533 assertFalse("Incorrect output for checkConvertUint4Long4" + 19534 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19535 } 19536 19537 public class ArgumentsFloatUlong { 19538 public float inV; 19539 public long out; 19540 } 19541 checkConvertFloat2Ulong2()19542 private void checkConvertFloat2Ulong2() { 19543 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4ec4cff7l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); 19544 try { 19545 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 19546 script.forEach_testConvertUlong2Float2Ulong2(inV, out); 19547 verifyResultsConvertFloat2Ulong2(inV, out, false); 19548 } catch (Exception e) { 19549 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString()); 19550 } 19551 try { 19552 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 19553 scriptRelaxed.forEach_testConvertUlong2Float2Ulong2(inV, out); 19554 verifyResultsConvertFloat2Ulong2(inV, out, true); 19555 } catch (Exception e) { 19556 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString()); 19557 } 19558 } 19559 verifyResultsConvertFloat2Ulong2(Allocation inV, Allocation out, boolean relaxed)19560 private void verifyResultsConvertFloat2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 19561 float[] arrayInV = new float[INPUTSIZE * 2]; 19562 Arrays.fill(arrayInV, (float) 42); 19563 inV.copyTo(arrayInV); 19564 long[] arrayOut = new long[INPUTSIZE * 2]; 19565 Arrays.fill(arrayOut, (long) 42); 19566 out.copyTo(arrayOut); 19567 StringBuilder message = new StringBuilder(); 19568 boolean errorFound = false; 19569 for (int i = 0; i < INPUTSIZE; i++) { 19570 for (int j = 0; j < 2 ; j++) { 19571 // Extract the inputs. 19572 ArgumentsFloatUlong args = new ArgumentsFloatUlong(); 19573 args.inV = arrayInV[i * 2 + j]; 19574 // Figure out what the outputs should have been. 19575 CoreMathVerifier.computeConvert(args); 19576 // Validate the outputs. 19577 boolean valid = true; 19578 if (args.out != arrayOut[i * 2 + j]) { 19579 valid = false; 19580 } 19581 if (!valid) { 19582 if (!errorFound) { 19583 errorFound = true; 19584 message.append("Input inV: "); 19585 appendVariableToMessage(message, args.inV); 19586 message.append("\n"); 19587 message.append("Expected output out: "); 19588 appendVariableToMessage(message, args.out); 19589 message.append("\n"); 19590 message.append("Actual output out: "); 19591 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19592 if (args.out != arrayOut[i * 2 + j]) { 19593 message.append(" FAIL"); 19594 } 19595 message.append("\n"); 19596 message.append("Errors at"); 19597 } 19598 message.append(" ["); 19599 message.append(Integer.toString(i)); 19600 message.append(", "); 19601 message.append(Integer.toString(j)); 19602 message.append("]"); 19603 } 19604 } 19605 } 19606 assertFalse("Incorrect output for checkConvertFloat2Ulong2" + 19607 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19608 } 19609 checkConvertFloat3Ulong3()19610 private void checkConvertFloat3Ulong3() { 19611 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x44dff0d5l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); 19612 try { 19613 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 19614 script.forEach_testConvertUlong3Float3Ulong3(inV, out); 19615 verifyResultsConvertFloat3Ulong3(inV, out, false); 19616 } catch (Exception e) { 19617 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString()); 19618 } 19619 try { 19620 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 19621 scriptRelaxed.forEach_testConvertUlong3Float3Ulong3(inV, out); 19622 verifyResultsConvertFloat3Ulong3(inV, out, true); 19623 } catch (Exception e) { 19624 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString()); 19625 } 19626 } 19627 verifyResultsConvertFloat3Ulong3(Allocation inV, Allocation out, boolean relaxed)19628 private void verifyResultsConvertFloat3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 19629 float[] arrayInV = new float[INPUTSIZE * 4]; 19630 Arrays.fill(arrayInV, (float) 42); 19631 inV.copyTo(arrayInV); 19632 long[] arrayOut = new long[INPUTSIZE * 4]; 19633 Arrays.fill(arrayOut, (long) 42); 19634 out.copyTo(arrayOut); 19635 StringBuilder message = new StringBuilder(); 19636 boolean errorFound = false; 19637 for (int i = 0; i < INPUTSIZE; i++) { 19638 for (int j = 0; j < 3 ; j++) { 19639 // Extract the inputs. 19640 ArgumentsFloatUlong args = new ArgumentsFloatUlong(); 19641 args.inV = arrayInV[i * 4 + j]; 19642 // Figure out what the outputs should have been. 19643 CoreMathVerifier.computeConvert(args); 19644 // Validate the outputs. 19645 boolean valid = true; 19646 if (args.out != arrayOut[i * 4 + j]) { 19647 valid = false; 19648 } 19649 if (!valid) { 19650 if (!errorFound) { 19651 errorFound = true; 19652 message.append("Input inV: "); 19653 appendVariableToMessage(message, args.inV); 19654 message.append("\n"); 19655 message.append("Expected output out: "); 19656 appendVariableToMessage(message, args.out); 19657 message.append("\n"); 19658 message.append("Actual output out: "); 19659 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19660 if (args.out != arrayOut[i * 4 + j]) { 19661 message.append(" FAIL"); 19662 } 19663 message.append("\n"); 19664 message.append("Errors at"); 19665 } 19666 message.append(" ["); 19667 message.append(Integer.toString(i)); 19668 message.append(", "); 19669 message.append(Integer.toString(j)); 19670 message.append("]"); 19671 } 19672 } 19673 } 19674 assertFalse("Incorrect output for checkConvertFloat3Ulong3" + 19675 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19676 } 19677 checkConvertFloat4Ulong4()19678 private void checkConvertFloat4Ulong4() { 19679 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3afb11b3l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); 19680 try { 19681 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 19682 script.forEach_testConvertUlong4Float4Ulong4(inV, out); 19683 verifyResultsConvertFloat4Ulong4(inV, out, false); 19684 } catch (Exception e) { 19685 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString()); 19686 } 19687 try { 19688 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 19689 scriptRelaxed.forEach_testConvertUlong4Float4Ulong4(inV, out); 19690 verifyResultsConvertFloat4Ulong4(inV, out, true); 19691 } catch (Exception e) { 19692 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString()); 19693 } 19694 } 19695 verifyResultsConvertFloat4Ulong4(Allocation inV, Allocation out, boolean relaxed)19696 private void verifyResultsConvertFloat4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 19697 float[] arrayInV = new float[INPUTSIZE * 4]; 19698 Arrays.fill(arrayInV, (float) 42); 19699 inV.copyTo(arrayInV); 19700 long[] arrayOut = new long[INPUTSIZE * 4]; 19701 Arrays.fill(arrayOut, (long) 42); 19702 out.copyTo(arrayOut); 19703 StringBuilder message = new StringBuilder(); 19704 boolean errorFound = false; 19705 for (int i = 0; i < INPUTSIZE; i++) { 19706 for (int j = 0; j < 4 ; j++) { 19707 // Extract the inputs. 19708 ArgumentsFloatUlong args = new ArgumentsFloatUlong(); 19709 args.inV = arrayInV[i * 4 + j]; 19710 // Figure out what the outputs should have been. 19711 CoreMathVerifier.computeConvert(args); 19712 // Validate the outputs. 19713 boolean valid = true; 19714 if (args.out != arrayOut[i * 4 + j]) { 19715 valid = false; 19716 } 19717 if (!valid) { 19718 if (!errorFound) { 19719 errorFound = true; 19720 message.append("Input inV: "); 19721 appendVariableToMessage(message, args.inV); 19722 message.append("\n"); 19723 message.append("Expected output out: "); 19724 appendVariableToMessage(message, args.out); 19725 message.append("\n"); 19726 message.append("Actual output out: "); 19727 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19728 if (args.out != arrayOut[i * 4 + j]) { 19729 message.append(" FAIL"); 19730 } 19731 message.append("\n"); 19732 message.append("Errors at"); 19733 } 19734 message.append(" ["); 19735 message.append(Integer.toString(i)); 19736 message.append(", "); 19737 message.append(Integer.toString(j)); 19738 message.append("]"); 19739 } 19740 } 19741 } 19742 assertFalse("Incorrect output for checkConvertFloat4Ulong4" + 19743 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19744 } 19745 19746 public class ArgumentsCharUlong { 19747 public byte inV; 19748 public long out; 19749 } 19750 checkConvertChar2Ulong2()19751 private void checkConvertChar2Ulong2() { 19752 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x1fedf7b7l, false, 7); 19753 try { 19754 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 19755 script.forEach_testConvertUlong2Char2Ulong2(inV, out); 19756 verifyResultsConvertChar2Ulong2(inV, out, false); 19757 } catch (Exception e) { 19758 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString()); 19759 } 19760 try { 19761 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 19762 scriptRelaxed.forEach_testConvertUlong2Char2Ulong2(inV, out); 19763 verifyResultsConvertChar2Ulong2(inV, out, true); 19764 } catch (Exception e) { 19765 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString()); 19766 } 19767 } 19768 verifyResultsConvertChar2Ulong2(Allocation inV, Allocation out, boolean relaxed)19769 private void verifyResultsConvertChar2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 19770 byte[] arrayInV = new byte[INPUTSIZE * 2]; 19771 Arrays.fill(arrayInV, (byte) 42); 19772 inV.copyTo(arrayInV); 19773 long[] arrayOut = new long[INPUTSIZE * 2]; 19774 Arrays.fill(arrayOut, (long) 42); 19775 out.copyTo(arrayOut); 19776 StringBuilder message = new StringBuilder(); 19777 boolean errorFound = false; 19778 for (int i = 0; i < INPUTSIZE; i++) { 19779 for (int j = 0; j < 2 ; j++) { 19780 // Extract the inputs. 19781 ArgumentsCharUlong args = new ArgumentsCharUlong(); 19782 args.inV = arrayInV[i * 2 + j]; 19783 // Figure out what the outputs should have been. 19784 CoreMathVerifier.computeConvert(args); 19785 // Validate the outputs. 19786 boolean valid = true; 19787 if (args.out != arrayOut[i * 2 + j]) { 19788 valid = false; 19789 } 19790 if (!valid) { 19791 if (!errorFound) { 19792 errorFound = true; 19793 message.append("Input inV: "); 19794 appendVariableToMessage(message, args.inV); 19795 message.append("\n"); 19796 message.append("Expected output out: "); 19797 appendVariableToMessage(message, args.out); 19798 message.append("\n"); 19799 message.append("Actual output out: "); 19800 appendVariableToMessage(message, arrayOut[i * 2 + j]); 19801 if (args.out != arrayOut[i * 2 + j]) { 19802 message.append(" FAIL"); 19803 } 19804 message.append("\n"); 19805 message.append("Errors at"); 19806 } 19807 message.append(" ["); 19808 message.append(Integer.toString(i)); 19809 message.append(", "); 19810 message.append(Integer.toString(j)); 19811 message.append("]"); 19812 } 19813 } 19814 } 19815 assertFalse("Incorrect output for checkConvertChar2Ulong2" + 19816 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19817 } 19818 checkConvertChar3Ulong3()19819 private void checkConvertChar3Ulong3() { 19820 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x16091895l, false, 7); 19821 try { 19822 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 19823 script.forEach_testConvertUlong3Char3Ulong3(inV, out); 19824 verifyResultsConvertChar3Ulong3(inV, out, false); 19825 } catch (Exception e) { 19826 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString()); 19827 } 19828 try { 19829 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 19830 scriptRelaxed.forEach_testConvertUlong3Char3Ulong3(inV, out); 19831 verifyResultsConvertChar3Ulong3(inV, out, true); 19832 } catch (Exception e) { 19833 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString()); 19834 } 19835 } 19836 verifyResultsConvertChar3Ulong3(Allocation inV, Allocation out, boolean relaxed)19837 private void verifyResultsConvertChar3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 19838 byte[] arrayInV = new byte[INPUTSIZE * 4]; 19839 Arrays.fill(arrayInV, (byte) 42); 19840 inV.copyTo(arrayInV); 19841 long[] arrayOut = new long[INPUTSIZE * 4]; 19842 Arrays.fill(arrayOut, (long) 42); 19843 out.copyTo(arrayOut); 19844 StringBuilder message = new StringBuilder(); 19845 boolean errorFound = false; 19846 for (int i = 0; i < INPUTSIZE; i++) { 19847 for (int j = 0; j < 3 ; j++) { 19848 // Extract the inputs. 19849 ArgumentsCharUlong args = new ArgumentsCharUlong(); 19850 args.inV = arrayInV[i * 4 + j]; 19851 // Figure out what the outputs should have been. 19852 CoreMathVerifier.computeConvert(args); 19853 // Validate the outputs. 19854 boolean valid = true; 19855 if (args.out != arrayOut[i * 4 + j]) { 19856 valid = false; 19857 } 19858 if (!valid) { 19859 if (!errorFound) { 19860 errorFound = true; 19861 message.append("Input inV: "); 19862 appendVariableToMessage(message, args.inV); 19863 message.append("\n"); 19864 message.append("Expected output out: "); 19865 appendVariableToMessage(message, args.out); 19866 message.append("\n"); 19867 message.append("Actual output out: "); 19868 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19869 if (args.out != arrayOut[i * 4 + j]) { 19870 message.append(" FAIL"); 19871 } 19872 message.append("\n"); 19873 message.append("Errors at"); 19874 } 19875 message.append(" ["); 19876 message.append(Integer.toString(i)); 19877 message.append(", "); 19878 message.append(Integer.toString(j)); 19879 message.append("]"); 19880 } 19881 } 19882 } 19883 assertFalse("Incorrect output for checkConvertChar3Ulong3" + 19884 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19885 } 19886 checkConvertChar4Ulong4()19887 private void checkConvertChar4Ulong4() { 19888 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xc243973l, false, 7); 19889 try { 19890 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 19891 script.forEach_testConvertUlong4Char4Ulong4(inV, out); 19892 verifyResultsConvertChar4Ulong4(inV, out, false); 19893 } catch (Exception e) { 19894 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString()); 19895 } 19896 try { 19897 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 19898 scriptRelaxed.forEach_testConvertUlong4Char4Ulong4(inV, out); 19899 verifyResultsConvertChar4Ulong4(inV, out, true); 19900 } catch (Exception e) { 19901 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString()); 19902 } 19903 } 19904 verifyResultsConvertChar4Ulong4(Allocation inV, Allocation out, boolean relaxed)19905 private void verifyResultsConvertChar4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 19906 byte[] arrayInV = new byte[INPUTSIZE * 4]; 19907 Arrays.fill(arrayInV, (byte) 42); 19908 inV.copyTo(arrayInV); 19909 long[] arrayOut = new long[INPUTSIZE * 4]; 19910 Arrays.fill(arrayOut, (long) 42); 19911 out.copyTo(arrayOut); 19912 StringBuilder message = new StringBuilder(); 19913 boolean errorFound = false; 19914 for (int i = 0; i < INPUTSIZE; i++) { 19915 for (int j = 0; j < 4 ; j++) { 19916 // Extract the inputs. 19917 ArgumentsCharUlong args = new ArgumentsCharUlong(); 19918 args.inV = arrayInV[i * 4 + j]; 19919 // Figure out what the outputs should have been. 19920 CoreMathVerifier.computeConvert(args); 19921 // Validate the outputs. 19922 boolean valid = true; 19923 if (args.out != arrayOut[i * 4 + j]) { 19924 valid = false; 19925 } 19926 if (!valid) { 19927 if (!errorFound) { 19928 errorFound = true; 19929 message.append("Input inV: "); 19930 appendVariableToMessage(message, args.inV); 19931 message.append("\n"); 19932 message.append("Expected output out: "); 19933 appendVariableToMessage(message, args.out); 19934 message.append("\n"); 19935 message.append("Actual output out: "); 19936 appendVariableToMessage(message, arrayOut[i * 4 + j]); 19937 if (args.out != arrayOut[i * 4 + j]) { 19938 message.append(" FAIL"); 19939 } 19940 message.append("\n"); 19941 message.append("Errors at"); 19942 } 19943 message.append(" ["); 19944 message.append(Integer.toString(i)); 19945 message.append(", "); 19946 message.append(Integer.toString(j)); 19947 message.append("]"); 19948 } 19949 } 19950 } 19951 assertFalse("Incorrect output for checkConvertChar4Ulong4" + 19952 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 19953 } 19954 19955 public class ArgumentsUcharUlong { 19956 public byte inV; 19957 public long out; 19958 } 19959 checkConvertUchar2Ulong2()19960 private void checkConvertUchar2Ulong2() { 19961 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbbc61162l, false, 8); 19962 try { 19963 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 19964 script.forEach_testConvertUlong2Uchar2Ulong2(inV, out); 19965 verifyResultsConvertUchar2Ulong2(inV, out, false); 19966 } catch (Exception e) { 19967 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString()); 19968 } 19969 try { 19970 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 19971 scriptRelaxed.forEach_testConvertUlong2Uchar2Ulong2(inV, out); 19972 verifyResultsConvertUchar2Ulong2(inV, out, true); 19973 } catch (Exception e) { 19974 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString()); 19975 } 19976 } 19977 verifyResultsConvertUchar2Ulong2(Allocation inV, Allocation out, boolean relaxed)19978 private void verifyResultsConvertUchar2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 19979 byte[] arrayInV = new byte[INPUTSIZE * 2]; 19980 Arrays.fill(arrayInV, (byte) 42); 19981 inV.copyTo(arrayInV); 19982 long[] arrayOut = new long[INPUTSIZE * 2]; 19983 Arrays.fill(arrayOut, (long) 42); 19984 out.copyTo(arrayOut); 19985 StringBuilder message = new StringBuilder(); 19986 boolean errorFound = false; 19987 for (int i = 0; i < INPUTSIZE; i++) { 19988 for (int j = 0; j < 2 ; j++) { 19989 // Extract the inputs. 19990 ArgumentsUcharUlong args = new ArgumentsUcharUlong(); 19991 args.inV = arrayInV[i * 2 + j]; 19992 // Figure out what the outputs should have been. 19993 CoreMathVerifier.computeConvert(args); 19994 // Validate the outputs. 19995 boolean valid = true; 19996 if (args.out != arrayOut[i * 2 + j]) { 19997 valid = false; 19998 } 19999 if (!valid) { 20000 if (!errorFound) { 20001 errorFound = true; 20002 message.append("Input inV: "); 20003 appendVariableToMessage(message, args.inV); 20004 message.append("\n"); 20005 message.append("Expected output out: "); 20006 appendVariableToMessage(message, args.out); 20007 message.append("\n"); 20008 message.append("Actual output out: "); 20009 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20010 if (args.out != arrayOut[i * 2 + j]) { 20011 message.append(" FAIL"); 20012 } 20013 message.append("\n"); 20014 message.append("Errors at"); 20015 } 20016 message.append(" ["); 20017 message.append(Integer.toString(i)); 20018 message.append(", "); 20019 message.append(Integer.toString(j)); 20020 message.append("]"); 20021 } 20022 } 20023 } 20024 assertFalse("Incorrect output for checkConvertUchar2Ulong2" + 20025 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20026 } 20027 checkConvertUchar3Ulong3()20028 private void checkConvertUchar3Ulong3() { 20029 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb1e13240l, false, 8); 20030 try { 20031 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20032 script.forEach_testConvertUlong3Uchar3Ulong3(inV, out); 20033 verifyResultsConvertUchar3Ulong3(inV, out, false); 20034 } catch (Exception e) { 20035 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString()); 20036 } 20037 try { 20038 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20039 scriptRelaxed.forEach_testConvertUlong3Uchar3Ulong3(inV, out); 20040 verifyResultsConvertUchar3Ulong3(inV, out, true); 20041 } catch (Exception e) { 20042 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString()); 20043 } 20044 } 20045 verifyResultsConvertUchar3Ulong3(Allocation inV, Allocation out, boolean relaxed)20046 private void verifyResultsConvertUchar3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20047 byte[] arrayInV = new byte[INPUTSIZE * 4]; 20048 Arrays.fill(arrayInV, (byte) 42); 20049 inV.copyTo(arrayInV); 20050 long[] arrayOut = new long[INPUTSIZE * 4]; 20051 Arrays.fill(arrayOut, (long) 42); 20052 out.copyTo(arrayOut); 20053 StringBuilder message = new StringBuilder(); 20054 boolean errorFound = false; 20055 for (int i = 0; i < INPUTSIZE; i++) { 20056 for (int j = 0; j < 3 ; j++) { 20057 // Extract the inputs. 20058 ArgumentsUcharUlong args = new ArgumentsUcharUlong(); 20059 args.inV = arrayInV[i * 4 + j]; 20060 // Figure out what the outputs should have been. 20061 CoreMathVerifier.computeConvert(args); 20062 // Validate the outputs. 20063 boolean valid = true; 20064 if (args.out != arrayOut[i * 4 + j]) { 20065 valid = false; 20066 } 20067 if (!valid) { 20068 if (!errorFound) { 20069 errorFound = true; 20070 message.append("Input inV: "); 20071 appendVariableToMessage(message, args.inV); 20072 message.append("\n"); 20073 message.append("Expected output out: "); 20074 appendVariableToMessage(message, args.out); 20075 message.append("\n"); 20076 message.append("Actual output out: "); 20077 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20078 if (args.out != arrayOut[i * 4 + j]) { 20079 message.append(" FAIL"); 20080 } 20081 message.append("\n"); 20082 message.append("Errors at"); 20083 } 20084 message.append(" ["); 20085 message.append(Integer.toString(i)); 20086 message.append(", "); 20087 message.append(Integer.toString(j)); 20088 message.append("]"); 20089 } 20090 } 20091 } 20092 assertFalse("Incorrect output for checkConvertUchar3Ulong3" + 20093 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20094 } 20095 checkConvertUchar4Ulong4()20096 private void checkConvertUchar4Ulong4() { 20097 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa7fc531el, false, 8); 20098 try { 20099 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20100 script.forEach_testConvertUlong4Uchar4Ulong4(inV, out); 20101 verifyResultsConvertUchar4Ulong4(inV, out, false); 20102 } catch (Exception e) { 20103 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString()); 20104 } 20105 try { 20106 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20107 scriptRelaxed.forEach_testConvertUlong4Uchar4Ulong4(inV, out); 20108 verifyResultsConvertUchar4Ulong4(inV, out, true); 20109 } catch (Exception e) { 20110 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString()); 20111 } 20112 } 20113 verifyResultsConvertUchar4Ulong4(Allocation inV, Allocation out, boolean relaxed)20114 private void verifyResultsConvertUchar4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20115 byte[] arrayInV = new byte[INPUTSIZE * 4]; 20116 Arrays.fill(arrayInV, (byte) 42); 20117 inV.copyTo(arrayInV); 20118 long[] arrayOut = new long[INPUTSIZE * 4]; 20119 Arrays.fill(arrayOut, (long) 42); 20120 out.copyTo(arrayOut); 20121 StringBuilder message = new StringBuilder(); 20122 boolean errorFound = false; 20123 for (int i = 0; i < INPUTSIZE; i++) { 20124 for (int j = 0; j < 4 ; j++) { 20125 // Extract the inputs. 20126 ArgumentsUcharUlong args = new ArgumentsUcharUlong(); 20127 args.inV = arrayInV[i * 4 + j]; 20128 // Figure out what the outputs should have been. 20129 CoreMathVerifier.computeConvert(args); 20130 // Validate the outputs. 20131 boolean valid = true; 20132 if (args.out != arrayOut[i * 4 + j]) { 20133 valid = false; 20134 } 20135 if (!valid) { 20136 if (!errorFound) { 20137 errorFound = true; 20138 message.append("Input inV: "); 20139 appendVariableToMessage(message, args.inV); 20140 message.append("\n"); 20141 message.append("Expected output out: "); 20142 appendVariableToMessage(message, args.out); 20143 message.append("\n"); 20144 message.append("Actual output out: "); 20145 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20146 if (args.out != arrayOut[i * 4 + j]) { 20147 message.append(" FAIL"); 20148 } 20149 message.append("\n"); 20150 message.append("Errors at"); 20151 } 20152 message.append(" ["); 20153 message.append(Integer.toString(i)); 20154 message.append(", "); 20155 message.append(Integer.toString(j)); 20156 message.append("]"); 20157 } 20158 } 20159 } 20160 assertFalse("Incorrect output for checkConvertUchar4Ulong4" + 20161 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20162 } 20163 20164 public class ArgumentsShortUlong { 20165 public short inV; 20166 public long out; 20167 } 20168 checkConvertShort2Ulong2()20169 private void checkConvertShort2Ulong2() { 20170 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xffc6f6a3l, false, 15); 20171 try { 20172 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20173 script.forEach_testConvertUlong2Short2Ulong2(inV, out); 20174 verifyResultsConvertShort2Ulong2(inV, out, false); 20175 } catch (Exception e) { 20176 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString()); 20177 } 20178 try { 20179 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20180 scriptRelaxed.forEach_testConvertUlong2Short2Ulong2(inV, out); 20181 verifyResultsConvertShort2Ulong2(inV, out, true); 20182 } catch (Exception e) { 20183 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString()); 20184 } 20185 } 20186 verifyResultsConvertShort2Ulong2(Allocation inV, Allocation out, boolean relaxed)20187 private void verifyResultsConvertShort2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20188 short[] arrayInV = new short[INPUTSIZE * 2]; 20189 Arrays.fill(arrayInV, (short) 42); 20190 inV.copyTo(arrayInV); 20191 long[] arrayOut = new long[INPUTSIZE * 2]; 20192 Arrays.fill(arrayOut, (long) 42); 20193 out.copyTo(arrayOut); 20194 StringBuilder message = new StringBuilder(); 20195 boolean errorFound = false; 20196 for (int i = 0; i < INPUTSIZE; i++) { 20197 for (int j = 0; j < 2 ; j++) { 20198 // Extract the inputs. 20199 ArgumentsShortUlong args = new ArgumentsShortUlong(); 20200 args.inV = arrayInV[i * 2 + j]; 20201 // Figure out what the outputs should have been. 20202 CoreMathVerifier.computeConvert(args); 20203 // Validate the outputs. 20204 boolean valid = true; 20205 if (args.out != arrayOut[i * 2 + j]) { 20206 valid = false; 20207 } 20208 if (!valid) { 20209 if (!errorFound) { 20210 errorFound = true; 20211 message.append("Input inV: "); 20212 appendVariableToMessage(message, args.inV); 20213 message.append("\n"); 20214 message.append("Expected output out: "); 20215 appendVariableToMessage(message, args.out); 20216 message.append("\n"); 20217 message.append("Actual output out: "); 20218 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20219 if (args.out != arrayOut[i * 2 + j]) { 20220 message.append(" FAIL"); 20221 } 20222 message.append("\n"); 20223 message.append("Errors at"); 20224 } 20225 message.append(" ["); 20226 message.append(Integer.toString(i)); 20227 message.append(", "); 20228 message.append(Integer.toString(j)); 20229 message.append("]"); 20230 } 20231 } 20232 } 20233 assertFalse("Incorrect output for checkConvertShort2Ulong2" + 20234 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20235 } 20236 checkConvertShort3Ulong3()20237 private void checkConvertShort3Ulong3() { 20238 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf5e21781l, false, 15); 20239 try { 20240 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20241 script.forEach_testConvertUlong3Short3Ulong3(inV, out); 20242 verifyResultsConvertShort3Ulong3(inV, out, false); 20243 } catch (Exception e) { 20244 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString()); 20245 } 20246 try { 20247 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20248 scriptRelaxed.forEach_testConvertUlong3Short3Ulong3(inV, out); 20249 verifyResultsConvertShort3Ulong3(inV, out, true); 20250 } catch (Exception e) { 20251 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString()); 20252 } 20253 } 20254 verifyResultsConvertShort3Ulong3(Allocation inV, Allocation out, boolean relaxed)20255 private void verifyResultsConvertShort3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20256 short[] arrayInV = new short[INPUTSIZE * 4]; 20257 Arrays.fill(arrayInV, (short) 42); 20258 inV.copyTo(arrayInV); 20259 long[] arrayOut = new long[INPUTSIZE * 4]; 20260 Arrays.fill(arrayOut, (long) 42); 20261 out.copyTo(arrayOut); 20262 StringBuilder message = new StringBuilder(); 20263 boolean errorFound = false; 20264 for (int i = 0; i < INPUTSIZE; i++) { 20265 for (int j = 0; j < 3 ; j++) { 20266 // Extract the inputs. 20267 ArgumentsShortUlong args = new ArgumentsShortUlong(); 20268 args.inV = arrayInV[i * 4 + j]; 20269 // Figure out what the outputs should have been. 20270 CoreMathVerifier.computeConvert(args); 20271 // Validate the outputs. 20272 boolean valid = true; 20273 if (args.out != arrayOut[i * 4 + j]) { 20274 valid = false; 20275 } 20276 if (!valid) { 20277 if (!errorFound) { 20278 errorFound = true; 20279 message.append("Input inV: "); 20280 appendVariableToMessage(message, args.inV); 20281 message.append("\n"); 20282 message.append("Expected output out: "); 20283 appendVariableToMessage(message, args.out); 20284 message.append("\n"); 20285 message.append("Actual output out: "); 20286 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20287 if (args.out != arrayOut[i * 4 + j]) { 20288 message.append(" FAIL"); 20289 } 20290 message.append("\n"); 20291 message.append("Errors at"); 20292 } 20293 message.append(" ["); 20294 message.append(Integer.toString(i)); 20295 message.append(", "); 20296 message.append(Integer.toString(j)); 20297 message.append("]"); 20298 } 20299 } 20300 } 20301 assertFalse("Incorrect output for checkConvertShort3Ulong3" + 20302 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20303 } 20304 checkConvertShort4Ulong4()20305 private void checkConvertShort4Ulong4() { 20306 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xebfd385fl, false, 15); 20307 try { 20308 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20309 script.forEach_testConvertUlong4Short4Ulong4(inV, out); 20310 verifyResultsConvertShort4Ulong4(inV, out, false); 20311 } catch (Exception e) { 20312 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString()); 20313 } 20314 try { 20315 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20316 scriptRelaxed.forEach_testConvertUlong4Short4Ulong4(inV, out); 20317 verifyResultsConvertShort4Ulong4(inV, out, true); 20318 } catch (Exception e) { 20319 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString()); 20320 } 20321 } 20322 verifyResultsConvertShort4Ulong4(Allocation inV, Allocation out, boolean relaxed)20323 private void verifyResultsConvertShort4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20324 short[] arrayInV = new short[INPUTSIZE * 4]; 20325 Arrays.fill(arrayInV, (short) 42); 20326 inV.copyTo(arrayInV); 20327 long[] arrayOut = new long[INPUTSIZE * 4]; 20328 Arrays.fill(arrayOut, (long) 42); 20329 out.copyTo(arrayOut); 20330 StringBuilder message = new StringBuilder(); 20331 boolean errorFound = false; 20332 for (int i = 0; i < INPUTSIZE; i++) { 20333 for (int j = 0; j < 4 ; j++) { 20334 // Extract the inputs. 20335 ArgumentsShortUlong args = new ArgumentsShortUlong(); 20336 args.inV = arrayInV[i * 4 + j]; 20337 // Figure out what the outputs should have been. 20338 CoreMathVerifier.computeConvert(args); 20339 // Validate the outputs. 20340 boolean valid = true; 20341 if (args.out != arrayOut[i * 4 + j]) { 20342 valid = false; 20343 } 20344 if (!valid) { 20345 if (!errorFound) { 20346 errorFound = true; 20347 message.append("Input inV: "); 20348 appendVariableToMessage(message, args.inV); 20349 message.append("\n"); 20350 message.append("Expected output out: "); 20351 appendVariableToMessage(message, args.out); 20352 message.append("\n"); 20353 message.append("Actual output out: "); 20354 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20355 if (args.out != arrayOut[i * 4 + j]) { 20356 message.append(" FAIL"); 20357 } 20358 message.append("\n"); 20359 message.append("Errors at"); 20360 } 20361 message.append(" ["); 20362 message.append(Integer.toString(i)); 20363 message.append(", "); 20364 message.append(Integer.toString(j)); 20365 message.append("]"); 20366 } 20367 } 20368 } 20369 assertFalse("Incorrect output for checkConvertShort4Ulong4" + 20370 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20371 } 20372 20373 public class ArgumentsUshortUlong { 20374 public short inV; 20375 public long out; 20376 } 20377 checkConvertUshort2Ulong2()20378 private void checkConvertUshort2Ulong2() { 20379 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2d13465cl, false, 16); 20380 try { 20381 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20382 script.forEach_testConvertUlong2Ushort2Ulong2(inV, out); 20383 verifyResultsConvertUshort2Ulong2(inV, out, false); 20384 } catch (Exception e) { 20385 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString()); 20386 } 20387 try { 20388 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20389 scriptRelaxed.forEach_testConvertUlong2Ushort2Ulong2(inV, out); 20390 verifyResultsConvertUshort2Ulong2(inV, out, true); 20391 } catch (Exception e) { 20392 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString()); 20393 } 20394 } 20395 verifyResultsConvertUshort2Ulong2(Allocation inV, Allocation out, boolean relaxed)20396 private void verifyResultsConvertUshort2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20397 short[] arrayInV = new short[INPUTSIZE * 2]; 20398 Arrays.fill(arrayInV, (short) 42); 20399 inV.copyTo(arrayInV); 20400 long[] arrayOut = new long[INPUTSIZE * 2]; 20401 Arrays.fill(arrayOut, (long) 42); 20402 out.copyTo(arrayOut); 20403 StringBuilder message = new StringBuilder(); 20404 boolean errorFound = false; 20405 for (int i = 0; i < INPUTSIZE; i++) { 20406 for (int j = 0; j < 2 ; j++) { 20407 // Extract the inputs. 20408 ArgumentsUshortUlong args = new ArgumentsUshortUlong(); 20409 args.inV = arrayInV[i * 2 + j]; 20410 // Figure out what the outputs should have been. 20411 CoreMathVerifier.computeConvert(args); 20412 // Validate the outputs. 20413 boolean valid = true; 20414 if (args.out != arrayOut[i * 2 + j]) { 20415 valid = false; 20416 } 20417 if (!valid) { 20418 if (!errorFound) { 20419 errorFound = true; 20420 message.append("Input inV: "); 20421 appendVariableToMessage(message, args.inV); 20422 message.append("\n"); 20423 message.append("Expected output out: "); 20424 appendVariableToMessage(message, args.out); 20425 message.append("\n"); 20426 message.append("Actual output out: "); 20427 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20428 if (args.out != arrayOut[i * 2 + j]) { 20429 message.append(" FAIL"); 20430 } 20431 message.append("\n"); 20432 message.append("Errors at"); 20433 } 20434 message.append(" ["); 20435 message.append(Integer.toString(i)); 20436 message.append(", "); 20437 message.append(Integer.toString(j)); 20438 message.append("]"); 20439 } 20440 } 20441 } 20442 assertFalse("Incorrect output for checkConvertUshort2Ulong2" + 20443 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20444 } 20445 checkConvertUshort3Ulong3()20446 private void checkConvertUshort3Ulong3() { 20447 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x232e673al, false, 16); 20448 try { 20449 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20450 script.forEach_testConvertUlong3Ushort3Ulong3(inV, out); 20451 verifyResultsConvertUshort3Ulong3(inV, out, false); 20452 } catch (Exception e) { 20453 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString()); 20454 } 20455 try { 20456 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20457 scriptRelaxed.forEach_testConvertUlong3Ushort3Ulong3(inV, out); 20458 verifyResultsConvertUshort3Ulong3(inV, out, true); 20459 } catch (Exception e) { 20460 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString()); 20461 } 20462 } 20463 verifyResultsConvertUshort3Ulong3(Allocation inV, Allocation out, boolean relaxed)20464 private void verifyResultsConvertUshort3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20465 short[] arrayInV = new short[INPUTSIZE * 4]; 20466 Arrays.fill(arrayInV, (short) 42); 20467 inV.copyTo(arrayInV); 20468 long[] arrayOut = new long[INPUTSIZE * 4]; 20469 Arrays.fill(arrayOut, (long) 42); 20470 out.copyTo(arrayOut); 20471 StringBuilder message = new StringBuilder(); 20472 boolean errorFound = false; 20473 for (int i = 0; i < INPUTSIZE; i++) { 20474 for (int j = 0; j < 3 ; j++) { 20475 // Extract the inputs. 20476 ArgumentsUshortUlong args = new ArgumentsUshortUlong(); 20477 args.inV = arrayInV[i * 4 + j]; 20478 // Figure out what the outputs should have been. 20479 CoreMathVerifier.computeConvert(args); 20480 // Validate the outputs. 20481 boolean valid = true; 20482 if (args.out != arrayOut[i * 4 + j]) { 20483 valid = false; 20484 } 20485 if (!valid) { 20486 if (!errorFound) { 20487 errorFound = true; 20488 message.append("Input inV: "); 20489 appendVariableToMessage(message, args.inV); 20490 message.append("\n"); 20491 message.append("Expected output out: "); 20492 appendVariableToMessage(message, args.out); 20493 message.append("\n"); 20494 message.append("Actual output out: "); 20495 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20496 if (args.out != arrayOut[i * 4 + j]) { 20497 message.append(" FAIL"); 20498 } 20499 message.append("\n"); 20500 message.append("Errors at"); 20501 } 20502 message.append(" ["); 20503 message.append(Integer.toString(i)); 20504 message.append(", "); 20505 message.append(Integer.toString(j)); 20506 message.append("]"); 20507 } 20508 } 20509 } 20510 assertFalse("Incorrect output for checkConvertUshort3Ulong3" + 20511 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20512 } 20513 checkConvertUshort4Ulong4()20514 private void checkConvertUshort4Ulong4() { 20515 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19498818l, false, 16); 20516 try { 20517 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20518 script.forEach_testConvertUlong4Ushort4Ulong4(inV, out); 20519 verifyResultsConvertUshort4Ulong4(inV, out, false); 20520 } catch (Exception e) { 20521 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString()); 20522 } 20523 try { 20524 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20525 scriptRelaxed.forEach_testConvertUlong4Ushort4Ulong4(inV, out); 20526 verifyResultsConvertUshort4Ulong4(inV, out, true); 20527 } catch (Exception e) { 20528 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString()); 20529 } 20530 } 20531 verifyResultsConvertUshort4Ulong4(Allocation inV, Allocation out, boolean relaxed)20532 private void verifyResultsConvertUshort4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20533 short[] arrayInV = new short[INPUTSIZE * 4]; 20534 Arrays.fill(arrayInV, (short) 42); 20535 inV.copyTo(arrayInV); 20536 long[] arrayOut = new long[INPUTSIZE * 4]; 20537 Arrays.fill(arrayOut, (long) 42); 20538 out.copyTo(arrayOut); 20539 StringBuilder message = new StringBuilder(); 20540 boolean errorFound = false; 20541 for (int i = 0; i < INPUTSIZE; i++) { 20542 for (int j = 0; j < 4 ; j++) { 20543 // Extract the inputs. 20544 ArgumentsUshortUlong args = new ArgumentsUshortUlong(); 20545 args.inV = arrayInV[i * 4 + j]; 20546 // Figure out what the outputs should have been. 20547 CoreMathVerifier.computeConvert(args); 20548 // Validate the outputs. 20549 boolean valid = true; 20550 if (args.out != arrayOut[i * 4 + j]) { 20551 valid = false; 20552 } 20553 if (!valid) { 20554 if (!errorFound) { 20555 errorFound = true; 20556 message.append("Input inV: "); 20557 appendVariableToMessage(message, args.inV); 20558 message.append("\n"); 20559 message.append("Expected output out: "); 20560 appendVariableToMessage(message, args.out); 20561 message.append("\n"); 20562 message.append("Actual output out: "); 20563 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20564 if (args.out != arrayOut[i * 4 + j]) { 20565 message.append(" FAIL"); 20566 } 20567 message.append("\n"); 20568 message.append("Errors at"); 20569 } 20570 message.append(" ["); 20571 message.append(Integer.toString(i)); 20572 message.append(", "); 20573 message.append(Integer.toString(j)); 20574 message.append("]"); 20575 } 20576 } 20577 } 20578 assertFalse("Incorrect output for checkConvertUshort4Ulong4" + 20579 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20580 } 20581 20582 public class ArgumentsIntUlong { 20583 public int inV; 20584 public long out; 20585 } 20586 checkConvertInt2Ulong2()20587 private void checkConvertInt2Ulong2() { 20588 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x74a824f6l, false, 31); 20589 try { 20590 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20591 script.forEach_testConvertUlong2Int2Ulong2(inV, out); 20592 verifyResultsConvertInt2Ulong2(inV, out, false); 20593 } catch (Exception e) { 20594 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString()); 20595 } 20596 try { 20597 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20598 scriptRelaxed.forEach_testConvertUlong2Int2Ulong2(inV, out); 20599 verifyResultsConvertInt2Ulong2(inV, out, true); 20600 } catch (Exception e) { 20601 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString()); 20602 } 20603 } 20604 verifyResultsConvertInt2Ulong2(Allocation inV, Allocation out, boolean relaxed)20605 private void verifyResultsConvertInt2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20606 int[] arrayInV = new int[INPUTSIZE * 2]; 20607 Arrays.fill(arrayInV, (int) 42); 20608 inV.copyTo(arrayInV); 20609 long[] arrayOut = new long[INPUTSIZE * 2]; 20610 Arrays.fill(arrayOut, (long) 42); 20611 out.copyTo(arrayOut); 20612 StringBuilder message = new StringBuilder(); 20613 boolean errorFound = false; 20614 for (int i = 0; i < INPUTSIZE; i++) { 20615 for (int j = 0; j < 2 ; j++) { 20616 // Extract the inputs. 20617 ArgumentsIntUlong args = new ArgumentsIntUlong(); 20618 args.inV = arrayInV[i * 2 + j]; 20619 // Figure out what the outputs should have been. 20620 CoreMathVerifier.computeConvert(args); 20621 // Validate the outputs. 20622 boolean valid = true; 20623 if (args.out != arrayOut[i * 2 + j]) { 20624 valid = false; 20625 } 20626 if (!valid) { 20627 if (!errorFound) { 20628 errorFound = true; 20629 message.append("Input inV: "); 20630 appendVariableToMessage(message, args.inV); 20631 message.append("\n"); 20632 message.append("Expected output out: "); 20633 appendVariableToMessage(message, args.out); 20634 message.append("\n"); 20635 message.append("Actual output out: "); 20636 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20637 if (args.out != arrayOut[i * 2 + j]) { 20638 message.append(" FAIL"); 20639 } 20640 message.append("\n"); 20641 message.append("Errors at"); 20642 } 20643 message.append(" ["); 20644 message.append(Integer.toString(i)); 20645 message.append(", "); 20646 message.append(Integer.toString(j)); 20647 message.append("]"); 20648 } 20649 } 20650 } 20651 assertFalse("Incorrect output for checkConvertInt2Ulong2" + 20652 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20653 } 20654 checkConvertInt3Ulong3()20655 private void checkConvertInt3Ulong3() { 20656 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6ac345d4l, false, 31); 20657 try { 20658 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20659 script.forEach_testConvertUlong3Int3Ulong3(inV, out); 20660 verifyResultsConvertInt3Ulong3(inV, out, false); 20661 } catch (Exception e) { 20662 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString()); 20663 } 20664 try { 20665 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20666 scriptRelaxed.forEach_testConvertUlong3Int3Ulong3(inV, out); 20667 verifyResultsConvertInt3Ulong3(inV, out, true); 20668 } catch (Exception e) { 20669 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString()); 20670 } 20671 } 20672 verifyResultsConvertInt3Ulong3(Allocation inV, Allocation out, boolean relaxed)20673 private void verifyResultsConvertInt3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20674 int[] arrayInV = new int[INPUTSIZE * 4]; 20675 Arrays.fill(arrayInV, (int) 42); 20676 inV.copyTo(arrayInV); 20677 long[] arrayOut = new long[INPUTSIZE * 4]; 20678 Arrays.fill(arrayOut, (long) 42); 20679 out.copyTo(arrayOut); 20680 StringBuilder message = new StringBuilder(); 20681 boolean errorFound = false; 20682 for (int i = 0; i < INPUTSIZE; i++) { 20683 for (int j = 0; j < 3 ; j++) { 20684 // Extract the inputs. 20685 ArgumentsIntUlong args = new ArgumentsIntUlong(); 20686 args.inV = arrayInV[i * 4 + j]; 20687 // Figure out what the outputs should have been. 20688 CoreMathVerifier.computeConvert(args); 20689 // Validate the outputs. 20690 boolean valid = true; 20691 if (args.out != arrayOut[i * 4 + j]) { 20692 valid = false; 20693 } 20694 if (!valid) { 20695 if (!errorFound) { 20696 errorFound = true; 20697 message.append("Input inV: "); 20698 appendVariableToMessage(message, args.inV); 20699 message.append("\n"); 20700 message.append("Expected output out: "); 20701 appendVariableToMessage(message, args.out); 20702 message.append("\n"); 20703 message.append("Actual output out: "); 20704 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20705 if (args.out != arrayOut[i * 4 + j]) { 20706 message.append(" FAIL"); 20707 } 20708 message.append("\n"); 20709 message.append("Errors at"); 20710 } 20711 message.append(" ["); 20712 message.append(Integer.toString(i)); 20713 message.append(", "); 20714 message.append(Integer.toString(j)); 20715 message.append("]"); 20716 } 20717 } 20718 } 20719 assertFalse("Incorrect output for checkConvertInt3Ulong3" + 20720 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20721 } 20722 checkConvertInt4Ulong4()20723 private void checkConvertInt4Ulong4() { 20724 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x60de66b2l, false, 31); 20725 try { 20726 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20727 script.forEach_testConvertUlong4Int4Ulong4(inV, out); 20728 verifyResultsConvertInt4Ulong4(inV, out, false); 20729 } catch (Exception e) { 20730 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString()); 20731 } 20732 try { 20733 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20734 scriptRelaxed.forEach_testConvertUlong4Int4Ulong4(inV, out); 20735 verifyResultsConvertInt4Ulong4(inV, out, true); 20736 } catch (Exception e) { 20737 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString()); 20738 } 20739 } 20740 verifyResultsConvertInt4Ulong4(Allocation inV, Allocation out, boolean relaxed)20741 private void verifyResultsConvertInt4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20742 int[] arrayInV = new int[INPUTSIZE * 4]; 20743 Arrays.fill(arrayInV, (int) 42); 20744 inV.copyTo(arrayInV); 20745 long[] arrayOut = new long[INPUTSIZE * 4]; 20746 Arrays.fill(arrayOut, (long) 42); 20747 out.copyTo(arrayOut); 20748 StringBuilder message = new StringBuilder(); 20749 boolean errorFound = false; 20750 for (int i = 0; i < INPUTSIZE; i++) { 20751 for (int j = 0; j < 4 ; j++) { 20752 // Extract the inputs. 20753 ArgumentsIntUlong args = new ArgumentsIntUlong(); 20754 args.inV = arrayInV[i * 4 + j]; 20755 // Figure out what the outputs should have been. 20756 CoreMathVerifier.computeConvert(args); 20757 // Validate the outputs. 20758 boolean valid = true; 20759 if (args.out != arrayOut[i * 4 + j]) { 20760 valid = false; 20761 } 20762 if (!valid) { 20763 if (!errorFound) { 20764 errorFound = true; 20765 message.append("Input inV: "); 20766 appendVariableToMessage(message, args.inV); 20767 message.append("\n"); 20768 message.append("Expected output out: "); 20769 appendVariableToMessage(message, args.out); 20770 message.append("\n"); 20771 message.append("Actual output out: "); 20772 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20773 if (args.out != arrayOut[i * 4 + j]) { 20774 message.append(" FAIL"); 20775 } 20776 message.append("\n"); 20777 message.append("Errors at"); 20778 } 20779 message.append(" ["); 20780 message.append(Integer.toString(i)); 20781 message.append(", "); 20782 message.append(Integer.toString(j)); 20783 message.append("]"); 20784 } 20785 } 20786 } 20787 assertFalse("Incorrect output for checkConvertInt4Ulong4" + 20788 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20789 } 20790 20791 public class ArgumentsUintUlong { 20792 public int inV; 20793 public long out; 20794 } 20795 checkConvertUint2Ulong2()20796 private void checkConvertUint2Ulong2() { 20797 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x72a3177l, false, 32); 20798 try { 20799 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20800 script.forEach_testConvertUlong2Uint2Ulong2(inV, out); 20801 verifyResultsConvertUint2Ulong2(inV, out, false); 20802 } catch (Exception e) { 20803 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString()); 20804 } 20805 try { 20806 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 20807 scriptRelaxed.forEach_testConvertUlong2Uint2Ulong2(inV, out); 20808 verifyResultsConvertUint2Ulong2(inV, out, true); 20809 } catch (Exception e) { 20810 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString()); 20811 } 20812 } 20813 verifyResultsConvertUint2Ulong2(Allocation inV, Allocation out, boolean relaxed)20814 private void verifyResultsConvertUint2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 20815 int[] arrayInV = new int[INPUTSIZE * 2]; 20816 Arrays.fill(arrayInV, (int) 42); 20817 inV.copyTo(arrayInV); 20818 long[] arrayOut = new long[INPUTSIZE * 2]; 20819 Arrays.fill(arrayOut, (long) 42); 20820 out.copyTo(arrayOut); 20821 StringBuilder message = new StringBuilder(); 20822 boolean errorFound = false; 20823 for (int i = 0; i < INPUTSIZE; i++) { 20824 for (int j = 0; j < 2 ; j++) { 20825 // Extract the inputs. 20826 ArgumentsUintUlong args = new ArgumentsUintUlong(); 20827 args.inV = arrayInV[i * 2 + j]; 20828 // Figure out what the outputs should have been. 20829 CoreMathVerifier.computeConvert(args); 20830 // Validate the outputs. 20831 boolean valid = true; 20832 if (args.out != arrayOut[i * 2 + j]) { 20833 valid = false; 20834 } 20835 if (!valid) { 20836 if (!errorFound) { 20837 errorFound = true; 20838 message.append("Input inV: "); 20839 appendVariableToMessage(message, args.inV); 20840 message.append("\n"); 20841 message.append("Expected output out: "); 20842 appendVariableToMessage(message, args.out); 20843 message.append("\n"); 20844 message.append("Actual output out: "); 20845 appendVariableToMessage(message, arrayOut[i * 2 + j]); 20846 if (args.out != arrayOut[i * 2 + j]) { 20847 message.append(" FAIL"); 20848 } 20849 message.append("\n"); 20850 message.append("Errors at"); 20851 } 20852 message.append(" ["); 20853 message.append(Integer.toString(i)); 20854 message.append(", "); 20855 message.append(Integer.toString(j)); 20856 message.append("]"); 20857 } 20858 } 20859 } 20860 assertFalse("Incorrect output for checkConvertUint2Ulong2" + 20861 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20862 } 20863 checkConvertUint3Ulong3()20864 private void checkConvertUint3Ulong3() { 20865 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xfd455255l, false, 32); 20866 try { 20867 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20868 script.forEach_testConvertUlong3Uint3Ulong3(inV, out); 20869 verifyResultsConvertUint3Ulong3(inV, out, false); 20870 } catch (Exception e) { 20871 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString()); 20872 } 20873 try { 20874 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 20875 scriptRelaxed.forEach_testConvertUlong3Uint3Ulong3(inV, out); 20876 verifyResultsConvertUint3Ulong3(inV, out, true); 20877 } catch (Exception e) { 20878 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString()); 20879 } 20880 } 20881 verifyResultsConvertUint3Ulong3(Allocation inV, Allocation out, boolean relaxed)20882 private void verifyResultsConvertUint3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 20883 int[] arrayInV = new int[INPUTSIZE * 4]; 20884 Arrays.fill(arrayInV, (int) 42); 20885 inV.copyTo(arrayInV); 20886 long[] arrayOut = new long[INPUTSIZE * 4]; 20887 Arrays.fill(arrayOut, (long) 42); 20888 out.copyTo(arrayOut); 20889 StringBuilder message = new StringBuilder(); 20890 boolean errorFound = false; 20891 for (int i = 0; i < INPUTSIZE; i++) { 20892 for (int j = 0; j < 3 ; j++) { 20893 // Extract the inputs. 20894 ArgumentsUintUlong args = new ArgumentsUintUlong(); 20895 args.inV = arrayInV[i * 4 + j]; 20896 // Figure out what the outputs should have been. 20897 CoreMathVerifier.computeConvert(args); 20898 // Validate the outputs. 20899 boolean valid = true; 20900 if (args.out != arrayOut[i * 4 + j]) { 20901 valid = false; 20902 } 20903 if (!valid) { 20904 if (!errorFound) { 20905 errorFound = true; 20906 message.append("Input inV: "); 20907 appendVariableToMessage(message, args.inV); 20908 message.append("\n"); 20909 message.append("Expected output out: "); 20910 appendVariableToMessage(message, args.out); 20911 message.append("\n"); 20912 message.append("Actual output out: "); 20913 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20914 if (args.out != arrayOut[i * 4 + j]) { 20915 message.append(" FAIL"); 20916 } 20917 message.append("\n"); 20918 message.append("Errors at"); 20919 } 20920 message.append(" ["); 20921 message.append(Integer.toString(i)); 20922 message.append(", "); 20923 message.append(Integer.toString(j)); 20924 message.append("]"); 20925 } 20926 } 20927 } 20928 assertFalse("Incorrect output for checkConvertUint3Ulong3" + 20929 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20930 } 20931 checkConvertUint4Ulong4()20932 private void checkConvertUint4Ulong4() { 20933 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf3607333l, false, 32); 20934 try { 20935 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20936 script.forEach_testConvertUlong4Uint4Ulong4(inV, out); 20937 verifyResultsConvertUint4Ulong4(inV, out, false); 20938 } catch (Exception e) { 20939 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString()); 20940 } 20941 try { 20942 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 20943 scriptRelaxed.forEach_testConvertUlong4Uint4Ulong4(inV, out); 20944 verifyResultsConvertUint4Ulong4(inV, out, true); 20945 } catch (Exception e) { 20946 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString()); 20947 } 20948 } 20949 verifyResultsConvertUint4Ulong4(Allocation inV, Allocation out, boolean relaxed)20950 private void verifyResultsConvertUint4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 20951 int[] arrayInV = new int[INPUTSIZE * 4]; 20952 Arrays.fill(arrayInV, (int) 42); 20953 inV.copyTo(arrayInV); 20954 long[] arrayOut = new long[INPUTSIZE * 4]; 20955 Arrays.fill(arrayOut, (long) 42); 20956 out.copyTo(arrayOut); 20957 StringBuilder message = new StringBuilder(); 20958 boolean errorFound = false; 20959 for (int i = 0; i < INPUTSIZE; i++) { 20960 for (int j = 0; j < 4 ; j++) { 20961 // Extract the inputs. 20962 ArgumentsUintUlong args = new ArgumentsUintUlong(); 20963 args.inV = arrayInV[i * 4 + j]; 20964 // Figure out what the outputs should have been. 20965 CoreMathVerifier.computeConvert(args); 20966 // Validate the outputs. 20967 boolean valid = true; 20968 if (args.out != arrayOut[i * 4 + j]) { 20969 valid = false; 20970 } 20971 if (!valid) { 20972 if (!errorFound) { 20973 errorFound = true; 20974 message.append("Input inV: "); 20975 appendVariableToMessage(message, args.inV); 20976 message.append("\n"); 20977 message.append("Expected output out: "); 20978 appendVariableToMessage(message, args.out); 20979 message.append("\n"); 20980 message.append("Actual output out: "); 20981 appendVariableToMessage(message, arrayOut[i * 4 + j]); 20982 if (args.out != arrayOut[i * 4 + j]) { 20983 message.append(" FAIL"); 20984 } 20985 message.append("\n"); 20986 message.append("Errors at"); 20987 } 20988 message.append(" ["); 20989 message.append(Integer.toString(i)); 20990 message.append(", "); 20991 message.append(Integer.toString(j)); 20992 message.append("]"); 20993 } 20994 } 20995 } 20996 assertFalse("Incorrect output for checkConvertUint4Ulong4" + 20997 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 20998 } 20999 21000 public class ArgumentsHalfHalf { 21001 public short inV; 21002 public double inVDouble; 21003 public Target.Floaty out; 21004 } 21005 checkConvertHalf2Half2()21006 private void checkConvertHalf2Half2() { 21007 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x77294e2el, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21008 try { 21009 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 21010 script.forEach_testConvertHalf2Half2Half2(inV, out); 21011 verifyResultsConvertHalf2Half2(inV, out, false); 21012 } catch (Exception e) { 21013 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Half2Half2: " + e.toString()); 21014 } 21015 try { 21016 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 21017 scriptRelaxed.forEach_testConvertHalf2Half2Half2(inV, out); 21018 verifyResultsConvertHalf2Half2(inV, out, true); 21019 } catch (Exception e) { 21020 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Half2Half2: " + e.toString()); 21021 } 21022 } 21023 verifyResultsConvertHalf2Half2(Allocation inV, Allocation out, boolean relaxed)21024 private void verifyResultsConvertHalf2Half2(Allocation inV, Allocation out, boolean relaxed) { 21025 short[] arrayInV = new short[INPUTSIZE * 2]; 21026 Arrays.fill(arrayInV, (short) 42); 21027 inV.copyTo(arrayInV); 21028 short[] arrayOut = new short[INPUTSIZE * 2]; 21029 Arrays.fill(arrayOut, (short) 42); 21030 out.copyTo(arrayOut); 21031 StringBuilder message = new StringBuilder(); 21032 boolean errorFound = false; 21033 for (int i = 0; i < INPUTSIZE; i++) { 21034 for (int j = 0; j < 2 ; j++) { 21035 // Extract the inputs. 21036 ArgumentsHalfHalf args = new ArgumentsHalfHalf(); 21037 args.inV = arrayInV[i * 2 + j]; 21038 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21039 // Figure out what the outputs should have been. 21040 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 21041 CoreMathVerifier.computeConvert(args, target); 21042 // Validate the outputs. 21043 boolean valid = true; 21044 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 21045 valid = false; 21046 } 21047 if (!valid) { 21048 if (!errorFound) { 21049 errorFound = true; 21050 message.append("Input inV: "); 21051 appendVariableToMessage(message, args.inV); 21052 message.append("\n"); 21053 message.append("Expected output out: "); 21054 appendVariableToMessage(message, args.out); 21055 message.append("\n"); 21056 message.append("Actual output out: "); 21057 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21058 message.append("\n"); 21059 message.append("Actual output out (in double): "); 21060 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 21061 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 21062 message.append(" FAIL"); 21063 } 21064 message.append("\n"); 21065 message.append("Errors at"); 21066 } 21067 message.append(" ["); 21068 message.append(Integer.toString(i)); 21069 message.append(", "); 21070 message.append(Integer.toString(j)); 21071 message.append("]"); 21072 } 21073 } 21074 } 21075 assertFalse("Incorrect output for checkConvertHalf2Half2" + 21076 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21077 } 21078 checkConvertHalf3Half3()21079 private void checkConvertHalf3Half3() { 21080 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd6311322l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21081 try { 21082 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 21083 script.forEach_testConvertHalf3Half3Half3(inV, out); 21084 verifyResultsConvertHalf3Half3(inV, out, false); 21085 } catch (Exception e) { 21086 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Half3Half3: " + e.toString()); 21087 } 21088 try { 21089 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 21090 scriptRelaxed.forEach_testConvertHalf3Half3Half3(inV, out); 21091 verifyResultsConvertHalf3Half3(inV, out, true); 21092 } catch (Exception e) { 21093 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Half3Half3: " + e.toString()); 21094 } 21095 } 21096 verifyResultsConvertHalf3Half3(Allocation inV, Allocation out, boolean relaxed)21097 private void verifyResultsConvertHalf3Half3(Allocation inV, Allocation out, boolean relaxed) { 21098 short[] arrayInV = new short[INPUTSIZE * 4]; 21099 Arrays.fill(arrayInV, (short) 42); 21100 inV.copyTo(arrayInV); 21101 short[] arrayOut = new short[INPUTSIZE * 4]; 21102 Arrays.fill(arrayOut, (short) 42); 21103 out.copyTo(arrayOut); 21104 StringBuilder message = new StringBuilder(); 21105 boolean errorFound = false; 21106 for (int i = 0; i < INPUTSIZE; i++) { 21107 for (int j = 0; j < 3 ; j++) { 21108 // Extract the inputs. 21109 ArgumentsHalfHalf args = new ArgumentsHalfHalf(); 21110 args.inV = arrayInV[i * 4 + j]; 21111 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21112 // Figure out what the outputs should have been. 21113 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 21114 CoreMathVerifier.computeConvert(args, target); 21115 // Validate the outputs. 21116 boolean valid = true; 21117 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 21118 valid = false; 21119 } 21120 if (!valid) { 21121 if (!errorFound) { 21122 errorFound = true; 21123 message.append("Input inV: "); 21124 appendVariableToMessage(message, args.inV); 21125 message.append("\n"); 21126 message.append("Expected output out: "); 21127 appendVariableToMessage(message, args.out); 21128 message.append("\n"); 21129 message.append("Actual output out: "); 21130 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21131 message.append("\n"); 21132 message.append("Actual output out (in double): "); 21133 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 21134 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 21135 message.append(" FAIL"); 21136 } 21137 message.append("\n"); 21138 message.append("Errors at"); 21139 } 21140 message.append(" ["); 21141 message.append(Integer.toString(i)); 21142 message.append(", "); 21143 message.append(Integer.toString(j)); 21144 message.append("]"); 21145 } 21146 } 21147 } 21148 assertFalse("Incorrect output for checkConvertHalf3Half3" + 21149 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21150 } 21151 checkConvertHalf4Half4()21152 private void checkConvertHalf4Half4() { 21153 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3538d816l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21154 try { 21155 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 21156 script.forEach_testConvertHalf4Half4Half4(inV, out); 21157 verifyResultsConvertHalf4Half4(inV, out, false); 21158 } catch (Exception e) { 21159 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Half4Half4: " + e.toString()); 21160 } 21161 try { 21162 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 21163 scriptRelaxed.forEach_testConvertHalf4Half4Half4(inV, out); 21164 verifyResultsConvertHalf4Half4(inV, out, true); 21165 } catch (Exception e) { 21166 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Half4Half4: " + e.toString()); 21167 } 21168 } 21169 verifyResultsConvertHalf4Half4(Allocation inV, Allocation out, boolean relaxed)21170 private void verifyResultsConvertHalf4Half4(Allocation inV, Allocation out, boolean relaxed) { 21171 short[] arrayInV = new short[INPUTSIZE * 4]; 21172 Arrays.fill(arrayInV, (short) 42); 21173 inV.copyTo(arrayInV); 21174 short[] arrayOut = new short[INPUTSIZE * 4]; 21175 Arrays.fill(arrayOut, (short) 42); 21176 out.copyTo(arrayOut); 21177 StringBuilder message = new StringBuilder(); 21178 boolean errorFound = false; 21179 for (int i = 0; i < INPUTSIZE; i++) { 21180 for (int j = 0; j < 4 ; j++) { 21181 // Extract the inputs. 21182 ArgumentsHalfHalf args = new ArgumentsHalfHalf(); 21183 args.inV = arrayInV[i * 4 + j]; 21184 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21185 // Figure out what the outputs should have been. 21186 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 21187 CoreMathVerifier.computeConvert(args, target); 21188 // Validate the outputs. 21189 boolean valid = true; 21190 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 21191 valid = false; 21192 } 21193 if (!valid) { 21194 if (!errorFound) { 21195 errorFound = true; 21196 message.append("Input inV: "); 21197 appendVariableToMessage(message, args.inV); 21198 message.append("\n"); 21199 message.append("Expected output out: "); 21200 appendVariableToMessage(message, args.out); 21201 message.append("\n"); 21202 message.append("Actual output out: "); 21203 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21204 message.append("\n"); 21205 message.append("Actual output out (in double): "); 21206 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 21207 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 21208 message.append(" FAIL"); 21209 } 21210 message.append("\n"); 21211 message.append("Errors at"); 21212 } 21213 message.append(" ["); 21214 message.append(Integer.toString(i)); 21215 message.append(", "); 21216 message.append(Integer.toString(j)); 21217 message.append("]"); 21218 } 21219 } 21220 } 21221 assertFalse("Incorrect output for checkConvertHalf4Half4" + 21222 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21223 } 21224 21225 public class ArgumentsHalfFloat { 21226 public short inV; 21227 public double inVDouble; 21228 public Target.Floaty out; 21229 } 21230 checkConvertHalf2Float2()21231 private void checkConvertHalf2Float2() { 21232 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbbc7b5dbl, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21233 try { 21234 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 21235 script.forEach_testConvertFloat2Half2Float2(inV, out); 21236 verifyResultsConvertHalf2Float2(inV, out, false); 21237 } catch (Exception e) { 21238 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Half2Float2: " + e.toString()); 21239 } 21240 try { 21241 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); 21242 scriptRelaxed.forEach_testConvertFloat2Half2Float2(inV, out); 21243 verifyResultsConvertHalf2Float2(inV, out, true); 21244 } catch (Exception e) { 21245 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Half2Float2: " + e.toString()); 21246 } 21247 } 21248 verifyResultsConvertHalf2Float2(Allocation inV, Allocation out, boolean relaxed)21249 private void verifyResultsConvertHalf2Float2(Allocation inV, Allocation out, boolean relaxed) { 21250 short[] arrayInV = new short[INPUTSIZE * 2]; 21251 Arrays.fill(arrayInV, (short) 42); 21252 inV.copyTo(arrayInV); 21253 float[] arrayOut = new float[INPUTSIZE * 2]; 21254 Arrays.fill(arrayOut, (float) 42); 21255 out.copyTo(arrayOut); 21256 StringBuilder message = new StringBuilder(); 21257 boolean errorFound = false; 21258 for (int i = 0; i < INPUTSIZE; i++) { 21259 for (int j = 0; j < 2 ; j++) { 21260 // Extract the inputs. 21261 ArgumentsHalfFloat args = new ArgumentsHalfFloat(); 21262 args.inV = arrayInV[i * 2 + j]; 21263 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21264 // Figure out what the outputs should have been. 21265 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 21266 CoreMathVerifier.computeConvert(args, target); 21267 // Validate the outputs. 21268 boolean valid = true; 21269 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 21270 valid = false; 21271 } 21272 if (!valid) { 21273 if (!errorFound) { 21274 errorFound = true; 21275 message.append("Input inV: "); 21276 appendVariableToMessage(message, args.inV); 21277 message.append("\n"); 21278 message.append("Expected output out: "); 21279 appendVariableToMessage(message, args.out); 21280 message.append("\n"); 21281 message.append("Actual output out: "); 21282 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21283 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 21284 message.append(" FAIL"); 21285 } 21286 message.append("\n"); 21287 message.append("Errors at"); 21288 } 21289 message.append(" ["); 21290 message.append(Integer.toString(i)); 21291 message.append(", "); 21292 message.append(Integer.toString(j)); 21293 message.append("]"); 21294 } 21295 } 21296 } 21297 assertFalse("Incorrect output for checkConvertHalf2Float2" + 21298 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21299 } 21300 checkConvertHalf3Float3()21301 private void checkConvertHalf3Float3() { 21302 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb1e2d6b9l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21303 try { 21304 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 21305 script.forEach_testConvertFloat3Half3Float3(inV, out); 21306 verifyResultsConvertHalf3Float3(inV, out, false); 21307 } catch (Exception e) { 21308 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Half3Float3: " + e.toString()); 21309 } 21310 try { 21311 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); 21312 scriptRelaxed.forEach_testConvertFloat3Half3Float3(inV, out); 21313 verifyResultsConvertHalf3Float3(inV, out, true); 21314 } catch (Exception e) { 21315 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Half3Float3: " + e.toString()); 21316 } 21317 } 21318 verifyResultsConvertHalf3Float3(Allocation inV, Allocation out, boolean relaxed)21319 private void verifyResultsConvertHalf3Float3(Allocation inV, Allocation out, boolean relaxed) { 21320 short[] arrayInV = new short[INPUTSIZE * 4]; 21321 Arrays.fill(arrayInV, (short) 42); 21322 inV.copyTo(arrayInV); 21323 float[] arrayOut = new float[INPUTSIZE * 4]; 21324 Arrays.fill(arrayOut, (float) 42); 21325 out.copyTo(arrayOut); 21326 StringBuilder message = new StringBuilder(); 21327 boolean errorFound = false; 21328 for (int i = 0; i < INPUTSIZE; i++) { 21329 for (int j = 0; j < 3 ; j++) { 21330 // Extract the inputs. 21331 ArgumentsHalfFloat args = new ArgumentsHalfFloat(); 21332 args.inV = arrayInV[i * 4 + j]; 21333 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21334 // Figure out what the outputs should have been. 21335 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 21336 CoreMathVerifier.computeConvert(args, target); 21337 // Validate the outputs. 21338 boolean valid = true; 21339 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21340 valid = false; 21341 } 21342 if (!valid) { 21343 if (!errorFound) { 21344 errorFound = true; 21345 message.append("Input inV: "); 21346 appendVariableToMessage(message, args.inV); 21347 message.append("\n"); 21348 message.append("Expected output out: "); 21349 appendVariableToMessage(message, args.out); 21350 message.append("\n"); 21351 message.append("Actual output out: "); 21352 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21353 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21354 message.append(" FAIL"); 21355 } 21356 message.append("\n"); 21357 message.append("Errors at"); 21358 } 21359 message.append(" ["); 21360 message.append(Integer.toString(i)); 21361 message.append(", "); 21362 message.append(Integer.toString(j)); 21363 message.append("]"); 21364 } 21365 } 21366 } 21367 assertFalse("Incorrect output for checkConvertHalf3Float3" + 21368 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21369 } 21370 checkConvertHalf4Float4()21371 private void checkConvertHalf4Float4() { 21372 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa7fdf797l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21373 try { 21374 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 21375 script.forEach_testConvertFloat4Half4Float4(inV, out); 21376 verifyResultsConvertHalf4Float4(inV, out, false); 21377 } catch (Exception e) { 21378 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Half4Float4: " + e.toString()); 21379 } 21380 try { 21381 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); 21382 scriptRelaxed.forEach_testConvertFloat4Half4Float4(inV, out); 21383 verifyResultsConvertHalf4Float4(inV, out, true); 21384 } catch (Exception e) { 21385 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Half4Float4: " + e.toString()); 21386 } 21387 } 21388 verifyResultsConvertHalf4Float4(Allocation inV, Allocation out, boolean relaxed)21389 private void verifyResultsConvertHalf4Float4(Allocation inV, Allocation out, boolean relaxed) { 21390 short[] arrayInV = new short[INPUTSIZE * 4]; 21391 Arrays.fill(arrayInV, (short) 42); 21392 inV.copyTo(arrayInV); 21393 float[] arrayOut = new float[INPUTSIZE * 4]; 21394 Arrays.fill(arrayOut, (float) 42); 21395 out.copyTo(arrayOut); 21396 StringBuilder message = new StringBuilder(); 21397 boolean errorFound = false; 21398 for (int i = 0; i < INPUTSIZE; i++) { 21399 for (int j = 0; j < 4 ; j++) { 21400 // Extract the inputs. 21401 ArgumentsHalfFloat args = new ArgumentsHalfFloat(); 21402 args.inV = arrayInV[i * 4 + j]; 21403 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21404 // Figure out what the outputs should have been. 21405 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed); 21406 CoreMathVerifier.computeConvert(args, target); 21407 // Validate the outputs. 21408 boolean valid = true; 21409 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21410 valid = false; 21411 } 21412 if (!valid) { 21413 if (!errorFound) { 21414 errorFound = true; 21415 message.append("Input inV: "); 21416 appendVariableToMessage(message, args.inV); 21417 message.append("\n"); 21418 message.append("Expected output out: "); 21419 appendVariableToMessage(message, args.out); 21420 message.append("\n"); 21421 message.append("Actual output out: "); 21422 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21423 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21424 message.append(" FAIL"); 21425 } 21426 message.append("\n"); 21427 message.append("Errors at"); 21428 } 21429 message.append(" ["); 21430 message.append(Integer.toString(i)); 21431 message.append(", "); 21432 message.append(Integer.toString(j)); 21433 message.append("]"); 21434 } 21435 } 21436 } 21437 assertFalse("Incorrect output for checkConvertHalf4Float4" + 21438 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21439 } 21440 21441 public class ArgumentsHalfDouble { 21442 public short inV; 21443 public double inVDouble; 21444 public Target.Floaty out; 21445 } 21446 checkConvertHalf2Double2()21447 private void checkConvertHalf2Double2() { 21448 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb2251ea8l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21449 try { 21450 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 21451 script.forEach_testConvertDouble2Half2Double2(inV, out); 21452 verifyResultsConvertHalf2Double2(inV, out, false); 21453 } catch (Exception e) { 21454 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Half2Double2: " + e.toString()); 21455 } 21456 try { 21457 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); 21458 scriptRelaxed.forEach_testConvertDouble2Half2Double2(inV, out); 21459 verifyResultsConvertHalf2Double2(inV, out, true); 21460 } catch (Exception e) { 21461 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Half2Double2: " + e.toString()); 21462 } 21463 } 21464 verifyResultsConvertHalf2Double2(Allocation inV, Allocation out, boolean relaxed)21465 private void verifyResultsConvertHalf2Double2(Allocation inV, Allocation out, boolean relaxed) { 21466 short[] arrayInV = new short[INPUTSIZE * 2]; 21467 Arrays.fill(arrayInV, (short) 42); 21468 inV.copyTo(arrayInV); 21469 double[] arrayOut = new double[INPUTSIZE * 2]; 21470 Arrays.fill(arrayOut, (double) 42); 21471 out.copyTo(arrayOut); 21472 StringBuilder message = new StringBuilder(); 21473 boolean errorFound = false; 21474 for (int i = 0; i < INPUTSIZE; i++) { 21475 for (int j = 0; j < 2 ; j++) { 21476 // Extract the inputs. 21477 ArgumentsHalfDouble args = new ArgumentsHalfDouble(); 21478 args.inV = arrayInV[i * 2 + j]; 21479 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21480 // Figure out what the outputs should have been. 21481 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 21482 CoreMathVerifier.computeConvert(args, target); 21483 // Validate the outputs. 21484 boolean valid = true; 21485 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 21486 valid = false; 21487 } 21488 if (!valid) { 21489 if (!errorFound) { 21490 errorFound = true; 21491 message.append("Input inV: "); 21492 appendVariableToMessage(message, args.inV); 21493 message.append("\n"); 21494 message.append("Expected output out: "); 21495 appendVariableToMessage(message, args.out); 21496 message.append("\n"); 21497 message.append("Actual output out: "); 21498 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21499 if (!args.out.couldBe(arrayOut[i * 2 + j])) { 21500 message.append(" FAIL"); 21501 } 21502 message.append("\n"); 21503 message.append("Errors at"); 21504 } 21505 message.append(" ["); 21506 message.append(Integer.toString(i)); 21507 message.append(", "); 21508 message.append(Integer.toString(j)); 21509 message.append("]"); 21510 } 21511 } 21512 } 21513 assertFalse("Incorrect output for checkConvertHalf2Double2" + 21514 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21515 } 21516 checkConvertHalf3Double3()21517 private void checkConvertHalf3Double3() { 21518 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x880afd4l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21519 try { 21520 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 21521 script.forEach_testConvertDouble3Half3Double3(inV, out); 21522 verifyResultsConvertHalf3Double3(inV, out, false); 21523 } catch (Exception e) { 21524 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Half3Double3: " + e.toString()); 21525 } 21526 try { 21527 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); 21528 scriptRelaxed.forEach_testConvertDouble3Half3Double3(inV, out); 21529 verifyResultsConvertHalf3Double3(inV, out, true); 21530 } catch (Exception e) { 21531 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Half3Double3: " + e.toString()); 21532 } 21533 } 21534 verifyResultsConvertHalf3Double3(Allocation inV, Allocation out, boolean relaxed)21535 private void verifyResultsConvertHalf3Double3(Allocation inV, Allocation out, boolean relaxed) { 21536 short[] arrayInV = new short[INPUTSIZE * 4]; 21537 Arrays.fill(arrayInV, (short) 42); 21538 inV.copyTo(arrayInV); 21539 double[] arrayOut = new double[INPUTSIZE * 4]; 21540 Arrays.fill(arrayOut, (double) 42); 21541 out.copyTo(arrayOut); 21542 StringBuilder message = new StringBuilder(); 21543 boolean errorFound = false; 21544 for (int i = 0; i < INPUTSIZE; i++) { 21545 for (int j = 0; j < 3 ; j++) { 21546 // Extract the inputs. 21547 ArgumentsHalfDouble args = new ArgumentsHalfDouble(); 21548 args.inV = arrayInV[i * 4 + j]; 21549 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21550 // Figure out what the outputs should have been. 21551 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 21552 CoreMathVerifier.computeConvert(args, target); 21553 // Validate the outputs. 21554 boolean valid = true; 21555 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21556 valid = false; 21557 } 21558 if (!valid) { 21559 if (!errorFound) { 21560 errorFound = true; 21561 message.append("Input inV: "); 21562 appendVariableToMessage(message, args.inV); 21563 message.append("\n"); 21564 message.append("Expected output out: "); 21565 appendVariableToMessage(message, args.out); 21566 message.append("\n"); 21567 message.append("Actual output out: "); 21568 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21569 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21570 message.append(" FAIL"); 21571 } 21572 message.append("\n"); 21573 message.append("Errors at"); 21574 } 21575 message.append(" ["); 21576 message.append(Integer.toString(i)); 21577 message.append(", "); 21578 message.append(Integer.toString(j)); 21579 message.append("]"); 21580 } 21581 } 21582 } 21583 assertFalse("Incorrect output for checkConvertHalf3Double3" + 21584 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21585 } 21586 checkConvertHalf4Double4()21587 private void checkConvertHalf4Double4() { 21588 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5edc4100l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 21589 try { 21590 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 21591 script.forEach_testConvertDouble4Half4Double4(inV, out); 21592 verifyResultsConvertHalf4Double4(inV, out, false); 21593 } catch (Exception e) { 21594 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Half4Double4: " + e.toString()); 21595 } 21596 try { 21597 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); 21598 scriptRelaxed.forEach_testConvertDouble4Half4Double4(inV, out); 21599 verifyResultsConvertHalf4Double4(inV, out, true); 21600 } catch (Exception e) { 21601 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Half4Double4: " + e.toString()); 21602 } 21603 } 21604 verifyResultsConvertHalf4Double4(Allocation inV, Allocation out, boolean relaxed)21605 private void verifyResultsConvertHalf4Double4(Allocation inV, Allocation out, boolean relaxed) { 21606 short[] arrayInV = new short[INPUTSIZE * 4]; 21607 Arrays.fill(arrayInV, (short) 42); 21608 inV.copyTo(arrayInV); 21609 double[] arrayOut = new double[INPUTSIZE * 4]; 21610 Arrays.fill(arrayOut, (double) 42); 21611 out.copyTo(arrayOut); 21612 StringBuilder message = new StringBuilder(); 21613 boolean errorFound = false; 21614 for (int i = 0; i < INPUTSIZE; i++) { 21615 for (int j = 0; j < 4 ; j++) { 21616 // Extract the inputs. 21617 ArgumentsHalfDouble args = new ArgumentsHalfDouble(); 21618 args.inV = arrayInV[i * 4 + j]; 21619 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21620 // Figure out what the outputs should have been. 21621 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.DOUBLE, relaxed); 21622 CoreMathVerifier.computeConvert(args, target); 21623 // Validate the outputs. 21624 boolean valid = true; 21625 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21626 valid = false; 21627 } 21628 if (!valid) { 21629 if (!errorFound) { 21630 errorFound = true; 21631 message.append("Input inV: "); 21632 appendVariableToMessage(message, args.inV); 21633 message.append("\n"); 21634 message.append("Expected output out: "); 21635 appendVariableToMessage(message, args.out); 21636 message.append("\n"); 21637 message.append("Actual output out: "); 21638 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21639 if (!args.out.couldBe(arrayOut[i * 4 + j])) { 21640 message.append(" FAIL"); 21641 } 21642 message.append("\n"); 21643 message.append("Errors at"); 21644 } 21645 message.append(" ["); 21646 message.append(Integer.toString(i)); 21647 message.append(", "); 21648 message.append(Integer.toString(j)); 21649 message.append("]"); 21650 } 21651 } 21652 } 21653 assertFalse("Incorrect output for checkConvertHalf4Double4" + 21654 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21655 } 21656 21657 public class ArgumentsHalfChar { 21658 public short inV; 21659 public double inVDouble; 21660 public byte out; 21661 } 21662 checkConvertHalf2Char2()21663 private void checkConvertHalf2Char2() { 21664 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf6709821l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 21665 try { 21666 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 21667 script.forEach_testConvertChar2Half2Char2(inV, out); 21668 verifyResultsConvertHalf2Char2(inV, out, false); 21669 } catch (Exception e) { 21670 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Half2Char2: " + e.toString()); 21671 } 21672 try { 21673 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); 21674 scriptRelaxed.forEach_testConvertChar2Half2Char2(inV, out); 21675 verifyResultsConvertHalf2Char2(inV, out, true); 21676 } catch (Exception e) { 21677 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Half2Char2: " + e.toString()); 21678 } 21679 } 21680 verifyResultsConvertHalf2Char2(Allocation inV, Allocation out, boolean relaxed)21681 private void verifyResultsConvertHalf2Char2(Allocation inV, Allocation out, boolean relaxed) { 21682 short[] arrayInV = new short[INPUTSIZE * 2]; 21683 Arrays.fill(arrayInV, (short) 42); 21684 inV.copyTo(arrayInV); 21685 byte[] arrayOut = new byte[INPUTSIZE * 2]; 21686 Arrays.fill(arrayOut, (byte) 42); 21687 out.copyTo(arrayOut); 21688 StringBuilder message = new StringBuilder(); 21689 boolean errorFound = false; 21690 for (int i = 0; i < INPUTSIZE; i++) { 21691 for (int j = 0; j < 2 ; j++) { 21692 // Extract the inputs. 21693 ArgumentsHalfChar args = new ArgumentsHalfChar(); 21694 args.inV = arrayInV[i * 2 + j]; 21695 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21696 // Figure out what the outputs should have been. 21697 CoreMathVerifier.computeConvert(args); 21698 // Validate the outputs. 21699 boolean valid = true; 21700 if (args.out != arrayOut[i * 2 + j]) { 21701 valid = false; 21702 } 21703 if (!valid) { 21704 if (!errorFound) { 21705 errorFound = true; 21706 message.append("Input inV: "); 21707 appendVariableToMessage(message, args.inV); 21708 message.append("\n"); 21709 message.append("Expected output out: "); 21710 appendVariableToMessage(message, args.out); 21711 message.append("\n"); 21712 message.append("Actual output out: "); 21713 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21714 if (args.out != arrayOut[i * 2 + j]) { 21715 message.append(" FAIL"); 21716 } 21717 message.append("\n"); 21718 message.append("Errors at"); 21719 } 21720 message.append(" ["); 21721 message.append(Integer.toString(i)); 21722 message.append(", "); 21723 message.append(Integer.toString(j)); 21724 message.append("]"); 21725 } 21726 } 21727 } 21728 assertFalse("Incorrect output for checkConvertHalf2Char2" + 21729 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21730 } 21731 checkConvertHalf3Char3()21732 private void checkConvertHalf3Char3() { 21733 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x55785d15l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 21734 try { 21735 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 21736 script.forEach_testConvertChar3Half3Char3(inV, out); 21737 verifyResultsConvertHalf3Char3(inV, out, false); 21738 } catch (Exception e) { 21739 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Half3Char3: " + e.toString()); 21740 } 21741 try { 21742 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); 21743 scriptRelaxed.forEach_testConvertChar3Half3Char3(inV, out); 21744 verifyResultsConvertHalf3Char3(inV, out, true); 21745 } catch (Exception e) { 21746 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Half3Char3: " + e.toString()); 21747 } 21748 } 21749 verifyResultsConvertHalf3Char3(Allocation inV, Allocation out, boolean relaxed)21750 private void verifyResultsConvertHalf3Char3(Allocation inV, Allocation out, boolean relaxed) { 21751 short[] arrayInV = new short[INPUTSIZE * 4]; 21752 Arrays.fill(arrayInV, (short) 42); 21753 inV.copyTo(arrayInV); 21754 byte[] arrayOut = new byte[INPUTSIZE * 4]; 21755 Arrays.fill(arrayOut, (byte) 42); 21756 out.copyTo(arrayOut); 21757 StringBuilder message = new StringBuilder(); 21758 boolean errorFound = false; 21759 for (int i = 0; i < INPUTSIZE; i++) { 21760 for (int j = 0; j < 3 ; j++) { 21761 // Extract the inputs. 21762 ArgumentsHalfChar args = new ArgumentsHalfChar(); 21763 args.inV = arrayInV[i * 4 + j]; 21764 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21765 // Figure out what the outputs should have been. 21766 CoreMathVerifier.computeConvert(args); 21767 // Validate the outputs. 21768 boolean valid = true; 21769 if (args.out != arrayOut[i * 4 + j]) { 21770 valid = false; 21771 } 21772 if (!valid) { 21773 if (!errorFound) { 21774 errorFound = true; 21775 message.append("Input inV: "); 21776 appendVariableToMessage(message, args.inV); 21777 message.append("\n"); 21778 message.append("Expected output out: "); 21779 appendVariableToMessage(message, args.out); 21780 message.append("\n"); 21781 message.append("Actual output out: "); 21782 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21783 if (args.out != arrayOut[i * 4 + j]) { 21784 message.append(" FAIL"); 21785 } 21786 message.append("\n"); 21787 message.append("Errors at"); 21788 } 21789 message.append(" ["); 21790 message.append(Integer.toString(i)); 21791 message.append(", "); 21792 message.append(Integer.toString(j)); 21793 message.append("]"); 21794 } 21795 } 21796 } 21797 assertFalse("Incorrect output for checkConvertHalf3Char3" + 21798 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21799 } 21800 checkConvertHalf4Char4()21801 private void checkConvertHalf4Char4() { 21802 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb4802209l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); 21803 try { 21804 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 21805 script.forEach_testConvertChar4Half4Char4(inV, out); 21806 verifyResultsConvertHalf4Char4(inV, out, false); 21807 } catch (Exception e) { 21808 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Half4Char4: " + e.toString()); 21809 } 21810 try { 21811 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); 21812 scriptRelaxed.forEach_testConvertChar4Half4Char4(inV, out); 21813 verifyResultsConvertHalf4Char4(inV, out, true); 21814 } catch (Exception e) { 21815 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Half4Char4: " + e.toString()); 21816 } 21817 } 21818 verifyResultsConvertHalf4Char4(Allocation inV, Allocation out, boolean relaxed)21819 private void verifyResultsConvertHalf4Char4(Allocation inV, Allocation out, boolean relaxed) { 21820 short[] arrayInV = new short[INPUTSIZE * 4]; 21821 Arrays.fill(arrayInV, (short) 42); 21822 inV.copyTo(arrayInV); 21823 byte[] arrayOut = new byte[INPUTSIZE * 4]; 21824 Arrays.fill(arrayOut, (byte) 42); 21825 out.copyTo(arrayOut); 21826 StringBuilder message = new StringBuilder(); 21827 boolean errorFound = false; 21828 for (int i = 0; i < INPUTSIZE; i++) { 21829 for (int j = 0; j < 4 ; j++) { 21830 // Extract the inputs. 21831 ArgumentsHalfChar args = new ArgumentsHalfChar(); 21832 args.inV = arrayInV[i * 4 + j]; 21833 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21834 // Figure out what the outputs should have been. 21835 CoreMathVerifier.computeConvert(args); 21836 // Validate the outputs. 21837 boolean valid = true; 21838 if (args.out != arrayOut[i * 4 + j]) { 21839 valid = false; 21840 } 21841 if (!valid) { 21842 if (!errorFound) { 21843 errorFound = true; 21844 message.append("Input inV: "); 21845 appendVariableToMessage(message, args.inV); 21846 message.append("\n"); 21847 message.append("Expected output out: "); 21848 appendVariableToMessage(message, args.out); 21849 message.append("\n"); 21850 message.append("Actual output out: "); 21851 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21852 if (args.out != arrayOut[i * 4 + j]) { 21853 message.append(" FAIL"); 21854 } 21855 message.append("\n"); 21856 message.append("Errors at"); 21857 } 21858 message.append(" ["); 21859 message.append(Integer.toString(i)); 21860 message.append(", "); 21861 message.append(Integer.toString(j)); 21862 message.append("]"); 21863 } 21864 } 21865 } 21866 assertFalse("Incorrect output for checkConvertHalf4Char4" + 21867 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21868 } 21869 21870 public class ArgumentsHalfUchar { 21871 public short inV; 21872 public double inVDouble; 21873 public byte out; 21874 } 21875 checkConvertHalf2Uchar2()21876 private void checkConvertHalf2Uchar2() { 21877 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6869a68el, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 21878 try { 21879 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 21880 script.forEach_testConvertUchar2Half2Uchar2(inV, out); 21881 verifyResultsConvertHalf2Uchar2(inV, out, false); 21882 } catch (Exception e) { 21883 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Half2Uchar2: " + e.toString()); 21884 } 21885 try { 21886 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); 21887 scriptRelaxed.forEach_testConvertUchar2Half2Uchar2(inV, out); 21888 verifyResultsConvertHalf2Uchar2(inV, out, true); 21889 } catch (Exception e) { 21890 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Half2Uchar2: " + e.toString()); 21891 } 21892 } 21893 verifyResultsConvertHalf2Uchar2(Allocation inV, Allocation out, boolean relaxed)21894 private void verifyResultsConvertHalf2Uchar2(Allocation inV, Allocation out, boolean relaxed) { 21895 short[] arrayInV = new short[INPUTSIZE * 2]; 21896 Arrays.fill(arrayInV, (short) 42); 21897 inV.copyTo(arrayInV); 21898 byte[] arrayOut = new byte[INPUTSIZE * 2]; 21899 Arrays.fill(arrayOut, (byte) 42); 21900 out.copyTo(arrayOut); 21901 StringBuilder message = new StringBuilder(); 21902 boolean errorFound = false; 21903 for (int i = 0; i < INPUTSIZE; i++) { 21904 for (int j = 0; j < 2 ; j++) { 21905 // Extract the inputs. 21906 ArgumentsHalfUchar args = new ArgumentsHalfUchar(); 21907 args.inV = arrayInV[i * 2 + j]; 21908 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21909 // Figure out what the outputs should have been. 21910 CoreMathVerifier.computeConvert(args); 21911 // Validate the outputs. 21912 boolean valid = true; 21913 if (args.out != arrayOut[i * 2 + j]) { 21914 valid = false; 21915 } 21916 if (!valid) { 21917 if (!errorFound) { 21918 errorFound = true; 21919 message.append("Input inV: "); 21920 appendVariableToMessage(message, args.inV); 21921 message.append("\n"); 21922 message.append("Expected output out: "); 21923 appendVariableToMessage(message, args.out); 21924 message.append("\n"); 21925 message.append("Actual output out: "); 21926 appendVariableToMessage(message, arrayOut[i * 2 + j]); 21927 if (args.out != arrayOut[i * 2 + j]) { 21928 message.append(" FAIL"); 21929 } 21930 message.append("\n"); 21931 message.append("Errors at"); 21932 } 21933 message.append(" ["); 21934 message.append(Integer.toString(i)); 21935 message.append(", "); 21936 message.append(Integer.toString(j)); 21937 message.append("]"); 21938 } 21939 } 21940 } 21941 assertFalse("Incorrect output for checkConvertHalf2Uchar2" + 21942 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 21943 } 21944 checkConvertHalf3Uchar3()21945 private void checkConvertHalf3Uchar3() { 21946 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5e84c76cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 21947 try { 21948 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 21949 script.forEach_testConvertUchar3Half3Uchar3(inV, out); 21950 verifyResultsConvertHalf3Uchar3(inV, out, false); 21951 } catch (Exception e) { 21952 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Half3Uchar3: " + e.toString()); 21953 } 21954 try { 21955 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); 21956 scriptRelaxed.forEach_testConvertUchar3Half3Uchar3(inV, out); 21957 verifyResultsConvertHalf3Uchar3(inV, out, true); 21958 } catch (Exception e) { 21959 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Half3Uchar3: " + e.toString()); 21960 } 21961 } 21962 verifyResultsConvertHalf3Uchar3(Allocation inV, Allocation out, boolean relaxed)21963 private void verifyResultsConvertHalf3Uchar3(Allocation inV, Allocation out, boolean relaxed) { 21964 short[] arrayInV = new short[INPUTSIZE * 4]; 21965 Arrays.fill(arrayInV, (short) 42); 21966 inV.copyTo(arrayInV); 21967 byte[] arrayOut = new byte[INPUTSIZE * 4]; 21968 Arrays.fill(arrayOut, (byte) 42); 21969 out.copyTo(arrayOut); 21970 StringBuilder message = new StringBuilder(); 21971 boolean errorFound = false; 21972 for (int i = 0; i < INPUTSIZE; i++) { 21973 for (int j = 0; j < 3 ; j++) { 21974 // Extract the inputs. 21975 ArgumentsHalfUchar args = new ArgumentsHalfUchar(); 21976 args.inV = arrayInV[i * 4 + j]; 21977 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 21978 // Figure out what the outputs should have been. 21979 CoreMathVerifier.computeConvert(args); 21980 // Validate the outputs. 21981 boolean valid = true; 21982 if (args.out != arrayOut[i * 4 + j]) { 21983 valid = false; 21984 } 21985 if (!valid) { 21986 if (!errorFound) { 21987 errorFound = true; 21988 message.append("Input inV: "); 21989 appendVariableToMessage(message, args.inV); 21990 message.append("\n"); 21991 message.append("Expected output out: "); 21992 appendVariableToMessage(message, args.out); 21993 message.append("\n"); 21994 message.append("Actual output out: "); 21995 appendVariableToMessage(message, arrayOut[i * 4 + j]); 21996 if (args.out != arrayOut[i * 4 + j]) { 21997 message.append(" FAIL"); 21998 } 21999 message.append("\n"); 22000 message.append("Errors at"); 22001 } 22002 message.append(" ["); 22003 message.append(Integer.toString(i)); 22004 message.append(", "); 22005 message.append(Integer.toString(j)); 22006 message.append("]"); 22007 } 22008 } 22009 } 22010 assertFalse("Incorrect output for checkConvertHalf3Uchar3" + 22011 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22012 } 22013 checkConvertHalf4Uchar4()22014 private void checkConvertHalf4Uchar4() { 22015 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x549fe84al, 0.0000000000000000000e+00, 2.5500000000000000000e+02); 22016 try { 22017 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 22018 script.forEach_testConvertUchar4Half4Uchar4(inV, out); 22019 verifyResultsConvertHalf4Uchar4(inV, out, false); 22020 } catch (Exception e) { 22021 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Half4Uchar4: " + e.toString()); 22022 } 22023 try { 22024 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); 22025 scriptRelaxed.forEach_testConvertUchar4Half4Uchar4(inV, out); 22026 verifyResultsConvertHalf4Uchar4(inV, out, true); 22027 } catch (Exception e) { 22028 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Half4Uchar4: " + e.toString()); 22029 } 22030 } 22031 verifyResultsConvertHalf4Uchar4(Allocation inV, Allocation out, boolean relaxed)22032 private void verifyResultsConvertHalf4Uchar4(Allocation inV, Allocation out, boolean relaxed) { 22033 short[] arrayInV = new short[INPUTSIZE * 4]; 22034 Arrays.fill(arrayInV, (short) 42); 22035 inV.copyTo(arrayInV); 22036 byte[] arrayOut = new byte[INPUTSIZE * 4]; 22037 Arrays.fill(arrayOut, (byte) 42); 22038 out.copyTo(arrayOut); 22039 StringBuilder message = new StringBuilder(); 22040 boolean errorFound = false; 22041 for (int i = 0; i < INPUTSIZE; i++) { 22042 for (int j = 0; j < 4 ; j++) { 22043 // Extract the inputs. 22044 ArgumentsHalfUchar args = new ArgumentsHalfUchar(); 22045 args.inV = arrayInV[i * 4 + j]; 22046 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22047 // Figure out what the outputs should have been. 22048 CoreMathVerifier.computeConvert(args); 22049 // Validate the outputs. 22050 boolean valid = true; 22051 if (args.out != arrayOut[i * 4 + j]) { 22052 valid = false; 22053 } 22054 if (!valid) { 22055 if (!errorFound) { 22056 errorFound = true; 22057 message.append("Input inV: "); 22058 appendVariableToMessage(message, args.inV); 22059 message.append("\n"); 22060 message.append("Expected output out: "); 22061 appendVariableToMessage(message, args.out); 22062 message.append("\n"); 22063 message.append("Actual output out: "); 22064 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22065 if (args.out != arrayOut[i * 4 + j]) { 22066 message.append(" FAIL"); 22067 } 22068 message.append("\n"); 22069 message.append("Errors at"); 22070 } 22071 message.append(" ["); 22072 message.append(Integer.toString(i)); 22073 message.append(", "); 22074 message.append(Integer.toString(j)); 22075 message.append("]"); 22076 } 22077 } 22078 } 22079 assertFalse("Incorrect output for checkConvertHalf4Uchar4" + 22080 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22081 } 22082 22083 public class ArgumentsHalfShort { 22084 public short inV; 22085 public double inVDouble; 22086 public short out; 22087 } 22088 checkConvertHalf2Short2()22089 private void checkConvertHalf2Short2() { 22090 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfd7771a7l, -3.2753000000000000000e+04, 3.2752000000000000000e+04); 22091 try { 22092 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 22093 script.forEach_testConvertShort2Half2Short2(inV, out); 22094 verifyResultsConvertHalf2Short2(inV, out, false); 22095 } catch (Exception e) { 22096 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Half2Short2: " + e.toString()); 22097 } 22098 try { 22099 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); 22100 scriptRelaxed.forEach_testConvertShort2Half2Short2(inV, out); 22101 verifyResultsConvertHalf2Short2(inV, out, true); 22102 } catch (Exception e) { 22103 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Half2Short2: " + e.toString()); 22104 } 22105 } 22106 verifyResultsConvertHalf2Short2(Allocation inV, Allocation out, boolean relaxed)22107 private void verifyResultsConvertHalf2Short2(Allocation inV, Allocation out, boolean relaxed) { 22108 short[] arrayInV = new short[INPUTSIZE * 2]; 22109 Arrays.fill(arrayInV, (short) 42); 22110 inV.copyTo(arrayInV); 22111 short[] arrayOut = new short[INPUTSIZE * 2]; 22112 Arrays.fill(arrayOut, (short) 42); 22113 out.copyTo(arrayOut); 22114 StringBuilder message = new StringBuilder(); 22115 boolean errorFound = false; 22116 for (int i = 0; i < INPUTSIZE; i++) { 22117 for (int j = 0; j < 2 ; j++) { 22118 // Extract the inputs. 22119 ArgumentsHalfShort args = new ArgumentsHalfShort(); 22120 args.inV = arrayInV[i * 2 + j]; 22121 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22122 // Figure out what the outputs should have been. 22123 CoreMathVerifier.computeConvert(args); 22124 // Validate the outputs. 22125 boolean valid = true; 22126 if (args.out != arrayOut[i * 2 + j]) { 22127 valid = false; 22128 } 22129 if (!valid) { 22130 if (!errorFound) { 22131 errorFound = true; 22132 message.append("Input inV: "); 22133 appendVariableToMessage(message, args.inV); 22134 message.append("\n"); 22135 message.append("Expected output out: "); 22136 appendVariableToMessage(message, args.out); 22137 message.append("\n"); 22138 message.append("Actual output out: "); 22139 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22140 if (args.out != arrayOut[i * 2 + j]) { 22141 message.append(" FAIL"); 22142 } 22143 message.append("\n"); 22144 message.append("Errors at"); 22145 } 22146 message.append(" ["); 22147 message.append(Integer.toString(i)); 22148 message.append(", "); 22149 message.append(Integer.toString(j)); 22150 message.append("]"); 22151 } 22152 } 22153 } 22154 assertFalse("Incorrect output for checkConvertHalf2Short2" + 22155 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22156 } 22157 checkConvertHalf3Short3()22158 private void checkConvertHalf3Short3() { 22159 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf3929285l, -3.2753000000000000000e+04, 3.2752000000000000000e+04); 22160 try { 22161 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 22162 script.forEach_testConvertShort3Half3Short3(inV, out); 22163 verifyResultsConvertHalf3Short3(inV, out, false); 22164 } catch (Exception e) { 22165 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Half3Short3: " + e.toString()); 22166 } 22167 try { 22168 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); 22169 scriptRelaxed.forEach_testConvertShort3Half3Short3(inV, out); 22170 verifyResultsConvertHalf3Short3(inV, out, true); 22171 } catch (Exception e) { 22172 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Half3Short3: " + e.toString()); 22173 } 22174 } 22175 verifyResultsConvertHalf3Short3(Allocation inV, Allocation out, boolean relaxed)22176 private void verifyResultsConvertHalf3Short3(Allocation inV, Allocation out, boolean relaxed) { 22177 short[] arrayInV = new short[INPUTSIZE * 4]; 22178 Arrays.fill(arrayInV, (short) 42); 22179 inV.copyTo(arrayInV); 22180 short[] arrayOut = new short[INPUTSIZE * 4]; 22181 Arrays.fill(arrayOut, (short) 42); 22182 out.copyTo(arrayOut); 22183 StringBuilder message = new StringBuilder(); 22184 boolean errorFound = false; 22185 for (int i = 0; i < INPUTSIZE; i++) { 22186 for (int j = 0; j < 3 ; j++) { 22187 // Extract the inputs. 22188 ArgumentsHalfShort args = new ArgumentsHalfShort(); 22189 args.inV = arrayInV[i * 4 + j]; 22190 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22191 // Figure out what the outputs should have been. 22192 CoreMathVerifier.computeConvert(args); 22193 // Validate the outputs. 22194 boolean valid = true; 22195 if (args.out != arrayOut[i * 4 + j]) { 22196 valid = false; 22197 } 22198 if (!valid) { 22199 if (!errorFound) { 22200 errorFound = true; 22201 message.append("Input inV: "); 22202 appendVariableToMessage(message, args.inV); 22203 message.append("\n"); 22204 message.append("Expected output out: "); 22205 appendVariableToMessage(message, args.out); 22206 message.append("\n"); 22207 message.append("Actual output out: "); 22208 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22209 if (args.out != arrayOut[i * 4 + j]) { 22210 message.append(" FAIL"); 22211 } 22212 message.append("\n"); 22213 message.append("Errors at"); 22214 } 22215 message.append(" ["); 22216 message.append(Integer.toString(i)); 22217 message.append(", "); 22218 message.append(Integer.toString(j)); 22219 message.append("]"); 22220 } 22221 } 22222 } 22223 assertFalse("Incorrect output for checkConvertHalf3Short3" + 22224 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22225 } 22226 checkConvertHalf4Short4()22227 private void checkConvertHalf4Short4() { 22228 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe9adb363l, -3.2753000000000000000e+04, 3.2752000000000000000e+04); 22229 try { 22230 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 22231 script.forEach_testConvertShort4Half4Short4(inV, out); 22232 verifyResultsConvertHalf4Short4(inV, out, false); 22233 } catch (Exception e) { 22234 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Half4Short4: " + e.toString()); 22235 } 22236 try { 22237 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); 22238 scriptRelaxed.forEach_testConvertShort4Half4Short4(inV, out); 22239 verifyResultsConvertHalf4Short4(inV, out, true); 22240 } catch (Exception e) { 22241 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Half4Short4: " + e.toString()); 22242 } 22243 } 22244 verifyResultsConvertHalf4Short4(Allocation inV, Allocation out, boolean relaxed)22245 private void verifyResultsConvertHalf4Short4(Allocation inV, Allocation out, boolean relaxed) { 22246 short[] arrayInV = new short[INPUTSIZE * 4]; 22247 Arrays.fill(arrayInV, (short) 42); 22248 inV.copyTo(arrayInV); 22249 short[] arrayOut = new short[INPUTSIZE * 4]; 22250 Arrays.fill(arrayOut, (short) 42); 22251 out.copyTo(arrayOut); 22252 StringBuilder message = new StringBuilder(); 22253 boolean errorFound = false; 22254 for (int i = 0; i < INPUTSIZE; i++) { 22255 for (int j = 0; j < 4 ; j++) { 22256 // Extract the inputs. 22257 ArgumentsHalfShort args = new ArgumentsHalfShort(); 22258 args.inV = arrayInV[i * 4 + j]; 22259 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22260 // Figure out what the outputs should have been. 22261 CoreMathVerifier.computeConvert(args); 22262 // Validate the outputs. 22263 boolean valid = true; 22264 if (args.out != arrayOut[i * 4 + j]) { 22265 valid = false; 22266 } 22267 if (!valid) { 22268 if (!errorFound) { 22269 errorFound = true; 22270 message.append("Input inV: "); 22271 appendVariableToMessage(message, args.inV); 22272 message.append("\n"); 22273 message.append("Expected output out: "); 22274 appendVariableToMessage(message, args.out); 22275 message.append("\n"); 22276 message.append("Actual output out: "); 22277 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22278 if (args.out != arrayOut[i * 4 + j]) { 22279 message.append(" FAIL"); 22280 } 22281 message.append("\n"); 22282 message.append("Errors at"); 22283 } 22284 message.append(" ["); 22285 message.append(Integer.toString(i)); 22286 message.append(", "); 22287 message.append(Integer.toString(j)); 22288 message.append("]"); 22289 } 22290 } 22291 } 22292 assertFalse("Incorrect output for checkConvertHalf4Short4" + 22293 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22294 } 22295 22296 public class ArgumentsHalfUshort { 22297 public short inV; 22298 public double inVDouble; 22299 public short out; 22300 } 22301 checkConvertHalf2Ushort2()22302 private void checkConvertHalf2Ushort2() { 22303 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x224cddf6l, 0.0000000000000000000e+00, 6.5504000000000000000e+04); 22304 try { 22305 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 22306 script.forEach_testConvertUshort2Half2Ushort2(inV, out); 22307 verifyResultsConvertHalf2Ushort2(inV, out, false); 22308 } catch (Exception e) { 22309 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Half2Ushort2: " + e.toString()); 22310 } 22311 try { 22312 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); 22313 scriptRelaxed.forEach_testConvertUshort2Half2Ushort2(inV, out); 22314 verifyResultsConvertHalf2Ushort2(inV, out, true); 22315 } catch (Exception e) { 22316 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Half2Ushort2: " + e.toString()); 22317 } 22318 } 22319 verifyResultsConvertHalf2Ushort2(Allocation inV, Allocation out, boolean relaxed)22320 private void verifyResultsConvertHalf2Ushort2(Allocation inV, Allocation out, boolean relaxed) { 22321 short[] arrayInV = new short[INPUTSIZE * 2]; 22322 Arrays.fill(arrayInV, (short) 42); 22323 inV.copyTo(arrayInV); 22324 short[] arrayOut = new short[INPUTSIZE * 2]; 22325 Arrays.fill(arrayOut, (short) 42); 22326 out.copyTo(arrayOut); 22327 StringBuilder message = new StringBuilder(); 22328 boolean errorFound = false; 22329 for (int i = 0; i < INPUTSIZE; i++) { 22330 for (int j = 0; j < 2 ; j++) { 22331 // Extract the inputs. 22332 ArgumentsHalfUshort args = new ArgumentsHalfUshort(); 22333 args.inV = arrayInV[i * 2 + j]; 22334 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22335 // Figure out what the outputs should have been. 22336 CoreMathVerifier.computeConvert(args); 22337 // Validate the outputs. 22338 boolean valid = true; 22339 if (args.out != arrayOut[i * 2 + j]) { 22340 valid = false; 22341 } 22342 if (!valid) { 22343 if (!errorFound) { 22344 errorFound = true; 22345 message.append("Input inV: "); 22346 appendVariableToMessage(message, args.inV); 22347 message.append("\n"); 22348 message.append("Expected output out: "); 22349 appendVariableToMessage(message, args.out); 22350 message.append("\n"); 22351 message.append("Actual output out: "); 22352 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22353 if (args.out != arrayOut[i * 2 + j]) { 22354 message.append(" FAIL"); 22355 } 22356 message.append("\n"); 22357 message.append("Errors at"); 22358 } 22359 message.append(" ["); 22360 message.append(Integer.toString(i)); 22361 message.append(", "); 22362 message.append(Integer.toString(j)); 22363 message.append("]"); 22364 } 22365 } 22366 } 22367 assertFalse("Incorrect output for checkConvertHalf2Ushort2" + 22368 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22369 } 22370 checkConvertHalf3Ushort3()22371 private void checkConvertHalf3Ushort3() { 22372 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x78a86f22l, 0.0000000000000000000e+00, 6.5504000000000000000e+04); 22373 try { 22374 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 22375 script.forEach_testConvertUshort3Half3Ushort3(inV, out); 22376 verifyResultsConvertHalf3Ushort3(inV, out, false); 22377 } catch (Exception e) { 22378 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Half3Ushort3: " + e.toString()); 22379 } 22380 try { 22381 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); 22382 scriptRelaxed.forEach_testConvertUshort3Half3Ushort3(inV, out); 22383 verifyResultsConvertHalf3Ushort3(inV, out, true); 22384 } catch (Exception e) { 22385 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Half3Ushort3: " + e.toString()); 22386 } 22387 } 22388 verifyResultsConvertHalf3Ushort3(Allocation inV, Allocation out, boolean relaxed)22389 private void verifyResultsConvertHalf3Ushort3(Allocation inV, Allocation out, boolean relaxed) { 22390 short[] arrayInV = new short[INPUTSIZE * 4]; 22391 Arrays.fill(arrayInV, (short) 42); 22392 inV.copyTo(arrayInV); 22393 short[] arrayOut = new short[INPUTSIZE * 4]; 22394 Arrays.fill(arrayOut, (short) 42); 22395 out.copyTo(arrayOut); 22396 StringBuilder message = new StringBuilder(); 22397 boolean errorFound = false; 22398 for (int i = 0; i < INPUTSIZE; i++) { 22399 for (int j = 0; j < 3 ; j++) { 22400 // Extract the inputs. 22401 ArgumentsHalfUshort args = new ArgumentsHalfUshort(); 22402 args.inV = arrayInV[i * 4 + j]; 22403 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22404 // Figure out what the outputs should have been. 22405 CoreMathVerifier.computeConvert(args); 22406 // Validate the outputs. 22407 boolean valid = true; 22408 if (args.out != arrayOut[i * 4 + j]) { 22409 valid = false; 22410 } 22411 if (!valid) { 22412 if (!errorFound) { 22413 errorFound = true; 22414 message.append("Input inV: "); 22415 appendVariableToMessage(message, args.inV); 22416 message.append("\n"); 22417 message.append("Expected output out: "); 22418 appendVariableToMessage(message, args.out); 22419 message.append("\n"); 22420 message.append("Actual output out: "); 22421 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22422 if (args.out != arrayOut[i * 4 + j]) { 22423 message.append(" FAIL"); 22424 } 22425 message.append("\n"); 22426 message.append("Errors at"); 22427 } 22428 message.append(" ["); 22429 message.append(Integer.toString(i)); 22430 message.append(", "); 22431 message.append(Integer.toString(j)); 22432 message.append("]"); 22433 } 22434 } 22435 } 22436 assertFalse("Incorrect output for checkConvertHalf3Ushort3" + 22437 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22438 } 22439 checkConvertHalf4Ushort4()22440 private void checkConvertHalf4Ushort4() { 22441 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcf04004el, 0.0000000000000000000e+00, 6.5504000000000000000e+04); 22442 try { 22443 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 22444 script.forEach_testConvertUshort4Half4Ushort4(inV, out); 22445 verifyResultsConvertHalf4Ushort4(inV, out, false); 22446 } catch (Exception e) { 22447 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Half4Ushort4: " + e.toString()); 22448 } 22449 try { 22450 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); 22451 scriptRelaxed.forEach_testConvertUshort4Half4Ushort4(inV, out); 22452 verifyResultsConvertHalf4Ushort4(inV, out, true); 22453 } catch (Exception e) { 22454 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Half4Ushort4: " + e.toString()); 22455 } 22456 } 22457 verifyResultsConvertHalf4Ushort4(Allocation inV, Allocation out, boolean relaxed)22458 private void verifyResultsConvertHalf4Ushort4(Allocation inV, Allocation out, boolean relaxed) { 22459 short[] arrayInV = new short[INPUTSIZE * 4]; 22460 Arrays.fill(arrayInV, (short) 42); 22461 inV.copyTo(arrayInV); 22462 short[] arrayOut = new short[INPUTSIZE * 4]; 22463 Arrays.fill(arrayOut, (short) 42); 22464 out.copyTo(arrayOut); 22465 StringBuilder message = new StringBuilder(); 22466 boolean errorFound = false; 22467 for (int i = 0; i < INPUTSIZE; i++) { 22468 for (int j = 0; j < 4 ; j++) { 22469 // Extract the inputs. 22470 ArgumentsHalfUshort args = new ArgumentsHalfUshort(); 22471 args.inV = arrayInV[i * 4 + j]; 22472 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22473 // Figure out what the outputs should have been. 22474 CoreMathVerifier.computeConvert(args); 22475 // Validate the outputs. 22476 boolean valid = true; 22477 if (args.out != arrayOut[i * 4 + j]) { 22478 valid = false; 22479 } 22480 if (!valid) { 22481 if (!errorFound) { 22482 errorFound = true; 22483 message.append("Input inV: "); 22484 appendVariableToMessage(message, args.inV); 22485 message.append("\n"); 22486 message.append("Expected output out: "); 22487 appendVariableToMessage(message, args.out); 22488 message.append("\n"); 22489 message.append("Actual output out: "); 22490 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22491 if (args.out != arrayOut[i * 4 + j]) { 22492 message.append(" FAIL"); 22493 } 22494 message.append("\n"); 22495 message.append("Errors at"); 22496 } 22497 message.append(" ["); 22498 message.append(Integer.toString(i)); 22499 message.append(", "); 22500 message.append(Integer.toString(j)); 22501 message.append("]"); 22502 } 22503 } 22504 } 22505 assertFalse("Incorrect output for checkConvertHalf4Ushort4" + 22506 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22507 } 22508 22509 public class ArgumentsHalfInt { 22510 public short inV; 22511 public double inVDouble; 22512 public int out; 22513 } 22514 checkConvertHalf2Int2()22515 private void checkConvertHalf2Int2() { 22516 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xdcfe841al, -2.1464350730000000000e+09, 2.1464350720000000000e+09); 22517 try { 22518 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 22519 script.forEach_testConvertInt2Half2Int2(inV, out); 22520 verifyResultsConvertHalf2Int2(inV, out, false); 22521 } catch (Exception e) { 22522 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Half2Int2: " + e.toString()); 22523 } 22524 try { 22525 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); 22526 scriptRelaxed.forEach_testConvertInt2Half2Int2(inV, out); 22527 verifyResultsConvertHalf2Int2(inV, out, true); 22528 } catch (Exception e) { 22529 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Half2Int2: " + e.toString()); 22530 } 22531 } 22532 verifyResultsConvertHalf2Int2(Allocation inV, Allocation out, boolean relaxed)22533 private void verifyResultsConvertHalf2Int2(Allocation inV, Allocation out, boolean relaxed) { 22534 short[] arrayInV = new short[INPUTSIZE * 2]; 22535 Arrays.fill(arrayInV, (short) 42); 22536 inV.copyTo(arrayInV); 22537 int[] arrayOut = new int[INPUTSIZE * 2]; 22538 Arrays.fill(arrayOut, (int) 42); 22539 out.copyTo(arrayOut); 22540 StringBuilder message = new StringBuilder(); 22541 boolean errorFound = false; 22542 for (int i = 0; i < INPUTSIZE; i++) { 22543 for (int j = 0; j < 2 ; j++) { 22544 // Extract the inputs. 22545 ArgumentsHalfInt args = new ArgumentsHalfInt(); 22546 args.inV = arrayInV[i * 2 + j]; 22547 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22548 // Figure out what the outputs should have been. 22549 CoreMathVerifier.computeConvert(args); 22550 // Validate the outputs. 22551 boolean valid = true; 22552 if (args.out != arrayOut[i * 2 + j]) { 22553 valid = false; 22554 } 22555 if (!valid) { 22556 if (!errorFound) { 22557 errorFound = true; 22558 message.append("Input inV: "); 22559 appendVariableToMessage(message, args.inV); 22560 message.append("\n"); 22561 message.append("Expected output out: "); 22562 appendVariableToMessage(message, args.out); 22563 message.append("\n"); 22564 message.append("Actual output out: "); 22565 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22566 if (args.out != arrayOut[i * 2 + j]) { 22567 message.append(" FAIL"); 22568 } 22569 message.append("\n"); 22570 message.append("Errors at"); 22571 } 22572 message.append(" ["); 22573 message.append(Integer.toString(i)); 22574 message.append(", "); 22575 message.append(Integer.toString(j)); 22576 message.append("]"); 22577 } 22578 } 22579 } 22580 assertFalse("Incorrect output for checkConvertHalf2Int2" + 22581 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22582 } 22583 checkConvertHalf3Int3()22584 private void checkConvertHalf3Int3() { 22585 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x26a69450l, -2.1464350730000000000e+09, 2.1464350720000000000e+09); 22586 try { 22587 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 22588 script.forEach_testConvertInt3Half3Int3(inV, out); 22589 verifyResultsConvertHalf3Int3(inV, out, false); 22590 } catch (Exception e) { 22591 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Half3Int3: " + e.toString()); 22592 } 22593 try { 22594 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); 22595 scriptRelaxed.forEach_testConvertInt3Half3Int3(inV, out); 22596 verifyResultsConvertHalf3Int3(inV, out, true); 22597 } catch (Exception e) { 22598 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Half3Int3: " + e.toString()); 22599 } 22600 } 22601 verifyResultsConvertHalf3Int3(Allocation inV, Allocation out, boolean relaxed)22602 private void verifyResultsConvertHalf3Int3(Allocation inV, Allocation out, boolean relaxed) { 22603 short[] arrayInV = new short[INPUTSIZE * 4]; 22604 Arrays.fill(arrayInV, (short) 42); 22605 inV.copyTo(arrayInV); 22606 int[] arrayOut = new int[INPUTSIZE * 4]; 22607 Arrays.fill(arrayOut, (int) 42); 22608 out.copyTo(arrayOut); 22609 StringBuilder message = new StringBuilder(); 22610 boolean errorFound = false; 22611 for (int i = 0; i < INPUTSIZE; i++) { 22612 for (int j = 0; j < 3 ; j++) { 22613 // Extract the inputs. 22614 ArgumentsHalfInt args = new ArgumentsHalfInt(); 22615 args.inV = arrayInV[i * 4 + j]; 22616 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22617 // Figure out what the outputs should have been. 22618 CoreMathVerifier.computeConvert(args); 22619 // Validate the outputs. 22620 boolean valid = true; 22621 if (args.out != arrayOut[i * 4 + j]) { 22622 valid = false; 22623 } 22624 if (!valid) { 22625 if (!errorFound) { 22626 errorFound = true; 22627 message.append("Input inV: "); 22628 appendVariableToMessage(message, args.inV); 22629 message.append("\n"); 22630 message.append("Expected output out: "); 22631 appendVariableToMessage(message, args.out); 22632 message.append("\n"); 22633 message.append("Actual output out: "); 22634 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22635 if (args.out != arrayOut[i * 4 + j]) { 22636 message.append(" FAIL"); 22637 } 22638 message.append("\n"); 22639 message.append("Errors at"); 22640 } 22641 message.append(" ["); 22642 message.append(Integer.toString(i)); 22643 message.append(", "); 22644 message.append(Integer.toString(j)); 22645 message.append("]"); 22646 } 22647 } 22648 } 22649 assertFalse("Incorrect output for checkConvertHalf3Int3" + 22650 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22651 } 22652 checkConvertHalf4Int4()22653 private void checkConvertHalf4Int4() { 22654 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x704ea486l, -2.1464350730000000000e+09, 2.1464350720000000000e+09); 22655 try { 22656 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 22657 script.forEach_testConvertInt4Half4Int4(inV, out); 22658 verifyResultsConvertHalf4Int4(inV, out, false); 22659 } catch (Exception e) { 22660 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Half4Int4: " + e.toString()); 22661 } 22662 try { 22663 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); 22664 scriptRelaxed.forEach_testConvertInt4Half4Int4(inV, out); 22665 verifyResultsConvertHalf4Int4(inV, out, true); 22666 } catch (Exception e) { 22667 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Half4Int4: " + e.toString()); 22668 } 22669 } 22670 verifyResultsConvertHalf4Int4(Allocation inV, Allocation out, boolean relaxed)22671 private void verifyResultsConvertHalf4Int4(Allocation inV, Allocation out, boolean relaxed) { 22672 short[] arrayInV = new short[INPUTSIZE * 4]; 22673 Arrays.fill(arrayInV, (short) 42); 22674 inV.copyTo(arrayInV); 22675 int[] arrayOut = new int[INPUTSIZE * 4]; 22676 Arrays.fill(arrayOut, (int) 42); 22677 out.copyTo(arrayOut); 22678 StringBuilder message = new StringBuilder(); 22679 boolean errorFound = false; 22680 for (int i = 0; i < INPUTSIZE; i++) { 22681 for (int j = 0; j < 4 ; j++) { 22682 // Extract the inputs. 22683 ArgumentsHalfInt args = new ArgumentsHalfInt(); 22684 args.inV = arrayInV[i * 4 + j]; 22685 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22686 // Figure out what the outputs should have been. 22687 CoreMathVerifier.computeConvert(args); 22688 // Validate the outputs. 22689 boolean valid = true; 22690 if (args.out != arrayOut[i * 4 + j]) { 22691 valid = false; 22692 } 22693 if (!valid) { 22694 if (!errorFound) { 22695 errorFound = true; 22696 message.append("Input inV: "); 22697 appendVariableToMessage(message, args.inV); 22698 message.append("\n"); 22699 message.append("Expected output out: "); 22700 appendVariableToMessage(message, args.out); 22701 message.append("\n"); 22702 message.append("Actual output out: "); 22703 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22704 if (args.out != arrayOut[i * 4 + j]) { 22705 message.append(" FAIL"); 22706 } 22707 message.append("\n"); 22708 message.append("Errors at"); 22709 } 22710 message.append(" ["); 22711 message.append(Integer.toString(i)); 22712 message.append(", "); 22713 message.append(Integer.toString(j)); 22714 message.append("]"); 22715 } 22716 } 22717 } 22718 assertFalse("Incorrect output for checkConvertHalf4Int4" + 22719 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22720 } 22721 22722 public class ArgumentsHalfUint { 22723 public short inV; 22724 public double inVDouble; 22725 public int out; 22726 } 22727 checkConvertHalf2Uint2()22728 private void checkConvertHalf2Uint2() { 22729 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf45cbe1l, 0.0000000000000000000e+00, 4.2928701440000000000e+09); 22730 try { 22731 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 22732 script.forEach_testConvertUint2Half2Uint2(inV, out); 22733 verifyResultsConvertHalf2Uint2(inV, out, false); 22734 } catch (Exception e) { 22735 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Half2Uint2: " + e.toString()); 22736 } 22737 try { 22738 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); 22739 scriptRelaxed.forEach_testConvertUint2Half2Uint2(inV, out); 22740 verifyResultsConvertHalf2Uint2(inV, out, true); 22741 } catch (Exception e) { 22742 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Half2Uint2: " + e.toString()); 22743 } 22744 } 22745 verifyResultsConvertHalf2Uint2(Allocation inV, Allocation out, boolean relaxed)22746 private void verifyResultsConvertHalf2Uint2(Allocation inV, Allocation out, boolean relaxed) { 22747 short[] arrayInV = new short[INPUTSIZE * 2]; 22748 Arrays.fill(arrayInV, (short) 42); 22749 inV.copyTo(arrayInV); 22750 int[] arrayOut = new int[INPUTSIZE * 2]; 22751 Arrays.fill(arrayOut, (int) 42); 22752 out.copyTo(arrayOut); 22753 StringBuilder message = new StringBuilder(); 22754 boolean errorFound = false; 22755 for (int i = 0; i < INPUTSIZE; i++) { 22756 for (int j = 0; j < 2 ; j++) { 22757 // Extract the inputs. 22758 ArgumentsHalfUint args = new ArgumentsHalfUint(); 22759 args.inV = arrayInV[i * 2 + j]; 22760 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22761 // Figure out what the outputs should have been. 22762 CoreMathVerifier.computeConvert(args); 22763 // Validate the outputs. 22764 boolean valid = true; 22765 if (args.out != arrayOut[i * 2 + j]) { 22766 valid = false; 22767 } 22768 if (!valid) { 22769 if (!errorFound) { 22770 errorFound = true; 22771 message.append("Input inV: "); 22772 appendVariableToMessage(message, args.inV); 22773 message.append("\n"); 22774 message.append("Expected output out: "); 22775 appendVariableToMessage(message, args.out); 22776 message.append("\n"); 22777 message.append("Actual output out: "); 22778 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22779 if (args.out != arrayOut[i * 2 + j]) { 22780 message.append(" FAIL"); 22781 } 22782 message.append("\n"); 22783 message.append("Errors at"); 22784 } 22785 message.append(" ["); 22786 message.append(Integer.toString(i)); 22787 message.append(", "); 22788 message.append(Integer.toString(j)); 22789 message.append("]"); 22790 } 22791 } 22792 } 22793 assertFalse("Incorrect output for checkConvertHalf2Uint2" + 22794 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22795 } 22796 checkConvertHalf3Uint3()22797 private void checkConvertHalf3Uint3() { 22798 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6e4d90d5l, 0.0000000000000000000e+00, 4.2928701440000000000e+09); 22799 try { 22800 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 22801 script.forEach_testConvertUint3Half3Uint3(inV, out); 22802 verifyResultsConvertHalf3Uint3(inV, out, false); 22803 } catch (Exception e) { 22804 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Half3Uint3: " + e.toString()); 22805 } 22806 try { 22807 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); 22808 scriptRelaxed.forEach_testConvertUint3Half3Uint3(inV, out); 22809 verifyResultsConvertHalf3Uint3(inV, out, true); 22810 } catch (Exception e) { 22811 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Half3Uint3: " + e.toString()); 22812 } 22813 } 22814 verifyResultsConvertHalf3Uint3(Allocation inV, Allocation out, boolean relaxed)22815 private void verifyResultsConvertHalf3Uint3(Allocation inV, Allocation out, boolean relaxed) { 22816 short[] arrayInV = new short[INPUTSIZE * 4]; 22817 Arrays.fill(arrayInV, (short) 42); 22818 inV.copyTo(arrayInV); 22819 int[] arrayOut = new int[INPUTSIZE * 4]; 22820 Arrays.fill(arrayOut, (int) 42); 22821 out.copyTo(arrayOut); 22822 StringBuilder message = new StringBuilder(); 22823 boolean errorFound = false; 22824 for (int i = 0; i < INPUTSIZE; i++) { 22825 for (int j = 0; j < 3 ; j++) { 22826 // Extract the inputs. 22827 ArgumentsHalfUint args = new ArgumentsHalfUint(); 22828 args.inV = arrayInV[i * 4 + j]; 22829 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22830 // Figure out what the outputs should have been. 22831 CoreMathVerifier.computeConvert(args); 22832 // Validate the outputs. 22833 boolean valid = true; 22834 if (args.out != arrayOut[i * 4 + j]) { 22835 valid = false; 22836 } 22837 if (!valid) { 22838 if (!errorFound) { 22839 errorFound = true; 22840 message.append("Input inV: "); 22841 appendVariableToMessage(message, args.inV); 22842 message.append("\n"); 22843 message.append("Expected output out: "); 22844 appendVariableToMessage(message, args.out); 22845 message.append("\n"); 22846 message.append("Actual output out: "); 22847 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22848 if (args.out != arrayOut[i * 4 + j]) { 22849 message.append(" FAIL"); 22850 } 22851 message.append("\n"); 22852 message.append("Errors at"); 22853 } 22854 message.append(" ["); 22855 message.append(Integer.toString(i)); 22856 message.append(", "); 22857 message.append(Integer.toString(j)); 22858 message.append("]"); 22859 } 22860 } 22861 } 22862 assertFalse("Incorrect output for checkConvertHalf3Uint3" + 22863 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22864 } 22865 checkConvertHalf4Uint4()22866 private void checkConvertHalf4Uint4() { 22867 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcd5555c9l, 0.0000000000000000000e+00, 4.2928701440000000000e+09); 22868 try { 22869 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 22870 script.forEach_testConvertUint4Half4Uint4(inV, out); 22871 verifyResultsConvertHalf4Uint4(inV, out, false); 22872 } catch (Exception e) { 22873 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Half4Uint4: " + e.toString()); 22874 } 22875 try { 22876 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); 22877 scriptRelaxed.forEach_testConvertUint4Half4Uint4(inV, out); 22878 verifyResultsConvertHalf4Uint4(inV, out, true); 22879 } catch (Exception e) { 22880 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Half4Uint4: " + e.toString()); 22881 } 22882 } 22883 verifyResultsConvertHalf4Uint4(Allocation inV, Allocation out, boolean relaxed)22884 private void verifyResultsConvertHalf4Uint4(Allocation inV, Allocation out, boolean relaxed) { 22885 short[] arrayInV = new short[INPUTSIZE * 4]; 22886 Arrays.fill(arrayInV, (short) 42); 22887 inV.copyTo(arrayInV); 22888 int[] arrayOut = new int[INPUTSIZE * 4]; 22889 Arrays.fill(arrayOut, (int) 42); 22890 out.copyTo(arrayOut); 22891 StringBuilder message = new StringBuilder(); 22892 boolean errorFound = false; 22893 for (int i = 0; i < INPUTSIZE; i++) { 22894 for (int j = 0; j < 4 ; j++) { 22895 // Extract the inputs. 22896 ArgumentsHalfUint args = new ArgumentsHalfUint(); 22897 args.inV = arrayInV[i * 4 + j]; 22898 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22899 // Figure out what the outputs should have been. 22900 CoreMathVerifier.computeConvert(args); 22901 // Validate the outputs. 22902 boolean valid = true; 22903 if (args.out != arrayOut[i * 4 + j]) { 22904 valid = false; 22905 } 22906 if (!valid) { 22907 if (!errorFound) { 22908 errorFound = true; 22909 message.append("Input inV: "); 22910 appendVariableToMessage(message, args.inV); 22911 message.append("\n"); 22912 message.append("Expected output out: "); 22913 appendVariableToMessage(message, args.out); 22914 message.append("\n"); 22915 message.append("Actual output out: "); 22916 appendVariableToMessage(message, arrayOut[i * 4 + j]); 22917 if (args.out != arrayOut[i * 4 + j]) { 22918 message.append(" FAIL"); 22919 } 22920 message.append("\n"); 22921 message.append("Errors at"); 22922 } 22923 message.append(" ["); 22924 message.append(Integer.toString(i)); 22925 message.append(", "); 22926 message.append(Integer.toString(j)); 22927 message.append("]"); 22928 } 22929 } 22930 } 22931 assertFalse("Incorrect output for checkConvertHalf4Uint4" + 22932 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 22933 } 22934 22935 public class ArgumentsHalfLong { 22936 public short inV; 22937 public double inVDouble; 22938 public long out; 22939 } 22940 checkConvertHalf2Long2()22941 private void checkConvertHalf2Long2() { 22942 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4a740c9fl, -9.2188684372274053120e+18, 9.2188684372274053120e+18); 22943 try { 22944 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 22945 script.forEach_testConvertLong2Half2Long2(inV, out); 22946 verifyResultsConvertHalf2Long2(inV, out, false); 22947 } catch (Exception e) { 22948 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Half2Long2: " + e.toString()); 22949 } 22950 try { 22951 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); 22952 scriptRelaxed.forEach_testConvertLong2Half2Long2(inV, out); 22953 verifyResultsConvertHalf2Long2(inV, out, true); 22954 } catch (Exception e) { 22955 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Half2Long2: " + e.toString()); 22956 } 22957 } 22958 verifyResultsConvertHalf2Long2(Allocation inV, Allocation out, boolean relaxed)22959 private void verifyResultsConvertHalf2Long2(Allocation inV, Allocation out, boolean relaxed) { 22960 short[] arrayInV = new short[INPUTSIZE * 2]; 22961 Arrays.fill(arrayInV, (short) 42); 22962 inV.copyTo(arrayInV); 22963 long[] arrayOut = new long[INPUTSIZE * 2]; 22964 Arrays.fill(arrayOut, (long) 42); 22965 out.copyTo(arrayOut); 22966 StringBuilder message = new StringBuilder(); 22967 boolean errorFound = false; 22968 for (int i = 0; i < INPUTSIZE; i++) { 22969 for (int j = 0; j < 2 ; j++) { 22970 // Extract the inputs. 22971 ArgumentsHalfLong args = new ArgumentsHalfLong(); 22972 args.inV = arrayInV[i * 2 + j]; 22973 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 22974 // Figure out what the outputs should have been. 22975 CoreMathVerifier.computeConvert(args); 22976 // Validate the outputs. 22977 boolean valid = true; 22978 if (args.out != arrayOut[i * 2 + j]) { 22979 valid = false; 22980 } 22981 if (!valid) { 22982 if (!errorFound) { 22983 errorFound = true; 22984 message.append("Input inV: "); 22985 appendVariableToMessage(message, args.inV); 22986 message.append("\n"); 22987 message.append("Expected output out: "); 22988 appendVariableToMessage(message, args.out); 22989 message.append("\n"); 22990 message.append("Actual output out: "); 22991 appendVariableToMessage(message, arrayOut[i * 2 + j]); 22992 if (args.out != arrayOut[i * 2 + j]) { 22993 message.append(" FAIL"); 22994 } 22995 message.append("\n"); 22996 message.append("Errors at"); 22997 } 22998 message.append(" ["); 22999 message.append(Integer.toString(i)); 23000 message.append(", "); 23001 message.append(Integer.toString(j)); 23002 message.append("]"); 23003 } 23004 } 23005 } 23006 assertFalse("Incorrect output for checkConvertHalf2Long2" + 23007 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23008 } 23009 checkConvertHalf3Long3()23010 private void checkConvertHalf3Long3() { 23011 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa97bd193l, -9.2188684372274053120e+18, 9.2188684372274053120e+18); 23012 try { 23013 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 23014 script.forEach_testConvertLong3Half3Long3(inV, out); 23015 verifyResultsConvertHalf3Long3(inV, out, false); 23016 } catch (Exception e) { 23017 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Half3Long3: " + e.toString()); 23018 } 23019 try { 23020 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); 23021 scriptRelaxed.forEach_testConvertLong3Half3Long3(inV, out); 23022 verifyResultsConvertHalf3Long3(inV, out, true); 23023 } catch (Exception e) { 23024 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Half3Long3: " + e.toString()); 23025 } 23026 } 23027 verifyResultsConvertHalf3Long3(Allocation inV, Allocation out, boolean relaxed)23028 private void verifyResultsConvertHalf3Long3(Allocation inV, Allocation out, boolean relaxed) { 23029 short[] arrayInV = new short[INPUTSIZE * 4]; 23030 Arrays.fill(arrayInV, (short) 42); 23031 inV.copyTo(arrayInV); 23032 long[] arrayOut = new long[INPUTSIZE * 4]; 23033 Arrays.fill(arrayOut, (long) 42); 23034 out.copyTo(arrayOut); 23035 StringBuilder message = new StringBuilder(); 23036 boolean errorFound = false; 23037 for (int i = 0; i < INPUTSIZE; i++) { 23038 for (int j = 0; j < 3 ; j++) { 23039 // Extract the inputs. 23040 ArgumentsHalfLong args = new ArgumentsHalfLong(); 23041 args.inV = arrayInV[i * 4 + j]; 23042 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23043 // Figure out what the outputs should have been. 23044 CoreMathVerifier.computeConvert(args); 23045 // Validate the outputs. 23046 boolean valid = true; 23047 if (args.out != arrayOut[i * 4 + j]) { 23048 valid = false; 23049 } 23050 if (!valid) { 23051 if (!errorFound) { 23052 errorFound = true; 23053 message.append("Input inV: "); 23054 appendVariableToMessage(message, args.inV); 23055 message.append("\n"); 23056 message.append("Expected output out: "); 23057 appendVariableToMessage(message, args.out); 23058 message.append("\n"); 23059 message.append("Actual output out: "); 23060 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23061 if (args.out != arrayOut[i * 4 + j]) { 23062 message.append(" FAIL"); 23063 } 23064 message.append("\n"); 23065 message.append("Errors at"); 23066 } 23067 message.append(" ["); 23068 message.append(Integer.toString(i)); 23069 message.append(", "); 23070 message.append(Integer.toString(j)); 23071 message.append("]"); 23072 } 23073 } 23074 } 23075 assertFalse("Incorrect output for checkConvertHalf3Long3" + 23076 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23077 } 23078 checkConvertHalf4Long4()23079 private void checkConvertHalf4Long4() { 23080 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8839687l, -9.2188684372274053120e+18, 9.2188684372274053120e+18); 23081 try { 23082 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 23083 script.forEach_testConvertLong4Half4Long4(inV, out); 23084 verifyResultsConvertHalf4Long4(inV, out, false); 23085 } catch (Exception e) { 23086 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Half4Long4: " + e.toString()); 23087 } 23088 try { 23089 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); 23090 scriptRelaxed.forEach_testConvertLong4Half4Long4(inV, out); 23091 verifyResultsConvertHalf4Long4(inV, out, true); 23092 } catch (Exception e) { 23093 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Half4Long4: " + e.toString()); 23094 } 23095 } 23096 verifyResultsConvertHalf4Long4(Allocation inV, Allocation out, boolean relaxed)23097 private void verifyResultsConvertHalf4Long4(Allocation inV, Allocation out, boolean relaxed) { 23098 short[] arrayInV = new short[INPUTSIZE * 4]; 23099 Arrays.fill(arrayInV, (short) 42); 23100 inV.copyTo(arrayInV); 23101 long[] arrayOut = new long[INPUTSIZE * 4]; 23102 Arrays.fill(arrayOut, (long) 42); 23103 out.copyTo(arrayOut); 23104 StringBuilder message = new StringBuilder(); 23105 boolean errorFound = false; 23106 for (int i = 0; i < INPUTSIZE; i++) { 23107 for (int j = 0; j < 4 ; j++) { 23108 // Extract the inputs. 23109 ArgumentsHalfLong args = new ArgumentsHalfLong(); 23110 args.inV = arrayInV[i * 4 + j]; 23111 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23112 // Figure out what the outputs should have been. 23113 CoreMathVerifier.computeConvert(args); 23114 // Validate the outputs. 23115 boolean valid = true; 23116 if (args.out != arrayOut[i * 4 + j]) { 23117 valid = false; 23118 } 23119 if (!valid) { 23120 if (!errorFound) { 23121 errorFound = true; 23122 message.append("Input inV: "); 23123 appendVariableToMessage(message, args.inV); 23124 message.append("\n"); 23125 message.append("Expected output out: "); 23126 appendVariableToMessage(message, args.out); 23127 message.append("\n"); 23128 message.append("Actual output out: "); 23129 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23130 if (args.out != arrayOut[i * 4 + j]) { 23131 message.append(" FAIL"); 23132 } 23133 message.append("\n"); 23134 message.append("Errors at"); 23135 } 23136 message.append(" ["); 23137 message.append(Integer.toString(i)); 23138 message.append(", "); 23139 message.append(Integer.toString(j)); 23140 message.append("]"); 23141 } 23142 } 23143 } 23144 assertFalse("Incorrect output for checkConvertHalf4Long4" + 23145 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23146 } 23147 23148 public class ArgumentsHalfUlong { 23149 public short inV; 23150 public double inVDouble; 23151 public long out; 23152 } 23153 checkConvertHalf2Ulong2()23154 private void checkConvertHalf2Ulong2() { 23155 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbc6d1b0cl, 0.0000000000000000000e+00, 1.8437736874454810624e+19); 23156 try { 23157 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 23158 script.forEach_testConvertUlong2Half2Ulong2(inV, out); 23159 verifyResultsConvertHalf2Ulong2(inV, out, false); 23160 } catch (Exception e) { 23161 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Half2Ulong2: " + e.toString()); 23162 } 23163 try { 23164 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); 23165 scriptRelaxed.forEach_testConvertUlong2Half2Ulong2(inV, out); 23166 verifyResultsConvertHalf2Ulong2(inV, out, true); 23167 } catch (Exception e) { 23168 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Half2Ulong2: " + e.toString()); 23169 } 23170 } 23171 verifyResultsConvertHalf2Ulong2(Allocation inV, Allocation out, boolean relaxed)23172 private void verifyResultsConvertHalf2Ulong2(Allocation inV, Allocation out, boolean relaxed) { 23173 short[] arrayInV = new short[INPUTSIZE * 2]; 23174 Arrays.fill(arrayInV, (short) 42); 23175 inV.copyTo(arrayInV); 23176 long[] arrayOut = new long[INPUTSIZE * 2]; 23177 Arrays.fill(arrayOut, (long) 42); 23178 out.copyTo(arrayOut); 23179 StringBuilder message = new StringBuilder(); 23180 boolean errorFound = false; 23181 for (int i = 0; i < INPUTSIZE; i++) { 23182 for (int j = 0; j < 2 ; j++) { 23183 // Extract the inputs. 23184 ArgumentsHalfUlong args = new ArgumentsHalfUlong(); 23185 args.inV = arrayInV[i * 2 + j]; 23186 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23187 // Figure out what the outputs should have been. 23188 CoreMathVerifier.computeConvert(args); 23189 // Validate the outputs. 23190 boolean valid = true; 23191 if (args.out != arrayOut[i * 2 + j]) { 23192 valid = false; 23193 } 23194 if (!valid) { 23195 if (!errorFound) { 23196 errorFound = true; 23197 message.append("Input inV: "); 23198 appendVariableToMessage(message, args.inV); 23199 message.append("\n"); 23200 message.append("Expected output out: "); 23201 appendVariableToMessage(message, args.out); 23202 message.append("\n"); 23203 message.append("Actual output out: "); 23204 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23205 if (args.out != arrayOut[i * 2 + j]) { 23206 message.append(" FAIL"); 23207 } 23208 message.append("\n"); 23209 message.append("Errors at"); 23210 } 23211 message.append(" ["); 23212 message.append(Integer.toString(i)); 23213 message.append(", "); 23214 message.append(Integer.toString(j)); 23215 message.append("]"); 23216 } 23217 } 23218 } 23219 assertFalse("Incorrect output for checkConvertHalf2Ulong2" + 23220 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23221 } 23222 checkConvertHalf3Ulong3()23223 private void checkConvertHalf3Ulong3() { 23224 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb2883beal, 0.0000000000000000000e+00, 1.8437736874454810624e+19); 23225 try { 23226 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 23227 script.forEach_testConvertUlong3Half3Ulong3(inV, out); 23228 verifyResultsConvertHalf3Ulong3(inV, out, false); 23229 } catch (Exception e) { 23230 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Half3Ulong3: " + e.toString()); 23231 } 23232 try { 23233 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); 23234 scriptRelaxed.forEach_testConvertUlong3Half3Ulong3(inV, out); 23235 verifyResultsConvertHalf3Ulong3(inV, out, true); 23236 } catch (Exception e) { 23237 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Half3Ulong3: " + e.toString()); 23238 } 23239 } 23240 verifyResultsConvertHalf3Ulong3(Allocation inV, Allocation out, boolean relaxed)23241 private void verifyResultsConvertHalf3Ulong3(Allocation inV, Allocation out, boolean relaxed) { 23242 short[] arrayInV = new short[INPUTSIZE * 4]; 23243 Arrays.fill(arrayInV, (short) 42); 23244 inV.copyTo(arrayInV); 23245 long[] arrayOut = new long[INPUTSIZE * 4]; 23246 Arrays.fill(arrayOut, (long) 42); 23247 out.copyTo(arrayOut); 23248 StringBuilder message = new StringBuilder(); 23249 boolean errorFound = false; 23250 for (int i = 0; i < INPUTSIZE; i++) { 23251 for (int j = 0; j < 3 ; j++) { 23252 // Extract the inputs. 23253 ArgumentsHalfUlong args = new ArgumentsHalfUlong(); 23254 args.inV = arrayInV[i * 4 + j]; 23255 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23256 // Figure out what the outputs should have been. 23257 CoreMathVerifier.computeConvert(args); 23258 // Validate the outputs. 23259 boolean valid = true; 23260 if (args.out != arrayOut[i * 4 + j]) { 23261 valid = false; 23262 } 23263 if (!valid) { 23264 if (!errorFound) { 23265 errorFound = true; 23266 message.append("Input inV: "); 23267 appendVariableToMessage(message, args.inV); 23268 message.append("\n"); 23269 message.append("Expected output out: "); 23270 appendVariableToMessage(message, args.out); 23271 message.append("\n"); 23272 message.append("Actual output out: "); 23273 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23274 if (args.out != arrayOut[i * 4 + j]) { 23275 message.append(" FAIL"); 23276 } 23277 message.append("\n"); 23278 message.append("Errors at"); 23279 } 23280 message.append(" ["); 23281 message.append(Integer.toString(i)); 23282 message.append(", "); 23283 message.append(Integer.toString(j)); 23284 message.append("]"); 23285 } 23286 } 23287 } 23288 assertFalse("Incorrect output for checkConvertHalf3Ulong3" + 23289 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23290 } 23291 checkConvertHalf4Ulong4()23292 private void checkConvertHalf4Ulong4() { 23293 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa8a35cc8l, 0.0000000000000000000e+00, 1.8437736874454810624e+19); 23294 try { 23295 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 23296 script.forEach_testConvertUlong4Half4Ulong4(inV, out); 23297 verifyResultsConvertHalf4Ulong4(inV, out, false); 23298 } catch (Exception e) { 23299 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Half4Ulong4: " + e.toString()); 23300 } 23301 try { 23302 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); 23303 scriptRelaxed.forEach_testConvertUlong4Half4Ulong4(inV, out); 23304 verifyResultsConvertHalf4Ulong4(inV, out, true); 23305 } catch (Exception e) { 23306 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Half4Ulong4: " + e.toString()); 23307 } 23308 } 23309 verifyResultsConvertHalf4Ulong4(Allocation inV, Allocation out, boolean relaxed)23310 private void verifyResultsConvertHalf4Ulong4(Allocation inV, Allocation out, boolean relaxed) { 23311 short[] arrayInV = new short[INPUTSIZE * 4]; 23312 Arrays.fill(arrayInV, (short) 42); 23313 inV.copyTo(arrayInV); 23314 long[] arrayOut = new long[INPUTSIZE * 4]; 23315 Arrays.fill(arrayOut, (long) 42); 23316 out.copyTo(arrayOut); 23317 StringBuilder message = new StringBuilder(); 23318 boolean errorFound = false; 23319 for (int i = 0; i < INPUTSIZE; i++) { 23320 for (int j = 0; j < 4 ; j++) { 23321 // Extract the inputs. 23322 ArgumentsHalfUlong args = new ArgumentsHalfUlong(); 23323 args.inV = arrayInV[i * 4 + j]; 23324 args.inVDouble = Float16Utils.convertFloat16ToDouble(args.inV); 23325 // Figure out what the outputs should have been. 23326 CoreMathVerifier.computeConvert(args); 23327 // Validate the outputs. 23328 boolean valid = true; 23329 if (args.out != arrayOut[i * 4 + j]) { 23330 valid = false; 23331 } 23332 if (!valid) { 23333 if (!errorFound) { 23334 errorFound = true; 23335 message.append("Input inV: "); 23336 appendVariableToMessage(message, args.inV); 23337 message.append("\n"); 23338 message.append("Expected output out: "); 23339 appendVariableToMessage(message, args.out); 23340 message.append("\n"); 23341 message.append("Actual output out: "); 23342 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23343 if (args.out != arrayOut[i * 4 + j]) { 23344 message.append(" FAIL"); 23345 } 23346 message.append("\n"); 23347 message.append("Errors at"); 23348 } 23349 message.append(" ["); 23350 message.append(Integer.toString(i)); 23351 message.append(", "); 23352 message.append(Integer.toString(j)); 23353 message.append("]"); 23354 } 23355 } 23356 } 23357 assertFalse("Incorrect output for checkConvertHalf4Ulong4" + 23358 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23359 } 23360 23361 public class ArgumentsFloatHalf { 23362 public float inV; 23363 public Target.Floaty out; 23364 } 23365 checkConvertFloat2Half2()23366 private void checkConvertFloat2Half2() { 23367 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaa314c6fl, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 23368 try { 23369 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 23370 script.forEach_testConvertHalf2Float2Half2(inV, out); 23371 verifyResultsConvertFloat2Half2(inV, out, false); 23372 } catch (Exception e) { 23373 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Float2Half2: " + e.toString()); 23374 } 23375 try { 23376 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 23377 scriptRelaxed.forEach_testConvertHalf2Float2Half2(inV, out); 23378 verifyResultsConvertFloat2Half2(inV, out, true); 23379 } catch (Exception e) { 23380 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Float2Half2: " + e.toString()); 23381 } 23382 } 23383 verifyResultsConvertFloat2Half2(Allocation inV, Allocation out, boolean relaxed)23384 private void verifyResultsConvertFloat2Half2(Allocation inV, Allocation out, boolean relaxed) { 23385 float[] arrayInV = new float[INPUTSIZE * 2]; 23386 Arrays.fill(arrayInV, (float) 42); 23387 inV.copyTo(arrayInV); 23388 short[] arrayOut = new short[INPUTSIZE * 2]; 23389 Arrays.fill(arrayOut, (short) 42); 23390 out.copyTo(arrayOut); 23391 StringBuilder message = new StringBuilder(); 23392 boolean errorFound = false; 23393 for (int i = 0; i < INPUTSIZE; i++) { 23394 for (int j = 0; j < 2 ; j++) { 23395 // Extract the inputs. 23396 ArgumentsFloatHalf args = new ArgumentsFloatHalf(); 23397 args.inV = arrayInV[i * 2 + j]; 23398 // Figure out what the outputs should have been. 23399 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23400 CoreMathVerifier.computeConvert(args, target); 23401 // Validate the outputs. 23402 boolean valid = true; 23403 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 23404 valid = false; 23405 } 23406 if (!valid) { 23407 if (!errorFound) { 23408 errorFound = true; 23409 message.append("Input inV: "); 23410 appendVariableToMessage(message, args.inV); 23411 message.append("\n"); 23412 message.append("Expected output out: "); 23413 appendVariableToMessage(message, args.out); 23414 message.append("\n"); 23415 message.append("Actual output out: "); 23416 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23417 message.append("\n"); 23418 message.append("Actual output out (in double): "); 23419 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 23420 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 23421 message.append(" FAIL"); 23422 } 23423 message.append("\n"); 23424 message.append("Errors at"); 23425 } 23426 message.append(" ["); 23427 message.append(Integer.toString(i)); 23428 message.append(", "); 23429 message.append(Integer.toString(j)); 23430 message.append("]"); 23431 } 23432 } 23433 } 23434 assertFalse("Incorrect output for checkConvertFloat2Half2" + 23435 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23436 } 23437 checkConvertFloat3Half3()23438 private void checkConvertFloat3Half3() { 23439 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9391163l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 23440 try { 23441 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 23442 script.forEach_testConvertHalf3Float3Half3(inV, out); 23443 verifyResultsConvertFloat3Half3(inV, out, false); 23444 } catch (Exception e) { 23445 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Float3Half3: " + e.toString()); 23446 } 23447 try { 23448 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 23449 scriptRelaxed.forEach_testConvertHalf3Float3Half3(inV, out); 23450 verifyResultsConvertFloat3Half3(inV, out, true); 23451 } catch (Exception e) { 23452 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Float3Half3: " + e.toString()); 23453 } 23454 } 23455 verifyResultsConvertFloat3Half3(Allocation inV, Allocation out, boolean relaxed)23456 private void verifyResultsConvertFloat3Half3(Allocation inV, Allocation out, boolean relaxed) { 23457 float[] arrayInV = new float[INPUTSIZE * 4]; 23458 Arrays.fill(arrayInV, (float) 42); 23459 inV.copyTo(arrayInV); 23460 short[] arrayOut = new short[INPUTSIZE * 4]; 23461 Arrays.fill(arrayOut, (short) 42); 23462 out.copyTo(arrayOut); 23463 StringBuilder message = new StringBuilder(); 23464 boolean errorFound = false; 23465 for (int i = 0; i < INPUTSIZE; i++) { 23466 for (int j = 0; j < 3 ; j++) { 23467 // Extract the inputs. 23468 ArgumentsFloatHalf args = new ArgumentsFloatHalf(); 23469 args.inV = arrayInV[i * 4 + j]; 23470 // Figure out what the outputs should have been. 23471 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23472 CoreMathVerifier.computeConvert(args, target); 23473 // Validate the outputs. 23474 boolean valid = true; 23475 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23476 valid = false; 23477 } 23478 if (!valid) { 23479 if (!errorFound) { 23480 errorFound = true; 23481 message.append("Input inV: "); 23482 appendVariableToMessage(message, args.inV); 23483 message.append("\n"); 23484 message.append("Expected output out: "); 23485 appendVariableToMessage(message, args.out); 23486 message.append("\n"); 23487 message.append("Actual output out: "); 23488 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23489 message.append("\n"); 23490 message.append("Actual output out (in double): "); 23491 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 23492 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23493 message.append(" FAIL"); 23494 } 23495 message.append("\n"); 23496 message.append("Errors at"); 23497 } 23498 message.append(" ["); 23499 message.append(Integer.toString(i)); 23500 message.append(", "); 23501 message.append(Integer.toString(j)); 23502 message.append("]"); 23503 } 23504 } 23505 } 23506 assertFalse("Incorrect output for checkConvertFloat3Half3" + 23507 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23508 } 23509 checkConvertFloat4Half4()23510 private void checkConvertFloat4Half4() { 23511 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6840d657l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 23512 try { 23513 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 23514 script.forEach_testConvertHalf4Float4Half4(inV, out); 23515 verifyResultsConvertFloat4Half4(inV, out, false); 23516 } catch (Exception e) { 23517 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Float4Half4: " + e.toString()); 23518 } 23519 try { 23520 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 23521 scriptRelaxed.forEach_testConvertHalf4Float4Half4(inV, out); 23522 verifyResultsConvertFloat4Half4(inV, out, true); 23523 } catch (Exception e) { 23524 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Float4Half4: " + e.toString()); 23525 } 23526 } 23527 verifyResultsConvertFloat4Half4(Allocation inV, Allocation out, boolean relaxed)23528 private void verifyResultsConvertFloat4Half4(Allocation inV, Allocation out, boolean relaxed) { 23529 float[] arrayInV = new float[INPUTSIZE * 4]; 23530 Arrays.fill(arrayInV, (float) 42); 23531 inV.copyTo(arrayInV); 23532 short[] arrayOut = new short[INPUTSIZE * 4]; 23533 Arrays.fill(arrayOut, (short) 42); 23534 out.copyTo(arrayOut); 23535 StringBuilder message = new StringBuilder(); 23536 boolean errorFound = false; 23537 for (int i = 0; i < INPUTSIZE; i++) { 23538 for (int j = 0; j < 4 ; j++) { 23539 // Extract the inputs. 23540 ArgumentsFloatHalf args = new ArgumentsFloatHalf(); 23541 args.inV = arrayInV[i * 4 + j]; 23542 // Figure out what the outputs should have been. 23543 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23544 CoreMathVerifier.computeConvert(args, target); 23545 // Validate the outputs. 23546 boolean valid = true; 23547 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23548 valid = false; 23549 } 23550 if (!valid) { 23551 if (!errorFound) { 23552 errorFound = true; 23553 message.append("Input inV: "); 23554 appendVariableToMessage(message, args.inV); 23555 message.append("\n"); 23556 message.append("Expected output out: "); 23557 appendVariableToMessage(message, args.out); 23558 message.append("\n"); 23559 message.append("Actual output out: "); 23560 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23561 message.append("\n"); 23562 message.append("Actual output out (in double): "); 23563 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 23564 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23565 message.append(" FAIL"); 23566 } 23567 message.append("\n"); 23568 message.append("Errors at"); 23569 } 23570 message.append(" ["); 23571 message.append(Integer.toString(i)); 23572 message.append(", "); 23573 message.append(Integer.toString(j)); 23574 message.append("]"); 23575 } 23576 } 23577 } 23578 assertFalse("Incorrect output for checkConvertFloat4Half4" + 23579 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23580 } 23581 23582 public class ArgumentsDoubleHalf { 23583 public double inV; 23584 public Target.Floaty out; 23585 } 23586 checkConvertDouble2Half2()23587 private void checkConvertDouble2Half2() { 23588 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x6fc20024l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 23589 try { 23590 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 23591 script.forEach_testConvertHalf2Double2Half2(inV, out); 23592 verifyResultsConvertDouble2Half2(inV, out, false); 23593 } catch (Exception e) { 23594 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Double2Half2: " + e.toString()); 23595 } 23596 try { 23597 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 23598 scriptRelaxed.forEach_testConvertHalf2Double2Half2(inV, out); 23599 verifyResultsConvertDouble2Half2(inV, out, true); 23600 } catch (Exception e) { 23601 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Double2Half2: " + e.toString()); 23602 } 23603 } 23604 verifyResultsConvertDouble2Half2(Allocation inV, Allocation out, boolean relaxed)23605 private void verifyResultsConvertDouble2Half2(Allocation inV, Allocation out, boolean relaxed) { 23606 double[] arrayInV = new double[INPUTSIZE * 2]; 23607 Arrays.fill(arrayInV, (double) 42); 23608 inV.copyTo(arrayInV); 23609 short[] arrayOut = new short[INPUTSIZE * 2]; 23610 Arrays.fill(arrayOut, (short) 42); 23611 out.copyTo(arrayOut); 23612 StringBuilder message = new StringBuilder(); 23613 boolean errorFound = false; 23614 for (int i = 0; i < INPUTSIZE; i++) { 23615 for (int j = 0; j < 2 ; j++) { 23616 // Extract the inputs. 23617 ArgumentsDoubleHalf args = new ArgumentsDoubleHalf(); 23618 args.inV = arrayInV[i * 2 + j]; 23619 // Figure out what the outputs should have been. 23620 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23621 CoreMathVerifier.computeConvert(args, target); 23622 // Validate the outputs. 23623 boolean valid = true; 23624 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 23625 valid = false; 23626 } 23627 if (!valid) { 23628 if (!errorFound) { 23629 errorFound = true; 23630 message.append("Input inV: "); 23631 appendVariableToMessage(message, args.inV); 23632 message.append("\n"); 23633 message.append("Expected output out: "); 23634 appendVariableToMessage(message, args.out); 23635 message.append("\n"); 23636 message.append("Actual output out: "); 23637 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23638 message.append("\n"); 23639 message.append("Actual output out (in double): "); 23640 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 23641 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 23642 message.append(" FAIL"); 23643 } 23644 message.append("\n"); 23645 message.append("Errors at"); 23646 } 23647 message.append(" ["); 23648 message.append(Integer.toString(i)); 23649 message.append(", "); 23650 message.append(Integer.toString(j)); 23651 message.append("]"); 23652 } 23653 } 23654 } 23655 assertFalse("Incorrect output for checkConvertDouble2Half2" + 23656 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23657 } 23658 checkConvertDouble3Half3()23659 private void checkConvertDouble3Half3() { 23660 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcec9c518l, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 23661 try { 23662 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 23663 script.forEach_testConvertHalf3Double3Half3(inV, out); 23664 verifyResultsConvertDouble3Half3(inV, out, false); 23665 } catch (Exception e) { 23666 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Double3Half3: " + e.toString()); 23667 } 23668 try { 23669 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 23670 scriptRelaxed.forEach_testConvertHalf3Double3Half3(inV, out); 23671 verifyResultsConvertDouble3Half3(inV, out, true); 23672 } catch (Exception e) { 23673 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Double3Half3: " + e.toString()); 23674 } 23675 } 23676 verifyResultsConvertDouble3Half3(Allocation inV, Allocation out, boolean relaxed)23677 private void verifyResultsConvertDouble3Half3(Allocation inV, Allocation out, boolean relaxed) { 23678 double[] arrayInV = new double[INPUTSIZE * 4]; 23679 Arrays.fill(arrayInV, (double) 42); 23680 inV.copyTo(arrayInV); 23681 short[] arrayOut = new short[INPUTSIZE * 4]; 23682 Arrays.fill(arrayOut, (short) 42); 23683 out.copyTo(arrayOut); 23684 StringBuilder message = new StringBuilder(); 23685 boolean errorFound = false; 23686 for (int i = 0; i < INPUTSIZE; i++) { 23687 for (int j = 0; j < 3 ; j++) { 23688 // Extract the inputs. 23689 ArgumentsDoubleHalf args = new ArgumentsDoubleHalf(); 23690 args.inV = arrayInV[i * 4 + j]; 23691 // Figure out what the outputs should have been. 23692 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23693 CoreMathVerifier.computeConvert(args, target); 23694 // Validate the outputs. 23695 boolean valid = true; 23696 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23697 valid = false; 23698 } 23699 if (!valid) { 23700 if (!errorFound) { 23701 errorFound = true; 23702 message.append("Input inV: "); 23703 appendVariableToMessage(message, args.inV); 23704 message.append("\n"); 23705 message.append("Expected output out: "); 23706 appendVariableToMessage(message, args.out); 23707 message.append("\n"); 23708 message.append("Actual output out: "); 23709 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23710 message.append("\n"); 23711 message.append("Actual output out (in double): "); 23712 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 23713 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23714 message.append(" FAIL"); 23715 } 23716 message.append("\n"); 23717 message.append("Errors at"); 23718 } 23719 message.append(" ["); 23720 message.append(Integer.toString(i)); 23721 message.append(", "); 23722 message.append(Integer.toString(j)); 23723 message.append("]"); 23724 } 23725 } 23726 } 23727 assertFalse("Incorrect output for checkConvertDouble3Half3" + 23728 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23729 } 23730 checkConvertDouble4Half4()23731 private void checkConvertDouble4Half4() { 23732 Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x2dd18a0cl, -3.1129599999999998545e+04, 3.1129599999999998545e+04); 23733 try { 23734 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 23735 script.forEach_testConvertHalf4Double4Half4(inV, out); 23736 verifyResultsConvertDouble4Half4(inV, out, false); 23737 } catch (Exception e) { 23738 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Double4Half4: " + e.toString()); 23739 } 23740 try { 23741 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 23742 scriptRelaxed.forEach_testConvertHalf4Double4Half4(inV, out); 23743 verifyResultsConvertDouble4Half4(inV, out, true); 23744 } catch (Exception e) { 23745 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Double4Half4: " + e.toString()); 23746 } 23747 } 23748 verifyResultsConvertDouble4Half4(Allocation inV, Allocation out, boolean relaxed)23749 private void verifyResultsConvertDouble4Half4(Allocation inV, Allocation out, boolean relaxed) { 23750 double[] arrayInV = new double[INPUTSIZE * 4]; 23751 Arrays.fill(arrayInV, (double) 42); 23752 inV.copyTo(arrayInV); 23753 short[] arrayOut = new short[INPUTSIZE * 4]; 23754 Arrays.fill(arrayOut, (short) 42); 23755 out.copyTo(arrayOut); 23756 StringBuilder message = new StringBuilder(); 23757 boolean errorFound = false; 23758 for (int i = 0; i < INPUTSIZE; i++) { 23759 for (int j = 0; j < 4 ; j++) { 23760 // Extract the inputs. 23761 ArgumentsDoubleHalf args = new ArgumentsDoubleHalf(); 23762 args.inV = arrayInV[i * 4 + j]; 23763 // Figure out what the outputs should have been. 23764 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23765 CoreMathVerifier.computeConvert(args, target); 23766 // Validate the outputs. 23767 boolean valid = true; 23768 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23769 valid = false; 23770 } 23771 if (!valid) { 23772 if (!errorFound) { 23773 errorFound = true; 23774 message.append("Input inV: "); 23775 appendVariableToMessage(message, args.inV); 23776 message.append("\n"); 23777 message.append("Expected output out: "); 23778 appendVariableToMessage(message, args.out); 23779 message.append("\n"); 23780 message.append("Actual output out: "); 23781 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23782 message.append("\n"); 23783 message.append("Actual output out (in double): "); 23784 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 23785 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23786 message.append(" FAIL"); 23787 } 23788 message.append("\n"); 23789 message.append("Errors at"); 23790 } 23791 message.append(" ["); 23792 message.append(Integer.toString(i)); 23793 message.append(", "); 23794 message.append(Integer.toString(j)); 23795 message.append("]"); 23796 } 23797 } 23798 } 23799 assertFalse("Incorrect output for checkConvertDouble4Half4" + 23800 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23801 } 23802 23803 public class ArgumentsCharHalf { 23804 public byte inV; 23805 public Target.Floaty out; 23806 } 23807 checkConvertChar2Half2()23808 private void checkConvertChar2Half2() { 23809 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x55c123afl, true, 7); 23810 try { 23811 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 23812 script.forEach_testConvertHalf2Char2Half2(inV, out); 23813 verifyResultsConvertChar2Half2(inV, out, false); 23814 } catch (Exception e) { 23815 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Char2Half2: " + e.toString()); 23816 } 23817 try { 23818 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 23819 scriptRelaxed.forEach_testConvertHalf2Char2Half2(inV, out); 23820 verifyResultsConvertChar2Half2(inV, out, true); 23821 } catch (Exception e) { 23822 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Char2Half2: " + e.toString()); 23823 } 23824 } 23825 verifyResultsConvertChar2Half2(Allocation inV, Allocation out, boolean relaxed)23826 private void verifyResultsConvertChar2Half2(Allocation inV, Allocation out, boolean relaxed) { 23827 byte[] arrayInV = new byte[INPUTSIZE * 2]; 23828 Arrays.fill(arrayInV, (byte) 42); 23829 inV.copyTo(arrayInV); 23830 short[] arrayOut = new short[INPUTSIZE * 2]; 23831 Arrays.fill(arrayOut, (short) 42); 23832 out.copyTo(arrayOut); 23833 StringBuilder message = new StringBuilder(); 23834 boolean errorFound = false; 23835 for (int i = 0; i < INPUTSIZE; i++) { 23836 for (int j = 0; j < 2 ; j++) { 23837 // Extract the inputs. 23838 ArgumentsCharHalf args = new ArgumentsCharHalf(); 23839 args.inV = arrayInV[i * 2 + j]; 23840 // Figure out what the outputs should have been. 23841 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23842 CoreMathVerifier.computeConvert(args, target); 23843 // Validate the outputs. 23844 boolean valid = true; 23845 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 23846 valid = false; 23847 } 23848 if (!valid) { 23849 if (!errorFound) { 23850 errorFound = true; 23851 message.append("Input inV: "); 23852 appendVariableToMessage(message, args.inV); 23853 message.append("\n"); 23854 message.append("Expected output out: "); 23855 appendVariableToMessage(message, args.out); 23856 message.append("\n"); 23857 message.append("Actual output out: "); 23858 appendVariableToMessage(message, arrayOut[i * 2 + j]); 23859 message.append("\n"); 23860 message.append("Actual output out (in double): "); 23861 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 23862 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 23863 message.append(" FAIL"); 23864 } 23865 message.append("\n"); 23866 message.append("Errors at"); 23867 } 23868 message.append(" ["); 23869 message.append(Integer.toString(i)); 23870 message.append(", "); 23871 message.append(Integer.toString(j)); 23872 message.append("]"); 23873 } 23874 } 23875 } 23876 assertFalse("Incorrect output for checkConvertChar2Half2" + 23877 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23878 } 23879 checkConvertChar3Half3()23880 private void checkConvertChar3Half3() { 23881 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xb4c8e8a3l, true, 7); 23882 try { 23883 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 23884 script.forEach_testConvertHalf3Char3Half3(inV, out); 23885 verifyResultsConvertChar3Half3(inV, out, false); 23886 } catch (Exception e) { 23887 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Char3Half3: " + e.toString()); 23888 } 23889 try { 23890 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 23891 scriptRelaxed.forEach_testConvertHalf3Char3Half3(inV, out); 23892 verifyResultsConvertChar3Half3(inV, out, true); 23893 } catch (Exception e) { 23894 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Char3Half3: " + e.toString()); 23895 } 23896 } 23897 verifyResultsConvertChar3Half3(Allocation inV, Allocation out, boolean relaxed)23898 private void verifyResultsConvertChar3Half3(Allocation inV, Allocation out, boolean relaxed) { 23899 byte[] arrayInV = new byte[INPUTSIZE * 4]; 23900 Arrays.fill(arrayInV, (byte) 42); 23901 inV.copyTo(arrayInV); 23902 short[] arrayOut = new short[INPUTSIZE * 4]; 23903 Arrays.fill(arrayOut, (short) 42); 23904 out.copyTo(arrayOut); 23905 StringBuilder message = new StringBuilder(); 23906 boolean errorFound = false; 23907 for (int i = 0; i < INPUTSIZE; i++) { 23908 for (int j = 0; j < 3 ; j++) { 23909 // Extract the inputs. 23910 ArgumentsCharHalf args = new ArgumentsCharHalf(); 23911 args.inV = arrayInV[i * 4 + j]; 23912 // Figure out what the outputs should have been. 23913 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23914 CoreMathVerifier.computeConvert(args, target); 23915 // Validate the outputs. 23916 boolean valid = true; 23917 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23918 valid = false; 23919 } 23920 if (!valid) { 23921 if (!errorFound) { 23922 errorFound = true; 23923 message.append("Input inV: "); 23924 appendVariableToMessage(message, args.inV); 23925 message.append("\n"); 23926 message.append("Expected output out: "); 23927 appendVariableToMessage(message, args.out); 23928 message.append("\n"); 23929 message.append("Actual output out: "); 23930 appendVariableToMessage(message, arrayOut[i * 4 + j]); 23931 message.append("\n"); 23932 message.append("Actual output out (in double): "); 23933 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 23934 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23935 message.append(" FAIL"); 23936 } 23937 message.append("\n"); 23938 message.append("Errors at"); 23939 } 23940 message.append(" ["); 23941 message.append(Integer.toString(i)); 23942 message.append(", "); 23943 message.append(Integer.toString(j)); 23944 message.append("]"); 23945 } 23946 } 23947 } 23948 assertFalse("Incorrect output for checkConvertChar3Half3" + 23949 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 23950 } 23951 checkConvertChar4Half4()23952 private void checkConvertChar4Half4() { 23953 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x13d0ad97l, true, 7); 23954 try { 23955 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 23956 script.forEach_testConvertHalf4Char4Half4(inV, out); 23957 verifyResultsConvertChar4Half4(inV, out, false); 23958 } catch (Exception e) { 23959 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Char4Half4: " + e.toString()); 23960 } 23961 try { 23962 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 23963 scriptRelaxed.forEach_testConvertHalf4Char4Half4(inV, out); 23964 verifyResultsConvertChar4Half4(inV, out, true); 23965 } catch (Exception e) { 23966 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Char4Half4: " + e.toString()); 23967 } 23968 } 23969 verifyResultsConvertChar4Half4(Allocation inV, Allocation out, boolean relaxed)23970 private void verifyResultsConvertChar4Half4(Allocation inV, Allocation out, boolean relaxed) { 23971 byte[] arrayInV = new byte[INPUTSIZE * 4]; 23972 Arrays.fill(arrayInV, (byte) 42); 23973 inV.copyTo(arrayInV); 23974 short[] arrayOut = new short[INPUTSIZE * 4]; 23975 Arrays.fill(arrayOut, (short) 42); 23976 out.copyTo(arrayOut); 23977 StringBuilder message = new StringBuilder(); 23978 boolean errorFound = false; 23979 for (int i = 0; i < INPUTSIZE; i++) { 23980 for (int j = 0; j < 4 ; j++) { 23981 // Extract the inputs. 23982 ArgumentsCharHalf args = new ArgumentsCharHalf(); 23983 args.inV = arrayInV[i * 4 + j]; 23984 // Figure out what the outputs should have been. 23985 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 23986 CoreMathVerifier.computeConvert(args, target); 23987 // Validate the outputs. 23988 boolean valid = true; 23989 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 23990 valid = false; 23991 } 23992 if (!valid) { 23993 if (!errorFound) { 23994 errorFound = true; 23995 message.append("Input inV: "); 23996 appendVariableToMessage(message, args.inV); 23997 message.append("\n"); 23998 message.append("Expected output out: "); 23999 appendVariableToMessage(message, args.out); 24000 message.append("\n"); 24001 message.append("Actual output out: "); 24002 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24003 message.append("\n"); 24004 message.append("Actual output out (in double): "); 24005 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24006 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24007 message.append(" FAIL"); 24008 } 24009 message.append("\n"); 24010 message.append("Errors at"); 24011 } 24012 message.append(" ["); 24013 message.append(Integer.toString(i)); 24014 message.append(", "); 24015 message.append(Integer.toString(j)); 24016 message.append("]"); 24017 } 24018 } 24019 } 24020 assertFalse("Incorrect output for checkConvertChar4Half4" + 24021 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24022 } 24023 24024 public class ArgumentsUcharHalf { 24025 public byte inV; 24026 public Target.Floaty out; 24027 } 24028 checkConvertUchar2Half2()24029 private void checkConvertUchar2Half2() { 24030 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xe8433030l, false, 8); 24031 try { 24032 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24033 script.forEach_testConvertHalf2Uchar2Half2(inV, out); 24034 verifyResultsConvertUchar2Half2(inV, out, false); 24035 } catch (Exception e) { 24036 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uchar2Half2: " + e.toString()); 24037 } 24038 try { 24039 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24040 scriptRelaxed.forEach_testConvertHalf2Uchar2Half2(inV, out); 24041 verifyResultsConvertUchar2Half2(inV, out, true); 24042 } catch (Exception e) { 24043 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uchar2Half2: " + e.toString()); 24044 } 24045 } 24046 verifyResultsConvertUchar2Half2(Allocation inV, Allocation out, boolean relaxed)24047 private void verifyResultsConvertUchar2Half2(Allocation inV, Allocation out, boolean relaxed) { 24048 byte[] arrayInV = new byte[INPUTSIZE * 2]; 24049 Arrays.fill(arrayInV, (byte) 42); 24050 inV.copyTo(arrayInV); 24051 short[] arrayOut = new short[INPUTSIZE * 2]; 24052 Arrays.fill(arrayOut, (short) 42); 24053 out.copyTo(arrayOut); 24054 StringBuilder message = new StringBuilder(); 24055 boolean errorFound = false; 24056 for (int i = 0; i < INPUTSIZE; i++) { 24057 for (int j = 0; j < 2 ; j++) { 24058 // Extract the inputs. 24059 ArgumentsUcharHalf args = new ArgumentsUcharHalf(); 24060 args.inV = arrayInV[i * 2 + j]; 24061 // Figure out what the outputs should have been. 24062 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24063 CoreMathVerifier.computeConvert(args, target); 24064 // Validate the outputs. 24065 boolean valid = true; 24066 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24067 valid = false; 24068 } 24069 if (!valid) { 24070 if (!errorFound) { 24071 errorFound = true; 24072 message.append("Input inV: "); 24073 appendVariableToMessage(message, args.inV); 24074 message.append("\n"); 24075 message.append("Expected output out: "); 24076 appendVariableToMessage(message, args.out); 24077 message.append("\n"); 24078 message.append("Actual output out: "); 24079 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24080 message.append("\n"); 24081 message.append("Actual output out (in double): "); 24082 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24083 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24084 message.append(" FAIL"); 24085 } 24086 message.append("\n"); 24087 message.append("Errors at"); 24088 } 24089 message.append(" ["); 24090 message.append(Integer.toString(i)); 24091 message.append(", "); 24092 message.append(Integer.toString(j)); 24093 message.append("]"); 24094 } 24095 } 24096 } 24097 assertFalse("Incorrect output for checkConvertUchar2Half2" + 24098 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24099 } 24100 checkConvertUchar3Half3()24101 private void checkConvertUchar3Half3() { 24102 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x474af524l, false, 8); 24103 try { 24104 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24105 script.forEach_testConvertHalf3Uchar3Half3(inV, out); 24106 verifyResultsConvertUchar3Half3(inV, out, false); 24107 } catch (Exception e) { 24108 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uchar3Half3: " + e.toString()); 24109 } 24110 try { 24111 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24112 scriptRelaxed.forEach_testConvertHalf3Uchar3Half3(inV, out); 24113 verifyResultsConvertUchar3Half3(inV, out, true); 24114 } catch (Exception e) { 24115 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uchar3Half3: " + e.toString()); 24116 } 24117 } 24118 verifyResultsConvertUchar3Half3(Allocation inV, Allocation out, boolean relaxed)24119 private void verifyResultsConvertUchar3Half3(Allocation inV, Allocation out, boolean relaxed) { 24120 byte[] arrayInV = new byte[INPUTSIZE * 4]; 24121 Arrays.fill(arrayInV, (byte) 42); 24122 inV.copyTo(arrayInV); 24123 short[] arrayOut = new short[INPUTSIZE * 4]; 24124 Arrays.fill(arrayOut, (short) 42); 24125 out.copyTo(arrayOut); 24126 StringBuilder message = new StringBuilder(); 24127 boolean errorFound = false; 24128 for (int i = 0; i < INPUTSIZE; i++) { 24129 for (int j = 0; j < 3 ; j++) { 24130 // Extract the inputs. 24131 ArgumentsUcharHalf args = new ArgumentsUcharHalf(); 24132 args.inV = arrayInV[i * 4 + j]; 24133 // Figure out what the outputs should have been. 24134 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24135 CoreMathVerifier.computeConvert(args, target); 24136 // Validate the outputs. 24137 boolean valid = true; 24138 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24139 valid = false; 24140 } 24141 if (!valid) { 24142 if (!errorFound) { 24143 errorFound = true; 24144 message.append("Input inV: "); 24145 appendVariableToMessage(message, args.inV); 24146 message.append("\n"); 24147 message.append("Expected output out: "); 24148 appendVariableToMessage(message, args.out); 24149 message.append("\n"); 24150 message.append("Actual output out: "); 24151 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24152 message.append("\n"); 24153 message.append("Actual output out (in double): "); 24154 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24155 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24156 message.append(" FAIL"); 24157 } 24158 message.append("\n"); 24159 message.append("Errors at"); 24160 } 24161 message.append(" ["); 24162 message.append(Integer.toString(i)); 24163 message.append(", "); 24164 message.append(Integer.toString(j)); 24165 message.append("]"); 24166 } 24167 } 24168 } 24169 assertFalse("Incorrect output for checkConvertUchar3Half3" + 24170 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24171 } 24172 checkConvertUchar4Half4()24173 private void checkConvertUchar4Half4() { 24174 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa652ba18l, false, 8); 24175 try { 24176 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24177 script.forEach_testConvertHalf4Uchar4Half4(inV, out); 24178 verifyResultsConvertUchar4Half4(inV, out, false); 24179 } catch (Exception e) { 24180 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uchar4Half4: " + e.toString()); 24181 } 24182 try { 24183 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24184 scriptRelaxed.forEach_testConvertHalf4Uchar4Half4(inV, out); 24185 verifyResultsConvertUchar4Half4(inV, out, true); 24186 } catch (Exception e) { 24187 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uchar4Half4: " + e.toString()); 24188 } 24189 } 24190 verifyResultsConvertUchar4Half4(Allocation inV, Allocation out, boolean relaxed)24191 private void verifyResultsConvertUchar4Half4(Allocation inV, Allocation out, boolean relaxed) { 24192 byte[] arrayInV = new byte[INPUTSIZE * 4]; 24193 Arrays.fill(arrayInV, (byte) 42); 24194 inV.copyTo(arrayInV); 24195 short[] arrayOut = new short[INPUTSIZE * 4]; 24196 Arrays.fill(arrayOut, (short) 42); 24197 out.copyTo(arrayOut); 24198 StringBuilder message = new StringBuilder(); 24199 boolean errorFound = false; 24200 for (int i = 0; i < INPUTSIZE; i++) { 24201 for (int j = 0; j < 4 ; j++) { 24202 // Extract the inputs. 24203 ArgumentsUcharHalf args = new ArgumentsUcharHalf(); 24204 args.inV = arrayInV[i * 4 + j]; 24205 // Figure out what the outputs should have been. 24206 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24207 CoreMathVerifier.computeConvert(args, target); 24208 // Validate the outputs. 24209 boolean valid = true; 24210 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24211 valid = false; 24212 } 24213 if (!valid) { 24214 if (!errorFound) { 24215 errorFound = true; 24216 message.append("Input inV: "); 24217 appendVariableToMessage(message, args.inV); 24218 message.append("\n"); 24219 message.append("Expected output out: "); 24220 appendVariableToMessage(message, args.out); 24221 message.append("\n"); 24222 message.append("Actual output out: "); 24223 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24224 message.append("\n"); 24225 message.append("Actual output out (in double): "); 24226 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24227 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24228 message.append(" FAIL"); 24229 } 24230 message.append("\n"); 24231 message.append("Errors at"); 24232 } 24233 message.append(" ["); 24234 message.append(Integer.toString(i)); 24235 message.append(", "); 24236 message.append(Integer.toString(j)); 24237 message.append("]"); 24238 } 24239 } 24240 } 24241 assertFalse("Incorrect output for checkConvertUchar4Half4" + 24242 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24243 } 24244 24245 public class ArgumentsShortHalf { 24246 public short inV; 24247 public Target.Floaty out; 24248 } 24249 checkConvertShort2Half2()24250 private void checkConvertShort2Half2() { 24251 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x967ebe73l, true, 15); 24252 try { 24253 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24254 script.forEach_testConvertHalf2Short2Half2(inV, out); 24255 verifyResultsConvertShort2Half2(inV, out, false); 24256 } catch (Exception e) { 24257 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Short2Half2: " + e.toString()); 24258 } 24259 try { 24260 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24261 scriptRelaxed.forEach_testConvertHalf2Short2Half2(inV, out); 24262 verifyResultsConvertShort2Half2(inV, out, true); 24263 } catch (Exception e) { 24264 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Short2Half2: " + e.toString()); 24265 } 24266 } 24267 verifyResultsConvertShort2Half2(Allocation inV, Allocation out, boolean relaxed)24268 private void verifyResultsConvertShort2Half2(Allocation inV, Allocation out, boolean relaxed) { 24269 short[] arrayInV = new short[INPUTSIZE * 2]; 24270 Arrays.fill(arrayInV, (short) 42); 24271 inV.copyTo(arrayInV); 24272 short[] arrayOut = new short[INPUTSIZE * 2]; 24273 Arrays.fill(arrayOut, (short) 42); 24274 out.copyTo(arrayOut); 24275 StringBuilder message = new StringBuilder(); 24276 boolean errorFound = false; 24277 for (int i = 0; i < INPUTSIZE; i++) { 24278 for (int j = 0; j < 2 ; j++) { 24279 // Extract the inputs. 24280 ArgumentsShortHalf args = new ArgumentsShortHalf(); 24281 args.inV = arrayInV[i * 2 + j]; 24282 // Figure out what the outputs should have been. 24283 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24284 CoreMathVerifier.computeConvert(args, target); 24285 // Validate the outputs. 24286 boolean valid = true; 24287 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24288 valid = false; 24289 } 24290 if (!valid) { 24291 if (!errorFound) { 24292 errorFound = true; 24293 message.append("Input inV: "); 24294 appendVariableToMessage(message, args.inV); 24295 message.append("\n"); 24296 message.append("Expected output out: "); 24297 appendVariableToMessage(message, args.out); 24298 message.append("\n"); 24299 message.append("Actual output out: "); 24300 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24301 message.append("\n"); 24302 message.append("Actual output out (in double): "); 24303 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24304 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24305 message.append(" FAIL"); 24306 } 24307 message.append("\n"); 24308 message.append("Errors at"); 24309 } 24310 message.append(" ["); 24311 message.append(Integer.toString(i)); 24312 message.append(", "); 24313 message.append(Integer.toString(j)); 24314 message.append("]"); 24315 } 24316 } 24317 } 24318 assertFalse("Incorrect output for checkConvertShort2Half2" + 24319 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24320 } 24321 checkConvertShort3Half3()24322 private void checkConvertShort3Half3() { 24323 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf5868367l, true, 15); 24324 try { 24325 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24326 script.forEach_testConvertHalf3Short3Half3(inV, out); 24327 verifyResultsConvertShort3Half3(inV, out, false); 24328 } catch (Exception e) { 24329 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Short3Half3: " + e.toString()); 24330 } 24331 try { 24332 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24333 scriptRelaxed.forEach_testConvertHalf3Short3Half3(inV, out); 24334 verifyResultsConvertShort3Half3(inV, out, true); 24335 } catch (Exception e) { 24336 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Short3Half3: " + e.toString()); 24337 } 24338 } 24339 verifyResultsConvertShort3Half3(Allocation inV, Allocation out, boolean relaxed)24340 private void verifyResultsConvertShort3Half3(Allocation inV, Allocation out, boolean relaxed) { 24341 short[] arrayInV = new short[INPUTSIZE * 4]; 24342 Arrays.fill(arrayInV, (short) 42); 24343 inV.copyTo(arrayInV); 24344 short[] arrayOut = new short[INPUTSIZE * 4]; 24345 Arrays.fill(arrayOut, (short) 42); 24346 out.copyTo(arrayOut); 24347 StringBuilder message = new StringBuilder(); 24348 boolean errorFound = false; 24349 for (int i = 0; i < INPUTSIZE; i++) { 24350 for (int j = 0; j < 3 ; j++) { 24351 // Extract the inputs. 24352 ArgumentsShortHalf args = new ArgumentsShortHalf(); 24353 args.inV = arrayInV[i * 4 + j]; 24354 // Figure out what the outputs should have been. 24355 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24356 CoreMathVerifier.computeConvert(args, target); 24357 // Validate the outputs. 24358 boolean valid = true; 24359 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24360 valid = false; 24361 } 24362 if (!valid) { 24363 if (!errorFound) { 24364 errorFound = true; 24365 message.append("Input inV: "); 24366 appendVariableToMessage(message, args.inV); 24367 message.append("\n"); 24368 message.append("Expected output out: "); 24369 appendVariableToMessage(message, args.out); 24370 message.append("\n"); 24371 message.append("Actual output out: "); 24372 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24373 message.append("\n"); 24374 message.append("Actual output out (in double): "); 24375 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24376 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24377 message.append(" FAIL"); 24378 } 24379 message.append("\n"); 24380 message.append("Errors at"); 24381 } 24382 message.append(" ["); 24383 message.append(Integer.toString(i)); 24384 message.append(", "); 24385 message.append(Integer.toString(j)); 24386 message.append("]"); 24387 } 24388 } 24389 } 24390 assertFalse("Incorrect output for checkConvertShort3Half3" + 24391 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24392 } 24393 checkConvertShort4Half4()24394 private void checkConvertShort4Half4() { 24395 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x548e485bl, true, 15); 24396 try { 24397 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24398 script.forEach_testConvertHalf4Short4Half4(inV, out); 24399 verifyResultsConvertShort4Half4(inV, out, false); 24400 } catch (Exception e) { 24401 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Short4Half4: " + e.toString()); 24402 } 24403 try { 24404 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24405 scriptRelaxed.forEach_testConvertHalf4Short4Half4(inV, out); 24406 verifyResultsConvertShort4Half4(inV, out, true); 24407 } catch (Exception e) { 24408 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Short4Half4: " + e.toString()); 24409 } 24410 } 24411 verifyResultsConvertShort4Half4(Allocation inV, Allocation out, boolean relaxed)24412 private void verifyResultsConvertShort4Half4(Allocation inV, Allocation out, boolean relaxed) { 24413 short[] arrayInV = new short[INPUTSIZE * 4]; 24414 Arrays.fill(arrayInV, (short) 42); 24415 inV.copyTo(arrayInV); 24416 short[] arrayOut = new short[INPUTSIZE * 4]; 24417 Arrays.fill(arrayOut, (short) 42); 24418 out.copyTo(arrayOut); 24419 StringBuilder message = new StringBuilder(); 24420 boolean errorFound = false; 24421 for (int i = 0; i < INPUTSIZE; i++) { 24422 for (int j = 0; j < 4 ; j++) { 24423 // Extract the inputs. 24424 ArgumentsShortHalf args = new ArgumentsShortHalf(); 24425 args.inV = arrayInV[i * 4 + j]; 24426 // Figure out what the outputs should have been. 24427 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24428 CoreMathVerifier.computeConvert(args, target); 24429 // Validate the outputs. 24430 boolean valid = true; 24431 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24432 valid = false; 24433 } 24434 if (!valid) { 24435 if (!errorFound) { 24436 errorFound = true; 24437 message.append("Input inV: "); 24438 appendVariableToMessage(message, args.inV); 24439 message.append("\n"); 24440 message.append("Expected output out: "); 24441 appendVariableToMessage(message, args.out); 24442 message.append("\n"); 24443 message.append("Actual output out: "); 24444 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24445 message.append("\n"); 24446 message.append("Actual output out (in double): "); 24447 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24448 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24449 message.append(" FAIL"); 24450 } 24451 message.append("\n"); 24452 message.append("Errors at"); 24453 } 24454 message.append(" ["); 24455 message.append(Integer.toString(i)); 24456 message.append(", "); 24457 message.append(Integer.toString(j)); 24458 message.append("]"); 24459 } 24460 } 24461 } 24462 assertFalse("Incorrect output for checkConvertShort4Half4" + 24463 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24464 } 24465 24466 public class ArgumentsUshortHalf { 24467 public short inV; 24468 public Target.Floaty out; 24469 } 24470 checkConvertUshort2Half2()24471 private void checkConvertUshort2Half2() { 24472 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x3256d81el, false, 16); 24473 try { 24474 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24475 script.forEach_testConvertHalf2Ushort2Half2(inV, out); 24476 verifyResultsConvertUshort2Half2(inV, out, false); 24477 } catch (Exception e) { 24478 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ushort2Half2: " + e.toString()); 24479 } 24480 try { 24481 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24482 scriptRelaxed.forEach_testConvertHalf2Ushort2Half2(inV, out); 24483 verifyResultsConvertUshort2Half2(inV, out, true); 24484 } catch (Exception e) { 24485 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ushort2Half2: " + e.toString()); 24486 } 24487 } 24488 verifyResultsConvertUshort2Half2(Allocation inV, Allocation out, boolean relaxed)24489 private void verifyResultsConvertUshort2Half2(Allocation inV, Allocation out, boolean relaxed) { 24490 short[] arrayInV = new short[INPUTSIZE * 2]; 24491 Arrays.fill(arrayInV, (short) 42); 24492 inV.copyTo(arrayInV); 24493 short[] arrayOut = new short[INPUTSIZE * 2]; 24494 Arrays.fill(arrayOut, (short) 42); 24495 out.copyTo(arrayOut); 24496 StringBuilder message = new StringBuilder(); 24497 boolean errorFound = false; 24498 for (int i = 0; i < INPUTSIZE; i++) { 24499 for (int j = 0; j < 2 ; j++) { 24500 // Extract the inputs. 24501 ArgumentsUshortHalf args = new ArgumentsUshortHalf(); 24502 args.inV = arrayInV[i * 2 + j]; 24503 // Figure out what the outputs should have been. 24504 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24505 CoreMathVerifier.computeConvert(args, target); 24506 // Validate the outputs. 24507 boolean valid = true; 24508 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24509 valid = false; 24510 } 24511 if (!valid) { 24512 if (!errorFound) { 24513 errorFound = true; 24514 message.append("Input inV: "); 24515 appendVariableToMessage(message, args.inV); 24516 message.append("\n"); 24517 message.append("Expected output out: "); 24518 appendVariableToMessage(message, args.out); 24519 message.append("\n"); 24520 message.append("Actual output out: "); 24521 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24522 message.append("\n"); 24523 message.append("Actual output out (in double): "); 24524 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24525 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24526 message.append(" FAIL"); 24527 } 24528 message.append("\n"); 24529 message.append("Errors at"); 24530 } 24531 message.append(" ["); 24532 message.append(Integer.toString(i)); 24533 message.append(", "); 24534 message.append(Integer.toString(j)); 24535 message.append("]"); 24536 } 24537 } 24538 } 24539 assertFalse("Incorrect output for checkConvertUshort2Half2" + 24540 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24541 } 24542 checkConvertUshort3Half3()24543 private void checkConvertUshort3Half3() { 24544 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x915e9d12l, false, 16); 24545 try { 24546 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24547 script.forEach_testConvertHalf3Ushort3Half3(inV, out); 24548 verifyResultsConvertUshort3Half3(inV, out, false); 24549 } catch (Exception e) { 24550 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ushort3Half3: " + e.toString()); 24551 } 24552 try { 24553 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24554 scriptRelaxed.forEach_testConvertHalf3Ushort3Half3(inV, out); 24555 verifyResultsConvertUshort3Half3(inV, out, true); 24556 } catch (Exception e) { 24557 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ushort3Half3: " + e.toString()); 24558 } 24559 } 24560 verifyResultsConvertUshort3Half3(Allocation inV, Allocation out, boolean relaxed)24561 private void verifyResultsConvertUshort3Half3(Allocation inV, Allocation out, boolean relaxed) { 24562 short[] arrayInV = new short[INPUTSIZE * 4]; 24563 Arrays.fill(arrayInV, (short) 42); 24564 inV.copyTo(arrayInV); 24565 short[] arrayOut = new short[INPUTSIZE * 4]; 24566 Arrays.fill(arrayOut, (short) 42); 24567 out.copyTo(arrayOut); 24568 StringBuilder message = new StringBuilder(); 24569 boolean errorFound = false; 24570 for (int i = 0; i < INPUTSIZE; i++) { 24571 for (int j = 0; j < 3 ; j++) { 24572 // Extract the inputs. 24573 ArgumentsUshortHalf args = new ArgumentsUshortHalf(); 24574 args.inV = arrayInV[i * 4 + j]; 24575 // Figure out what the outputs should have been. 24576 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24577 CoreMathVerifier.computeConvert(args, target); 24578 // Validate the outputs. 24579 boolean valid = true; 24580 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24581 valid = false; 24582 } 24583 if (!valid) { 24584 if (!errorFound) { 24585 errorFound = true; 24586 message.append("Input inV: "); 24587 appendVariableToMessage(message, args.inV); 24588 message.append("\n"); 24589 message.append("Expected output out: "); 24590 appendVariableToMessage(message, args.out); 24591 message.append("\n"); 24592 message.append("Actual output out: "); 24593 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24594 message.append("\n"); 24595 message.append("Actual output out (in double): "); 24596 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24597 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24598 message.append(" FAIL"); 24599 } 24600 message.append("\n"); 24601 message.append("Errors at"); 24602 } 24603 message.append(" ["); 24604 message.append(Integer.toString(i)); 24605 message.append(", "); 24606 message.append(Integer.toString(j)); 24607 message.append("]"); 24608 } 24609 } 24610 } 24611 assertFalse("Incorrect output for checkConvertUshort3Half3" + 24612 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24613 } 24614 checkConvertUshort4Half4()24615 private void checkConvertUshort4Half4() { 24616 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xf0666206l, false, 16); 24617 try { 24618 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24619 script.forEach_testConvertHalf4Ushort4Half4(inV, out); 24620 verifyResultsConvertUshort4Half4(inV, out, false); 24621 } catch (Exception e) { 24622 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ushort4Half4: " + e.toString()); 24623 } 24624 try { 24625 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24626 scriptRelaxed.forEach_testConvertHalf4Ushort4Half4(inV, out); 24627 verifyResultsConvertUshort4Half4(inV, out, true); 24628 } catch (Exception e) { 24629 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ushort4Half4: " + e.toString()); 24630 } 24631 } 24632 verifyResultsConvertUshort4Half4(Allocation inV, Allocation out, boolean relaxed)24633 private void verifyResultsConvertUshort4Half4(Allocation inV, Allocation out, boolean relaxed) { 24634 short[] arrayInV = new short[INPUTSIZE * 4]; 24635 Arrays.fill(arrayInV, (short) 42); 24636 inV.copyTo(arrayInV); 24637 short[] arrayOut = new short[INPUTSIZE * 4]; 24638 Arrays.fill(arrayOut, (short) 42); 24639 out.copyTo(arrayOut); 24640 StringBuilder message = new StringBuilder(); 24641 boolean errorFound = false; 24642 for (int i = 0; i < INPUTSIZE; i++) { 24643 for (int j = 0; j < 4 ; j++) { 24644 // Extract the inputs. 24645 ArgumentsUshortHalf args = new ArgumentsUshortHalf(); 24646 args.inV = arrayInV[i * 4 + j]; 24647 // Figure out what the outputs should have been. 24648 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24649 CoreMathVerifier.computeConvert(args, target); 24650 // Validate the outputs. 24651 boolean valid = true; 24652 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24653 valid = false; 24654 } 24655 if (!valid) { 24656 if (!errorFound) { 24657 errorFound = true; 24658 message.append("Input inV: "); 24659 appendVariableToMessage(message, args.inV); 24660 message.append("\n"); 24661 message.append("Expected output out: "); 24662 appendVariableToMessage(message, args.out); 24663 message.append("\n"); 24664 message.append("Actual output out: "); 24665 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24666 message.append("\n"); 24667 message.append("Actual output out (in double): "); 24668 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24669 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24670 message.append(" FAIL"); 24671 } 24672 message.append("\n"); 24673 message.append("Errors at"); 24674 } 24675 message.append(" ["); 24676 message.append(Integer.toString(i)); 24677 message.append(", "); 24678 message.append(Integer.toString(j)); 24679 message.append("]"); 24680 } 24681 } 24682 } 24683 assertFalse("Incorrect output for checkConvertUshort4Half4" + 24684 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24685 } 24686 24687 public class ArgumentsIntHalf { 24688 public int inV; 24689 public Target.Floaty out; 24690 } 24691 checkConvertInt2Half2()24692 private void checkConvertInt2Half2() { 24693 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xb6fb0cecl, true, 31); 24694 try { 24695 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24696 script.forEach_testConvertHalf2Int2Half2(inV, out); 24697 verifyResultsConvertInt2Half2(inV, out, false); 24698 } catch (Exception e) { 24699 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Int2Half2: " + e.toString()); 24700 } 24701 try { 24702 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24703 scriptRelaxed.forEach_testConvertHalf2Int2Half2(inV, out); 24704 verifyResultsConvertInt2Half2(inV, out, true); 24705 } catch (Exception e) { 24706 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Int2Half2: " + e.toString()); 24707 } 24708 } 24709 verifyResultsConvertInt2Half2(Allocation inV, Allocation out, boolean relaxed)24710 private void verifyResultsConvertInt2Half2(Allocation inV, Allocation out, boolean relaxed) { 24711 int[] arrayInV = new int[INPUTSIZE * 2]; 24712 Arrays.fill(arrayInV, (int) 42); 24713 inV.copyTo(arrayInV); 24714 short[] arrayOut = new short[INPUTSIZE * 2]; 24715 Arrays.fill(arrayOut, (short) 42); 24716 out.copyTo(arrayOut); 24717 StringBuilder message = new StringBuilder(); 24718 boolean errorFound = false; 24719 for (int i = 0; i < INPUTSIZE; i++) { 24720 for (int j = 0; j < 2 ; j++) { 24721 // Extract the inputs. 24722 ArgumentsIntHalf args = new ArgumentsIntHalf(); 24723 args.inV = arrayInV[i * 2 + j]; 24724 // Figure out what the outputs should have been. 24725 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24726 CoreMathVerifier.computeConvert(args, target); 24727 // Validate the outputs. 24728 boolean valid = true; 24729 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24730 valid = false; 24731 } 24732 if (!valid) { 24733 if (!errorFound) { 24734 errorFound = true; 24735 message.append("Input inV: "); 24736 appendVariableToMessage(message, args.inV); 24737 message.append("\n"); 24738 message.append("Expected output out: "); 24739 appendVariableToMessage(message, args.out); 24740 message.append("\n"); 24741 message.append("Actual output out: "); 24742 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24743 message.append("\n"); 24744 message.append("Actual output out (in double): "); 24745 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24746 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24747 message.append(" FAIL"); 24748 } 24749 message.append("\n"); 24750 message.append("Errors at"); 24751 } 24752 message.append(" ["); 24753 message.append(Integer.toString(i)); 24754 message.append(", "); 24755 message.append(Integer.toString(j)); 24756 message.append("]"); 24757 } 24758 } 24759 } 24760 assertFalse("Incorrect output for checkConvertInt2Half2" + 24761 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24762 } 24763 checkConvertInt3Half3()24764 private void checkConvertInt3Half3() { 24765 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1602d1e0l, true, 31); 24766 try { 24767 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24768 script.forEach_testConvertHalf3Int3Half3(inV, out); 24769 verifyResultsConvertInt3Half3(inV, out, false); 24770 } catch (Exception e) { 24771 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Int3Half3: " + e.toString()); 24772 } 24773 try { 24774 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24775 scriptRelaxed.forEach_testConvertHalf3Int3Half3(inV, out); 24776 verifyResultsConvertInt3Half3(inV, out, true); 24777 } catch (Exception e) { 24778 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Int3Half3: " + e.toString()); 24779 } 24780 } 24781 verifyResultsConvertInt3Half3(Allocation inV, Allocation out, boolean relaxed)24782 private void verifyResultsConvertInt3Half3(Allocation inV, Allocation out, boolean relaxed) { 24783 int[] arrayInV = new int[INPUTSIZE * 4]; 24784 Arrays.fill(arrayInV, (int) 42); 24785 inV.copyTo(arrayInV); 24786 short[] arrayOut = new short[INPUTSIZE * 4]; 24787 Arrays.fill(arrayOut, (short) 42); 24788 out.copyTo(arrayOut); 24789 StringBuilder message = new StringBuilder(); 24790 boolean errorFound = false; 24791 for (int i = 0; i < INPUTSIZE; i++) { 24792 for (int j = 0; j < 3 ; j++) { 24793 // Extract the inputs. 24794 ArgumentsIntHalf args = new ArgumentsIntHalf(); 24795 args.inV = arrayInV[i * 4 + j]; 24796 // Figure out what the outputs should have been. 24797 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24798 CoreMathVerifier.computeConvert(args, target); 24799 // Validate the outputs. 24800 boolean valid = true; 24801 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24802 valid = false; 24803 } 24804 if (!valid) { 24805 if (!errorFound) { 24806 errorFound = true; 24807 message.append("Input inV: "); 24808 appendVariableToMessage(message, args.inV); 24809 message.append("\n"); 24810 message.append("Expected output out: "); 24811 appendVariableToMessage(message, args.out); 24812 message.append("\n"); 24813 message.append("Actual output out: "); 24814 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24815 message.append("\n"); 24816 message.append("Actual output out (in double): "); 24817 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24818 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24819 message.append(" FAIL"); 24820 } 24821 message.append("\n"); 24822 message.append("Errors at"); 24823 } 24824 message.append(" ["); 24825 message.append(Integer.toString(i)); 24826 message.append(", "); 24827 message.append(Integer.toString(j)); 24828 message.append("]"); 24829 } 24830 } 24831 } 24832 assertFalse("Incorrect output for checkConvertInt3Half3" + 24833 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24834 } 24835 checkConvertInt4Half4()24836 private void checkConvertInt4Half4() { 24837 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x750a96d4l, true, 31); 24838 try { 24839 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24840 script.forEach_testConvertHalf4Int4Half4(inV, out); 24841 verifyResultsConvertInt4Half4(inV, out, false); 24842 } catch (Exception e) { 24843 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Int4Half4: " + e.toString()); 24844 } 24845 try { 24846 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 24847 scriptRelaxed.forEach_testConvertHalf4Int4Half4(inV, out); 24848 verifyResultsConvertInt4Half4(inV, out, true); 24849 } catch (Exception e) { 24850 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Int4Half4: " + e.toString()); 24851 } 24852 } 24853 verifyResultsConvertInt4Half4(Allocation inV, Allocation out, boolean relaxed)24854 private void verifyResultsConvertInt4Half4(Allocation inV, Allocation out, boolean relaxed) { 24855 int[] arrayInV = new int[INPUTSIZE * 4]; 24856 Arrays.fill(arrayInV, (int) 42); 24857 inV.copyTo(arrayInV); 24858 short[] arrayOut = new short[INPUTSIZE * 4]; 24859 Arrays.fill(arrayOut, (short) 42); 24860 out.copyTo(arrayOut); 24861 StringBuilder message = new StringBuilder(); 24862 boolean errorFound = false; 24863 for (int i = 0; i < INPUTSIZE; i++) { 24864 for (int j = 0; j < 4 ; j++) { 24865 // Extract the inputs. 24866 ArgumentsIntHalf args = new ArgumentsIntHalf(); 24867 args.inV = arrayInV[i * 4 + j]; 24868 // Figure out what the outputs should have been. 24869 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24870 CoreMathVerifier.computeConvert(args, target); 24871 // Validate the outputs. 24872 boolean valid = true; 24873 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24874 valid = false; 24875 } 24876 if (!valid) { 24877 if (!errorFound) { 24878 errorFound = true; 24879 message.append("Input inV: "); 24880 appendVariableToMessage(message, args.inV); 24881 message.append("\n"); 24882 message.append("Expected output out: "); 24883 appendVariableToMessage(message, args.out); 24884 message.append("\n"); 24885 message.append("Actual output out: "); 24886 appendVariableToMessage(message, arrayOut[i * 4 + j]); 24887 message.append("\n"); 24888 message.append("Actual output out (in double): "); 24889 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 24890 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 24891 message.append(" FAIL"); 24892 } 24893 message.append("\n"); 24894 message.append("Errors at"); 24895 } 24896 message.append(" ["); 24897 message.append(Integer.toString(i)); 24898 message.append(", "); 24899 message.append(Integer.toString(j)); 24900 message.append("]"); 24901 } 24902 } 24903 } 24904 assertFalse("Incorrect output for checkConvertInt4Half4" + 24905 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24906 } 24907 24908 public class ArgumentsUintHalf { 24909 public int inV; 24910 public Target.Floaty out; 24911 } 24912 checkConvertUint2Half2()24913 private void checkConvertUint2Half2() { 24914 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb46f30efl, false, 32); 24915 try { 24916 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24917 script.forEach_testConvertHalf2Uint2Half2(inV, out); 24918 verifyResultsConvertUint2Half2(inV, out, false); 24919 } catch (Exception e) { 24920 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uint2Half2: " + e.toString()); 24921 } 24922 try { 24923 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 24924 scriptRelaxed.forEach_testConvertHalf2Uint2Half2(inV, out); 24925 verifyResultsConvertUint2Half2(inV, out, true); 24926 } catch (Exception e) { 24927 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uint2Half2: " + e.toString()); 24928 } 24929 } 24930 verifyResultsConvertUint2Half2(Allocation inV, Allocation out, boolean relaxed)24931 private void verifyResultsConvertUint2Half2(Allocation inV, Allocation out, boolean relaxed) { 24932 int[] arrayInV = new int[INPUTSIZE * 2]; 24933 Arrays.fill(arrayInV, (int) 42); 24934 inV.copyTo(arrayInV); 24935 short[] arrayOut = new short[INPUTSIZE * 2]; 24936 Arrays.fill(arrayOut, (short) 42); 24937 out.copyTo(arrayOut); 24938 StringBuilder message = new StringBuilder(); 24939 boolean errorFound = false; 24940 for (int i = 0; i < INPUTSIZE; i++) { 24941 for (int j = 0; j < 2 ; j++) { 24942 // Extract the inputs. 24943 ArgumentsUintHalf args = new ArgumentsUintHalf(); 24944 args.inV = arrayInV[i * 2 + j]; 24945 // Figure out what the outputs should have been. 24946 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 24947 CoreMathVerifier.computeConvert(args, target); 24948 // Validate the outputs. 24949 boolean valid = true; 24950 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24951 valid = false; 24952 } 24953 if (!valid) { 24954 if (!errorFound) { 24955 errorFound = true; 24956 message.append("Input inV: "); 24957 appendVariableToMessage(message, args.inV); 24958 message.append("\n"); 24959 message.append("Expected output out: "); 24960 appendVariableToMessage(message, args.out); 24961 message.append("\n"); 24962 message.append("Actual output out: "); 24963 appendVariableToMessage(message, arrayOut[i * 2 + j]); 24964 message.append("\n"); 24965 message.append("Actual output out (in double): "); 24966 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 24967 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 24968 message.append(" FAIL"); 24969 } 24970 message.append("\n"); 24971 message.append("Errors at"); 24972 } 24973 message.append(" ["); 24974 message.append(Integer.toString(i)); 24975 message.append(", "); 24976 message.append(Integer.toString(j)); 24977 message.append("]"); 24978 } 24979 } 24980 } 24981 assertFalse("Incorrect output for checkConvertUint2Half2" + 24982 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 24983 } 24984 checkConvertUint3Half3()24985 private void checkConvertUint3Half3() { 24986 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1376f5e3l, false, 32); 24987 try { 24988 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24989 script.forEach_testConvertHalf3Uint3Half3(inV, out); 24990 verifyResultsConvertUint3Half3(inV, out, false); 24991 } catch (Exception e) { 24992 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uint3Half3: " + e.toString()); 24993 } 24994 try { 24995 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 24996 scriptRelaxed.forEach_testConvertHalf3Uint3Half3(inV, out); 24997 verifyResultsConvertUint3Half3(inV, out, true); 24998 } catch (Exception e) { 24999 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uint3Half3: " + e.toString()); 25000 } 25001 } 25002 verifyResultsConvertUint3Half3(Allocation inV, Allocation out, boolean relaxed)25003 private void verifyResultsConvertUint3Half3(Allocation inV, Allocation out, boolean relaxed) { 25004 int[] arrayInV = new int[INPUTSIZE * 4]; 25005 Arrays.fill(arrayInV, (int) 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 < 3 ; j++) { 25014 // Extract the inputs. 25015 ArgumentsUintHalf args = new ArgumentsUintHalf(); 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 checkConvertUint3Half3" + 25054 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25055 } 25056 checkConvertUint4Half4()25057 private void checkConvertUint4Half4() { 25058 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x727ebad7l, false, 32); 25059 try { 25060 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25061 script.forEach_testConvertHalf4Uint4Half4(inV, out); 25062 verifyResultsConvertUint4Half4(inV, out, false); 25063 } catch (Exception e) { 25064 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uint4Half4: " + e.toString()); 25065 } 25066 try { 25067 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25068 scriptRelaxed.forEach_testConvertHalf4Uint4Half4(inV, out); 25069 verifyResultsConvertUint4Half4(inV, out, true); 25070 } catch (Exception e) { 25071 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uint4Half4: " + e.toString()); 25072 } 25073 } 25074 verifyResultsConvertUint4Half4(Allocation inV, Allocation out, boolean relaxed)25075 private void verifyResultsConvertUint4Half4(Allocation inV, Allocation out, boolean relaxed) { 25076 int[] arrayInV = new int[INPUTSIZE * 4]; 25077 Arrays.fill(arrayInV, (int) 42); 25078 inV.copyTo(arrayInV); 25079 short[] arrayOut = new short[INPUTSIZE * 4]; 25080 Arrays.fill(arrayOut, (short) 42); 25081 out.copyTo(arrayOut); 25082 StringBuilder message = new StringBuilder(); 25083 boolean errorFound = false; 25084 for (int i = 0; i < INPUTSIZE; i++) { 25085 for (int j = 0; j < 4 ; j++) { 25086 // Extract the inputs. 25087 ArgumentsUintHalf args = new ArgumentsUintHalf(); 25088 args.inV = arrayInV[i * 4 + j]; 25089 // Figure out what the outputs should have been. 25090 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25091 CoreMathVerifier.computeConvert(args, target); 25092 // Validate the outputs. 25093 boolean valid = true; 25094 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25095 valid = false; 25096 } 25097 if (!valid) { 25098 if (!errorFound) { 25099 errorFound = true; 25100 message.append("Input inV: "); 25101 appendVariableToMessage(message, args.inV); 25102 message.append("\n"); 25103 message.append("Expected output out: "); 25104 appendVariableToMessage(message, args.out); 25105 message.append("\n"); 25106 message.append("Actual output out: "); 25107 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25108 message.append("\n"); 25109 message.append("Actual output out (in double): "); 25110 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25111 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25112 message.append(" FAIL"); 25113 } 25114 message.append("\n"); 25115 message.append("Errors at"); 25116 } 25117 message.append(" ["); 25118 message.append(Integer.toString(i)); 25119 message.append(", "); 25120 message.append(Integer.toString(j)); 25121 message.append("]"); 25122 } 25123 } 25124 } 25125 assertFalse("Incorrect output for checkConvertUint4Half4" + 25126 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25127 } 25128 25129 public class ArgumentsLongHalf { 25130 public long inV; 25131 public Target.Floaty out; 25132 } 25133 checkConvertLong2Half2()25134 private void checkConvertLong2Half2() { 25135 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xf4d265b9l, true, 63); 25136 try { 25137 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25138 script.forEach_testConvertHalf2Long2Half2(inV, out); 25139 verifyResultsConvertLong2Half2(inV, out, false); 25140 } catch (Exception e) { 25141 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Long2Half2: " + e.toString()); 25142 } 25143 try { 25144 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25145 scriptRelaxed.forEach_testConvertHalf2Long2Half2(inV, out); 25146 verifyResultsConvertLong2Half2(inV, out, true); 25147 } catch (Exception e) { 25148 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Long2Half2: " + e.toString()); 25149 } 25150 } 25151 verifyResultsConvertLong2Half2(Allocation inV, Allocation out, boolean relaxed)25152 private void verifyResultsConvertLong2Half2(Allocation inV, Allocation out, boolean relaxed) { 25153 long[] arrayInV = new long[INPUTSIZE * 2]; 25154 Arrays.fill(arrayInV, (long) 42); 25155 inV.copyTo(arrayInV); 25156 short[] arrayOut = new short[INPUTSIZE * 2]; 25157 Arrays.fill(arrayOut, (short) 42); 25158 out.copyTo(arrayOut); 25159 StringBuilder message = new StringBuilder(); 25160 boolean errorFound = false; 25161 for (int i = 0; i < INPUTSIZE; i++) { 25162 for (int j = 0; j < 2 ; j++) { 25163 // Extract the inputs. 25164 ArgumentsLongHalf args = new ArgumentsLongHalf(); 25165 args.inV = arrayInV[i * 2 + j]; 25166 // Figure out what the outputs should have been. 25167 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25168 CoreMathVerifier.computeConvert(args, target); 25169 // Validate the outputs. 25170 boolean valid = true; 25171 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25172 valid = false; 25173 } 25174 if (!valid) { 25175 if (!errorFound) { 25176 errorFound = true; 25177 message.append("Input inV: "); 25178 appendVariableToMessage(message, args.inV); 25179 message.append("\n"); 25180 message.append("Expected output out: "); 25181 appendVariableToMessage(message, args.out); 25182 message.append("\n"); 25183 message.append("Actual output out: "); 25184 appendVariableToMessage(message, arrayOut[i * 2 + j]); 25185 message.append("\n"); 25186 message.append("Actual output out (in double): "); 25187 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 25188 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25189 message.append(" FAIL"); 25190 } 25191 message.append("\n"); 25192 message.append("Errors at"); 25193 } 25194 message.append(" ["); 25195 message.append(Integer.toString(i)); 25196 message.append(", "); 25197 message.append(Integer.toString(j)); 25198 message.append("]"); 25199 } 25200 } 25201 } 25202 assertFalse("Incorrect output for checkConvertLong2Half2" + 25203 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25204 } 25205 checkConvertLong3Half3()25206 private void checkConvertLong3Half3() { 25207 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x53da2aadl, true, 63); 25208 try { 25209 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25210 script.forEach_testConvertHalf3Long3Half3(inV, out); 25211 verifyResultsConvertLong3Half3(inV, out, false); 25212 } catch (Exception e) { 25213 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Long3Half3: " + e.toString()); 25214 } 25215 try { 25216 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25217 scriptRelaxed.forEach_testConvertHalf3Long3Half3(inV, out); 25218 verifyResultsConvertLong3Half3(inV, out, true); 25219 } catch (Exception e) { 25220 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Long3Half3: " + e.toString()); 25221 } 25222 } 25223 verifyResultsConvertLong3Half3(Allocation inV, Allocation out, boolean relaxed)25224 private void verifyResultsConvertLong3Half3(Allocation inV, Allocation out, boolean relaxed) { 25225 long[] arrayInV = new long[INPUTSIZE * 4]; 25226 Arrays.fill(arrayInV, (long) 42); 25227 inV.copyTo(arrayInV); 25228 short[] arrayOut = new short[INPUTSIZE * 4]; 25229 Arrays.fill(arrayOut, (short) 42); 25230 out.copyTo(arrayOut); 25231 StringBuilder message = new StringBuilder(); 25232 boolean errorFound = false; 25233 for (int i = 0; i < INPUTSIZE; i++) { 25234 for (int j = 0; j < 3 ; j++) { 25235 // Extract the inputs. 25236 ArgumentsLongHalf args = new ArgumentsLongHalf(); 25237 args.inV = arrayInV[i * 4 + j]; 25238 // Figure out what the outputs should have been. 25239 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25240 CoreMathVerifier.computeConvert(args, target); 25241 // Validate the outputs. 25242 boolean valid = true; 25243 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25244 valid = false; 25245 } 25246 if (!valid) { 25247 if (!errorFound) { 25248 errorFound = true; 25249 message.append("Input inV: "); 25250 appendVariableToMessage(message, args.inV); 25251 message.append("\n"); 25252 message.append("Expected output out: "); 25253 appendVariableToMessage(message, args.out); 25254 message.append("\n"); 25255 message.append("Actual output out: "); 25256 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25257 message.append("\n"); 25258 message.append("Actual output out (in double): "); 25259 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25260 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25261 message.append(" FAIL"); 25262 } 25263 message.append("\n"); 25264 message.append("Errors at"); 25265 } 25266 message.append(" ["); 25267 message.append(Integer.toString(i)); 25268 message.append(", "); 25269 message.append(Integer.toString(j)); 25270 message.append("]"); 25271 } 25272 } 25273 } 25274 assertFalse("Incorrect output for checkConvertLong3Half3" + 25275 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25276 } 25277 checkConvertLong4Half4()25278 private void checkConvertLong4Half4() { 25279 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb2e1efa1l, true, 63); 25280 try { 25281 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25282 script.forEach_testConvertHalf4Long4Half4(inV, out); 25283 verifyResultsConvertLong4Half4(inV, out, false); 25284 } catch (Exception e) { 25285 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Long4Half4: " + e.toString()); 25286 } 25287 try { 25288 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25289 scriptRelaxed.forEach_testConvertHalf4Long4Half4(inV, out); 25290 verifyResultsConvertLong4Half4(inV, out, true); 25291 } catch (Exception e) { 25292 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Long4Half4: " + e.toString()); 25293 } 25294 } 25295 verifyResultsConvertLong4Half4(Allocation inV, Allocation out, boolean relaxed)25296 private void verifyResultsConvertLong4Half4(Allocation inV, Allocation out, boolean relaxed) { 25297 long[] arrayInV = new long[INPUTSIZE * 4]; 25298 Arrays.fill(arrayInV, (long) 42); 25299 inV.copyTo(arrayInV); 25300 short[] arrayOut = new short[INPUTSIZE * 4]; 25301 Arrays.fill(arrayOut, (short) 42); 25302 out.copyTo(arrayOut); 25303 StringBuilder message = new StringBuilder(); 25304 boolean errorFound = false; 25305 for (int i = 0; i < INPUTSIZE; i++) { 25306 for (int j = 0; j < 4 ; j++) { 25307 // Extract the inputs. 25308 ArgumentsLongHalf args = new ArgumentsLongHalf(); 25309 args.inV = arrayInV[i * 4 + j]; 25310 // Figure out what the outputs should have been. 25311 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25312 CoreMathVerifier.computeConvert(args, target); 25313 // Validate the outputs. 25314 boolean valid = true; 25315 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25316 valid = false; 25317 } 25318 if (!valid) { 25319 if (!errorFound) { 25320 errorFound = true; 25321 message.append("Input inV: "); 25322 appendVariableToMessage(message, args.inV); 25323 message.append("\n"); 25324 message.append("Expected output out: "); 25325 appendVariableToMessage(message, args.out); 25326 message.append("\n"); 25327 message.append("Actual output out: "); 25328 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25329 message.append("\n"); 25330 message.append("Actual output out (in double): "); 25331 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25332 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25333 message.append(" FAIL"); 25334 } 25335 message.append("\n"); 25336 message.append("Errors at"); 25337 } 25338 message.append(" ["); 25339 message.append(Integer.toString(i)); 25340 message.append(", "); 25341 message.append(Integer.toString(j)); 25342 message.append("]"); 25343 } 25344 } 25345 } 25346 assertFalse("Incorrect output for checkConvertLong4Half4" + 25347 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25348 } 25349 25350 public class ArgumentsUlongHalf { 25351 public long inV; 25352 public Target.Floaty out; 25353 } 25354 checkConvertUlong2Half2()25355 private void checkConvertUlong2Half2() { 25356 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x8754723al, false, 64); 25357 try { 25358 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25359 script.forEach_testConvertHalf2Ulong2Half2(inV, out); 25360 verifyResultsConvertUlong2Half2(inV, out, false); 25361 } catch (Exception e) { 25362 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ulong2Half2: " + e.toString()); 25363 } 25364 try { 25365 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE); 25366 scriptRelaxed.forEach_testConvertHalf2Ulong2Half2(inV, out); 25367 verifyResultsConvertUlong2Half2(inV, out, true); 25368 } catch (Exception e) { 25369 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ulong2Half2: " + e.toString()); 25370 } 25371 } 25372 verifyResultsConvertUlong2Half2(Allocation inV, Allocation out, boolean relaxed)25373 private void verifyResultsConvertUlong2Half2(Allocation inV, Allocation out, boolean relaxed) { 25374 long[] arrayInV = new long[INPUTSIZE * 2]; 25375 Arrays.fill(arrayInV, (long) 42); 25376 inV.copyTo(arrayInV); 25377 short[] arrayOut = new short[INPUTSIZE * 2]; 25378 Arrays.fill(arrayOut, (short) 42); 25379 out.copyTo(arrayOut); 25380 StringBuilder message = new StringBuilder(); 25381 boolean errorFound = false; 25382 for (int i = 0; i < INPUTSIZE; i++) { 25383 for (int j = 0; j < 2 ; j++) { 25384 // Extract the inputs. 25385 ArgumentsUlongHalf args = new ArgumentsUlongHalf(); 25386 args.inV = arrayInV[i * 2 + j]; 25387 // Figure out what the outputs should have been. 25388 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25389 CoreMathVerifier.computeConvert(args, target); 25390 // Validate the outputs. 25391 boolean valid = true; 25392 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25393 valid = false; 25394 } 25395 if (!valid) { 25396 if (!errorFound) { 25397 errorFound = true; 25398 message.append("Input inV: "); 25399 appendVariableToMessage(message, args.inV); 25400 message.append("\n"); 25401 message.append("Expected output out: "); 25402 appendVariableToMessage(message, args.out); 25403 message.append("\n"); 25404 message.append("Actual output out: "); 25405 appendVariableToMessage(message, arrayOut[i * 2 + j]); 25406 message.append("\n"); 25407 message.append("Actual output out (in double): "); 25408 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j])); 25409 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 2 + j]))) { 25410 message.append(" FAIL"); 25411 } 25412 message.append("\n"); 25413 message.append("Errors at"); 25414 } 25415 message.append(" ["); 25416 message.append(Integer.toString(i)); 25417 message.append(", "); 25418 message.append(Integer.toString(j)); 25419 message.append("]"); 25420 } 25421 } 25422 } 25423 assertFalse("Incorrect output for checkConvertUlong2Half2" + 25424 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25425 } 25426 checkConvertUlong3Half3()25427 private void checkConvertUlong3Half3() { 25428 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xe65c372el, false, 64); 25429 try { 25430 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25431 script.forEach_testConvertHalf3Ulong3Half3(inV, out); 25432 verifyResultsConvertUlong3Half3(inV, out, false); 25433 } catch (Exception e) { 25434 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ulong3Half3: " + e.toString()); 25435 } 25436 try { 25437 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE); 25438 scriptRelaxed.forEach_testConvertHalf3Ulong3Half3(inV, out); 25439 verifyResultsConvertUlong3Half3(inV, out, true); 25440 } catch (Exception e) { 25441 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ulong3Half3: " + e.toString()); 25442 } 25443 } 25444 verifyResultsConvertUlong3Half3(Allocation inV, Allocation out, boolean relaxed)25445 private void verifyResultsConvertUlong3Half3(Allocation inV, Allocation out, boolean relaxed) { 25446 long[] arrayInV = new long[INPUTSIZE * 4]; 25447 Arrays.fill(arrayInV, (long) 42); 25448 inV.copyTo(arrayInV); 25449 short[] arrayOut = new short[INPUTSIZE * 4]; 25450 Arrays.fill(arrayOut, (short) 42); 25451 out.copyTo(arrayOut); 25452 StringBuilder message = new StringBuilder(); 25453 boolean errorFound = false; 25454 for (int i = 0; i < INPUTSIZE; i++) { 25455 for (int j = 0; j < 3 ; j++) { 25456 // Extract the inputs. 25457 ArgumentsUlongHalf args = new ArgumentsUlongHalf(); 25458 args.inV = arrayInV[i * 4 + j]; 25459 // Figure out what the outputs should have been. 25460 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25461 CoreMathVerifier.computeConvert(args, target); 25462 // Validate the outputs. 25463 boolean valid = true; 25464 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25465 valid = false; 25466 } 25467 if (!valid) { 25468 if (!errorFound) { 25469 errorFound = true; 25470 message.append("Input inV: "); 25471 appendVariableToMessage(message, args.inV); 25472 message.append("\n"); 25473 message.append("Expected output out: "); 25474 appendVariableToMessage(message, args.out); 25475 message.append("\n"); 25476 message.append("Actual output out: "); 25477 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25478 message.append("\n"); 25479 message.append("Actual output out (in double): "); 25480 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25481 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25482 message.append(" FAIL"); 25483 } 25484 message.append("\n"); 25485 message.append("Errors at"); 25486 } 25487 message.append(" ["); 25488 message.append(Integer.toString(i)); 25489 message.append(", "); 25490 message.append(Integer.toString(j)); 25491 message.append("]"); 25492 } 25493 } 25494 } 25495 assertFalse("Incorrect output for checkConvertUlong3Half3" + 25496 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25497 } 25498 checkConvertUlong4Half4()25499 private void checkConvertUlong4Half4() { 25500 Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x4563fc22l, false, 64); 25501 try { 25502 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25503 script.forEach_testConvertHalf4Ulong4Half4(inV, out); 25504 verifyResultsConvertUlong4Half4(inV, out, false); 25505 } catch (Exception e) { 25506 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ulong4Half4: " + e.toString()); 25507 } 25508 try { 25509 Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE); 25510 scriptRelaxed.forEach_testConvertHalf4Ulong4Half4(inV, out); 25511 verifyResultsConvertUlong4Half4(inV, out, true); 25512 } catch (Exception e) { 25513 throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ulong4Half4: " + e.toString()); 25514 } 25515 } 25516 verifyResultsConvertUlong4Half4(Allocation inV, Allocation out, boolean relaxed)25517 private void verifyResultsConvertUlong4Half4(Allocation inV, Allocation out, boolean relaxed) { 25518 long[] arrayInV = new long[INPUTSIZE * 4]; 25519 Arrays.fill(arrayInV, (long) 42); 25520 inV.copyTo(arrayInV); 25521 short[] arrayOut = new short[INPUTSIZE * 4]; 25522 Arrays.fill(arrayOut, (short) 42); 25523 out.copyTo(arrayOut); 25524 StringBuilder message = new StringBuilder(); 25525 boolean errorFound = false; 25526 for (int i = 0; i < INPUTSIZE; i++) { 25527 for (int j = 0; j < 4 ; j++) { 25528 // Extract the inputs. 25529 ArgumentsUlongHalf args = new ArgumentsUlongHalf(); 25530 args.inV = arrayInV[i * 4 + j]; 25531 // Figure out what the outputs should have been. 25532 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.HALF, relaxed); 25533 CoreMathVerifier.computeConvert(args, target); 25534 // Validate the outputs. 25535 boolean valid = true; 25536 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25537 valid = false; 25538 } 25539 if (!valid) { 25540 if (!errorFound) { 25541 errorFound = true; 25542 message.append("Input inV: "); 25543 appendVariableToMessage(message, args.inV); 25544 message.append("\n"); 25545 message.append("Expected output out: "); 25546 appendVariableToMessage(message, args.out); 25547 message.append("\n"); 25548 message.append("Actual output out: "); 25549 appendVariableToMessage(message, arrayOut[i * 4 + j]); 25550 message.append("\n"); 25551 message.append("Actual output out (in double): "); 25552 appendVariableToMessage(message, Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j])); 25553 if (!args.out.couldBe(Float16Utils.convertFloat16ToDouble(arrayOut[i * 4 + j]))) { 25554 message.append(" FAIL"); 25555 } 25556 message.append("\n"); 25557 message.append("Errors at"); 25558 } 25559 message.append(" ["); 25560 message.append(Integer.toString(i)); 25561 message.append(", "); 25562 message.append(Integer.toString(j)); 25563 message.append("]"); 25564 } 25565 } 25566 } 25567 assertFalse("Incorrect output for checkConvertUlong4Half4" + 25568 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); 25569 } 25570 testConvert()25571 public void testConvert() { 25572 checkConvertFloat2Float2(); 25573 checkConvertFloat3Float3(); 25574 checkConvertFloat4Float4(); 25575 checkConvertChar2Float2(); 25576 checkConvertChar3Float3(); 25577 checkConvertChar4Float4(); 25578 checkConvertUchar2Float2(); 25579 checkConvertUchar3Float3(); 25580 checkConvertUchar4Float4(); 25581 checkConvertShort2Float2(); 25582 checkConvertShort3Float3(); 25583 checkConvertShort4Float4(); 25584 checkConvertUshort2Float2(); 25585 checkConvertUshort3Float3(); 25586 checkConvertUshort4Float4(); 25587 checkConvertInt2Float2(); 25588 checkConvertInt3Float3(); 25589 checkConvertInt4Float4(); 25590 checkConvertUint2Float2(); 25591 checkConvertUint3Float3(); 25592 checkConvertUint4Float4(); 25593 checkConvertFloat2Char2(); 25594 checkConvertFloat3Char3(); 25595 checkConvertFloat4Char4(); 25596 checkConvertChar2Char2(); 25597 checkConvertChar3Char3(); 25598 checkConvertChar4Char4(); 25599 checkConvertUchar2Char2(); 25600 checkConvertUchar3Char3(); 25601 checkConvertUchar4Char4(); 25602 checkConvertShort2Char2(); 25603 checkConvertShort3Char3(); 25604 checkConvertShort4Char4(); 25605 checkConvertUshort2Char2(); 25606 checkConvertUshort3Char3(); 25607 checkConvertUshort4Char4(); 25608 checkConvertInt2Char2(); 25609 checkConvertInt3Char3(); 25610 checkConvertInt4Char4(); 25611 checkConvertUint2Char2(); 25612 checkConvertUint3Char3(); 25613 checkConvertUint4Char4(); 25614 checkConvertFloat2Uchar2(); 25615 checkConvertFloat3Uchar3(); 25616 checkConvertFloat4Uchar4(); 25617 checkConvertChar2Uchar2(); 25618 checkConvertChar3Uchar3(); 25619 checkConvertChar4Uchar4(); 25620 checkConvertUchar2Uchar2(); 25621 checkConvertUchar3Uchar3(); 25622 checkConvertUchar4Uchar4(); 25623 checkConvertShort2Uchar2(); 25624 checkConvertShort3Uchar3(); 25625 checkConvertShort4Uchar4(); 25626 checkConvertUshort2Uchar2(); 25627 checkConvertUshort3Uchar3(); 25628 checkConvertUshort4Uchar4(); 25629 checkConvertInt2Uchar2(); 25630 checkConvertInt3Uchar3(); 25631 checkConvertInt4Uchar4(); 25632 checkConvertUint2Uchar2(); 25633 checkConvertUint3Uchar3(); 25634 checkConvertUint4Uchar4(); 25635 checkConvertFloat2Short2(); 25636 checkConvertFloat3Short3(); 25637 checkConvertFloat4Short4(); 25638 checkConvertChar2Short2(); 25639 checkConvertChar3Short3(); 25640 checkConvertChar4Short4(); 25641 checkConvertUchar2Short2(); 25642 checkConvertUchar3Short3(); 25643 checkConvertUchar4Short4(); 25644 checkConvertShort2Short2(); 25645 checkConvertShort3Short3(); 25646 checkConvertShort4Short4(); 25647 checkConvertUshort2Short2(); 25648 checkConvertUshort3Short3(); 25649 checkConvertUshort4Short4(); 25650 checkConvertInt2Short2(); 25651 checkConvertInt3Short3(); 25652 checkConvertInt4Short4(); 25653 checkConvertUint2Short2(); 25654 checkConvertUint3Short3(); 25655 checkConvertUint4Short4(); 25656 checkConvertFloat2Ushort2(); 25657 checkConvertFloat3Ushort3(); 25658 checkConvertFloat4Ushort4(); 25659 checkConvertChar2Ushort2(); 25660 checkConvertChar3Ushort3(); 25661 checkConvertChar4Ushort4(); 25662 checkConvertUchar2Ushort2(); 25663 checkConvertUchar3Ushort3(); 25664 checkConvertUchar4Ushort4(); 25665 checkConvertShort2Ushort2(); 25666 checkConvertShort3Ushort3(); 25667 checkConvertShort4Ushort4(); 25668 checkConvertUshort2Ushort2(); 25669 checkConvertUshort3Ushort3(); 25670 checkConvertUshort4Ushort4(); 25671 checkConvertInt2Ushort2(); 25672 checkConvertInt3Ushort3(); 25673 checkConvertInt4Ushort4(); 25674 checkConvertUint2Ushort2(); 25675 checkConvertUint3Ushort3(); 25676 checkConvertUint4Ushort4(); 25677 checkConvertFloat2Int2(); 25678 checkConvertFloat3Int3(); 25679 checkConvertFloat4Int4(); 25680 checkConvertChar2Int2(); 25681 checkConvertChar3Int3(); 25682 checkConvertChar4Int4(); 25683 checkConvertUchar2Int2(); 25684 checkConvertUchar3Int3(); 25685 checkConvertUchar4Int4(); 25686 checkConvertShort2Int2(); 25687 checkConvertShort3Int3(); 25688 checkConvertShort4Int4(); 25689 checkConvertUshort2Int2(); 25690 checkConvertUshort3Int3(); 25691 checkConvertUshort4Int4(); 25692 checkConvertInt2Int2(); 25693 checkConvertInt3Int3(); 25694 checkConvertInt4Int4(); 25695 checkConvertUint2Int2(); 25696 checkConvertUint3Int3(); 25697 checkConvertUint4Int4(); 25698 checkConvertFloat2Uint2(); 25699 checkConvertFloat3Uint3(); 25700 checkConvertFloat4Uint4(); 25701 checkConvertChar2Uint2(); 25702 checkConvertChar3Uint3(); 25703 checkConvertChar4Uint4(); 25704 checkConvertUchar2Uint2(); 25705 checkConvertUchar3Uint3(); 25706 checkConvertUchar4Uint4(); 25707 checkConvertShort2Uint2(); 25708 checkConvertShort3Uint3(); 25709 checkConvertShort4Uint4(); 25710 checkConvertUshort2Uint2(); 25711 checkConvertUshort3Uint3(); 25712 checkConvertUshort4Uint4(); 25713 checkConvertInt2Uint2(); 25714 checkConvertInt3Uint3(); 25715 checkConvertInt4Uint4(); 25716 checkConvertUint2Uint2(); 25717 checkConvertUint3Uint3(); 25718 checkConvertUint4Uint4(); 25719 checkConvertDouble2Double2(); 25720 checkConvertDouble3Double3(); 25721 checkConvertDouble4Double4(); 25722 checkConvertLong2Double2(); 25723 checkConvertLong3Double3(); 25724 checkConvertLong4Double4(); 25725 checkConvertUlong2Double2(); 25726 checkConvertUlong3Double3(); 25727 checkConvertUlong4Double4(); 25728 checkConvertDouble2Long2(); 25729 checkConvertDouble3Long3(); 25730 checkConvertDouble4Long4(); 25731 checkConvertLong2Long2(); 25732 checkConvertLong3Long3(); 25733 checkConvertLong4Long4(); 25734 checkConvertUlong2Long2(); 25735 checkConvertUlong3Long3(); 25736 checkConvertUlong4Long4(); 25737 checkConvertDouble2Ulong2(); 25738 checkConvertDouble3Ulong3(); 25739 checkConvertDouble4Ulong4(); 25740 checkConvertLong2Ulong2(); 25741 checkConvertLong3Ulong3(); 25742 checkConvertLong4Ulong4(); 25743 checkConvertUlong2Ulong2(); 25744 checkConvertUlong3Ulong3(); 25745 checkConvertUlong4Ulong4(); 25746 checkConvertDouble2Float2(); 25747 checkConvertDouble3Float3(); 25748 checkConvertDouble4Float4(); 25749 checkConvertLong2Float2(); 25750 checkConvertLong3Float3(); 25751 checkConvertLong4Float4(); 25752 checkConvertUlong2Float2(); 25753 checkConvertUlong3Float3(); 25754 checkConvertUlong4Float4(); 25755 checkConvertDouble2Char2(); 25756 checkConvertDouble3Char3(); 25757 checkConvertDouble4Char4(); 25758 checkConvertLong2Char2(); 25759 checkConvertLong3Char3(); 25760 checkConvertLong4Char4(); 25761 checkConvertUlong2Char2(); 25762 checkConvertUlong3Char3(); 25763 checkConvertUlong4Char4(); 25764 checkConvertDouble2Uchar2(); 25765 checkConvertDouble3Uchar3(); 25766 checkConvertDouble4Uchar4(); 25767 checkConvertLong2Uchar2(); 25768 checkConvertLong3Uchar3(); 25769 checkConvertLong4Uchar4(); 25770 checkConvertUlong2Uchar2(); 25771 checkConvertUlong3Uchar3(); 25772 checkConvertUlong4Uchar4(); 25773 checkConvertDouble2Short2(); 25774 checkConvertDouble3Short3(); 25775 checkConvertDouble4Short4(); 25776 checkConvertLong2Short2(); 25777 checkConvertLong3Short3(); 25778 checkConvertLong4Short4(); 25779 checkConvertUlong2Short2(); 25780 checkConvertUlong3Short3(); 25781 checkConvertUlong4Short4(); 25782 checkConvertDouble2Ushort2(); 25783 checkConvertDouble3Ushort3(); 25784 checkConvertDouble4Ushort4(); 25785 checkConvertLong2Ushort2(); 25786 checkConvertLong3Ushort3(); 25787 checkConvertLong4Ushort4(); 25788 checkConvertUlong2Ushort2(); 25789 checkConvertUlong3Ushort3(); 25790 checkConvertUlong4Ushort4(); 25791 checkConvertDouble2Int2(); 25792 checkConvertDouble3Int3(); 25793 checkConvertDouble4Int4(); 25794 checkConvertLong2Int2(); 25795 checkConvertLong3Int3(); 25796 checkConvertLong4Int4(); 25797 checkConvertUlong2Int2(); 25798 checkConvertUlong3Int3(); 25799 checkConvertUlong4Int4(); 25800 checkConvertDouble2Uint2(); 25801 checkConvertDouble3Uint3(); 25802 checkConvertDouble4Uint4(); 25803 checkConvertLong2Uint2(); 25804 checkConvertLong3Uint3(); 25805 checkConvertLong4Uint4(); 25806 checkConvertUlong2Uint2(); 25807 checkConvertUlong3Uint3(); 25808 checkConvertUlong4Uint4(); 25809 checkConvertFloat2Double2(); 25810 checkConvertFloat3Double3(); 25811 checkConvertFloat4Double4(); 25812 checkConvertChar2Double2(); 25813 checkConvertChar3Double3(); 25814 checkConvertChar4Double4(); 25815 checkConvertUchar2Double2(); 25816 checkConvertUchar3Double3(); 25817 checkConvertUchar4Double4(); 25818 checkConvertShort2Double2(); 25819 checkConvertShort3Double3(); 25820 checkConvertShort4Double4(); 25821 checkConvertUshort2Double2(); 25822 checkConvertUshort3Double3(); 25823 checkConvertUshort4Double4(); 25824 checkConvertInt2Double2(); 25825 checkConvertInt3Double3(); 25826 checkConvertInt4Double4(); 25827 checkConvertUint2Double2(); 25828 checkConvertUint3Double3(); 25829 checkConvertUint4Double4(); 25830 checkConvertFloat2Long2(); 25831 checkConvertFloat3Long3(); 25832 checkConvertFloat4Long4(); 25833 checkConvertChar2Long2(); 25834 checkConvertChar3Long3(); 25835 checkConvertChar4Long4(); 25836 checkConvertUchar2Long2(); 25837 checkConvertUchar3Long3(); 25838 checkConvertUchar4Long4(); 25839 checkConvertShort2Long2(); 25840 checkConvertShort3Long3(); 25841 checkConvertShort4Long4(); 25842 checkConvertUshort2Long2(); 25843 checkConvertUshort3Long3(); 25844 checkConvertUshort4Long4(); 25845 checkConvertInt2Long2(); 25846 checkConvertInt3Long3(); 25847 checkConvertInt4Long4(); 25848 checkConvertUint2Long2(); 25849 checkConvertUint3Long3(); 25850 checkConvertUint4Long4(); 25851 checkConvertFloat2Ulong2(); 25852 checkConvertFloat3Ulong3(); 25853 checkConvertFloat4Ulong4(); 25854 checkConvertChar2Ulong2(); 25855 checkConvertChar3Ulong3(); 25856 checkConvertChar4Ulong4(); 25857 checkConvertUchar2Ulong2(); 25858 checkConvertUchar3Ulong3(); 25859 checkConvertUchar4Ulong4(); 25860 checkConvertShort2Ulong2(); 25861 checkConvertShort3Ulong3(); 25862 checkConvertShort4Ulong4(); 25863 checkConvertUshort2Ulong2(); 25864 checkConvertUshort3Ulong3(); 25865 checkConvertUshort4Ulong4(); 25866 checkConvertInt2Ulong2(); 25867 checkConvertInt3Ulong3(); 25868 checkConvertInt4Ulong4(); 25869 checkConvertUint2Ulong2(); 25870 checkConvertUint3Ulong3(); 25871 checkConvertUint4Ulong4(); 25872 checkConvertHalf2Half2(); 25873 checkConvertHalf3Half3(); 25874 checkConvertHalf4Half4(); 25875 checkConvertHalf2Float2(); 25876 checkConvertHalf3Float3(); 25877 checkConvertHalf4Float4(); 25878 checkConvertHalf2Double2(); 25879 checkConvertHalf3Double3(); 25880 checkConvertHalf4Double4(); 25881 checkConvertHalf2Char2(); 25882 checkConvertHalf3Char3(); 25883 checkConvertHalf4Char4(); 25884 checkConvertHalf2Uchar2(); 25885 checkConvertHalf3Uchar3(); 25886 checkConvertHalf4Uchar4(); 25887 checkConvertHalf2Short2(); 25888 checkConvertHalf3Short3(); 25889 checkConvertHalf4Short4(); 25890 checkConvertHalf2Ushort2(); 25891 checkConvertHalf3Ushort3(); 25892 checkConvertHalf4Ushort4(); 25893 checkConvertHalf2Int2(); 25894 checkConvertHalf3Int3(); 25895 checkConvertHalf4Int4(); 25896 checkConvertHalf2Uint2(); 25897 checkConvertHalf3Uint3(); 25898 checkConvertHalf4Uint4(); 25899 checkConvertHalf2Long2(); 25900 checkConvertHalf3Long3(); 25901 checkConvertHalf4Long4(); 25902 checkConvertHalf2Ulong2(); 25903 checkConvertHalf3Ulong3(); 25904 checkConvertHalf4Ulong4(); 25905 checkConvertFloat2Half2(); 25906 checkConvertFloat3Half3(); 25907 checkConvertFloat4Half4(); 25908 checkConvertDouble2Half2(); 25909 checkConvertDouble3Half3(); 25910 checkConvertDouble4Half4(); 25911 checkConvertChar2Half2(); 25912 checkConvertChar3Half3(); 25913 checkConvertChar4Half4(); 25914 checkConvertUchar2Half2(); 25915 checkConvertUchar3Half3(); 25916 checkConvertUchar4Half4(); 25917 checkConvertShort2Half2(); 25918 checkConvertShort3Half3(); 25919 checkConvertShort4Half4(); 25920 checkConvertUshort2Half2(); 25921 checkConvertUshort3Half3(); 25922 checkConvertUshort4Half4(); 25923 checkConvertInt2Half2(); 25924 checkConvertInt3Half3(); 25925 checkConvertInt4Half4(); 25926 checkConvertUint2Half2(); 25927 checkConvertUint3Half3(); 25928 checkConvertUint4Half4(); 25929 checkConvertLong2Half2(); 25930 checkConvertLong3Half3(); 25931 checkConvertLong4Half4(); 25932 checkConvertUlong2Half2(); 25933 checkConvertUlong3Half3(); 25934 checkConvertUlong4Half4(); 25935 } 25936 } 25937