< prev index next >

test/jdk/jdk/incubator/vector/gen-template.sh

Print this page

  1 #!/bin/bash
  2 #
  3 # Copyright (c) 2018, 2024, 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.
  9 #
 10 # This code is distributed in the hope that it will be useful, but WITHOUT
 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13 # version 2 for more details (a copy is included in the LICENSE file that
 14 # accompanied this code).
 15 #
 16 # You should have received a copy of the GNU General Public License version
 17 # 2 along with this work; if not, write to the Free Software Foundation,
 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19 #
 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21 # or visit www.oracle.com if you need additional information or have any
 22 # questions.
 23 #

 85 zero_template="Zero"
 86 slice_template="Slice-op"
 87 slice1_template="Slice-bop"
 88 slice1_masked_template="Slice-Masked-bop"
 89 unslice_template="Unslice-op"
 90 unslice1_template="Unslice-bop"
 91 unslice1_masked_template="Unslice-Masked-bop"
 92 miscellaneous_template="Miscellaneous"
 93 
 94 function replace_variables {
 95   local filename=$1
 96   local output=$2
 97   local kernel=$3
 98   local test=$4
 99   local op=$5
100   local init=$6
101   local guard=$7
102   local masked=$8
103   local op_name=$9
104   local kernel_smoke=${10}

105 
106   if [ "x${kernel}" != "x" ]; then
107     local kernel_escaped=$(echo -e "$kernel" | tr '\n' '`')
108     sed "s/\[\[KERNEL\]\]/${kernel_escaped}/g" $filename > ${filename}.current1
109     cat ${filename}.current1 | tr '`' "\n" > ${filename}.current
110     rm -f "${filename}.current1"
111   else
112     cp $filename ${filename}.current
113   fi
114 
115   # Check if we need to do multiple replacements
116   # If you want to emit for an operation using lanewise(VectorOperator.**, ..) and also using dedicated instruction (e.g. add(..)), then
117   # pass the 'test' argument as "OPERATOR_NAME+func_Name" (e.g. "ADD+add")
118   # if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask")
119   local test_func=""
120   local withMask=""

121   local tests=($(awk -F+ '{$1=$1} 1' <<< $test))
122   if [ "${tests[2]}" == "withMask" ]; then
123     test=${tests[0]}
124     test_func=${tests[1]}
125     withMask=${tests[2]}
126   elif [ "${tests[1]}" == "withMask" ]; then
127     test=""
128     test_func=${tests[0]}
129     withMask=${tests[1]}
130   elif [ "${tests[1]}" != "" ]; then
131     test=${tests[0]}
132     test_func=${tests[1]}
133   fi
134 










135   sed_prog="
136     s/\<OPTIONAL\>\(.*\)\<\\OPTIONAL\>/\1/g
137     s/\[\[TEST_TYPE\]\]/${masked}/g
138     s/\[\[TEST_OP\]\]/${op}/g
139     s/\[\[TEST_INIT\]\]/${init}/g
140     s/\[\[OP_NAME\]\]/${op_name}/g

141   "
142   sed_prog_2="$sed_prog
143     s/\[\[TEST\]\]/${test_func}/g
144     s/[.][^(]*(VectorOperators.$test_func, /.$test_func(/g
145     s/[.][^(]*(VectorOperators.$test_func,/.$test_func(/g
146     s/[.][^(]*(VectorOperators.$test_func/.$test_func(/g
147   "
148   sed_prog="
149     $sed_prog
150     s/\[\[TEST\]\]/${test}/g
151   "
152 
153   # Guard the test if necessary
154   if [ "$guard" != "" ]; then
155     echo -e "#if[${guard}]" >> $output
156   fi
157   if [ "$test" != "" ]; then
158     sed -e "$sed_prog" < ${filename}.current >> $output
159   fi
160   # If we also have a dedicated function for the operation then use 2nd sed expression

168       else
169         cp $filename.current ${filename}.scurrent
170       fi
171       sed -e "$sed_prog_2" < ${filename}.scurrent >> $output
172       rm -f ${filename}.scurrent
173     fi
174   fi
175   if [ "$guard" != "" ]; then
176     echo -e "#end[${guard}]" >> $output
177   fi
178 
179   rm -f ${filename}.current
180 }
181 
182 function gen_op_tmpl {
183   local template=$1
184   local test=$2
185   local op=$3
186   local guard=""
187   local init=""

188   if [ $# -gt 3 ]; then
189     guard=$4
190   fi
191   if [ $# == 5 ]; then
192     init=$5
193   fi
194 




195   local masked=""
196   if [[ $template == *"Masked"* ]]; then
197     masked="Masked"
198   fi
199 
200   local op_name=""
201   if [[ $template == *"Shift"* ]]; then
202     op_name="Shift"
203   elif [[ $template == *"Get"* ]]; then
204     op_name="extract"
205   fi
206 
207   local kernel_filename="${TEMPLATE_FOLDER}/Kernel-${template}.template"
208   local kernel_smoke_filename="${TEMPLATE_FOLDER}/Kernel-${template}-smoke.template"
209   local unit_filename="${TEMPLATE_FOLDER}/Unit-${template}.template"
210   if [ ! -f $unit_filename ]; then
211     # Leverage general unit code snippet if no specialization exists
212     unit_filename="${TEMPLATE_FOLDER}/Unit-${template%_*}.template"
213     echo $unit_filename
214   fi
215 
216   local kernel=""
217   if [ -f $kernel_filename ]; then
218     kernel="$(cat $kernel_filename)"
219   fi
220 
221   local kernel_smoke=""
222   if [ -f $kernel_smoke_filename ]; then
223     kernel_smoke="$(cat $kernel_smoke_filename)"
224   else
225     kernel_smoke="$kernel"
226   fi
227 
228   # Replace template variables in unit test files (if any)
229   replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke"
230 
231   local gen_perf_tests=$generate_perf_tests
232   if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] ||
233      [[ $template == *"Compare-Masked"* ]] || [[ $template == *"Compare-Broadcast"* ]]; then
234     gen_perf_tests=false
235   fi
236   if [ $gen_perf_tests == true ]; then
237     # Replace template variables in performance test files (if any)
238     local perf_wrapper_filename="${TEMPLATE_FOLDER}/Perf-wrapper.template"
239     local perf_vector_filename="${TEMPLATE_FOLDER}/Perf-${template}.template"
240     local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template"
241 
242     if [ -f $perf_vector_filename ]; then
243       replace_variables $perf_vector_filename  $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
244     elif [ -f $kernel_filename ]; then
245       replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
246     elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
247       echo "Warning: missing perf: $@"
248     fi
249 
250     if [ -f $perf_scalar_filename ]; then
251       replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
252     elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
253       echo "Warning: Missing PERF SCALAR: $perf_scalar_filename"
254     fi
255   fi
256 }
257 
258 function gen_binary_alu_op {
259   echo "Generating binary op $1 ($2)..."
260   gen_op_tmpl $binary "$@"
261   gen_op_tmpl $binary_masked "$@"
262 }
263 
264 function gen_binary_alu_mem_op {
265   echo "Generating binary op $1 ($2)..."
266   gen_op_tmpl $binary_memop "$@"
267   gen_op_tmpl $binary_masked_memop "$@"
268 }
269 
270 function gen_binary_alu_bcst_op {
271   echo "Generating binary broadcast op $1 ($2)..."
272   gen_op_tmpl $binary_broadcast "$@"
273   gen_op_tmpl $binary_broadcast_masked "$@"
274 }
275 
276 function gen_binary_alu_bcst_long_op {
277   echo "Generating binary broadcast long op $1 ($2)..."
278   gen_op_tmpl $binary_broadcast_long "$@"
279   gen_op_tmpl $binary_broadcast_masked_long "$@"
280 }
281 
282 function gen_shift_op {
283   echo "Generating Shift constant op $1 ($2)..."
284   gen_op_tmpl $shift_template "$@"
285   gen_op_tmpl $shift_masked_template "$@"
286 }
287 

315   echo "Generating ternary double broadcast op $1 ($2)..."
316   gen_op_tmpl $ternary_double_broadcast "$@"
317   gen_op_tmpl $ternary_double_broadcast_masked "$@"
318 }
319 
320 function gen_binary_op {
321   echo "Generating binary op $1 ($2)..."
322 #  gen_op_tmpl $binary_scalar "$@"
323   gen_op_tmpl $binary "$@"
324   gen_op_tmpl $binary_masked "$@"
325 }
326 
327 function gen_saturating_binary_op {
328   echo "Generating binary op $1 ($2)..."
329   gen_op_tmpl $saturating_binary "$@"
330   gen_op_tmpl $saturating_binary_masked "$@"
331 }
332 
333 function gen_saturating_binary_op_associative {
334   echo "Generating saturating binary associative op $1 ($2)..."
335   gen_op_tmpl $saturating_binary_assocative "$@"
336   gen_op_tmpl $saturating_binary_assocative_masked "$@"
337 }
338 
339 function gen_binary_op_no_masked {
340   echo "Generating binary op $1 ($2)..."
341 #  gen_op_tmpl $binary_scalar "$@"
342   gen_op_tmpl $binary "$@"
343 }
344 
345 function gen_binary_bcst_op_no_masked {
346   echo "Generating binary broadcast op $1 ($2)..."
347   gen_op_tmpl $binary_broadcast "$@"
348 }
349 
350 function gen_compare_op {
351   echo "Generating compare op $1 ($2)..."
352   gen_op_tmpl $compare_template "$@"
353   gen_op_tmpl $compare_masked_template "$@"
354 }
355 
356 function gen_compare_bcst_op {

364   gen_op_tmpl $reduction_op "$@"
365   gen_op_tmpl $reduction_scalar_masked "$@"
366   gen_op_tmpl $reduction_op_masked "$@"
367 }
368 
369 function gen_reduction_op_func {
370   echo "Generating reduction op $1 ($2)..."
371   gen_op_tmpl $reduction_scalar_func "$@"
372   gen_op_tmpl $reduction_op_func "$@"
373   gen_op_tmpl $reduction_scalar_masked_func "$@"
374   gen_op_tmpl $reduction_op_masked_func "$@"
375 }
376 
377 function gen_bool_reduction_op {
378   echo "Generating boolean reduction op $1 ($2)..."
379   gen_op_tmpl $bool_reduction_scalar "$@"
380   gen_op_tmpl $bool_reduction_template "$@"
381 }
382 function gen_saturating_reduction_op {
383   echo "Generating saturating reduction op $1 ($2)..."
384   gen_op_tmpl $reduction_scalar_func "$@"
385   gen_op_tmpl $reduction_saturating_op "$@"
386   gen_op_tmpl $reduction_scalar_masked_func "$@"
387   gen_op_tmpl $reduction_saturating_op_masked "$@"
388 }
389 
390 function gen_with_op {
391   echo "Generating with op $1 ($2)..."
392   gen_op_tmpl $with_op_template "$@"
393 }
394 
395 function gen_get_op {
396   echo "Generating get op $1 ($2)..."
397   gen_op_tmpl $get_template "$@"
398 }
399 
400 function gen_unit_header {
401   cat $TEMPLATE_FOLDER/Unit-header.template > $1
402 }
403 
404 function gen_unit_footer {
405   cat $TEMPLATE_FOLDER/Unit-footer.template >> $1
406 }
407 

  1 #!/bin/bash
  2 #
  3 # Copyright (c) 2018, 2025, 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.
  9 #
 10 # This code is distributed in the hope that it will be useful, but WITHOUT
 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13 # version 2 for more details (a copy is included in the LICENSE file that
 14 # accompanied this code).
 15 #
 16 # You should have received a copy of the GNU General Public License version
 17 # 2 along with this work; if not, write to the Free Software Foundation,
 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19 #
 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21 # or visit www.oracle.com if you need additional information or have any
 22 # questions.
 23 #

 85 zero_template="Zero"
 86 slice_template="Slice-op"
 87 slice1_template="Slice-bop"
 88 slice1_masked_template="Slice-Masked-bop"
 89 unslice_template="Unslice-op"
 90 unslice1_template="Unslice-bop"
 91 unslice1_masked_template="Unslice-Masked-bop"
 92 miscellaneous_template="Miscellaneous"
 93 
 94 function replace_variables {
 95   local filename=$1
 96   local output=$2
 97   local kernel=$3
 98   local test=$4
 99   local op=$5
100   local init=$6
101   local guard=$7
102   local masked=$8
103   local op_name=$9
104   local kernel_smoke=${10}
105   local attrib=${11}
106 
107   if [ "x${kernel}" != "x" ]; then
108     local kernel_escaped=$(echo -e "$kernel" | tr '\n' '`')
109     sed "s/\[\[KERNEL\]\]/${kernel_escaped}/g" $filename > ${filename}.current1
110     cat ${filename}.current1 | tr '`' "\n" > ${filename}.current
111     rm -f "${filename}.current1"
112   else
113     cp $filename ${filename}.current
114   fi
115 
116   # Check if we need to do multiple replacements
117   # If you want to emit for an operation using lanewise(VectorOperator.**, ..) and also using dedicated instruction (e.g. add(..)), then
118   # pass the 'test' argument as "OPERATOR_NAME+func_Name" (e.g. "ADD+add")
119   # if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask")
120   local test_func=""
121   local withMask=""
122   local suffix=""
123   local tests=($(awk -F+ '{$1=$1} 1' <<< $test))
124   if [ "${tests[2]}" == "withMask" ]; then
125     test=${tests[0]}
126     test_func=${tests[1]}
127     withMask=${tests[2]}
128   elif [ "${tests[1]}" == "withMask" ]; then
129     test=""
130     test_func=${tests[0]}
131     withMask=${tests[1]}
132   elif [ "${tests[1]}" != "" ]; then
133     test=${tests[0]}
134     test_func=${tests[1]}
135   fi
136 
137   if [ "${attrib}" == "associative" ]; then
138      suffix=${suffix}"_ASSOC"
139   fi
140   if [ "${attrib}" == "reduction" ]; then
141      suffix=${suffix}"_REDUCTION"
142   fi
143   if [ "${attrib}" == "memoryoper" ]; then
144      suffix=${suffix}"_MEM"
145   fi
146 
147   sed_prog="
148     s/\<OPTIONAL\>\(.*\)\<\\OPTIONAL\>/\1/g
149     s/\[\[TEST_TYPE\]\]/${masked}/g
150     s/\[\[TEST_OP\]\]/${op}/g
151     s/\[\[TEST_INIT\]\]/${init}/g
152     s/\[\[OP_NAME\]\]/${op_name}/g
153     s/\[\[SUFFIX\]\]/${suffix}/g
154   "
155   sed_prog_2="$sed_prog
156     s/\[\[TEST\]\]/${test_func}/g
157     s/[.][^(]*(VectorOperators.$test_func, /.$test_func(/g
158     s/[.][^(]*(VectorOperators.$test_func,/.$test_func(/g
159     s/[.][^(]*(VectorOperators.$test_func/.$test_func(/g
160   "
161   sed_prog="
162     $sed_prog
163     s/\[\[TEST\]\]/${test}/g
164   "
165 
166   # Guard the test if necessary
167   if [ "$guard" != "" ]; then
168     echo -e "#if[${guard}]" >> $output
169   fi
170   if [ "$test" != "" ]; then
171     sed -e "$sed_prog" < ${filename}.current >> $output
172   fi
173   # If we also have a dedicated function for the operation then use 2nd sed expression

181       else
182         cp $filename.current ${filename}.scurrent
183       fi
184       sed -e "$sed_prog_2" < ${filename}.scurrent >> $output
185       rm -f ${filename}.scurrent
186     fi
187   fi
188   if [ "$guard" != "" ]; then
189     echo -e "#end[${guard}]" >> $output
190   fi
191 
192   rm -f ${filename}.current
193 }
194 
195 function gen_op_tmpl {
196   local template=$1
197   local test=$2
198   local op=$3
199   local guard=""
200   local init=""
201   local attrib=""
202   if [ $# -gt 3 ]; then
203     guard=$4
204   fi
205   if [ $# -gt 4 ]; then
206     init=$5
207   fi
208 
209   if [ $# -gt 5 ]; then
210     attrib=$6
211   fi
212 
213   local masked=""
214   if [[ $template == *"Masked"* ]]; then
215     masked="Masked"
216   fi
217 
218   local op_name=""
219   if [[ $template == *"Shift"* ]]; then
220     op_name="Shift"
221   elif [[ $template == *"Get"* ]]; then
222     op_name="extract"
223   fi
224 
225   local kernel_filename="${TEMPLATE_FOLDER}/Kernel-${template}.template"
226   local kernel_smoke_filename="${TEMPLATE_FOLDER}/Kernel-${template}-smoke.template"
227   local unit_filename="${TEMPLATE_FOLDER}/Unit-${template}.template"
228   if [ ! -f $unit_filename ]; then
229     # Leverage general unit code snippet if no specialization exists
230     unit_filename="${TEMPLATE_FOLDER}/Unit-${template%_*}.template"
231     echo $unit_filename
232   fi
233 
234   local kernel=""
235   if [ -f $kernel_filename ]; then
236     kernel="$(cat $kernel_filename)"
237   fi
238 
239   local kernel_smoke=""
240   if [ -f $kernel_smoke_filename ]; then
241     kernel_smoke="$(cat $kernel_smoke_filename)"
242   else
243     kernel_smoke="$kernel"
244   fi
245 
246   # Replace template variables in unit test files (if any)
247   replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke" "$attrib"
248 
249   local gen_perf_tests=$generate_perf_tests
250   if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] ||
251      [[ $template == *"Compare-Masked"* ]] || [[ $template == *"Compare-Broadcast"* ]]; then
252     gen_perf_tests=false
253   fi
254   if [ $gen_perf_tests == true ]; then
255     # Replace template variables in performance test files (if any)
256     local perf_wrapper_filename="${TEMPLATE_FOLDER}/Perf-wrapper.template"
257     local perf_vector_filename="${TEMPLATE_FOLDER}/Perf-${template}.template"
258     local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template"
259 
260     if [ -f $perf_vector_filename ]; then
261       replace_variables $perf_vector_filename  $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib"
262     elif [ -f $kernel_filename ]; then
263       replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib"
264     elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
265       echo "Warning: missing perf: $@"
266     fi
267 
268     if [ -f $perf_scalar_filename ]; then
269       replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib"
270     elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
271       echo "Warning: Missing PERF SCALAR: $perf_scalar_filename"
272     fi
273   fi
274 }
275 
276 function gen_binary_alu_op {
277   echo "Generating binary op $1 ($2)..."
278   gen_op_tmpl $binary "$@"
279   gen_op_tmpl $binary_masked "$@"
280 }
281 
282 function gen_binary_alu_mem_op {
283   echo "Generating binary op $1 ($2)..."
284   gen_op_tmpl $binary_memop "$@" "" "" "memoryoper"
285   gen_op_tmpl $binary_masked_memop "$@" "" "" "memoryoper"
286 }
287 
288 function gen_binary_alu_bcst_op {
289   echo "Generating binary broadcast op $1 ($2)..."
290   gen_op_tmpl $binary_broadcast "$@"
291   gen_op_tmpl $binary_broadcast_masked "$@"
292 }
293 
294 function gen_binary_alu_bcst_long_op {
295   echo "Generating binary broadcast long op $1 ($2)..."
296   gen_op_tmpl $binary_broadcast_long "$@"
297   gen_op_tmpl $binary_broadcast_masked_long "$@"
298 }
299 
300 function gen_shift_op {
301   echo "Generating Shift constant op $1 ($2)..."
302   gen_op_tmpl $shift_template "$@"
303   gen_op_tmpl $shift_masked_template "$@"
304 }
305 

333   echo "Generating ternary double broadcast op $1 ($2)..."
334   gen_op_tmpl $ternary_double_broadcast "$@"
335   gen_op_tmpl $ternary_double_broadcast_masked "$@"
336 }
337 
338 function gen_binary_op {
339   echo "Generating binary op $1 ($2)..."
340 #  gen_op_tmpl $binary_scalar "$@"
341   gen_op_tmpl $binary "$@"
342   gen_op_tmpl $binary_masked "$@"
343 }
344 
345 function gen_saturating_binary_op {
346   echo "Generating binary op $1 ($2)..."
347   gen_op_tmpl $saturating_binary "$@"
348   gen_op_tmpl $saturating_binary_masked "$@"
349 }
350 
351 function gen_saturating_binary_op_associative {
352   echo "Generating saturating binary associative op $1 ($2)..."
353   gen_op_tmpl $saturating_binary_assocative "$@" "" "associative"
354   gen_op_tmpl $saturating_binary_assocative_masked "$@" "" "associative"
355 }
356 
357 function gen_binary_op_no_masked {
358   echo "Generating binary op $1 ($2)..."
359 #  gen_op_tmpl $binary_scalar "$@"
360   gen_op_tmpl $binary "$@"
361 }
362 
363 function gen_binary_bcst_op_no_masked {
364   echo "Generating binary broadcast op $1 ($2)..."
365   gen_op_tmpl $binary_broadcast "$@"
366 }
367 
368 function gen_compare_op {
369   echo "Generating compare op $1 ($2)..."
370   gen_op_tmpl $compare_template "$@"
371   gen_op_tmpl $compare_masked_template "$@"
372 }
373 
374 function gen_compare_bcst_op {

382   gen_op_tmpl $reduction_op "$@"
383   gen_op_tmpl $reduction_scalar_masked "$@"
384   gen_op_tmpl $reduction_op_masked "$@"
385 }
386 
387 function gen_reduction_op_func {
388   echo "Generating reduction op $1 ($2)..."
389   gen_op_tmpl $reduction_scalar_func "$@"
390   gen_op_tmpl $reduction_op_func "$@"
391   gen_op_tmpl $reduction_scalar_masked_func "$@"
392   gen_op_tmpl $reduction_op_masked_func "$@"
393 }
394 
395 function gen_bool_reduction_op {
396   echo "Generating boolean reduction op $1 ($2)..."
397   gen_op_tmpl $bool_reduction_scalar "$@"
398   gen_op_tmpl $bool_reduction_template "$@"
399 }
400 function gen_saturating_reduction_op {
401   echo "Generating saturating reduction op $1 ($2)..."
402   gen_op_tmpl $reduction_scalar_func "$@" "reduction"
403   gen_op_tmpl $reduction_saturating_op "$@" "reduction"
404   gen_op_tmpl $reduction_scalar_masked_func "$@" "reduction"
405   gen_op_tmpl $reduction_saturating_op_masked "$@" "reduction"
406 }
407 
408 function gen_with_op {
409   echo "Generating with op $1 ($2)..."
410   gen_op_tmpl $with_op_template "$@"
411 }
412 
413 function gen_get_op {
414   echo "Generating get op $1 ($2)..."
415   gen_op_tmpl $get_template "$@"
416 }
417 
418 function gen_unit_header {
419   cat $TEMPLATE_FOLDER/Unit-header.template > $1
420 }
421 
422 function gen_unit_footer {
423   cat $TEMPLATE_FOLDER/Unit-footer.template >> $1
424 }
425 
< prev index next >