1 /*
2 * Copyright (c) 2018, 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
21 * questions.
22 */
286 double[] b = fb.apply(SPECIES.length());
287 double[] r = fr.apply(SPECIES.length());
288
289 for (int ic = 0; ic < INVOC_COUNT; ic++) {
290 for (int i = 0; i < a.length; i += SPECIES.length()) {
291 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
292 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
293 av.min(bv).intoArray(r, i);
294 }
295 }
296
297 bh.consume(r);
298 }
299
300
301
302
303 @Benchmark
304 public void addAll(Blackhole bh) {
305 double[] a = fa.apply(SPECIES.length());
306 double[] r = fr.apply(SPECIES.length());
307 double ra = 0;
308
309 for (int ic = 0; ic < INVOC_COUNT; ic++) {
310 for (int i = 0; i < a.length; i += SPECIES.length()) {
311 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
312 r[i] = av.addAll();
313 }
314 }
315
316 for (int ic = 0; ic < INVOC_COUNT; ic++) {
317 ra = 0;
318 for (int i = 0; i < a.length; i += SPECIES.length()) {
319 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
320 ra += av.addAll();
321 }
322 }
323
324 bh.consume(ra);
325 bh.consume(r);
326 }
327
328 @Benchmark
329 public void mulAll(Blackhole bh) {
330 double[] a = fa.apply(SPECIES.length());
331 double[] r = fr.apply(SPECIES.length());
332 double ra = 1;
333
334 for (int ic = 0; ic < INVOC_COUNT; ic++) {
335 for (int i = 0; i < a.length; i += SPECIES.length()) {
336 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
337 r[i] = av.mulAll();
338 }
339 }
340
341 for (int ic = 0; ic < INVOC_COUNT; ic++) {
342 ra = 1;
343 for (int i = 0; i < a.length; i += SPECIES.length()) {
344 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
345 ra *= av.mulAll();
346 }
347 }
348
349 bh.consume(ra);
350 bh.consume(r);
351 }
352
353 @Benchmark
354 public void minAll(Blackhole bh) {
355 double[] a = fa.apply(SPECIES.length());
356 double[] r = fr.apply(SPECIES.length());
357 double ra = Double.POSITIVE_INFINITY;
358
359 for (int ic = 0; ic < INVOC_COUNT; ic++) {
360 for (int i = 0; i < a.length; i += SPECIES.length()) {
361 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
362 r[i] = av.minAll();
363 }
364 }
365
366 for (int ic = 0; ic < INVOC_COUNT; ic++) {
367 ra = Double.POSITIVE_INFINITY;
368 for (int i = 0; i < a.length; i += SPECIES.length()) {
369 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
370 ra = (double)Math.min(ra, av.minAll());
371 }
372 }
373
374 bh.consume(ra);
375 bh.consume(r);
376 }
377
378 @Benchmark
379 public void maxAll(Blackhole bh) {
380 double[] a = fa.apply(SPECIES.length());
381 double[] r = fr.apply(SPECIES.length());
382 double ra = Double.NEGATIVE_INFINITY;
383
384 for (int ic = 0; ic < INVOC_COUNT; ic++) {
385 for (int i = 0; i < a.length; i += SPECIES.length()) {
386 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
387 r[i] = av.maxAll();
388 }
389 }
390
391 for (int ic = 0; ic < INVOC_COUNT; ic++) {
392 ra = Double.NEGATIVE_INFINITY;
393 for (int i = 0; i < a.length; i += SPECIES.length()) {
394 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
395 ra = (double)Math.max(ra, av.maxAll());
396 }
397 }
398
399 bh.consume(ra);
400 bh.consume(r);
401 }
402
403
404
405 @Benchmark
406 public void with(Blackhole bh) {
407 double[] a = fa.apply(SPECIES.length());
408 double[] r = fr.apply(SPECIES.length());
409
410 for (int ic = 0; ic < INVOC_COUNT; ic++) {
411 for (int i = 0; i < a.length; i += SPECIES.length()) {
412 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
413 av.with(0, (double)4).intoArray(r, i);
414 }
415 }
416
417 bh.consume(r);
418 }
419
420 @Benchmark
|
1 /*
2 * Copyright (c) 2018, 2019, 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
21 * questions.
22 */
286 double[] b = fb.apply(SPECIES.length());
287 double[] r = fr.apply(SPECIES.length());
288
289 for (int ic = 0; ic < INVOC_COUNT; ic++) {
290 for (int i = 0; i < a.length; i += SPECIES.length()) {
291 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
292 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
293 av.min(bv).intoArray(r, i);
294 }
295 }
296
297 bh.consume(r);
298 }
299
300
301
302
303 @Benchmark
304 public void addAll(Blackhole bh) {
305 double[] a = fa.apply(SPECIES.length());
306 double ra = 0;
307
308 for (int ic = 0; ic < INVOC_COUNT; ic++) {
309 ra = 0;
310 for (int i = 0; i < a.length; i += SPECIES.length()) {
311 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
312 ra += av.addAll();
313 }
314 }
315 bh.consume(ra);
316 }
317
318 @Benchmark
319 public void mulAll(Blackhole bh) {
320 double[] a = fa.apply(SPECIES.length());
321 double ra = 1;
322
323 for (int ic = 0; ic < INVOC_COUNT; ic++) {
324 ra = 1;
325 for (int i = 0; i < a.length; i += SPECIES.length()) {
326 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
327 ra *= av.mulAll();
328 }
329 }
330 bh.consume(ra);
331 }
332
333 @Benchmark
334 public void minAll(Blackhole bh) {
335 double[] a = fa.apply(SPECIES.length());
336 double ra = Double.POSITIVE_INFINITY;
337
338 for (int ic = 0; ic < INVOC_COUNT; ic++) {
339 ra = Double.POSITIVE_INFINITY;
340 for (int i = 0; i < a.length; i += SPECIES.length()) {
341 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
342 ra = (double)Math.min(ra, av.minAll());
343 }
344 }
345 bh.consume(ra);
346 }
347
348 @Benchmark
349 public void maxAll(Blackhole bh) {
350 double[] a = fa.apply(SPECIES.length());
351 double ra = Double.NEGATIVE_INFINITY;
352
353 for (int ic = 0; ic < INVOC_COUNT; ic++) {
354 ra = Double.NEGATIVE_INFINITY;
355 for (int i = 0; i < a.length; i += SPECIES.length()) {
356 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
357 ra = (double)Math.max(ra, av.maxAll());
358 }
359 }
360 bh.consume(ra);
361 }
362
363
364
365 @Benchmark
366 public void with(Blackhole bh) {
367 double[] a = fa.apply(SPECIES.length());
368 double[] r = fr.apply(SPECIES.length());
369
370 for (int ic = 0; ic < INVOC_COUNT; ic++) {
371 for (int i = 0; i < a.length; i += SPECIES.length()) {
372 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
373 av.with(0, (double)4).intoArray(r, i);
374 }
375 }
376
377 bh.consume(r);
378 }
379
380 @Benchmark
|