|
1 |
| -dnl -*- shell-script -*- |
| 1 | +dnl -*- autoconf -*- |
2 | 2 | dnl
|
3 | 3 | dnl Copyright (c) 2016 Los Alamos National Security, LLC. All rights
|
4 | 4 | dnl reserved.
|
5 | 5 | dnl Copyright (c) 2016-2018 Cisco Systems, Inc. All rights reserved
|
6 | 6 | dnl Copyright (c) 2016 Research Organization for Information Science
|
7 | 7 | dnl and Technology (RIST). All rights reserved.
|
| 8 | +dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved. |
8 | 9 | dnl $COPYRIGHT$
|
9 | 10 | dnl
|
10 | 11 | dnl Additional copyrights may follow
|
11 | 12 | dnl
|
12 | 13 | dnl $HEADER$
|
13 | 14 | dnl
|
14 |
| -AC_DEFUN([OPAL_SUMMARY_ADD],[ |
15 |
| - OPAL_VAR_SCOPE_PUSH([ompi_summary_section ompi_summary_line ompi_summary_section_current]) |
16 |
| - |
17 |
| - dnl need to replace spaces in the section name with somethis else. _ seems like a reasonable |
18 |
| - dnl choice. if this changes remember to change OMPI_PRINT_SUMMARY as well. |
19 |
| - ompi_summary_section=$(echo $1 | tr ' ' '_') |
20 |
| - ompi_summary_line="$2: $4" |
21 |
| - ompi_summary_section_current=$(eval echo \$ompi_summary_values_$ompi_summary_section) |
22 | 15 |
|
23 |
| - if test -z "$ompi_summary_section_current" ; then |
24 |
| - if test -z "$ompi_summary_sections" ; then |
25 |
| - ompi_summary_sections=$ompi_summary_section |
26 |
| - else |
27 |
| - ompi_summary_sections="$ompi_summary_sections $ompi_summary_section" |
28 |
| - fi |
29 |
| - eval ompi_summary_values_$ompi_summary_section=\"$ompi_summary_line\" |
30 |
| - else |
31 |
| - eval ompi_summary_values_$ompi_summary_section=\"$ompi_summary_section_current,$ompi_summary_line\" |
32 |
| - fi |
| 16 | +# OPAL_SUMMARY_ADD(section, topic, unused, result) |
| 17 | +# |
| 18 | +# queue a summary line in the given section of the form: |
| 19 | +# topic: result |
| 20 | +# |
| 21 | +# section:topic lines are only added once; first to add wins. |
| 22 | +# The key for uniqification is a shell-variable-ified representation |
| 23 | +# of section followed by an underscore followed by a |
| 24 | +# shell-variable-ified representation of line. |
| 25 | +# |
| 26 | +# There are no restrictions on the contents of section and topic; they |
| 27 | +# can be variable references (although the use case for this is |
| 28 | +# dubious) and they can contain most ASCII characters (escape |
| 29 | +# characters excluded). Note that some care must be taken with the |
| 30 | +# unique check and this liberal rule, as the unique check is after the |
| 31 | +# string has been run through AS_TR_SH. Basically, any character that |
| 32 | +# is not legal in a shell variable name will be turned into an |
| 33 | +# underscore. So the strings "Section_foo" and "Section-foo" would be |
| 34 | +# the same as far as the unique check is concerned. |
| 35 | +# |
| 36 | +# The input strings are evaluated during OPAL_SUMMARY_ADD, not during |
| 37 | +# OPAL_SUMMARY_PRINT. This seems to meet the principle of least |
| 38 | +# astonishment. A common pattern is to call |
| 39 | +# OPAL_SUMMARY_ADD([Resource Type], [Component Name], [], [$results]) |
| 40 | +# and then unset $results to avoid namespace pollution. This will |
| 41 | +# work properly with the current behavior, but would result in odd |
| 42 | +# errors if we delayed evaulation. |
| 43 | +# |
| 44 | +# As a historical note, the third argument has never been used in |
| 45 | +# OPAL_SUMMARY_ADD and its meaning is unclear. Preferred behavior is |
| 46 | +# to leave it empty. |
| 47 | +# |
| 48 | +# As a final historical note, the initial version of SUMMARY_ADD was |
| 49 | +# added with implementation of the callers having all of the section |
| 50 | +# and topic headers double quoted. This was never necessary, and |
| 51 | +# certainly is not with the current implementation. While harmless, |
| 52 | +# it is not great practice to over-quote, so we recommend against |
| 53 | +# doing so. |
| 54 | +# ----------------------------------------------------------- |
| 55 | +AC_DEFUN([OPAL_SUMMARY_ADD],[ |
| 56 | + OPAL_VAR_SCOPE_PUSH([opal_summary_line opal_summary_newline opal_summary_key]) |
| 57 | +
|
| 58 | + # The end quote on the next line is intentional! |
| 59 | + opal_summary_newline=" |
| 60 | +" |
| 61 | + opal_summary_line="$2: $4" |
| 62 | + opal_summary_key="AS_TR_SH([$1])_AS_TR_SH([$2])" |
| 63 | +
|
| 64 | + # Use the section name variable as an indicator for whether or not |
| 65 | + # the section has already been created. |
| 66 | + AS_IF([AS_VAR_TEST_SET([opal_summary_section_]AS_TR_SH([$1])[_name])], |
| 67 | + [], |
| 68 | + [AS_VAR_SET([opal_summary_section_]AS_TR_SH([$1])[_name], ["$1"]) |
| 69 | + OPAL_APPEND([opal_summary_sections], [AS_TR_SH([$1])])]) |
| 70 | +
|
| 71 | + # Use the summary key as indicator if the section:topic has already |
| 72 | + # been added to the results for the given section. |
| 73 | + AS_IF([AS_VAR_TEST_SET([${opal_summary_key}])], |
| 74 | + [], |
| 75 | + [AS_VAR_SET([${opal_summary_key}], [1]) |
| 76 | + dnl this is a bit overcomplicated, but we are basically implementing |
| 77 | + dnl a poor mans AS_VAR_APPEND with the ability to specify a separator, |
| 78 | + dnl because we have a newline separator in the string. |
| 79 | + AS_IF([AS_VAR_TEST_SET([opal_summary_section_]AS_TR_SH([$1])[_value])], |
| 80 | + [AS_VAR_APPEND([opal_summary_section_]AS_TR_SH([$1])[_value], |
| 81 | + ["${opal_summary_newline}${opal_summary_line}"])], |
| 82 | + [AS_VAR_SET([opal_summary_section_]AS_TR_SH([$1])[_value], |
| 83 | + ["${opal_summary_line}"])])]) |
33 | 84 |
|
34 | 85 | OPAL_VAR_SCOPE_POP
|
35 | 86 | ])
|
36 | 87 |
|
37 | 88 | AC_DEFUN([OPAL_SUMMARY_PRINT],[
|
38 |
| - OPAL_VAR_SCOPE_PUSH([ompi_summary_section ompi_summary_section_name]) |
| 89 | + OPAL_VAR_SCOPE_PUSH([opal_summary_section opal_summary_section_name]) |
39 | 90 | cat <<EOF
|
40 | 91 |
|
41 | 92 | Open MPI configuration:
|
|
90 | 141 |
|
91 | 142 | echo
|
92 | 143 |
|
93 |
| - for ompi_summary_section in $(echo $ompi_summary_sections) ; do |
94 |
| - ompi_summary_section_name=$(echo $ompi_summary_section | tr '_' ' ') |
95 |
| - echo "$ompi_summary_section_name" |
| 144 | + for opal_summary_section in ${opal_summary_sections} ; do |
| 145 | + AS_VAR_COPY([opal_summary_section_name], [opal_summary_section_${opal_summary_section}_name]) |
| 146 | + AS_VAR_COPY([opal_summary_section_value], [opal_summary_section_${opal_summary_section}_value]) |
| 147 | + echo "${opal_summary_section_name}" |
96 | 148 | echo "-----------------------"
|
97 |
| - echo "$(eval echo \$ompi_summary_values_$ompi_summary_section)" | tr ',' $'\n' | sort -f |
| 149 | + echo "${opal_summary_section_value}" | sort -f |
98 | 150 | echo " "
|
99 | 151 | done
|
100 | 152 |
|
|
0 commit comments