1 #!/bin/bash 2 # 3 # Copyright (c) 2018, 2021, 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 any 24 # questions. 25 # 26 27 # For manual invocation. 28 # You can regenerate the source files, 29 # and you can clean them up. 30 # FIXME: Move this script under $REPO/make/gensrc/ 31 case $* in 32 '') CLASS_FILTER='*';; 33 --generate*) CLASS_FILTER=${2-'*'};; 34 --help|*) echo "Usage: $0 [--generate [file]]"; exit 1;; 35 esac 36 37 . config.sh 38 39 # Detect whether to generate the performance tests 40 generate_perf_tests=false 41 if [ -d "$PERF_DEST" ]; then 42 generate_perf_tests=true 43 fi 44 45 # First, generate the template file. 46 bash ./gen-template.sh $generate_perf_tests 47 48 Log false "Generating Vector API tests, $(date)\n" 49 50 # Compile SPP 51 Log true "Compiling SPP... " 52 compilation=$(${JAVAC} -d . "${JDK_SRC_HOME}/make/jdk/src/classes/build/tools/spp/Spp.java") 53 Log false "$compilation\n" 54 Log true "done\n" 55 56 # For each type 57 for type in byte short int long float double 58 do 59 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 60 TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" 61 args="-K$type -Dtype=$type -DType=$Type -DTYPE=$TYPE" 62 63 Boxtype=$Type 64 Wideboxtype=$Boxtype 65 MaxValue=MAX_VALUE 66 MinValue=MIN_VALUE 67 68 kind=BITWISE 69 70 bitstype=$type 71 Bitstype=$Type 72 Boxbitstype=$Boxtype 73 74 fptype=$type 75 Fptype=$Type 76 Boxfptype=$Boxtype 77 78 case $type in 79 byte) 80 Wideboxtype=Byte 81 args="$args -KbyteOrShort" 82 ;; 83 short) 84 Wideboxtype=Short 85 args="$args -KbyteOrShort" 86 ;; 87 int) 88 Boxtype=Integer 89 Wideboxtype=Integer 90 fptype=float 91 Fptype=Float 92 Boxfptype=Float 93 args="$args -KintOrLong" 94 ;; 95 long) 96 Wideboxtype=Long 97 fptype=double 98 Fptype=Double 99 Boxfptype=Double 100 args="$args -KintOrLong" 101 ;; 102 float) 103 kind=FP 104 bitstype=int 105 Bitstype=Int 106 Boxbitstype=Integer 107 Wideboxtype=Float 108 MaxValue=POSITIVE_INFINITY 109 MinValue=NEGATIVE_INFINITY 110 ;; 111 double) 112 kind=FP 113 bitstype=long 114 Bitstype=Long 115 Boxbitstype=Long 116 Wideboxtype=Double 117 MaxValue=POSITIVE_INFINITY 118 MinValue=NEGATIVE_INFINITY 119 ;; 120 esac 121 122 args="$args -K$kind -K$Type -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype -DMaxValue=$MaxValue -DMinValue=$MinValue" 123 args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" 124 args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" 125 126 abstractvectortype=${typeprefix}${Type}Vector 127 abstractvectorteststype=${typeprefix}${Type}VectorTests 128 abstractbitsvectortype=${typeprefix}${Bitstype}Vector 129 abstractfpvectortype=${typeprefix}${Fptype}Vector 130 args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" 131 132 # Generate tests for operations 133 # For each size 134 Log true "${Type}:" 135 136 for bits in 64 128 256 512 Max 137 do 138 vectortype=${typeprefix}${Type}${bits}Vector 139 vectorteststype=${typeprefix}${Type}${bits}VectorTests 140 vectorbenchtype=${typeprefix}${Type}${bits}Vector 141 masktype=${typeprefix}${Type}${bits}Mask 142 bitsvectortype=${typeprefix}${Bitstype}${bits}Vector 143 fpvectortype=${typeprefix}${Fptype}${bits}Vector 144 shape=S${bits}Bit 145 Shape=S_${bits}_BIT 146 if [[ "${vectortype}" == "ByteMaxVector" ]]; then 147 args="$args -KByteMax" 148 fi 149 bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" 150 if [ $bits == 'Max' ]; then 151 bitargs="$bitargs -KMaxBit" 152 fi 153 154 # Generate jtreg tests 155 case $vectorteststype in 156 $CLASS_FILTER) 157 Log true " ${bits}_jtreg $vectorteststype.java" 158 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " 159 TEST_DEST_FILE="${vectorteststype}.java" 160 rm -f ${TEST_DEST_FILE} 161 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 162 -i${TEMPLATE_FILE} \ 163 -o${TEST_DEST_FILE} 164 if [ VAR_OS_ENV==windows.cygwin ]; then 165 tr -d '\r' < ${TEST_DEST_FILE} > temp 166 mv temp ${TEST_DEST_FILE} 167 fi 168 ;; 169 esac 170 171 if [ $generate_perf_tests == true ]; then 172 # Generate jmh performance tests 173 case $vectorbenchtype in 174 $CLASS_FILTER) 175 Log true " ${bits}_jmh $vectorbenchtype.java" 176 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " 177 PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" 178 rm -f ${PERF_DEST_FILE} 179 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 180 -i${PERF_TEMPLATE_FILE} \ 181 -o${PERF_DEST_FILE} 182 if [ VAR_OS_ENV==windows.cygwin ]; then 183 tr -d '\r' < ${PERF_DEST_FILE} > temp 184 mv temp ${PERF_DEST_FILE} 185 fi 186 ;; 187 esac 188 fi 189 done 190 191 if [ $generate_perf_tests == true ]; then 192 # Generate jmh performance tests 193 case ${Type}Scalar in 194 $CLASS_FILTER) 195 Log true " scalar ${Type}Scalar.java" 196 PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" 197 rm -f ${PERF_DEST_FILE} 198 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ 199 -i${PERF_SCALAR_TEMPLATE_FILE} \ 200 -o${PERF_DEST_FILE} 201 if [ VAR_OS_ENV==windows.cygwin ]; then 202 tr -d '\r' < ${PERF_DEST_FILE} > temp 203 mv temp ${PERF_DEST_FILE} 204 fi 205 ;; 206 esac 207 fi 208 209 # Generate tests for loads and stores 210 # For each size 211 for bits in 64 128 256 512 Max 212 do 213 vectortype=${typeprefix}${Type}${bits}Vector 214 vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests 215 vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore 216 masktype=${typeprefix}${Type}${bits}Mask 217 bitsvectortype=${typeprefix}${Bitstype}${bits}Vector 218 fpvectortype=${typeprefix}${Fptype}${bits}Vector 219 shape=S${bits}Bit 220 Shape=S_${bits}_BIT 221 if [[ "${vectortype}" == "ByteMaxVector" ]]; then 222 args="$args -KByteMax" 223 fi 224 bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" 225 if [ $bits == 'Max' ]; then 226 bitargs="$bitargs -KMaxBit" 227 fi 228 229 # Generate 230 case $vectorteststype in 231 $CLASS_FILTER) 232 Log true " ${bits}_ls $vectorteststype.java" 233 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -itemplates/X-LoadStoreTest.java.template -o$vectorteststype.java " 234 TEST_DEST_FILE="${vectorteststype}.java" 235 rm -f ${TEST_DEST_FILE} 236 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 237 -itemplates/X-LoadStoreTest.java.template \ 238 -o${TEST_DEST_FILE} 239 if [ VAR_OS_ENV==windows.cygwin ]; then 240 tr -d '\r' < ${TEST_DEST_FILE} > temp 241 mv temp ${TEST_DEST_FILE} 242 fi 243 ;; 244 esac 245 246 # TODO: Generate jmh performance tests for LoadStore variants 247 done 248 249 Log true " done\n" 250 251 done 252 253 rm -fr build --- EOF ---