hotspot/test/compiler/loopopts/superword/ReductionPerf.java
author stsmirno
Mon, 17 Oct 2016 18:54:12 -0400
changeset 41705 332239c052cc
parent 40059 c2304140ed64
permissions -rw-r--r--
8165687: Fix license and copyright headers in jd9 under hotspot/test Summary: Legal notices and Oracle copyrights were updated (white and blank space, commas) in tests files for uniformity to meet Oracle requirements. Reviewed-by: dholmes, iris Contributed-by: Stanislav Smirnov <stanislav.smirnov@oracle.com>, Vassili Igouchkine <vassili.igouchkine@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     1
/*
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     4
 *
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     8
 *
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    13
 * accompanied this code).
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    14
 *
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    18
 *
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    21
 * questions.
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    22
 */
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    23
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    24
/**
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    25
 * @test
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    26
 * @bug 8074981
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    27
 * @summary Add C2 x86 Superword support for scalar product reduction optimizations : int test
36057
867e857daf84 8149123: [TESTBUG] compiler/loopopts/superword/SumRed* tests running on non-x86 platforms
thartmann
parents: 30588
diff changeset
    28
 * @requires os.arch=="x86" | os.arch=="i386" | os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64"
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    29
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    30
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    31
 *      -XX:LoopUnrollLimit=250 -XX:CompileThresholdScaling=0.1
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    32
 *      -XX:CompileCommand=exclude,compiler.loopopts.superword.ReductionPerf::main
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    33
 *      -XX:+SuperWordReductions
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    34
 *      compiler.loopopts.superword.ReductionPerf
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    35
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    36
 *      -XX:LoopUnrollLimit=250 -XX:CompileThresholdScaling=0.1
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    37
 *      -XX:CompileCommand=exclude,compiler.loopopts.superword.ReductionPerf::main
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    38
 *      -XX:-SuperWordReductions
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    39
 *      compiler.loopopts.superword.ReductionPerf
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    40
 */
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    41
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    42
package compiler.loopopts.superword;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    43
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    44
public class ReductionPerf {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    45
    public static void main(String[] args) throws Exception {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    46
        int[] a1 = new int[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    47
        int[] a2 = new int[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    48
        int[] a3 = new int[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    49
        long[] b1 = new long[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    50
        long[] b2 = new long[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    51
        long[] b3 = new long[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    52
        float[] c1 = new float[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    53
        float[] c2 = new float[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    54
        float[] c3 = new float[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    55
        double[] d1 = new double[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    56
        double[] d2 = new double[8 * 1024];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    57
        double[] d3 = new double[8 * 1024];
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    58
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    59
        ReductionInit(a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    60
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    61
        int sumIv = sumInt(a1, a2, a3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    62
        long sumLv = sumLong(b1, b2, b3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    63
        float sumFv = sumFloat(c1, c2, c3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    64
        double sumDv = sumDouble(d1, d2, d3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    65
        int mulIv = prodInt(a1, a2, a3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    66
        long mulLv = prodLong(b1, b2, b3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    67
        float mulFv = prodFloat(c1, c2, c3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    68
        double mulDv = prodDouble(d1, d2, d3);
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    69
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    70
        int sumI = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    71
        long sumL = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    72
        float sumF = 0.f;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    73
        double sumD = 0.;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    74
        int mulI = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    75
        long mulL = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    76
        float mulF = 0.f;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    77
        double mulD = 0.;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    78
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    79
        System.out.println("Warmup ...");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    80
        long start = System.currentTimeMillis();
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    81
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    82
        for (int j = 0; j < 2000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    83
            sumI = sumInt(a1, a2, a3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    84
            sumL = sumLong(b1, b2, b3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    85
            sumF = sumFloat(c1, c2, c3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    86
            sumD = sumDouble(d1, d2, d3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    87
            mulI = prodInt(a1, a2, a3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    88
            mulL = prodLong(b1, b2, b3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    89
            mulF = prodFloat(c1, c2, c3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    90
            mulD = prodDouble(d1, d2, d3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    91
        }
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    92
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    93
        long stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    94
        System.out.println(" Warmup is done in " + (stop - start) + " msec");
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
    95
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    96
        if (sumIv != sumI) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    97
            System.out.println("sum int:    " + sumIv + " != " + sumI);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    98
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
    99
        if (sumLv != sumL) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   100
            System.out.println("sum long:   " + sumLv + " != " + sumL);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   101
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   102
        if (sumFv != sumF) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   103
            System.out.println("sum float:  " + sumFv + " != " + sumF);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   104
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   105
        if (sumDv != sumD) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   106
            System.out.println("sum double: " + sumDv + " != " + sumD);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   107
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   108
        if (mulIv != mulI) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   109
            System.out.println("prod int:    " + mulIv + " != " + mulI);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   110
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   111
        if (mulLv != mulL) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   112
            System.out.println("prod long:   " + mulLv + " != " + mulL);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   113
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   114
        if (mulFv != mulF) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   115
            System.out.println("prod float:  " + mulFv + " != " + mulF);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   116
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   117
        if (mulDv != mulD) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   118
            System.out.println("prod double: " + mulDv + " != " + mulD);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   119
        }
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   120
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   121
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   122
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   123
            sumI = sumInt(a1, a2, a3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   124
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   125
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   126
        System.out.println("sum int:    " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   127
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   128
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   129
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   130
            sumL = sumLong(b1, b2, b3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   131
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   132
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   133
        System.out.println("sum long:   " + (stop - start));
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   134
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   135
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   136
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   137
            sumF = sumFloat(c1, c2, c3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   138
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   139
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   140
        System.out.println("sum float:  " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   141
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   142
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   143
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   144
            sumD = sumDouble(d1, d2, d3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   145
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   146
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   147
        System.out.println("sum double: " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   148
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   149
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   150
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   151
            mulI = prodInt(a1, a2, a3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   152
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   153
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   154
        System.out.println("prod int:    " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   155
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   156
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   157
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   158
            mulL = prodLong(b1, b2, b3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   159
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   160
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   161
        System.out.println("prod long:   " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   162
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   163
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   164
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   165
            mulF = prodFloat(c1, c2, c3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   166
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   167
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   168
        System.out.println("prod float:  " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   169
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   170
        start = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   171
        for (int j = 0; j < 5000; j++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   172
            mulD = prodDouble(d1, d2, d3);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   173
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   174
        stop = System.currentTimeMillis();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   175
        System.out.println("prod double: " + (stop - start));
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   176
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   177
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   178
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   179
    public static void ReductionInit(int[] a1, int[] a2, int[] a3,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   180
                                     long[] b1, long[] b2, long[] b3,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   181
                                     float[] c1, float[] c2, float[] c3,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   182
                                     double[] d1, double[] d2, double[] d3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   183
        for(int i = 0; i < a1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   184
            a1[i] =          (i + 0);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   185
            a2[i] =          (i + 1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   186
            a3[i] =          (i + 2);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   187
            b1[i] =   (long) (i + 0);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   188
            b2[i] =   (long) (i + 1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   189
            b3[i] =   (long) (i + 2);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   190
            c1[i] =  (float) (i + 0);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   191
            c2[i] =  (float) (i + 1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   192
            c3[i] =  (float) (i + 2);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   193
            d1[i] = (double) (i + 0);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   194
            d2[i] = (double) (i + 1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   195
            d3[i] = (double) (i + 2);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   196
        }
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   197
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   198
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   199
    public static int sumInt(int[] a1, int[] a2, int[] a3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   200
        int total = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   201
        for (int i = 0; i < a1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   202
            total += (a1[i] * a2[i]) + (a1[i] * a3[i]) + (a2[i] * a3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   203
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   204
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   205
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   206
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   207
    public static long sumLong(long[] b1, long[] b2, long[] b3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   208
        long total = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   209
        for (int i = 0; i < b1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   210
            total += (b1[i] * b2[i]) + (b1[i] * b3[i]) + (b2[i] * b3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   211
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   212
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   213
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   214
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   215
    public static float sumFloat(float[] c1, float[] c2, float[] c3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   216
        float total = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   217
        for (int i = 0; i < c1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   218
            total += (c1[i] * c2[i]) + (c1[i] * c3[i]) + (c2[i] * c3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   219
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   220
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   221
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   222
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   223
    public static double sumDouble(double[] d1, double[] d2, double[] d3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   224
        double total = 0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   225
        for (int i = 0; i < d1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   226
            total += (d1[i] * d2[i]) + (d1[i] * d3[i]) + (d2[i] * d3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   227
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   228
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   229
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   230
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   231
    public static int prodInt(int[] a1, int[] a2, int[] a3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   232
        int total = 1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   233
        for (int i = 0; i < a1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   234
            total *= (a1[i] * a2[i]) + (a1[i] * a3[i]) + (a2[i] * a3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   235
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   236
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   237
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   238
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   239
    public static long prodLong(long[] b1, long[] b2, long[] b3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   240
        long total = 1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   241
        for (int i = 0; i < b1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   242
            total *= (b1[i] * b2[i]) + (b1[i] * b3[i]) + (b2[i] * b3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   243
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   244
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   245
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   246
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   247
    public static float prodFloat(float[] c1, float[] c2, float[] c3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   248
        float total = 1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   249
        for (int i = 0; i < c1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   250
            total *= (c1[i] * c2[i]) + (c1[i] * c3[i]) + (c2[i] * c3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   251
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   252
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   253
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   254
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   255
    public static double prodDouble(double[] d1, double[] d2, double[] d3) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   256
        double total = 1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   257
        for (int i = 0; i < d1.length; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   258
            total *= (d1[i] * d2[i]) + (d1[i] * d3[i]) + (d2[i] * d3[i]);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   259
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36057
diff changeset
   260
        return total;
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   261
    }
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents:
diff changeset
   262
}