< prev index next > test/jdk/jdk/incubator/vector/gen-template.sh
Print this page
#!/bin/bash
#
- # Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
+ # Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
local init=$6
local guard=$7
local masked=$8
local op_name=$9
local kernel_smoke=${10}
+ local attrib=${11}
if [ "x${kernel}" != "x" ]; then
local kernel_escaped=$(echo -e "$kernel" | tr '\n' '`')
sed "s/\[\[KERNEL\]\]/${kernel_escaped}/g" $filename > ${filename}.current1
cat ${filename}.current1 | tr '`' "\n" > ${filename}.current
# If you want to emit for an operation using lanewise(VectorOperator.**, ..) and also using dedicated instruction (e.g. add(..)), then
# 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 suffix=""
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]}" != "" ]; then
test=${tests[0]}
test_func=${tests[1]}
fi
+ if [ "${attrib}" == "associative" ]; then
+ suffix=${suffix}"_ASSOC"
+ fi
+ if [ "${attrib}" == "reduction" ]; then
+ suffix=${suffix}"_REDUCTION"
+ fi
+ if [ "${attrib}" == "memoryoper" ]; then
+ suffix=${suffix}"_MEM"
+ fi
+
sed_prog="
s/\<OPTIONAL\>\(.*\)\<\\OPTIONAL\>/\1/g
s/\[\[TEST_TYPE\]\]/${masked}/g
s/\[\[TEST_OP\]\]/${op}/g
s/\[\[TEST_INIT\]\]/${init}/g
s/\[\[OP_NAME\]\]/${op_name}/g
+ s/\[\[SUFFIX\]\]/${suffix}/g
"
sed_prog_2="$sed_prog
s/\[\[TEST\]\]/${test_func}/g
s/[.][^(]*(VectorOperators.$test_func, /.$test_func(/g
s/[.][^(]*(VectorOperators.$test_func,/.$test_func(/g
local template=$1
local test=$2
local op=$3
local guard=""
local init=""
+ local attrib=""
if [ $# -gt 3 ]; then
guard=$4
fi
- if [ $# == 5 ]; then
+ if [ $# -gt 4 ]; then
init=$5
fi
+ if [ $# -gt 5 ]; then
+ attrib=$6
+ fi
+
local masked=""
if [[ $template == *"Masked"* ]]; then
masked="Masked"
fi
else
kernel_smoke="$kernel"
fi
# Replace template variables in unit test files (if any)
- replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke"
+ replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke" "$attrib"
local gen_perf_tests=$generate_perf_tests
if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] ||
[[ $template == *"Compare-Masked"* ]] || [[ $template == *"Compare-Broadcast"* ]]; then
gen_perf_tests=false
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"
if [ -f $perf_vector_filename ]; then
- replace_variables $perf_vector_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
+ replace_variables $perf_vector_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib"
elif [ -f $kernel_filename ]; then
- replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
+ replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib"
elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
echo "Warning: missing perf: $@"
fi
if [ -f $perf_scalar_filename ]; then
- replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
+ replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib"
elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
echo "Warning: Missing PERF SCALAR: $perf_scalar_filename"
fi
fi
}
gen_op_tmpl $binary_masked "$@"
}
function gen_binary_alu_mem_op {
echo "Generating binary op $1 ($2)..."
- gen_op_tmpl $binary_memop "$@"
- gen_op_tmpl $binary_masked_memop "$@"
+ gen_op_tmpl $binary_memop "$@" "" "" "memoryoper"
+ gen_op_tmpl $binary_masked_memop "$@" "" "" "memoryoper"
}
function gen_binary_alu_bcst_op {
echo "Generating binary broadcast op $1 ($2)..."
gen_op_tmpl $binary_broadcast "$@"
gen_op_tmpl $saturating_binary_masked "$@"
}
function gen_saturating_binary_op_associative {
echo "Generating saturating binary associative op $1 ($2)..."
- gen_op_tmpl $saturating_binary_assocative "$@"
- gen_op_tmpl $saturating_binary_assocative_masked "$@"
+ gen_op_tmpl $saturating_binary_assocative "$@" "" "associative"
+ gen_op_tmpl $saturating_binary_assocative_masked "$@" "" "associative"
}
function gen_binary_op_no_masked {
echo "Generating binary op $1 ($2)..."
# gen_op_tmpl $binary_scalar "$@"
gen_op_tmpl $bool_reduction_scalar "$@"
gen_op_tmpl $bool_reduction_template "$@"
}
function gen_saturating_reduction_op {
echo "Generating saturating reduction op $1 ($2)..."
- gen_op_tmpl $reduction_scalar_func "$@"
- gen_op_tmpl $reduction_saturating_op "$@"
- gen_op_tmpl $reduction_scalar_masked_func "$@"
- gen_op_tmpl $reduction_saturating_op_masked "$@"
+ gen_op_tmpl $reduction_scalar_func "$@" "reduction"
+ gen_op_tmpl $reduction_saturating_op "$@" "reduction"
+ gen_op_tmpl $reduction_scalar_masked_func "$@" "reduction"
+ gen_op_tmpl $reduction_saturating_op_masked "$@" "reduction"
}
function gen_with_op {
echo "Generating with op $1 ($2)..."
gen_op_tmpl $with_op_template "$@"
< prev index next >