1 /* 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @bug 6340864 27 * @summary Implement vectorization optimizations in hotspot-server 28 * 29 * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestDoubleVect 30 * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestDoubleVect 31 * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestDoubleVect 32 * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestDoubleVect 33 */ 34 35 package compiler.c2.cr6340864; 36 37 public class TestDoubleVect { 38 private static final int ARRLEN = 997; 39 private static final int ITERS = 11000; 40 private static final double ADD_INIT = -7500.; 41 private static final double VALUE = 15.; 42 43 public static void main(String args[]) { 44 System.out.println("Testing Double vectors"); 45 int errn = test(); 46 if (errn > 0) { 47 System.err.println("FAILED: " + errn + " errors"); 48 System.exit(97); 49 } 50 System.out.println("PASSED"); 51 } 52 53 static int test() { 54 double[] a0 = new double[ARRLEN]; 55 double[] a1 = new double[ARRLEN]; 56 double[] a2 = new double[ARRLEN]; 57 double[] a3 = new double[ARRLEN]; 58 // Initialize 59 double gold_sum = 0; 60 for (int i=0; i<ARRLEN; i++) { 61 double val = ADD_INIT+(double)i; 62 gold_sum += val; 63 a1[i] = val; 64 a2[i] = VALUE; 65 a3[i] = -VALUE; 66 } 67 68 System.out.println("Warmup"); 69 for (int i=0; i<ITERS; i++) { 70 test_sum(a1); 71 test_addc(a0, a1); 72 test_addv(a0, a1, VALUE); 73 test_adda(a0, a1, a2); 74 test_subc(a0, a1); 75 test_subv(a0, a1, VALUE); 76 test_suba(a0, a1, a2); 77 test_mulc(a0, a1); 78 test_mulv(a0, a1, VALUE); 79 test_mula(a0, a1, a2); 80 test_divc(a0, a1); 81 test_divv(a0, a1, VALUE); 82 test_diva(a0, a1, a2); 83 test_mulc_n(a0, a1); 84 test_mulv(a0, a1, -VALUE); 85 test_mula(a0, a1, a3); 86 test_divc_n(a0, a1); 87 test_divv(a0, a1, -VALUE); 88 test_diva(a0, a1, a3); 89 test_negc(a0, a1); 90 } 91 // Test and verify results 92 System.out.println("Verification"); 93 int errn = 0; 94 { 95 double sum = test_sum(a1); 96 if (sum != gold_sum) { 97 System.err.println("test_sum: " + sum + " != " + gold_sum); 98 errn++; 99 } 100 // Overwrite with NaN values 101 a1[0] = Double.NaN; 102 a1[1] = Double.POSITIVE_INFINITY; 103 a1[2] = Double.NEGATIVE_INFINITY; 104 a1[3] = Double.MAX_VALUE; 105 a1[4] = Double.MIN_VALUE; 106 a1[5] = Double.MIN_NORMAL; 107 108 a2[6] = a1[0]; 109 a2[7] = a1[1]; 110 a2[8] = a1[2]; 111 a2[9] = a1[3]; 112 a2[10] = a1[4]; 113 a2[11] = a1[5]; 114 115 a3[6] = -a2[6]; 116 a3[7] = -a2[7]; 117 a3[8] = -a2[8]; 118 a3[9] = -a2[9]; 119 a3[10] = -a2[10]; 120 a3[11] = -a2[11]; 121 122 test_addc(a0, a1); 123 errn += verify("test_addc: ", 0, a0[0], (Double.NaN+VALUE)); 124 errn += verify("test_addc: ", 1, a0[1], (Double.POSITIVE_INFINITY+VALUE)); 125 errn += verify("test_addc: ", 2, a0[2], (Double.NEGATIVE_INFINITY+VALUE)); 126 errn += verify("test_addc: ", 3, a0[3], (Double.MAX_VALUE+VALUE)); 127 errn += verify("test_addc: ", 4, a0[4], (Double.MIN_VALUE+VALUE)); 128 errn += verify("test_addc: ", 5, a0[5], (Double.MIN_NORMAL+VALUE)); 129 for (int i=6; i<ARRLEN; i++) { 130 errn += verify("test_addc: ", i, a0[i], ((ADD_INIT+i)+VALUE)); 131 } 132 test_addv(a0, a1, VALUE); 133 errn += verify("test_addv: ", 0, a0[0], (Double.NaN+VALUE)); 134 errn += verify("test_addv: ", 1, a0[1], (Double.POSITIVE_INFINITY+VALUE)); 135 errn += verify("test_addv: ", 2, a0[2], (Double.NEGATIVE_INFINITY+VALUE)); 136 errn += verify("test_addv: ", 3, a0[3], (Double.MAX_VALUE+VALUE)); 137 errn += verify("test_addv: ", 4, a0[4], (Double.MIN_VALUE+VALUE)); 138 errn += verify("test_addv: ", 5, a0[5], (Double.MIN_NORMAL+VALUE)); 139 for (int i=6; i<ARRLEN; i++) { 140 errn += verify("test_addv: ", i, a0[i], ((ADD_INIT+i)+VALUE)); 141 } 142 test_adda(a0, a1, a2); 143 errn += verify("test_adda: ", 0, a0[0], (Double.NaN+VALUE)); 144 errn += verify("test_adda: ", 1, a0[1], (Double.POSITIVE_INFINITY+VALUE)); 145 errn += verify("test_adda: ", 2, a0[2], (Double.NEGATIVE_INFINITY+VALUE)); 146 errn += verify("test_adda: ", 3, a0[3], (Double.MAX_VALUE+VALUE)); 147 errn += verify("test_adda: ", 4, a0[4], (Double.MIN_VALUE+VALUE)); 148 errn += verify("test_adda: ", 5, a0[5], (Double.MIN_NORMAL+VALUE)); 149 errn += verify("test_adda: ", 6, a0[6], ((ADD_INIT+6)+Double.NaN)); 150 errn += verify("test_adda: ", 7, a0[7], ((ADD_INIT+7)+Double.POSITIVE_INFINITY)); 151 errn += verify("test_adda: ", 8, a0[8], ((ADD_INIT+8)+Double.NEGATIVE_INFINITY)); 152 errn += verify("test_adda: ", 9, a0[9], ((ADD_INIT+9)+Double.MAX_VALUE)); 153 errn += verify("test_adda: ", 10, a0[10], ((ADD_INIT+10)+Double.MIN_VALUE)); 154 errn += verify("test_adda: ", 11, a0[11], ((ADD_INIT+11)+Double.MIN_NORMAL)); 155 for (int i=12; i<ARRLEN; i++) { 156 errn += verify("test_adda: ", i, a0[i], ((ADD_INIT+i)+VALUE)); 157 } 158 159 test_subc(a0, a1); 160 errn += verify("test_subc: ", 0, a0[0], (Double.NaN-VALUE)); 161 errn += verify("test_subc: ", 1, a0[1], (Double.POSITIVE_INFINITY-VALUE)); 162 errn += verify("test_subc: ", 2, a0[2], (Double.NEGATIVE_INFINITY-VALUE)); 163 errn += verify("test_subc: ", 3, a0[3], (Double.MAX_VALUE-VALUE)); 164 errn += verify("test_subc: ", 4, a0[4], (Double.MIN_VALUE-VALUE)); 165 errn += verify("test_subc: ", 5, a0[5], (Double.MIN_NORMAL-VALUE)); 166 for (int i=6; i<ARRLEN; i++) { 167 errn += verify("test_subc: ", i, a0[i], ((ADD_INIT+i)-VALUE)); 168 } 169 test_subv(a0, a1, VALUE); 170 errn += verify("test_subv: ", 0, a0[0], (Double.NaN-VALUE)); 171 errn += verify("test_subv: ", 1, a0[1], (Double.POSITIVE_INFINITY-VALUE)); 172 errn += verify("test_subv: ", 2, a0[2], (Double.NEGATIVE_INFINITY-VALUE)); 173 errn += verify("test_subv: ", 3, a0[3], (Double.MAX_VALUE-VALUE)); 174 errn += verify("test_subv: ", 4, a0[4], (Double.MIN_VALUE-VALUE)); 175 errn += verify("test_subv: ", 5, a0[5], (Double.MIN_NORMAL-VALUE)); 176 for (int i=6; i<ARRLEN; i++) { 177 errn += verify("test_subv: ", i, a0[i], ((ADD_INIT+i)-VALUE)); 178 } 179 test_suba(a0, a1, a2); 180 errn += verify("test_suba: ", 0, a0[0], (Double.NaN-VALUE)); 181 errn += verify("test_suba: ", 1, a0[1], (Double.POSITIVE_INFINITY-VALUE)); 182 errn += verify("test_suba: ", 2, a0[2], (Double.NEGATIVE_INFINITY-VALUE)); 183 errn += verify("test_suba: ", 3, a0[3], (Double.MAX_VALUE-VALUE)); 184 errn += verify("test_suba: ", 4, a0[4], (Double.MIN_VALUE-VALUE)); 185 errn += verify("test_suba: ", 5, a0[5], (Double.MIN_NORMAL-VALUE)); 186 errn += verify("test_suba: ", 6, a0[6], ((ADD_INIT+6)-Double.NaN)); 187 errn += verify("test_suba: ", 7, a0[7], ((ADD_INIT+7)-Double.POSITIVE_INFINITY)); 188 errn += verify("test_suba: ", 8, a0[8], ((ADD_INIT+8)-Double.NEGATIVE_INFINITY)); 189 errn += verify("test_suba: ", 9, a0[9], ((ADD_INIT+9)-Double.MAX_VALUE)); 190 errn += verify("test_suba: ", 10, a0[10], ((ADD_INIT+10)-Double.MIN_VALUE)); 191 errn += verify("test_suba: ", 11, a0[11], ((ADD_INIT+11)-Double.MIN_NORMAL)); 192 for (int i=12; i<ARRLEN; i++) { 193 errn += verify("test_suba: ", i, a0[i], ((ADD_INIT+i)-VALUE)); 194 } 195 196 test_mulc(a0, a1); 197 errn += verify("test_mulc: ", 0, a0[0], (Double.NaN*VALUE)); 198 errn += verify("test_mulc: ", 1, a0[1], (Double.POSITIVE_INFINITY*VALUE)); 199 errn += verify("test_mulc: ", 2, a0[2], (Double.NEGATIVE_INFINITY*VALUE)); 200 errn += verify("test_mulc: ", 3, a0[3], (Double.MAX_VALUE*VALUE)); 201 errn += verify("test_mulc: ", 4, a0[4], (Double.MIN_VALUE*VALUE)); 202 errn += verify("test_mulc: ", 5, a0[5], (Double.MIN_NORMAL*VALUE)); 203 for (int i=6; i<ARRLEN; i++) { 204 errn += verify("test_mulc: ", i, a0[i], ((ADD_INIT+i)*VALUE)); 205 } 206 test_mulv(a0, a1, VALUE); 207 errn += verify("test_mulv: ", 0, a0[0], (Double.NaN*VALUE)); 208 errn += verify("test_mulv: ", 1, a0[1], (Double.POSITIVE_INFINITY*VALUE)); 209 errn += verify("test_mulv: ", 2, a0[2], (Double.NEGATIVE_INFINITY*VALUE)); 210 errn += verify("test_mulv: ", 3, a0[3], (Double.MAX_VALUE*VALUE)); 211 errn += verify("test_mulv: ", 4, a0[4], (Double.MIN_VALUE*VALUE)); 212 errn += verify("test_mulv: ", 5, a0[5], (Double.MIN_NORMAL*VALUE)); 213 for (int i=6; i<ARRLEN; i++) { 214 errn += verify("test_mulv: ", i, a0[i], ((ADD_INIT+i)*VALUE)); 215 } 216 test_mula(a0, a1, a2); 217 errn += verify("test_mula: ", 0, a0[0], (Double.NaN*VALUE)); 218 errn += verify("test_mula: ", 1, a0[1], (Double.POSITIVE_INFINITY*VALUE)); 219 errn += verify("test_mula: ", 2, a0[2], (Double.NEGATIVE_INFINITY*VALUE)); 220 errn += verify("test_mula: ", 3, a0[3], (Double.MAX_VALUE*VALUE)); 221 errn += verify("test_mula: ", 4, a0[4], (Double.MIN_VALUE*VALUE)); 222 errn += verify("test_mula: ", 5, a0[5], (Double.MIN_NORMAL*VALUE)); 223 errn += verify("test_mula: ", 6, a0[6], ((ADD_INIT+6)*Double.NaN)); 224 errn += verify("test_mula: ", 7, a0[7], ((ADD_INIT+7)*Double.POSITIVE_INFINITY)); 225 errn += verify("test_mula: ", 8, a0[8], ((ADD_INIT+8)*Double.NEGATIVE_INFINITY)); 226 errn += verify("test_mula: ", 9, a0[9], ((ADD_INIT+9)*Double.MAX_VALUE)); 227 errn += verify("test_mula: ", 10, a0[10], ((ADD_INIT+10)*Double.MIN_VALUE)); 228 errn += verify("test_mula: ", 11, a0[11], ((ADD_INIT+11)*Double.MIN_NORMAL)); 229 for (int i=12; i<ARRLEN; i++) { 230 errn += verify("test_mula: ", i, a0[i], ((ADD_INIT+i)*VALUE)); 231 } 232 233 test_divc(a0, a1); 234 errn += verify("test_divc: ", 0, a0[0], (Double.NaN/VALUE)); 235 errn += verify("test_divc: ", 1, a0[1], (Double.POSITIVE_INFINITY/VALUE)); 236 errn += verify("test_divc: ", 2, a0[2], (Double.NEGATIVE_INFINITY/VALUE)); 237 errn += verify("test_divc: ", 3, a0[3], (Double.MAX_VALUE/VALUE)); 238 errn += verify("test_divc: ", 4, a0[4], (Double.MIN_VALUE/VALUE)); 239 errn += verify("test_divc: ", 5, a0[5], (Double.MIN_NORMAL/VALUE)); 240 for (int i=6; i<ARRLEN; i++) { 241 errn += verify("test_divc: ", i, a0[i], ((ADD_INIT+i)/VALUE)); 242 } 243 test_divv(a0, a1, VALUE); 244 errn += verify("test_divv: ", 0, a0[0], (Double.NaN/VALUE)); 245 errn += verify("test_divv: ", 1, a0[1], (Double.POSITIVE_INFINITY/VALUE)); 246 errn += verify("test_divv: ", 2, a0[2], (Double.NEGATIVE_INFINITY/VALUE)); 247 errn += verify("test_divv: ", 3, a0[3], (Double.MAX_VALUE/VALUE)); 248 errn += verify("test_divv: ", 4, a0[4], (Double.MIN_VALUE/VALUE)); 249 errn += verify("test_divv: ", 5, a0[5], (Double.MIN_NORMAL/VALUE)); 250 for (int i=6; i<ARRLEN; i++) { 251 errn += verify("test_divv: ", i, a0[i], ((ADD_INIT+i)/VALUE)); 252 } 253 test_diva(a0, a1, a2); 254 errn += verify("test_diva: ", 0, a0[0], (Double.NaN/VALUE)); 255 errn += verify("test_diva: ", 1, a0[1], (Double.POSITIVE_INFINITY/VALUE)); 256 errn += verify("test_diva: ", 2, a0[2], (Double.NEGATIVE_INFINITY/VALUE)); 257 errn += verify("test_diva: ", 3, a0[3], (Double.MAX_VALUE/VALUE)); 258 errn += verify("test_diva: ", 4, a0[4], (Double.MIN_VALUE/VALUE)); 259 errn += verify("test_diva: ", 5, a0[5], (Double.MIN_NORMAL/VALUE)); 260 errn += verify("test_diva: ", 6, a0[6], ((ADD_INIT+6)/Double.NaN)); 261 errn += verify("test_diva: ", 7, a0[7], ((ADD_INIT+7)/Double.POSITIVE_INFINITY)); 262 errn += verify("test_diva: ", 8, a0[8], ((ADD_INIT+8)/Double.NEGATIVE_INFINITY)); 263 errn += verify("test_diva: ", 9, a0[9], ((ADD_INIT+9)/Double.MAX_VALUE)); 264 errn += verify("test_diva: ", 10, a0[10], ((ADD_INIT+10)/Double.MIN_VALUE)); 265 errn += verify("test_diva: ", 11, a0[11], ((ADD_INIT+11)/Double.MIN_NORMAL)); 266 for (int i=12; i<ARRLEN; i++) { 267 errn += verify("test_diva: ", i, a0[i], ((ADD_INIT+i)/VALUE)); 268 } 269 270 test_mulc_n(a0, a1); 271 errn += verify("test_mulc_n: ", 0, a0[0], (Double.NaN*(-VALUE))); 272 errn += verify("test_mulc_n: ", 1, a0[1], (Double.POSITIVE_INFINITY*(-VALUE))); 273 errn += verify("test_mulc_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY*(-VALUE))); 274 errn += verify("test_mulc_n: ", 3, a0[3], (Double.MAX_VALUE*(-VALUE))); 275 errn += verify("test_mulc_n: ", 4, a0[4], (Double.MIN_VALUE*(-VALUE))); 276 errn += verify("test_mulc_n: ", 5, a0[5], (Double.MIN_NORMAL*(-VALUE))); 277 for (int i=6; i<ARRLEN; i++) { 278 errn += verify("test_mulc_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE))); 279 } 280 test_mulv(a0, a1, -VALUE); 281 errn += verify("test_mulv_n: ", 0, a0[0], (Double.NaN*(-VALUE))); 282 errn += verify("test_mulv_n: ", 1, a0[1], (Double.POSITIVE_INFINITY*(-VALUE))); 283 errn += verify("test_mulv_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY*(-VALUE))); 284 errn += verify("test_mulv_n: ", 3, a0[3], (Double.MAX_VALUE*(-VALUE))); 285 errn += verify("test_mulv_n: ", 4, a0[4], (Double.MIN_VALUE*(-VALUE))); 286 errn += verify("test_mulv_n: ", 5, a0[5], (Double.MIN_NORMAL*(-VALUE))); 287 for (int i=6; i<ARRLEN; i++) { 288 errn += verify("test_mulv_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE))); 289 } 290 test_mula(a0, a1, a3); 291 errn += verify("test_mula_n: ", 0, a0[0], (Double.NaN*(-VALUE))); 292 errn += verify("test_mula_n: ", 1, a0[1], (Double.POSITIVE_INFINITY*(-VALUE))); 293 errn += verify("test_mula_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY*(-VALUE))); 294 errn += verify("test_mula_n: ", 3, a0[3], (Double.MAX_VALUE*(-VALUE))); 295 errn += verify("test_mula_n: ", 4, a0[4], (Double.MIN_VALUE*(-VALUE))); 296 errn += verify("test_mula_n: ", 5, a0[5], (Double.MIN_NORMAL*(-VALUE))); 297 errn += verify("test_mula_n: ", 6, a0[6], ((ADD_INIT+6)*(-Double.NaN))); 298 errn += verify("test_mula_n: ", 7, a0[7], ((ADD_INIT+7)*(-Double.POSITIVE_INFINITY))); 299 errn += verify("test_mula_n: ", 8, a0[8], ((ADD_INIT+8)*(-Double.NEGATIVE_INFINITY))); 300 errn += verify("test_mula_n: ", 9, a0[9], ((ADD_INIT+9)*(-Double.MAX_VALUE))); 301 errn += verify("test_mula_n: ", 10, a0[10], ((ADD_INIT+10)*(-Double.MIN_VALUE))); 302 errn += verify("test_mula_n: ", 11, a0[11], ((ADD_INIT+11)*(-Double.MIN_NORMAL))); 303 for (int i=12; i<ARRLEN; i++) { 304 errn += verify("test_mula_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE))); 305 } 306 307 test_divc_n(a0, a1); 308 errn += verify("test_divc_n: ", 0, a0[0], (Double.NaN/(-VALUE))); 309 errn += verify("test_divc_n: ", 1, a0[1], (Double.POSITIVE_INFINITY/(-VALUE))); 310 errn += verify("test_divc_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY/(-VALUE))); 311 errn += verify("test_divc_n: ", 3, a0[3], (Double.MAX_VALUE/(-VALUE))); 312 errn += verify("test_divc_n: ", 4, a0[4], (Double.MIN_VALUE/(-VALUE))); 313 errn += verify("test_divc_n: ", 5, a0[5], (Double.MIN_NORMAL/(-VALUE))); 314 for (int i=6; i<ARRLEN; i++) { 315 errn += verify("test_divc_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE))); 316 } 317 test_divv(a0, a1, -VALUE); 318 errn += verify("test_divv_n: ", 0, a0[0], (Double.NaN/(-VALUE))); 319 errn += verify("test_divv_n: ", 1, a0[1], (Double.POSITIVE_INFINITY/(-VALUE))); 320 errn += verify("test_divv_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY/(-VALUE))); 321 errn += verify("test_divv_n: ", 3, a0[3], (Double.MAX_VALUE/(-VALUE))); 322 errn += verify("test_divv_n: ", 4, a0[4], (Double.MIN_VALUE/(-VALUE))); 323 errn += verify("test_divv_n: ", 5, a0[5], (Double.MIN_NORMAL/(-VALUE))); 324 for (int i=6; i<ARRLEN; i++) { 325 errn += verify("test_divv_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE))); 326 } 327 test_diva(a0, a1, a3); 328 errn += verify("test_diva_n: ", 0, a0[0], (Double.NaN/(-VALUE))); 329 errn += verify("test_diva_n: ", 1, a0[1], (Double.POSITIVE_INFINITY/(-VALUE))); 330 errn += verify("test_diva_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY/(-VALUE))); 331 errn += verify("test_diva_n: ", 3, a0[3], (Double.MAX_VALUE/(-VALUE))); 332 errn += verify("test_diva_n: ", 4, a0[4], (Double.MIN_VALUE/(-VALUE))); 333 errn += verify("test_diva_n: ", 5, a0[5], (Double.MIN_NORMAL/(-VALUE))); 334 errn += verify("test_diva_n: ", 6, a0[6], ((ADD_INIT+6)/(-Double.NaN))); 335 errn += verify("test_diva_n: ", 7, a0[7], ((ADD_INIT+7)/(-Double.POSITIVE_INFINITY))); 336 errn += verify("test_diva_n: ", 8, a0[8], ((ADD_INIT+8)/(-Double.NEGATIVE_INFINITY))); 337 errn += verify("test_diva_n: ", 9, a0[9], ((ADD_INIT+9)/(-Double.MAX_VALUE))); 338 errn += verify("test_diva_n: ", 10, a0[10], ((ADD_INIT+10)/(-Double.MIN_VALUE))); 339 errn += verify("test_diva_n: ", 11, a0[11], ((ADD_INIT+11)/(-Double.MIN_NORMAL))); 340 for (int i=12; i<ARRLEN; i++) { 341 errn += verify("test_diva_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE))); 342 } 343 test_negc(a0, a1); 344 errn += verify("test_negc: ", 0, a0[0], (Double.NaN)); 345 errn += verify("test_negc: ", 1, a0[1], (Double.NEGATIVE_INFINITY)); 346 errn += verify("test_negc: ", 2, a0[2], (Double.POSITIVE_INFINITY)); 347 errn += verify("test_negc: ", 3, a0[3], (double)(-Double.MAX_VALUE)); 348 errn += verify("test_negc: ", 4, a0[4], (double)(-Double.MIN_VALUE)); 349 errn += verify("test_negc: ", 5, a0[5], (double)(-Double.MIN_NORMAL)); 350 for (int i=6; i<ARRLEN; i++) { 351 errn += verify("test_negc: ", i, a0[i], (double)(-((double)(ADD_INIT+i)))); 352 } 353 354 } 355 356 if (errn > 0) 357 return errn; 358 359 System.out.println("Time"); 360 long start, end; 361 362 start = System.currentTimeMillis(); 363 for (int i=0; i<ITERS; i++) { 364 test_sum(a1); 365 } 366 end = System.currentTimeMillis(); 367 System.out.println("test_sum: " + (end - start)); 368 369 start = System.currentTimeMillis(); 370 for (int i=0; i<ITERS; i++) { 371 test_addc(a0, a1); 372 } 373 end = System.currentTimeMillis(); 374 System.out.println("test_addc: " + (end - start)); 375 start = System.currentTimeMillis(); 376 for (int i=0; i<ITERS; i++) { 377 test_addv(a0, a1, VALUE); 378 } 379 end = System.currentTimeMillis(); 380 System.out.println("test_addv: " + (end - start)); 381 start = System.currentTimeMillis(); 382 for (int i=0; i<ITERS; i++) { 383 test_adda(a0, a1, a2); 384 } 385 end = System.currentTimeMillis(); 386 System.out.println("test_adda: " + (end - start)); 387 388 start = System.currentTimeMillis(); 389 for (int i=0; i<ITERS; i++) { 390 test_subc(a0, a1); 391 } 392 end = System.currentTimeMillis(); 393 System.out.println("test_subc: " + (end - start)); 394 start = System.currentTimeMillis(); 395 for (int i=0; i<ITERS; i++) { 396 test_subv(a0, a1, VALUE); 397 } 398 end = System.currentTimeMillis(); 399 System.out.println("test_subv: " + (end - start)); 400 start = System.currentTimeMillis(); 401 for (int i=0; i<ITERS; i++) { 402 test_suba(a0, a1, a2); 403 } 404 end = System.currentTimeMillis(); 405 System.out.println("test_suba: " + (end - start)); 406 407 start = System.currentTimeMillis(); 408 for (int i=0; i<ITERS; i++) { 409 test_mulc(a0, a1); 410 } 411 end = System.currentTimeMillis(); 412 System.out.println("test_mulc: " + (end - start)); 413 start = System.currentTimeMillis(); 414 for (int i=0; i<ITERS; i++) { 415 test_mulv(a0, a1, VALUE); 416 } 417 end = System.currentTimeMillis(); 418 System.out.println("test_mulv: " + (end - start)); 419 start = System.currentTimeMillis(); 420 for (int i=0; i<ITERS; i++) { 421 test_mula(a0, a1, a2); 422 } 423 end = System.currentTimeMillis(); 424 System.out.println("test_mula: " + (end - start)); 425 426 start = System.currentTimeMillis(); 427 for (int i=0; i<ITERS; i++) { 428 test_divc(a0, a1); 429 } 430 end = System.currentTimeMillis(); 431 System.out.println("test_divc: " + (end - start)); 432 start = System.currentTimeMillis(); 433 for (int i=0; i<ITERS; i++) { 434 test_divv(a0, a1, VALUE); 435 } 436 end = System.currentTimeMillis(); 437 System.out.println("test_divv: " + (end - start)); 438 start = System.currentTimeMillis(); 439 for (int i=0; i<ITERS; i++) { 440 test_diva(a0, a1, a2); 441 } 442 end = System.currentTimeMillis(); 443 System.out.println("test_diva: " + (end - start)); 444 445 start = System.currentTimeMillis(); 446 for (int i=0; i<ITERS; i++) { 447 test_mulc_n(a0, a1); 448 } 449 end = System.currentTimeMillis(); 450 System.out.println("test_mulc_n: " + (end - start)); 451 start = System.currentTimeMillis(); 452 for (int i=0; i<ITERS; i++) { 453 test_mulv(a0, a1, -VALUE); 454 } 455 end = System.currentTimeMillis(); 456 System.out.println("test_mulv_n: " + (end - start)); 457 start = System.currentTimeMillis(); 458 for (int i=0; i<ITERS; i++) { 459 test_mula(a0, a1, a3); 460 } 461 end = System.currentTimeMillis(); 462 System.out.println("test_mula_n: " + (end - start)); 463 464 start = System.currentTimeMillis(); 465 for (int i=0; i<ITERS; i++) { 466 test_divc_n(a0, a1); 467 } 468 end = System.currentTimeMillis(); 469 System.out.println("test_divc_n: " + (end - start)); 470 start = System.currentTimeMillis(); 471 for (int i=0; i<ITERS; i++) { 472 test_divv(a0, a1, -VALUE); 473 } 474 end = System.currentTimeMillis(); 475 System.out.println("test_divv_n: " + (end - start)); 476 start = System.currentTimeMillis(); 477 for (int i=0; i<ITERS; i++) { 478 test_diva(a0, a1, a3); 479 } 480 end = System.currentTimeMillis(); 481 System.out.println("test_diva_n: " + (end - start)); 482 483 start = System.currentTimeMillis(); 484 for (int i=0; i<ITERS; i++) { 485 test_negc(a0, a1); 486 } 487 end = System.currentTimeMillis(); 488 System.out.println("test_negc_n: " + (end - start)); 489 490 return errn; 491 } 492 493 static double test_sum(double[] a1) { 494 double sum = 0; 495 for (int i = 0; i < a1.length; i+=1) { 496 sum += a1[i]; 497 } 498 return sum; 499 } 500 501 static void test_addc(double[] a0, double[] a1) { 502 for (int i = 0; i < a0.length; i+=1) { 503 a0[i] = (a1[i]+VALUE); 504 } 505 } 506 static void test_addv(double[] a0, double[] a1, double b) { 507 for (int i = 0; i < a0.length; i+=1) { 508 a0[i] = (a1[i]+b); 509 } 510 } 511 static void test_adda(double[] a0, double[] a1, double[] a2) { 512 for (int i = 0; i < a0.length; i+=1) { 513 a0[i] = (a1[i]+a2[i]); 514 } 515 } 516 517 static void test_subc(double[] a0, double[] a1) { 518 for (int i = 0; i < a0.length; i+=1) { 519 a0[i] = (a1[i]-VALUE); 520 } 521 } 522 static void test_subv(double[] a0, double[] a1, double b) { 523 for (int i = 0; i < a0.length; i+=1) { 524 a0[i] = (a1[i]-b); 525 } 526 } 527 static void test_suba(double[] a0, double[] a1, double[] a2) { 528 for (int i = 0; i < a0.length; i+=1) { 529 a0[i] = (a1[i]-a2[i]); 530 } 531 } 532 533 static void test_mulc(double[] a0, double[] a1) { 534 for (int i = 0; i < a0.length; i+=1) { 535 a0[i] = (a1[i]*VALUE); 536 } 537 } 538 static void test_mulc_n(double[] a0, double[] a1) { 539 for (int i = 0; i < a0.length; i+=1) { 540 a0[i] = (a1[i]*(-VALUE)); 541 } 542 } 543 static void test_mulv(double[] a0, double[] a1, double b) { 544 for (int i = 0; i < a0.length; i+=1) { 545 a0[i] = (a1[i]*b); 546 } 547 } 548 static void test_mula(double[] a0, double[] a1, double[] a2) { 549 for (int i = 0; i < a0.length; i+=1) { 550 a0[i] = (a1[i]*a2[i]); 551 } 552 } 553 554 static void test_divc(double[] a0, double[] a1) { 555 for (int i = 0; i < a0.length; i+=1) { 556 a0[i] = (a1[i]/VALUE); 557 } 558 } 559 static void test_divc_n(double[] a0, double[] a1) { 560 for (int i = 0; i < a0.length; i+=1) { 561 a0[i] = (a1[i]/(-VALUE)); 562 } 563 } 564 static void test_divv(double[] a0, double[] a1, double b) { 565 for (int i = 0; i < a0.length; i+=1) { 566 a0[i] = (a1[i]/b); 567 } 568 } 569 static void test_diva(double[] a0, double[] a1, double[] a2) { 570 for (int i = 0; i < a0.length; i+=1) { 571 a0[i] = (a1[i]/a2[i]); 572 } 573 } 574 static void test_negc(double[] a0, double[] a1) { 575 for (int i = 0; i < a0.length; i+=1) { 576 a0[i] = (double)(-((double)a1[i])); 577 } 578 } 579 580 static int verify(String text, int i, double elem, double val) { 581 if (elem != val && !(Double.isNaN(elem) && Double.isNaN(val))) { 582 System.err.println(text + "[" + i + "] = " + elem + " != " + val); 583 return 1; 584 } 585 return 0; 586 } 587 }