hotspot/test/compiler/intrinsics/zip/TestCRC32.java
author zmajo
Wed, 19 Apr 2017 14:37:11 +0200
changeset 44737 d090627aedb8
parent 40059 c2304140ed64
permissions -rw-r--r--
8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720) Summary: Disable CRC32C intrinsic on affected machines. Improve tests. Reviewed-by: kvn, simonis, mdoerr, aph Contributed-by: Lutz Schmidt <lutz.schmidt@sap.com>, Zoltan Majo <zoltan.majo@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     1
/*
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     4
 *
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     8
 *
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    13
 * accompanied this code).
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    14
 *
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    18
 *
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    21
 * questions.
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    22
 */
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    23
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    24
/**
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    25
 * @test
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    26
 * @bug 8143012
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    27
 * @summary CRC32 Intrinsics support on SPARC
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34205
diff changeset
    29
 * @run main/othervm/timeout=720 -Xbatch compiler.intrinsics.zip.TestCRC32 -m
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    30
 */
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    31
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34205
diff changeset
    32
package compiler.intrinsics.zip;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34205
diff changeset
    33
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    34
import java.nio.ByteBuffer;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34205
diff changeset
    35
import java.util.zip.CRC32;
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    36
import java.util.zip.Checksum;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    37
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    38
public class TestCRC32 {
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    39
    // standard CRC32 polynomial
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    40
    // coefficients in different forms
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    41
    // normal:              polyBits = 0x04c11db7   = 0b0000 0100 1100 0001 0001 1101 1011 0111
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    42
    // reversed:            polybits = 0xedb88320   = 0b1110 1101 1011 1000 1000 0011 0010 0000
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    43
    // reversed reciprocal  polybits = 0x82608edb   = 0b1000 0010 0110 0000 1000 1110 1101 1011
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    44
    //
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    45
    //                                                  0      5    9    13   17   21   25   29
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    46
    //                                                  |      |    |    |    |    |    |    |
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    47
    // reversed shiftL 1    polyBits = 0x1db710641L = 0b1 1101 1011 0111 0001 0000 0110 0100 0001
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    48
    final static long polyBits = (1L<<(32-32)) + (1L<<(32-26)) + (1L<<(32-23)) + (1L<<(32-22))
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    49
                               + (1L<<(32-16)) + (1L<<(32-12)) + (1L<<(32-11)) + (1L<<(32-10))
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    50
                               + (1L<<(32-8))  + (1L<<(32-7))  + (1L<<(32-5))  + (1L<<(32-4))
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    51
                               + (1L<<(32-2))  + (1L<<(32-1))  + (1L<<(32-0));
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    52
    final static long polyBitsShifted = polyBits>>1;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    53
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    54
    public static void main(String[] args) throws Exception {
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    55
        int offset = Integer.getInteger("offset", 0);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    56
        int msgSize = Integer.getInteger("msgSize", 512);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    57
        boolean multi = false;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    58
        int iters = 20000;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    59
        int warmupIters = 20000;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    60
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    61
        if (args.length > 0) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    62
            if (args[0].equals("-m")) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    63
                multi = true;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    64
            } else {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    65
                iters = Integer.valueOf(args[0]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    66
            }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    67
            if (args.length > 1) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    68
                warmupIters = Integer.valueOf(args[1]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    69
            }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    70
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    71
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    72
        if (multi) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    73
            test_multi(warmupIters);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    74
            return;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    75
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    76
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    77
        System.out.println(" offset = " + offset);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    78
        System.out.println("msgSize = " + msgSize + " bytes");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    79
        System.out.println("  iters = " + iters);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    80
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    81
        byte[] b = initializedBytes(msgSize, offset);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    82
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    83
        final long crcReference = update_byteLoop(0, b, offset);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    84
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    85
        CRC32 crc0 = new CRC32();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    86
        CRC32 crc1 = new CRC32();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    87
        CRC32 crc2 = new CRC32();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    88
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    89
        crc0.update(b, offset, msgSize);
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    90
        check(crc0, crcReference);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    91
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    92
        System.out.println("-------------------------------------------------------");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    93
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    94
        /* warm up */
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    95
        for (int i = 0; i < warmupIters; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    96
            crc1.reset();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    97
            crc1.update(b, offset, msgSize);
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
    98
            check(crc1, crcReference);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
    99
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   100
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   101
        /* check correctness
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   102
         * Do that before measuring performance
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   103
         * to even better heat up involved methods.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   104
         */
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   105
        for (int i = 0; i < iters; i++) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   106
            crc1.reset();
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   107
            crc1.update(b, offset, msgSize);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   108
            check(crc1, crcReference);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   109
        }
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   110
        report("CRCs", crc1, crcReference);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   111
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   112
        /* measure performance
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   113
         * Don't spoil times with error checking.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   114
         */
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   115
        long start = System.nanoTime();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   116
        for (int i = 0; i < iters; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   117
            crc1.reset();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   118
            crc1.update(b, offset, msgSize);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   119
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   120
        long end = System.nanoTime();
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   121
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   122
        double total = (double)(end - start)/1e9;         // in seconds
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   123
        double thruput = (double)msgSize*iters/1e6/total; // in MB/s
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   124
        System.out.println("CRC32.update(byte[]) runtime = " + total + " seconds");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   125
        System.out.println("CRC32.update(byte[]) throughput = " + thruput + " MB/s");
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   126
        report("CRCs", crc1, crcReference);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   127
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   128
        System.out.println("-------------------------------------------------------");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   129
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   130
        ByteBuffer buf = ByteBuffer.allocateDirect(msgSize);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   131
        buf.put(b, offset, msgSize);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   132
        buf.flip();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   133
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   134
        /* warm up */
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   135
        for (int i = 0; i < warmupIters; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   136
            crc2.reset();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   137
            crc2.update(buf);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   138
            buf.rewind();
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   139
            check(crc2, crcReference);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   140
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   141
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   142
        /* check correctness
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   143
         * Do that before measuring performance
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   144
         * to even better heat up involved methods.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   145
         */
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   146
        for (int i = 0; i < iters; i++) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   147
            crc2.reset();
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   148
            crc2.update(buf);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   149
            buf.rewind();
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   150
            check(crc2, crcReference);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   151
        }
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   152
        report("CRCs", crc2, crcReference);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   153
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   154
        /* measure performance
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   155
         * Don't spoil times with error checking.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   156
         */
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   157
        start = System.nanoTime();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   158
        for (int i = 0; i < iters; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   159
            crc2.reset();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   160
            crc2.update(buf);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   161
            buf.rewind();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   162
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   163
        end = System.nanoTime();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   164
        total = (double)(end - start)/1e9;         // in seconds
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   165
        thruput = (double)msgSize*iters/1e6/total; // in MB/s
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   166
        System.out.println("CRC32.update(ByteBuffer) runtime = " + total + " seconds");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   167
        System.out.println("CRC32.update(ByteBuffer) throughput = " + thruput + " MB/s");
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   168
        report("CRCs", crc2, crcReference);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   169
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   170
        System.out.println("-------------------------------------------------------");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   171
    }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   172
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   173
    // Just a loop over a byte array, updating the CRC byte by byte.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   174
    public static long update_byteLoop(long crc, byte[] buf, int offset) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   175
        return update_byteLoop(crc, buf, offset, buf.length-offset);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   176
    }
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   177
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   178
    // Just a loop over a byte array, with given length, updating the CRC byte by byte.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   179
    public static long update_byteLoop(long crc, byte[] buf, int offset, int length) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   180
        int end = length+offset;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   181
        for (int i = offset; i < end; i++) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   182
            crc = update_singlebyte(crc, polyBitsShifted, buf[i]);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   183
        }
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   184
        return crc;
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   185
    }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   186
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   187
    // Straight-forward implementation of CRC update by one byte.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   188
    // We use this very basic implementation to calculate reference
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   189
    // results. It is necessary to have full control over how the
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   190
    // reference results are calculated. It is not sufficient to rely
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   191
    // on the interpreter (or c1, or c2) to do the right thing.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   192
    public static long update_singlebyte(long crc, long polynomial, int val) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   193
        crc = (crc ^ -1L) & 0x00000000ffffffffL;  // use 1's complement of crc
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   194
        crc =  crc ^ (val&0xff);                  // XOR in next byte from stream
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   195
        for (int i = 0; i <  8; i++) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   196
            boolean bitset = (crc & 0x01L) != 0;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   197
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   198
            crc = crc>>1;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   199
            if (bitset) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   200
                crc = crc ^ polynomial;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   201
                crc = crc & 0x00000000ffffffffL;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   202
            }
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   203
        }
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   204
        crc = (crc ^ -1L) & 0x00000000ffffffffL;  // revert taking 1's complement
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   205
        return crc;
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   206
    }
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   207
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   208
    private static void report(String s, Checksum crc, long crcReference) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   209
        System.out.printf("%s: crc = %08x, crcReference = %08x\n",
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   210
                          s, crc.getValue(), crcReference);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   211
    }
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   212
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   213
    private static void check(Checksum crc, long crcReference) throws Exception {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   214
        if (crc.getValue() != crcReference) {
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   215
            System.err.printf("ERROR: crc = %08x, crcReference = %08x\n",
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   216
                              crc.getValue(), crcReference);
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   217
            throw new Exception("TestCRC32 Error");
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   218
        }
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   219
    }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   220
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   221
    private static byte[] initializedBytes(int M, int offset) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   222
        byte[] bytes = new byte[M + offset];
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   223
        for (int i = 0; i < offset; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   224
            bytes[i] = (byte) i;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   225
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   226
        for (int i = offset; i < bytes.length; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   227
            bytes[i] = (byte) (i - offset);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   228
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   229
        return bytes;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   230
    }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   231
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   232
    private static void test_multi(int iters) throws Exception {
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   233
        int len1 = 8;    // the  8B/iteration loop
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   234
        int len2 = 32;   // the 32B/iteration loop
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   235
        int len3 = 4096; // the 4KB/iteration loop
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   236
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   237
        byte[] b = initializedBytes(len3*16, 0);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   238
        int[] offsets = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32, 64, 128, 256, 512 };
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   239
        int[] sizes = { 0, 1, 2, 3, 4, 5, 6, 7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   240
                        len1, len1+1, len1+2, len1+3, len1+4, len1+5, len1+6, len1+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   241
                        len1*2, len1*2+1, len1*2+3, len1*2+5, len1*2+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   242
                        len2, len2+1, len2+3, len2+5, len2+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   243
                        len2*2, len2*4, len2*8, len2*16, len2*32, len2*64,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   244
                        len3, len3+1, len3+3, len3+5, len3+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   245
                        len3*2, len3*4, len3*8,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   246
                        len1+len2, len1+len2+1, len1+len2+3, len1+len2+5, len1+len2+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   247
                        len1+len3, len1+len3+1, len1+len3+3, len1+len3+5, len1+len3+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   248
                        len2+len3, len2+len3+1, len2+len3+3, len2+len3+5, len2+len3+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   249
                        len1+len2+len3, len1+len2+len3+1, len1+len2+len3+3,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   250
                        len1+len2+len3+5, len1+len2+len3+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   251
                        (len1+len2+len3)*2, (len1+len2+len3)*2+1, (len1+len2+len3)*2+3,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   252
                        (len1+len2+len3)*2+5, (len1+len2+len3)*2+7,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   253
                        (len1+len2+len3)*3, (len1+len2+len3)*3-1, (len1+len2+len3)*3-3,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   254
                        (len1+len2+len3)*3-5, (len1+len2+len3)*3-7 };
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   255
        CRC32[] crc1 = new CRC32[offsets.length*sizes.length];
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   256
        long[] crcReference = new long[offsets.length*sizes.length];
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   257
        int i, j, k;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   258
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   259
        System.out.printf("testing %d cases ...\n", offsets.length*sizes.length);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   260
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   261
        // Initialize CRC32 result arrays, CRC32 reference array.
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   262
        // Reference is calculated using a very basic Java implementation.
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   263
        for (i = 0; i < offsets.length; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   264
            for (j = 0; j < sizes.length; j++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   265
                crc1[i*sizes.length + j] = new CRC32();
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   266
                crcReference[i*sizes.length + j] = update_byteLoop(0, b, offsets[i], sizes[j]);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   267
            }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   268
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   269
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   270
        // Warm up the JIT compiler. Over time, all methods involved will
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   271
        // be executed by the interpreter, then get compiled by c1 and
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   272
        // finally by c2. Each calculated CRC value must, in each iteration,
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   273
        // be equal to the precalculated reference value for the test to pass.
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   274
        for (k = 0; k < iters; k++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   275
            for (i = 0; i < offsets.length; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   276
                for (j = 0; j < sizes.length; j++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   277
                    crc1[i*sizes.length + j].reset();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   278
                    crc1[i*sizes.length + j].update(b, offsets[i], sizes[j]);
44737
d090627aedb8 8178723: Workaround for failure of CRC32C intrinsic on x86 machines without CLMUL support (JDK-8178720)
zmajo
parents: 40059
diff changeset
   279
                    check(crc1[i*sizes.length + j], crcReference[i*sizes.length + j]);
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   280
                }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   281
            }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   282
        }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   283
    }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents:
diff changeset
   284
}