Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 // Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
     18 
     19 package android.renderscript.cts;
     20 
     21 import android.renderscript.Allocation;
     22 import android.renderscript.RSRuntimeException;
     23 import android.renderscript.Element;
     24 
     25 public class TestClamp extends RSBaseCompute {
     26 
     27     private ScriptC_TestClamp script;
     28     private ScriptC_TestClampRelaxed scriptRelaxed;
     29 
     30     @Override
     31     protected void setUp() throws Exception {
     32         super.setUp();
     33         script = new ScriptC_TestClamp(mRS);
     34         scriptRelaxed = new ScriptC_TestClampRelaxed(mRS);
     35     }
     36 
     37     public class ArgumentsFloatFloatFloatFloat {
     38         public float inValue;
     39         public float inMinValue;
     40         public float inMaxValue;
     41         public Target.Floaty out;
     42     }
     43 
     44     private void checkClampFloatFloatFloatFloat() {
     45         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7e886d7cc83c447dl, false);
     46         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcebf6f230234027l, false);
     47         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcebf6e6c180322dl, false);
     48         enforceOrdering(inMinValue, inMaxValue);
     49         try {
     50             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
     51             script.set_gAllocInMinValue(inMinValue);
     52             script.set_gAllocInMaxValue(inMaxValue);
     53             script.forEach_testClampFloatFloatFloatFloat(inValue, out);
     54             verifyResultsClampFloatFloatFloatFloat(inValue, inMinValue, inMaxValue, out, false);
     55         } catch (Exception e) {
     56             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloatFloatFloatFloat: " + e.toString());
     57         }
     58         try {
     59             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
     60             scriptRelaxed.set_gAllocInMinValue(inMinValue);
     61             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
     62             scriptRelaxed.forEach_testClampFloatFloatFloatFloat(inValue, out);
     63             verifyResultsClampFloatFloatFloatFloat(inValue, inMinValue, inMaxValue, out, true);
     64         } catch (Exception e) {
     65             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloatFloatFloatFloat: " + e.toString());
     66         }
     67     }
     68 
     69     private void verifyResultsClampFloatFloatFloatFloat(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
     70         float[] arrayInValue = new float[INPUTSIZE * 1];
     71         inValue.copyTo(arrayInValue);
     72         float[] arrayInMinValue = new float[INPUTSIZE * 1];
     73         inMinValue.copyTo(arrayInMinValue);
     74         float[] arrayInMaxValue = new float[INPUTSIZE * 1];
     75         inMaxValue.copyTo(arrayInMaxValue);
     76         float[] arrayOut = new float[INPUTSIZE * 1];
     77         out.copyTo(arrayOut);
     78         for (int i = 0; i < INPUTSIZE; i++) {
     79             for (int j = 0; j < 1 ; j++) {
     80                 // Extract the inputs.
     81                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
     82                 args.inValue = arrayInValue[i];
     83                 args.inMinValue = arrayInMinValue[i];
     84                 args.inMaxValue = arrayInMaxValue[i];
     85                 // Figure out what the outputs should have been.
     86                 Target target = new Target(relaxed);
     87                 CoreMathVerifier.computeClamp(args, target);
     88                 // Validate the outputs.
     89                 boolean valid = true;
     90                 if (!args.out.couldBe(arrayOut[i * 1 + j])) {
     91                     valid = false;
     92                 }
     93                 if (!valid) {
     94                     StringBuilder message = new StringBuilder();
     95                     message.append("Input inValue: ");
     96                     message.append(String.format("%14.8g {%8x} %15a",
     97                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
     98                     message.append("\n");
     99                     message.append("Input inMinValue: ");
    100                     message.append(String.format("%14.8g {%8x} %15a",
    101                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    102                     message.append("\n");
    103                     message.append("Input inMaxValue: ");
    104                     message.append(String.format("%14.8g {%8x} %15a",
    105                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    106                     message.append("\n");
    107                     message.append("Expected output out: ");
    108                     message.append(args.out.toString());
    109                     message.append("\n");
    110                     message.append("Actual   output out: ");
    111                     message.append(String.format("%14.8g {%8x} %15a",
    112                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
    113                     if (!args.out.couldBe(arrayOut[i * 1 + j])) {
    114                         message.append(" FAIL");
    115                     }
    116                     message.append("\n");
    117                     assertTrue("Incorrect output for checkClampFloatFloatFloatFloat" +
    118                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    119                 }
    120             }
    121         }
    122     }
    123 
    124     private void checkClampFloat2Float2Float2Float2() {
    125         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa0d28bf142b07a5l, false);
    126         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb4e5c5f6ea8fc01fl, false);
    127         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb4e5c5eb7becb225l, false);
    128         enforceOrdering(inMinValue, inMaxValue);
    129         try {
    130             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    131             script.set_gAllocInMinValue(inMinValue);
    132             script.set_gAllocInMaxValue(inMaxValue);
    133             script.forEach_testClampFloat2Float2Float2Float2(inValue, out);
    134             verifyResultsClampFloat2Float2Float2Float2(inValue, inMinValue, inMaxValue, out, false);
    135         } catch (Exception e) {
    136             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2Float2Float2Float2: " + e.toString());
    137         }
    138         try {
    139             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    140             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    141             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    142             scriptRelaxed.forEach_testClampFloat2Float2Float2Float2(inValue, out);
    143             verifyResultsClampFloat2Float2Float2Float2(inValue, inMinValue, inMaxValue, out, true);
    144         } catch (Exception e) {
    145             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2Float2Float2Float2: " + e.toString());
    146         }
    147     }
    148 
    149     private void verifyResultsClampFloat2Float2Float2Float2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    150         float[] arrayInValue = new float[INPUTSIZE * 2];
    151         inValue.copyTo(arrayInValue);
    152         float[] arrayInMinValue = new float[INPUTSIZE * 2];
    153         inMinValue.copyTo(arrayInMinValue);
    154         float[] arrayInMaxValue = new float[INPUTSIZE * 2];
    155         inMaxValue.copyTo(arrayInMaxValue);
    156         float[] arrayOut = new float[INPUTSIZE * 2];
    157         out.copyTo(arrayOut);
    158         for (int i = 0; i < INPUTSIZE; i++) {
    159             for (int j = 0; j < 2 ; j++) {
    160                 // Extract the inputs.
    161                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
    162                 args.inValue = arrayInValue[i * 2 + j];
    163                 args.inMinValue = arrayInMinValue[i * 2 + j];
    164                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
    165                 // Figure out what the outputs should have been.
    166                 Target target = new Target(relaxed);
    167                 CoreMathVerifier.computeClamp(args, target);
    168                 // Validate the outputs.
    169                 boolean valid = true;
    170                 if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    171                     valid = false;
    172                 }
    173                 if (!valid) {
    174                     StringBuilder message = new StringBuilder();
    175                     message.append("Input inValue: ");
    176                     message.append(String.format("%14.8g {%8x} %15a",
    177                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
    178                     message.append("\n");
    179                     message.append("Input inMinValue: ");
    180                     message.append(String.format("%14.8g {%8x} %15a",
    181                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    182                     message.append("\n");
    183                     message.append("Input inMaxValue: ");
    184                     message.append(String.format("%14.8g {%8x} %15a",
    185                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    186                     message.append("\n");
    187                     message.append("Expected output out: ");
    188                     message.append(args.out.toString());
    189                     message.append("\n");
    190                     message.append("Actual   output out: ");
    191                     message.append(String.format("%14.8g {%8x} %15a",
    192                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
    193                     if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    194                         message.append(" FAIL");
    195                     }
    196                     message.append("\n");
    197                     assertTrue("Incorrect output for checkClampFloat2Float2Float2Float2" +
    198                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    199                 }
    200             }
    201         }
    202     }
    203 
    204     private void checkClampFloat3Float3Float3Float3() {
    205         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd3716a4730ad7481l, false);
    206         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc0d239a53946aa73l, false);
    207         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc0d23999caa39c79l, false);
    208         enforceOrdering(inMinValue, inMaxValue);
    209         try {
    210             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    211             script.set_gAllocInMinValue(inMinValue);
    212             script.set_gAllocInMaxValue(inMaxValue);
    213             script.forEach_testClampFloat3Float3Float3Float3(inValue, out);
    214             verifyResultsClampFloat3Float3Float3Float3(inValue, inMinValue, inMaxValue, out, false);
    215         } catch (Exception e) {
    216             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3Float3Float3Float3: " + e.toString());
    217         }
    218         try {
    219             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    220             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    221             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    222             scriptRelaxed.forEach_testClampFloat3Float3Float3Float3(inValue, out);
    223             verifyResultsClampFloat3Float3Float3Float3(inValue, inMinValue, inMaxValue, out, true);
    224         } catch (Exception e) {
    225             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3Float3Float3Float3: " + e.toString());
    226         }
    227     }
    228 
    229     private void verifyResultsClampFloat3Float3Float3Float3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    230         float[] arrayInValue = new float[INPUTSIZE * 4];
    231         inValue.copyTo(arrayInValue);
    232         float[] arrayInMinValue = new float[INPUTSIZE * 4];
    233         inMinValue.copyTo(arrayInMinValue);
    234         float[] arrayInMaxValue = new float[INPUTSIZE * 4];
    235         inMaxValue.copyTo(arrayInMaxValue);
    236         float[] arrayOut = new float[INPUTSIZE * 4];
    237         out.copyTo(arrayOut);
    238         for (int i = 0; i < INPUTSIZE; i++) {
    239             for (int j = 0; j < 3 ; j++) {
    240                 // Extract the inputs.
    241                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
    242                 args.inValue = arrayInValue[i * 4 + j];
    243                 args.inMinValue = arrayInMinValue[i * 4 + j];
    244                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
    245                 // Figure out what the outputs should have been.
    246                 Target target = new Target(relaxed);
    247                 CoreMathVerifier.computeClamp(args, target);
    248                 // Validate the outputs.
    249                 boolean valid = true;
    250                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    251                     valid = false;
    252                 }
    253                 if (!valid) {
    254                     StringBuilder message = new StringBuilder();
    255                     message.append("Input inValue: ");
    256                     message.append(String.format("%14.8g {%8x} %15a",
    257                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
    258                     message.append("\n");
    259                     message.append("Input inMinValue: ");
    260                     message.append(String.format("%14.8g {%8x} %15a",
    261                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    262                     message.append("\n");
    263                     message.append("Input inMaxValue: ");
    264                     message.append(String.format("%14.8g {%8x} %15a",
    265                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    266                     message.append("\n");
    267                     message.append("Expected output out: ");
    268                     message.append(args.out.toString());
    269                     message.append("\n");
    270                     message.append("Actual   output out: ");
    271                     message.append(String.format("%14.8g {%8x} %15a",
    272                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
    273                     if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    274                         message.append(" FAIL");
    275                     }
    276                     message.append("\n");
    277                     assertTrue("Incorrect output for checkClampFloat3Float3Float3Float3" +
    278                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    279                 }
    280             }
    281         }
    282     }
    283 
    284     private void checkClampFloat4Float4Float4Float4() {
    285         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9cd5abcf4d2fe15dl, false);
    286         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xccbead5387fd94c7l, false);
    287         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xccbead48195a86cdl, false);
    288         enforceOrdering(inMinValue, inMaxValue);
    289         try {
    290             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    291             script.set_gAllocInMinValue(inMinValue);
    292             script.set_gAllocInMaxValue(inMaxValue);
    293             script.forEach_testClampFloat4Float4Float4Float4(inValue, out);
    294             verifyResultsClampFloat4Float4Float4Float4(inValue, inMinValue, inMaxValue, out, false);
    295         } catch (Exception e) {
    296             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4Float4Float4Float4: " + e.toString());
    297         }
    298         try {
    299             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    300             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    301             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    302             scriptRelaxed.forEach_testClampFloat4Float4Float4Float4(inValue, out);
    303             verifyResultsClampFloat4Float4Float4Float4(inValue, inMinValue, inMaxValue, out, true);
    304         } catch (Exception e) {
    305             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4Float4Float4Float4: " + e.toString());
    306         }
    307     }
    308 
    309     private void verifyResultsClampFloat4Float4Float4Float4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    310         float[] arrayInValue = new float[INPUTSIZE * 4];
    311         inValue.copyTo(arrayInValue);
    312         float[] arrayInMinValue = new float[INPUTSIZE * 4];
    313         inMinValue.copyTo(arrayInMinValue);
    314         float[] arrayInMaxValue = new float[INPUTSIZE * 4];
    315         inMaxValue.copyTo(arrayInMaxValue);
    316         float[] arrayOut = new float[INPUTSIZE * 4];
    317         out.copyTo(arrayOut);
    318         for (int i = 0; i < INPUTSIZE; i++) {
    319             for (int j = 0; j < 4 ; j++) {
    320                 // Extract the inputs.
    321                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
    322                 args.inValue = arrayInValue[i * 4 + j];
    323                 args.inMinValue = arrayInMinValue[i * 4 + j];
    324                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
    325                 // Figure out what the outputs should have been.
    326                 Target target = new Target(relaxed);
    327                 CoreMathVerifier.computeClamp(args, target);
    328                 // Validate the outputs.
    329                 boolean valid = true;
    330                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    331                     valid = false;
    332                 }
    333                 if (!valid) {
    334                     StringBuilder message = new StringBuilder();
    335                     message.append("Input inValue: ");
    336                     message.append(String.format("%14.8g {%8x} %15a",
    337                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
    338                     message.append("\n");
    339                     message.append("Input inMinValue: ");
    340                     message.append(String.format("%14.8g {%8x} %15a",
    341                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    342                     message.append("\n");
    343                     message.append("Input inMaxValue: ");
    344                     message.append(String.format("%14.8g {%8x} %15a",
    345                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    346                     message.append("\n");
    347                     message.append("Expected output out: ");
    348                     message.append(args.out.toString());
    349                     message.append("\n");
    350                     message.append("Actual   output out: ");
    351                     message.append(String.format("%14.8g {%8x} %15a",
    352                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
    353                     if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    354                         message.append(" FAIL");
    355                     }
    356                     message.append("\n");
    357                     assertTrue("Incorrect output for checkClampFloat4Float4Float4Float4" +
    358                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    359                 }
    360             }
    361         }
    362     }
    363 
    364     private void checkClampFloat2FloatFloatFloat2() {
    365         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x71623fb3f1fca1a1l, false);
    366         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x148e792e1a6253d3l, false);
    367         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x148e7922abbf45d9l, false);
    368         enforceOrdering(inMinValue, inMaxValue);
    369         try {
    370             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    371             script.set_gAllocInMinValue(inMinValue);
    372             script.set_gAllocInMaxValue(inMaxValue);
    373             script.forEach_testClampFloat2FloatFloatFloat2(inValue, out);
    374             verifyResultsClampFloat2FloatFloatFloat2(inValue, inMinValue, inMaxValue, out, false);
    375         } catch (Exception e) {
    376             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2FloatFloatFloat2: " + e.toString());
    377         }
    378         try {
    379             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    380             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    381             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    382             scriptRelaxed.forEach_testClampFloat2FloatFloatFloat2(inValue, out);
    383             verifyResultsClampFloat2FloatFloatFloat2(inValue, inMinValue, inMaxValue, out, true);
    384         } catch (Exception e) {
    385             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2FloatFloatFloat2: " + e.toString());
    386         }
    387     }
    388 
    389     private void verifyResultsClampFloat2FloatFloatFloat2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    390         float[] arrayInValue = new float[INPUTSIZE * 2];
    391         inValue.copyTo(arrayInValue);
    392         float[] arrayInMinValue = new float[INPUTSIZE * 1];
    393         inMinValue.copyTo(arrayInMinValue);
    394         float[] arrayInMaxValue = new float[INPUTSIZE * 1];
    395         inMaxValue.copyTo(arrayInMaxValue);
    396         float[] arrayOut = new float[INPUTSIZE * 2];
    397         out.copyTo(arrayOut);
    398         for (int i = 0; i < INPUTSIZE; i++) {
    399             for (int j = 0; j < 2 ; j++) {
    400                 // Extract the inputs.
    401                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
    402                 args.inValue = arrayInValue[i * 2 + j];
    403                 args.inMinValue = arrayInMinValue[i];
    404                 args.inMaxValue = arrayInMaxValue[i];
    405                 // Figure out what the outputs should have been.
    406                 Target target = new Target(relaxed);
    407                 CoreMathVerifier.computeClamp(args, target);
    408                 // Validate the outputs.
    409                 boolean valid = true;
    410                 if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    411                     valid = false;
    412                 }
    413                 if (!valid) {
    414                     StringBuilder message = new StringBuilder();
    415                     message.append("Input inValue: ");
    416                     message.append(String.format("%14.8g {%8x} %15a",
    417                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
    418                     message.append("\n");
    419                     message.append("Input inMinValue: ");
    420                     message.append(String.format("%14.8g {%8x} %15a",
    421                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    422                     message.append("\n");
    423                     message.append("Input inMaxValue: ");
    424                     message.append(String.format("%14.8g {%8x} %15a",
    425                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    426                     message.append("\n");
    427                     message.append("Expected output out: ");
    428                     message.append(args.out.toString());
    429                     message.append("\n");
    430                     message.append("Actual   output out: ");
    431                     message.append(String.format("%14.8g {%8x} %15a",
    432                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
    433                     if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    434                         message.append(" FAIL");
    435                     }
    436                     message.append("\n");
    437                     assertTrue("Incorrect output for checkClampFloat2FloatFloatFloat2" +
    438                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    439                 }
    440             }
    441         }
    442     }
    443 
    444     private void checkClampFloat3FloatFloatFloat3() {
    445         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc06893ff6ab8cf27l, false);
    446         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1f4444b84d90bbc5l, false);
    447         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1f4444acdeedadcbl, false);
    448         enforceOrdering(inMinValue, inMaxValue);
    449         try {
    450             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    451             script.set_gAllocInMinValue(inMinValue);
    452             script.set_gAllocInMaxValue(inMaxValue);
    453             script.forEach_testClampFloat3FloatFloatFloat3(inValue, out);
    454             verifyResultsClampFloat3FloatFloatFloat3(inValue, inMinValue, inMaxValue, out, false);
    455         } catch (Exception e) {
    456             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3FloatFloatFloat3: " + e.toString());
    457         }
    458         try {
    459             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    460             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    461             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    462             scriptRelaxed.forEach_testClampFloat3FloatFloatFloat3(inValue, out);
    463             verifyResultsClampFloat3FloatFloatFloat3(inValue, inMinValue, inMaxValue, out, true);
    464         } catch (Exception e) {
    465             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3FloatFloatFloat3: " + e.toString());
    466         }
    467     }
    468 
    469     private void verifyResultsClampFloat3FloatFloatFloat3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    470         float[] arrayInValue = new float[INPUTSIZE * 4];
    471         inValue.copyTo(arrayInValue);
    472         float[] arrayInMinValue = new float[INPUTSIZE * 1];
    473         inMinValue.copyTo(arrayInMinValue);
    474         float[] arrayInMaxValue = new float[INPUTSIZE * 1];
    475         inMaxValue.copyTo(arrayInMaxValue);
    476         float[] arrayOut = new float[INPUTSIZE * 4];
    477         out.copyTo(arrayOut);
    478         for (int i = 0; i < INPUTSIZE; i++) {
    479             for (int j = 0; j < 3 ; j++) {
    480                 // Extract the inputs.
    481                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
    482                 args.inValue = arrayInValue[i * 4 + j];
    483                 args.inMinValue = arrayInMinValue[i];
    484                 args.inMaxValue = arrayInMaxValue[i];
    485                 // Figure out what the outputs should have been.
    486                 Target target = new Target(relaxed);
    487                 CoreMathVerifier.computeClamp(args, target);
    488                 // Validate the outputs.
    489                 boolean valid = true;
    490                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    491                     valid = false;
    492                 }
    493                 if (!valid) {
    494                     StringBuilder message = new StringBuilder();
    495                     message.append("Input inValue: ");
    496                     message.append(String.format("%14.8g {%8x} %15a",
    497                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
    498                     message.append("\n");
    499                     message.append("Input inMinValue: ");
    500                     message.append(String.format("%14.8g {%8x} %15a",
    501                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    502                     message.append("\n");
    503                     message.append("Input inMaxValue: ");
    504                     message.append(String.format("%14.8g {%8x} %15a",
    505                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    506                     message.append("\n");
    507                     message.append("Expected output out: ");
    508                     message.append(args.out.toString());
    509                     message.append("\n");
    510                     message.append("Actual   output out: ");
    511                     message.append(String.format("%14.8g {%8x} %15a",
    512                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
    513                     if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    514                         message.append(" FAIL");
    515                     }
    516                     message.append("\n");
    517                     assertTrue("Incorrect output for checkClampFloat3FloatFloatFloat3" +
    518                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    519                 }
    520             }
    521         }
    522     }
    523 
    524     private void checkClampFloat4FloatFloatFloat4() {
    525         Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf6ee84ae374fcadl, false);
    526         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x29fa104280bf23b7l, false);
    527         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x29fa1037121c15bdl, false);
    528         enforceOrdering(inMinValue, inMaxValue);
    529         try {
    530             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    531             script.set_gAllocInMinValue(inMinValue);
    532             script.set_gAllocInMaxValue(inMaxValue);
    533             script.forEach_testClampFloat4FloatFloatFloat4(inValue, out);
    534             verifyResultsClampFloat4FloatFloatFloat4(inValue, inMinValue, inMaxValue, out, false);
    535         } catch (Exception e) {
    536             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4FloatFloatFloat4: " + e.toString());
    537         }
    538         try {
    539             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    540             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    541             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    542             scriptRelaxed.forEach_testClampFloat4FloatFloatFloat4(inValue, out);
    543             verifyResultsClampFloat4FloatFloatFloat4(inValue, inMinValue, inMaxValue, out, true);
    544         } catch (Exception e) {
    545             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4FloatFloatFloat4: " + e.toString());
    546         }
    547     }
    548 
    549     private void verifyResultsClampFloat4FloatFloatFloat4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    550         float[] arrayInValue = new float[INPUTSIZE * 4];
    551         inValue.copyTo(arrayInValue);
    552         float[] arrayInMinValue = new float[INPUTSIZE * 1];
    553         inMinValue.copyTo(arrayInMinValue);
    554         float[] arrayInMaxValue = new float[INPUTSIZE * 1];
    555         inMaxValue.copyTo(arrayInMaxValue);
    556         float[] arrayOut = new float[INPUTSIZE * 4];
    557         out.copyTo(arrayOut);
    558         for (int i = 0; i < INPUTSIZE; i++) {
    559             for (int j = 0; j < 4 ; j++) {
    560                 // Extract the inputs.
    561                 ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat();
    562                 args.inValue = arrayInValue[i * 4 + j];
    563                 args.inMinValue = arrayInMinValue[i];
    564                 args.inMaxValue = arrayInMaxValue[i];
    565                 // Figure out what the outputs should have been.
    566                 Target target = new Target(relaxed);
    567                 CoreMathVerifier.computeClamp(args, target);
    568                 // Validate the outputs.
    569                 boolean valid = true;
    570                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    571                     valid = false;
    572                 }
    573                 if (!valid) {
    574                     StringBuilder message = new StringBuilder();
    575                     message.append("Input inValue: ");
    576                     message.append(String.format("%14.8g {%8x} %15a",
    577                             args.inValue, Float.floatToRawIntBits(args.inValue), args.inValue));
    578                     message.append("\n");
    579                     message.append("Input inMinValue: ");
    580                     message.append(String.format("%14.8g {%8x} %15a",
    581                             args.inMinValue, Float.floatToRawIntBits(args.inMinValue), args.inMinValue));
    582                     message.append("\n");
    583                     message.append("Input inMaxValue: ");
    584                     message.append(String.format("%14.8g {%8x} %15a",
    585                             args.inMaxValue, Float.floatToRawIntBits(args.inMaxValue), args.inMaxValue));
    586                     message.append("\n");
    587                     message.append("Expected output out: ");
    588                     message.append(args.out.toString());
    589                     message.append("\n");
    590                     message.append("Actual   output out: ");
    591                     message.append(String.format("%14.8g {%8x} %15a",
    592                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
    593                     if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    594                         message.append(" FAIL");
    595                     }
    596                     message.append("\n");
    597                     assertTrue("Incorrect output for checkClampFloat4FloatFloatFloat4" +
    598                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    599                 }
    600             }
    601         }
    602     }
    603 
    604     public class ArgumentsCharCharCharChar {
    605         public byte inValue;
    606         public byte inMinValue;
    607         public byte inMaxValue;
    608         public byte out;
    609     }
    610 
    611     private void checkClampCharCharCharChar() {
    612         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xaec8640bb673cf75l, false);
    613         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x6379f7c3c505c8fl, false);
    614         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x6379f70cdad4e95l, false);
    615         enforceOrdering(inMinValue, inMaxValue);
    616         try {
    617             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
    618             script.set_gAllocInMinValue(inMinValue);
    619             script.set_gAllocInMaxValue(inMaxValue);
    620             script.forEach_testClampCharCharCharChar(inValue, out);
    621             verifyResultsClampCharCharCharChar(inValue, inMinValue, inMaxValue, out, false);
    622         } catch (Exception e) {
    623             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampCharCharCharChar: " + e.toString());
    624         }
    625         try {
    626             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
    627             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    628             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    629             scriptRelaxed.forEach_testClampCharCharCharChar(inValue, out);
    630             verifyResultsClampCharCharCharChar(inValue, inMinValue, inMaxValue, out, true);
    631         } catch (Exception e) {
    632             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampCharCharCharChar: " + e.toString());
    633         }
    634     }
    635 
    636     private void verifyResultsClampCharCharCharChar(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    637         byte[] arrayInValue = new byte[INPUTSIZE * 1];
    638         inValue.copyTo(arrayInValue);
    639         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
    640         inMinValue.copyTo(arrayInMinValue);
    641         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
    642         inMaxValue.copyTo(arrayInMaxValue);
    643         byte[] arrayOut = new byte[INPUTSIZE * 1];
    644         out.copyTo(arrayOut);
    645         for (int i = 0; i < INPUTSIZE; i++) {
    646             for (int j = 0; j < 1 ; j++) {
    647                 // Extract the inputs.
    648                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
    649                 args.inValue = arrayInValue[i];
    650                 args.inMinValue = arrayInMinValue[i];
    651                 args.inMaxValue = arrayInMaxValue[i];
    652                 // Figure out what the outputs should have been.
    653                 CoreMathVerifier.computeClamp(args);
    654                 // Validate the outputs.
    655                 boolean valid = true;
    656                 if (args.out != arrayOut[i * 1 + j]) {
    657                     valid = false;
    658                 }
    659                 if (!valid) {
    660                     StringBuilder message = new StringBuilder();
    661                     message.append("Input inValue: ");
    662                     message.append(String.format("%d", args.inValue));
    663                     message.append("\n");
    664                     message.append("Input inMinValue: ");
    665                     message.append(String.format("%d", args.inMinValue));
    666                     message.append("\n");
    667                     message.append("Input inMaxValue: ");
    668                     message.append(String.format("%d", args.inMaxValue));
    669                     message.append("\n");
    670                     message.append("Expected output out: ");
    671                     message.append(String.format("%d", args.out));
    672                     message.append("\n");
    673                     message.append("Actual   output out: ");
    674                     message.append(String.format("%d", arrayOut[i * 1 + j]));
    675                     if (args.out != arrayOut[i * 1 + j]) {
    676                         message.append(" FAIL");
    677                     }
    678                     message.append("\n");
    679                     assertTrue("Incorrect output for checkClampCharCharCharChar" +
    680                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    681                 }
    682             }
    683         }
    684     }
    685 
    686     private void checkClampChar2Char2Char2Char2() {
    687         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xa209cfe6c3feb45dl, false);
    688         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xed63d0ab3442bdc7l, false);
    689         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xed63d09fc59fafcdl, false);
    690         enforceOrdering(inMinValue, inMaxValue);
    691         try {
    692             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
    693             script.set_gAllocInMinValue(inMinValue);
    694             script.set_gAllocInMaxValue(inMaxValue);
    695             script.forEach_testClampChar2Char2Char2Char2(inValue, out);
    696             verifyResultsClampChar2Char2Char2Char2(inValue, inMinValue, inMaxValue, out, false);
    697         } catch (Exception e) {
    698             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2Char2Char2Char2: " + e.toString());
    699         }
    700         try {
    701             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
    702             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    703             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    704             scriptRelaxed.forEach_testClampChar2Char2Char2Char2(inValue, out);
    705             verifyResultsClampChar2Char2Char2Char2(inValue, inMinValue, inMaxValue, out, true);
    706         } catch (Exception e) {
    707             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2Char2Char2Char2: " + e.toString());
    708         }
    709     }
    710 
    711     private void verifyResultsClampChar2Char2Char2Char2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    712         byte[] arrayInValue = new byte[INPUTSIZE * 2];
    713         inValue.copyTo(arrayInValue);
    714         byte[] arrayInMinValue = new byte[INPUTSIZE * 2];
    715         inMinValue.copyTo(arrayInMinValue);
    716         byte[] arrayInMaxValue = new byte[INPUTSIZE * 2];
    717         inMaxValue.copyTo(arrayInMaxValue);
    718         byte[] arrayOut = new byte[INPUTSIZE * 2];
    719         out.copyTo(arrayOut);
    720         for (int i = 0; i < INPUTSIZE; i++) {
    721             for (int j = 0; j < 2 ; j++) {
    722                 // Extract the inputs.
    723                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
    724                 args.inValue = arrayInValue[i * 2 + j];
    725                 args.inMinValue = arrayInMinValue[i * 2 + j];
    726                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
    727                 // Figure out what the outputs should have been.
    728                 CoreMathVerifier.computeClamp(args);
    729                 // Validate the outputs.
    730                 boolean valid = true;
    731                 if (args.out != arrayOut[i * 2 + j]) {
    732                     valid = false;
    733                 }
    734                 if (!valid) {
    735                     StringBuilder message = new StringBuilder();
    736                     message.append("Input inValue: ");
    737                     message.append(String.format("%d", args.inValue));
    738                     message.append("\n");
    739                     message.append("Input inMinValue: ");
    740                     message.append(String.format("%d", args.inMinValue));
    741                     message.append("\n");
    742                     message.append("Input inMaxValue: ");
    743                     message.append(String.format("%d", args.inMaxValue));
    744                     message.append("\n");
    745                     message.append("Expected output out: ");
    746                     message.append(String.format("%d", args.out));
    747                     message.append("\n");
    748                     message.append("Actual   output out: ");
    749                     message.append(String.format("%d", arrayOut[i * 2 + j]));
    750                     if (args.out != arrayOut[i * 2 + j]) {
    751                         message.append(" FAIL");
    752                     }
    753                     message.append("\n");
    754                     assertTrue("Incorrect output for checkClampChar2Char2Char2Char2" +
    755                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    756                 }
    757             }
    758         }
    759     }
    760 
    761     private void checkClampChar3Char3Char3Char3() {
    762         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xfab6edb7b9d3b0a5l, false);
    763         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x7ae6f958470ecb1fl, false);
    764         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x7ae6f94cd86bbd25l, false);
    765         enforceOrdering(inMinValue, inMaxValue);
    766         try {
    767             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
    768             script.set_gAllocInMinValue(inMinValue);
    769             script.set_gAllocInMaxValue(inMaxValue);
    770             script.forEach_testClampChar3Char3Char3Char3(inValue, out);
    771             verifyResultsClampChar3Char3Char3Char3(inValue, inMinValue, inMaxValue, out, false);
    772         } catch (Exception e) {
    773             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3Char3Char3Char3: " + e.toString());
    774         }
    775         try {
    776             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
    777             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    778             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    779             scriptRelaxed.forEach_testClampChar3Char3Char3Char3(inValue, out);
    780             verifyResultsClampChar3Char3Char3Char3(inValue, inMinValue, inMaxValue, out, true);
    781         } catch (Exception e) {
    782             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3Char3Char3Char3: " + e.toString());
    783         }
    784     }
    785 
    786     private void verifyResultsClampChar3Char3Char3Char3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    787         byte[] arrayInValue = new byte[INPUTSIZE * 4];
    788         inValue.copyTo(arrayInValue);
    789         byte[] arrayInMinValue = new byte[INPUTSIZE * 4];
    790         inMinValue.copyTo(arrayInMinValue);
    791         byte[] arrayInMaxValue = new byte[INPUTSIZE * 4];
    792         inMaxValue.copyTo(arrayInMaxValue);
    793         byte[] arrayOut = new byte[INPUTSIZE * 4];
    794         out.copyTo(arrayOut);
    795         for (int i = 0; i < INPUTSIZE; i++) {
    796             for (int j = 0; j < 3 ; j++) {
    797                 // Extract the inputs.
    798                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
    799                 args.inValue = arrayInValue[i * 4 + j];
    800                 args.inMinValue = arrayInMinValue[i * 4 + j];
    801                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
    802                 // Figure out what the outputs should have been.
    803                 CoreMathVerifier.computeClamp(args);
    804                 // Validate the outputs.
    805                 boolean valid = true;
    806                 if (args.out != arrayOut[i * 4 + j]) {
    807                     valid = false;
    808                 }
    809                 if (!valid) {
    810                     StringBuilder message = new StringBuilder();
    811                     message.append("Input inValue: ");
    812                     message.append(String.format("%d", args.inValue));
    813                     message.append("\n");
    814                     message.append("Input inMinValue: ");
    815                     message.append(String.format("%d", args.inMinValue));
    816                     message.append("\n");
    817                     message.append("Input inMaxValue: ");
    818                     message.append(String.format("%d", args.inMaxValue));
    819                     message.append("\n");
    820                     message.append("Expected output out: ");
    821                     message.append(String.format("%d", args.out));
    822                     message.append("\n");
    823                     message.append("Actual   output out: ");
    824                     message.append(String.format("%d", arrayOut[i * 4 + j]));
    825                     if (args.out != arrayOut[i * 4 + j]) {
    826                         message.append(" FAIL");
    827                     }
    828                     message.append("\n");
    829                     assertTrue("Incorrect output for checkClampChar3Char3Char3Char3" +
    830                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    831                 }
    832             }
    833         }
    834     }
    835 
    836     private void checkClampChar4Char4Char4Char4() {
    837         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x53640b88afa8acedl, false);
    838         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x86a220559dad877l, false);
    839         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x86a21f9eb37ca7dl, false);
    840         enforceOrdering(inMinValue, inMaxValue);
    841         try {
    842             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
    843             script.set_gAllocInMinValue(inMinValue);
    844             script.set_gAllocInMaxValue(inMaxValue);
    845             script.forEach_testClampChar4Char4Char4Char4(inValue, out);
    846             verifyResultsClampChar4Char4Char4Char4(inValue, inMinValue, inMaxValue, out, false);
    847         } catch (Exception e) {
    848             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4Char4Char4Char4: " + e.toString());
    849         }
    850         try {
    851             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
    852             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    853             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    854             scriptRelaxed.forEach_testClampChar4Char4Char4Char4(inValue, out);
    855             verifyResultsClampChar4Char4Char4Char4(inValue, inMinValue, inMaxValue, out, true);
    856         } catch (Exception e) {
    857             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4Char4Char4Char4: " + e.toString());
    858         }
    859     }
    860 
    861     private void verifyResultsClampChar4Char4Char4Char4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    862         byte[] arrayInValue = new byte[INPUTSIZE * 4];
    863         inValue.copyTo(arrayInValue);
    864         byte[] arrayInMinValue = new byte[INPUTSIZE * 4];
    865         inMinValue.copyTo(arrayInMinValue);
    866         byte[] arrayInMaxValue = new byte[INPUTSIZE * 4];
    867         inMaxValue.copyTo(arrayInMaxValue);
    868         byte[] arrayOut = new byte[INPUTSIZE * 4];
    869         out.copyTo(arrayOut);
    870         for (int i = 0; i < INPUTSIZE; i++) {
    871             for (int j = 0; j < 4 ; j++) {
    872                 // Extract the inputs.
    873                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
    874                 args.inValue = arrayInValue[i * 4 + j];
    875                 args.inMinValue = arrayInMinValue[i * 4 + j];
    876                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
    877                 // Figure out what the outputs should have been.
    878                 CoreMathVerifier.computeClamp(args);
    879                 // Validate the outputs.
    880                 boolean valid = true;
    881                 if (args.out != arrayOut[i * 4 + j]) {
    882                     valid = false;
    883                 }
    884                 if (!valid) {
    885                     StringBuilder message = new StringBuilder();
    886                     message.append("Input inValue: ");
    887                     message.append(String.format("%d", args.inValue));
    888                     message.append("\n");
    889                     message.append("Input inMinValue: ");
    890                     message.append(String.format("%d", args.inMinValue));
    891                     message.append("\n");
    892                     message.append("Input inMaxValue: ");
    893                     message.append(String.format("%d", args.inMaxValue));
    894                     message.append("\n");
    895                     message.append("Expected output out: ");
    896                     message.append(String.format("%d", args.out));
    897                     message.append("\n");
    898                     message.append("Actual   output out: ");
    899                     message.append(String.format("%d", arrayOut[i * 4 + j]));
    900                     if (args.out != arrayOut[i * 4 + j]) {
    901                         message.append(" FAIL");
    902                     }
    903                     message.append("\n");
    904                     assertTrue("Incorrect output for checkClampChar4Char4Char4Char4" +
    905                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    906                 }
    907             }
    908         }
    909     }
    910 
    911     public class ArgumentsUcharUcharUcharUchar {
    912         public byte inValue;
    913         public byte inMinValue;
    914         public byte inMaxValue;
    915         public byte out;
    916     }
    917 
    918     private void checkClampUcharUcharUcharUchar() {
    919         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x680c818a4447655l, false);
    920         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xae40bae375336f2fl, false);
    921         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xae40bad806906135l, false);
    922         enforceOrdering(inMinValue, inMaxValue);
    923         try {
    924             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
    925             script.set_gAllocInMinValue(inMinValue);
    926             script.set_gAllocInMaxValue(inMaxValue);
    927             script.forEach_testClampUcharUcharUcharUchar(inValue, out);
    928             verifyResultsClampUcharUcharUcharUchar(inValue, inMinValue, inMaxValue, out, false);
    929         } catch (Exception e) {
    930             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUcharUcharUcharUchar: " + e.toString());
    931         }
    932         try {
    933             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
    934             scriptRelaxed.set_gAllocInMinValue(inMinValue);
    935             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
    936             scriptRelaxed.forEach_testClampUcharUcharUcharUchar(inValue, out);
    937             verifyResultsClampUcharUcharUcharUchar(inValue, inMinValue, inMaxValue, out, true);
    938         } catch (Exception e) {
    939             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUcharUcharUcharUchar: " + e.toString());
    940         }
    941     }
    942 
    943     private void verifyResultsClampUcharUcharUcharUchar(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
    944         byte[] arrayInValue = new byte[INPUTSIZE * 1];
    945         inValue.copyTo(arrayInValue);
    946         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
    947         inMinValue.copyTo(arrayInMinValue);
    948         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
    949         inMaxValue.copyTo(arrayInMaxValue);
    950         byte[] arrayOut = new byte[INPUTSIZE * 1];
    951         out.copyTo(arrayOut);
    952         for (int i = 0; i < INPUTSIZE; i++) {
    953             for (int j = 0; j < 1 ; j++) {
    954                 // Extract the inputs.
    955                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
    956                 args.inValue = arrayInValue[i];
    957                 args.inMinValue = arrayInMinValue[i];
    958                 args.inMaxValue = arrayInMaxValue[i];
    959                 // Figure out what the outputs should have been.
    960                 CoreMathVerifier.computeClamp(args);
    961                 // Validate the outputs.
    962                 boolean valid = true;
    963                 if (args.out != arrayOut[i * 1 + j]) {
    964                     valid = false;
    965                 }
    966                 if (!valid) {
    967                     StringBuilder message = new StringBuilder();
    968                     message.append("Input inValue: ");
    969                     message.append(String.format("0x%x", args.inValue));
    970                     message.append("\n");
    971                     message.append("Input inMinValue: ");
    972                     message.append(String.format("0x%x", args.inMinValue));
    973                     message.append("\n");
    974                     message.append("Input inMaxValue: ");
    975                     message.append(String.format("0x%x", args.inMaxValue));
    976                     message.append("\n");
    977                     message.append("Expected output out: ");
    978                     message.append(String.format("0x%x", args.out));
    979                     message.append("\n");
    980                     message.append("Actual   output out: ");
    981                     message.append(String.format("0x%x", arrayOut[i * 1 + j]));
    982                     if (args.out != arrayOut[i * 1 + j]) {
    983                         message.append(" FAIL");
    984                     }
    985                     message.append("\n");
    986                     assertTrue("Incorrect output for checkClampUcharUcharUcharUchar" +
    987                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    988                 }
    989             }
    990         }
    991     }
    992 
    993     private void checkClampUchar2Uchar2Uchar2Uchar2() {
    994         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xd69df43245dae301l, false);
    995         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x82681747662c1df3l, false);
    996         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x8268173bf7890ff9l, false);
    997         enforceOrdering(inMinValue, inMaxValue);
    998         try {
    999             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
   1000             script.set_gAllocInMinValue(inMinValue);
   1001             script.set_gAllocInMaxValue(inMaxValue);
   1002             script.forEach_testClampUchar2Uchar2Uchar2Uchar2(inValue, out);
   1003             verifyResultsClampUchar2Uchar2Uchar2Uchar2(inValue, inMinValue, inMaxValue, out, false);
   1004         } catch (Exception e) {
   1005             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2Uchar2Uchar2Uchar2: " + e.toString());
   1006         }
   1007         try {
   1008             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
   1009             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1010             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1011             scriptRelaxed.forEach_testClampUchar2Uchar2Uchar2Uchar2(inValue, out);
   1012             verifyResultsClampUchar2Uchar2Uchar2Uchar2(inValue, inMinValue, inMaxValue, out, true);
   1013         } catch (Exception e) {
   1014             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2Uchar2Uchar2Uchar2: " + e.toString());
   1015         }
   1016     }
   1017 
   1018     private void verifyResultsClampUchar2Uchar2Uchar2Uchar2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1019         byte[] arrayInValue = new byte[INPUTSIZE * 2];
   1020         inValue.copyTo(arrayInValue);
   1021         byte[] arrayInMinValue = new byte[INPUTSIZE * 2];
   1022         inMinValue.copyTo(arrayInMinValue);
   1023         byte[] arrayInMaxValue = new byte[INPUTSIZE * 2];
   1024         inMaxValue.copyTo(arrayInMaxValue);
   1025         byte[] arrayOut = new byte[INPUTSIZE * 2];
   1026         out.copyTo(arrayOut);
   1027         for (int i = 0; i < INPUTSIZE; i++) {
   1028             for (int j = 0; j < 2 ; j++) {
   1029                 // Extract the inputs.
   1030                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
   1031                 args.inValue = arrayInValue[i * 2 + j];
   1032                 args.inMinValue = arrayInMinValue[i * 2 + j];
   1033                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   1034                 // Figure out what the outputs should have been.
   1035                 CoreMathVerifier.computeClamp(args);
   1036                 // Validate the outputs.
   1037                 boolean valid = true;
   1038                 if (args.out != arrayOut[i * 2 + j]) {
   1039                     valid = false;
   1040                 }
   1041                 if (!valid) {
   1042                     StringBuilder message = new StringBuilder();
   1043                     message.append("Input inValue: ");
   1044                     message.append(String.format("0x%x", args.inValue));
   1045                     message.append("\n");
   1046                     message.append("Input inMinValue: ");
   1047                     message.append(String.format("0x%x", args.inMinValue));
   1048                     message.append("\n");
   1049                     message.append("Input inMaxValue: ");
   1050                     message.append(String.format("0x%x", args.inMaxValue));
   1051                     message.append("\n");
   1052                     message.append("Expected output out: ");
   1053                     message.append(String.format("0x%x", args.out));
   1054                     message.append("\n");
   1055                     message.append("Actual   output out: ");
   1056                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   1057                     if (args.out != arrayOut[i * 2 + j]) {
   1058                         message.append(" FAIL");
   1059                     }
   1060                     message.append("\n");
   1061                     assertTrue("Incorrect output for checkClampUchar2Uchar2Uchar2Uchar2" +
   1062                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1063                 }
   1064             }
   1065         }
   1066     }
   1067 
   1068     private void checkClampUchar3Uchar3Uchar3Uchar3() {
   1069         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xa00235ba625d4fddl, false);
   1070         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x8e548af5b4e30847l, false);
   1071         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x8e548aea463ffa4dl, false);
   1072         enforceOrdering(inMinValue, inMaxValue);
   1073         try {
   1074             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
   1075             script.set_gAllocInMinValue(inMinValue);
   1076             script.set_gAllocInMaxValue(inMaxValue);
   1077             script.forEach_testClampUchar3Uchar3Uchar3Uchar3(inValue, out);
   1078             verifyResultsClampUchar3Uchar3Uchar3Uchar3(inValue, inMinValue, inMaxValue, out, false);
   1079         } catch (Exception e) {
   1080             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3Uchar3Uchar3Uchar3: " + e.toString());
   1081         }
   1082         try {
   1083             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
   1084             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1085             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1086             scriptRelaxed.forEach_testClampUchar3Uchar3Uchar3Uchar3(inValue, out);
   1087             verifyResultsClampUchar3Uchar3Uchar3Uchar3(inValue, inMinValue, inMaxValue, out, true);
   1088         } catch (Exception e) {
   1089             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3Uchar3Uchar3Uchar3: " + e.toString());
   1090         }
   1091     }
   1092 
   1093     private void verifyResultsClampUchar3Uchar3Uchar3Uchar3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1094         byte[] arrayInValue = new byte[INPUTSIZE * 4];
   1095         inValue.copyTo(arrayInValue);
   1096         byte[] arrayInMinValue = new byte[INPUTSIZE * 4];
   1097         inMinValue.copyTo(arrayInMinValue);
   1098         byte[] arrayInMaxValue = new byte[INPUTSIZE * 4];
   1099         inMaxValue.copyTo(arrayInMaxValue);
   1100         byte[] arrayOut = new byte[INPUTSIZE * 4];
   1101         out.copyTo(arrayOut);
   1102         for (int i = 0; i < INPUTSIZE; i++) {
   1103             for (int j = 0; j < 3 ; j++) {
   1104                 // Extract the inputs.
   1105                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
   1106                 args.inValue = arrayInValue[i * 4 + j];
   1107                 args.inMinValue = arrayInMinValue[i * 4 + j];
   1108                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   1109                 // Figure out what the outputs should have been.
   1110                 CoreMathVerifier.computeClamp(args);
   1111                 // Validate the outputs.
   1112                 boolean valid = true;
   1113                 if (args.out != arrayOut[i * 4 + j]) {
   1114                     valid = false;
   1115                 }
   1116                 if (!valid) {
   1117                     StringBuilder message = new StringBuilder();
   1118                     message.append("Input inValue: ");
   1119                     message.append(String.format("0x%x", args.inValue));
   1120                     message.append("\n");
   1121                     message.append("Input inMinValue: ");
   1122                     message.append(String.format("0x%x", args.inMinValue));
   1123                     message.append("\n");
   1124                     message.append("Input inMaxValue: ");
   1125                     message.append(String.format("0x%x", args.inMaxValue));
   1126                     message.append("\n");
   1127                     message.append("Expected output out: ");
   1128                     message.append(String.format("0x%x", args.out));
   1129                     message.append("\n");
   1130                     message.append("Actual   output out: ");
   1131                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   1132                     if (args.out != arrayOut[i * 4 + j]) {
   1133                         message.append(" FAIL");
   1134                     }
   1135                     message.append("\n");
   1136                     assertTrue("Incorrect output for checkClampUchar3Uchar3Uchar3Uchar3" +
   1137                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1138                 }
   1139             }
   1140         }
   1141     }
   1142 
   1143     private void checkClampUchar4Uchar4Uchar4Uchar4() {
   1144         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x696677427edfbcb9l, false);
   1145         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x9a40fea40399f29bl, false);
   1146         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x9a40fe9894f6e4a1l, false);
   1147         enforceOrdering(inMinValue, inMaxValue);
   1148         try {
   1149             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
   1150             script.set_gAllocInMinValue(inMinValue);
   1151             script.set_gAllocInMaxValue(inMaxValue);
   1152             script.forEach_testClampUchar4Uchar4Uchar4Uchar4(inValue, out);
   1153             verifyResultsClampUchar4Uchar4Uchar4Uchar4(inValue, inMinValue, inMaxValue, out, false);
   1154         } catch (Exception e) {
   1155             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4Uchar4Uchar4Uchar4: " + e.toString());
   1156         }
   1157         try {
   1158             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
   1159             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1160             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1161             scriptRelaxed.forEach_testClampUchar4Uchar4Uchar4Uchar4(inValue, out);
   1162             verifyResultsClampUchar4Uchar4Uchar4Uchar4(inValue, inMinValue, inMaxValue, out, true);
   1163         } catch (Exception e) {
   1164             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4Uchar4Uchar4Uchar4: " + e.toString());
   1165         }
   1166     }
   1167 
   1168     private void verifyResultsClampUchar4Uchar4Uchar4Uchar4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1169         byte[] arrayInValue = new byte[INPUTSIZE * 4];
   1170         inValue.copyTo(arrayInValue);
   1171         byte[] arrayInMinValue = new byte[INPUTSIZE * 4];
   1172         inMinValue.copyTo(arrayInMinValue);
   1173         byte[] arrayInMaxValue = new byte[INPUTSIZE * 4];
   1174         inMaxValue.copyTo(arrayInMaxValue);
   1175         byte[] arrayOut = new byte[INPUTSIZE * 4];
   1176         out.copyTo(arrayOut);
   1177         for (int i = 0; i < INPUTSIZE; i++) {
   1178             for (int j = 0; j < 4 ; j++) {
   1179                 // Extract the inputs.
   1180                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
   1181                 args.inValue = arrayInValue[i * 4 + j];
   1182                 args.inMinValue = arrayInMinValue[i * 4 + j];
   1183                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   1184                 // Figure out what the outputs should have been.
   1185                 CoreMathVerifier.computeClamp(args);
   1186                 // Validate the outputs.
   1187                 boolean valid = true;
   1188                 if (args.out != arrayOut[i * 4 + j]) {
   1189                     valid = false;
   1190                 }
   1191                 if (!valid) {
   1192                     StringBuilder message = new StringBuilder();
   1193                     message.append("Input inValue: ");
   1194                     message.append(String.format("0x%x", args.inValue));
   1195                     message.append("\n");
   1196                     message.append("Input inMinValue: ");
   1197                     message.append(String.format("0x%x", args.inMinValue));
   1198                     message.append("\n");
   1199                     message.append("Input inMaxValue: ");
   1200                     message.append(String.format("0x%x", args.inMaxValue));
   1201                     message.append("\n");
   1202                     message.append("Expected output out: ");
   1203                     message.append(String.format("0x%x", args.out));
   1204                     message.append("\n");
   1205                     message.append("Actual   output out: ");
   1206                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   1207                     if (args.out != arrayOut[i * 4 + j]) {
   1208                         message.append(" FAIL");
   1209                     }
   1210                     message.append("\n");
   1211                     assertTrue("Incorrect output for checkClampUchar4Uchar4Uchar4Uchar4" +
   1212                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1213                 }
   1214             }
   1215         }
   1216     }
   1217 
   1218     public class ArgumentsShortShortShortShort {
   1219         public short inValue;
   1220         public short inMinValue;
   1221         public short inMaxValue;
   1222         public short out;
   1223     }
   1224 
   1225     private void checkClampShortShortShortShort() {
   1226         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x8035c0627fc993ddl, false);
   1227         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xb5d4bd1fb4661447l, false);
   1228         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xb5d4bd1445c3064dl, false);
   1229         enforceOrdering(inMinValue, inMaxValue);
   1230         try {
   1231             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
   1232             script.set_gAllocInMinValue(inMinValue);
   1233             script.set_gAllocInMaxValue(inMaxValue);
   1234             script.forEach_testClampShortShortShortShort(inValue, out);
   1235             verifyResultsClampShortShortShortShort(inValue, inMinValue, inMaxValue, out, false);
   1236         } catch (Exception e) {
   1237             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShortShortShortShort: " + e.toString());
   1238         }
   1239         try {
   1240             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
   1241             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1242             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1243             scriptRelaxed.forEach_testClampShortShortShortShort(inValue, out);
   1244             verifyResultsClampShortShortShortShort(inValue, inMinValue, inMaxValue, out, true);
   1245         } catch (Exception e) {
   1246             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShortShortShortShort: " + e.toString());
   1247         }
   1248     }
   1249 
   1250     private void verifyResultsClampShortShortShortShort(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1251         short[] arrayInValue = new short[INPUTSIZE * 1];
   1252         inValue.copyTo(arrayInValue);
   1253         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   1254         inMinValue.copyTo(arrayInMinValue);
   1255         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   1256         inMaxValue.copyTo(arrayInMaxValue);
   1257         short[] arrayOut = new short[INPUTSIZE * 1];
   1258         out.copyTo(arrayOut);
   1259         for (int i = 0; i < INPUTSIZE; i++) {
   1260             for (int j = 0; j < 1 ; j++) {
   1261                 // Extract the inputs.
   1262                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   1263                 args.inValue = arrayInValue[i];
   1264                 args.inMinValue = arrayInMinValue[i];
   1265                 args.inMaxValue = arrayInMaxValue[i];
   1266                 // Figure out what the outputs should have been.
   1267                 CoreMathVerifier.computeClamp(args);
   1268                 // Validate the outputs.
   1269                 boolean valid = true;
   1270                 if (args.out != arrayOut[i * 1 + j]) {
   1271                     valid = false;
   1272                 }
   1273                 if (!valid) {
   1274                     StringBuilder message = new StringBuilder();
   1275                     message.append("Input inValue: ");
   1276                     message.append(String.format("%d", args.inValue));
   1277                     message.append("\n");
   1278                     message.append("Input inMinValue: ");
   1279                     message.append(String.format("%d", args.inMinValue));
   1280                     message.append("\n");
   1281                     message.append("Input inMaxValue: ");
   1282                     message.append(String.format("%d", args.inMaxValue));
   1283                     message.append("\n");
   1284                     message.append("Expected output out: ");
   1285                     message.append(String.format("%d", args.out));
   1286                     message.append("\n");
   1287                     message.append("Actual   output out: ");
   1288                     message.append(String.format("%d", arrayOut[i * 1 + j]));
   1289                     if (args.out != arrayOut[i * 1 + j]) {
   1290                         message.append(" FAIL");
   1291                     }
   1292                     message.append("\n");
   1293                     assertTrue("Incorrect output for checkClampShortShortShortShort" +
   1294                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1295                 }
   1296             }
   1297         }
   1298     }
   1299 
   1300     private void checkClampShort2Short2Short2Short2() {
   1301         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7eab8e9b984e0915l, false);
   1302         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7b334b992e67336fl, false);
   1303         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7b334b8dbfc42575l, false);
   1304         enforceOrdering(inMinValue, inMaxValue);
   1305         try {
   1306             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
   1307             script.set_gAllocInMinValue(inMinValue);
   1308             script.set_gAllocInMaxValue(inMaxValue);
   1309             script.forEach_testClampShort2Short2Short2Short2(inValue, out);
   1310             verifyResultsClampShort2Short2Short2Short2(inValue, inMinValue, inMaxValue, out, false);
   1311         } catch (Exception e) {
   1312             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2Short2Short2Short2: " + e.toString());
   1313         }
   1314         try {
   1315             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
   1316             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1317             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1318             scriptRelaxed.forEach_testClampShort2Short2Short2Short2(inValue, out);
   1319             verifyResultsClampShort2Short2Short2Short2(inValue, inMinValue, inMaxValue, out, true);
   1320         } catch (Exception e) {
   1321             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2Short2Short2Short2: " + e.toString());
   1322         }
   1323     }
   1324 
   1325     private void verifyResultsClampShort2Short2Short2Short2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1326         short[] arrayInValue = new short[INPUTSIZE * 2];
   1327         inValue.copyTo(arrayInValue);
   1328         short[] arrayInMinValue = new short[INPUTSIZE * 2];
   1329         inMinValue.copyTo(arrayInMinValue);
   1330         short[] arrayInMaxValue = new short[INPUTSIZE * 2];
   1331         inMaxValue.copyTo(arrayInMaxValue);
   1332         short[] arrayOut = new short[INPUTSIZE * 2];
   1333         out.copyTo(arrayOut);
   1334         for (int i = 0; i < INPUTSIZE; i++) {
   1335             for (int j = 0; j < 2 ; j++) {
   1336                 // Extract the inputs.
   1337                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   1338                 args.inValue = arrayInValue[i * 2 + j];
   1339                 args.inMinValue = arrayInMinValue[i * 2 + j];
   1340                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   1341                 // Figure out what the outputs should have been.
   1342                 CoreMathVerifier.computeClamp(args);
   1343                 // Validate the outputs.
   1344                 boolean valid = true;
   1345                 if (args.out != arrayOut[i * 2 + j]) {
   1346                     valid = false;
   1347                 }
   1348                 if (!valid) {
   1349                     StringBuilder message = new StringBuilder();
   1350                     message.append("Input inValue: ");
   1351                     message.append(String.format("%d", args.inValue));
   1352                     message.append("\n");
   1353                     message.append("Input inMinValue: ");
   1354                     message.append(String.format("%d", args.inMinValue));
   1355                     message.append("\n");
   1356                     message.append("Input inMaxValue: ");
   1357                     message.append(String.format("%d", args.inMaxValue));
   1358                     message.append("\n");
   1359                     message.append("Expected output out: ");
   1360                     message.append(String.format("%d", args.out));
   1361                     message.append("\n");
   1362                     message.append("Actual   output out: ");
   1363                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   1364                     if (args.out != arrayOut[i * 2 + j]) {
   1365                         message.append(" FAIL");
   1366                     }
   1367                     message.append("\n");
   1368                     assertTrue("Incorrect output for checkClampShort2Short2Short2Short2" +
   1369                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1370                 }
   1371             }
   1372         }
   1373     }
   1374 
   1375     private void checkClampShort3Short3Short3Short3() {
   1376         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x480fd023b4d075f1l, false);
   1377         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x871fbf477d1e1dc3l, false);
   1378         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x871fbf3c0e7b0fc9l, false);
   1379         enforceOrdering(inMinValue, inMaxValue);
   1380         try {
   1381             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
   1382             script.set_gAllocInMinValue(inMinValue);
   1383             script.set_gAllocInMaxValue(inMaxValue);
   1384             script.forEach_testClampShort3Short3Short3Short3(inValue, out);
   1385             verifyResultsClampShort3Short3Short3Short3(inValue, inMinValue, inMaxValue, out, false);
   1386         } catch (Exception e) {
   1387             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3Short3Short3Short3: " + e.toString());
   1388         }
   1389         try {
   1390             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
   1391             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1392             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1393             scriptRelaxed.forEach_testClampShort3Short3Short3Short3(inValue, out);
   1394             verifyResultsClampShort3Short3Short3Short3(inValue, inMinValue, inMaxValue, out, true);
   1395         } catch (Exception e) {
   1396             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3Short3Short3Short3: " + e.toString());
   1397         }
   1398     }
   1399 
   1400     private void verifyResultsClampShort3Short3Short3Short3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1401         short[] arrayInValue = new short[INPUTSIZE * 4];
   1402         inValue.copyTo(arrayInValue);
   1403         short[] arrayInMinValue = new short[INPUTSIZE * 4];
   1404         inMinValue.copyTo(arrayInMinValue);
   1405         short[] arrayInMaxValue = new short[INPUTSIZE * 4];
   1406         inMaxValue.copyTo(arrayInMaxValue);
   1407         short[] arrayOut = new short[INPUTSIZE * 4];
   1408         out.copyTo(arrayOut);
   1409         for (int i = 0; i < INPUTSIZE; i++) {
   1410             for (int j = 0; j < 3 ; j++) {
   1411                 // Extract the inputs.
   1412                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   1413                 args.inValue = arrayInValue[i * 4 + j];
   1414                 args.inMinValue = arrayInMinValue[i * 4 + j];
   1415                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   1416                 // Figure out what the outputs should have been.
   1417                 CoreMathVerifier.computeClamp(args);
   1418                 // Validate the outputs.
   1419                 boolean valid = true;
   1420                 if (args.out != arrayOut[i * 4 + j]) {
   1421                     valid = false;
   1422                 }
   1423                 if (!valid) {
   1424                     StringBuilder message = new StringBuilder();
   1425                     message.append("Input inValue: ");
   1426                     message.append(String.format("%d", args.inValue));
   1427                     message.append("\n");
   1428                     message.append("Input inMinValue: ");
   1429                     message.append(String.format("%d", args.inMinValue));
   1430                     message.append("\n");
   1431                     message.append("Input inMaxValue: ");
   1432                     message.append(String.format("%d", args.inMaxValue));
   1433                     message.append("\n");
   1434                     message.append("Expected output out: ");
   1435                     message.append(String.format("%d", args.out));
   1436                     message.append("\n");
   1437                     message.append("Actual   output out: ");
   1438                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   1439                     if (args.out != arrayOut[i * 4 + j]) {
   1440                         message.append(" FAIL");
   1441                     }
   1442                     message.append("\n");
   1443                     assertTrue("Incorrect output for checkClampShort3Short3Short3Short3" +
   1444                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1445                 }
   1446             }
   1447         }
   1448     }
   1449 
   1450     private void checkClampShort4Short4Short4Short4() {
   1451         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x117411abd152e2cdl, false);
   1452         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x930c32f5cbd50817l, false);
   1453         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x930c32ea5d31fa1dl, false);
   1454         enforceOrdering(inMinValue, inMaxValue);
   1455         try {
   1456             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
   1457             script.set_gAllocInMinValue(inMinValue);
   1458             script.set_gAllocInMaxValue(inMaxValue);
   1459             script.forEach_testClampShort4Short4Short4Short4(inValue, out);
   1460             verifyResultsClampShort4Short4Short4Short4(inValue, inMinValue, inMaxValue, out, false);
   1461         } catch (Exception e) {
   1462             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4Short4Short4Short4: " + e.toString());
   1463         }
   1464         try {
   1465             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
   1466             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1467             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1468             scriptRelaxed.forEach_testClampShort4Short4Short4Short4(inValue, out);
   1469             verifyResultsClampShort4Short4Short4Short4(inValue, inMinValue, inMaxValue, out, true);
   1470         } catch (Exception e) {
   1471             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4Short4Short4Short4: " + e.toString());
   1472         }
   1473     }
   1474 
   1475     private void verifyResultsClampShort4Short4Short4Short4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1476         short[] arrayInValue = new short[INPUTSIZE * 4];
   1477         inValue.copyTo(arrayInValue);
   1478         short[] arrayInMinValue = new short[INPUTSIZE * 4];
   1479         inMinValue.copyTo(arrayInMinValue);
   1480         short[] arrayInMaxValue = new short[INPUTSIZE * 4];
   1481         inMaxValue.copyTo(arrayInMaxValue);
   1482         short[] arrayOut = new short[INPUTSIZE * 4];
   1483         out.copyTo(arrayOut);
   1484         for (int i = 0; i < INPUTSIZE; i++) {
   1485             for (int j = 0; j < 4 ; j++) {
   1486                 // Extract the inputs.
   1487                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   1488                 args.inValue = arrayInValue[i * 4 + j];
   1489                 args.inMinValue = arrayInMinValue[i * 4 + j];
   1490                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   1491                 // Figure out what the outputs should have been.
   1492                 CoreMathVerifier.computeClamp(args);
   1493                 // Validate the outputs.
   1494                 boolean valid = true;
   1495                 if (args.out != arrayOut[i * 4 + j]) {
   1496                     valid = false;
   1497                 }
   1498                 if (!valid) {
   1499                     StringBuilder message = new StringBuilder();
   1500                     message.append("Input inValue: ");
   1501                     message.append(String.format("%d", args.inValue));
   1502                     message.append("\n");
   1503                     message.append("Input inMinValue: ");
   1504                     message.append(String.format("%d", args.inMinValue));
   1505                     message.append("\n");
   1506                     message.append("Input inMaxValue: ");
   1507                     message.append(String.format("%d", args.inMaxValue));
   1508                     message.append("\n");
   1509                     message.append("Expected output out: ");
   1510                     message.append(String.format("%d", args.out));
   1511                     message.append("\n");
   1512                     message.append("Actual   output out: ");
   1513                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   1514                     if (args.out != arrayOut[i * 4 + j]) {
   1515                         message.append(" FAIL");
   1516                     }
   1517                     message.append("\n");
   1518                     assertTrue("Incorrect output for checkClampShort4Short4Short4Short4" +
   1519                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1520                 }
   1521             }
   1522         }
   1523     }
   1524 
   1525     public class ArgumentsUshortUshortUshortUshort {
   1526         public short inValue;
   1527         public short inMinValue;
   1528         public short inMaxValue;
   1529         public short out;
   1530     }
   1531 
   1532     private void checkClampUshortUshortUshortUshort() {
   1533         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf5881eeff74c4341l, false);
   1534         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd2a0571394d3e2b3l, false);
   1535         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd2a057082630d4b9l, false);
   1536         enforceOrdering(inMinValue, inMaxValue);
   1537         try {
   1538             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
   1539             script.set_gAllocInMinValue(inMinValue);
   1540             script.set_gAllocInMaxValue(inMaxValue);
   1541             script.forEach_testClampUshortUshortUshortUshort(inValue, out);
   1542             verifyResultsClampUshortUshortUshortUshort(inValue, inMinValue, inMaxValue, out, false);
   1543         } catch (Exception e) {
   1544             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshortUshortUshortUshort: " + e.toString());
   1545         }
   1546         try {
   1547             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
   1548             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1549             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1550             scriptRelaxed.forEach_testClampUshortUshortUshortUshort(inValue, out);
   1551             verifyResultsClampUshortUshortUshortUshort(inValue, inMinValue, inMaxValue, out, true);
   1552         } catch (Exception e) {
   1553             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshortUshortUshortUshort: " + e.toString());
   1554         }
   1555     }
   1556 
   1557     private void verifyResultsClampUshortUshortUshortUshort(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1558         short[] arrayInValue = new short[INPUTSIZE * 1];
   1559         inValue.copyTo(arrayInValue);
   1560         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   1561         inMinValue.copyTo(arrayInMinValue);
   1562         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   1563         inMaxValue.copyTo(arrayInMaxValue);
   1564         short[] arrayOut = new short[INPUTSIZE * 1];
   1565         out.copyTo(arrayOut);
   1566         for (int i = 0; i < INPUTSIZE; i++) {
   1567             for (int j = 0; j < 1 ; j++) {
   1568                 // Extract the inputs.
   1569                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   1570                 args.inValue = arrayInValue[i];
   1571                 args.inMinValue = arrayInMinValue[i];
   1572                 args.inMaxValue = arrayInMaxValue[i];
   1573                 // Figure out what the outputs should have been.
   1574                 CoreMathVerifier.computeClamp(args);
   1575                 // Validate the outputs.
   1576                 boolean valid = true;
   1577                 if (args.out != arrayOut[i * 1 + j]) {
   1578                     valid = false;
   1579                 }
   1580                 if (!valid) {
   1581                     StringBuilder message = new StringBuilder();
   1582                     message.append("Input inValue: ");
   1583                     message.append(String.format("0x%x", args.inValue));
   1584                     message.append("\n");
   1585                     message.append("Input inMinValue: ");
   1586                     message.append(String.format("0x%x", args.inMinValue));
   1587                     message.append("\n");
   1588                     message.append("Input inMaxValue: ");
   1589                     message.append(String.format("0x%x", args.inMaxValue));
   1590                     message.append("\n");
   1591                     message.append("Expected output out: ");
   1592                     message.append(String.format("0x%x", args.out));
   1593                     message.append("\n");
   1594                     message.append("Actual   output out: ");
   1595                     message.append(String.format("0x%x", arrayOut[i * 1 + j]));
   1596                     if (args.out != arrayOut[i * 1 + j]) {
   1597                         message.append(" FAIL");
   1598                     }
   1599                     message.append("\n");
   1600                     assertTrue("Incorrect output for checkClampUshortUshortUshortUshort" +
   1601                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1602                 }
   1603             }
   1604         }
   1605     }
   1606 
   1607     private void checkClampUshort2Ushort2Ushort2Ushort2() {
   1608         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x6441dbe2fc36b705l, false);
   1609         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x52161e934fa3b43fl, false);
   1610         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x52161e87e100a645l, false);
   1611         enforceOrdering(inMinValue, inMaxValue);
   1612         try {
   1613             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
   1614             script.set_gAllocInMinValue(inMinValue);
   1615             script.set_gAllocInMaxValue(inMaxValue);
   1616             script.forEach_testClampUshort2Ushort2Ushort2Ushort2(inValue, out);
   1617             verifyResultsClampUshort2Ushort2Ushort2Ushort2(inValue, inMinValue, inMaxValue, out, false);
   1618         } catch (Exception e) {
   1619             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2Ushort2Ushort2Ushort2: " + e.toString());
   1620         }
   1621         try {
   1622             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
   1623             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1624             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1625             scriptRelaxed.forEach_testClampUshort2Ushort2Ushort2Ushort2(inValue, out);
   1626             verifyResultsClampUshort2Ushort2Ushort2Ushort2(inValue, inMinValue, inMaxValue, out, true);
   1627         } catch (Exception e) {
   1628             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2Ushort2Ushort2Ushort2: " + e.toString());
   1629         }
   1630     }
   1631 
   1632     private void verifyResultsClampUshort2Ushort2Ushort2Ushort2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1633         short[] arrayInValue = new short[INPUTSIZE * 2];
   1634         inValue.copyTo(arrayInValue);
   1635         short[] arrayInMinValue = new short[INPUTSIZE * 2];
   1636         inMinValue.copyTo(arrayInMinValue);
   1637         short[] arrayInMaxValue = new short[INPUTSIZE * 2];
   1638         inMaxValue.copyTo(arrayInMaxValue);
   1639         short[] arrayOut = new short[INPUTSIZE * 2];
   1640         out.copyTo(arrayOut);
   1641         for (int i = 0; i < INPUTSIZE; i++) {
   1642             for (int j = 0; j < 2 ; j++) {
   1643                 // Extract the inputs.
   1644                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   1645                 args.inValue = arrayInValue[i * 2 + j];
   1646                 args.inMinValue = arrayInMinValue[i * 2 + j];
   1647                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   1648                 // Figure out what the outputs should have been.
   1649                 CoreMathVerifier.computeClamp(args);
   1650                 // Validate the outputs.
   1651                 boolean valid = true;
   1652                 if (args.out != arrayOut[i * 2 + j]) {
   1653                     valid = false;
   1654                 }
   1655                 if (!valid) {
   1656                     StringBuilder message = new StringBuilder();
   1657                     message.append("Input inValue: ");
   1658                     message.append(String.format("0x%x", args.inValue));
   1659                     message.append("\n");
   1660                     message.append("Input inMinValue: ");
   1661                     message.append(String.format("0x%x", args.inMinValue));
   1662                     message.append("\n");
   1663                     message.append("Input inMaxValue: ");
   1664                     message.append(String.format("0x%x", args.inMaxValue));
   1665                     message.append("\n");
   1666                     message.append("Expected output out: ");
   1667                     message.append(String.format("0x%x", args.out));
   1668                     message.append("\n");
   1669                     message.append("Actual   output out: ");
   1670                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   1671                     if (args.out != arrayOut[i * 2 + j]) {
   1672                         message.append(" FAIL");
   1673                     }
   1674                     message.append("\n");
   1675                     assertTrue("Incorrect output for checkClampUshort2Ushort2Ushort2Ushort2" +
   1676                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1677                 }
   1678             }
   1679         }
   1680     }
   1681 
   1682     private void checkClampUshort3Ushort3Ushort3Ushort3() {
   1683         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6b244d61fc64ee3dl, false);
   1684         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x7b8d14b8610b3967l, false);
   1685         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x7b8d14acf2682b6dl, false);
   1686         enforceOrdering(inMinValue, inMaxValue);
   1687         try {
   1688             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
   1689             script.set_gAllocInMinValue(inMinValue);
   1690             script.set_gAllocInMaxValue(inMaxValue);
   1691             script.forEach_testClampUshort3Ushort3Ushort3Ushort3(inValue, out);
   1692             verifyResultsClampUshort3Ushort3Ushort3Ushort3(inValue, inMinValue, inMaxValue, out, false);
   1693         } catch (Exception e) {
   1694             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3Ushort3Ushort3Ushort3: " + e.toString());
   1695         }
   1696         try {
   1697             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
   1698             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1699             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1700             scriptRelaxed.forEach_testClampUshort3Ushort3Ushort3Ushort3(inValue, out);
   1701             verifyResultsClampUshort3Ushort3Ushort3Ushort3(inValue, inMinValue, inMaxValue, out, true);
   1702         } catch (Exception e) {
   1703             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3Ushort3Ushort3Ushort3: " + e.toString());
   1704         }
   1705     }
   1706 
   1707     private void verifyResultsClampUshort3Ushort3Ushort3Ushort3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1708         short[] arrayInValue = new short[INPUTSIZE * 4];
   1709         inValue.copyTo(arrayInValue);
   1710         short[] arrayInMinValue = new short[INPUTSIZE * 4];
   1711         inMinValue.copyTo(arrayInMinValue);
   1712         short[] arrayInMaxValue = new short[INPUTSIZE * 4];
   1713         inMaxValue.copyTo(arrayInMaxValue);
   1714         short[] arrayOut = new short[INPUTSIZE * 4];
   1715         out.copyTo(arrayOut);
   1716         for (int i = 0; i < INPUTSIZE; i++) {
   1717             for (int j = 0; j < 3 ; j++) {
   1718                 // Extract the inputs.
   1719                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   1720                 args.inValue = arrayInValue[i * 4 + j];
   1721                 args.inMinValue = arrayInMinValue[i * 4 + j];
   1722                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   1723                 // Figure out what the outputs should have been.
   1724                 CoreMathVerifier.computeClamp(args);
   1725                 // Validate the outputs.
   1726                 boolean valid = true;
   1727                 if (args.out != arrayOut[i * 4 + j]) {
   1728                     valid = false;
   1729                 }
   1730                 if (!valid) {
   1731                     StringBuilder message = new StringBuilder();
   1732                     message.append("Input inValue: ");
   1733                     message.append(String.format("0x%x", args.inValue));
   1734                     message.append("\n");
   1735                     message.append("Input inMinValue: ");
   1736                     message.append(String.format("0x%x", args.inMinValue));
   1737                     message.append("\n");
   1738                     message.append("Input inMaxValue: ");
   1739                     message.append(String.format("0x%x", args.inMaxValue));
   1740                     message.append("\n");
   1741                     message.append("Expected output out: ");
   1742                     message.append(String.format("0x%x", args.out));
   1743                     message.append("\n");
   1744                     message.append("Actual   output out: ");
   1745                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   1746                     if (args.out != arrayOut[i * 4 + j]) {
   1747                         message.append(" FAIL");
   1748                     }
   1749                     message.append("\n");
   1750                     assertTrue("Incorrect output for checkClampUshort3Ushort3Ushort3Ushort3" +
   1751                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1752                 }
   1753             }
   1754         }
   1755     }
   1756 
   1757     private void checkClampUshort4Ushort4Ushort4Ushort4() {
   1758         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x7206bee0fc932575l, false);
   1759         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa5040add7272be8fl, false);
   1760         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa5040ad203cfb095l, false);
   1761         enforceOrdering(inMinValue, inMaxValue);
   1762         try {
   1763             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
   1764             script.set_gAllocInMinValue(inMinValue);
   1765             script.set_gAllocInMaxValue(inMaxValue);
   1766             script.forEach_testClampUshort4Ushort4Ushort4Ushort4(inValue, out);
   1767             verifyResultsClampUshort4Ushort4Ushort4Ushort4(inValue, inMinValue, inMaxValue, out, false);
   1768         } catch (Exception e) {
   1769             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4Ushort4Ushort4Ushort4: " + e.toString());
   1770         }
   1771         try {
   1772             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
   1773             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1774             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1775             scriptRelaxed.forEach_testClampUshort4Ushort4Ushort4Ushort4(inValue, out);
   1776             verifyResultsClampUshort4Ushort4Ushort4Ushort4(inValue, inMinValue, inMaxValue, out, true);
   1777         } catch (Exception e) {
   1778             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4Ushort4Ushort4Ushort4: " + e.toString());
   1779         }
   1780     }
   1781 
   1782     private void verifyResultsClampUshort4Ushort4Ushort4Ushort4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1783         short[] arrayInValue = new short[INPUTSIZE * 4];
   1784         inValue.copyTo(arrayInValue);
   1785         short[] arrayInMinValue = new short[INPUTSIZE * 4];
   1786         inMinValue.copyTo(arrayInMinValue);
   1787         short[] arrayInMaxValue = new short[INPUTSIZE * 4];
   1788         inMaxValue.copyTo(arrayInMaxValue);
   1789         short[] arrayOut = new short[INPUTSIZE * 4];
   1790         out.copyTo(arrayOut);
   1791         for (int i = 0; i < INPUTSIZE; i++) {
   1792             for (int j = 0; j < 4 ; j++) {
   1793                 // Extract the inputs.
   1794                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   1795                 args.inValue = arrayInValue[i * 4 + j];
   1796                 args.inMinValue = arrayInMinValue[i * 4 + j];
   1797                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   1798                 // Figure out what the outputs should have been.
   1799                 CoreMathVerifier.computeClamp(args);
   1800                 // Validate the outputs.
   1801                 boolean valid = true;
   1802                 if (args.out != arrayOut[i * 4 + j]) {
   1803                     valid = false;
   1804                 }
   1805                 if (!valid) {
   1806                     StringBuilder message = new StringBuilder();
   1807                     message.append("Input inValue: ");
   1808                     message.append(String.format("0x%x", args.inValue));
   1809                     message.append("\n");
   1810                     message.append("Input inMinValue: ");
   1811                     message.append(String.format("0x%x", args.inMinValue));
   1812                     message.append("\n");
   1813                     message.append("Input inMaxValue: ");
   1814                     message.append(String.format("0x%x", args.inMaxValue));
   1815                     message.append("\n");
   1816                     message.append("Expected output out: ");
   1817                     message.append(String.format("0x%x", args.out));
   1818                     message.append("\n");
   1819                     message.append("Actual   output out: ");
   1820                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   1821                     if (args.out != arrayOut[i * 4 + j]) {
   1822                         message.append(" FAIL");
   1823                     }
   1824                     message.append("\n");
   1825                     assertTrue("Incorrect output for checkClampUshort4Ushort4Ushort4Ushort4" +
   1826                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1827                 }
   1828             }
   1829         }
   1830     }
   1831 
   1832     public class ArgumentsIntIntIntInt {
   1833         public int inValue;
   1834         public int inMinValue;
   1835         public int inMaxValue;
   1836         public int out;
   1837     }
   1838 
   1839     private void checkClampIntIntIntInt() {
   1840         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfeb3aa11be6164c5l, false);
   1841         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xd11c228c7c8bf97fl, false);
   1842         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xd11c22810de8eb85l, false);
   1843         enforceOrdering(inMinValue, inMaxValue);
   1844         try {
   1845             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
   1846             script.set_gAllocInMinValue(inMinValue);
   1847             script.set_gAllocInMaxValue(inMaxValue);
   1848             script.forEach_testClampIntIntIntInt(inValue, out);
   1849             verifyResultsClampIntIntIntInt(inValue, inMinValue, inMaxValue, out, false);
   1850         } catch (Exception e) {
   1851             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampIntIntIntInt: " + e.toString());
   1852         }
   1853         try {
   1854             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
   1855             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1856             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1857             scriptRelaxed.forEach_testClampIntIntIntInt(inValue, out);
   1858             verifyResultsClampIntIntIntInt(inValue, inMinValue, inMaxValue, out, true);
   1859         } catch (Exception e) {
   1860             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampIntIntIntInt: " + e.toString());
   1861         }
   1862     }
   1863 
   1864     private void verifyResultsClampIntIntIntInt(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1865         int[] arrayInValue = new int[INPUTSIZE * 1];
   1866         inValue.copyTo(arrayInValue);
   1867         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   1868         inMinValue.copyTo(arrayInMinValue);
   1869         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   1870         inMaxValue.copyTo(arrayInMaxValue);
   1871         int[] arrayOut = new int[INPUTSIZE * 1];
   1872         out.copyTo(arrayOut);
   1873         for (int i = 0; i < INPUTSIZE; i++) {
   1874             for (int j = 0; j < 1 ; j++) {
   1875                 // Extract the inputs.
   1876                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   1877                 args.inValue = arrayInValue[i];
   1878                 args.inMinValue = arrayInMinValue[i];
   1879                 args.inMaxValue = arrayInMaxValue[i];
   1880                 // Figure out what the outputs should have been.
   1881                 CoreMathVerifier.computeClamp(args);
   1882                 // Validate the outputs.
   1883                 boolean valid = true;
   1884                 if (args.out != arrayOut[i * 1 + j]) {
   1885                     valid = false;
   1886                 }
   1887                 if (!valid) {
   1888                     StringBuilder message = new StringBuilder();
   1889                     message.append("Input inValue: ");
   1890                     message.append(String.format("%d", args.inValue));
   1891                     message.append("\n");
   1892                     message.append("Input inMinValue: ");
   1893                     message.append(String.format("%d", args.inMinValue));
   1894                     message.append("\n");
   1895                     message.append("Input inMaxValue: ");
   1896                     message.append(String.format("%d", args.inMaxValue));
   1897                     message.append("\n");
   1898                     message.append("Expected output out: ");
   1899                     message.append(String.format("%d", args.out));
   1900                     message.append("\n");
   1901                     message.append("Actual   output out: ");
   1902                     message.append(String.format("%d", arrayOut[i * 1 + j]));
   1903                     if (args.out != arrayOut[i * 1 + j]) {
   1904                         message.append(" FAIL");
   1905                     }
   1906                     message.append("\n");
   1907                     assertTrue("Incorrect output for checkClampIntIntIntInt" +
   1908                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1909                 }
   1910             }
   1911         }
   1912     }
   1913 
   1914     private void checkClampInt2Int2Int2Int2() {
   1915         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x56252903bd307c01l, false);
   1916         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x770112109398f8f3l, false);
   1917         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7701120524f5eaf9l, false);
   1918         enforceOrdering(inMinValue, inMaxValue);
   1919         try {
   1920             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
   1921             script.set_gAllocInMinValue(inMinValue);
   1922             script.set_gAllocInMaxValue(inMaxValue);
   1923             script.forEach_testClampInt2Int2Int2Int2(inValue, out);
   1924             verifyResultsClampInt2Int2Int2Int2(inValue, inMinValue, inMaxValue, out, false);
   1925         } catch (Exception e) {
   1926             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2Int2Int2Int2: " + e.toString());
   1927         }
   1928         try {
   1929             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
   1930             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   1931             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   1932             scriptRelaxed.forEach_testClampInt2Int2Int2Int2(inValue, out);
   1933             verifyResultsClampInt2Int2Int2Int2(inValue, inMinValue, inMaxValue, out, true);
   1934         } catch (Exception e) {
   1935             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2Int2Int2Int2: " + e.toString());
   1936         }
   1937     }
   1938 
   1939     private void verifyResultsClampInt2Int2Int2Int2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   1940         int[] arrayInValue = new int[INPUTSIZE * 2];
   1941         inValue.copyTo(arrayInValue);
   1942         int[] arrayInMinValue = new int[INPUTSIZE * 2];
   1943         inMinValue.copyTo(arrayInMinValue);
   1944         int[] arrayInMaxValue = new int[INPUTSIZE * 2];
   1945         inMaxValue.copyTo(arrayInMaxValue);
   1946         int[] arrayOut = new int[INPUTSIZE * 2];
   1947         out.copyTo(arrayOut);
   1948         for (int i = 0; i < INPUTSIZE; i++) {
   1949             for (int j = 0; j < 2 ; j++) {
   1950                 // Extract the inputs.
   1951                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   1952                 args.inValue = arrayInValue[i * 2 + j];
   1953                 args.inMinValue = arrayInMinValue[i * 2 + j];
   1954                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   1955                 // Figure out what the outputs should have been.
   1956                 CoreMathVerifier.computeClamp(args);
   1957                 // Validate the outputs.
   1958                 boolean valid = true;
   1959                 if (args.out != arrayOut[i * 2 + j]) {
   1960                     valid = false;
   1961                 }
   1962                 if (!valid) {
   1963                     StringBuilder message = new StringBuilder();
   1964                     message.append("Input inValue: ");
   1965                     message.append(String.format("%d", args.inValue));
   1966                     message.append("\n");
   1967                     message.append("Input inMinValue: ");
   1968                     message.append(String.format("%d", args.inMinValue));
   1969                     message.append("\n");
   1970                     message.append("Input inMaxValue: ");
   1971                     message.append(String.format("%d", args.inMaxValue));
   1972                     message.append("\n");
   1973                     message.append("Expected output out: ");
   1974                     message.append(String.format("%d", args.out));
   1975                     message.append("\n");
   1976                     message.append("Actual   output out: ");
   1977                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   1978                     if (args.out != arrayOut[i * 2 + j]) {
   1979                         message.append(" FAIL");
   1980                     }
   1981                     message.append("\n");
   1982                     assertTrue("Incorrect output for checkClampInt2Int2Int2Int2" +
   1983                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   1984                 }
   1985             }
   1986         }
   1987     }
   1988 
   1989     private void checkClampInt3Int3Int3Int3() {
   1990         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x966882045600d2edl, false);
   1991         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xeb73e6749c7caa77l, false);
   1992         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xeb73e6692dd99c7dl, false);
   1993         enforceOrdering(inMinValue, inMaxValue);
   1994         try {
   1995             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
   1996             script.set_gAllocInMinValue(inMinValue);
   1997             script.set_gAllocInMaxValue(inMaxValue);
   1998             script.forEach_testClampInt3Int3Int3Int3(inValue, out);
   1999             verifyResultsClampInt3Int3Int3Int3(inValue, inMinValue, inMaxValue, out, false);
   2000         } catch (Exception e) {
   2001             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3Int3Int3Int3: " + e.toString());
   2002         }
   2003         try {
   2004             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
   2005             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2006             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2007             scriptRelaxed.forEach_testClampInt3Int3Int3Int3(inValue, out);
   2008             verifyResultsClampInt3Int3Int3Int3(inValue, inMinValue, inMaxValue, out, true);
   2009         } catch (Exception e) {
   2010             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3Int3Int3Int3: " + e.toString());
   2011         }
   2012     }
   2013 
   2014     private void verifyResultsClampInt3Int3Int3Int3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2015         int[] arrayInValue = new int[INPUTSIZE * 4];
   2016         inValue.copyTo(arrayInValue);
   2017         int[] arrayInMinValue = new int[INPUTSIZE * 4];
   2018         inMinValue.copyTo(arrayInMinValue);
   2019         int[] arrayInMaxValue = new int[INPUTSIZE * 4];
   2020         inMaxValue.copyTo(arrayInMaxValue);
   2021         int[] arrayOut = new int[INPUTSIZE * 4];
   2022         out.copyTo(arrayOut);
   2023         for (int i = 0; i < INPUTSIZE; i++) {
   2024             for (int j = 0; j < 3 ; j++) {
   2025                 // Extract the inputs.
   2026                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   2027                 args.inValue = arrayInValue[i * 4 + j];
   2028                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2029                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2030                 // Figure out what the outputs should have been.
   2031                 CoreMathVerifier.computeClamp(args);
   2032                 // Validate the outputs.
   2033                 boolean valid = true;
   2034                 if (args.out != arrayOut[i * 4 + j]) {
   2035                     valid = false;
   2036                 }
   2037                 if (!valid) {
   2038                     StringBuilder message = new StringBuilder();
   2039                     message.append("Input inValue: ");
   2040                     message.append(String.format("%d", args.inValue));
   2041                     message.append("\n");
   2042                     message.append("Input inMinValue: ");
   2043                     message.append(String.format("%d", args.inMinValue));
   2044                     message.append("\n");
   2045                     message.append("Input inMaxValue: ");
   2046                     message.append(String.format("%d", args.inMaxValue));
   2047                     message.append("\n");
   2048                     message.append("Expected output out: ");
   2049                     message.append(String.format("%d", args.out));
   2050                     message.append("\n");
   2051                     message.append("Actual   output out: ");
   2052                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   2053                     if (args.out != arrayOut[i * 4 + j]) {
   2054                         message.append(" FAIL");
   2055                     }
   2056                     message.append("\n");
   2057                     assertTrue("Incorrect output for checkClampInt3Int3Int3Int3" +
   2058                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2059                 }
   2060             }
   2061         }
   2062     }
   2063 
   2064     private void checkClampInt4Int4Int4Int4() {
   2065         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd6abdb04eed129d9l, false);
   2066         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x5fe6bad8a5605bfbl, false);
   2067         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x5fe6bacd36bd4e01l, false);
   2068         enforceOrdering(inMinValue, inMaxValue);
   2069         try {
   2070             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
   2071             script.set_gAllocInMinValue(inMinValue);
   2072             script.set_gAllocInMaxValue(inMaxValue);
   2073             script.forEach_testClampInt4Int4Int4Int4(inValue, out);
   2074             verifyResultsClampInt4Int4Int4Int4(inValue, inMinValue, inMaxValue, out, false);
   2075         } catch (Exception e) {
   2076             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4Int4Int4Int4: " + e.toString());
   2077         }
   2078         try {
   2079             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
   2080             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2081             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2082             scriptRelaxed.forEach_testClampInt4Int4Int4Int4(inValue, out);
   2083             verifyResultsClampInt4Int4Int4Int4(inValue, inMinValue, inMaxValue, out, true);
   2084         } catch (Exception e) {
   2085             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4Int4Int4Int4: " + e.toString());
   2086         }
   2087     }
   2088 
   2089     private void verifyResultsClampInt4Int4Int4Int4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2090         int[] arrayInValue = new int[INPUTSIZE * 4];
   2091         inValue.copyTo(arrayInValue);
   2092         int[] arrayInMinValue = new int[INPUTSIZE * 4];
   2093         inMinValue.copyTo(arrayInMinValue);
   2094         int[] arrayInMaxValue = new int[INPUTSIZE * 4];
   2095         inMaxValue.copyTo(arrayInMaxValue);
   2096         int[] arrayOut = new int[INPUTSIZE * 4];
   2097         out.copyTo(arrayOut);
   2098         for (int i = 0; i < INPUTSIZE; i++) {
   2099             for (int j = 0; j < 4 ; j++) {
   2100                 // Extract the inputs.
   2101                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   2102                 args.inValue = arrayInValue[i * 4 + j];
   2103                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2104                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2105                 // Figure out what the outputs should have been.
   2106                 CoreMathVerifier.computeClamp(args);
   2107                 // Validate the outputs.
   2108                 boolean valid = true;
   2109                 if (args.out != arrayOut[i * 4 + j]) {
   2110                     valid = false;
   2111                 }
   2112                 if (!valid) {
   2113                     StringBuilder message = new StringBuilder();
   2114                     message.append("Input inValue: ");
   2115                     message.append(String.format("%d", args.inValue));
   2116                     message.append("\n");
   2117                     message.append("Input inMinValue: ");
   2118                     message.append(String.format("%d", args.inMinValue));
   2119                     message.append("\n");
   2120                     message.append("Input inMaxValue: ");
   2121                     message.append(String.format("%d", args.inMaxValue));
   2122                     message.append("\n");
   2123                     message.append("Expected output out: ");
   2124                     message.append(String.format("%d", args.out));
   2125                     message.append("\n");
   2126                     message.append("Actual   output out: ");
   2127                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   2128                     if (args.out != arrayOut[i * 4 + j]) {
   2129                         message.append(" FAIL");
   2130                     }
   2131                     message.append("\n");
   2132                     assertTrue("Incorrect output for checkClampInt4Int4Int4Int4" +
   2133                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2134                 }
   2135             }
   2136         }
   2137     }
   2138 
   2139     public class ArgumentsUintUintUintUint {
   2140         public int inValue;
   2141         public int inMinValue;
   2142         public int inMaxValue;
   2143         public int out;
   2144     }
   2145 
   2146     private void checkClampUintUintUintUint() {
   2147         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xd8df32b2efc89475l, false);
   2148         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcf8ec8eece8b7b8fl, false);
   2149         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcf8ec8e35fe86d95l, false);
   2150         enforceOrdering(inMinValue, inMaxValue);
   2151         try {
   2152             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
   2153             script.set_gAllocInMinValue(inMinValue);
   2154             script.set_gAllocInMaxValue(inMaxValue);
   2155             script.forEach_testClampUintUintUintUint(inValue, out);
   2156             verifyResultsClampUintUintUintUint(inValue, inMinValue, inMaxValue, out, false);
   2157         } catch (Exception e) {
   2158             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUintUintUintUint: " + e.toString());
   2159         }
   2160         try {
   2161             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
   2162             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2163             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2164             scriptRelaxed.forEach_testClampUintUintUintUint(inValue, out);
   2165             verifyResultsClampUintUintUintUint(inValue, inMinValue, inMaxValue, out, true);
   2166         } catch (Exception e) {
   2167             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUintUintUintUint: " + e.toString());
   2168         }
   2169     }
   2170 
   2171     private void verifyResultsClampUintUintUintUint(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2172         int[] arrayInValue = new int[INPUTSIZE * 1];
   2173         inValue.copyTo(arrayInValue);
   2174         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   2175         inMinValue.copyTo(arrayInMinValue);
   2176         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   2177         inMaxValue.copyTo(arrayInMaxValue);
   2178         int[] arrayOut = new int[INPUTSIZE * 1];
   2179         out.copyTo(arrayOut);
   2180         for (int i = 0; i < INPUTSIZE; i++) {
   2181             for (int j = 0; j < 1 ; j++) {
   2182                 // Extract the inputs.
   2183                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   2184                 args.inValue = arrayInValue[i];
   2185                 args.inMinValue = arrayInMinValue[i];
   2186                 args.inMaxValue = arrayInMaxValue[i];
   2187                 // Figure out what the outputs should have been.
   2188                 CoreMathVerifier.computeClamp(args);
   2189                 // Validate the outputs.
   2190                 boolean valid = true;
   2191                 if (args.out != arrayOut[i * 1 + j]) {
   2192                     valid = false;
   2193                 }
   2194                 if (!valid) {
   2195                     StringBuilder message = new StringBuilder();
   2196                     message.append("Input inValue: ");
   2197                     message.append(String.format("0x%x", args.inValue));
   2198                     message.append("\n");
   2199                     message.append("Input inMinValue: ");
   2200                     message.append(String.format("0x%x", args.inMinValue));
   2201                     message.append("\n");
   2202                     message.append("Input inMaxValue: ");
   2203                     message.append(String.format("0x%x", args.inMaxValue));
   2204                     message.append("\n");
   2205                     message.append("Expected output out: ");
   2206                     message.append(String.format("0x%x", args.out));
   2207                     message.append("\n");
   2208                     message.append("Actual   output out: ");
   2209                     message.append(String.format("0x%x", arrayOut[i * 1 + j]));
   2210                     if (args.out != arrayOut[i * 1 + j]) {
   2211                         message.append(" FAIL");
   2212                     }
   2213                     message.append("\n");
   2214                     assertTrue("Incorrect output for checkClampUintUintUintUint" +
   2215                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2216                 }
   2217             }
   2218         }
   2219     }
   2220 
   2221     private void checkClampUint2Uint2Uint2Uint2() {
   2222         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xaf28d478873ae5dl, false);
   2223         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x5bbd21aa2a4bc7l, false);
   2224         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x5bbd163b873dcdl, false);
   2225         enforceOrdering(inMinValue, inMaxValue);
   2226         try {
   2227             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
   2228             script.set_gAllocInMinValue(inMinValue);
   2229             script.set_gAllocInMaxValue(inMaxValue);
   2230             script.forEach_testClampUint2Uint2Uint2Uint2(inValue, out);
   2231             verifyResultsClampUint2Uint2Uint2Uint2(inValue, inMinValue, inMaxValue, out, false);
   2232         } catch (Exception e) {
   2233             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2Uint2Uint2Uint2: " + e.toString());
   2234         }
   2235         try {
   2236             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
   2237             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2238             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2239             scriptRelaxed.forEach_testClampUint2Uint2Uint2Uint2(inValue, out);
   2240             verifyResultsClampUint2Uint2Uint2Uint2(inValue, inMinValue, inMaxValue, out, true);
   2241         } catch (Exception e) {
   2242             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2Uint2Uint2Uint2: " + e.toString());
   2243         }
   2244     }
   2245 
   2246     private void verifyResultsClampUint2Uint2Uint2Uint2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2247         int[] arrayInValue = new int[INPUTSIZE * 2];
   2248         inValue.copyTo(arrayInValue);
   2249         int[] arrayInMinValue = new int[INPUTSIZE * 2];
   2250         inMinValue.copyTo(arrayInMinValue);
   2251         int[] arrayInMaxValue = new int[INPUTSIZE * 2];
   2252         inMaxValue.copyTo(arrayInMaxValue);
   2253         int[] arrayOut = new int[INPUTSIZE * 2];
   2254         out.copyTo(arrayOut);
   2255         for (int i = 0; i < INPUTSIZE; i++) {
   2256             for (int j = 0; j < 2 ; j++) {
   2257                 // Extract the inputs.
   2258                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   2259                 args.inValue = arrayInValue[i * 2 + j];
   2260                 args.inMinValue = arrayInMinValue[i * 2 + j];
   2261                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   2262                 // Figure out what the outputs should have been.
   2263                 CoreMathVerifier.computeClamp(args);
   2264                 // Validate the outputs.
   2265                 boolean valid = true;
   2266                 if (args.out != arrayOut[i * 2 + j]) {
   2267                     valid = false;
   2268                 }
   2269                 if (!valid) {
   2270                     StringBuilder message = new StringBuilder();
   2271                     message.append("Input inValue: ");
   2272                     message.append(String.format("0x%x", args.inValue));
   2273                     message.append("\n");
   2274                     message.append("Input inMinValue: ");
   2275                     message.append(String.format("0x%x", args.inMinValue));
   2276                     message.append("\n");
   2277                     message.append("Input inMaxValue: ");
   2278                     message.append(String.format("0x%x", args.inMaxValue));
   2279                     message.append("\n");
   2280                     message.append("Expected output out: ");
   2281                     message.append(String.format("0x%x", args.out));
   2282                     message.append("\n");
   2283                     message.append("Actual   output out: ");
   2284                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   2285                     if (args.out != arrayOut[i * 2 + j]) {
   2286                         message.append(" FAIL");
   2287                     }
   2288                     message.append("\n");
   2289                     assertTrue("Incorrect output for checkClampUint2Uint2Uint2Uint2" +
   2290                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2291                 }
   2292             }
   2293         }
   2294     }
   2295 
   2296     private void checkClampUint3Uint3Uint3Uint3() {
   2297         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x639fab187e48aaa5l, false);
   2298         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8ddee5cebcf6591fl, false);
   2299         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8ddee5c34e534b25l, false);
   2300         enforceOrdering(inMinValue, inMaxValue);
   2301         try {
   2302             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
   2303             script.set_gAllocInMinValue(inMinValue);
   2304             script.set_gAllocInMaxValue(inMaxValue);
   2305             script.forEach_testClampUint3Uint3Uint3Uint3(inValue, out);
   2306             verifyResultsClampUint3Uint3Uint3Uint3(inValue, inMinValue, inMaxValue, out, false);
   2307         } catch (Exception e) {
   2308             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3Uint3Uint3Uint3: " + e.toString());
   2309         }
   2310         try {
   2311             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
   2312             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2313             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2314             scriptRelaxed.forEach_testClampUint3Uint3Uint3Uint3(inValue, out);
   2315             verifyResultsClampUint3Uint3Uint3Uint3(inValue, inMinValue, inMaxValue, out, true);
   2316         } catch (Exception e) {
   2317             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3Uint3Uint3Uint3: " + e.toString());
   2318         }
   2319     }
   2320 
   2321     private void verifyResultsClampUint3Uint3Uint3Uint3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2322         int[] arrayInValue = new int[INPUTSIZE * 4];
   2323         inValue.copyTo(arrayInValue);
   2324         int[] arrayInMinValue = new int[INPUTSIZE * 4];
   2325         inMinValue.copyTo(arrayInMinValue);
   2326         int[] arrayInMaxValue = new int[INPUTSIZE * 4];
   2327         inMaxValue.copyTo(arrayInMaxValue);
   2328         int[] arrayOut = new int[INPUTSIZE * 4];
   2329         out.copyTo(arrayOut);
   2330         for (int i = 0; i < INPUTSIZE; i++) {
   2331             for (int j = 0; j < 3 ; j++) {
   2332                 // Extract the inputs.
   2333                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   2334                 args.inValue = arrayInValue[i * 4 + j];
   2335                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2336                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2337                 // Figure out what the outputs should have been.
   2338                 CoreMathVerifier.computeClamp(args);
   2339                 // Validate the outputs.
   2340                 boolean valid = true;
   2341                 if (args.out != arrayOut[i * 4 + j]) {
   2342                     valid = false;
   2343                 }
   2344                 if (!valid) {
   2345                     StringBuilder message = new StringBuilder();
   2346                     message.append("Input inValue: ");
   2347                     message.append(String.format("0x%x", args.inValue));
   2348                     message.append("\n");
   2349                     message.append("Input inMinValue: ");
   2350                     message.append(String.format("0x%x", args.inMinValue));
   2351                     message.append("\n");
   2352                     message.append("Input inMaxValue: ");
   2353                     message.append(String.format("0x%x", args.inMaxValue));
   2354                     message.append("\n");
   2355                     message.append("Expected output out: ");
   2356                     message.append(String.format("0x%x", args.out));
   2357                     message.append("\n");
   2358                     message.append("Actual   output out: ");
   2359                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   2360                     if (args.out != arrayOut[i * 4 + j]) {
   2361                         message.append(" FAIL");
   2362                     }
   2363                     message.append("\n");
   2364                     assertTrue("Incorrect output for checkClampUint3Uint3Uint3Uint3" +
   2365                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2366                 }
   2367             }
   2368         }
   2369     }
   2370 
   2371     private void checkClampUint4Uint4Uint4Uint4() {
   2372         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xbc4cc8e9741da6edl, false);
   2373         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x1b620e7bcfc26677l, false);
   2374         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x1b620e70611f587dl, false);
   2375         enforceOrdering(inMinValue, inMaxValue);
   2376         try {
   2377             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
   2378             script.set_gAllocInMinValue(inMinValue);
   2379             script.set_gAllocInMaxValue(inMaxValue);
   2380             script.forEach_testClampUint4Uint4Uint4Uint4(inValue, out);
   2381             verifyResultsClampUint4Uint4Uint4Uint4(inValue, inMinValue, inMaxValue, out, false);
   2382         } catch (Exception e) {
   2383             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4Uint4Uint4Uint4: " + e.toString());
   2384         }
   2385         try {
   2386             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
   2387             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2388             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2389             scriptRelaxed.forEach_testClampUint4Uint4Uint4Uint4(inValue, out);
   2390             verifyResultsClampUint4Uint4Uint4Uint4(inValue, inMinValue, inMaxValue, out, true);
   2391         } catch (Exception e) {
   2392             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4Uint4Uint4Uint4: " + e.toString());
   2393         }
   2394     }
   2395 
   2396     private void verifyResultsClampUint4Uint4Uint4Uint4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2397         int[] arrayInValue = new int[INPUTSIZE * 4];
   2398         inValue.copyTo(arrayInValue);
   2399         int[] arrayInMinValue = new int[INPUTSIZE * 4];
   2400         inMinValue.copyTo(arrayInMinValue);
   2401         int[] arrayInMaxValue = new int[INPUTSIZE * 4];
   2402         inMaxValue.copyTo(arrayInMaxValue);
   2403         int[] arrayOut = new int[INPUTSIZE * 4];
   2404         out.copyTo(arrayOut);
   2405         for (int i = 0; i < INPUTSIZE; i++) {
   2406             for (int j = 0; j < 4 ; j++) {
   2407                 // Extract the inputs.
   2408                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   2409                 args.inValue = arrayInValue[i * 4 + j];
   2410                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2411                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2412                 // Figure out what the outputs should have been.
   2413                 CoreMathVerifier.computeClamp(args);
   2414                 // Validate the outputs.
   2415                 boolean valid = true;
   2416                 if (args.out != arrayOut[i * 4 + j]) {
   2417                     valid = false;
   2418                 }
   2419                 if (!valid) {
   2420                     StringBuilder message = new StringBuilder();
   2421                     message.append("Input inValue: ");
   2422                     message.append(String.format("0x%x", args.inValue));
   2423                     message.append("\n");
   2424                     message.append("Input inMinValue: ");
   2425                     message.append(String.format("0x%x", args.inMinValue));
   2426                     message.append("\n");
   2427                     message.append("Input inMaxValue: ");
   2428                     message.append(String.format("0x%x", args.inMaxValue));
   2429                     message.append("\n");
   2430                     message.append("Expected output out: ");
   2431                     message.append(String.format("0x%x", args.out));
   2432                     message.append("\n");
   2433                     message.append("Actual   output out: ");
   2434                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   2435                     if (args.out != arrayOut[i * 4 + j]) {
   2436                         message.append(" FAIL");
   2437                     }
   2438                     message.append("\n");
   2439                     assertTrue("Incorrect output for checkClampUint4Uint4Uint4Uint4" +
   2440                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2441                 }
   2442             }
   2443         }
   2444     }
   2445 
   2446     public class ArgumentsLongLongLongLong {
   2447         public long inValue;
   2448         public long inMinValue;
   2449         public long inMaxValue;
   2450         public long out;
   2451     }
   2452 
   2453     private void checkClampLongLongLongLong() {
   2454         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x63fd360531c9c41dl, false);
   2455         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x9d04d1824ef4907l, false);
   2456         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x9d04d0cb64c3b0dl, false);
   2457         enforceOrdering(inMinValue, inMaxValue);
   2458         try {
   2459             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE);
   2460             script.set_gAllocInMinValue(inMinValue);
   2461             script.set_gAllocInMaxValue(inMaxValue);
   2462             script.forEach_testClampLongLongLongLong(inValue, out);
   2463             verifyResultsClampLongLongLongLong(inValue, inMinValue, inMaxValue, out, false);
   2464         } catch (Exception e) {
   2465             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLongLongLongLong: " + e.toString());
   2466         }
   2467         try {
   2468             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE);
   2469             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2470             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2471             scriptRelaxed.forEach_testClampLongLongLongLong(inValue, out);
   2472             verifyResultsClampLongLongLongLong(inValue, inMinValue, inMaxValue, out, true);
   2473         } catch (Exception e) {
   2474             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLongLongLongLong: " + e.toString());
   2475         }
   2476     }
   2477 
   2478     private void verifyResultsClampLongLongLongLong(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2479         long[] arrayInValue = new long[INPUTSIZE * 1];
   2480         inValue.copyTo(arrayInValue);
   2481         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   2482         inMinValue.copyTo(arrayInMinValue);
   2483         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   2484         inMaxValue.copyTo(arrayInMaxValue);
   2485         long[] arrayOut = new long[INPUTSIZE * 1];
   2486         out.copyTo(arrayOut);
   2487         for (int i = 0; i < INPUTSIZE; i++) {
   2488             for (int j = 0; j < 1 ; j++) {
   2489                 // Extract the inputs.
   2490                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   2491                 args.inValue = arrayInValue[i];
   2492                 args.inMinValue = arrayInMinValue[i];
   2493                 args.inMaxValue = arrayInMaxValue[i];
   2494                 // Figure out what the outputs should have been.
   2495                 CoreMathVerifier.computeClamp(args);
   2496                 // Validate the outputs.
   2497                 boolean valid = true;
   2498                 if (args.out != arrayOut[i * 1 + j]) {
   2499                     valid = false;
   2500                 }
   2501                 if (!valid) {
   2502                     StringBuilder message = new StringBuilder();
   2503                     message.append("Input inValue: ");
   2504                     message.append(String.format("%d", args.inValue));
   2505                     message.append("\n");
   2506                     message.append("Input inMinValue: ");
   2507                     message.append(String.format("%d", args.inMinValue));
   2508                     message.append("\n");
   2509                     message.append("Input inMaxValue: ");
   2510                     message.append(String.format("%d", args.inMaxValue));
   2511                     message.append("\n");
   2512                     message.append("Expected output out: ");
   2513                     message.append(String.format("%d", args.out));
   2514                     message.append("\n");
   2515                     message.append("Actual   output out: ");
   2516                     message.append(String.format("%d", arrayOut[i * 1 + j]));
   2517                     if (args.out != arrayOut[i * 1 + j]) {
   2518                         message.append(" FAIL");
   2519                     }
   2520                     message.append("\n");
   2521                     assertTrue("Incorrect output for checkClampLongLongLongLong" +
   2522                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2523                 }
   2524             }
   2525         }
   2526     }
   2527 
   2528     private void checkClampLong2Long2Long2Long2() {
   2529         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xccbae869c2b0f12dl, false);
   2530         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe4c3844f4a3f8937l, false);
   2531         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe4c38443db9c7b3dl, false);
   2532         enforceOrdering(inMinValue, inMaxValue);
   2533         try {
   2534             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
   2535             script.set_gAllocInMinValue(inMinValue);
   2536             script.set_gAllocInMaxValue(inMaxValue);
   2537             script.forEach_testClampLong2Long2Long2Long2(inValue, out);
   2538             verifyResultsClampLong2Long2Long2Long2(inValue, inMinValue, inMaxValue, out, false);
   2539         } catch (Exception e) {
   2540             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2Long2Long2Long2: " + e.toString());
   2541         }
   2542         try {
   2543             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
   2544             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2545             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2546             scriptRelaxed.forEach_testClampLong2Long2Long2Long2(inValue, out);
   2547             verifyResultsClampLong2Long2Long2Long2(inValue, inMinValue, inMaxValue, out, true);
   2548         } catch (Exception e) {
   2549             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2Long2Long2Long2: " + e.toString());
   2550         }
   2551     }
   2552 
   2553     private void verifyResultsClampLong2Long2Long2Long2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2554         long[] arrayInValue = new long[INPUTSIZE * 2];
   2555         inValue.copyTo(arrayInValue);
   2556         long[] arrayInMinValue = new long[INPUTSIZE * 2];
   2557         inMinValue.copyTo(arrayInMinValue);
   2558         long[] arrayInMaxValue = new long[INPUTSIZE * 2];
   2559         inMaxValue.copyTo(arrayInMaxValue);
   2560         long[] arrayOut = new long[INPUTSIZE * 2];
   2561         out.copyTo(arrayOut);
   2562         for (int i = 0; i < INPUTSIZE; i++) {
   2563             for (int j = 0; j < 2 ; j++) {
   2564                 // Extract the inputs.
   2565                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   2566                 args.inValue = arrayInValue[i * 2 + j];
   2567                 args.inMinValue = arrayInMinValue[i * 2 + j];
   2568                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   2569                 // Figure out what the outputs should have been.
   2570                 CoreMathVerifier.computeClamp(args);
   2571                 // Validate the outputs.
   2572                 boolean valid = true;
   2573                 if (args.out != arrayOut[i * 2 + j]) {
   2574                     valid = false;
   2575                 }
   2576                 if (!valid) {
   2577                     StringBuilder message = new StringBuilder();
   2578                     message.append("Input inValue: ");
   2579                     message.append(String.format("%d", args.inValue));
   2580                     message.append("\n");
   2581                     message.append("Input inMinValue: ");
   2582                     message.append(String.format("%d", args.inMinValue));
   2583                     message.append("\n");
   2584                     message.append("Input inMaxValue: ");
   2585                     message.append(String.format("%d", args.inMaxValue));
   2586                     message.append("\n");
   2587                     message.append("Expected output out: ");
   2588                     message.append(String.format("%d", args.out));
   2589                     message.append("\n");
   2590                     message.append("Actual   output out: ");
   2591                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   2592                     if (args.out != arrayOut[i * 2 + j]) {
   2593                         message.append(" FAIL");
   2594                     }
   2595                     message.append("\n");
   2596                     assertTrue("Incorrect output for checkClampLong2Long2Long2Long2" +
   2597                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2598                 }
   2599             }
   2600         }
   2601     }
   2602 
   2603     private void checkClampLong3Long3Long3Long3() {
   2604         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2568063ab885ed75l, false);
   2605         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7246acfc5d0b968fl, false);
   2606         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7246acf0ee688895l, false);
   2607         enforceOrdering(inMinValue, inMaxValue);
   2608         try {
   2609             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
   2610             script.set_gAllocInMinValue(inMinValue);
   2611             script.set_gAllocInMaxValue(inMaxValue);
   2612             script.forEach_testClampLong3Long3Long3Long3(inValue, out);
   2613             verifyResultsClampLong3Long3Long3Long3(inValue, inMinValue, inMaxValue, out, false);
   2614         } catch (Exception e) {
   2615             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3Long3Long3Long3: " + e.toString());
   2616         }
   2617         try {
   2618             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
   2619             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2620             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2621             scriptRelaxed.forEach_testClampLong3Long3Long3Long3(inValue, out);
   2622             verifyResultsClampLong3Long3Long3Long3(inValue, inMinValue, inMaxValue, out, true);
   2623         } catch (Exception e) {
   2624             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3Long3Long3Long3: " + e.toString());
   2625         }
   2626     }
   2627 
   2628     private void verifyResultsClampLong3Long3Long3Long3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2629         long[] arrayInValue = new long[INPUTSIZE * 4];
   2630         inValue.copyTo(arrayInValue);
   2631         long[] arrayInMinValue = new long[INPUTSIZE * 4];
   2632         inMinValue.copyTo(arrayInMinValue);
   2633         long[] arrayInMaxValue = new long[INPUTSIZE * 4];
   2634         inMaxValue.copyTo(arrayInMaxValue);
   2635         long[] arrayOut = new long[INPUTSIZE * 4];
   2636         out.copyTo(arrayOut);
   2637         for (int i = 0; i < INPUTSIZE; i++) {
   2638             for (int j = 0; j < 3 ; j++) {
   2639                 // Extract the inputs.
   2640                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   2641                 args.inValue = arrayInValue[i * 4 + j];
   2642                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2643                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2644                 // Figure out what the outputs should have been.
   2645                 CoreMathVerifier.computeClamp(args);
   2646                 // Validate the outputs.
   2647                 boolean valid = true;
   2648                 if (args.out != arrayOut[i * 4 + j]) {
   2649                     valid = false;
   2650                 }
   2651                 if (!valid) {
   2652                     StringBuilder message = new StringBuilder();
   2653                     message.append("Input inValue: ");
   2654                     message.append(String.format("%d", args.inValue));
   2655                     message.append("\n");
   2656                     message.append("Input inMinValue: ");
   2657                     message.append(String.format("%d", args.inMinValue));
   2658                     message.append("\n");
   2659                     message.append("Input inMaxValue: ");
   2660                     message.append(String.format("%d", args.inMaxValue));
   2661                     message.append("\n");
   2662                     message.append("Expected output out: ");
   2663                     message.append(String.format("%d", args.out));
   2664                     message.append("\n");
   2665                     message.append("Actual   output out: ");
   2666                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   2667                     if (args.out != arrayOut[i * 4 + j]) {
   2668                         message.append(" FAIL");
   2669                     }
   2670                     message.append("\n");
   2671                     assertTrue("Incorrect output for checkClampLong3Long3Long3Long3" +
   2672                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2673                 }
   2674             }
   2675         }
   2676     }
   2677 
   2678     private void checkClampLong4Long4Long4Long4() {
   2679         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7e15240bae5ae9bdl, false);
   2680         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xffc9d5a96fd7a3e7l, false);
   2681         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xffc9d59e013495edl, false);
   2682         enforceOrdering(inMinValue, inMaxValue);
   2683         try {
   2684             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
   2685             script.set_gAllocInMinValue(inMinValue);
   2686             script.set_gAllocInMaxValue(inMaxValue);
   2687             script.forEach_testClampLong4Long4Long4Long4(inValue, out);
   2688             verifyResultsClampLong4Long4Long4Long4(inValue, inMinValue, inMaxValue, out, false);
   2689         } catch (Exception e) {
   2690             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4Long4Long4Long4: " + e.toString());
   2691         }
   2692         try {
   2693             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
   2694             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2695             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2696             scriptRelaxed.forEach_testClampLong4Long4Long4Long4(inValue, out);
   2697             verifyResultsClampLong4Long4Long4Long4(inValue, inMinValue, inMaxValue, out, true);
   2698         } catch (Exception e) {
   2699             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4Long4Long4Long4: " + e.toString());
   2700         }
   2701     }
   2702 
   2703     private void verifyResultsClampLong4Long4Long4Long4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2704         long[] arrayInValue = new long[INPUTSIZE * 4];
   2705         inValue.copyTo(arrayInValue);
   2706         long[] arrayInMinValue = new long[INPUTSIZE * 4];
   2707         inMinValue.copyTo(arrayInMinValue);
   2708         long[] arrayInMaxValue = new long[INPUTSIZE * 4];
   2709         inMaxValue.copyTo(arrayInMaxValue);
   2710         long[] arrayOut = new long[INPUTSIZE * 4];
   2711         out.copyTo(arrayOut);
   2712         for (int i = 0; i < INPUTSIZE; i++) {
   2713             for (int j = 0; j < 4 ; j++) {
   2714                 // Extract the inputs.
   2715                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   2716                 args.inValue = arrayInValue[i * 4 + j];
   2717                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2718                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2719                 // Figure out what the outputs should have been.
   2720                 CoreMathVerifier.computeClamp(args);
   2721                 // Validate the outputs.
   2722                 boolean valid = true;
   2723                 if (args.out != arrayOut[i * 4 + j]) {
   2724                     valid = false;
   2725                 }
   2726                 if (!valid) {
   2727                     StringBuilder message = new StringBuilder();
   2728                     message.append("Input inValue: ");
   2729                     message.append(String.format("%d", args.inValue));
   2730                     message.append("\n");
   2731                     message.append("Input inMinValue: ");
   2732                     message.append(String.format("%d", args.inMinValue));
   2733                     message.append("\n");
   2734                     message.append("Input inMaxValue: ");
   2735                     message.append(String.format("%d", args.inMaxValue));
   2736                     message.append("\n");
   2737                     message.append("Expected output out: ");
   2738                     message.append(String.format("%d", args.out));
   2739                     message.append("\n");
   2740                     message.append("Actual   output out: ");
   2741                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   2742                     if (args.out != arrayOut[i * 4 + j]) {
   2743                         message.append(" FAIL");
   2744                     }
   2745                     message.append("\n");
   2746                     assertTrue("Incorrect output for checkClampLong4Long4Long4Long4" +
   2747                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2748                 }
   2749             }
   2750         }
   2751     }
   2752 
   2753     public class ArgumentsUlongUlongUlongUlong {
   2754         public long inValue;
   2755         public long inMinValue;
   2756         public long inMaxValue;
   2757         public long out;
   2758     }
   2759 
   2760     private void checkClampUlongUlongUlongUlong() {
   2761         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x2b378139749bf4c5l, false);
   2762         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x75ac5050a8ca97fl, false);
   2763         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x75ac4f99be99b85l, false);
   2764         enforceOrdering(inMinValue, inMaxValue);
   2765         try {
   2766             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE);
   2767             script.set_gAllocInMinValue(inMinValue);
   2768             script.set_gAllocInMaxValue(inMaxValue);
   2769             script.forEach_testClampUlongUlongUlongUlong(inValue, out);
   2770             verifyResultsClampUlongUlongUlongUlong(inValue, inMinValue, inMaxValue, out, false);
   2771         } catch (Exception e) {
   2772             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlongUlongUlongUlong: " + e.toString());
   2773         }
   2774         try {
   2775             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE);
   2776             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2777             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2778             scriptRelaxed.forEach_testClampUlongUlongUlongUlong(inValue, out);
   2779             verifyResultsClampUlongUlongUlongUlong(inValue, inMinValue, inMaxValue, out, true);
   2780         } catch (Exception e) {
   2781             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlongUlongUlongUlong: " + e.toString());
   2782         }
   2783     }
   2784 
   2785     private void verifyResultsClampUlongUlongUlongUlong(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2786         long[] arrayInValue = new long[INPUTSIZE * 1];
   2787         inValue.copyTo(arrayInValue);
   2788         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   2789         inMinValue.copyTo(arrayInMinValue);
   2790         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   2791         inMaxValue.copyTo(arrayInMaxValue);
   2792         long[] arrayOut = new long[INPUTSIZE * 1];
   2793         out.copyTo(arrayOut);
   2794         for (int i = 0; i < INPUTSIZE; i++) {
   2795             for (int j = 0; j < 1 ; j++) {
   2796                 // Extract the inputs.
   2797                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   2798                 args.inValue = arrayInValue[i];
   2799                 args.inMinValue = arrayInMinValue[i];
   2800                 args.inMaxValue = arrayInMaxValue[i];
   2801                 // Figure out what the outputs should have been.
   2802                 CoreMathVerifier.computeClamp(args);
   2803                 // Validate the outputs.
   2804                 boolean valid = true;
   2805                 if (args.out != arrayOut[i * 1 + j]) {
   2806                     valid = false;
   2807                 }
   2808                 if (!valid) {
   2809                     StringBuilder message = new StringBuilder();
   2810                     message.append("Input inValue: ");
   2811                     message.append(String.format("0x%x", args.inValue));
   2812                     message.append("\n");
   2813                     message.append("Input inMinValue: ");
   2814                     message.append(String.format("0x%x", args.inMinValue));
   2815                     message.append("\n");
   2816                     message.append("Input inMaxValue: ");
   2817                     message.append(String.format("0x%x", args.inMaxValue));
   2818                     message.append("\n");
   2819                     message.append("Expected output out: ");
   2820                     message.append(String.format("0x%x", args.out));
   2821                     message.append("\n");
   2822                     message.append("Actual   output out: ");
   2823                     message.append(String.format("0x%x", arrayOut[i * 1 + j]));
   2824                     if (args.out != arrayOut[i * 1 + j]) {
   2825                         message.append(" FAIL");
   2826                     }
   2827                     message.append("\n");
   2828                     assertTrue("Incorrect output for checkClampUlongUlongUlongUlong" +
   2829                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2830                 }
   2831             }
   2832         }
   2833     }
   2834 
   2835     private void checkClampUlong2Ulong2Ulong2Ulong2() {
   2836         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xa8c7fb17a09bb299l, false);
   2837         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x14e3c8dffe45623bl, false);
   2838         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x14e3c8d48fa25441l, false);
   2839         enforceOrdering(inMinValue, inMaxValue);
   2840         try {
   2841             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
   2842             script.set_gAllocInMinValue(inMinValue);
   2843             script.set_gAllocInMaxValue(inMaxValue);
   2844             script.forEach_testClampUlong2Ulong2Ulong2Ulong2(inValue, out);
   2845             verifyResultsClampUlong2Ulong2Ulong2Ulong2(inValue, inMinValue, inMaxValue, out, false);
   2846         } catch (Exception e) {
   2847             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2Ulong2Ulong2Ulong2: " + e.toString());
   2848         }
   2849         try {
   2850             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
   2851             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2852             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2853             scriptRelaxed.forEach_testClampUlong2Ulong2Ulong2Ulong2(inValue, out);
   2854             verifyResultsClampUlong2Ulong2Ulong2Ulong2(inValue, inMinValue, inMaxValue, out, true);
   2855         } catch (Exception e) {
   2856             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2Ulong2Ulong2Ulong2: " + e.toString());
   2857         }
   2858     }
   2859 
   2860     private void verifyResultsClampUlong2Ulong2Ulong2Ulong2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2861         long[] arrayInValue = new long[INPUTSIZE * 2];
   2862         inValue.copyTo(arrayInValue);
   2863         long[] arrayInMinValue = new long[INPUTSIZE * 2];
   2864         inMinValue.copyTo(arrayInMinValue);
   2865         long[] arrayInMaxValue = new long[INPUTSIZE * 2];
   2866         inMaxValue.copyTo(arrayInMaxValue);
   2867         long[] arrayOut = new long[INPUTSIZE * 2];
   2868         out.copyTo(arrayOut);
   2869         for (int i = 0; i < INPUTSIZE; i++) {
   2870             for (int j = 0; j < 2 ; j++) {
   2871                 // Extract the inputs.
   2872                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   2873                 args.inValue = arrayInValue[i * 2 + j];
   2874                 args.inMinValue = arrayInMinValue[i * 2 + j];
   2875                 args.inMaxValue = arrayInMaxValue[i * 2 + j];
   2876                 // Figure out what the outputs should have been.
   2877                 CoreMathVerifier.computeClamp(args);
   2878                 // Validate the outputs.
   2879                 boolean valid = true;
   2880                 if (args.out != arrayOut[i * 2 + j]) {
   2881                     valid = false;
   2882                 }
   2883                 if (!valid) {
   2884                     StringBuilder message = new StringBuilder();
   2885                     message.append("Input inValue: ");
   2886                     message.append(String.format("0x%x", args.inValue));
   2887                     message.append("\n");
   2888                     message.append("Input inMinValue: ");
   2889                     message.append(String.format("0x%x", args.inMinValue));
   2890                     message.append("\n");
   2891                     message.append("Input inMaxValue: ");
   2892                     message.append(String.format("0x%x", args.inMaxValue));
   2893                     message.append("\n");
   2894                     message.append("Expected output out: ");
   2895                     message.append(String.format("0x%x", args.out));
   2896                     message.append("\n");
   2897                     message.append("Actual   output out: ");
   2898                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   2899                     if (args.out != arrayOut[i * 2 + j]) {
   2900                         message.append(" FAIL");
   2901                     }
   2902                     message.append("\n");
   2903                     assertTrue("Incorrect output for checkClampUlong2Ulong2Ulong2Ulong2" +
   2904                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2905                 }
   2906             }
   2907         }
   2908     }
   2909 
   2910     private void checkClampUlong3Ulong3Ulong3Ulong3() {
   2911         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x722c3c9fbd1e1f75l, false);
   2912         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x20d03c8e4cfc4c8fl, false);
   2913         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x20d03c82de593e95l, false);
   2914         enforceOrdering(inMinValue, inMaxValue);
   2915         try {
   2916             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
   2917             script.set_gAllocInMinValue(inMinValue);
   2918             script.set_gAllocInMaxValue(inMaxValue);
   2919             script.forEach_testClampUlong3Ulong3Ulong3Ulong3(inValue, out);
   2920             verifyResultsClampUlong3Ulong3Ulong3Ulong3(inValue, inMinValue, inMaxValue, out, false);
   2921         } catch (Exception e) {
   2922             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3Ulong3Ulong3Ulong3: " + e.toString());
   2923         }
   2924         try {
   2925             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
   2926             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   2927             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   2928             scriptRelaxed.forEach_testClampUlong3Ulong3Ulong3Ulong3(inValue, out);
   2929             verifyResultsClampUlong3Ulong3Ulong3Ulong3(inValue, inMinValue, inMaxValue, out, true);
   2930         } catch (Exception e) {
   2931             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3Ulong3Ulong3Ulong3: " + e.toString());
   2932         }
   2933     }
   2934 
   2935     private void verifyResultsClampUlong3Ulong3Ulong3Ulong3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   2936         long[] arrayInValue = new long[INPUTSIZE * 4];
   2937         inValue.copyTo(arrayInValue);
   2938         long[] arrayInMinValue = new long[INPUTSIZE * 4];
   2939         inMinValue.copyTo(arrayInMinValue);
   2940         long[] arrayInMaxValue = new long[INPUTSIZE * 4];
   2941         inMaxValue.copyTo(arrayInMaxValue);
   2942         long[] arrayOut = new long[INPUTSIZE * 4];
   2943         out.copyTo(arrayOut);
   2944         for (int i = 0; i < INPUTSIZE; i++) {
   2945             for (int j = 0; j < 3 ; j++) {
   2946                 // Extract the inputs.
   2947                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   2948                 args.inValue = arrayInValue[i * 4 + j];
   2949                 args.inMinValue = arrayInMinValue[i * 4 + j];
   2950                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   2951                 // Figure out what the outputs should have been.
   2952                 CoreMathVerifier.computeClamp(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                     StringBuilder message = new StringBuilder();
   2960                     message.append("Input inValue: ");
   2961                     message.append(String.format("0x%x", args.inValue));
   2962                     message.append("\n");
   2963                     message.append("Input inMinValue: ");
   2964                     message.append(String.format("0x%x", args.inMinValue));
   2965                     message.append("\n");
   2966                     message.append("Input inMaxValue: ");
   2967                     message.append(String.format("0x%x", args.inMaxValue));
   2968                     message.append("\n");
   2969                     message.append("Expected output out: ");
   2970                     message.append(String.format("0x%x", args.out));
   2971                     message.append("\n");
   2972                     message.append("Actual   output out: ");
   2973                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   2974                     if (args.out != arrayOut[i * 4 + j]) {
   2975                         message.append(" FAIL");
   2976                     }
   2977                     message.append("\n");
   2978                     assertTrue("Incorrect output for checkClampUlong3Ulong3Ulong3Ulong3" +
   2979                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   2980                 }
   2981             }
   2982         }
   2983     }
   2984 
   2985     private void checkClampUlong4Ulong4Ulong4Ulong4() {
   2986         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x3b907e27d9a08c51l, false);
   2987         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x2cbcb03c9bb336e3l, false);
   2988         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x2cbcb0312d1028e9l, false);
   2989         enforceOrdering(inMinValue, inMaxValue);
   2990         try {
   2991             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
   2992             script.set_gAllocInMinValue(inMinValue);
   2993             script.set_gAllocInMaxValue(inMaxValue);
   2994             script.forEach_testClampUlong4Ulong4Ulong4Ulong4(inValue, out);
   2995             verifyResultsClampUlong4Ulong4Ulong4Ulong4(inValue, inMinValue, inMaxValue, out, false);
   2996         } catch (Exception e) {
   2997             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4Ulong4Ulong4Ulong4: " + e.toString());
   2998         }
   2999         try {
   3000             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
   3001             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3002             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3003             scriptRelaxed.forEach_testClampUlong4Ulong4Ulong4Ulong4(inValue, out);
   3004             verifyResultsClampUlong4Ulong4Ulong4Ulong4(inValue, inMinValue, inMaxValue, out, true);
   3005         } catch (Exception e) {
   3006             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4Ulong4Ulong4Ulong4: " + e.toString());
   3007         }
   3008     }
   3009 
   3010     private void verifyResultsClampUlong4Ulong4Ulong4Ulong4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3011         long[] arrayInValue = new long[INPUTSIZE * 4];
   3012         inValue.copyTo(arrayInValue);
   3013         long[] arrayInMinValue = new long[INPUTSIZE * 4];
   3014         inMinValue.copyTo(arrayInMinValue);
   3015         long[] arrayInMaxValue = new long[INPUTSIZE * 4];
   3016         inMaxValue.copyTo(arrayInMaxValue);
   3017         long[] arrayOut = new long[INPUTSIZE * 4];
   3018         out.copyTo(arrayOut);
   3019         for (int i = 0; i < INPUTSIZE; i++) {
   3020             for (int j = 0; j < 4 ; j++) {
   3021                 // Extract the inputs.
   3022                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   3023                 args.inValue = arrayInValue[i * 4 + j];
   3024                 args.inMinValue = arrayInMinValue[i * 4 + j];
   3025                 args.inMaxValue = arrayInMaxValue[i * 4 + j];
   3026                 // Figure out what the outputs should have been.
   3027                 CoreMathVerifier.computeClamp(args);
   3028                 // Validate the outputs.
   3029                 boolean valid = true;
   3030                 if (args.out != arrayOut[i * 4 + j]) {
   3031                     valid = false;
   3032                 }
   3033                 if (!valid) {
   3034                     StringBuilder message = new StringBuilder();
   3035                     message.append("Input inValue: ");
   3036                     message.append(String.format("0x%x", args.inValue));
   3037                     message.append("\n");
   3038                     message.append("Input inMinValue: ");
   3039                     message.append(String.format("0x%x", args.inMinValue));
   3040                     message.append("\n");
   3041                     message.append("Input inMaxValue: ");
   3042                     message.append(String.format("0x%x", args.inMaxValue));
   3043                     message.append("\n");
   3044                     message.append("Expected output out: ");
   3045                     message.append(String.format("0x%x", args.out));
   3046                     message.append("\n");
   3047                     message.append("Actual   output out: ");
   3048                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   3049                     if (args.out != arrayOut[i * 4 + j]) {
   3050                         message.append(" FAIL");
   3051                     }
   3052                     message.append("\n");
   3053                     assertTrue("Incorrect output for checkClampUlong4Ulong4Ulong4Ulong4" +
   3054                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3055                 }
   3056             }
   3057         }
   3058     }
   3059 
   3060     private void checkClampChar2CharCharChar2() {
   3061         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd6884bbb7c57a5d1l, false);
   3062         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x3bf8830cc3b7db63l, false);
   3063         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x3bf883015514cd69l, false);
   3064         enforceOrdering(inMinValue, inMaxValue);
   3065         try {
   3066             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
   3067             script.set_gAllocInMinValue(inMinValue);
   3068             script.set_gAllocInMaxValue(inMaxValue);
   3069             script.forEach_testClampChar2CharCharChar2(inValue, out);
   3070             verifyResultsClampChar2CharCharChar2(inValue, inMinValue, inMaxValue, out, false);
   3071         } catch (Exception e) {
   3072             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2CharCharChar2: " + e.toString());
   3073         }
   3074         try {
   3075             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
   3076             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3077             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3078             scriptRelaxed.forEach_testClampChar2CharCharChar2(inValue, out);
   3079             verifyResultsClampChar2CharCharChar2(inValue, inMinValue, inMaxValue, out, true);
   3080         } catch (Exception e) {
   3081             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2CharCharChar2: " + e.toString());
   3082         }
   3083     }
   3084 
   3085     private void verifyResultsClampChar2CharCharChar2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3086         byte[] arrayInValue = new byte[INPUTSIZE * 2];
   3087         inValue.copyTo(arrayInValue);
   3088         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
   3089         inMinValue.copyTo(arrayInMinValue);
   3090         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
   3091         inMaxValue.copyTo(arrayInMaxValue);
   3092         byte[] arrayOut = new byte[INPUTSIZE * 2];
   3093         out.copyTo(arrayOut);
   3094         for (int i = 0; i < INPUTSIZE; i++) {
   3095             for (int j = 0; j < 2 ; j++) {
   3096                 // Extract the inputs.
   3097                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
   3098                 args.inValue = arrayInValue[i * 2 + j];
   3099                 args.inMinValue = arrayInMinValue[i];
   3100                 args.inMaxValue = arrayInMaxValue[i];
   3101                 // Figure out what the outputs should have been.
   3102                 CoreMathVerifier.computeClamp(args);
   3103                 // Validate the outputs.
   3104                 boolean valid = true;
   3105                 if (args.out != arrayOut[i * 2 + j]) {
   3106                     valid = false;
   3107                 }
   3108                 if (!valid) {
   3109                     StringBuilder message = new StringBuilder();
   3110                     message.append("Input inValue: ");
   3111                     message.append(String.format("%d", args.inValue));
   3112                     message.append("\n");
   3113                     message.append("Input inMinValue: ");
   3114                     message.append(String.format("%d", args.inMinValue));
   3115                     message.append("\n");
   3116                     message.append("Input inMaxValue: ");
   3117                     message.append(String.format("%d", args.inMaxValue));
   3118                     message.append("\n");
   3119                     message.append("Expected output out: ");
   3120                     message.append(String.format("%d", args.out));
   3121                     message.append("\n");
   3122                     message.append("Actual   output out: ");
   3123                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   3124                     if (args.out != arrayOut[i * 2 + j]) {
   3125                         message.append(" FAIL");
   3126                     }
   3127                     message.append("\n");
   3128                     assertTrue("Incorrect output for checkClampChar2CharCharChar2" +
   3129                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3130                 }
   3131             }
   3132         }
   3133     }
   3134 
   3135     private void checkClampChar3CharCharChar3() {
   3136         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4aa68c1b65a26ee5l, false);
   3137         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x8b4b9ea0492789dfl, false);
   3138         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x8b4b9e94da847be5l, false);
   3139         enforceOrdering(inMinValue, inMaxValue);
   3140         try {
   3141             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
   3142             script.set_gAllocInMinValue(inMinValue);
   3143             script.set_gAllocInMaxValue(inMaxValue);
   3144             script.forEach_testClampChar3CharCharChar3(inValue, out);
   3145             verifyResultsClampChar3CharCharChar3(inValue, inMinValue, inMaxValue, out, false);
   3146         } catch (Exception e) {
   3147             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3CharCharChar3: " + e.toString());
   3148         }
   3149         try {
   3150             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
   3151             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3152             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3153             scriptRelaxed.forEach_testClampChar3CharCharChar3(inValue, out);
   3154             verifyResultsClampChar3CharCharChar3(inValue, inMinValue, inMaxValue, out, true);
   3155         } catch (Exception e) {
   3156             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3CharCharChar3: " + e.toString());
   3157         }
   3158     }
   3159 
   3160     private void verifyResultsClampChar3CharCharChar3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3161         byte[] arrayInValue = new byte[INPUTSIZE * 4];
   3162         inValue.copyTo(arrayInValue);
   3163         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
   3164         inMinValue.copyTo(arrayInMinValue);
   3165         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
   3166         inMaxValue.copyTo(arrayInMaxValue);
   3167         byte[] arrayOut = new byte[INPUTSIZE * 4];
   3168         out.copyTo(arrayOut);
   3169         for (int i = 0; i < INPUTSIZE; i++) {
   3170             for (int j = 0; j < 3 ; j++) {
   3171                 // Extract the inputs.
   3172                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
   3173                 args.inValue = arrayInValue[i * 4 + j];
   3174                 args.inMinValue = arrayInMinValue[i];
   3175                 args.inMaxValue = arrayInMaxValue[i];
   3176                 // Figure out what the outputs should have been.
   3177                 CoreMathVerifier.computeClamp(args);
   3178                 // Validate the outputs.
   3179                 boolean valid = true;
   3180                 if (args.out != arrayOut[i * 4 + j]) {
   3181                     valid = false;
   3182                 }
   3183                 if (!valid) {
   3184                     StringBuilder message = new StringBuilder();
   3185                     message.append("Input inValue: ");
   3186                     message.append(String.format("%d", args.inValue));
   3187                     message.append("\n");
   3188                     message.append("Input inMinValue: ");
   3189                     message.append(String.format("%d", args.inMinValue));
   3190                     message.append("\n");
   3191                     message.append("Input inMaxValue: ");
   3192                     message.append(String.format("%d", args.inMaxValue));
   3193                     message.append("\n");
   3194                     message.append("Expected output out: ");
   3195                     message.append(String.format("%d", args.out));
   3196                     message.append("\n");
   3197                     message.append("Actual   output out: ");
   3198                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   3199                     if (args.out != arrayOut[i * 4 + j]) {
   3200                         message.append(" FAIL");
   3201                     }
   3202                     message.append("\n");
   3203                     assertTrue("Incorrect output for checkClampChar3CharCharChar3" +
   3204                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3205                 }
   3206             }
   3207         }
   3208     }
   3209 
   3210     private void checkClampChar4CharCharChar4() {
   3211         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xbec4cc7b4eed37f9l, false);
   3212         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xda9eba33ce97385bl, false);
   3213         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xda9eba285ff42a61l, false);
   3214         enforceOrdering(inMinValue, inMaxValue);
   3215         try {
   3216             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
   3217             script.set_gAllocInMinValue(inMinValue);
   3218             script.set_gAllocInMaxValue(inMaxValue);
   3219             script.forEach_testClampChar4CharCharChar4(inValue, out);
   3220             verifyResultsClampChar4CharCharChar4(inValue, inMinValue, inMaxValue, out, false);
   3221         } catch (Exception e) {
   3222             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4CharCharChar4: " + e.toString());
   3223         }
   3224         try {
   3225             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
   3226             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3227             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3228             scriptRelaxed.forEach_testClampChar4CharCharChar4(inValue, out);
   3229             verifyResultsClampChar4CharCharChar4(inValue, inMinValue, inMaxValue, out, true);
   3230         } catch (Exception e) {
   3231             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4CharCharChar4: " + e.toString());
   3232         }
   3233     }
   3234 
   3235     private void verifyResultsClampChar4CharCharChar4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3236         byte[] arrayInValue = new byte[INPUTSIZE * 4];
   3237         inValue.copyTo(arrayInValue);
   3238         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
   3239         inMinValue.copyTo(arrayInMinValue);
   3240         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
   3241         inMaxValue.copyTo(arrayInMaxValue);
   3242         byte[] arrayOut = new byte[INPUTSIZE * 4];
   3243         out.copyTo(arrayOut);
   3244         for (int i = 0; i < INPUTSIZE; i++) {
   3245             for (int j = 0; j < 4 ; j++) {
   3246                 // Extract the inputs.
   3247                 ArgumentsCharCharCharChar args = new ArgumentsCharCharCharChar();
   3248                 args.inValue = arrayInValue[i * 4 + j];
   3249                 args.inMinValue = arrayInMinValue[i];
   3250                 args.inMaxValue = arrayInMaxValue[i];
   3251                 // Figure out what the outputs should have been.
   3252                 CoreMathVerifier.computeClamp(args);
   3253                 // Validate the outputs.
   3254                 boolean valid = true;
   3255                 if (args.out != arrayOut[i * 4 + j]) {
   3256                     valid = false;
   3257                 }
   3258                 if (!valid) {
   3259                     StringBuilder message = new StringBuilder();
   3260                     message.append("Input inValue: ");
   3261                     message.append(String.format("%d", args.inValue));
   3262                     message.append("\n");
   3263                     message.append("Input inMinValue: ");
   3264                     message.append(String.format("%d", args.inMinValue));
   3265                     message.append("\n");
   3266                     message.append("Input inMaxValue: ");
   3267                     message.append(String.format("%d", args.inMaxValue));
   3268                     message.append("\n");
   3269                     message.append("Expected output out: ");
   3270                     message.append(String.format("%d", args.out));
   3271                     message.append("\n");
   3272                     message.append("Actual   output out: ");
   3273                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   3274                     if (args.out != arrayOut[i * 4 + j]) {
   3275                         message.append(" FAIL");
   3276                     }
   3277                     message.append("\n");
   3278                     assertTrue("Incorrect output for checkClampChar4CharCharChar4" +
   3279                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3280                 }
   3281             }
   3282         }
   3283     }
   3284 
   3285     private void checkClampUchar2UcharUcharUchar2() {
   3286         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xafd4a680f02e0d63l, false);
   3287         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x78bbbcb3e9402039l, false);
   3288         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x78bbbca87a9d123fl, false);
   3289         enforceOrdering(inMinValue, inMaxValue);
   3290         try {
   3291             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
   3292             script.set_gAllocInMinValue(inMinValue);
   3293             script.set_gAllocInMaxValue(inMaxValue);
   3294             script.forEach_testClampUchar2UcharUcharUchar2(inValue, out);
   3295             verifyResultsClampUchar2UcharUcharUchar2(inValue, inMinValue, inMaxValue, out, false);
   3296         } catch (Exception e) {
   3297             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2UcharUcharUchar2: " + e.toString());
   3298         }
   3299         try {
   3300             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
   3301             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3302             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3303             scriptRelaxed.forEach_testClampUchar2UcharUcharUchar2(inValue, out);
   3304             verifyResultsClampUchar2UcharUcharUchar2(inValue, inMinValue, inMaxValue, out, true);
   3305         } catch (Exception e) {
   3306             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2UcharUcharUchar2: " + e.toString());
   3307         }
   3308     }
   3309 
   3310     private void verifyResultsClampUchar2UcharUcharUchar2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3311         byte[] arrayInValue = new byte[INPUTSIZE * 2];
   3312         inValue.copyTo(arrayInValue);
   3313         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
   3314         inMinValue.copyTo(arrayInMinValue);
   3315         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
   3316         inMaxValue.copyTo(arrayInMaxValue);
   3317         byte[] arrayOut = new byte[INPUTSIZE * 2];
   3318         out.copyTo(arrayOut);
   3319         for (int i = 0; i < INPUTSIZE; i++) {
   3320             for (int j = 0; j < 2 ; j++) {
   3321                 // Extract the inputs.
   3322                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
   3323                 args.inValue = arrayInValue[i * 2 + j];
   3324                 args.inMinValue = arrayInMinValue[i];
   3325                 args.inMaxValue = arrayInMaxValue[i];
   3326                 // Figure out what the outputs should have been.
   3327                 CoreMathVerifier.computeClamp(args);
   3328                 // Validate the outputs.
   3329                 boolean valid = true;
   3330                 if (args.out != arrayOut[i * 2 + j]) {
   3331                     valid = false;
   3332                 }
   3333                 if (!valid) {
   3334                     StringBuilder message = new StringBuilder();
   3335                     message.append("Input inValue: ");
   3336                     message.append(String.format("0x%x", args.inValue));
   3337                     message.append("\n");
   3338                     message.append("Input inMinValue: ");
   3339                     message.append(String.format("0x%x", args.inMinValue));
   3340                     message.append("\n");
   3341                     message.append("Input inMaxValue: ");
   3342                     message.append(String.format("0x%x", args.inMaxValue));
   3343                     message.append("\n");
   3344                     message.append("Expected output out: ");
   3345                     message.append(String.format("0x%x", args.out));
   3346                     message.append("\n");
   3347                     message.append("Actual   output out: ");
   3348                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   3349                     if (args.out != arrayOut[i * 2 + j]) {
   3350                         message.append(" FAIL");
   3351                     }
   3352                     message.append("\n");
   3353                     assertTrue("Incorrect output for checkClampUchar2UcharUcharUchar2" +
   3354                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3355                 }
   3356             }
   3357         }
   3358     }
   3359 
   3360     private void checkClampUchar3UcharUcharUchar3() {
   3361         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xfedafacc68ea3ae9l, false);
   3362         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8371883e1c6e882bl, false);
   3363         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x83718832adcb7a31l, false);
   3364         enforceOrdering(inMinValue, inMaxValue);
   3365         try {
   3366             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
   3367             script.set_gAllocInMinValue(inMinValue);
   3368             script.set_gAllocInMaxValue(inMaxValue);
   3369             script.forEach_testClampUchar3UcharUcharUchar3(inValue, out);
   3370             verifyResultsClampUchar3UcharUcharUchar3(inValue, inMinValue, inMaxValue, out, false);
   3371         } catch (Exception e) {
   3372             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3UcharUcharUchar3: " + e.toString());
   3373         }
   3374         try {
   3375             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
   3376             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3377             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3378             scriptRelaxed.forEach_testClampUchar3UcharUcharUchar3(inValue, out);
   3379             verifyResultsClampUchar3UcharUcharUchar3(inValue, inMinValue, inMaxValue, out, true);
   3380         } catch (Exception e) {
   3381             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3UcharUcharUchar3: " + e.toString());
   3382         }
   3383     }
   3384 
   3385     private void verifyResultsClampUchar3UcharUcharUchar3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3386         byte[] arrayInValue = new byte[INPUTSIZE * 4];
   3387         inValue.copyTo(arrayInValue);
   3388         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
   3389         inMinValue.copyTo(arrayInMinValue);
   3390         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
   3391         inMaxValue.copyTo(arrayInMaxValue);
   3392         byte[] arrayOut = new byte[INPUTSIZE * 4];
   3393         out.copyTo(arrayOut);
   3394         for (int i = 0; i < INPUTSIZE; i++) {
   3395             for (int j = 0; j < 3 ; j++) {
   3396                 // Extract the inputs.
   3397                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
   3398                 args.inValue = arrayInValue[i * 4 + j];
   3399                 args.inMinValue = arrayInMinValue[i];
   3400                 args.inMaxValue = arrayInMaxValue[i];
   3401                 // Figure out what the outputs should have been.
   3402                 CoreMathVerifier.computeClamp(args);
   3403                 // Validate the outputs.
   3404                 boolean valid = true;
   3405                 if (args.out != arrayOut[i * 4 + j]) {
   3406                     valid = false;
   3407                 }
   3408                 if (!valid) {
   3409                     StringBuilder message = new StringBuilder();
   3410                     message.append("Input inValue: ");
   3411                     message.append(String.format("0x%x", args.inValue));
   3412                     message.append("\n");
   3413                     message.append("Input inMinValue: ");
   3414                     message.append(String.format("0x%x", args.inMinValue));
   3415                     message.append("\n");
   3416                     message.append("Input inMaxValue: ");
   3417                     message.append(String.format("0x%x", args.inMaxValue));
   3418                     message.append("\n");
   3419                     message.append("Expected output out: ");
   3420                     message.append(String.format("0x%x", args.out));
   3421                     message.append("\n");
   3422                     message.append("Actual   output out: ");
   3423                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   3424                     if (args.out != arrayOut[i * 4 + j]) {
   3425                         message.append(" FAIL");
   3426                     }
   3427                     message.append("\n");
   3428                     assertTrue("Incorrect output for checkClampUchar3UcharUcharUchar3" +
   3429                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3430                 }
   3431             }
   3432         }
   3433     }
   3434 
   3435     private void checkClampUchar4UcharUcharUchar4() {
   3436         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x4de14f17e1a6686fl, false);
   3437         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8e2753c84f9cf01dl, false);
   3438         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8e2753bce0f9e223l, false);
   3439         enforceOrdering(inMinValue, inMaxValue);
   3440         try {
   3441             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
   3442             script.set_gAllocInMinValue(inMinValue);
   3443             script.set_gAllocInMaxValue(inMaxValue);
   3444             script.forEach_testClampUchar4UcharUcharUchar4(inValue, out);
   3445             verifyResultsClampUchar4UcharUcharUchar4(inValue, inMinValue, inMaxValue, out, false);
   3446         } catch (Exception e) {
   3447             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4UcharUcharUchar4: " + e.toString());
   3448         }
   3449         try {
   3450             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
   3451             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3452             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3453             scriptRelaxed.forEach_testClampUchar4UcharUcharUchar4(inValue, out);
   3454             verifyResultsClampUchar4UcharUcharUchar4(inValue, inMinValue, inMaxValue, out, true);
   3455         } catch (Exception e) {
   3456             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4UcharUcharUchar4: " + e.toString());
   3457         }
   3458     }
   3459 
   3460     private void verifyResultsClampUchar4UcharUcharUchar4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3461         byte[] arrayInValue = new byte[INPUTSIZE * 4];
   3462         inValue.copyTo(arrayInValue);
   3463         byte[] arrayInMinValue = new byte[INPUTSIZE * 1];
   3464         inMinValue.copyTo(arrayInMinValue);
   3465         byte[] arrayInMaxValue = new byte[INPUTSIZE * 1];
   3466         inMaxValue.copyTo(arrayInMaxValue);
   3467         byte[] arrayOut = new byte[INPUTSIZE * 4];
   3468         out.copyTo(arrayOut);
   3469         for (int i = 0; i < INPUTSIZE; i++) {
   3470             for (int j = 0; j < 4 ; j++) {
   3471                 // Extract the inputs.
   3472                 ArgumentsUcharUcharUcharUchar args = new ArgumentsUcharUcharUcharUchar();
   3473                 args.inValue = arrayInValue[i * 4 + j];
   3474                 args.inMinValue = arrayInMinValue[i];
   3475                 args.inMaxValue = arrayInMaxValue[i];
   3476                 // Figure out what the outputs should have been.
   3477                 CoreMathVerifier.computeClamp(args);
   3478                 // Validate the outputs.
   3479                 boolean valid = true;
   3480                 if (args.out != arrayOut[i * 4 + j]) {
   3481                     valid = false;
   3482                 }
   3483                 if (!valid) {
   3484                     StringBuilder message = new StringBuilder();
   3485                     message.append("Input inValue: ");
   3486                     message.append(String.format("0x%x", args.inValue));
   3487                     message.append("\n");
   3488                     message.append("Input inMinValue: ");
   3489                     message.append(String.format("0x%x", args.inMinValue));
   3490                     message.append("\n");
   3491                     message.append("Input inMaxValue: ");
   3492                     message.append(String.format("0x%x", args.inMaxValue));
   3493                     message.append("\n");
   3494                     message.append("Expected output out: ");
   3495                     message.append(String.format("0x%x", args.out));
   3496                     message.append("\n");
   3497                     message.append("Actual   output out: ");
   3498                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   3499                     if (args.out != arrayOut[i * 4 + j]) {
   3500                         message.append(" FAIL");
   3501                     }
   3502                     message.append("\n");
   3503                     assertTrue("Incorrect output for checkClampUchar4UcharUcharUchar4" +
   3504                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3505                 }
   3506             }
   3507         }
   3508     }
   3509 
   3510     private void checkClampShort2ShortShortShort2() {
   3511         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x89e3627eae2d6a9l, false);
   3512         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x886d6d2ccaca776bl, false);
   3513         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x886d6d215c276971l, false);
   3514         enforceOrdering(inMinValue, inMaxValue);
   3515         try {
   3516             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
   3517             script.set_gAllocInMinValue(inMinValue);
   3518             script.set_gAllocInMaxValue(inMaxValue);
   3519             script.forEach_testClampShort2ShortShortShort2(inValue, out);
   3520             verifyResultsClampShort2ShortShortShort2(inValue, inMinValue, inMaxValue, out, false);
   3521         } catch (Exception e) {
   3522             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2ShortShortShort2: " + e.toString());
   3523         }
   3524         try {
   3525             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
   3526             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3527             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3528             scriptRelaxed.forEach_testClampShort2ShortShortShort2(inValue, out);
   3529             verifyResultsClampShort2ShortShortShort2(inValue, inMinValue, inMaxValue, out, true);
   3530         } catch (Exception e) {
   3531             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2ShortShortShort2: " + e.toString());
   3532         }
   3533     }
   3534 
   3535     private void verifyResultsClampShort2ShortShortShort2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3536         short[] arrayInValue = new short[INPUTSIZE * 2];
   3537         inValue.copyTo(arrayInValue);
   3538         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   3539         inMinValue.copyTo(arrayInMinValue);
   3540         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   3541         inMaxValue.copyTo(arrayInMaxValue);
   3542         short[] arrayOut = new short[INPUTSIZE * 2];
   3543         out.copyTo(arrayOut);
   3544         for (int i = 0; i < INPUTSIZE; i++) {
   3545             for (int j = 0; j < 2 ; j++) {
   3546                 // Extract the inputs.
   3547                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   3548                 args.inValue = arrayInValue[i * 2 + j];
   3549                 args.inMinValue = arrayInMinValue[i];
   3550                 args.inMaxValue = arrayInMaxValue[i];
   3551                 // Figure out what the outputs should have been.
   3552                 CoreMathVerifier.computeClamp(args);
   3553                 // Validate the outputs.
   3554                 boolean valid = true;
   3555                 if (args.out != arrayOut[i * 2 + j]) {
   3556                     valid = false;
   3557                 }
   3558                 if (!valid) {
   3559                     StringBuilder message = new StringBuilder();
   3560                     message.append("Input inValue: ");
   3561                     message.append(String.format("%d", args.inValue));
   3562                     message.append("\n");
   3563                     message.append("Input inMinValue: ");
   3564                     message.append(String.format("%d", args.inMinValue));
   3565                     message.append("\n");
   3566                     message.append("Input inMaxValue: ");
   3567                     message.append(String.format("%d", args.inMaxValue));
   3568                     message.append("\n");
   3569                     message.append("Expected output out: ");
   3570                     message.append(String.format("%d", args.out));
   3571                     message.append("\n");
   3572                     message.append("Actual   output out: ");
   3573                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   3574                     if (args.out != arrayOut[i * 2 + j]) {
   3575                         message.append(" FAIL");
   3576                     }
   3577                     message.append("\n");
   3578                     assertTrue("Incorrect output for checkClampShort2ShortShortShort2" +
   3579                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3580                 }
   3581             }
   3582         }
   3583     }
   3584 
   3585     private void checkClampShort3ShortShortShort3() {
   3586         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x57a48a73639f042fl, false);
   3587         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x932338b6fdf8df5dl, false);
   3588         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x932338ab8f55d163l, false);
   3589         enforceOrdering(inMinValue, inMaxValue);
   3590         try {
   3591             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
   3592             script.set_gAllocInMinValue(inMinValue);
   3593             script.set_gAllocInMaxValue(inMaxValue);
   3594             script.forEach_testClampShort3ShortShortShort3(inValue, out);
   3595             verifyResultsClampShort3ShortShortShort3(inValue, inMinValue, inMaxValue, out, false);
   3596         } catch (Exception e) {
   3597             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3ShortShortShort3: " + e.toString());
   3598         }
   3599         try {
   3600             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
   3601             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3602             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3603             scriptRelaxed.forEach_testClampShort3ShortShortShort3(inValue, out);
   3604             verifyResultsClampShort3ShortShortShort3(inValue, inMinValue, inMaxValue, out, true);
   3605         } catch (Exception e) {
   3606             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3ShortShortShort3: " + e.toString());
   3607         }
   3608     }
   3609 
   3610     private void verifyResultsClampShort3ShortShortShort3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3611         short[] arrayInValue = new short[INPUTSIZE * 4];
   3612         inValue.copyTo(arrayInValue);
   3613         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   3614         inMinValue.copyTo(arrayInMinValue);
   3615         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   3616         inMaxValue.copyTo(arrayInMaxValue);
   3617         short[] arrayOut = new short[INPUTSIZE * 4];
   3618         out.copyTo(arrayOut);
   3619         for (int i = 0; i < INPUTSIZE; i++) {
   3620             for (int j = 0; j < 3 ; j++) {
   3621                 // Extract the inputs.
   3622                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   3623                 args.inValue = arrayInValue[i * 4 + j];
   3624                 args.inMinValue = arrayInMinValue[i];
   3625                 args.inMaxValue = arrayInMaxValue[i];
   3626                 // Figure out what the outputs should have been.
   3627                 CoreMathVerifier.computeClamp(args);
   3628                 // Validate the outputs.
   3629                 boolean valid = true;
   3630                 if (args.out != arrayOut[i * 4 + j]) {
   3631                     valid = false;
   3632                 }
   3633                 if (!valid) {
   3634                     StringBuilder message = new StringBuilder();
   3635                     message.append("Input inValue: ");
   3636                     message.append(String.format("%d", args.inValue));
   3637                     message.append("\n");
   3638                     message.append("Input inMinValue: ");
   3639                     message.append(String.format("%d", args.inMinValue));
   3640                     message.append("\n");
   3641                     message.append("Input inMaxValue: ");
   3642                     message.append(String.format("%d", args.inMaxValue));
   3643                     message.append("\n");
   3644                     message.append("Expected output out: ");
   3645                     message.append(String.format("%d", args.out));
   3646                     message.append("\n");
   3647                     message.append("Actual   output out: ");
   3648                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   3649                     if (args.out != arrayOut[i * 4 + j]) {
   3650                         message.append(" FAIL");
   3651                     }
   3652                     message.append("\n");
   3653                     assertTrue("Incorrect output for checkClampShort3ShortShortShort3" +
   3654                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3655                 }
   3656             }
   3657         }
   3658     }
   3659 
   3660     private void checkClampShort4ShortShortShort4() {
   3661         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xa6aadebedc5b31b5l, false);
   3662         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x9dd904413127474fl, false);
   3663         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x9dd90435c2843955l, false);
   3664         enforceOrdering(inMinValue, inMaxValue);
   3665         try {
   3666             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
   3667             script.set_gAllocInMinValue(inMinValue);
   3668             script.set_gAllocInMaxValue(inMaxValue);
   3669             script.forEach_testClampShort4ShortShortShort4(inValue, out);
   3670             verifyResultsClampShort4ShortShortShort4(inValue, inMinValue, inMaxValue, out, false);
   3671         } catch (Exception e) {
   3672             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4ShortShortShort4: " + e.toString());
   3673         }
   3674         try {
   3675             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
   3676             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3677             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3678             scriptRelaxed.forEach_testClampShort4ShortShortShort4(inValue, out);
   3679             verifyResultsClampShort4ShortShortShort4(inValue, inMinValue, inMaxValue, out, true);
   3680         } catch (Exception e) {
   3681             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4ShortShortShort4: " + e.toString());
   3682         }
   3683     }
   3684 
   3685     private void verifyResultsClampShort4ShortShortShort4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3686         short[] arrayInValue = new short[INPUTSIZE * 4];
   3687         inValue.copyTo(arrayInValue);
   3688         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   3689         inMinValue.copyTo(arrayInMinValue);
   3690         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   3691         inMaxValue.copyTo(arrayInMaxValue);
   3692         short[] arrayOut = new short[INPUTSIZE * 4];
   3693         out.copyTo(arrayOut);
   3694         for (int i = 0; i < INPUTSIZE; i++) {
   3695             for (int j = 0; j < 4 ; j++) {
   3696                 // Extract the inputs.
   3697                 ArgumentsShortShortShortShort args = new ArgumentsShortShortShortShort();
   3698                 args.inValue = arrayInValue[i * 4 + j];
   3699                 args.inMinValue = arrayInMinValue[i];
   3700                 args.inMaxValue = arrayInMaxValue[i];
   3701                 // Figure out what the outputs should have been.
   3702                 CoreMathVerifier.computeClamp(args);
   3703                 // Validate the outputs.
   3704                 boolean valid = true;
   3705                 if (args.out != arrayOut[i * 4 + j]) {
   3706                     valid = false;
   3707                 }
   3708                 if (!valid) {
   3709                     StringBuilder message = new StringBuilder();
   3710                     message.append("Input inValue: ");
   3711                     message.append(String.format("%d", args.inValue));
   3712                     message.append("\n");
   3713                     message.append("Input inMinValue: ");
   3714                     message.append(String.format("%d", args.inMinValue));
   3715                     message.append("\n");
   3716                     message.append("Input inMaxValue: ");
   3717                     message.append(String.format("%d", args.inMaxValue));
   3718                     message.append("\n");
   3719                     message.append("Expected output out: ");
   3720                     message.append(String.format("%d", args.out));
   3721                     message.append("\n");
   3722                     message.append("Actual   output out: ");
   3723                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   3724                     if (args.out != arrayOut[i * 4 + j]) {
   3725                         message.append(" FAIL");
   3726                     }
   3727                     message.append("\n");
   3728                     assertTrue("Incorrect output for checkClampShort4ShortShortShort4" +
   3729                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3730                 }
   3731             }
   3732         }
   3733     }
   3734 
   3735     private void checkClampUshort2UshortUshortUshort2() {
   3736         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2ece6d045621ef07l, false);
   3737         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd88bd79cc7874965l, false);
   3738         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd88bd79158e43b6bl, false);
   3739         enforceOrdering(inMinValue, inMaxValue);
   3740         try {
   3741             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
   3742             script.set_gAllocInMinValue(inMinValue);
   3743             script.set_gAllocInMaxValue(inMaxValue);
   3744             script.forEach_testClampUshort2UshortUshortUshort2(inValue, out);
   3745             verifyResultsClampUshort2UshortUshortUshort2(inValue, inMinValue, inMaxValue, out, false);
   3746         } catch (Exception e) {
   3747             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2UshortUshortUshort2: " + e.toString());
   3748         }
   3749         try {
   3750             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
   3751             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3752             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3753             scriptRelaxed.forEach_testClampUshort2UshortUshortUshort2(inValue, out);
   3754             verifyResultsClampUshort2UshortUshortUshort2(inValue, inMinValue, inMaxValue, out, true);
   3755         } catch (Exception e) {
   3756             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2UshortUshortUshort2: " + e.toString());
   3757         }
   3758     }
   3759 
   3760     private void verifyResultsClampUshort2UshortUshortUshort2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3761         short[] arrayInValue = new short[INPUTSIZE * 2];
   3762         inValue.copyTo(arrayInValue);
   3763         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   3764         inMinValue.copyTo(arrayInMinValue);
   3765         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   3766         inMaxValue.copyTo(arrayInMaxValue);
   3767         short[] arrayOut = new short[INPUTSIZE * 2];
   3768         out.copyTo(arrayOut);
   3769         for (int i = 0; i < INPUTSIZE; i++) {
   3770             for (int j = 0; j < 2 ; j++) {
   3771                 // Extract the inputs.
   3772                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   3773                 args.inValue = arrayInValue[i * 2 + j];
   3774                 args.inMinValue = arrayInMinValue[i];
   3775                 args.inMaxValue = arrayInMaxValue[i];
   3776                 // Figure out what the outputs should have been.
   3777                 CoreMathVerifier.computeClamp(args);
   3778                 // Validate the outputs.
   3779                 boolean valid = true;
   3780                 if (args.out != arrayOut[i * 2 + j]) {
   3781                     valid = false;
   3782                 }
   3783                 if (!valid) {
   3784                     StringBuilder message = new StringBuilder();
   3785                     message.append("Input inValue: ");
   3786                     message.append(String.format("0x%x", args.inValue));
   3787                     message.append("\n");
   3788                     message.append("Input inMinValue: ");
   3789                     message.append(String.format("0x%x", args.inMinValue));
   3790                     message.append("\n");
   3791                     message.append("Input inMaxValue: ");
   3792                     message.append(String.format("0x%x", args.inMaxValue));
   3793                     message.append("\n");
   3794                     message.append("Expected output out: ");
   3795                     message.append(String.format("0x%x", args.out));
   3796                     message.append("\n");
   3797                     message.append("Actual   output out: ");
   3798                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   3799                     if (args.out != arrayOut[i * 2 + j]) {
   3800                         message.append(" FAIL");
   3801                     }
   3802                     message.append("\n");
   3803                     assertTrue("Incorrect output for checkClampUshort2UshortUshortUshort2" +
   3804                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3805                 }
   3806             }
   3807         }
   3808     }
   3809 
   3810     private void checkClampUshort3UshortUshortUshort3() {
   3811         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x393771467c9cd603l, false);
   3812         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xfe016431b3cf1419l, false);
   3813         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xfe016426452c061fl, false);
   3814         enforceOrdering(inMinValue, inMaxValue);
   3815         try {
   3816             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
   3817             script.set_gAllocInMinValue(inMinValue);
   3818             script.set_gAllocInMaxValue(inMaxValue);
   3819             script.forEach_testClampUshort3UshortUshortUshort3(inValue, out);
   3820             verifyResultsClampUshort3UshortUshortUshort3(inValue, inMinValue, inMaxValue, out, false);
   3821         } catch (Exception e) {
   3822             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3UshortUshortUshort3: " + e.toString());
   3823         }
   3824         try {
   3825             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
   3826             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3827             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3828             scriptRelaxed.forEach_testClampUshort3UshortUshortUshort3(inValue, out);
   3829             verifyResultsClampUshort3UshortUshortUshort3(inValue, inMinValue, inMaxValue, out, true);
   3830         } catch (Exception e) {
   3831             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3UshortUshortUshort3: " + e.toString());
   3832         }
   3833     }
   3834 
   3835     private void verifyResultsClampUshort3UshortUshortUshort3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3836         short[] arrayInValue = new short[INPUTSIZE * 4];
   3837         inValue.copyTo(arrayInValue);
   3838         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   3839         inMinValue.copyTo(arrayInMinValue);
   3840         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   3841         inMaxValue.copyTo(arrayInMaxValue);
   3842         short[] arrayOut = new short[INPUTSIZE * 4];
   3843         out.copyTo(arrayOut);
   3844         for (int i = 0; i < INPUTSIZE; i++) {
   3845             for (int j = 0; j < 3 ; j++) {
   3846                 // Extract the inputs.
   3847                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   3848                 args.inValue = arrayInValue[i * 4 + j];
   3849                 args.inMinValue = arrayInMinValue[i];
   3850                 args.inMaxValue = arrayInMaxValue[i];
   3851                 // Figure out what the outputs should have been.
   3852                 CoreMathVerifier.computeClamp(args);
   3853                 // Validate the outputs.
   3854                 boolean valid = true;
   3855                 if (args.out != arrayOut[i * 4 + j]) {
   3856                     valid = false;
   3857                 }
   3858                 if (!valid) {
   3859                     StringBuilder message = new StringBuilder();
   3860                     message.append("Input inValue: ");
   3861                     message.append(String.format("0x%x", args.inValue));
   3862                     message.append("\n");
   3863                     message.append("Input inMinValue: ");
   3864                     message.append(String.format("0x%x", args.inMinValue));
   3865                     message.append("\n");
   3866                     message.append("Input inMaxValue: ");
   3867                     message.append(String.format("0x%x", args.inMaxValue));
   3868                     message.append("\n");
   3869                     message.append("Expected output out: ");
   3870                     message.append(String.format("0x%x", args.out));
   3871                     message.append("\n");
   3872                     message.append("Actual   output out: ");
   3873                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   3874                     if (args.out != arrayOut[i * 4 + j]) {
   3875                         message.append(" FAIL");
   3876                     }
   3877                     message.append("\n");
   3878                     assertTrue("Incorrect output for checkClampUshort3UshortUshortUshort3" +
   3879                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3880                 }
   3881             }
   3882         }
   3883     }
   3884 
   3885     private void checkClampUshort4UshortUshortUshort4() {
   3886         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x43a07588a317bcffl, false);
   3887         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x2376f0c6a016decdl, false);
   3888         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x2376f0bb3173d0d3l, false);
   3889         enforceOrdering(inMinValue, inMaxValue);
   3890         try {
   3891             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
   3892             script.set_gAllocInMinValue(inMinValue);
   3893             script.set_gAllocInMaxValue(inMaxValue);
   3894             script.forEach_testClampUshort4UshortUshortUshort4(inValue, out);
   3895             verifyResultsClampUshort4UshortUshortUshort4(inValue, inMinValue, inMaxValue, out, false);
   3896         } catch (Exception e) {
   3897             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4UshortUshortUshort4: " + e.toString());
   3898         }
   3899         try {
   3900             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
   3901             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3902             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3903             scriptRelaxed.forEach_testClampUshort4UshortUshortUshort4(inValue, out);
   3904             verifyResultsClampUshort4UshortUshortUshort4(inValue, inMinValue, inMaxValue, out, true);
   3905         } catch (Exception e) {
   3906             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4UshortUshortUshort4: " + e.toString());
   3907         }
   3908     }
   3909 
   3910     private void verifyResultsClampUshort4UshortUshortUshort4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3911         short[] arrayInValue = new short[INPUTSIZE * 4];
   3912         inValue.copyTo(arrayInValue);
   3913         short[] arrayInMinValue = new short[INPUTSIZE * 1];
   3914         inMinValue.copyTo(arrayInMinValue);
   3915         short[] arrayInMaxValue = new short[INPUTSIZE * 1];
   3916         inMaxValue.copyTo(arrayInMaxValue);
   3917         short[] arrayOut = new short[INPUTSIZE * 4];
   3918         out.copyTo(arrayOut);
   3919         for (int i = 0; i < INPUTSIZE; i++) {
   3920             for (int j = 0; j < 4 ; j++) {
   3921                 // Extract the inputs.
   3922                 ArgumentsUshortUshortUshortUshort args = new ArgumentsUshortUshortUshortUshort();
   3923                 args.inValue = arrayInValue[i * 4 + j];
   3924                 args.inMinValue = arrayInMinValue[i];
   3925                 args.inMaxValue = arrayInMaxValue[i];
   3926                 // Figure out what the outputs should have been.
   3927                 CoreMathVerifier.computeClamp(args);
   3928                 // Validate the outputs.
   3929                 boolean valid = true;
   3930                 if (args.out != arrayOut[i * 4 + j]) {
   3931                     valid = false;
   3932                 }
   3933                 if (!valid) {
   3934                     StringBuilder message = new StringBuilder();
   3935                     message.append("Input inValue: ");
   3936                     message.append(String.format("0x%x", args.inValue));
   3937                     message.append("\n");
   3938                     message.append("Input inMinValue: ");
   3939                     message.append(String.format("0x%x", args.inMinValue));
   3940                     message.append("\n");
   3941                     message.append("Input inMaxValue: ");
   3942                     message.append(String.format("0x%x", args.inMaxValue));
   3943                     message.append("\n");
   3944                     message.append("Expected output out: ");
   3945                     message.append(String.format("0x%x", args.out));
   3946                     message.append("\n");
   3947                     message.append("Actual   output out: ");
   3948                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   3949                     if (args.out != arrayOut[i * 4 + j]) {
   3950                         message.append(" FAIL");
   3951                     }
   3952                     message.append("\n");
   3953                     assertTrue("Incorrect output for checkClampUshort4UshortUshortUshort4" +
   3954                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   3955                 }
   3956             }
   3957         }
   3958     }
   3959 
   3960     private void checkClampInt2IntIntInt2() {
   3961         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xbb55c0997906d1dbl, false);
   3962         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x69776e80fba24121l, false);
   3963         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x69776e758cff3327l, false);
   3964         enforceOrdering(inMinValue, inMaxValue);
   3965         try {
   3966             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
   3967             script.set_gAllocInMinValue(inMinValue);
   3968             script.set_gAllocInMaxValue(inMaxValue);
   3969             script.forEach_testClampInt2IntIntInt2(inValue, out);
   3970             verifyResultsClampInt2IntIntInt2(inValue, inMinValue, inMaxValue, out, false);
   3971         } catch (Exception e) {
   3972             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2IntIntInt2: " + e.toString());
   3973         }
   3974         try {
   3975             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
   3976             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   3977             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   3978             scriptRelaxed.forEach_testClampInt2IntIntInt2(inValue, out);
   3979             verifyResultsClampInt2IntIntInt2(inValue, inMinValue, inMaxValue, out, true);
   3980         } catch (Exception e) {
   3981             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2IntIntInt2: " + e.toString());
   3982         }
   3983     }
   3984 
   3985     private void verifyResultsClampInt2IntIntInt2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   3986         int[] arrayInValue = new int[INPUTSIZE * 2];
   3987         inValue.copyTo(arrayInValue);
   3988         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   3989         inMinValue.copyTo(arrayInMinValue);
   3990         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   3991         inMaxValue.copyTo(arrayInMaxValue);
   3992         int[] arrayOut = new int[INPUTSIZE * 2];
   3993         out.copyTo(arrayOut);
   3994         for (int i = 0; i < INPUTSIZE; i++) {
   3995             for (int j = 0; j < 2 ; j++) {
   3996                 // Extract the inputs.
   3997                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   3998                 args.inValue = arrayInValue[i * 2 + j];
   3999                 args.inMinValue = arrayInMinValue[i];
   4000                 args.inMaxValue = arrayInMaxValue[i];
   4001                 // Figure out what the outputs should have been.
   4002                 CoreMathVerifier.computeClamp(args);
   4003                 // Validate the outputs.
   4004                 boolean valid = true;
   4005                 if (args.out != arrayOut[i * 2 + j]) {
   4006                     valid = false;
   4007                 }
   4008                 if (!valid) {
   4009                     StringBuilder message = new StringBuilder();
   4010                     message.append("Input inValue: ");
   4011                     message.append(String.format("%d", args.inValue));
   4012                     message.append("\n");
   4013                     message.append("Input inMinValue: ");
   4014                     message.append(String.format("%d", args.inMinValue));
   4015                     message.append("\n");
   4016                     message.append("Input inMaxValue: ");
   4017                     message.append(String.format("%d", args.inMaxValue));
   4018                     message.append("\n");
   4019                     message.append("Expected output out: ");
   4020                     message.append(String.format("%d", args.out));
   4021                     message.append("\n");
   4022                     message.append("Actual   output out: ");
   4023                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   4024                     if (args.out != arrayOut[i * 2 + j]) {
   4025                         message.append(" FAIL");
   4026                     }
   4027                     message.append("\n");
   4028                     assertTrue("Incorrect output for checkClampInt2IntIntInt2" +
   4029                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4030                 }
   4031             }
   4032         }
   4033     }
   4034 
   4035     private void checkClampInt3IntIntInt3() {
   4036         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x3af8924ab5370be9l, false);
   4037         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xdde27628f1a08b2bl, false);
   4038         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xdde2761d82fd7d31l, false);
   4039         enforceOrdering(inMinValue, inMaxValue);
   4040         try {
   4041             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
   4042             script.set_gAllocInMinValue(inMinValue);
   4043             script.set_gAllocInMaxValue(inMaxValue);
   4044             script.forEach_testClampInt3IntIntInt3(inValue, out);
   4045             verifyResultsClampInt3IntIntInt3(inValue, inMinValue, inMaxValue, out, false);
   4046         } catch (Exception e) {
   4047             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3IntIntInt3: " + e.toString());
   4048         }
   4049         try {
   4050             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
   4051             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4052             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4053             scriptRelaxed.forEach_testClampInt3IntIntInt3(inValue, out);
   4054             verifyResultsClampInt3IntIntInt3(inValue, inMinValue, inMaxValue, out, true);
   4055         } catch (Exception e) {
   4056             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3IntIntInt3: " + e.toString());
   4057         }
   4058     }
   4059 
   4060     private void verifyResultsClampInt3IntIntInt3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4061         int[] arrayInValue = new int[INPUTSIZE * 4];
   4062         inValue.copyTo(arrayInValue);
   4063         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   4064         inMinValue.copyTo(arrayInMinValue);
   4065         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   4066         inMaxValue.copyTo(arrayInMaxValue);
   4067         int[] arrayOut = new int[INPUTSIZE * 4];
   4068         out.copyTo(arrayOut);
   4069         for (int i = 0; i < INPUTSIZE; i++) {
   4070             for (int j = 0; j < 3 ; j++) {
   4071                 // Extract the inputs.
   4072                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   4073                 args.inValue = arrayInValue[i * 4 + j];
   4074                 args.inMinValue = arrayInMinValue[i];
   4075                 args.inMaxValue = arrayInMaxValue[i];
   4076                 // Figure out what the outputs should have been.
   4077                 CoreMathVerifier.computeClamp(args);
   4078                 // Validate the outputs.
   4079                 boolean valid = true;
   4080                 if (args.out != arrayOut[i * 4 + j]) {
   4081                     valid = false;
   4082                 }
   4083                 if (!valid) {
   4084                     StringBuilder message = new StringBuilder();
   4085                     message.append("Input inValue: ");
   4086                     message.append(String.format("%d", args.inValue));
   4087                     message.append("\n");
   4088                     message.append("Input inMinValue: ");
   4089                     message.append(String.format("%d", args.inMinValue));
   4090                     message.append("\n");
   4091                     message.append("Input inMaxValue: ");
   4092                     message.append(String.format("%d", args.inMaxValue));
   4093                     message.append("\n");
   4094                     message.append("Expected output out: ");
   4095                     message.append(String.format("%d", args.out));
   4096                     message.append("\n");
   4097                     message.append("Actual   output out: ");
   4098                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   4099                     if (args.out != arrayOut[i * 4 + j]) {
   4100                         message.append(" FAIL");
   4101                     }
   4102                     message.append("\n");
   4103                     assertTrue("Incorrect output for checkClampInt3IntIntInt3" +
   4104                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4105                 }
   4106             }
   4107         }
   4108     }
   4109 
   4110     private void checkClampInt4IntIntInt4() {
   4111         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xba9b63fbf16745f7l, false);
   4112         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x524d7dd0e79ed535l, false);
   4113         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x524d7dc578fbc73bl, false);
   4114         enforceOrdering(inMinValue, inMaxValue);
   4115         try {
   4116             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
   4117             script.set_gAllocInMinValue(inMinValue);
   4118             script.set_gAllocInMaxValue(inMaxValue);
   4119             script.forEach_testClampInt4IntIntInt4(inValue, out);
   4120             verifyResultsClampInt4IntIntInt4(inValue, inMinValue, inMaxValue, out, false);
   4121         } catch (Exception e) {
   4122             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4IntIntInt4: " + e.toString());
   4123         }
   4124         try {
   4125             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
   4126             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4127             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4128             scriptRelaxed.forEach_testClampInt4IntIntInt4(inValue, out);
   4129             verifyResultsClampInt4IntIntInt4(inValue, inMinValue, inMaxValue, out, true);
   4130         } catch (Exception e) {
   4131             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4IntIntInt4: " + e.toString());
   4132         }
   4133     }
   4134 
   4135     private void verifyResultsClampInt4IntIntInt4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4136         int[] arrayInValue = new int[INPUTSIZE * 4];
   4137         inValue.copyTo(arrayInValue);
   4138         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   4139         inMinValue.copyTo(arrayInMinValue);
   4140         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   4141         inMaxValue.copyTo(arrayInMaxValue);
   4142         int[] arrayOut = new int[INPUTSIZE * 4];
   4143         out.copyTo(arrayOut);
   4144         for (int i = 0; i < INPUTSIZE; i++) {
   4145             for (int j = 0; j < 4 ; j++) {
   4146                 // Extract the inputs.
   4147                 ArgumentsIntIntIntInt args = new ArgumentsIntIntIntInt();
   4148                 args.inValue = arrayInValue[i * 4 + j];
   4149                 args.inMinValue = arrayInMinValue[i];
   4150                 args.inMaxValue = arrayInMaxValue[i];
   4151                 // Figure out what the outputs should have been.
   4152                 CoreMathVerifier.computeClamp(args);
   4153                 // Validate the outputs.
   4154                 boolean valid = true;
   4155                 if (args.out != arrayOut[i * 4 + j]) {
   4156                     valid = false;
   4157                 }
   4158                 if (!valid) {
   4159                     StringBuilder message = new StringBuilder();
   4160                     message.append("Input inValue: ");
   4161                     message.append(String.format("%d", args.inValue));
   4162                     message.append("\n");
   4163                     message.append("Input inMinValue: ");
   4164                     message.append(String.format("%d", args.inMinValue));
   4165                     message.append("\n");
   4166                     message.append("Input inMaxValue: ");
   4167                     message.append(String.format("%d", args.inMaxValue));
   4168                     message.append("\n");
   4169                     message.append("Expected output out: ");
   4170                     message.append(String.format("%d", args.out));
   4171                     message.append("\n");
   4172                     message.append("Actual   output out: ");
   4173                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   4174                     if (args.out != arrayOut[i * 4 + j]) {
   4175                         message.append(" FAIL");
   4176                     }
   4177                     message.append("\n");
   4178                     assertTrue("Incorrect output for checkClampInt4IntIntInt4" +
   4179                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4180                 }
   4181             }
   4182         }
   4183     }
   4184 
   4185     private void checkClampUint2UintUintUint2() {
   4186         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x4fd098dd770d5a51l, false);
   4187         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x6de3f327c2a180e3l, false);
   4188         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x6de3f31c53fe72e9l, false);
   4189         enforceOrdering(inMinValue, inMaxValue);
   4190         try {
   4191             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
   4192             script.set_gAllocInMinValue(inMinValue);
   4193             script.set_gAllocInMaxValue(inMaxValue);
   4194             script.forEach_testClampUint2UintUintUint2(inValue, out);
   4195             verifyResultsClampUint2UintUintUint2(inValue, inMinValue, inMaxValue, out, false);
   4196         } catch (Exception e) {
   4197             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2UintUintUint2: " + e.toString());
   4198         }
   4199         try {
   4200             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
   4201             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4202             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4203             scriptRelaxed.forEach_testClampUint2UintUintUint2(inValue, out);
   4204             verifyResultsClampUint2UintUintUint2(inValue, inMinValue, inMaxValue, out, true);
   4205         } catch (Exception e) {
   4206             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2UintUintUint2: " + e.toString());
   4207         }
   4208     }
   4209 
   4210     private void verifyResultsClampUint2UintUintUint2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4211         int[] arrayInValue = new int[INPUTSIZE * 2];
   4212         inValue.copyTo(arrayInValue);
   4213         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   4214         inMinValue.copyTo(arrayInMinValue);
   4215         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   4216         inMaxValue.copyTo(arrayInMaxValue);
   4217         int[] arrayOut = new int[INPUTSIZE * 2];
   4218         out.copyTo(arrayOut);
   4219         for (int i = 0; i < INPUTSIZE; i++) {
   4220             for (int j = 0; j < 2 ; j++) {
   4221                 // Extract the inputs.
   4222                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   4223                 args.inValue = arrayInValue[i * 2 + j];
   4224                 args.inMinValue = arrayInMinValue[i];
   4225                 args.inMaxValue = arrayInMaxValue[i];
   4226                 // Figure out what the outputs should have been.
   4227                 CoreMathVerifier.computeClamp(args);
   4228                 // Validate the outputs.
   4229                 boolean valid = true;
   4230                 if (args.out != arrayOut[i * 2 + j]) {
   4231                     valid = false;
   4232                 }
   4233                 if (!valid) {
   4234                     StringBuilder message = new StringBuilder();
   4235                     message.append("Input inValue: ");
   4236                     message.append(String.format("0x%x", args.inValue));
   4237                     message.append("\n");
   4238                     message.append("Input inMinValue: ");
   4239                     message.append(String.format("0x%x", args.inMinValue));
   4240                     message.append("\n");
   4241                     message.append("Input inMaxValue: ");
   4242                     message.append(String.format("0x%x", args.inMaxValue));
   4243                     message.append("\n");
   4244                     message.append("Expected output out: ");
   4245                     message.append(String.format("0x%x", args.out));
   4246                     message.append("\n");
   4247                     message.append("Actual   output out: ");
   4248                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   4249                     if (args.out != arrayOut[i * 2 + j]) {
   4250                         message.append(" FAIL");
   4251                     }
   4252                     message.append("\n");
   4253                     assertTrue("Incorrect output for checkClampUint2UintUintUint2" +
   4254                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4255                 }
   4256             }
   4257         }
   4258     }
   4259 
   4260     private void checkClampUint3UintUintUint3() {
   4261         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xc3eed93d60582365l, false);
   4262         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xbd370ebb48112f5fl, false);
   4263         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xbd370eafd96e2165l, false);
   4264         enforceOrdering(inMinValue, inMaxValue);
   4265         try {
   4266             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
   4267             script.set_gAllocInMinValue(inMinValue);
   4268             script.set_gAllocInMaxValue(inMaxValue);
   4269             script.forEach_testClampUint3UintUintUint3(inValue, out);
   4270             verifyResultsClampUint3UintUintUint3(inValue, inMinValue, inMaxValue, out, false);
   4271         } catch (Exception e) {
   4272             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3UintUintUint3: " + e.toString());
   4273         }
   4274         try {
   4275             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
   4276             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4277             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4278             scriptRelaxed.forEach_testClampUint3UintUintUint3(inValue, out);
   4279             verifyResultsClampUint3UintUintUint3(inValue, inMinValue, inMaxValue, out, true);
   4280         } catch (Exception e) {
   4281             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3UintUintUint3: " + e.toString());
   4282         }
   4283     }
   4284 
   4285     private void verifyResultsClampUint3UintUintUint3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4286         int[] arrayInValue = new int[INPUTSIZE * 4];
   4287         inValue.copyTo(arrayInValue);
   4288         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   4289         inMinValue.copyTo(arrayInMinValue);
   4290         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   4291         inMaxValue.copyTo(arrayInMaxValue);
   4292         int[] arrayOut = new int[INPUTSIZE * 4];
   4293         out.copyTo(arrayOut);
   4294         for (int i = 0; i < INPUTSIZE; i++) {
   4295             for (int j = 0; j < 3 ; j++) {
   4296                 // Extract the inputs.
   4297                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   4298                 args.inValue = arrayInValue[i * 4 + j];
   4299                 args.inMinValue = arrayInMinValue[i];
   4300                 args.inMaxValue = arrayInMaxValue[i];
   4301                 // Figure out what the outputs should have been.
   4302                 CoreMathVerifier.computeClamp(args);
   4303                 // Validate the outputs.
   4304                 boolean valid = true;
   4305                 if (args.out != arrayOut[i * 4 + j]) {
   4306                     valid = false;
   4307                 }
   4308                 if (!valid) {
   4309                     StringBuilder message = new StringBuilder();
   4310                     message.append("Input inValue: ");
   4311                     message.append(String.format("0x%x", args.inValue));
   4312                     message.append("\n");
   4313                     message.append("Input inMinValue: ");
   4314                     message.append(String.format("0x%x", args.inMinValue));
   4315                     message.append("\n");
   4316                     message.append("Input inMaxValue: ");
   4317                     message.append(String.format("0x%x", args.inMaxValue));
   4318                     message.append("\n");
   4319                     message.append("Expected output out: ");
   4320                     message.append(String.format("0x%x", args.out));
   4321                     message.append("\n");
   4322                     message.append("Actual   output out: ");
   4323                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   4324                     if (args.out != arrayOut[i * 4 + j]) {
   4325                         message.append(" FAIL");
   4326                     }
   4327                     message.append("\n");
   4328                     assertTrue("Incorrect output for checkClampUint3UintUintUint3" +
   4329                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4330                 }
   4331             }
   4332         }
   4333     }
   4334 
   4335     private void checkClampUint4UintUintUint4() {
   4336         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x380d199d49a2ec79l, false);
   4337         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xc8a2a4ecd80dddbl, false);
   4338         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xc8a2a435eddcfe1l, false);
   4339         enforceOrdering(inMinValue, inMaxValue);
   4340         try {
   4341             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
   4342             script.set_gAllocInMinValue(inMinValue);
   4343             script.set_gAllocInMaxValue(inMaxValue);
   4344             script.forEach_testClampUint4UintUintUint4(inValue, out);
   4345             verifyResultsClampUint4UintUintUint4(inValue, inMinValue, inMaxValue, out, false);
   4346         } catch (Exception e) {
   4347             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4UintUintUint4: " + e.toString());
   4348         }
   4349         try {
   4350             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
   4351             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4352             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4353             scriptRelaxed.forEach_testClampUint4UintUintUint4(inValue, out);
   4354             verifyResultsClampUint4UintUintUint4(inValue, inMinValue, inMaxValue, out, true);
   4355         } catch (Exception e) {
   4356             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4UintUintUint4: " + e.toString());
   4357         }
   4358     }
   4359 
   4360     private void verifyResultsClampUint4UintUintUint4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4361         int[] arrayInValue = new int[INPUTSIZE * 4];
   4362         inValue.copyTo(arrayInValue);
   4363         int[] arrayInMinValue = new int[INPUTSIZE * 1];
   4364         inMinValue.copyTo(arrayInMinValue);
   4365         int[] arrayInMaxValue = new int[INPUTSIZE * 1];
   4366         inMaxValue.copyTo(arrayInMaxValue);
   4367         int[] arrayOut = new int[INPUTSIZE * 4];
   4368         out.copyTo(arrayOut);
   4369         for (int i = 0; i < INPUTSIZE; i++) {
   4370             for (int j = 0; j < 4 ; j++) {
   4371                 // Extract the inputs.
   4372                 ArgumentsUintUintUintUint args = new ArgumentsUintUintUintUint();
   4373                 args.inValue = arrayInValue[i * 4 + j];
   4374                 args.inMinValue = arrayInMinValue[i];
   4375                 args.inMaxValue = arrayInMaxValue[i];
   4376                 // Figure out what the outputs should have been.
   4377                 CoreMathVerifier.computeClamp(args);
   4378                 // Validate the outputs.
   4379                 boolean valid = true;
   4380                 if (args.out != arrayOut[i * 4 + j]) {
   4381                     valid = false;
   4382                 }
   4383                 if (!valid) {
   4384                     StringBuilder message = new StringBuilder();
   4385                     message.append("Input inValue: ");
   4386                     message.append(String.format("0x%x", args.inValue));
   4387                     message.append("\n");
   4388                     message.append("Input inMinValue: ");
   4389                     message.append(String.format("0x%x", args.inMinValue));
   4390                     message.append("\n");
   4391                     message.append("Input inMaxValue: ");
   4392                     message.append(String.format("0x%x", args.inMaxValue));
   4393                     message.append("\n");
   4394                     message.append("Expected output out: ");
   4395                     message.append(String.format("0x%x", args.out));
   4396                     message.append("\n");
   4397                     message.append("Actual   output out: ");
   4398                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   4399                     if (args.out != arrayOut[i * 4 + j]) {
   4400                         message.append(" FAIL");
   4401                     }
   4402                     message.append("\n");
   4403                     assertTrue("Incorrect output for checkClampUint4UintUintUint4" +
   4404                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4405                 }
   4406             }
   4407         }
   4408     }
   4409 
   4410     private void checkClampLong2LongLongLong2() {
   4411         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x19353a9f7c535bb5l, false);
   4412         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xee8dc7f38f83654fl, false);
   4413         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xee8dc7e820e05755l, false);
   4414         enforceOrdering(inMinValue, inMaxValue);
   4415         try {
   4416             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
   4417             script.set_gAllocInMinValue(inMinValue);
   4418             script.set_gAllocInMaxValue(inMaxValue);
   4419             script.forEach_testClampLong2LongLongLong2(inValue, out);
   4420             verifyResultsClampLong2LongLongLong2(inValue, inMinValue, inMaxValue, out, false);
   4421         } catch (Exception e) {
   4422             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2LongLongLong2: " + e.toString());
   4423         }
   4424         try {
   4425             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
   4426             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4427             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4428             scriptRelaxed.forEach_testClampLong2LongLongLong2(inValue, out);
   4429             verifyResultsClampLong2LongLongLong2(inValue, inMinValue, inMaxValue, out, true);
   4430         } catch (Exception e) {
   4431             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2LongLongLong2: " + e.toString());
   4432         }
   4433     }
   4434 
   4435     private void verifyResultsClampLong2LongLongLong2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4436         long[] arrayInValue = new long[INPUTSIZE * 2];
   4437         inValue.copyTo(arrayInValue);
   4438         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   4439         inMinValue.copyTo(arrayInMinValue);
   4440         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   4441         inMaxValue.copyTo(arrayInMaxValue);
   4442         long[] arrayOut = new long[INPUTSIZE * 2];
   4443         out.copyTo(arrayOut);
   4444         for (int i = 0; i < INPUTSIZE; i++) {
   4445             for (int j = 0; j < 2 ; j++) {
   4446                 // Extract the inputs.
   4447                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   4448                 args.inValue = arrayInValue[i * 2 + j];
   4449                 args.inMinValue = arrayInMinValue[i];
   4450                 args.inMaxValue = arrayInMaxValue[i];
   4451                 // Figure out what the outputs should have been.
   4452                 CoreMathVerifier.computeClamp(args);
   4453                 // Validate the outputs.
   4454                 boolean valid = true;
   4455                 if (args.out != arrayOut[i * 2 + j]) {
   4456                     valid = false;
   4457                 }
   4458                 if (!valid) {
   4459                     StringBuilder message = new StringBuilder();
   4460                     message.append("Input inValue: ");
   4461                     message.append(String.format("%d", args.inValue));
   4462                     message.append("\n");
   4463                     message.append("Input inMinValue: ");
   4464                     message.append(String.format("%d", args.inMinValue));
   4465                     message.append("\n");
   4466                     message.append("Input inMaxValue: ");
   4467                     message.append(String.format("%d", args.inMaxValue));
   4468                     message.append("\n");
   4469                     message.append("Expected output out: ");
   4470                     message.append(String.format("%d", args.out));
   4471                     message.append("\n");
   4472                     message.append("Actual   output out: ");
   4473                     message.append(String.format("%d", arrayOut[i * 2 + j]));
   4474                     if (args.out != arrayOut[i * 2 + j]) {
   4475                         message.append(" FAIL");
   4476                     }
   4477                     message.append("\n");
   4478                     assertTrue("Incorrect output for checkClampLong2LongLongLong2" +
   4479                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4480                 }
   4481             }
   4482         }
   4483     }
   4484 
   4485     private void checkClampLong3LongLongLong3() {
   4486         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x8d537aff659e24c9l, false);
   4487         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x3de0e38714f313cbl, false);
   4488         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x3de0e37ba65005d1l, false);
   4489         enforceOrdering(inMinValue, inMaxValue);
   4490         try {
   4491             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
   4492             script.set_gAllocInMinValue(inMinValue);
   4493             script.set_gAllocInMaxValue(inMaxValue);
   4494             script.forEach_testClampLong3LongLongLong3(inValue, out);
   4495             verifyResultsClampLong3LongLongLong3(inValue, inMinValue, inMaxValue, out, false);
   4496         } catch (Exception e) {
   4497             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3LongLongLong3: " + e.toString());
   4498         }
   4499         try {
   4500             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
   4501             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4502             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4503             scriptRelaxed.forEach_testClampLong3LongLongLong3(inValue, out);
   4504             verifyResultsClampLong3LongLongLong3(inValue, inMinValue, inMaxValue, out, true);
   4505         } catch (Exception e) {
   4506             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3LongLongLong3: " + e.toString());
   4507         }
   4508     }
   4509 
   4510     private void verifyResultsClampLong3LongLongLong3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4511         long[] arrayInValue = new long[INPUTSIZE * 4];
   4512         inValue.copyTo(arrayInValue);
   4513         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   4514         inMinValue.copyTo(arrayInMinValue);
   4515         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   4516         inMaxValue.copyTo(arrayInMaxValue);
   4517         long[] arrayOut = new long[INPUTSIZE * 4];
   4518         out.copyTo(arrayOut);
   4519         for (int i = 0; i < INPUTSIZE; i++) {
   4520             for (int j = 0; j < 3 ; j++) {
   4521                 // Extract the inputs.
   4522                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   4523                 args.inValue = arrayInValue[i * 4 + j];
   4524                 args.inMinValue = arrayInMinValue[i];
   4525                 args.inMaxValue = arrayInMaxValue[i];
   4526                 // Figure out what the outputs should have been.
   4527                 CoreMathVerifier.computeClamp(args);
   4528                 // Validate the outputs.
   4529                 boolean valid = true;
   4530                 if (args.out != arrayOut[i * 4 + j]) {
   4531                     valid = false;
   4532                 }
   4533                 if (!valid) {
   4534                     StringBuilder message = new StringBuilder();
   4535                     message.append("Input inValue: ");
   4536                     message.append(String.format("%d", args.inValue));
   4537                     message.append("\n");
   4538                     message.append("Input inMinValue: ");
   4539                     message.append(String.format("%d", args.inMinValue));
   4540                     message.append("\n");
   4541                     message.append("Input inMaxValue: ");
   4542                     message.append(String.format("%d", args.inMaxValue));
   4543                     message.append("\n");
   4544                     message.append("Expected output out: ");
   4545                     message.append(String.format("%d", args.out));
   4546                     message.append("\n");
   4547                     message.append("Actual   output out: ");
   4548                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   4549                     if (args.out != arrayOut[i * 4 + j]) {
   4550                         message.append(" FAIL");
   4551                     }
   4552                     message.append("\n");
   4553                     assertTrue("Incorrect output for checkClampLong3LongLongLong3" +
   4554                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4555                 }
   4556             }
   4557         }
   4558     }
   4559 
   4560     private void checkClampLong4LongLongLong4() {
   4561         Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x171bb5f4ee8edddl, false);
   4562         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x8d33ff1a9a62c247l, false);
   4563         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x8d33ff0f2bbfb44dl, false);
   4564         enforceOrdering(inMinValue, inMaxValue);
   4565         try {
   4566             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
   4567             script.set_gAllocInMinValue(inMinValue);
   4568             script.set_gAllocInMaxValue(inMaxValue);
   4569             script.forEach_testClampLong4LongLongLong4(inValue, out);
   4570             verifyResultsClampLong4LongLongLong4(inValue, inMinValue, inMaxValue, out, false);
   4571         } catch (Exception e) {
   4572             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4LongLongLong4: " + e.toString());
   4573         }
   4574         try {
   4575             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
   4576             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4577             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4578             scriptRelaxed.forEach_testClampLong4LongLongLong4(inValue, out);
   4579             verifyResultsClampLong4LongLongLong4(inValue, inMinValue, inMaxValue, out, true);
   4580         } catch (Exception e) {
   4581             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4LongLongLong4: " + e.toString());
   4582         }
   4583     }
   4584 
   4585     private void verifyResultsClampLong4LongLongLong4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4586         long[] arrayInValue = new long[INPUTSIZE * 4];
   4587         inValue.copyTo(arrayInValue);
   4588         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   4589         inMinValue.copyTo(arrayInMinValue);
   4590         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   4591         inMaxValue.copyTo(arrayInMaxValue);
   4592         long[] arrayOut = new long[INPUTSIZE * 4];
   4593         out.copyTo(arrayOut);
   4594         for (int i = 0; i < INPUTSIZE; i++) {
   4595             for (int j = 0; j < 4 ; j++) {
   4596                 // Extract the inputs.
   4597                 ArgumentsLongLongLongLong args = new ArgumentsLongLongLongLong();
   4598                 args.inValue = arrayInValue[i * 4 + j];
   4599                 args.inMinValue = arrayInMinValue[i];
   4600                 args.inMaxValue = arrayInMaxValue[i];
   4601                 // Figure out what the outputs should have been.
   4602                 CoreMathVerifier.computeClamp(args);
   4603                 // Validate the outputs.
   4604                 boolean valid = true;
   4605                 if (args.out != arrayOut[i * 4 + j]) {
   4606                     valid = false;
   4607                 }
   4608                 if (!valid) {
   4609                     StringBuilder message = new StringBuilder();
   4610                     message.append("Input inValue: ");
   4611                     message.append(String.format("%d", args.inValue));
   4612                     message.append("\n");
   4613                     message.append("Input inMinValue: ");
   4614                     message.append(String.format("%d", args.inMinValue));
   4615                     message.append("\n");
   4616                     message.append("Input inMaxValue: ");
   4617                     message.append(String.format("%d", args.inMaxValue));
   4618                     message.append("\n");
   4619                     message.append("Expected output out: ");
   4620                     message.append(String.format("%d", args.out));
   4621                     message.append("\n");
   4622                     message.append("Actual   output out: ");
   4623                     message.append(String.format("%d", arrayOut[i * 4 + j]));
   4624                     if (args.out != arrayOut[i * 4 + j]) {
   4625                         message.append(" FAIL");
   4626                     }
   4627                     message.append("\n");
   4628                     assertTrue("Incorrect output for checkClampLong4LongLongLong4" +
   4629                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4630                 }
   4631             }
   4632         }
   4633     }
   4634 
   4635     private void checkClampUlong2UlongUlongUlong2() {
   4636         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xf275dabaa7fa1bf7l, false);
   4637         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xf08a9e698d13b735l, false);
   4638         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xf08a9e5e1e70a93bl, false);
   4639         enforceOrdering(inMinValue, inMaxValue);
   4640         try {
   4641             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
   4642             script.set_gAllocInMinValue(inMinValue);
   4643             script.set_gAllocInMaxValue(inMaxValue);
   4644             script.forEach_testClampUlong2UlongUlongUlong2(inValue, out);
   4645             verifyResultsClampUlong2UlongUlongUlong2(inValue, inMinValue, inMaxValue, out, false);
   4646         } catch (Exception e) {
   4647             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2UlongUlongUlong2: " + e.toString());
   4648         }
   4649         try {
   4650             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
   4651             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4652             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4653             scriptRelaxed.forEach_testClampUlong2UlongUlongUlong2(inValue, out);
   4654             verifyResultsClampUlong2UlongUlongUlong2(inValue, inMinValue, inMaxValue, out, true);
   4655         } catch (Exception e) {
   4656             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2UlongUlongUlong2: " + e.toString());
   4657         }
   4658     }
   4659 
   4660     private void verifyResultsClampUlong2UlongUlongUlong2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4661         long[] arrayInValue = new long[INPUTSIZE * 2];
   4662         inValue.copyTo(arrayInValue);
   4663         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   4664         inMinValue.copyTo(arrayInMinValue);
   4665         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   4666         inMaxValue.copyTo(arrayInMaxValue);
   4667         long[] arrayOut = new long[INPUTSIZE * 2];
   4668         out.copyTo(arrayOut);
   4669         for (int i = 0; i < INPUTSIZE; i++) {
   4670             for (int j = 0; j < 2 ; j++) {
   4671                 // Extract the inputs.
   4672                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   4673                 args.inValue = arrayInValue[i * 2 + j];
   4674                 args.inMinValue = arrayInMinValue[i];
   4675                 args.inMaxValue = arrayInMaxValue[i];
   4676                 // Figure out what the outputs should have been.
   4677                 CoreMathVerifier.computeClamp(args);
   4678                 // Validate the outputs.
   4679                 boolean valid = true;
   4680                 if (args.out != arrayOut[i * 2 + j]) {
   4681                     valid = false;
   4682                 }
   4683                 if (!valid) {
   4684                     StringBuilder message = new StringBuilder();
   4685                     message.append("Input inValue: ");
   4686                     message.append(String.format("0x%x", args.inValue));
   4687                     message.append("\n");
   4688                     message.append("Input inMinValue: ");
   4689                     message.append(String.format("0x%x", args.inMinValue));
   4690                     message.append("\n");
   4691                     message.append("Input inMaxValue: ");
   4692                     message.append(String.format("0x%x", args.inMaxValue));
   4693                     message.append("\n");
   4694                     message.append("Expected output out: ");
   4695                     message.append(String.format("0x%x", args.out));
   4696                     message.append("\n");
   4697                     message.append("Actual   output out: ");
   4698                     message.append(String.format("0x%x", arrayOut[i * 2 + j]));
   4699                     if (args.out != arrayOut[i * 2 + j]) {
   4700                         message.append(" FAIL");
   4701                     }
   4702                     message.append("\n");
   4703                     assertTrue("Incorrect output for checkClampUlong2UlongUlongUlong2" +
   4704                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4705                 }
   4706             }
   4707         }
   4708     }
   4709 
   4710     private void checkClampUlong3UlongUlongUlong3() {
   4711         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x417c2f0620b6497dl, false);
   4712         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xfb4069f3c0421f27l, false);
   4713         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xfb4069e8519f112dl, false);
   4714         enforceOrdering(inMinValue, inMaxValue);
   4715         try {
   4716             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
   4717             script.set_gAllocInMinValue(inMinValue);
   4718             script.set_gAllocInMaxValue(inMaxValue);
   4719             script.forEach_testClampUlong3UlongUlongUlong3(inValue, out);
   4720             verifyResultsClampUlong3UlongUlongUlong3(inValue, inMinValue, inMaxValue, out, false);
   4721         } catch (Exception e) {
   4722             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3UlongUlongUlong3: " + e.toString());
   4723         }
   4724         try {
   4725             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
   4726             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4727             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4728             scriptRelaxed.forEach_testClampUlong3UlongUlongUlong3(inValue, out);
   4729             verifyResultsClampUlong3UlongUlongUlong3(inValue, inMinValue, inMaxValue, out, true);
   4730         } catch (Exception e) {
   4731             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3UlongUlongUlong3: " + e.toString());
   4732         }
   4733     }
   4734 
   4735     private void verifyResultsClampUlong3UlongUlongUlong3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4736         long[] arrayInValue = new long[INPUTSIZE * 4];
   4737         inValue.copyTo(arrayInValue);
   4738         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   4739         inMinValue.copyTo(arrayInMinValue);
   4740         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   4741         inMaxValue.copyTo(arrayInMaxValue);
   4742         long[] arrayOut = new long[INPUTSIZE * 4];
   4743         out.copyTo(arrayOut);
   4744         for (int i = 0; i < INPUTSIZE; i++) {
   4745             for (int j = 0; j < 3 ; j++) {
   4746                 // Extract the inputs.
   4747                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   4748                 args.inValue = arrayInValue[i * 4 + j];
   4749                 args.inMinValue = arrayInMinValue[i];
   4750                 args.inMaxValue = arrayInMaxValue[i];
   4751                 // Figure out what the outputs should have been.
   4752                 CoreMathVerifier.computeClamp(args);
   4753                 // Validate the outputs.
   4754                 boolean valid = true;
   4755                 if (args.out != arrayOut[i * 4 + j]) {
   4756                     valid = false;
   4757                 }
   4758                 if (!valid) {
   4759                     StringBuilder message = new StringBuilder();
   4760                     message.append("Input inValue: ");
   4761                     message.append(String.format("0x%x", args.inValue));
   4762                     message.append("\n");
   4763                     message.append("Input inMinValue: ");
   4764                     message.append(String.format("0x%x", args.inMinValue));
   4765                     message.append("\n");
   4766                     message.append("Input inMaxValue: ");
   4767                     message.append(String.format("0x%x", args.inMaxValue));
   4768                     message.append("\n");
   4769                     message.append("Expected output out: ");
   4770                     message.append(String.format("0x%x", args.out));
   4771                     message.append("\n");
   4772                     message.append("Actual   output out: ");
   4773                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   4774                     if (args.out != arrayOut[i * 4 + j]) {
   4775                         message.append(" FAIL");
   4776                     }
   4777                     message.append("\n");
   4778                     assertTrue("Incorrect output for checkClampUlong3UlongUlongUlong3" +
   4779                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4780                 }
   4781             }
   4782         }
   4783     }
   4784 
   4785     private void checkClampUlong4UlongUlongUlong4() {
   4786         Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9082835199727703l, false);
   4787         Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x5f6357df3708719l, false);
   4788         Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x5f6357284cd791fl, false);
   4789         enforceOrdering(inMinValue, inMaxValue);
   4790         try {
   4791             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
   4792             script.set_gAllocInMinValue(inMinValue);
   4793             script.set_gAllocInMaxValue(inMaxValue);
   4794             script.forEach_testClampUlong4UlongUlongUlong4(inValue, out);
   4795             verifyResultsClampUlong4UlongUlongUlong4(inValue, inMinValue, inMaxValue, out, false);
   4796         } catch (Exception e) {
   4797             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4UlongUlongUlong4: " + e.toString());
   4798         }
   4799         try {
   4800             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
   4801             scriptRelaxed.set_gAllocInMinValue(inMinValue);
   4802             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
   4803             scriptRelaxed.forEach_testClampUlong4UlongUlongUlong4(inValue, out);
   4804             verifyResultsClampUlong4UlongUlongUlong4(inValue, inMinValue, inMaxValue, out, true);
   4805         } catch (Exception e) {
   4806             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4UlongUlongUlong4: " + e.toString());
   4807         }
   4808     }
   4809 
   4810     private void verifyResultsClampUlong4UlongUlongUlong4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
   4811         long[] arrayInValue = new long[INPUTSIZE * 4];
   4812         inValue.copyTo(arrayInValue);
   4813         long[] arrayInMinValue = new long[INPUTSIZE * 1];
   4814         inMinValue.copyTo(arrayInMinValue);
   4815         long[] arrayInMaxValue = new long[INPUTSIZE * 1];
   4816         inMaxValue.copyTo(arrayInMaxValue);
   4817         long[] arrayOut = new long[INPUTSIZE * 4];
   4818         out.copyTo(arrayOut);
   4819         for (int i = 0; i < INPUTSIZE; i++) {
   4820             for (int j = 0; j < 4 ; j++) {
   4821                 // Extract the inputs.
   4822                 ArgumentsUlongUlongUlongUlong args = new ArgumentsUlongUlongUlongUlong();
   4823                 args.inValue = arrayInValue[i * 4 + j];
   4824                 args.inMinValue = arrayInMinValue[i];
   4825                 args.inMaxValue = arrayInMaxValue[i];
   4826                 // Figure out what the outputs should have been.
   4827                 CoreMathVerifier.computeClamp(args);
   4828                 // Validate the outputs.
   4829                 boolean valid = true;
   4830                 if (args.out != arrayOut[i * 4 + j]) {
   4831                     valid = false;
   4832                 }
   4833                 if (!valid) {
   4834                     StringBuilder message = new StringBuilder();
   4835                     message.append("Input inValue: ");
   4836                     message.append(String.format("0x%x", args.inValue));
   4837                     message.append("\n");
   4838                     message.append("Input inMinValue: ");
   4839                     message.append(String.format("0x%x", args.inMinValue));
   4840                     message.append("\n");
   4841                     message.append("Input inMaxValue: ");
   4842                     message.append(String.format("0x%x", args.inMaxValue));
   4843                     message.append("\n");
   4844                     message.append("Expected output out: ");
   4845                     message.append(String.format("0x%x", args.out));
   4846                     message.append("\n");
   4847                     message.append("Actual   output out: ");
   4848                     message.append(String.format("0x%x", arrayOut[i * 4 + j]));
   4849                     if (args.out != arrayOut[i * 4 + j]) {
   4850                         message.append(" FAIL");
   4851                     }
   4852                     message.append("\n");
   4853                     assertTrue("Incorrect output for checkClampUlong4UlongUlongUlong4" +
   4854                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
   4855                 }
   4856             }
   4857         }
   4858     }
   4859 
   4860     public void testClamp() {
   4861         checkClampFloatFloatFloatFloat();
   4862         checkClampFloat2Float2Float2Float2();
   4863         checkClampFloat3Float3Float3Float3();
   4864         checkClampFloat4Float4Float4Float4();
   4865         checkClampFloat2FloatFloatFloat2();
   4866         checkClampFloat3FloatFloatFloat3();
   4867         checkClampFloat4FloatFloatFloat4();
   4868         checkClampCharCharCharChar();
   4869         checkClampChar2Char2Char2Char2();
   4870         checkClampChar3Char3Char3Char3();
   4871         checkClampChar4Char4Char4Char4();
   4872         checkClampUcharUcharUcharUchar();
   4873         checkClampUchar2Uchar2Uchar2Uchar2();
   4874         checkClampUchar3Uchar3Uchar3Uchar3();
   4875         checkClampUchar4Uchar4Uchar4Uchar4();
   4876         checkClampShortShortShortShort();
   4877         checkClampShort2Short2Short2Short2();
   4878         checkClampShort3Short3Short3Short3();
   4879         checkClampShort4Short4Short4Short4();
   4880         checkClampUshortUshortUshortUshort();
   4881         checkClampUshort2Ushort2Ushort2Ushort2();
   4882         checkClampUshort3Ushort3Ushort3Ushort3();
   4883         checkClampUshort4Ushort4Ushort4Ushort4();
   4884         checkClampIntIntIntInt();
   4885         checkClampInt2Int2Int2Int2();
   4886         checkClampInt3Int3Int3Int3();
   4887         checkClampInt4Int4Int4Int4();
   4888         checkClampUintUintUintUint();
   4889         checkClampUint2Uint2Uint2Uint2();
   4890         checkClampUint3Uint3Uint3Uint3();
   4891         checkClampUint4Uint4Uint4Uint4();
   4892         checkClampLongLongLongLong();
   4893         checkClampLong2Long2Long2Long2();
   4894         checkClampLong3Long3Long3Long3();
   4895         checkClampLong4Long4Long4Long4();
   4896         checkClampUlongUlongUlongUlong();
   4897         checkClampUlong2Ulong2Ulong2Ulong2();
   4898         checkClampUlong3Ulong3Ulong3Ulong3();
   4899         checkClampUlong4Ulong4Ulong4Ulong4();
   4900         checkClampChar2CharCharChar2();
   4901         checkClampChar3CharCharChar3();
   4902         checkClampChar4CharCharChar4();
   4903         checkClampUchar2UcharUcharUchar2();
   4904         checkClampUchar3UcharUcharUchar3();
   4905         checkClampUchar4UcharUcharUchar4();
   4906         checkClampShort2ShortShortShort2();
   4907         checkClampShort3ShortShortShort3();
   4908         checkClampShort4ShortShortShort4();
   4909         checkClampUshort2UshortUshortUshort2();
   4910         checkClampUshort3UshortUshortUshort3();
   4911         checkClampUshort4UshortUshortUshort4();
   4912         checkClampInt2IntIntInt2();
   4913         checkClampInt3IntIntInt3();
   4914         checkClampInt4IntIntInt4();
   4915         checkClampUint2UintUintUint2();
   4916         checkClampUint3UintUintUint3();
   4917         checkClampUint4UintUintUint4();
   4918         checkClampLong2LongLongLong2();
   4919         checkClampLong3LongLongLong3();
   4920         checkClampLong4LongLongLong4();
   4921         checkClampUlong2UlongUlongUlong2();
   4922         checkClampUlong3UlongUlongUlong3();
   4923         checkClampUlong4UlongUlongUlong4();
   4924     }
   4925 }
   4926