test/hotspot/jtreg/compiler/loopopts/superword/Vec_MulAddS2I.java
author shade
Tue, 10 Sep 2019 19:58:22 +0200
changeset 58079 8db87a43a1ce
parent 52992 4bb6e0871bf7
permissions -rw-r--r--
8230813: Add JDK-8010500 to compiler/loopopts/superword/TestFuzzPreLoop.java bug list Reviewed-by: zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52992
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     1
/*
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     4
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     8
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    13
 * accompanied this code).
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    14
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    18
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    21
 * questions.
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    22
 */
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    23
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    24
/**
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    25
 * @test
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    26
 * @bug 8214751
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    27
 * @summary Add C2 x86 Superword support for VNNI VPDPWSSD Instruction
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    28
 * @requires os.arch=="x86" | os.arch=="i386" | os.arch=="amd64" | os.arch=="x86_64"
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    29
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    30
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    31
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    32
 *      -XX:+SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    33
 *      -XX:LoopMaxUnroll=2
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    34
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    35
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    36
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    37
 *      -XX:-SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    38
 *      -XX:LoopMaxUnroll=2
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    39
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    40
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    41
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    42
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    43
 *      -XX:+SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    44
 *      -XX:LoopMaxUnroll=4
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    45
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    46
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    47
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    48
 *      -XX:-SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    49
 *      -XX:LoopMaxUnroll=4
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    50
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    51
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    52
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    53
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    54
 *      -XX:+SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    55
 *      -XX:LoopMaxUnroll=8
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    56
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    57
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    58
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    59
 *      -XX:-SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    60
 *      -XX:LoopMaxUnroll=8
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    61
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    62
 *
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    63
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    64
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    65
 *      -XX:+SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    66
 *      -XX:LoopMaxUnroll=16
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    67
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    68
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    69
 *      -XX:CompileThresholdScaling=0.1
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    70
 *      -XX:-SuperWord
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    71
 *      -XX:LoopMaxUnroll=16
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    72
 *      compiler.loopopts.superword.Vec_MulAddS2I
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    73
 */
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    74
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    75
package compiler.loopopts.superword;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    76
import java.util.Random;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    77
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    78
public class Vec_MulAddS2I {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    79
        static final int NUM = 1024;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    80
        static int[] out =  new int[NUM];
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    81
        static short[] in1 = new short[2*NUM];
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    82
        static short[] in2 = new short[2*NUM];
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    83
    public static void main(String[] args) throws Exception {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    84
        Vec_MulAddS2IInit(in1, in2);
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    85
        int result = 0;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    86
        int valid = 204800000;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    87
        for (int j = 0; j < 10000*512; j++) {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    88
            result = Vec_MulAddS2IImplement(in1, in2, out);
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    89
        }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    90
        if (result == valid) {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    91
            System.out.println("Success");
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    92
        } else {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    93
            System.out.println("Invalid calculation of element variables in the out array: " + result);
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    94
            System.out.println("Expected value for each element of out array = " + valid);
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    95
            throw new Exception("Failed");
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    96
        }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    97
    }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    98
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
    99
    public static void Vec_MulAddS2IInit(
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   100
            short[] in1,
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   101
            short[] in2) {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   102
        for (int i=0; i<2*NUM; i++) {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   103
            in1[i] = (short)4;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   104
            in2[i] = (short)5;
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   105
        }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   106
    }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   107
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   108
    public static int Vec_MulAddS2IImplement(
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   109
            short[] in1,
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   110
            short[] in2,
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   111
            int[] out) {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   112
        for (int i = 0; i < NUM; i++) {
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   113
            out[i] += ((in1[2*i] * in2[2*i]) + (in1[2*i+1] * in2[2*i+1]));
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   114
        }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   115
        Random rand = new Random();
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   116
        int n = rand.nextInt(NUM-1);
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   117
        return out[n];
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   118
    }
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   119
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents:
diff changeset
   120
}