< prev index next >
test/jdk/jdk/incubator/vector/gen-template.sh
Print this page
*** 38,47 ****
--- 38,49 ----
ternary="Ternary-op"
ternary_masked="Ternary-Masked-op"
ternary_scalar="Ternary-Scalar-op"
binary="Binary-op"
binary_masked="Binary-Masked-op"
+ binary_broadcast="Binary-Broadcast-op"
+ binary_broadcast_masked="Binary-Broadcast-Masked-op"
binary_scalar="Binary-Scalar-op"
blend="Blend-op"
test_template="Test"
compare_template="Compare"
reduction_scalar="Reduction-Scalar-op"
*** 103,116 ****
# pass the 'test' argument as "OPERATOR_NAME+func_Name" (e.g. "ADD+add")
# if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask")
local test_func=""
local withMask=""
local tests=($(awk -F+ '{$1=$1} 1' <<< $test))
! if [ "${tests[1]}" != "" ]; then
test=${tests[0]}
test_func=${tests[1]}
withMask=${tests[2]}
fi
sed_prog="
s/\<OPTIONAL\>\(.*\)\<\\OPTIONAL\>/\1/g
s/\[\[TEST_TYPE\]\]/${masked}/g
--- 105,125 ----
# pass the 'test' argument as "OPERATOR_NAME+func_Name" (e.g. "ADD+add")
# if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask")
local test_func=""
local withMask=""
local tests=($(awk -F+ '{$1=$1} 1' <<< $test))
! if [ "${tests[2]}" == "withMask" ]; then
test=${tests[0]}
test_func=${tests[1]}
withMask=${tests[2]}
+ elif [ "${tests[1]}" == "withMask" ]; then
+ test=""
+ test_func=${tests[0]}
+ withMask=${tests[1]}
+ elif [ "${tests[1]}" != "" ]; then
+ test=${tests[0]}
+ test_func=${tests[1]}
fi
sed_prog="
s/\<OPTIONAL\>\(.*\)\<\\OPTIONAL\>/\1/g
s/\[\[TEST_TYPE\]\]/${masked}/g
*** 131,141 ****
--- 140,152 ----
# Guard the test if necessary
if [ "$guard" != "" ]; then
echo -e "#if[${guard}]\n" >> $output
fi
+ if [ "$test" != "" ]; then
sed -e "$sed_prog" < ${filename}.current >> $output
+ fi
# If we also have a dedicated function for the operation then use 2nd sed expression
if [[ "$filename" == *"Unit"* ]] && [ "$test_func" != "" ]; then
if [ "$masked" == "" ] || [ "$withMask" != "" ]; then
sed -e "$sed_prog_2" < ${filename}.current >> $output
fi
*** 186,196 ****
fi
# Replace template variables in unit test files (if any)
replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name"
! if [ $generate_perf_tests == true ]; then
# Replace template variables in performance test files (if any)
local perf_wrapper_filename="${TEMPLATE_FOLDER}/Perf-wrapper.template"
local perf_vector_filename="${TEMPLATE_FOLDER}/Perf-${template}.template"
local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template"
--- 197,211 ----
fi
# Replace template variables in unit test files (if any)
replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name"
! local gen_perf_tests=$generate_perf_tests
! if [[ $template == *"-Broadcast-"* ]]; then
! gen_perf_tests=false
! fi
! if [ $gen_perf_tests == true ]; then
# Replace template variables in performance test files (if any)
local perf_wrapper_filename="${TEMPLATE_FOLDER}/Perf-wrapper.template"
local perf_vector_filename="${TEMPLATE_FOLDER}/Perf-${template}.template"
local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template"
*** 214,223 ****
--- 229,244 ----
echo "Generating binary op $1 ($2)..."
gen_op_tmpl $binary "$@"
gen_op_tmpl $binary_masked "$@"
}
+ function gen_binary_alu_bcst_op {
+ echo "Generating binary broadcast op $1 ($2)..."
+ gen_op_tmpl $binary_broadcast "$@"
+ gen_op_tmpl $binary_broadcast_masked "$@"
+ }
+
function gen_shift_cst_op {
echo "Generating Shift constant op $1 ($2)..."
gen_op_tmpl $shift_template "$@"
gen_op_tmpl $shift_masked_template "$@"
}
*** 247,256 ****
--- 268,282 ----
echo "Generating binary op $1 ($2)..."
# gen_op_tmpl $binary_scalar "$@"
gen_op_tmpl $binary "$@"
}
+ function gen_binary_bcst_op_no_masked {
+ echo "Generating binary op $1 ($2)..."
+ gen_op_tmpl $binary_broadcast "$@"
+ }
+
function gen_reduction_op {
echo "Generating reduction op $1 ($2)..."
gen_op_tmpl $reduction_scalar "$@"
gen_op_tmpl $reduction_op "$@"
gen_op_tmpl $reduction_scalar_masked "$@"
*** 329,341 ****
gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE"
gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE"
gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b"
gen_binary_alu_op "AND+and" "a \& b" "BITWISE"
gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE"
! gen_binary_alu_op "OR" "a | b" "BITWISE"
# Missing: "OR_UNCHECKED"
gen_binary_alu_op "XOR" "a ^ b" "BITWISE"
# Shifts
gen_binary_alu_op "LSHL" "(a << b)" "intOrLong"
gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte"
gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short"
--- 355,375 ----
gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE"
gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE"
gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b"
gen_binary_alu_op "AND+and" "a \& b" "BITWISE"
gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE"
! gen_binary_alu_op "OR+or" "a | b" "BITWISE"
# Missing: "OR_UNCHECKED"
gen_binary_alu_op "XOR" "a ^ b" "BITWISE"
+ # Generate the broadcast versions
+ gen_binary_alu_bcst_op "add+withMask" "a + b"
+ gen_binary_alu_bcst_op "sub+withMask" "a - b"
+ gen_binary_alu_bcst_op "mul+withMask" "a \* b"
+ gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP"
+ gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE"
+ gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE"
+ gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE"
# Shifts
gen_binary_alu_op "LSHL" "(a << b)" "intOrLong"
gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte"
gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short"
*** 356,365 ****
--- 390,401 ----
gen_shift_cst_op "ASHR" "(a >> (b \& 15))" "short"
# Masked reductions.
gen_binary_op_no_masked "MIN+min" "Math.min(a, b)"
gen_binary_op_no_masked "MAX+max" "Math.max(a, b)"
+ gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)"
+ gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)"
# Reductions.
gen_reduction_op "AND" "\&" "BITWISE" "-1"
gen_reduction_op "OR" "|" "BITWISE" "0"
gen_reduction_op "XOR" "^" "BITWISE" "0"
*** 396,406 ****
# Rearrange
gen_op_tmpl $rearrange_template "rearrange" ""
# Get
! gen_get_op "" ""
# Broadcast
gen_op_tmpl $broadcast_template "broadcast" ""
# Zero
--- 432,442 ----
# Rearrange
gen_op_tmpl $rearrange_template "rearrange" ""
# Get
! gen_get_op "lane" ""
# Broadcast
gen_op_tmpl $broadcast_template "broadcast" ""
# Zero
*** 439,451 ****
# Ternary operations.
gen_ternary_alu_op "FMA" "Math.fma(a, b, c)" "FP"
gen_ternary_alu_op "BITWISE_BLEND" "(a\&~(c))|(b\&c)" "BITWISE"
# Unary operations.
! gen_unary_alu_op "NEG" "-((\$type\$)a)"
gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)"
! gen_unary_alu_op "NOT" "~((\$type\$)a)" "BITWISE"
gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE"
gen_unary_alu_op "SQRT" "Math.sqrt((double)a)" "FP"
# Gather Scatter operations.
gen_op_tmpl $gather_template "gather" ""
--- 475,487 ----
# Ternary operations.
gen_ternary_alu_op "FMA" "Math.fma(a, b, c)" "FP"
gen_ternary_alu_op "BITWISE_BLEND" "(a\&~(c))|(b\&c)" "BITWISE"
# Unary operations.
! gen_unary_alu_op "NEG+neg" "-((\$type\$)a)"
gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)"
! gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE"
gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE"
gen_unary_alu_op "SQRT" "Math.sqrt((double)a)" "FP"
# Gather Scatter operations.
gen_op_tmpl $gather_template "gather" ""
< prev index next >