1 #!/bin/bash 2 # 3 # Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 # 6 # This code is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 only, as 8 # published by the Free Software Foundation. Oracle designates this 9 # particular file as subject to the "Classpath" exception as provided 10 # by Oracle in the LICENSE file that accompanied this code. 11 # 12 # This code is distributed in the hope that it will be useful, but WITHOUT 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 # version 2 for more details (a copy is included in the LICENSE file that 16 # accompanied this code). 17 # 18 # You should have received a copy of the GNU General Public License version 19 # 2 along with this work; if not, write to the Free Software Foundation, 20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 # 22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 # or visit www.oracle.com if you need additional information or have 24 # questions. 25 # 26 27 . config.sh 28 29 # First, generate the template file. 30 bash ./gen-template.sh 31 32 Log false "Generating Vector API tests, $(date)\n" 33 34 # Compile SPP 35 Log true "Compiling SPP... " 36 compilation=$(${JAVAC} -d . "${JDK_SRC_HOME}/make/jdk/src/classes/build/tools/spp/Spp.java") 37 Log false "$compilation\n" 38 Log true "done\n" 39 40 # For each type 41 for type in byte short int long float double 42 do 43 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 44 TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" 45 args="-K$type -Dtype=$type -DType=$Type -DTYPE=$TYPE" 46 47 Boxtype=$Type 48 Wideboxtype=$Boxtype 49 50 kind=BITWISE 51 52 bitstype=$type 53 Bitstype=$Type 54 Boxbitstype=$Boxtype 55 56 fptype=$type 57 Fptype=$Type 58 Boxfptype=$Boxtype 59 60 case $type in 61 byte) 62 Wideboxtype=Byte 63 args="$args -KbyteOrShort" 64 ;; 65 short) 66 Wideboxtype=Short 67 args="$args -KbyteOrShort" 68 ;; 69 int) 70 Boxtype=Integer 71 Wideboxtype=Integer 72 fptype=float 73 Fptype=Float 74 Boxfptype=Float 75 args="$args -KintOrLong" 76 ;; 77 long) 78 Wideboxtype=Long 79 fptype=double 80 Fptype=Double 81 Boxfptype=Double 82 args="$args -KintOrLong" 83 ;; 84 float) 85 kind=FP 86 bitstype=int 87 Bitstype=Int 88 Boxbitstype=Integer 89 ;; 90 double) 91 kind=FP 92 bitstype=long 93 Bitstype=Long 94 Boxbitstype=Long 95 ;; 96 esac 97 98 args="$args -K$kind -K$Type -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype" 99 args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" 100 args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" 101 102 abstractvectortype=${typeprefix}${Type}Vector 103 abstractvectorteststype=${typeprefix}${Type}VectorTests 104 abstractbitsvectortype=${typeprefix}${Bitstype}Vector 105 abstractfpvectortype=${typeprefix}${Fptype}Vector 106 args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" 107 108 # Generate tests for operations 109 # For each size 110 Log true "${Type}:" 111 112 for bits in 64 128 256 512 Max 113 do 114 vectortype=${typeprefix}${Type}${bits}Vector 115 vectorteststype=${typeprefix}${Type}${bits}VectorTests 116 vectorbenchtype=${typeprefix}${Type}${bits}Vector 117 masktype=${typeprefix}${Type}${bits}Mask 118 bitsvectortype=${typeprefix}${Bitstype}${bits}Vector 119 fpvectortype=${typeprefix}${Fptype}${bits}Vector 120 shape=S${bits}Bit 121 Shape=S_${bits}_BIT 122 bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" 123 if [ $bits == 'Max' ]; then 124 bitargs="$bitargs -KMaxBit" 125 fi 126 127 128 # Generate jtreg tests 129 Log true " ${bits}_jtreg" 130 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " 131 TEST_DEST_FILE="${vectorteststype}.java" 132 rm -f ${TEST_DEST_FILE} 133 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 134 -i${TEMPLATE_FILE} \ 135 -o${TEST_DEST_FILE} 136 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 137 tr -d '\r' < ${TEST_DEST_FILE} > temp 138 mv temp ${TEST_DEST_FILE} 139 fi 140 141 # Generate jmh performance tests 142 Log true " ${bits}_jmh" 143 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " 144 PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" 145 rm -f ${PERF_DEST_FILE} 146 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 147 -i${PERF_TEMPLATE_FILE} \ 148 -o${PERF_DEST_FILE} 149 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 150 tr -d '\r' < ${PERF_DEST_FILE} > temp 151 mv temp ${PERF_DEST_FILE} 152 fi 153 done 154 155 # Generate jmh performance tests 156 Log true " scalar" 157 PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" 158 rm -f ${PERF_DEST_FILE} 159 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ 160 -i${PERF_SCALAR_TEMPLATE_FILE} \ 161 -o${PERF_DEST_FILE} 162 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 163 tr -d '\r' < ${PERF_DEST_FILE} > temp 164 mv temp ${PERF_DEST_FILE} 165 fi 166 167 168 # Generate tests for loads and stores 169 # For each size 170 for bits in 64 128 256 512 Max 171 do 172 vectortype=${typeprefix}${Type}${bits}Vector 173 vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests 174 vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore 175 masktype=${typeprefix}${Type}${bits}Mask 176 bitsvectortype=${typeprefix}${Bitstype}${bits}Vector 177 fpvectortype=${typeprefix}${Fptype}${bits}Vector 178 shape=S${bits}Bit 179 Shape=S_${bits}_BIT 180 bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" 181 if [ $bits == 'Max' ]; then 182 bitargs="$bitargs -KMaxBit" 183 fi 184 185 # Generate 186 Log true " ${bits}_ls" 187 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -itemplates/X-LoadStoreTest.java.template -o$vectorteststype.java " 188 TEST_DEST_FILE="${vectorteststype}.java" 189 rm -f ${TEST_DEST_FILE} 190 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 191 -itemplates/X-LoadStoreTest.java.template \ 192 -o${TEST_DEST_FILE} 193 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 194 tr -d '\r' < ${TEST_DEST_FILE} > temp 195 mv temp ${TEST_DEST_FILE} 196 fi 197 198 # TODO: Generate jmh performance tests for LoadStore variants 199 done 200 201 Log true " done\n" 202 203 done 204 205 rm -fr build 206