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 if [[ "${vectortype}" == "LongMaxVector" || "${vectortype}" == "DoubleMaxVector" ]]; then 123 args="$args -KlongOrDoubleMax" 124 fi 125 bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" 126 if [ $bits == 'Max' ]; then 127 bitargs="$bitargs -KMaxBit" 128 fi 129 130 131 # Generate jtreg tests 132 Log true " ${bits}_jtreg" 133 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " 134 TEST_DEST_FILE="${vectorteststype}.java" 135 rm -f ${TEST_DEST_FILE} 136 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 137 -i${TEMPLATE_FILE} \ 138 -o${TEST_DEST_FILE} 139 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 140 tr -d '\r' < ${TEST_DEST_FILE} > temp 141 mv temp ${TEST_DEST_FILE} 142 fi 143 144 # Generate jmh performance tests 145 Log true " ${bits}_jmh" 146 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " 147 PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" 148 rm -f ${PERF_DEST_FILE} 149 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 150 -i${PERF_TEMPLATE_FILE} \ 151 -o${PERF_DEST_FILE} 152 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 153 tr -d '\r' < ${PERF_DEST_FILE} > temp 154 mv temp ${PERF_DEST_FILE} 155 fi 156 done 157 158 # Generate jmh performance tests 159 Log true " scalar" 160 PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" 161 rm -f ${PERF_DEST_FILE} 162 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ 163 -i${PERF_SCALAR_TEMPLATE_FILE} \ 164 -o${PERF_DEST_FILE} 165 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 166 tr -d '\r' < ${PERF_DEST_FILE} > temp 167 mv temp ${PERF_DEST_FILE} 168 fi 169 170 171 # Generate tests for loads and stores 172 # For each size 173 for bits in 64 128 256 512 Max 174 do 175 vectortype=${typeprefix}${Type}${bits}Vector 176 vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests 177 vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore 178 masktype=${typeprefix}${Type}${bits}Mask 179 bitsvectortype=${typeprefix}${Bitstype}${bits}Vector 180 fpvectortype=${typeprefix}${Fptype}${bits}Vector 181 shape=S${bits}Bit 182 Shape=S_${bits}_BIT 183 bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" 184 if [ $bits == 'Max' ]; then 185 bitargs="$bitargs -KMaxBit" 186 fi 187 188 # Generate 189 Log true " ${bits}_ls" 190 Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -itemplates/X-LoadStoreTest.java.template -o$vectorteststype.java " 191 TEST_DEST_FILE="${vectorteststype}.java" 192 rm -f ${TEST_DEST_FILE} 193 ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ 194 -itemplates/X-LoadStoreTest.java.template \ 195 -o${TEST_DEST_FILE} 196 if [ "x${VAR_OS_ENV}" == "xwindows.cygwin" ]; then 197 tr -d '\r' < ${TEST_DEST_FILE} > temp 198 mv temp ${TEST_DEST_FILE} 199 fi 200 201 # TODO: Generate jmh performance tests for LoadStore variants 202 done 203 204 Log true " done\n" 205 206 done 207 208 rm -fr build 209