Skip to content

Commit 6f240eb

Browse files
authored
Merge pull request #173 from ocaisa/unknown_arm_vendors
`eessi_archdetect.sh`: Allow for a default vendor fallback for ARM CPUs
2 parents 54a2498 + 84d120c commit 6f240eb

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

init/eessi_archdetect.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ cpupath(){
9393
# Identify the best matching CPU architecture from a list of supported specifications for the host CPU
9494
# Return the path to the installation files in EESSI of the best matching architecture
9595
local cpu_arch_spec=()
96-
96+
9797
# Identify the host CPU architecture
9898
local machine_type=${EESSI_MACHINE_TYPE:-$(uname -m)}
9999
log "DEBUG" "cpupath: Host CPU architecture identified as '$machine_type'"
100-
100+
101101
# Populate list of supported specs for this architecture
102102
case $machine_type in
103103
"x86_64") local spec_file="eessi_arch_x86.spec";;
@@ -109,14 +109,28 @@ cpupath(){
109109
# spec files are located in a subfolder with this script
110110
local base_dir=$(dirname $(readlink -f $0))
111111
update_arch_specs "$base_dir/arch_specs/${spec_file}"
112-
112+
113113
# Identify the host CPU vendor
114114
local cpu_vendor=$(get_cpuinfo "vendor[ _]id")
115115
if [ "${cpu_vendor}" == "" ]; then
116116
cpu_vendor=$(get_cpuinfo "cpu[ _]implementer")
117117
fi
118118
log "DEBUG" "cpupath: CPU vendor of host system: '$cpu_vendor'"
119-
119+
# Construct a list of known cpu vendors
120+
local cpu_vendors=()
121+
for spec in "${cpu_arch_spec[@]}"; do
122+
eval "cols=$spec"
123+
cpu_vendors+=("${cols[1]}")
124+
done
125+
log "DEBUG" "cpupath: Known CPU vendors: ${cpu_vendors[*]}"
126+
# For ARM, if CPU vendor is as-yet-unknown fall back to a default ARM vendor 0x41
127+
if [ "${machine_type}" == "aarch64" ]; then
128+
if [[ " ${cpu_vendors[*]} " != *" $cpu_vendor "* ]]; then
129+
log "DEBUG" "cpupath: Unknown ARM CPU vendor '$cpu_vendor', falling back to '0x41'"
130+
cpu_vendor="0x41"
131+
fi
132+
fi
133+
120134
# Identify the host CPU flags or features
121135
# cpuinfo systems print different line identifiers, eg features, instead of flags
122136
local cpu_flag_tag;
@@ -132,14 +146,14 @@ cpupath(){
132146
else
133147
cpu_flag_tag='flags'
134148
fi
135-
149+
136150
local cpu_flags=$(get_cpuinfo "$cpu_flag_tag")
137151
log "DEBUG" "cpupath: CPU flags of host system: '$cpu_flags'"
138-
152+
139153
# Default to generic CPU
140154
local best_arch_match="$machine_type/generic"
141155
local all_arch_matches=$best_arch_match
142-
156+
143157
# Iterate over the supported CPU specifications to find the best match for host CPU
144158
# Order of the specifications matters, the last one to match will be selected
145159
for arch in "${cpu_arch_spec[@]}"; do
@@ -151,7 +165,7 @@ cpupath(){
151165
log "DEBUG" "cpupath: host CPU best match updated to $best_arch_match"
152166
fi
153167
done
154-
168+
155169
if [ "allx" == "${CPUPATH_RESULT}x" ]; then
156170
log "INFO" "cpupath: all matches for host CPU: $all_arch_matches"
157171
echo "$all_arch_matches"
@@ -219,4 +233,3 @@ case "$ARGUMENT" in
219233
"accelpath") accelpath; exit;;
220234
*) echo "$USAGE"; log "ERROR" "Missing <action> argument (possible actions: 'cpupath', 'accelpath')";;
221235
esac
222-

0 commit comments

Comments
 (0)