| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# BLIS |
| 4 |
# An object-based framework for developing high-performance BLAS-like |
| 5 |
# libraries. |
| 6 |
# |
| 7 |
# Copyright (C) 2014, The University of Texas at Austin |
| 8 |
# Copyright (C) 2018, Advanced Micro Devices, Inc. |
| 9 |
# |
| 10 |
# Redistribution and use in source and binary forms, with or without |
| 11 |
# modification, are permitted provided that the following conditions are |
| 12 |
# met: |
| 13 |
# - Redistributions of source code must retain the above copyright |
| 14 |
# notice, this list of conditions and the following disclaimer. |
| 15 |
# - Redistributions in binary form must reproduce the above copyright |
| 16 |
# notice, this list of conditions and the following disclaimer in the |
| 17 |
# documentation and/or other materials provided with the distribution. |
| 18 |
# - Neither the name of The University of Texas at Austin nor the names |
| 19 |
# of its contributors may be used to endorse or promote products |
| 20 |
# derived from this software without specific prior written permission. |
| 21 |
# |
| 22 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 |
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
# |
| 34 |
# |
| 35 |
|
| 36 |
# |
| 37 |
# -- Helper functions ---------------------------------------------------------- |
| 38 |
# |
| 39 |
|
| 40 |
print_usage() |
| 41 |
{ |
| 42 |
# Use the version string in the 'version' file since we don't have |
| 43 |
# the patched version string yet. |
| 44 |
if [ -z "${version}" ]; then |
| 45 |
version=$(cat "${version_filepath}") |
| 46 |
fi |
| 47 |
|
| 48 |
# Echo usage info. |
| 49 |
echo " " |
| 50 |
echo " ${script_name} (BLIS ${version})" |
| 51 |
#echo " " |
| 52 |
#echo " BLIS ${version}" |
| 53 |
echo " " |
| 54 |
echo " Field G. Van Zee" |
| 55 |
echo " " |
| 56 |
echo " Configure BLIS's build system for compilation using a specified" |
| 57 |
echo " configuration directory." |
| 58 |
echo " " |
| 59 |
echo " Usage:" |
| 60 |
echo " " |
| 61 |
echo " ${script_name} [options] [env. vars.] confname" |
| 62 |
echo " " |
| 63 |
echo " Arguments:" |
| 64 |
echo " " |
| 65 |
echo " confname The name of the sub-directory inside of the 'config'" |
| 66 |
echo " directory containing the desired BLIS configuration." |
| 67 |
echo " Note that confname MUST be specified; if it is not," |
| 68 |
echo " configure will complain. To build a completely generic" |
| 69 |
echo " implementation, use the 'generic' configuration" |
| 70 |
echo " " |
| 71 |
echo " Options:" |
| 72 |
echo " " |
| 73 |
echo " -p PREFIX, --prefix=PREFIX" |
| 74 |
echo " " |
| 75 |
echo " The path to which make will install all build products." |
| 76 |
echo " If given, this option implies the following options:" |
| 77 |
echo " --libdir=PREFIX/lib" |
| 78 |
echo " --incdir=PREFIX/include" |
| 79 |
echo " --sharedir=PREFIX/share" |
| 80 |
echo " If not given, PREFIX defaults to \$(HOME)/blis. If PREFIX" |
| 81 |
echo " refers to a directory that does not exist, it will be" |
| 82 |
echo " created." |
| 83 |
echo " " |
| 84 |
echo " --libdir=LIBDIR" |
| 85 |
echo " " |
| 86 |
echo " The path to which make will install libraries. If given," |
| 87 |
echo " LIBDIR will override the corresponding directory implied" |
| 88 |
echo " by --prefix; if not not given, LIBDIR defaults to" |
| 89 |
echo " PREFIX/lib. If LIBDIR refers to a directory that does" |
| 90 |
echo " not exist, it will be created." |
| 91 |
echo " " |
| 92 |
echo " --includedir=INCDIR" |
| 93 |
echo " " |
| 94 |
echo " The path to which make will install development header" |
| 95 |
echo " files. If given, INCDIR will override the corresponding" |
| 96 |
echo " directory implied by --prefix; if not given, INCDIR" |
| 97 |
echo " defaults to PREFIX/include. If INCDIR refers to a" |
| 98 |
echo " directory that does not exist, it will be created." |
| 99 |
echo " " |
| 100 |
echo " --sharedir=SHAREDIR" |
| 101 |
echo " " |
| 102 |
echo " The path to which make will makefile fragments containing" |
| 103 |
echo " make variables determined by configure (e.g. CC, CFLAGS," |
| 104 |
echo " and LDFLAGS). These files allow certain BLIS makefiles," |
| 105 |
echo " such as those in the examples or testsuite directories, to" |
| 106 |
echo " operate on an installed copy of BLIS rather than a local" |
| 107 |
echo " (and possibly uninstalled) copy. If given, SHAREDIR will" |
| 108 |
echo " override the corresponding directory implied by --prefix;" |
| 109 |
echo " if not given, SHAREDIR defaults to PREFIX/share. If" |
| 110 |
echo " SHAREDIR refers to a directory that does not exist, it" |
| 111 |
echo " will be created." |
| 112 |
echo " " |
| 113 |
echo " -d DEBUG, --enable-debug[=DEBUG]" |
| 114 |
echo " " |
| 115 |
echo " Enable debugging symbols in the library. If argument" |
| 116 |
echo " DEBUG is given as 'opt', then optimization flags are" |
| 117 |
echo " kept in the framework, otherwise optimization is" |
| 118 |
echo " turned off." |
| 119 |
echo " " |
| 120 |
echo " --enable-verbose-make, --disable-verbose-make" |
| 121 |
echo " " |
| 122 |
echo " Enable (disabled by default) verbose compilation output" |
| 123 |
echo " during make." |
| 124 |
echo " " |
| 125 |
echo " --enable-arg-max-hack --disable-arg-max-hack" |
| 126 |
echo " " |
| 127 |
echo " Enable (disabled by default) build system logic that" |
| 128 |
echo " will allow archiving/linking the static/shared library" |
| 129 |
echo " even if the command plus command line arguments exceeds" |
| 130 |
echo " the operating system limit (ARG_MAX)." |
| 131 |
echo " " |
| 132 |
echo " --disable-static, --enable-static" |
| 133 |
echo " " |
| 134 |
echo " Disable (enabled by default) building BLIS as a static" |
| 135 |
echo " library. If the static library build is disabled, the" |
| 136 |
echo " shared library build must remain enabled." |
| 137 |
echo " " |
| 138 |
echo " --disable-shared, --enable-shared" |
| 139 |
echo " " |
| 140 |
echo " Disable (enabled by default) building BLIS as a shared" |
| 141 |
echo " library. If the shared library build is disabled, the" |
| 142 |
echo " static library build must remain enabled." |
| 143 |
echo " " |
| 144 |
echo " -t MODEL, --enable-threading[=MODEL], --disable-threading" |
| 145 |
echo " " |
| 146 |
echo " Enable threading in the library, using threading model" |
| 147 |
echo " MODEL={openmp,pthreads,no}. If MODEL=no or " |
| 148 |
echo " --disable-threading is specified, threading will be" |
| 149 |
echo " disabled. The default is 'no'." |
| 150 |
echo " " |
| 151 |
echo " --disable-packbuf-pools, --enable-packbuf-pools" |
| 152 |
echo " " |
| 153 |
echo " Disable (enabled by default) use of internal memory" |
| 154 |
echo " pools for managing packing buffers. When disabled," |
| 155 |
echo " the function specified by BLIS_MALLOC_POOL is called" |
| 156 |
echo " on-demand, whenever a packing buffer is needed, and" |
| 157 |
echo " the buffer is released via the function specified by" |
| 158 |
echo " BLIS_FREE_POOL() when the loop in which it was" |
| 159 |
echo " allocated terminates. When enabled, the memory pools" |
| 160 |
echo " minimize calls to both BLIS_MALLOC_POOL() and" |
| 161 |
echo " BLIS_FREE_POOL(), especially in a multithreaded" |
| 162 |
echo " environment, but does so through a mechanism that may" |
| 163 |
echo " incur additional overhead in some (but not all)" |
| 164 |
echo " situations." |
| 165 |
echo " " |
| 166 |
echo " -q, --quiet Suppress informational output. By default, configure" |
| 167 |
echo " is verbose. (NOTE: -q is not yet implemented)" |
| 168 |
echo " " |
| 169 |
echo " -i SIZE, --int-size=SIZE" |
| 170 |
echo " " |
| 171 |
echo " Set the size (in bits) of internal BLIS integers and" |
| 172 |
echo " integer types used in native BLIS interfaces. The" |
| 173 |
echo " default inteter type size is architecture dependent." |
| 174 |
echo " (Hint: You can always find this value printed at the" |
| 175 |
echo " beginning of the testsuite output.)" |
| 176 |
echo " " |
| 177 |
echo " -b SIZE, --blas-int-size=SIZE" |
| 178 |
echo " " |
| 179 |
echo " Set the size (in bits) of integer types in external" |
| 180 |
echo " BLAS and CBLAS interfaces, if enabled. The default" |
| 181 |
echo " integer type size used in BLAS/CBLAS is 32 bits." |
| 182 |
echo " " |
| 183 |
echo " --disable-blas, --enable-blas" |
| 184 |
echo " " |
| 185 |
echo " Disable (enabled by default) building the BLAS" |
| 186 |
echo " compatibility layer." |
| 187 |
echo " " |
| 188 |
echo " --enable-cblas, --disable-cblas" |
| 189 |
echo " " |
| 190 |
echo " Enable (disabled by default) building the CBLAS" |
| 191 |
echo " compatibility layer. This automatically enables the" |
| 192 |
echo " BLAS compatibility layer as well." |
| 193 |
echo " " |
| 194 |
echo " -s NAME --enable-sandbox=NAME" |
| 195 |
echo " " |
| 196 |
echo " Enable a separate sandbox implementation of gemm. This" |
| 197 |
echo " option disables BLIS's conventional gemm implementation" |
| 198 |
echo " (which shares common infrastructure with other level-3" |
| 199 |
echo " operations) and instead compiles and uses the code in" |
| 200 |
echo " the NAME directory, which is expected to be a sub-" |
| 201 |
echo " directory of 'sandbox'. By default, no sandboxes are" |
| 202 |
echo " enabled." |
| 203 |
echo " " |
| 204 |
echo " --with-memkind, --without-memkind" |
| 205 |
echo " " |
| 206 |
echo " Forcibly enable or disable the use of libmemkind's" |
| 207 |
echo " hbw_malloc() and hbw_free() as substitutes for malloc()" |
| 208 |
echo " and free(), respectively, when allocating memory for" |
| 209 |
echo " BLIS's memory pools, which are used to manage buffers" |
| 210 |
echo " into which matrices are packed. The default behavior" |
| 211 |
echo " for this option is environment-dependent; if configure" |
| 212 |
echo " detects the presence of libmemkind, libmemkind is used" |
| 213 |
echo " by default, and otherwise it is not used by default." |
| 214 |
echo " " |
| 215 |
echo " --force-version=STRING" |
| 216 |
echo " " |
| 217 |
echo " Force configure to use an arbitrary version string" |
| 218 |
echo " STRING. This option may be useful when repackaging" |
| 219 |
echo " custom versions of BLIS by outside organizations." |
| 220 |
echo " " |
| 221 |
echo " -c, --show-config-lists" |
| 222 |
echo " " |
| 223 |
echo " Print the config and kernel lists, and kernel-to-config" |
| 224 |
echo " map after they are read from file. This can be useful" |
| 225 |
echo " when debugging certain configuration issues, and/or as" |
| 226 |
echo " a sanity check to make sure these lists are constituted" |
| 227 |
echo " as expected." |
| 228 |
echo " " |
| 229 |
echo " -h, --help Output this information and quit." |
| 230 |
echo " " |
| 231 |
echo " Environment Variables:" |
| 232 |
echo " " |
| 233 |
echo " CC Specifies the C compiler to use." |
| 234 |
echo " RANLIB Specifies the ranlib executable to use." |
| 235 |
echo " CFLAGS Specifies additional compiler flags to use (prepended)." |
| 236 |
echo " LDFLAGS Specifies additional linker flags to use (prepended)." |
| 237 |
echo " " |
| 238 |
echo " Environment variables may also be specified as command line" |
| 239 |
echo " options, e.g.:" |
| 240 |
echo " " |
| 241 |
echo " ./configure [options] CC=gcc haswell" |
| 242 |
echo " " |
| 243 |
echo " Note that not all compilers are compatible with a given" |
| 244 |
echo " configuration." |
| 245 |
echo " " |
| 246 |
|
| 247 |
# Exit with non-zero exit status |
| 248 |
exit 1 |
| 249 |
} |
| 250 |
|
| 251 |
query_array() |
| 252 |
{ |
| 253 |
local arr key var_name |
| 254 |
|
| 255 |
arr="$1" |
| 256 |
key="$2" |
| 257 |
|
| 258 |
var_name="${arr}_${key}" |
| 259 |
|
| 260 |
echo "${!var_name}" |
| 261 |
} |
| 262 |
|
| 263 |
assign_key_value() |
| 264 |
{ |
| 265 |
local arr key val |
| 266 |
|
| 267 |
arr="$1" |
| 268 |
key="$2" |
| 269 |
val="$3" |
| 270 |
|
| 271 |
printf -v "${arr}_${key}" %s "${val}" |
| 272 |
} |
| 273 |
|
| 274 |
# |
| 275 |
# FGVZ: This commented-out function is being kept as an example how how |
| 276 |
# to effectively "pass by reference" in bash. That is, pass the name of |
| 277 |
# a variable, instead of its conents, and then let the function use the |
| 278 |
# variable by prepending a $, at which time it can evaluate the string |
| 279 |
# as if it were a literal variable occurance. |
| 280 |
# |
| 281 |
#filteradd_to_list() |
| 282 |
#{ |
| 283 |
# local dlist ditem list_c item_c is_blacklisted |
| 284 |
# |
| 285 |
# # Add $1 to the list identified by $2, but only if $1 is not |
| 286 |
# # found in a blacklist. |
| 287 |
# |
| 288 |
# # Note: $2 can actually be a list of items. |
| 289 |
# dlist=\$"$1" |
| 290 |
# ditem=\$"$2" |
| 291 |
# |
| 292 |
# # Acquire the contents of $list and $item and store them in list_c |
| 293 |
# # and item_c, respectively. |
| 294 |
# list_c=$(eval "expr \"$dlist\" ") |
| 295 |
# item_c=$(eval "expr \"$ditem\" ") |
| 296 |
# |
| 297 |
# # Iterate over $item_c in case it is actually multiple items. |
| 298 |
# for cur_item in $item_c; do |
| 299 |
# |
| 300 |
# is_blacklisted=$(is_in_list "${cur_item}" "${config_blist}") |
| 301 |
# if [ ${is_blacklisted} == "false" ]; then |
| 302 |
# |
| 303 |
# # If cur_item is not blacklisted, add it to list_c. |
| 304 |
# list_c="${list_c} ${cur_item}" |
| 305 |
# fi |
| 306 |
# done |
| 307 |
# |
| 308 |
# # Update the argument. |
| 309 |
# eval "$1=\"${list_c}\"" |
| 310 |
#} |
| 311 |
|
| 312 |
pass_config_kernel_registries() |
| 313 |
{ |
| 314 |
local filename passnum |
| 315 |
local all_blist |
| 316 |
local curline list item config kernels |
| 317 |
local cname clist klist |
| 318 |
|
| 319 |
# Read function arguments: |
| 320 |
# first argument: the file containing the configuration registry. |
| 321 |
# second argument: the pass number: 0 or 1. Pass 0 builds the |
| 322 |
# indirect config blacklist (indirect_blist) ONLY. Pass 1 actually |
| 323 |
# begins populating the config and kernel registries, and assumes |
| 324 |
# the indirect_blist has already been created. |
| 325 |
filename="$1" |
| 326 |
passnum="$2" |
| 327 |
|
| 328 |
# Initialize a list of indirect blacklisted configurations for the |
| 329 |
# current iteration. These are configurations that are invalidated by |
| 330 |
# the removal of blacklisted configurations. For example, if haswell |
| 331 |
# is registered as needing the 'haswell' and 'zen' kernel sets: |
| 332 |
# |
| 333 |
# haswell: haswell/haswell/zen |
| 334 |
# |
| 335 |
# and 'zen' was blacklisted because of the compiler version, then the |
| 336 |
# 'haswell' configuration must be omitted from the registry, as it no |
| 337 |
# longer has all of the kernel sets it was expecting. |
| 338 |
if [ "${passnum}" == "0" ]; then |
| 339 |
indirect_blist="" |
| 340 |
fi |
| 341 |
|
| 342 |
# For convenience, merge the original and indirect blacklists. |
| 343 |
# NOTE: During pass 0, all_blist is equal to config_blist, since |
| 344 |
# indirect_blist is still empty. |
| 345 |
all_blist="${config_blist} ${indirect_blist}" |
| 346 |
|
| 347 |
# Disable support for indirect blacklisting by returning early during |
| 348 |
# pass 0. See issue #214 for details [1]. Basically, I realized that |
| 349 |
# indirect blacklisting is not needed in the use case that I envisioned |
| 350 |
# in the real-life example above. If a subconfiguration such as haswell |
| 351 |
# is defined to require the zen kernel set, it implies that the zen |
| 352 |
# kernels can be compiled with haswell compiler flags. That is, just |
| 353 |
# because the zen subconfig (and its compiler flags) is blacklisted |
| 354 |
# does not mean that the haswell subconfig cannot compile the zen |
| 355 |
# kernels with haswell-specific flags. |
| 356 |
# |
| 357 |
# [1] https://github.com/flame/blis/issues/214 |
| 358 |
# |
| 359 |
if [ "${passnum}" == "0" ]; then |
| 360 |
return |
| 361 |
fi |
| 362 |
|
| 363 |
while read -r line |
| 364 |
do |
| 365 |
curline="${line}" |
| 366 |
|
| 367 |
# Remove everything after comment character '#'. |
| 368 |
curline=${curline%%#*} |
| 369 |
|
| 370 |
# We've stripped out leading whitespace and trailing comments. If |
| 371 |
# the line is now empty, then we can skip it altogether. |
| 372 |
if [ "x${curline}" = "x" ]; then |
| 373 |
continue; |
| 374 |
fi |
| 375 |
|
| 376 |
# Read the config name and config list for the current line. |
| 377 |
cname=${curline%%:*} |
| 378 |
list=${curline##*:} |
| 379 |
|
| 380 |
# If we encounter a slash, it means the name of the configuration |
| 381 |
# and the kernel set needed by that configuration are different. |
| 382 |
if [[ "${list}" == *[/]* ]]; then |
| 383 |
|
| 384 |
#echo "Slash found." |
| 385 |
klist="" |
| 386 |
clist="" |
| 387 |
for item in "${list}"; do |
| 388 |
|
| 389 |
# The sub-configuration name is always the first sub-word in |
| 390 |
# the slash-separated compound word. |
| 391 |
config=${item%%/*} |
| 392 |
|
| 393 |
# Delete the sub-configuration name from the front of the |
| 394 |
# string, leaving the slash-separated kernel names (or just |
| 395 |
# the kernel name, if there is only one). |
| 396 |
kernels=${list#*/} |
| 397 |
|
| 398 |
# Replace the slashes with spaces to transform the string |
| 399 |
# into a space-separated list of kernel names. |
| 400 |
kernels=$(echo -e ${kernels} | sed -e "s/\// /g") |
| 401 |
|
| 402 |
clist="${clist} ${config}" |
| 403 |
klist="${klist} ${kernels}" |
| 404 |
done |
| 405 |
else |
| 406 |
|
| 407 |
#echo "Slash not found." |
| 408 |
clist=${list} |
| 409 |
klist=${list} |
| 410 |
fi |
| 411 |
|
| 412 |
# Strip out whitespace from the config name and config/kernel list |
| 413 |
# on each line. |
| 414 |
cname=$(canonicalize_ws "${cname}") |
| 415 |
clist=$(canonicalize_ws "${clist}") |
| 416 |
klist=$(canonicalize_ws "${klist}") |
| 417 |
|
| 418 |
# Next, we prepare to: |
| 419 |
# - pass 0: inspect klist for blacklisted configurations, which may |
| 420 |
# reveal configurations as needing to be indirectly blacklisted. |
| 421 |
# - pass 1: compare cname to the blacklists and commit clist/klist |
| 422 |
# to their respective registries, as appropriate. |
| 423 |
|
| 424 |
# Handle singleton and umbrella configuration entries separately. |
| 425 |
if [ $(is_singleton_family "${cname}" "${clist}") == "true" ]; then |
| 426 |
|
| 427 |
# Singleton configurations/families. |
| 428 |
# Note: for singleton families, clist contains one item, which |
| 429 |
# always equals cname, but klist could contain more than one |
| 430 |
# item. |
| 431 |
|
| 432 |
# Only consider updating the indirect blacklist (pass 0) or |
| 433 |
# committing clist and klist to the registries (pass 1) if the |
| 434 |
# configuration name (cname) is not blacklisted. |
| 435 |
if [ $(is_in_list "${cname}" "${all_blist}") == "false" ]; then |
| 436 |
|
| 437 |
if [ "${passnum}" == "0" ]; then |
| 438 |
# Even if the cname isn't blacklisted, one of the requisite |
| 439 |
# kernels might be, so we need to check klist for blacklisted |
| 440 |
# items. If we find one, we must assume that the entire entry |
| 441 |
# must be thrown out. (Ideally, we would simply fall back to |
| 442 |
# reference code for the blacklisted kernels, but that is not |
| 443 |
# at all straightforward under the current configuration |
| 444 |
# system architecture.) Thus, we add cname to the indirect |
| 445 |
# blacklist. |
| 446 |
for item in ${klist}; do |
| 447 |
if [ $(is_in_list "${item}" "${config_blist}") == "true" ]; then |
| 448 |
indirect_blist="${indirect_blist} ${cname}" |
| 449 |
break |
| 450 |
fi |
| 451 |
done |
| 452 |
fi |
| 453 |
|
| 454 |
if [ "${passnum}" == "1" ]; then |
| 455 |
# Store the clist to the cname key of the config registry. |
| 456 |
#config_registry[${cname}]=${clist} |
| 457 |
#printf -v "config_registry_${cname}" %s "${clist}" |
| 458 |
assign_key_value "config_registry" "${cname}" "${clist}" |
| 459 |
fi |
| 460 |
fi |
| 461 |
|
| 462 |
if [ "${passnum}" == "1" ]; then |
| 463 |
# Store the klist to the cname key of the kernel registry. |
| 464 |
#kernel_registry[${cname}]=${klist} |
| 465 |
#printf -v "kernel_registry_${cname}" %s "${klist}" |
| 466 |
assign_key_value "kernel_registry" "${cname}" "${klist}" |
| 467 |
fi |
| 468 |
|
| 469 |
else |
| 470 |
# Umbrella configurations/families. |
| 471 |
|
| 472 |
# First we check cname, which should generally not be blacklisted |
| 473 |
# for umbrella families, but we check anyway just to be safe. |
| 474 |
if [ $(is_in_list "${cname}" "${all_blist}") == "false" ]; then |
| 475 |
|
| 476 |
if [ "${passnum}" == "1" ]; then |
| 477 |
|
| 478 |
# Check each item in the clist and klist. (At this point, |
| 479 |
# clist == klist.) If any sub-config is blacklisted, we |
| 480 |
# omit it from clist and klist. |
| 481 |
for item in ${clist}; do |
| 482 |
|
| 483 |
if [ $(is_in_list "${item}" "${all_blist}") == "true" ]; then |
| 484 |
clist=$(remove_from_list "${item}" "${clist}") |
| 485 |
klist=$(remove_from_list "${item}" "${klist}") |
| 486 |
fi |
| 487 |
done |
| 488 |
|
| 489 |
# Store the config and kernel lists to entries that |
| 490 |
# corresponds to the config name. |
| 491 |
#config_registry[${cname}]=${clist} |
| 492 |
#kernel_registry[${cname}]=${klist} |
| 493 |
#printf -v "config_registry_${cname}" %s "${clist}" |
| 494 |
#printf -v "kernel_registry_${cname}" %s "${klist}" |
| 495 |
assign_key_value "config_registry" "${cname}" "${clist}" |
| 496 |
assign_key_value "kernel_registry" "${cname}" "${klist}" |
| 497 |
fi |
| 498 |
fi |
| 499 |
fi |
| 500 |
|
| 501 |
done < "${filename}" |
| 502 |
|
| 503 |
if [ "${passnum}" == "0" ]; then |
| 504 |
# Assign the final indirect blacklist (with whitespace removed). |
| 505 |
indirect_blist="$(canonicalize_ws ${indirect_blist})" |
| 506 |
fi |
| 507 |
} |
| 508 |
|
| 509 |
read_registry_file() |
| 510 |
{ |
| 511 |
local filename |
| 512 |
local clist klist |
| 513 |
local iterate_again config |
| 514 |
local cr_var mem mems_mem newclist |
| 515 |
local kr_var ker kers_ker newklist |
| 516 |
|
| 517 |
filename="$1" |
| 518 |
|
| 519 |
# Execute an initial pass through the config_registry file so that |
| 520 |
# we can accumulate a list of indirectly blacklisted configurations, |
| 521 |
# if any. |
| 522 |
pass_config_kernel_registries "${filename}" "0" |
| 523 |
|
| 524 |
# Now that the indirect_blist has been created, make a second pass |
| 525 |
# through the 'config_registry' file, this time creating the actual |
| 526 |
# config and kernel registry data structures. |
| 527 |
pass_config_kernel_registries "${filename}" "1" |
| 528 |
|
| 529 |
# Now we must go back through the config_registry and subsitute any |
| 530 |
# configuration families with their constituents' members. Each time |
| 531 |
# one of these substitutions occurs, we set a flag that causes us to |
| 532 |
# make one more pass. (Subsituting a singleton definition does not |
| 533 |
# prompt additional iterations.) This process stops when a full pass |
| 534 |
# does not result in any subsitution. |
| 535 |
|
| 536 |
iterate_again="1" |
| 537 |
while [ "${iterate_again}" == "1" ]; do |
| 538 |
|
| 539 |
iterate_again="0" |
| 540 |
|
| 541 |
#for config in "${!config_registry[@]}"; do |
| 542 |
for cr_var in ${!config_registry_*}; do |
| 543 |
|
| 544 |
config=${cr_var##config_registry_} |
| 545 |
|
| 546 |
clist=$(query_array "config_registry" ${config}) |
| 547 |
|
| 548 |
# The entries that define singleton families should never need |
| 549 |
# any substitution. |
| 550 |
if [ $(is_singleton_family "${config}" "${clist}") == "true" ]; then |
| 551 |
continue |
| 552 |
fi |
| 553 |
|
| 554 |
#for mem in ${config_registry[$config]}; do |
| 555 |
#for mem in ${!cr_var}; do |
| 556 |
for mem in ${clist}; do |
| 557 |
|
| 558 |
#mems_mem="${config_registry[${mem}]}" |
| 559 |
mems_mem=$(query_array "config_registry" ${mem}) |
| 560 |
|
| 561 |
# If mems_mem is empty string, then mem was not found as a key |
| 562 |
# in the config list associative array. In that case, we continue |
| 563 |
# and will echo an error later in the script. |
| 564 |
if [ "${mems_mem}" == "" ]; then |
| 565 |
#echo " config for ${mem} is empty string! no entry in config list." |
| 566 |
continue; |
| 567 |
fi |
| 568 |
|
| 569 |
if [ "${mem}" != "${mems_mem}" ]; then |
| 570 |
|
| 571 |
#clist="${config_registry[$config]}" |
| 572 |
clist=$(query_array "config_registry" ${config}) |
| 573 |
|
| 574 |
# Replace the current config with its constituent config set, |
| 575 |
# canonicalize whitespace, and then remove duplicate config |
| 576 |
# set names, if they exist. Finally, update the config registry |
| 577 |
# with the new config list. |
| 578 |
newclist=$(echo -e "${clist}" | sed -e "s/${mem}/${mems_mem}/g") |
| 579 |
newclist=$(canonicalize_ws "${newclist}") |
| 580 |
newclist=$(rm_duplicate_words "${newclist}") |
| 581 |
|
| 582 |
#config_registry[${config}]=${newclist} |
| 583 |
#printf -v "config_registry_${config}" %s "${newclist}" |
| 584 |
assign_key_value "config_registry" "${config}" "${newclist}" |
| 585 |
|
| 586 |
# Since we performed a substitution and changed the config |
| 587 |
# list, mark the iteration flag to continue another round, |
| 588 |
# but only if the config (mem) value is NOT present |
| 589 |
# in the list of sub-configs. If it is present, then further |
| 590 |
# substitution may not necessarily be needed this round. |
| 591 |
if [ $(is_in_list "${mem}" "${mems_mem}") == "false" ]; then |
| 592 |
iterate_again="1" |
| 593 |
fi |
| 594 |
fi |
| 595 |
done |
| 596 |
done |
| 597 |
done |
| 598 |
|
| 599 |
# Similar to what we just did for the config_registry, we now iterate |
| 600 |
# through the kernel_registry and substitute any configuration families |
| 601 |
# in the kernel list (right side of ':') with the members of that |
| 602 |
# family's kernel set. This process continues iteratively, as before, |
| 603 |
# until all families have been replaced with singleton configurations' |
| 604 |
# kernel sets. |
| 605 |
|
| 606 |
iterate_again="1" |
| 607 |
while [ "${iterate_again}" == "1" ]; do |
| 608 |
|
| 609 |
iterate_again="0" |
| 610 |
|
| 611 |
#for config in "${!kernel_registry[@]}"; do |
| 612 |
for kr_var in ${!kernel_registry_*}; do |
| 613 |
|
| 614 |
config=${kr_var##kernel_registry_} |
| 615 |
|
| 616 |
klist=$(query_array "kernel_registry" ${config}) |
| 617 |
|
| 618 |
# The entries that define singleton families should never need |
| 619 |
# any substitution. In the kernel registry, we know it's a |
| 620 |
# singleton entry when the cname occurs somewhere in the klist. |
| 621 |
# (This is slightly different than the same test in the config |
| 622 |
# registry, where we test that clist is one word and that |
| 623 |
# clist == cname.) |
| 624 |
if [ $(is_in_list "${config}" "${klist}") == "true" ]; then |
| 625 |
#echo "debug: '${config}' not found in '${klist}'; skipping." |
| 626 |
continue |
| 627 |
fi |
| 628 |
|
| 629 |
#for ker in ${kernel_registry[$config]}; do |
| 630 |
#for ker in ${!kr_var}; do |
| 631 |
for ker in ${klist}; do |
| 632 |
|
| 633 |
#kers_ker="${kernel_registry[${ker}]}" |
| 634 |
kers_ker=$(query_array "kernel_registry" ${ker}) |
| 635 |
|
| 636 |
# If kers_ker is empty string, then ker was not found as a key |
| 637 |
# in the kernel registry. While not common, this can happen |
| 638 |
# when ker identifies a kernel set that does not correspond to |
| 639 |
# any configuration. (Example: armv7a and armv8a kernel sets are |
| 640 |
# used by cortexa* configurations, but do not corresond to their |
| 641 |
# own configurations.) |
| 642 |
if [ "${kers_ker}" == "" ]; then |
| 643 |
#echo "debug: ${ker} not found in kernel registry." |
| 644 |
continue |
| 645 |
fi |
| 646 |
|
| 647 |
# If the current config/kernel (ker) differs from its singleton kernel |
| 648 |
# entry (kers_ker), then that singleton entry was specified to use |
| 649 |
# a different configuration's kernel set. Thus, we need to replace the |
| 650 |
# occurrence in the current config/kernel name with that of the kernel |
| 651 |
# set it needs. |
| 652 |
if [ "${ker}" != "${kers_ker}" ]; then |
| 653 |
|
| 654 |
#klisttmp="${kernel_registry[$config]}" |
| 655 |
klisttmp=$(query_array "kernel_registry" ${config}) |
| 656 |
|
| 657 |
# Replace the current config with its requisite kernels, |
| 658 |
# canonicalize whitespace, and then remove duplicate kernel |
| 659 |
# set names, if they exist. Finally, update the kernel registry |
| 660 |
# with the new kernel list. |
| 661 |
newklist=$(echo -e "${klisttmp}" | sed -e "s/${ker}/${kers_ker}/g") |
| 662 |
newklist=$(canonicalize_ws "${newklist}") |
| 663 |
newklist=$(rm_duplicate_words "${newklist}") |
| 664 |
|
| 665 |
#kernel_registry[${config}]=${newklist} |
| 666 |
#printf -v "kernel_registry_${config}" %s "${newklist}" |
| 667 |
assign_key_value "kernel_registry" "${config}" "${newklist}" |
| 668 |
|
| 669 |
# Since we performed a substitution and changed the kernel |
| 670 |
# list, mark the iteration flag to continue another round, |
| 671 |
# unless we just substituted using a singleton family |
| 672 |
# definition, in which case we don't necessarily need to |
| 673 |
# iterate further this round. |
| 674 |
if [ $(is_in_list "${ker}" "${kers_ker}") == "false" ]; then |
| 675 |
iterate_again="1" |
| 676 |
fi |
| 677 |
fi |
| 678 |
done |
| 679 |
done |
| 680 |
done |
| 681 |
} |
| 682 |
|
| 683 |
build_kconfig_registry() |
| 684 |
{ |
| 685 |
local familyname clist config kernels kernel cur_configs newvalue |
| 686 |
|
| 687 |
familyname="$1" |
| 688 |
|
| 689 |
#clist="${config_registry[${familyname}]}" |
| 690 |
clist=$(query_array "config_registry" ${familyname}) |
| 691 |
|
| 692 |
for config in ${clist}; do |
| 693 |
|
| 694 |
# Look up the kernels for the current sub-configuration. |
| 695 |
#kernels="${kernel_registry[${config}]}" |
| 696 |
kernels=$(query_array "kernel_registry" ${config}) |
| 697 |
|
| 698 |
for kernel in ${kernels}; do |
| 699 |
|
| 700 |
# Add the sub-configuration to the list associated with the |
| 701 |
# kernel. |
| 702 |
|
| 703 |
# Query the current sub-configs for the current ${kernel}. |
| 704 |
#cur_configs="${kconfig_registry[${kernel}]}" |
| 705 |
cur_configs=$(query_array "kconfig_registry" ${kernel}) |
| 706 |
|
| 707 |
# Add the current sub-configuration to the list of sub-configs |
| 708 |
# we just queried. |
| 709 |
newvalue=$(canonicalize_ws "${cur_configs} ${config}") |
| 710 |
|
| 711 |
# Update the array. |
| 712 |
#kconfig_registry[${kernel}]="${newvalue}" |
| 713 |
#printf -v "kconfig_registry_${kernel}" %s "${newvalue}" |
| 714 |
assign_key_value "kconfig_registry" "${kernel}" "${newvalue}" |
| 715 |
|
| 716 |
done |
| 717 |
|
| 718 |
done |
| 719 |
} |
| 720 |
|
| 721 |
is_in_list() |
| 722 |
{ |
| 723 |
local word list rval item |
| 724 |
|
| 725 |
word="$1" |
| 726 |
list="$2" |
| 727 |
rval="false" |
| 728 |
|
| 729 |
for item in ${list}; do |
| 730 |
|
| 731 |
if [ "${item}" == "${word}" ]; then |
| 732 |
rval="true" |
| 733 |
break |
| 734 |
fi |
| 735 |
done |
| 736 |
|
| 737 |
echo "${rval}" |
| 738 |
} |
| 739 |
|
| 740 |
is_singleton() |
| 741 |
{ |
| 742 |
local list rval count_str item |
| 743 |
|
| 744 |
list="$1" |
| 745 |
rval="false" |
| 746 |
|
| 747 |
count_str="" |
| 748 |
for item in ${list}; do |
| 749 |
|
| 750 |
count_str="${count_str}x" |
| 751 |
done |
| 752 |
|
| 753 |
if [ "${count_str}" == "x" ]; then |
| 754 |
rval="true" |
| 755 |
fi |
| 756 |
|
| 757 |
echo "${rval}" |
| 758 |
} |
| 759 |
|
| 760 |
is_singleton_family() |
| 761 |
{ |
| 762 |
local familyname memberlist rval |
| 763 |
|
| 764 |
familyname="$1" |
| 765 |
memberlist="$2" |
| 766 |
|
| 767 |
rval="false" |
| 768 |
|
| 769 |
if [ $(is_singleton "${memberlist}") ]; then |
| 770 |
|
| 771 |
if [ "${memberlist}" == "${familyname}" ]; then |
| 772 |
rval="true" |
| 773 |
fi |
| 774 |
fi |
| 775 |
|
| 776 |
echo "${rval}" |
| 777 |
} |
| 778 |
|
| 779 |
remove_from_list() |
| 780 |
{ |
| 781 |
local strike_list list flist item |
| 782 |
|
| 783 |
strike_words="$1" |
| 784 |
list="$2" |
| 785 |
flist="" |
| 786 |
|
| 787 |
for item in ${list}; do |
| 788 |
|
| 789 |
# Filter out any list item that matches any of the strike words. |
| 790 |
if [ $(is_in_list "${item}" "${strike_words}") == "false" ]; then |
| 791 |
flist="${flist} ${item}" |
| 792 |
fi |
| 793 |
done |
| 794 |
|
| 795 |
flist=$(canonicalize_ws "${flist}") |
| 796 |
|
| 797 |
# Return the filtered list. |
| 798 |
echo "${flist}" |
| 799 |
} |
| 800 |
|
| 801 |
canonicalize_ws() |
| 802 |
{ |
| 803 |
local str |
| 804 |
|
| 805 |
str="$1" |
| 806 |
|
| 807 |
# Remove leading and trailing whitespace. |
| 808 |
str=$(echo -e "${str}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') |
| 809 |
|
| 810 |
# Remove duplicate spaces between words. |
| 811 |
str=$(echo -e "${str}" | tr -s " ") |
| 812 |
|
| 813 |
# Update the input argument. |
| 814 |
echo "${str}" |
| 815 |
} |
| 816 |
|
| 817 |
rm_duplicate_words() |
| 818 |
{ |
| 819 |
local str revstr revres res |
| 820 |
|
| 821 |
str="$1" |
| 822 |
|
| 823 |
# We reverse the initial string, THEN remove duplicates, then reverse |
| 824 |
# the de-duplicated result so that only the last instance is kept after |
| 825 |
# removing duplicates (rather than keeping only the first). This is |
| 826 |
# totally unnecessary but works well for the kinds of duplicates that |
| 827 |
# show up in certain use cases of the config and kernel registries. |
| 828 |
# For example, these gymnastics allow us to keep only the last instance |
| 829 |
# of the 'generic' configuration in a configuration family that |
| 830 |
# includes it twice or more. |
| 831 |
revstr=$(echo "${str}" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }') |
| 832 |
revres=$(echo "${revstr}" | awk '{for (i=1;i<=NF;i++) if (!a[$i]++) printf("%s%s",$i,FS)}{printf("\n")}') |
| 833 |
res=$(echo "${revres}" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }') |
| 834 |
|
| 835 |
echo "${res}" |
| 836 |
} |
| 837 |
|
| 838 |
get_cc_search_list() |
| 839 |
{ |
| 840 |
local list |
| 841 |
|
| 842 |
# For Linux, Darwin (OS X), and generic OSes, prioritize gcc. |
| 843 |
list="gcc clang cc" |
| 844 |
|
| 845 |
# For OpenBSD and FreeBSD, prioritize cc and clang over gcc. |
| 846 |
if [ "${os_name}" = "OpenBSD" ]; then |
| 847 |
list="cc clang gcc" |
| 848 |
elif [ "${os_name}" = "FreeBSD" ]; then |
| 849 |
list="cc clang gcc" |
| 850 |
fi |
| 851 |
|
| 852 |
echo "${list}" |
| 853 |
} |
| 854 |
|
| 855 |
get_cxx_search_list() |
| 856 |
{ |
| 857 |
local list |
| 858 |
|
| 859 |
# For Linux, Darwin (OS X), and generic OSes, prioritize g++. |
| 860 |
list="g++ clang++ c++" |
| 861 |
|
| 862 |
# For OpenBSD and FreeBSD, prioritize cc and clang over gcc. |
| 863 |
if [ "${os_name}" = "OpenBSD" ]; then |
| 864 |
list="c++ clang++ g++" |
| 865 |
elif [ "${os_name}" = "FreeBSD" ]; then |
| 866 |
list="c++ clang++ g++" |
| 867 |
fi |
| 868 |
|
| 869 |
echo "${list}" |
| 870 |
} |
| 871 |
|
| 872 |
select_cc() |
| 873 |
{ |
| 874 |
local search_list CC_env the_cc cc |
| 875 |
|
| 876 |
# This is the list of compilers to search for, and the order in which |
| 877 |
# to search for them. |
| 878 |
search_list=$1 |
| 879 |
|
| 880 |
# The environment variable associated with the compiler type we |
| 881 |
# are searching (e.g. CC, CXX). |
| 882 |
CC_env=$2 |
| 883 |
|
| 884 |
# If CC contains something, add it to the beginning of our default |
| 885 |
# search list. |
| 886 |
if [ -n "${CC_env}" ]; then |
| 887 |
search_list="${CC_env} ${search_list}" |
| 888 |
fi |
| 889 |
|
| 890 |
# Initialize our selected compiler to empty. |
| 891 |
the_cc="" |
| 892 |
|
| 893 |
# Try each compiler in the list and select the first one we find that |
| 894 |
# works. |
| 895 |
for cc in ${search_list}; do |
| 896 |
|
| 897 |
# See if the current compiler works and/or is present. |
| 898 |
${cc} --version > /dev/null 2>&1 |
| 899 |
|
| 900 |
if [ "$?" == 0 ]; then |
| 901 |
the_cc=${cc} |
| 902 |
break |
| 903 |
fi |
| 904 |
done |
| 905 |
|
| 906 |
# Return the selected compiler. |
| 907 |
echo "${the_cc}" |
| 908 |
} |
| 909 |
|
| 910 |
auto_detect() |
| 911 |
{ |
| 912 |
local cc cflags config_defines detected_config rval |
| 913 |
|
| 914 |
# Use the same compiler that was found earlier. |
| 915 |
cc="${found_cc}" |
| 916 |
|
| 917 |
# For debugging: reveal what compiler was chosen for auto-detection. |
| 918 |
#touch "${cc}.txt" |
| 919 |
|
| 920 |
# Tweak the flags we use based on the compiler. This is mostly just |
| 921 |
# an opportunity to turn off annoying warnings that some compilers |
| 922 |
# may throw off. |
| 923 |
if [ "${cc}" == "clang" ]; then |
| 924 |
cflags="-Wno-tautological-compare" |
| 925 |
else |
| 926 |
cflags= |
| 927 |
fi |
| 928 |
|
| 929 |
# Locate our source files. |
| 930 |
bli_arch_c="bli_arch.c" |
| 931 |
bli_cpuid_c="bli_cpuid.c" |
| 932 |
main_c="config_detect.c" |
| 933 |
|
| 934 |
bli_arch_c_filepath=$(find ${dist_path}/frame -name "${bli_arch_c}") |
| 935 |
bli_cpuid_c_filepath=$(find ${dist_path}/frame -name "${bli_cpuid_c}") |
| 936 |
main_c_filepath=$(find ${dist_path}/build -name "${main_c}") |
| 937 |
|
| 938 |
# Locate headers needed directly by the above files. |
| 939 |
bli_arch_h="bli_arch.h" |
| 940 |
bli_cpuid_h="bli_cpuid.h" |
| 941 |
bli_typed_h="bli_type_defs.h" |
| 942 |
|
| 943 |
bli_arch_h_filepath=$(find ${dist_path}/frame -name "${bli_arch_h}") |
| 944 |
bli_cpuid_h_filepath=$(find ${dist_path}/frame -name "${bli_cpuid_h}") |
| 945 |
bli_typed_h_filepath=$(find ${dist_path}/frame -name "${bli_typed_h}") |
| 946 |
|
| 947 |
bli_arch_h_path=${bli_arch_h_filepath%/${bli_arch_h}} |
| 948 |
bli_cpuid_h_path=${bli_cpuid_h_filepath%/${bli_cpuid_h}} |
| 949 |
bli_typed_h_path=${bli_typed_h_filepath%/${bli_typed_h}} |
| 950 |
|
| 951 |
# Locate other headers needed by bli_type_defs.h. |
| 952 |
bli_malloc_h="bli_malloc.h" |
| 953 |
bli_malloc_h_filepath=$(find ${dist_path}/frame -name "${bli_malloc_h}") |
| 954 |
bli_malloc_h_path=${bli_malloc_h_filepath%/${bli_malloc_h}} |
| 955 |
|
| 956 |
# Define the executable name. |
| 957 |
autodetect_x="auto-detect.x" |
| 958 |
|
| 959 |
# Create #defines for all of the BLIS_CONFIG_ macros in bli_cpuid.c. |
| 960 |
config_defines=$(grep BLIS_CONFIG_ ${bli_cpuid_c_filepath} \ |
| 961 |
| sed -e 's/#ifdef /-D/g') |
| 962 |
|
| 963 |
# Set the linker flags. We need pthreads because it is needed for |
| 964 |
# parts of bli_arch.c unrelated to bli_arch_string(), which is called |
| 965 |
# by the main() function in ${main_c}. |
| 966 |
ldflags="${LIBPTHREAD:--lpthread}" |
| 967 |
|
| 968 |
# Compile the auto-detect program using source code inside the |
| 969 |
# framework. |
| 970 |
${cc} ${config_defines} \ |
| 971 |
-DBLIS_CONFIGURETIME_CPUID \ |
| 972 |
-I${bli_cpuid_h_path} \ |
| 973 |
-I${bli_arch_h_path} \ |
| 974 |
-I${bli_typed_h_path} \ |
| 975 |
-I${bli_malloc_h_path} \ |
| 976 |
-std=c99 \ |
| 977 |
${cflags} \ |
| 978 |
${bli_arch_c_filepath} \ |
| 979 |
${bli_cpuid_c_filepath} \ |
| 980 |
${ldflags} \ |
| 981 |
${main_c_filepath} \ |
| 982 |
-o ${autodetect_x} |
| 983 |
|
| 984 |
# Run the auto-detect program. |
| 985 |
detected_config=$(./${autodetect_x}) |
| 986 |
|
| 987 |
# Remove the executable file. |
| 988 |
rm -f ./${autodetect_x} |
| 989 |
|
| 990 |
# Return the detected sub-configuration name. |
| 991 |
echo "${detected_config}" |
| 992 |
} |
| 993 |
|
| 994 |
has_libmemkind() |
| 995 |
{ |
| 996 |
local main_c main_c_filepath LDFLAGS_mk binname rval |
| 997 |
|
| 998 |
# Path to libmemkind detection source file. |
| 999 |
main_c="libmemkind_detect.c" |
| 1000 |
main_c_filepath=$(find ${dist_path}/build -name "${main_c}") |
| 1001 |
|
| 1002 |
# Add libmemkind to LDFLAGS. |
| 1003 |
LDFLAGS_mk="${LDFLAGS} -lmemkind" |
| 1004 |
|
| 1005 |
# Binary executable filename. |
| 1006 |
binname="libmemkind-detect.x" |
| 1007 |
|
| 1008 |
# Attempt to compile a simple main() program that contains a call |
| 1009 |
# to hbw_malloc() and that links to libmemkind. |
| 1010 |
${found_cc} -o ${binname} ${main_c_filepath} ${LDFLAGS_mk} 2> /dev/null |
| 1011 |
|
| 1012 |
# Depending on the return code from the compile step above, we set |
| 1013 |
# enable_memkind accordingly. |
| 1014 |
if [ "$?" == 0 ]; then |
| 1015 |
rval='yes' |
| 1016 |
else |
| 1017 |
rval='no' |
| 1018 |
fi |
| 1019 |
|
| 1020 |
# Remove the executable generated above. |
| 1021 |
rm -f ./${binname} |
| 1022 |
|
| 1023 |
echo "${rval}" |
| 1024 |
} |
| 1025 |
|
| 1026 |
echoerr() |
| 1027 |
{ |
| 1028 |
printf "${script_name}: error: %s\n" "$*" #>&2; |
| 1029 |
} |
| 1030 |
|
| 1031 |
echowarn() |
| 1032 |
{ |
| 1033 |
printf "${script_name}: warning: %s\n" "$*" #>&2; |
| 1034 |
} |
| 1035 |
|
| 1036 |
blacklistcc_add() |
| 1037 |
{ |
| 1038 |
# Check whether we've already blacklisted the given sub-config so |
| 1039 |
# we don't output redundant messages. |
| 1040 |
if [ $(is_in_list "$1" "${config_blist}") == "false" ]; then |
| 1041 |
|
| 1042 |
echowarn "${cc_vendor} ${cc_version} does not support '$1'; adding to blacklist." |
| 1043 |
config_blist="${config_blist} $1" |
| 1044 |
fi |
| 1045 |
} |
| 1046 |
|
| 1047 |
blacklistbu_add() |
| 1048 |
{ |
| 1049 |
# Check whether we've already blacklisted the given sub-config so |
| 1050 |
# we don't output redundant messages. |
| 1051 |
if [ $(is_in_list "$1" "${config_blist}") == "false" ]; then |
| 1052 |
|
| 1053 |
echowarn "assembler ('as' ${bu_version}) does not support '$1'; adding to blacklist." |
| 1054 |
config_blist="${config_blist} $1" |
| 1055 |
fi |
| 1056 |
} |
| 1057 |
|
| 1058 |
blacklist_init() |
| 1059 |
{ |
| 1060 |
config_blist="" |
| 1061 |
} |
| 1062 |
|
| 1063 |
blacklist_cleanup() |
| 1064 |
{ |
| 1065 |
# Remove duplicates and whitespace from the blacklist. |
| 1066 |
config_blist=$(rm_duplicate_words "${config_blist}") |
| 1067 |
config_blist=$(canonicalize_ws "${config_blist}") |
| 1068 |
} |
| 1069 |
|
| 1070 |
echoerr_unsupportedcc() |
| 1071 |
{ |
| 1072 |
echoerr "${script_name}: *** Unsupported compiler version: ${cc_vendor} ${cc_version}." |
| 1073 |
exit 1 |
| 1074 |
} |
| 1075 |
|
| 1076 |
get_binutils_version() |
| 1077 |
{ |
| 1078 |
binutil=${AS:-as} |
| 1079 |
|
| 1080 |
# Query the full binutils version string output. This includes the |
| 1081 |
# version string along with (potentially) a bunch of other textual |
| 1082 |
# clutter. |
| 1083 |
if [ "$(uname -s)" == "Darwin" ]; then |
| 1084 |
# The default OS X assembler uses a trifecta of brain-dead |
| 1085 |
# conventions: responding only to '-v', hanging indefinitely if |
| 1086 |
# not given an argument, and outputing the result to stderr. |
| 1087 |
# (And if you still weren't convinced, it creates an 'a.out' |
| 1088 |
# by default. So yeah.) |
| 1089 |
bu_string=$(${binutil} -v /dev/null -o /dev/null 2>&1) |
| 1090 |
else |
| 1091 |
bu_string=$(${binutil} --version 2>/dev/null) |
| 1092 |
fi |
| 1093 |
|
| 1094 |
# Query the binutils version number. |
| 1095 |
# The last part ({ read first rest ; echo $first ; }) is a workaround |
| 1096 |
# to OS X's egrep only returning the first match. |
| 1097 |
bu_version=$(echo "${bu_string}" | egrep -o '[0-9]+\.[0-9]+\.?[0-9]*' | { read first rest ; echo ${first} ; }) |
| 1098 |
|
| 1099 |
# Parse the version number into its major, minor, and revision |
| 1100 |
# components. |
| 1101 |
bu_major=$(echo "${bu_version}" | cut -d. -f1) |
| 1102 |
bu_minor=$(echo "${bu_version}" | cut -d. -f2) |
| 1103 |
bu_revision=$(echo "${bu_version}" | cut -d. -f3) |
| 1104 |
|
| 1105 |
echo "${script_name}: found assembler ('as') version ${bu_version} (maj: ${bu_major}, min: ${bu_minor}, rev: ${bu_revision})." |
| 1106 |
} |
| 1107 |
|
| 1108 |
get_compiler_version() |
| 1109 |
{ |
| 1110 |
local cc vendor_string |
| 1111 |
|
| 1112 |
cc="${found_cc}" |
| 1113 |
|
| 1114 |
# Query the full vendor version string output. This includes the |
| 1115 |
# version number along with (potentially) a bunch of other textual |
| 1116 |
# clutter. |
| 1117 |
# NOTE: This maybe should use merged stdout/stderr rather than only |
| 1118 |
# stdout. But it works for now. |
| 1119 |
vendor_string="$(${cc} --version 2>/dev/null)" |
| 1120 |
|
| 1121 |
# Query the compiler "vendor" (ie: the compiler's simple name) and |
| 1122 |
# isolate the version number. |
| 1123 |
# The last part ({ read first rest ; echo $first ; }) is a workaround |
| 1124 |
# to OS X's egrep only returning the first match. |
| 1125 |
cc_vendor=$(echo "${vendor_string}" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; }) |
| 1126 |
if [ "$cc_vendor" = "icc" -o "$cc_vendor" = "gcc" -o "$cc_vendor" = "clang" ] |
| 1127 |
then |
| 1128 |
cc_version=$(${cc} -dumpversion) |
| 1129 |
else |
| 1130 |
cc_version=$(echo "${vendor_string}" | egrep -o '[0-9]+\.[0-9]+\.?[0-9]*' | { read first rest ; echo ${first} ; }) |
| 1131 |
fi |
| 1132 |
|
| 1133 |
# Parse the version number into its major, minor, and revision |
| 1134 |
# components. |
| 1135 |
cc_major=$(echo "${cc_version}" | cut -d. -f1) |
| 1136 |
cc_minor=$(echo "${cc_version}" | cut -d. -f2) |
| 1137 |
cc_revision=$(echo "${cc_version}" | cut -d. -f3) |
| 1138 |
|
| 1139 |
echo "${script_name}: found ${cc_vendor} version ${cc_version} (maj: ${cc_major}, min: ${cc_minor}, rev: ${cc_revision})." |
| 1140 |
} |
| 1141 |
|
| 1142 |
check_compiler() |
| 1143 |
{ |
| 1144 |
local cc |
| 1145 |
|
| 1146 |
cc="${found_cc}" |
| 1147 |
|
| 1148 |
# |
| 1149 |
# Compiler requirements |
| 1150 |
# |
| 1151 |
# General: |
| 1152 |
# |
| 1153 |
# icc 15+, gcc 4.7+, clang 3.3+ |
| 1154 |
# |
| 1155 |
# Specific: |
| 1156 |
# |
| 1157 |
# skx: icc 15.0.1+, gcc 6.0+, clang 3.9+ |
| 1158 |
# knl: icc 14.0.1+, gcc 5.0+, clang 3.5+ |
| 1159 |
# haswell: any |
| 1160 |
# sandybridge: any |
| 1161 |
# penryn: any |
| 1162 |
# |
| 1163 |
# zen: gcc 6.0+[1], clang 4.0+ |
| 1164 |
# excavator: gcc 4.9+, clang 3.5+ |
| 1165 |
# steamroller: any |
| 1166 |
# piledriver: any |
| 1167 |
# bulldozer: any |
| 1168 |
# |
| 1169 |
# cortexa57: any |
| 1170 |
# cortexa15: any |
| 1171 |
# cortexa9: any |
| 1172 |
# |
| 1173 |
# generic: any |
| 1174 |
# |
| 1175 |
# Note: These compiler requirements were originally modeled after similar |
| 1176 |
# requirements encoded into TBLIS's configure.ac [2]. |
| 1177 |
# |
| 1178 |
# [1] While gcc 6.0 or newer is needed for zen support (-march=znver1), |
| 1179 |
# we relax this compiler version constraint a bit by targeting bdver4 |
| 1180 |
# and then disabling the instruction sets that were removed in the |
| 1181 |
# transition from bdver4 to znver1. (See config/zen/make_defs.mk for |
| 1182 |
# the specific compiler flags used.) |
| 1183 |
# [2] https://github.com/devinamatthews/tblis/ |
| 1184 |
# |
| 1185 |
|
| 1186 |
echo "${script_name}: checking for blacklisted configurations due to ${cc} ${cc_version}." |
| 1187 |
|
| 1188 |
# gcc |
| 1189 |
if [ "x${cc_vendor}" = "xgcc" ]; then |
| 1190 |
|
| 1191 |
if [ ${cc_major} -lt 4 ]; then |
| 1192 |
echoerr_unsupportedcc |
| 1193 |
fi |
| 1194 |
if [ ${cc_major} -eq 4 ]; then |
| 1195 |
blacklistcc_add "knl" |
| 1196 |
if [ ${cc_minor} -lt 7 ]; then |
| 1197 |
echoerr_unsupportedcc |
| 1198 |
fi |
| 1199 |
if [ ${cc_minor} -lt 9 ]; then |
| 1200 |
blacklistcc_add "excavator" |
| 1201 |
blacklistcc_add "zen" |
| 1202 |
fi |
| 1203 |
fi |
| 1204 |
if [ ${cc_major} -lt 5 ]; then |
| 1205 |
blacklistcc_add "knl" |
| 1206 |
fi |
| 1207 |
if [ ${cc_major} -lt 6 ]; then |
| 1208 |
# Normally, zen would be blacklisted for gcc prior to 6.0. |
| 1209 |
# However, we have a workaround in place in the zen |
| 1210 |
# configuration's make_defs.mk file that starts with bdver4 |
| 1211 |
# and disables the instructions that were removed in znver1. |
| 1212 |
# Thus, this "blacklistcc_add" statement has been moved above. |
| 1213 |
#blacklistcc_add "zen" |
| 1214 |
blacklistcc_add "skx" |
| 1215 |
fi |
| 1216 |
fi |
| 1217 |
|
| 1218 |
# icc |
| 1219 |
if [ "x${cc_vendor}" = "xicc" ]; then |
| 1220 |
|
| 1221 |
if [ ${cc_major} -lt 15 ]; then |
| 1222 |
echoerr_unsupportedcc |
| 1223 |
fi |
| 1224 |
if [ ${cc_major} -eq 15 ]; then |
| 1225 |
if [ ${cc_revision} -lt 1 ]; then |
| 1226 |
blacklistcc_add "skx" |
| 1227 |
fi |
| 1228 |
fi |
| 1229 |
fi |
| 1230 |
|
| 1231 |
# clang |
| 1232 |
if [ "x${cc_vendor}" = "xclang" ]; then |
| 1233 |
|
| 1234 |
if [ ${cc_major} -lt 3 ]; then |
| 1235 |
echoerr_unsupportedcc |
| 1236 |
fi |
| 1237 |
if [ ${cc_major} -eq 3 ]; then |
| 1238 |
if [ ${cc_minor} -lt 3 ]; then |
| 1239 |
echoerr_unsupportedcc |
| 1240 |
fi |
| 1241 |
if [ ${cc_minor} -lt 5 ]; then |
| 1242 |
blacklistcc_add "excavator" |
| 1243 |
blacklistcc_add "zen" |
| 1244 |
blacklistcc_add "knl" |
| 1245 |
fi |
| 1246 |
if [ ${cc_minor} -lt 9 ]; then |
| 1247 |
blacklistcc_add "skx" |
| 1248 |
fi |
| 1249 |
fi |
| 1250 |
if [ ${cc_major} -lt 4 ]; then |
| 1251 |
# See comment above regarding zen support. |
| 1252 |
#blacklistcc_add "zen" |
| 1253 |
: # explicit no-op since bash can't handle empty loop bodies. |
| 1254 |
fi |
| 1255 |
fi |
| 1256 |
} |
| 1257 |
|
| 1258 |
check_assembler() |
| 1259 |
{ |
| 1260 |
local cc asm_dir cflags asm_fp |
| 1261 |
|
| 1262 |
cc="${found_cc}" |
| 1263 |
|
| 1264 |
# The directory where the assembly files will be. |
| 1265 |
asm_dir="${dist_path}/build" |
| 1266 |
|
| 1267 |
# Most of the time, we won't need any additional compiler flags. |
| 1268 |
cflags="" |
| 1269 |
|
| 1270 |
echo "${script_name}: checking for blacklisted configurations due to as ${bu_version}." |
| 1271 |
|
| 1272 |
# |
| 1273 |
# Check support for FMA4 (amd: bulldozer). |
| 1274 |
# |
| 1275 |
asm_fp=$(find ${asm_dir} -name "fma4.s") |
| 1276 |
knows_fma4=$(try_assemble "${cc}" "${cflags}" "${asm_fp}") |
| 1277 |
|
| 1278 |
if [ "x${knows_fma4}" == "xno" ]; then |
| 1279 |
blacklistbu_add "bulldozer" |
| 1280 |
fi |
| 1281 |
|
| 1282 |
# |
| 1283 |
# Check support for AVX (intel: sandybridge+, amd: piledriver+). |
| 1284 |
# |
| 1285 |
asm_fp=$(find ${asm_dir} -name "avx.s") |
| 1286 |
knows_avx=$(try_assemble "${cc}" "${cflags}" "${asm_fp}") |
| 1287 |
|
| 1288 |
if [ "x${knows_avx}" == "xno" ]; then |
| 1289 |
blacklistbu_add "sandybridge" |
| 1290 |
fi |
| 1291 |
|
| 1292 |
# |
| 1293 |
# Check support for FMA3 (intel: haswell+, amd: piledriver+). |
| 1294 |
# |
| 1295 |
asm_fp=$(find ${asm_dir} -name "fma3.s") |
| 1296 |
knows_fma3=$(try_assemble "${cc}" "${cflags}" "${asm_fp}") |
| 1297 |
|
| 1298 |
if [ "x${knows_fma3}" == "xno" ]; then |
| 1299 |
blacklistbu_add "haswell" |
| 1300 |
blacklistbu_add "piledriver" |
| 1301 |
blacklistbu_add "steamroller" |
| 1302 |
blacklistbu_add "excavator" |
| 1303 |
blacklistbu_add "skx" |
| 1304 |
fi |
| 1305 |
|
| 1306 |
# |
| 1307 |
# Check support for AVX-512f (knl, skx). |
| 1308 |
# |
| 1309 |
|
| 1310 |
# The assembler on OS X won't recognize AVX-512 without help. |
| 1311 |
if [ "$(uname -s)" == "Darwin" ]; then |
| 1312 |
cflags="-Wa,-march=knl" |
| 1313 |
fi |
| 1314 |
|
| 1315 |
asm_fp=$(find ${asm_dir} -name "avx512f.s") |
| 1316 |
knows_avx512f=$(try_assemble "${cc}" "${cflags}" "${asm_fp}") |
| 1317 |
|
| 1318 |
if [ "x${knows_avx512f}" == "xno" ]; then |
| 1319 |
blacklistbu_add "knl" |
| 1320 |
blacklistbu_add "skx" |
| 1321 |
fi |
| 1322 |
|
| 1323 |
# |
| 1324 |
# Check support for AVX-512dq (skx). |
| 1325 |
# |
| 1326 |
|
| 1327 |
# The assembler on OS X won't recognize AVX-512 without help. |
| 1328 |
if [ "$(uname -s)" == "Darwin" ]; then |
| 1329 |
cflags="-Wa,-march=skylake-avx512" |
| 1330 |
fi |
| 1331 |
|
| 1332 |
asm_fp=$(find ${asm_dir} -name "avx512dq.s") |
| 1333 |
knows_avx512dq=$(try_assemble "${cc}" "${cflags}" "${asm_fp}") |
| 1334 |
|
| 1335 |
if [ "x${knows_avx512dq}" == "xno" ]; then |
| 1336 |
blacklistbu_add "skx" |
| 1337 |
fi |
| 1338 |
} |
| 1339 |
|
| 1340 |
try_assemble() |
| 1341 |
{ |
| 1342 |
local cc cflags asm_src asm_base asm_bin rval |
| 1343 |
|
| 1344 |
cc="$1" |
| 1345 |
cflags="$2" |
| 1346 |
asm_src="$3" |
| 1347 |
|
| 1348 |
# Construct the filename to the .o file corresponding to asm_src. |
| 1349 |
# (Strip the filepath, then the file extension, and then add ".o".) |
| 1350 |
asm_base=${asm_src##*/} |
| 1351 |
asm_base=${asm_base%.*} |
| 1352 |
asm_bin="${asm_base}.o" |
| 1353 |
|
| 1354 |
# Try to assemble the file. |
| 1355 |
${cc} ${cflags} -c ${asm_src} -o ${asm_bin} > /dev/null 2>&1 |
| 1356 |
|
| 1357 |
if [ "$?" == 0 ]; then |
| 1358 |
rval='yes' |
| 1359 |
else |
| 1360 |
rval='no' |
| 1361 |
fi |
| 1362 |
|
| 1363 |
# Remove the object file. |
| 1364 |
rm -f "${asm_bin}" |
| 1365 |
|
| 1366 |
# Return the result. |
| 1367 |
echo "${rval}" |
| 1368 |
} |
| 1369 |
|
| 1370 |
set_default_version() |
| 1371 |
{ |
| 1372 |
local gitdir version_file gd_stderr git_describe_str git_error new_version_str |
| 1373 |
|
| 1374 |
gitdir='.git' |
| 1375 |
|
| 1376 |
# The path to the version file. |
| 1377 |
version_file=$1 |
| 1378 |
|
| 1379 |
echo "${script_name}: determining default version string." |
| 1380 |
|
| 1381 |
# Check if the .git dir exists; if it does not, we do nothing. |
| 1382 |
if [ -d "${dist_path}/${gitdir}" ]; then |
| 1383 |
|
| 1384 |
echo "${script_name}: found '${gitdir}' directory; assuming git clone." |
| 1385 |
|
| 1386 |
echo "${script_name}: executing: git describe --tags." |
| 1387 |
|
| 1388 |
gd_stderr="git_describe_stderr.txt" |
| 1389 |
|
| 1390 |
# Query git for the version string, which is simply the current tag, |
| 1391 |
# followed by a number signifying how many commits have transpired |
| 1392 |
# since the tag, followed by a 'g' and a shortened hash tab. Capture |
| 1393 |
# stderr to a file. |
| 1394 |
git_describe_str=$(git -C ${dist_path} describe --tags 2> ${gd_stderr}) |
| 1395 |
|
| 1396 |
# Pull in whatever error message was generated, if any, and delete |
| 1397 |
# the file. |
| 1398 |
git_error=$(cat ${gd_stderr}) |
| 1399 |
|
| 1400 |
# Remove the stderr file. |
| 1401 |
rm -f ${gd_stderr} |
| 1402 |
|
| 1403 |
# If git returned an error, don't do anything. |
| 1404 |
if [ -n "${git_error}" ]; then |
| 1405 |
|
| 1406 |
echo "${script_name}: git returned an error: '${git_error}'." |
| 1407 |
echo "${script_name}: using string from unmodified version file." |
| 1408 |
|
| 1409 |
# Use what's in the version file as-is. |
| 1410 |
version=$(cat "${version_file}") |
| 1411 |
else |
| 1412 |
|
| 1413 |
echo "${script_name}: got back ${git_describe_str}." |
| 1414 |
|
| 1415 |
# Strip off the commit hash label. |
| 1416 |
new_version_str=$(echo ${git_describe_str} | cut -d- -f-2) |
| 1417 |
|
| 1418 |
echo "${script_name}: truncating to ${new_version_str}." |
| 1419 |
|
| 1420 |
# Write the new version string to the version file. |
| 1421 |
#echo "${new_version_str}" > ${version_file} |
| 1422 |
|
| 1423 |
# Set the version variable. |
| 1424 |
version="${new_version_str}" |
| 1425 |
fi |
| 1426 |
else |
| 1427 |
|
| 1428 |
echo "${script_name}: could not find '${gitdir}' directory; using unmodified version file." |
| 1429 |
|
| 1430 |
# Use what's in the version file as-is. |
| 1431 |
version=$(cat "${version_file}") |
| 1432 |
fi |
| 1433 |
} |
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
# |
| 1438 |
# -- main function ------------------------------------------------------------- |
| 1439 |
# |
| 1440 |
|
| 1441 |
main() |
| 1442 |
{ |
| 1443 |
#declare -A config_registry |
| 1444 |
#declare -A kernel_registry |
| 1445 |
#declare -A kconfig_registry |
| 1446 |
|
| 1447 |
# -- Basic names and paths -- |
| 1448 |
|
| 1449 |
# The name of the script, stripped of any preceeding path. |
| 1450 |
script_name=${0##*/} |
| 1451 |
|
| 1452 |
# The path to the script. We need this to find the top-level directory |
| 1453 |
# of the source distribution in the event that the user has chosen to |
| 1454 |
# build elsewhere. |
| 1455 |
dist_path=${0%/${script_name}} |
| 1456 |
|
| 1457 |
# The path to the directory in which we are building. We do this to |
| 1458 |
# make explicit that we distinguish between the top-level directory |
| 1459 |
# of the distribution and the directory in which we are building. |
| 1460 |
cur_dirpath="." |
| 1461 |
|
| 1462 |
# The file in which the version string is kept. |
| 1463 |
version_file="version" |
| 1464 |
version_filepath="${dist_path}/${version_file}" |
| 1465 |
|
| 1466 |
# The name of and path to the directory named "build" in the top-level |
| 1467 |
# directory of the source distribution. |
| 1468 |
build_dir='build' |
| 1469 |
build_dirpath="${dist_path}/${build_dir}" |
| 1470 |
|
| 1471 |
# The name/path to the registry (master list) of supported configurations. |
| 1472 |
registry_file="config_registry" |
| 1473 |
registry_filepath=${dist_path}/${registry_file} |
| 1474 |
|
| 1475 |
# The names/paths for the template config.mk.in and its instantiated |
| 1476 |
# counterpart. |
| 1477 |
config_mk_in='config.mk.in' |
| 1478 |
config_mk_out='config.mk' |
| 1479 |
config_mk_in_path="${build_dirpath}/${config_mk_in}" |
| 1480 |
config_mk_out_path="${cur_dirpath}/${config_mk_out}" |
| 1481 |
|
| 1482 |
# The names/paths for the template bli_config.h.in and its instantiated |
| 1483 |
# counterpart. |
| 1484 |
bli_config_h_in='bli_config.h.in' |
| 1485 |
bli_config_h_out='bli_config.h' |
| 1486 |
bli_config_h_in_path="${build_dirpath}/${bli_config_h_in}" |
| 1487 |
bli_config_h_out_path="${cur_dirpath}/${bli_config_h_out}" |
| 1488 |
|
| 1489 |
# Path to 'mirror-tree.sh' script. |
| 1490 |
mirror_tree_sh="${build_dirpath}/mirror-tree.sh" |
| 1491 |
|
| 1492 |
# Path to 'gen-make-frags.sh' script and directory. |
| 1493 |
gen_make_frags_dirpath="${build_dirpath}/gen-make-frags" |
| 1494 |
gen_make_frags_sh="${gen_make_frags_dirpath}/gen-make-frag.sh" |
| 1495 |
|
| 1496 |
# The name of the (top-level) configuration directory. |
| 1497 |
config_dir='config' |
| 1498 |
config_dirpath="${dist_path}/${config_dir}" |
| 1499 |
|
| 1500 |
# The name of the (top-level) kernels directory. |
| 1501 |
kernels_dir='kernels' |
| 1502 |
kernels_dirpath="${dist_path}/${kernels_dir}" |
| 1503 |
|
| 1504 |
# The name of the (top-level) reference kernels directory. |
| 1505 |
refkern_dir='ref_kernels' |
| 1506 |
refkern_dirpath="${dist_path}/${refkern_dir}" |
| 1507 |
|
| 1508 |
# The root directory of the BLIS framework. |
| 1509 |
frame_dir='frame' |
| 1510 |
frame_dirpath="${dist_path}/${frame_dir}" |
| 1511 |
|
| 1512 |
# The name of the sandbox directory. |
| 1513 |
sandbox_dir='sandbox' |
| 1514 |
sandbox_dirpath="${dist_path}/${sandbox_dir}" |
| 1515 |
|
| 1516 |
# The name of the directory in which object files will be kept. |
| 1517 |
obj_dir='obj' |
| 1518 |
obj_dirpath="${cur_dirpath}/${obj_dir}" |
| 1519 |
|
| 1520 |
# The name of the directory in which libraries will be kept. |
| 1521 |
lib_dir='lib' |
| 1522 |
lib_dirpath="${cur_dirpath}/${lib_dir}" |
| 1523 |
|
| 1524 |
# The name of the directory in which headers will be kept. |
| 1525 |
include_dir='include' |
| 1526 |
include_dirpath="${cur_dirpath}/${include_dir}" |
| 1527 |
|
| 1528 |
# The name of the directory in which the BLAS test suite is kept. |
| 1529 |
blastest_dir='blastest' |
| 1530 |
|
| 1531 |
# The name of the directory in which the BLIS test suite is kept. |
| 1532 |
testsuite_dir='testsuite' |
| 1533 |
|
| 1534 |
# -- Version-related -- |
| 1535 |
|
| 1536 |
# The shared library (.so) version file. |
| 1537 |
so_version_file='so_version' |
| 1538 |
so_version_filepath="${dist_path}/${so_version_file}" |
| 1539 |
|
| 1540 |
# The major and minor/build .so version numbers. |
| 1541 |
so_version_major='' |
| 1542 |
so_version_minorbuild='' |
| 1543 |
|
| 1544 |
# -- configure options -- |
| 1545 |
|
| 1546 |
# The user-given install prefix and a flag indicating it was given. |
| 1547 |
#install_prefix_def="${HOME}/blis" |
| 1548 |
install_prefix_user=${HOME}/blis # default to this directory. |
| 1549 |
prefix_flag='' |
| 1550 |
|
| 1551 |
# The user-given install libdir and a flag indicating it was given. |
| 1552 |
install_libdir_user='' |
| 1553 |
libdir_flag='' |
| 1554 |
|
| 1555 |
# The user-given install includedir and a flag indicating it was given. |
| 1556 |
install_incdir_user='' |
| 1557 |
incdir_flag='' |
| 1558 |
|
| 1559 |
# The user-given install sharedir and a flag indicating it was given. |
| 1560 |
install_sharedir_user='' |
| 1561 |
sharedir_flag='' |
| 1562 |
|
| 1563 |
# The preset value of CFLAGS and LDFLAGS (ie: compiler and linker flags |
| 1564 |
# to use in addition to those determined by the build system). |
| 1565 |
cflags_preset='' |
| 1566 |
ldflags_preset='' |
| 1567 |
|
| 1568 |
# The user-given debug type and a flag indicating it was given. |
| 1569 |
debug_type='' |
| 1570 |
debug_flag='' |
| 1571 |
|
| 1572 |
# The threading flag. |
| 1573 |
threading_model='no' |
| 1574 |
|
| 1575 |
# Option variables. |
| 1576 |
quiet_flag='' |
| 1577 |
show_config_list='' |
| 1578 |
|
| 1579 |
# Additional flags. |
| 1580 |
enable_verbose='no' |
| 1581 |
enable_arg_max_hack='no' |
| 1582 |
enable_static='yes' |
| 1583 |
enable_shared='yes' |
| 1584 |
enable_packbuf_pools='yes' |
| 1585 |
int_type_size=0 |
| 1586 |
blas_int_type_size=32 |
| 1587 |
enable_blas='yes' |
| 1588 |
enable_cblas='no' |
| 1589 |
enable_memkind='' # The default memkind value is determined later on. |
| 1590 |
force_version='no' |
| 1591 |
|
| 1592 |
# The sandbox flag and name. |
| 1593 |
sandbox_flag='' |
| 1594 |
sandbox='' |
| 1595 |
|
| 1596 |
# -- Configuration registry -- |
| 1597 |
|
| 1598 |
# The name of the chosen configuration (the configuration "family"). |
| 1599 |
config_name='' |
| 1600 |
|
| 1601 |
# The list of sub-configurations associated with config_name. |
| 1602 |
config_list='' |
| 1603 |
|
| 1604 |
# The list of kernel sets that will be needed by the sub-configurations |
| 1605 |
# in config_list.. |
| 1606 |
kernel_list='' |
| 1607 |
|
| 1608 |
# The list of kernel:sub-configuration pairs for all kernels contained |
| 1609 |
# in kernel_list. |
| 1610 |
kconfig_map='' |
| 1611 |
|
| 1612 |
# -- Out-of-tree -- |
| 1613 |
|
| 1614 |
# Whether we are building out-of-tree. |
| 1615 |
configured_oot="no" |
| 1616 |
|
| 1617 |
# Dummy file. Used to check whether the cwd is the same as the top-level |
| 1618 |
# source distribution directory. |
| 1619 |
dummy_file='_blis_dir_detect.tmp' |
| 1620 |
|
| 1621 |
|
| 1622 |
# -- Command line option/argument parsing ---------------------------------- |
| 1623 |
|
| 1624 |
# Process our command line options. |
| 1625 |
while getopts ":hp:d:s:t:qci:b:-:" opt; do |
| 1626 |
case $opt in |
| 1627 |
-) |
| 1628 |
case "$OPTARG" in |
| 1629 |
help) |
| 1630 |
print_usage |
| 1631 |
;; |
| 1632 |
quiet) |
| 1633 |
quiet_flag=1 |
| 1634 |
;; |
| 1635 |
prefix=*) |
| 1636 |
prefix_flag=1 |
| 1637 |
install_prefix_user=${OPTARG#*=} |
| 1638 |
;; |
| 1639 |
libdir=*) |
| 1640 |
libdir_flag=1 |
| 1641 |
install_libdir_user=${OPTARG#*=} |
| 1642 |
;; |
| 1643 |
includedir=*) |
| 1644 |
incdir_flag=1 |
| 1645 |
install_incdir_user=${OPTARG#*=} |
| 1646 |
;; |
| 1647 |
sharedir=*) |
| 1648 |
sharedir_flag=1 |
| 1649 |
install_sharedir_user=${OPTARG#*=} |
| 1650 |
;; |
| 1651 |
enable-debug) |
| 1652 |
debug_flag=1 |
| 1653 |
debug_type=noopt |
| 1654 |
;; |
| 1655 |
enable-debug=*) |
| 1656 |
debug_flag=1 |
| 1657 |
debug_type=${OPTARG#*=} |
| 1658 |
;; |
| 1659 |
disable-debug) |
| 1660 |
debug_flag=0 |
| 1661 |
;; |
| 1662 |
enable-verbose-make) |
| 1663 |
enable_verbose='yes' |
| 1664 |
;; |
| 1665 |
disable-verbose-make) |
| 1666 |
enable_verbose='no' |
| 1667 |
;; |
| 1668 |
enable-arg-max-hack) |
| 1669 |
enable_arg_max_hack='yes' |
| 1670 |
;; |
| 1671 |
disable-arg-max-hack) |
| 1672 |
enable_arg_max_hack='no' |
| 1673 |
;; |
| 1674 |
enable-static) |
| 1675 |
enable_static='yes' |
| 1676 |
;; |
| 1677 |
disable-static) |
| 1678 |
enable_static='no' |
| 1679 |
;; |
| 1680 |
enable-shared) |
| 1681 |
enable_shared='yes' |
| 1682 |
;; |
| 1683 |
disable-shared) |
| 1684 |
enable_shared='no' |
| 1685 |
;; |
| 1686 |
enable-threading=*) |
| 1687 |
threading_model=${OPTARG#*=} |
| 1688 |
;; |
| 1689 |
disable-threading) |
| 1690 |
threading_model='no' |
| 1691 |
;; |
| 1692 |
enable-packbuf-pools) |
| 1693 |
enable_packbuf_pools='yes' |
| 1694 |
;; |
| 1695 |
disable-packbuf-pools) |
| 1696 |
enable_packbuf_pools='no' |
| 1697 |
;; |
| 1698 |
enable-sandbox=*) |
| 1699 |
sandbox_flag=1 |
| 1700 |
sandbox=${OPTARG#*=} |
| 1701 |
;; |
| 1702 |
disable-sandbox) |
| 1703 |
sandbox_flag=0 |
| 1704 |
;; |
| 1705 |
int-size=*) |
| 1706 |
int_type_size=${OPTARG#*=} |
| 1707 |
;; |
| 1708 |
blas-int-size=*) |
| 1709 |
blas_int_type_size=${OPTARG#*=} |
| 1710 |
;; |
| 1711 |
enable-blas) |
| 1712 |
enable_blas='yes' |
| 1713 |
;; |
| 1714 |
disable-blas) |
| 1715 |
enable_blas='no' |
| 1716 |
;; |
| 1717 |
enable-cblas) |
| 1718 |
enable_cblas='yes' |
| 1719 |
;; |
| 1720 |
disable-cblas) |
| 1721 |
enable_cblas='no' |
| 1722 |
;; |
| 1723 |
with-memkind) |
| 1724 |
enable_memkind='yes' |
| 1725 |
;; |
| 1726 |
without-memkind) |
| 1727 |
enable_memkind='no' |
| 1728 |
;; |
| 1729 |
force-version=*) |
| 1730 |
force_version=${OPTARG#*=} |
| 1731 |
;; |
| 1732 |
show-config-list) |
| 1733 |
show_config_list=1 |
| 1734 |
;; |
| 1735 |
*) |
| 1736 |
print_usage |
| 1737 |
;; |
| 1738 |
esac;; |
| 1739 |
h) |
| 1740 |
print_usage |
| 1741 |
;; |
| 1742 |
p) |
| 1743 |
prefix_flag=1 |
| 1744 |
install_prefix_user=$OPTARG |
| 1745 |
;; |
| 1746 |
d) |
| 1747 |
debug_flag=1 |
| 1748 |
debug_type=$OPTARG |
| 1749 |
;; |
| 1750 |
s) |
| 1751 |
sandbox_flag=1 |
| 1752 |
sandbox=$OPTARG |
| 1753 |
;; |
| 1754 |
q) |
| 1755 |
quiet_flag=1 |
| 1756 |
;; |
| 1757 |
t) |
| 1758 |
threading_model=$OPTARG |
| 1759 |
;; |
| 1760 |
i) |
| 1761 |
int_type_size=$OPTARG |
| 1762 |
;; |
| 1763 |
b) |
| 1764 |
blas_int_type_size=$OPTARG |
| 1765 |
;; |
| 1766 |
c) |
| 1767 |
show_config_list=1 |
| 1768 |
;; |
| 1769 |
\?) |
| 1770 |
print_usage |
| 1771 |
;; |
| 1772 |
esac |
| 1773 |
done |
| 1774 |
shift $(($OPTIND - 1)) |
| 1775 |
|
| 1776 |
# Parse environment variables |
| 1777 |
while [ $# -gt 0 ]; do |
| 1778 |
case $1 in |
| 1779 |
CC=*) |
| 1780 |
CC=${1#*=} |
| 1781 |
shift |
| 1782 |
;; |
| 1783 |
RANLIB=*) |
| 1784 |
RANLIB=${1#*=} |
| 1785 |
shift |
| 1786 |
;; |
| 1787 |
*=*) |
| 1788 |
print_usage |
| 1789 |
;; |
| 1790 |
*) |
| 1791 |
break |
| 1792 |
;; |
| 1793 |
esac |
| 1794 |
done |
| 1795 |
|
| 1796 |
# -- Check the operating system -------------------------------------------- |
| 1797 |
|
| 1798 |
os_name=$(uname -s) |
| 1799 |
os_vers=$(uname -r) |
| 1800 |
echo "${script_name}: detected ${os_name} kernel version ${os_vers}." |
| 1801 |
|
| 1802 |
|
| 1803 |
# -- Find a C compiler ----------------------------------------------------- |
| 1804 |
|
| 1805 |
# Acquire the compiler search order. This will vary based on the os |
| 1806 |
# found above. |
| 1807 |
cc_search_list=$(get_cc_search_list) |
| 1808 |
|
| 1809 |
echo "${script_name}: C compiler search list is: ${cc_search_list}." |
| 1810 |
|
| 1811 |
# Find a working C compiler. |
| 1812 |
found_cc=$(select_cc "${cc_search_list}" "${CC}") |
| 1813 |
|
| 1814 |
# If we didn't find any working C compilers, we print an error message. |
| 1815 |
if [ -z "${found_cc}" ]; then |
| 1816 |
echo "${script_name}: *** Could not find working C compiler! Cannot continue." |
| 1817 |
exit 1 |
| 1818 |
fi |
| 1819 |
|
| 1820 |
echo "${script_name}: using '${found_cc}' C compiler." |
| 1821 |
|
| 1822 |
|
| 1823 |
# -- Find a C++ compiler --------------------------------------------------- |
| 1824 |
|
| 1825 |
# Acquire the compiler search order. This will vary based on the os |
| 1826 |
# found above. |
| 1827 |
cxx_search_list=$(get_cxx_search_list) |
| 1828 |
|
| 1829 |
echo "${script_name}: C++ compiler search list is: ${cxx_search_list}." |
| 1830 |
|
| 1831 |
# Find a working C++ compiler. NOTE: We can reuse the select_cc() |
| 1832 |
# function since it is written in a way that is general-purpose. |
| 1833 |
found_cxx=$(select_cc "${cxx_search_list}" "${CXX}") |
| 1834 |
|
| 1835 |
# If we didn't find any working C++ compilers, we print an error message. |
| 1836 |
if [ -z "${found_cxx}" ]; then |
| 1837 |
echo "${script_name}: Could not find working C++ compiler! C++ will not be available in sandbox." |
| 1838 |
found_cxx="c++notfound" |
| 1839 |
fi |
| 1840 |
|
| 1841 |
echo "${script_name}: using '${found_cxx}' C++ compiler (for sandbox only)." |
| 1842 |
|
| 1843 |
|
| 1844 |
# -- Check the compiler version -------------------------------------------- |
| 1845 |
|
| 1846 |
# Initialize the blacklist to empty. |
| 1847 |
blacklist_init |
| 1848 |
|
| 1849 |
# Check the compiler's version. Certain versions of certain compilers |
| 1850 |
# will preclude building certain sub-configurations, which are added |
| 1851 |
# to a blacklist. |
| 1852 |
get_compiler_version |
| 1853 |
check_compiler |
| 1854 |
|
| 1855 |
# Now check the assembler's ability to assemble code. Older versions |
| 1856 |
# of binutils may not be aware of certain instruction sets. Those |
| 1857 |
# sub-configurations employing kernels that use such instruction sets |
| 1858 |
# will also be blacklisted. |
| 1859 |
get_binutils_version |
| 1860 |
check_assembler |
| 1861 |
|
| 1862 |
# Remove duplicates and whitespace from the blacklist. |
| 1863 |
blacklist_cleanup |
| 1864 |
|
| 1865 |
if [ -n "${config_blist}" ]; then |
| 1866 |
|
| 1867 |
echo "${script_name}: configuration blacklist:" |
| 1868 |
echo "${script_name}: ${config_blist}" |
| 1869 |
fi |
| 1870 |
|
| 1871 |
|
| 1872 |
# -- Read the configuration registry --------------------------------------- |
| 1873 |
|
| 1874 |
# Make sure the config registry file exists and can be opened. |
| 1875 |
if [ ! -f "${registry_filepath}" ]; then |
| 1876 |
|
| 1877 |
echo "${script_name}: could not open '${registry_file}' file; cannot continue." |
| 1878 |
echo "${script_name}: BLIS distribution appears to be incomplete." |
| 1879 |
echo "${script_name}: *** Please verify source distribution." |
| 1880 |
|
| 1881 |
exit 1 |
| 1882 |
fi |
| 1883 |
|
| 1884 |
# Read the registered configuration names and lists into associative |
| 1885 |
# arrays. |
| 1886 |
echo -n "${script_name}: reading configuration registry..." |
| 1887 |
read_registry_file ${registry_filepath} |
| 1888 |
echo "done." |
| 1889 |
|
| 1890 |
# Report if additional configurations needed to be blacklisted. |
| 1891 |
# NOTE: This branch should never execute so long as indirect blacklisting |
| 1892 |
# is disabled. See comment regarding issue #214 in the definition of |
| 1893 |
# pass_config_kernel_registries(). |
| 1894 |
if [ -n "${indirect_blist}" ]; then |
| 1895 |
echo "${script_name}: needed to indirectly blacklist additional configurations:" |
| 1896 |
echo "${script_name}: ${indirect_blist}" |
| 1897 |
fi |
| 1898 |
|
| 1899 |
|
| 1900 |
# -- Acquire the BLIS version ---------------------------------------------- |
| 1901 |
|
| 1902 |
# Set the 'version' variable to the default value (the 'git describe' |
| 1903 |
# augmented instance of whatever is in the 'version' file if this is a git |
| 1904 |
# clone, or whatever is in the 'version' file unmodified if it is a bare |
| 1905 |
# source release). |
| 1906 |
set_default_version "${version_filepath}" |
| 1907 |
|
| 1908 |
# Initial message. |
| 1909 |
echo "${script_name}: starting configuration of BLIS ${version}." |
| 1910 |
|
| 1911 |
# Check if the user requested a custom version string. |
| 1912 |
if [ "x${force_version}" = "xno" ]; then |
| 1913 |
echo "${script_name}: configuring with official version string." |
| 1914 |
else |
| 1915 |
echo "${script_name}: configuring with custom version string '${force_version}'." |
| 1916 |
version="${force_version}" |
| 1917 |
fi |
| 1918 |
|
| 1919 |
|
| 1920 |
# -- Acquire the shared library (.so) versions ----------------------------- |
| 1921 |
|
| 1922 |
# The first line of the 'so_version' file contains the .so major version. |
| 1923 |
so_version_major=$(cat ${so_version_filepath} | sed -n "1p") |
| 1924 |
|
| 1925 |
# The second line contains the minor and build .so version numbers |
| 1926 |
# (separated by a '.'). |
| 1927 |
so_version_minorbuild=$(cat ${so_version_filepath} | sed -n "2p") |
| 1928 |
|
| 1929 |
echo "${script_name}: found shared library .so version '${so_version_major}.${so_version_minorbuild}'." |
| 1930 |
echo "${script_name}: .so major version: ${so_version_major}" |
| 1931 |
echo "${script_name}: .so minor.build version: ${so_version_minorbuild}" |
| 1932 |
|
| 1933 |
|
| 1934 |
# -- Various pre-configuration checks -------------------------------------- |
| 1935 |
|
| 1936 |
# Set config_name based on the number of arguments leftover (after command |
| 1937 |
# line option processing). |
| 1938 |
if [ $# = "0" ]; then |
| 1939 |
|
| 1940 |
#configs_avail="auto "$(ls ${config_dirpath}) |
| 1941 |
|
| 1942 |
echo "${script_name}: " |
| 1943 |
echo "${script_name}: *** No configuration given! ***" |
| 1944 |
echo "${script_name}: " |
| 1945 |
echo "${script_name}: Default configuration behavior is not implemented (for your" |
| 1946 |
echo "${script_name}: own safety). Please re-run '${script_name}' and specify one" |
| 1947 |
echo "${script_name}: of the existing configurations in the source distribution's" |
| 1948 |
echo "${script_name} '${registry_file}' file:" |
| 1949 |
echo "${script_name}: " |
| 1950 |
#for k in "${!config_registry[@]}"; do |
| 1951 |
for cr_var in ${!config_registry_*}; do |
| 1952 |
|
| 1953 |
#v=${config_registry[$k]} |
| 1954 |
k=${cr_var##config_registry_}; v=${!cr_var} |
| 1955 |
|
| 1956 |
echo "${script_name}: $k (${v})" |
| 1957 |
done |
| 1958 |
echo "${script_name}: " |
| 1959 |
|
| 1960 |
exit 1 |
| 1961 |
|
| 1962 |
elif [ $# != "1" ]; then # more than one configuration argument given. |
| 1963 |
|
| 1964 |
print_usage |
| 1965 |
|
| 1966 |
fi |
| 1967 |
|
| 1968 |
if [ $1 = "auto" ]; then |
| 1969 |
|
| 1970 |
echo "${script_name}: automatic configuration requested." |
| 1971 |
|
| 1972 |
# Call the auto_detect() function and save the returned string in |
| 1973 |
# config_name. |
| 1974 |
config_name=$(auto_detect) |
| 1975 |
|
| 1976 |
echo "${script_name}: hardware detection driver returned '${config_name}'." |
| 1977 |
else |
| 1978 |
|
| 1979 |
# Use the command line argument as the configuration name. |
| 1980 |
config_name=$1 |
| 1981 |
|
| 1982 |
#echo "${script_name}: manual configuration requested." |
| 1983 |
echo "${script_name}: manual configuration requested; configuring with '${config_name}'." |
| 1984 |
|
| 1985 |
fi |
| 1986 |
|
| 1987 |
# Use the selected config name to look up the list of configurations |
| 1988 |
# and kernels associated with that name. |
| 1989 |
#config_list=${config_registry[${config_name}]} |
| 1990 |
#kernel_list=${kernel_registry[${config_name}]} |
| 1991 |
config_list=$(query_array "config_registry" ${config_name}) |
| 1992 |
kernel_list=$(query_array "kernel_registry" ${config_name}) |
| 1993 |
|
| 1994 |
# Use the config_registry and kernel_registry to build a kconfig_registry |
| 1995 |
# for the selected config_name. |
| 1996 |
build_kconfig_registry "${config_name}" |
| 1997 |
|
| 1998 |
# Print the configuration list and kernel list, if requested. |
| 1999 |
if [ "${show_config_list}" == "1" ]; then |
| 2000 |
|
| 2001 |
echo "${script_name}: configuration list:" |
| 2002 |
#for k in "${!config_registry[@]}"; do |
| 2003 |
for cr_var in ${!config_registry_*}; do |
| 2004 |
|
| 2005 |
#v=${config_registry[$k]} |
| 2006 |
k=${cr_var##config_registry_}; v=${!cr_var} |
| 2007 |
|
| 2008 |
echo "${script_name}: $k: ${v}" |
| 2009 |
done |
| 2010 |
|
| 2011 |
echo "${script_name}: kernel list:" |
| 2012 |
#for k in "${!kernel_registry[@]}"; do |
| 2013 |
for kr_var in ${!kernel_registry_*}; do |
| 2014 |
|
| 2015 |
#v=${kernel_registry[$k]} |
| 2016 |
k=${kr_var##kernel_registry_}; v=${!kr_var} |
| 2017 |
|
| 2018 |
echo "${script_name}: $k: ${v}" |
| 2019 |
done |
| 2020 |
|
| 2021 |
echo "${script_name}: kernel-to-config map for '${config_name}':" |
| 2022 |
#for k in "${!kconfig_registry[@]}"; do |
| 2023 |
for kc_var in ${!kconfig_registry_*}; do |
| 2024 |
|
| 2025 |
#v=${kconfig_registry[$k]} |
| 2026 |
k=${kc_var##kconfig_registry_}; v=${!kc_var} |
| 2027 |
|
| 2028 |
echo "${script_name}: $k: ${v}" |
| 2029 |
done |
| 2030 |
fi |
| 2031 |
|
| 2032 |
# For each kernel in the kernel list, reduce the list of associated |
| 2033 |
# sub-configurations (in the kconfig_registry) to a singleton using |
| 2034 |
# the following rules: |
| 2035 |
# 1. If the list is a singleton, use that name. |
| 2036 |
# 2. If the list contains a sub-configuration name that matches the |
| 2037 |
# kernel name, use that name. |
| 2038 |
# 3. Otherwise, use the first name in the list. |
| 2039 |
# We use the chosen singleton to ceate a "kernel:subconfig" pair, which |
| 2040 |
# we accumulate into a list. This list is the kernel-to-config map, or |
| 2041 |
# kconfig_map. |
| 2042 |
|
| 2043 |
# We use a sorted version of kernel_list so that it ends up matching the |
| 2044 |
# display order of the kconfig_registry above. |
| 2045 |
kernel_list_sort=$(echo ${kernel_list} | xargs -n1 | sort -u) |
| 2046 |
|
| 2047 |
kconfig_map="" |
| 2048 |
for kernel in ${kernel_list_sort}; do |
| 2049 |
|
| 2050 |
#configs="${kconfig_registry[$kernel]}" |
| 2051 |
configs=$(query_array "kconfig_registry" ${kernel}) |
| 2052 |
|
| 2053 |
has_one_kernel=$(is_singleton "${configs}") |
| 2054 |
contains_kernel=$(is_in_list "${kernel}" "${configs}") |
| 2055 |
|
| 2056 |
# Check if the list is a singleton. |
| 2057 |
if [ "${has_one_kernel}" == "true" ]; then |
| 2058 |
|
| 2059 |
reducedclist="${configs}" |
| 2060 |
|
| 2061 |
# Check if the list contains a sub-config name that matches the kernel. |
| 2062 |
elif [ "${contains_kernel}" == "true" ]; then |
| 2063 |
|
| 2064 |
reducedclist="${kernel}" |
| 2065 |
|
| 2066 |
# Otherwise, use the first name. |
| 2067 |
else |
| 2068 |
|
| 2069 |
first_config=${configs%% *} |
| 2070 |
reducedclist="${first_config}" |
| 2071 |
fi |
| 2072 |
|
| 2073 |
# Create a new "kernel:subconfig" pair and add it to the kconfig_map |
| 2074 |
# list, removing whitespace. |
| 2075 |
new_pair="${kernel}:${reducedclist}" |
| 2076 |
kconfig_map=$(canonicalize_ws "${kconfig_map} ${new_pair}") |
| 2077 |
done |
| 2078 |
|
| 2079 |
if [ "${show_config_list}" == "1" ]; then |
| 2080 |
|
| 2081 |
echo "${script_name}: kernel-to-config map for '${config_name}' (chosen pairs):" |
| 2082 |
for k in ${kconfig_map}; do |
| 2083 |
echo "${script_name}: $k" |
| 2084 |
done |
| 2085 |
fi |
| 2086 |
|
| 2087 |
|
| 2088 |
echo "${script_name}: checking configuration against contents of '${registry_file}'." |
| 2089 |
|
| 2090 |
# First, ensure that the config name is registered (ie: it is present |
| 2091 |
# in the config_registry file). |
| 2092 |
if [ -z "${config_list}" ]; then |
| 2093 |
|
| 2094 |
# NOTE: This branch should never execute when using auto-detection, |
| 2095 |
# but we have it here just in case. |
| 2096 |
if [ $1 = "auto" ]; then |
| 2097 |
|
| 2098 |
echo "${script_name}: 'auto-detected configuration '${conf}' is NOT registered!" |
| 2099 |
echo "${script_name}: " |
| 2100 |
echo "${script_name}: *** Cannot continue with unregistered configuration '${conf}'. ***" |
| 2101 |
echo "${script_name}: " |
| 2102 |
exit 1; |
| 2103 |
|
| 2104 |
else |
| 2105 |
|
| 2106 |
echo "${script_name}: 'user-specified configuration '${conf}' is NOT registered!" |
| 2107 |
echo "${script_name}: " |
| 2108 |
echo "${script_name}: *** Cannot continue with unregistered configuration '${conf}'. ***" |
| 2109 |
echo "${script_name}: " |
| 2110 |
exit 1; |
| 2111 |
|
| 2112 |
fi |
| 2113 |
|
| 2114 |
else |
| 2115 |
|
| 2116 |
# This branch executes when the configuration is found to be present |
| 2117 |
# (i.e. registered) in the config_registry file. |
| 2118 |
|
| 2119 |
echo "${script_name}: configuration '${config_name}' is registered." |
| 2120 |
echo "${script_name}: '${config_name}' is defined as having the following sub-configurations:" |
| 2121 |
echo "${script_name}: ${config_list}" |
| 2122 |
echo "${script_name}: which collectively require the following kernels:" |
| 2123 |
echo "${script_name}: ${kernel_list}" |
| 2124 |
|
| 2125 |
fi |
| 2126 |
|
| 2127 |
|
| 2128 |
echo "${script_name}: checking sub-configurations:" |
| 2129 |
|
| 2130 |
# Now, verify that the constituent configurations associated with the |
| 2131 |
# config name are all valid. |
| 2132 |
for conf in ${config_list}; do |
| 2133 |
|
| 2134 |
# First confirm that the current configuration is registered. |
| 2135 |
#this_clist=${config_registry[${conf}]} |
| 2136 |
this_clist=$(query_array "config_registry" ${conf}) |
| 2137 |
|
| 2138 |
# If the config_list associated with conf is empty, then it was |
| 2139 |
# never entered into the config_registry to begin with. Thus, |
| 2140 |
# conf must be unregistered. |
| 2141 |
if [ -z "${this_clist}" ]; then |
| 2142 |
echo "${script_name}: '${conf}' is NOT registered!" |
| 2143 |
echo "${script_name}: " |
| 2144 |
echo "${script_name}: *** Cannot continue with unregistered configuration '${conf}'. ***" |
| 2145 |
echo "${script_name}: " |
| 2146 |
exit 1; |
| 2147 |
else |
| 2148 |
echo -n "${script_name}: '${conf}' is registered." |
| 2149 |
fi |
| 2150 |
|
| 2151 |
# Then confirm that the current sub-configuration directory exists. |
| 2152 |
if [ ! -d "${config_dirpath}/${conf}" ]; then |
| 2153 |
echo "..but does NOT exist!" |
| 2154 |
echo "${script_name}: " |
| 2155 |
echo "${script_name}: *** Cannot continue with nonexistent configuration '${conf}'. ***" |
| 2156 |
echo "${script_name}: " |
| 2157 |
exit 1; |
| 2158 |
else |
| 2159 |
echo "..and exists." |
| 2160 |
fi |
| 2161 |
done |
| 2162 |
|
| 2163 |
|
| 2164 |
echo "${script_name}: checking sub-configurations' requisite kernels:" |
| 2165 |
|
| 2166 |
# Also, let's verify that the requisite kernel sets associated with |
| 2167 |
# the config name all correspond to directories that exist. |
| 2168 |
for kernel in ${kernel_list}; do |
| 2169 |
|
| 2170 |
echo -n "${script_name}: '${kernel}' kernels..." |
| 2171 |
|
| 2172 |
# Confirm that the current kernel sub-directory exists. |
| 2173 |
if [ ! -d "${kernels_dirpath}/${kernel}" ]; then |
| 2174 |
echo "do NOT exist!" |
| 2175 |
echo "${script_name}: " |
| 2176 |
echo "${script_name}: *** Cannot continue with nonexistent kernel '${kernel}'. ***" |
| 2177 |
echo "${script_name}: " |
| 2178 |
exit 1; |
| 2179 |
else |
| 2180 |
echo "exist." |
| 2181 |
fi |
| 2182 |
done |
| 2183 |
|
| 2184 |
# In order to determine the default behavior of the --with[out]-memkind |
| 2185 |
# option, we try to detect whether libmemkind is available. If it is, |
| 2186 |
# the default implied option will be --with-memkind; otherwise, will be |
| 2187 |
# --without-memkind. |
| 2188 |
has_memkind=$(has_libmemkind) |
| 2189 |
|
| 2190 |
|
| 2191 |
# -- Prepare variables for subsitution into template files ----------------- |
| 2192 |
|
| 2193 |
# Parse the status of the install prefix and echo feedback. |
| 2194 |
if [ -n "${prefix_flag}" ]; then |
| 2195 |
echo "${script_name}: detected --prefix='${install_prefix_user}'." |
| 2196 |
else |
| 2197 |
echo "${script_name}: no install prefix option given; defaulting to '${install_prefix_user}'." |
| 2198 |
fi |
| 2199 |
|
| 2200 |
# Set initial (candidate) values for the libdir and includedir using the |
| 2201 |
# install prefix that was determined above. |
| 2202 |
install_libdir=${install_prefix_user}/lib |
| 2203 |
install_incdir=${install_prefix_user}/include |
| 2204 |
install_sharedir=${install_prefix_user}/share |
| 2205 |
|
| 2206 |
# Set the install libdir, if it was specified. Note that this will override |
| 2207 |
# the default libdir implied by the install prefix, even if both options |
| 2208 |
# were given. |
| 2209 |
if [ -n "${libdir_flag}" ]; then |
| 2210 |
echo "${script_name}: detected --libdir='${install_libdir_user}'." |
| 2211 |
install_libdir=${install_libdir_user} |
| 2212 |
else |
| 2213 |
echo "${script_name}: no install libdir option given; defaulting to PREFIX/lib." |
| 2214 |
fi |
| 2215 |
|
| 2216 |
# Set the install includedir, if it was specified. Note that this will |
| 2217 |
# override the default includedir implied by the install prefix, even if |
| 2218 |
# both options were given. |
| 2219 |
if [ -n "${incdir_flag}" ]; then |
| 2220 |
echo "${script_name}: detected --includedir='${install_incdir_user}'." |
| 2221 |
install_incdir=${install_incdir_user} |
| 2222 |
else |
| 2223 |
echo "${script_name}: no install includedir option given; defaulting to PREFIX/include." |
| 2224 |
fi |
| 2225 |
|
| 2226 |
# Set the install sharedir, if it was specified. Note that this will |
| 2227 |
# override the default sharedir implied by the install prefix, even if |
| 2228 |
# both options were given. |
| 2229 |
if [ -n "${sharedir_flag}" ]; then |
| 2230 |
echo "${script_name}: detected --sharedir='${install_sharedir_user}'." |
| 2231 |
install_sharedir=${install_sharedir_user} |
| 2232 |
else |
| 2233 |
echo "${script_name}: no install sharedir option given; defaulting to PREFIX/share." |
| 2234 |
fi |
| 2235 |
|
| 2236 |
# Echo the installation directories that we settled on. |
| 2237 |
echo "${script_name}: final installation directories:" |
| 2238 |
echo "${script_name}: libdir: ${install_libdir}" |
| 2239 |
echo "${script_name}: includedir: ${install_incdir}" |
| 2240 |
echo "${script_name}: sharedir: ${install_sharedir}" |
| 2241 |
|
| 2242 |
# Check if CFLAGS is non-empty. |
| 2243 |
if [ -n "${CFLAGS}" ]; then |
| 2244 |
cflags_preset="${CFLAGS}" |
| 2245 |
echo "${script_name}: detected preset CFLAGS; prepending:" |
| 2246 |
echo "${script_name}: ${cflags_preset}" |
| 2247 |
else |
| 2248 |
cflags_preset='' |
| 2249 |
echo "${script_name}: no preset CFLAGS detected." |
| 2250 |
fi |
| 2251 |
|
| 2252 |
# Check if LDFLAGS is non-empty. |
| 2253 |
if [ -n "${LDFLAGS}" ]; then |
| 2254 |
ldflags_preset="${LDFLAGS}" |
| 2255 |
echo "${script_name}: detected preset LDFLAGS; prepending:" |
| 2256 |
echo "${script_name}: ${ldflags_preset}" |
| 2257 |
else |
| 2258 |
ldflags_preset='' |
| 2259 |
echo "${script_name}: no preset LDFLAGS detected." |
| 2260 |
fi |
| 2261 |
|
| 2262 |
# Check if the debug flag was specified. |
| 2263 |
if [ -n "${debug_flag}" ]; then |
| 2264 |
if [ "x${debug_type}" = "xopt" ]; then |
| 2265 |
echo "${script_name}: enabling debug symbols with optimizations." |
| 2266 |
elif [ "x${debug_type}" = "xsde" ]; then |
| 2267 |
debug_type='sde' |
| 2268 |
echo "${script_name}: enabling SDE processor emulation." |
| 2269 |
else |
| 2270 |
debug_type='noopt' |
| 2271 |
echo "${script_name}: enabling debug symbols; optimizations disabled." |
| 2272 |
fi |
| 2273 |
else |
| 2274 |
debug_type='off' |
| 2275 |
echo "${script_name}: debug symbols disabled." |
| 2276 |
fi |
| 2277 |
|
| 2278 |
# Check if the verbose make flag was specified. |
| 2279 |
if [ "x${enable_verbose}" = "xyes" ]; then |
| 2280 |
echo "${script_name}: enabling verbose make output. (disable with 'make V=0'.)" |
| 2281 |
else |
| 2282 |
echo "${script_name}: disabling verbose make output. (enable with 'make V=1'.)" |
| 2283 |
fi |
| 2284 |
|
| 2285 |
# Check if the ARG_MAX hack was requested. |
| 2286 |
if [ "x${enable_arg_max_hack}" = "xyes" ]; then |
| 2287 |
echo "${script_name}: enabling ARG_MAX hack." |
| 2288 |
else |
| 2289 |
echo "${script_name}: disabling ARG_MAX hack." |
| 2290 |
fi |
| 2291 |
|
| 2292 |
# Check if the static lib flag was specified. |
| 2293 |
if [ "x${enable_static}" = "xyes" -a "x${enable_shared}" = "xyes" ]; then |
| 2294 |
echo "${script_name}: building BLIS as both static and shared libraries." |
| 2295 |
elif [ "x${enable_static}" = "xyes" -a "x${enable_shared}" = "xno" ]; then |
| 2296 |
echo "${script_name}: building BLIS as a static library (shared library disabled)." |
| 2297 |
elif [ "x${enable_static}" = "xno" -a "x${enable_shared}" = "xyes" ]; then |
| 2298 |
echo "${script_name}: building BLIS as a shared library (static library disabled)." |
| 2299 |
fi |
| 2300 |
#else |
| 2301 |
# echo "${script_name}: Both static and shared libraries were disabled." |
| 2302 |
# echo "${script_name}: *** Please enable one (or both) to continue." |
| 2303 |
# exit 1 |
| 2304 |
|
| 2305 |
# Check the threading model flag and standardize its value, if needed. |
| 2306 |
# NOTE: 'omp' is deprecated but still supported; 'openmp' is preferred. |
| 2307 |
enable_openmp='no' |
| 2308 |
enable_openmp_01=0 |
| 2309 |
enable_pthreads='no' |
| 2310 |
enable_pthreads_01=0 |
| 2311 |
if [ "x${threading_model}" = "xauto" ]; then |
| 2312 |
echo "${script_name}: determining the threading model automatically." |
| 2313 |
elif [ "x${threading_model}" = "xopenmp" ] || |
| 2314 |
[ "x${threading_model}" = "xomp" ]; then |
| 2315 |
echo "${script_name}: using OpenMP for threading." |
| 2316 |
enable_openmp='yes' |
| 2317 |
enable_openmp_01=1 |
| 2318 |
threading_model="openmp" # Standardize the value. |
| 2319 |
elif [ "x${threading_model}" = "xpthreads" ] || |
| 2320 |
[ "x${threading_model}" = "xpthread" ] || |
| 2321 |
[ "x${threading_model}" = "xposix" ]; then |
| 2322 |
echo "${script_name}: using Pthreads for threading." |
| 2323 |
enable_pthreads='yes' |
| 2324 |
enable_pthreads_01=1 |
| 2325 |
threading_model="pthreads" # Standardize the value. |
| 2326 |
elif [ "x${threading_model}" = "xno" ] || |
| 2327 |
[ "x${threading_model}" = "xnone" ]; then |
| 2328 |
echo "${script_name}: threading is disabled." |
| 2329 |
else |
| 2330 |
echo "${script_name}: *** Unsupported threading model: ${threading_model}." |
| 2331 |
exit 1 |
| 2332 |
fi |
| 2333 |
|
| 2334 |
# Convert 'yes' and 'no' flags to booleans. |
| 2335 |
if [ "x${enable_packbuf_pools}" = "xyes" ]; then |
| 2336 |
echo "${script_name}: internal memory pools for packing buffers are enabled." |
| 2337 |
enable_packbuf_pools_01=1 |
| 2338 |
else |
| 2339 |
echo "${script_name}: internal memory pools for packing buffers are disabled." |
| 2340 |
enable_packbuf_pools_01=0 |
| 2341 |
fi |
| 2342 |
if [ "x${has_memkind}" = "xyes" ]; then |
| 2343 |
# If no explicit option was given for libmemkind one way or the other, |
| 2344 |
# we use the value returned previously by has_libmemkind() to determine |
| 2345 |
# the default. |
| 2346 |
if [ "x${enable_memkind}" = "x" ]; then |
| 2347 |
enable_memkind="yes" |
| 2348 |
fi |
| 2349 |
echo "${script_name}: libmemkind found; default is to enable use." |
| 2350 |
if [ "x${enable_memkind}" = "xyes" ]; then |
| 2351 |
echo "${script_name}: received explicit request to enable libmemkind." |
| 2352 |
enable_memkind_01=1 |
| 2353 |
else |
| 2354 |
echo "${script_name}: received explicit request to disable libmemkind." |
| 2355 |
enable_memkind_01=0 |
| 2356 |
fi |
| 2357 |
else |
| 2358 |
echo "${script_name}: libmemkind not found; disabling." |
| 2359 |
if [ "x${enable_memkind}" = "xyes" ]; then |
| 2360 |
echo "${script_name}: cannot honor explicit request to enable libmemkind." |
| 2361 |
fi |
| 2362 |
enable_memkind="no" |
| 2363 |
enable_memkind_01=0 |
| 2364 |
fi |
| 2365 |
if [ "x${enable_blas}" = "xyes" ]; then |
| 2366 |
echo "${script_name}: the BLAS compatibility layer is enabled." |
| 2367 |
enable_blas_01=1 |
| 2368 |
else |
| 2369 |
echo "${script_name}: the BLAS compatibility layer is disabled." |
| 2370 |
enable_blas_01=0 |
| 2371 |
fi |
| 2372 |
if [ "x${enable_cblas}" = "xyes" ]; then |
| 2373 |
echo "${script_name}: the CBLAS compatibility layer is enabled." |
| 2374 |
enable_cblas_01=1 |
| 2375 |
# Force BLAS layer when CBLAS is enabled |
| 2376 |
enable_blas='yes' |
| 2377 |
else |
| 2378 |
echo "${script_name}: the CBLAS compatibility layer is disabled." |
| 2379 |
enable_cblas_01=0 |
| 2380 |
fi |
| 2381 |
|
| 2382 |
# Report integer sizes |
| 2383 |
if [ "x${int_type_size}" = "x32" ]; then |
| 2384 |
echo "${script_name}: the internal integer size is 32-bit." |
| 2385 |
elif [ "x${int_type_size}" = "x64" ]; then |
| 2386 |
echo "${script_name}: the internal integer size is 64-bit." |
| 2387 |
else |
| 2388 |
echo "${script_name}: the internal integer size is automatically determined." |
| 2389 |
fi |
| 2390 |
if [ "x${blas_int_type_size}" = "x32" ]; then |
| 2391 |
echo "${script_name}: the BLAS/CBLAS interface integer size is 32-bit." |
| 2392 |
elif [ "x${blas_int_type_size}" = "x64" ]; then |
| 2393 |
echo "${script_name}: the BLAS/CBLAS interface integer size is 64-bit." |
| 2394 |
else |
| 2395 |
echo "${script_name}: the BLAS/CBLAS interface integer size is automatically determined." |
| 2396 |
fi |
| 2397 |
|
| 2398 |
# Check if a sandbox was given. |
| 2399 |
if [ -n "${sandbox_flag}" ]; then |
| 2400 |
|
| 2401 |
#sandbox_relpath="${sandbox_dir}/${sandbox}" |
| 2402 |
|
| 2403 |
echo "${script_name}: configuring for alternate gemm implementation:" |
| 2404 |
echo "${script_name}: ${sandbox_dir}/${sandbox}" |
| 2405 |
|
| 2406 |
sandbox_fullpath="${sandbox_dirpath}/${sandbox}" |
| 2407 |
|
| 2408 |
if [ ! -d "${sandbox_fullpath}" ]; then |
| 2409 |
echo "${script_name}: requested sandbox sub-directory does not exist! Cannot continue." |
| 2410 |
echo "${script_name}: *** Please verify sandbox existence and name." |
| 2411 |
exit 1 |
| 2412 |
fi |
| 2413 |
|
| 2414 |
enable_sandbox_01=1 |
| 2415 |
else |
| 2416 |
echo "${script_name}: configuring for conventional gemm implementation." |
| 2417 |
|
| 2418 |
enable_sandbox_01=0 |
| 2419 |
fi |
| 2420 |
|
| 2421 |
|
| 2422 |
# Variables that contain forward slashes, such as paths, need extra |
| 2423 |
# escaping when used in sed commands. We insert those extra escape |
| 2424 |
# characters here so that the sed commands below do the right thing. |
| 2425 |
install_libdir_esc=$(echo "${install_libdir}" | sed 's/\//\\\//g') |
| 2426 |
install_incdir_esc=$(echo "${install_incdir}" | sed 's/\//\\\//g') |
| 2427 |
install_sharedir_esc=$(echo "${install_sharedir}" | sed 's/\//\\\//g') |
| 2428 |
dist_path_esc=$(echo "${dist_path}" | sed 's/\//\\\//g') |
| 2429 |
cc_esc=$(echo "${found_cc}" | sed 's/\//\\\//g') |
| 2430 |
cxx_esc=$(echo "${found_cxx}" | sed 's/\//\\\//g') |
| 2431 |
#sandbox_relpath_esc=$(echo "${sandbox_relpath}" | sed 's/\//\\\//g') |
| 2432 |
|
| 2433 |
# For RANLIB, if the variable is not set, we use a default value of |
| 2434 |
# 'ranlib'. |
| 2435 |
ranlib_esc=$(echo "${RANLIB:-ranlib}" | sed 's/\//\\\//g') |
| 2436 |
cflags_preset_esc=$(echo "${cflags_preset}" | sed 's/\//\\\//g') |
| 2437 |
ldflags_preset_esc=$(echo "${ldflags_preset}" | sed 's/\//\\\//g') |
| 2438 |
|
| 2439 |
# Create a #define for the configuration family (config_name). |
| 2440 |
uconf=$(echo ${config_name} | tr '[:lower:]' '[:upper:]') |
| 2441 |
config_name_define="#define BLIS_FAMILY_${uconf}\n" |
| 2442 |
|
| 2443 |
# Create a list of #defines, one for each configuration in config_list. |
| 2444 |
config_list_defines="" |
| 2445 |
for conf in ${config_list}; do |
| 2446 |
|
| 2447 |
# Convert the current config name to uppercase. |
| 2448 |
uconf=$(echo ${conf} | tr '[:lower:]' '[:upper:]') |
| 2449 |
|
| 2450 |
# Create a #define and add it to the running list. |
| 2451 |
config_define="BLIS_CONFIG_${uconf}" |
| 2452 |
config_list_defines="${config_list_defines}#define ${config_define}\n" |
| 2453 |
done |
| 2454 |
|
| 2455 |
# Create a list of #defines, one for each kernel set in kernel_list. |
| 2456 |
kernel_list_defines="" |
| 2457 |
for kern in ${kernel_list}; do |
| 2458 |
|
| 2459 |
# Convert the current config name to uppercase. |
| 2460 |
uconf=$(echo ${kern} | tr '[:lower:]' '[:upper:]') |
| 2461 |
|
| 2462 |
# Create a #define and add it to the running list. |
| 2463 |
kernel_define="BLIS_KERNELS_${uconf}" |
| 2464 |
kernel_list_defines="${kernel_list_defines}#define ${kernel_define}\n" |
| 2465 |
done |
| 2466 |
|
| 2467 |
|
| 2468 |
# -- Determine whether we are performing an out-of-tree build -------------- |
| 2469 |
|
| 2470 |
if [ ${dist_path} != "./" ]; then |
| 2471 |
|
| 2472 |
# At this point, we know the user did not run "./configure". But we |
| 2473 |
# have not yet ruled out "<fullpath>/configure" or some # equivalent |
| 2474 |
# that uses relative paths. To further rule out these possibilities, |
| 2475 |
# we create a dummy file in the current build directory. |
| 2476 |
touch ./${dummy_file} |
| 2477 |
|
| 2478 |
# If the dummy file we just created in the current directory does not |
| 2479 |
# appear in the source distribution path, then we are in a different |
| 2480 |
# directory and thus we must create a symbolic link. |
| 2481 |
if [ ! -f "${dist_path}/${dummy_file}" ]; then |
| 2482 |
configured_oot="yes" |
| 2483 |
#echo "${script_name}: detected out-of-tree build directory." |
| 2484 |
else |
| 2485 |
configured_oot="no" |
| 2486 |
#echo "${script_name}: detected in-tree build directory." |
| 2487 |
fi |
| 2488 |
|
| 2489 |
# Remove the dummy file. |
| 2490 |
rm -f "./${dummy_file}" |
| 2491 |
fi |
| 2492 |
|
| 2493 |
|
| 2494 |
# -- Instantiate config.mk, bli_config.h files from templates -------------- |
| 2495 |
|
| 2496 |
# Begin substituting information into the config_mk_in file, outputting |
| 2497 |
# to config_mk_out. |
| 2498 |
echo "${script_name}: creating ${config_mk_out_path} from ${config_mk_in_path}" |
| 2499 |
cat "${config_mk_in_path}" \ |
| 2500 |
| sed -e "s/@version@/${version}/g" \ |
| 2501 |
| sed -e "s/@so_version_major@/${so_version_major}/g" \ |
| 2502 |
| sed -e "s/@so_version_minorbuild@/${so_version_minorbuild}/g" \ |
| 2503 |
| sed -e "s/@config_name@/${config_name}/g" \ |
| 2504 |
| sed -e "s/@config_list@/${config_list}/g" \ |
| 2505 |
| sed -e "s/@kernel_list@/${kernel_list}/g" \ |
| 2506 |
| sed -e "s/@kconfig_map@/${kconfig_map}/g" \ |
| 2507 |
| sed -e "s/@os_name@/${os_name}/g" \ |
| 2508 |
| sed -e "s/@dist_path@/${dist_path_esc}/g" \ |
| 2509 |
| sed -e "s/@CC_VENDOR@/${cc_vendor}/g" \ |
| 2510 |
| sed -e "s/@CC@/${cc_esc}/g" \ |
| 2511 |
| sed -e "s/@CXX@/${cxx_esc}/g" \ |
| 2512 |
| sed -e "s/@RANLIB@/${ranlib_esc}/g" \ |
| 2513 |
| sed -e "s/@cflags_preset@/${cflags_preset_esc}/g" \ |
| 2514 |
| sed -e "s/@ldflags_preset@/${ldflags_preset_esc}/g" \ |
| 2515 |
| sed -e "s/@debug_type@/${debug_type}/g" \ |
| 2516 |
| sed -e "s/@threading_model@/${threading_model}/g" \ |
| 2517 |
| sed -e "s/@install_libdir@/${install_libdir_esc}/g" \ |
| 2518 |
| sed -e "s/@install_incdir@/${install_incdir_esc}/g" \ |
| 2519 |
| sed -e "s/@install_sharedir@/${install_sharedir_esc}/g" \ |
| 2520 |
| sed -e "s/@enable_verbose@/${enable_verbose}/g" \ |
| 2521 |
| sed -e "s/@configured_oot@/${configured_oot}/g" \ |
| 2522 |
| sed -e "s/@enable_arg_max_hack@/${enable_arg_max_hack}/g" \ |
| 2523 |
| sed -e "s/@enable_static@/${enable_static}/g" \ |
| 2524 |
| sed -e "s/@enable_shared@/${enable_shared}/g" \ |
| 2525 |
| sed -e "s/@enable_blas@/${enable_blas}/g" \ |
| 2526 |
| sed -e "s/@enable_cblas@/${enable_cblas}/g" \ |
| 2527 |
| sed -e "s/@enable_memkind@/${enable_memkind}/g" \ |
| 2528 |
| sed -e "s/@sandbox@/${sandbox}/g" \ |
| 2529 |
> "${config_mk_out_path}" |
| 2530 |
|
| 2531 |
|
| 2532 |
# Begin substituting information into the bli_config_h_in file, outputting |
| 2533 |
# to bli_config_h_out. NOTE: We use perl instead of sed because the version |
| 2534 |
# of sed used on OS X is old and does not handle the '\n' character |
| 2535 |
# intuitively, which was used when constructing ${config_name_define}, |
| 2536 |
# ${config_list_defines}, and ${kernel_list_defines}. |
| 2537 |
echo "${script_name}: creating ${bli_config_h_out_path} from ${bli_config_h_in_path}" |
| 2538 |
cat "${bli_config_h_in_path}" \ |
| 2539 |
| perl -pe "s/\@config_name_define\@/${config_name_define}/g" \ |
| 2540 |
| perl -pe "s/\@config_list_defines\@/${config_list_defines}/g" \ |
| 2541 |
| perl -pe "s/\@kernel_list_defines\@/${kernel_list_defines}/g" \ |
| 2542 |
| sed -e "s/@enable_openmp@/${enable_openmp_01}/g" \ |
| 2543 |
| sed -e "s/@enable_pthreads@/${enable_pthreads_01}/g" \ |
| 2544 |
| sed -e "s/@enable_packbuf_pools@/${enable_packbuf_pools_01}/g" \ |
| 2545 |
| sed -e "s/@int_type_size@/${int_type_size}/g" \ |
| 2546 |
| sed -e "s/@blas_int_type_size@/${blas_int_type_size}/g" \ |
| 2547 |
| sed -e "s/@enable_blas@/${enable_blas_01}/g" \ |
| 2548 |
| sed -e "s/@enable_cblas@/${enable_cblas_01}/g" \ |
| 2549 |
| sed -e "s/@enable_memkind@/${enable_memkind_01}/g" \ |
| 2550 |
| sed -e "s/@enable_sandbox@/${enable_sandbox_01}/g" \ |
| 2551 |
> "${bli_config_h_out_path}" |
| 2552 |
|
| 2553 |
|
| 2554 |
# -- Create top-level object directories ----------------------------------- |
| 2555 |
|
| 2556 |
# Create obj sub-directories (if they do not already exist). |
| 2557 |
base_obj_dirpath="${obj_dirpath}/${config_name}" |
| 2558 |
|
| 2559 |
echo "${script_name}: creating ${base_obj_dirpath}" |
| 2560 |
mkdir -p ${base_obj_dirpath} |
| 2561 |
|
| 2562 |
|
| 2563 |
obj_config_dirpath="${base_obj_dirpath}/${config_dir}" |
| 2564 |
|
| 2565 |
#echo "${script_name}: creating ${obj_config_dirpath}" |
| 2566 |
mkdir -p ${obj_config_dirpath} |
| 2567 |
for conf in ${config_list}; do |
| 2568 |
echo "${script_name}: creating ${obj_config_dirpath}/${conf}" |
| 2569 |
mkdir -p ${obj_config_dirpath}/${conf} |
| 2570 |
done |
| 2571 |
|
| 2572 |
|
| 2573 |
obj_kernels_dirpath="${base_obj_dirpath}/${kernels_dir}" |
| 2574 |
|
| 2575 |
#echo "${script_name}: creating ${obj_kernels_dirpath}" |
| 2576 |
mkdir -p ${obj_kernels_dirpath} |
| 2577 |
for kern in ${kernel_list}; do |
| 2578 |
echo "${script_name}: creating ${obj_kernels_dirpath}/${kern}" |
| 2579 |
mkdir -p ${obj_kernels_dirpath}/${kern} |
| 2580 |
done |
| 2581 |
|
| 2582 |
|
| 2583 |
obj_refkern_dirpath="${base_obj_dirpath}/${refkern_dir}" |
| 2584 |
|
| 2585 |
#echo "${script_name}: creating ${obj_refkern_dirpath}" |
| 2586 |
mkdir -p ${obj_refkern_dirpath} |
| 2587 |
for conf in ${config_list}; do |
| 2588 |
echo "${script_name}: creating ${obj_refkern_dirpath}/${conf}" |
| 2589 |
mkdir -p ${obj_refkern_dirpath}/${conf} |
| 2590 |
done |
| 2591 |
|
| 2592 |
|
| 2593 |
obj_frame_dirpath="${base_obj_dirpath}/${frame_dir}" |
| 2594 |
|
| 2595 |
echo "${script_name}: creating ${obj_frame_dirpath}" |
| 2596 |
mkdir -p ${obj_frame_dirpath} |
| 2597 |
|
| 2598 |
|
| 2599 |
if [ -n "${sandbox_flag}" ]; then |
| 2600 |
|
| 2601 |
obj_sandbox_dirpath="${base_obj_dirpath}/${sandbox_dir}" |
| 2602 |
|
| 2603 |
echo "${script_name}: creating ${obj_sandbox_dirpath}/${sandbox}" |
| 2604 |
mkdir -p ${obj_sandbox_dirpath}/${sandbox} |
| 2605 |
fi |
| 2606 |
|
| 2607 |
|
| 2608 |
obj_blastest_dirpath="${base_obj_dirpath}/${blastest_dir}" |
| 2609 |
|
| 2610 |
echo "${script_name}: creating ${obj_blastest_dirpath}" |
| 2611 |
mkdir -p ${obj_blastest_dirpath} |
| 2612 |
|
| 2613 |
|
| 2614 |
obj_testsuite_dirpath="${base_obj_dirpath}/${testsuite_dir}" |
| 2615 |
|
| 2616 |
echo "${script_name}: creating ${obj_testsuite_dirpath}" |
| 2617 |
mkdir -p ${obj_testsuite_dirpath} |
| 2618 |
|
| 2619 |
|
| 2620 |
# Create lib directory (if it does not already exist). |
| 2621 |
base_lib_dirpath="${lib_dirpath}/${config_name}" |
| 2622 |
|
| 2623 |
echo "${script_name}: creating ${base_lib_dirpath}" |
| 2624 |
mkdir -p ${base_lib_dirpath} |
| 2625 |
|
| 2626 |
# Create include directory (if it does not already exist). |
| 2627 |
base_include_dirpath="${include_dirpath}/${config_name}" |
| 2628 |
|
| 2629 |
echo "${script_name}: creating ${base_include_dirpath}" |
| 2630 |
mkdir -p ${base_include_dirpath} |
| 2631 |
|
| 2632 |
|
| 2633 |
# -- Mirror source directory hierarchies to object directories ------------- |
| 2634 |
|
| 2635 |
# Combine the config_list with the config_name and then remove duplicates. |
| 2636 |
config_list_plus_name=$(rm_duplicate_words "${config_list} ${config_name}") |
| 2637 |
|
| 2638 |
# Mirror each of the sub-configuration directories to the object directory. |
| 2639 |
for conf in ${config_list_plus_name}; do |
| 2640 |
|
| 2641 |
echo "${script_name}: mirroring ${config_dirpath}/${conf} to ${obj_config_dirpath}/${conf}" |
| 2642 |
${mirror_tree_sh} "${config_dirpath}/${conf}" "${obj_config_dirpath}/${conf}" |
| 2643 |
done |
| 2644 |
|
| 2645 |
# Mirror optimized kernels source tree to its object sub-directory. |
| 2646 |
# We perform the mirroring on each configuration/kernel sub-directory |
| 2647 |
# within 'kernels'. |
| 2648 |
for kern in ${kernel_list}; do |
| 2649 |
|
| 2650 |
# Only mirror the optimized kernels source directory if it exists. |
| 2651 |
# There are occasions where one of the sub-configurations in the |
| 2652 |
# config_list does not correspond to a kernels sub-directory, such |
| 2653 |
# as when architecture B is so close to architecture A that B can |
| 2654 |
# use A's kernel source code unmodified (though perhaps with |
| 2655 |
# different blocksizes). |
| 2656 |
#if [ -d "${kernels_dirpath}/${conf}" ]; then |
| 2657 |
|
| 2658 |
echo "${script_name}: mirroring ${kernels_dirpath}/${kern} to ${obj_kernels_dirpath}/${kern}" |
| 2659 |
${mirror_tree_sh} "${kernels_dirpath}/${kern}" "${obj_kernels_dirpath}/${kern}" |
| 2660 |
#else |
| 2661 |
# echo "${script_name}: mirroring ${kernels_dirpath}/${conf} skipped... directory does not exist" |
| 2662 |
#fi |
| 2663 |
done |
| 2664 |
|
| 2665 |
# Mirror reference kernel source tree to its object sub-directory. |
| 2666 |
echo "${script_name}: mirroring ${refkern_dirpath} to ${obj_refkern_dirpath}" |
| 2667 |
${mirror_tree_sh} ${refkern_dirpath} ${obj_refkern_dirpath} |
| 2668 |
|
| 2669 |
# Mirror reference kernels source tree to its object sub-directory. |
| 2670 |
for conf in ${config_list}; do |
| 2671 |
|
| 2672 |
echo "${script_name}: mirroring ${refkern_dirpath} to ${obj_refkern_dirpath}/${conf}" |
| 2673 |
${mirror_tree_sh} "${refkern_dirpath}" "${obj_refkern_dirpath}/${conf}" |
| 2674 |
done |
| 2675 |
|
| 2676 |
# Mirror framework source tree to its object sub-directory. |
| 2677 |
echo "${script_name}: mirroring ${frame_dirpath} to ${obj_frame_dirpath}" |
| 2678 |
${mirror_tree_sh} ${frame_dirpath} ${obj_frame_dirpath} |
| 2679 |
|
| 2680 |
# Mirror the chosen sandbox source tree to its object sub-directory. |
| 2681 |
if [ -n "${sandbox_flag}" ]; then |
| 2682 |
|
| 2683 |
echo "${script_name}: mirroring ${sandbox_dirpath}/${sandbox} to ${obj_sandbox_dirpath}/${sandbox}" |
| 2684 |
${mirror_tree_sh} "${sandbox_dirpath}/${sandbox}" "${obj_sandbox_dirpath}/${sandbox}" |
| 2685 |
fi |
| 2686 |
|
| 2687 |
|
| 2688 |
# -- Generate makefile fragements ------------------------------------------ |
| 2689 |
|
| 2690 |
clist_contains_cname=$(is_in_list "${config_name}" "${config_list}") |
| 2691 |
|
| 2692 |
# If the config_list does not already contain the config_name (i.e., |
| 2693 |
# if config_name is an umbrella family), generate makefiles in that |
| 2694 |
# directory. (In the next step, we will loop over the actual sub- |
| 2695 |
# configurations and create fragments there as well.) |
| 2696 |
if [ "${clist_contains_cname}" == "false" ]; then |
| 2697 |
|
| 2698 |
echo "${script_name}: creating makefile fragments in ${obj_config_dirpath}/${config_name}" |
| 2699 |
${gen_make_frags_sh} \ |
| 2700 |
-h -r -v0 \ |
| 2701 |
-o ${script_name} \ |
| 2702 |
-p 'CONFIG' \ |
| 2703 |
${config_dirpath}/${config_name} \ |
| 2704 |
${obj_config_dirpath}/${config_name} \ |
| 2705 |
${gen_make_frags_dirpath}/fragment.mk \ |
| 2706 |
${gen_make_frags_dirpath}/suffix_list \ |
| 2707 |
${gen_make_frags_dirpath}/ignore_list |
| 2708 |
fi |
| 2709 |
|
| 2710 |
# Generate makefile fragments for each of the sub-configurations present |
| 2711 |
# in the configuration list. |
| 2712 |
for conf in ${config_list}; do |
| 2713 |
|
| 2714 |
echo "${script_name}: creating makefile fragments in ${obj_config_dirpath}/${conf}" |
| 2715 |
${gen_make_frags_sh} \ |
| 2716 |
-h -r -v0 \ |
| 2717 |
-o ${script_name} \ |
| 2718 |
-p 'CONFIG' \ |
| 2719 |
${config_dirpath}/${conf} \ |
| 2720 |
${obj_config_dirpath}/${conf} \ |
| 2721 |
${gen_make_frags_dirpath}/fragment.mk \ |
| 2722 |
${gen_make_frags_dirpath}/suffix_list \ |
| 2723 |
${gen_make_frags_dirpath}/ignore_list |
| 2724 |
done |
| 2725 |
|
| 2726 |
# Generate makefile fragments for each of the kernel sets required by |
| 2727 |
# the configuration list (in the kernel list). |
| 2728 |
for kern in ${kernel_list}; do |
| 2729 |
|
| 2730 |
echo "${script_name}: creating makefile fragments in ${obj_kernels_dirpath}/${kern}" |
| 2731 |
${gen_make_frags_sh} \ |
| 2732 |
-h -r -v0 \ |
| 2733 |
-o ${script_name} \ |
| 2734 |
-p 'KERNELS' \ |
| 2735 |
${kernels_dirpath}/${kern} \ |
| 2736 |
${obj_kernels_dirpath}/${kern} \ |
| 2737 |
${gen_make_frags_dirpath}/fragment.mk \ |
| 2738 |
${gen_make_frags_dirpath}/suffix_list \ |
| 2739 |
${gen_make_frags_dirpath}/ignore_list |
| 2740 |
done |
| 2741 |
|
| 2742 |
# Generate makefile fragments in the reference kernels directory. |
| 2743 |
echo "${script_name}: creating makefile fragments in ${obj_refkern_dirpath}" |
| 2744 |
${gen_make_frags_sh} \ |
| 2745 |
-h -r -v0 \ |
| 2746 |
-o ${script_name} \ |
| 2747 |
-p 'REFKERN' \ |
| 2748 |
${refkern_dirpath} \ |
| 2749 |
${obj_refkern_dirpath} \ |
| 2750 |
${gen_make_frags_dirpath}/fragment.mk \ |
| 2751 |
${gen_make_frags_dirpath}/suffix_list \ |
| 2752 |
${gen_make_frags_dirpath}/ignore_list |
| 2753 |
|
| 2754 |
# Generate makefile fragments in the framework directory. |
| 2755 |
echo "${script_name}: creating makefile fragments in ${obj_frame_dirpath}" |
| 2756 |
${gen_make_frags_sh} \ |
| 2757 |
-h -r -v0 \ |
| 2758 |
-o ${script_name} \ |
| 2759 |
-p 'FRAME' \ |
| 2760 |
${frame_dirpath} \ |
| 2761 |
${obj_frame_dirpath} \ |
| 2762 |
${gen_make_frags_dirpath}/fragment.mk \ |
| 2763 |
${gen_make_frags_dirpath}/suffix_list \ |
| 2764 |
${gen_make_frags_dirpath}/ignore_list |
| 2765 |
|
| 2766 |
# Generate makefile fragments in the sandbox sub-directory. |
| 2767 |
if [ -n "${sandbox_flag}" ]; then |
| 2768 |
|
| 2769 |
echo "${script_name}: creating makefile fragments in ${obj_sandbox_dirpath}/${sandbox}" |
| 2770 |
${gen_make_frags_sh} \ |
| 2771 |
-h -r -v0 \ |
| 2772 |
-o ${script_name} \ |
| 2773 |
-p 'SANDBOX' \ |
| 2774 |
${sandbox_dirpath}/${sandbox} \ |
| 2775 |
${obj_sandbox_dirpath}/${sandbox} \ |
| 2776 |
${gen_make_frags_dirpath}/fragment.mk \ |
| 2777 |
${gen_make_frags_dirpath}/suffix_list \ |
| 2778 |
${gen_make_frags_dirpath}/ignore_list |
| 2779 |
fi |
| 2780 |
|
| 2781 |
|
| 2782 |
# -- Handle out-of-tree builds --------------------------------------------- |
| 2783 |
|
| 2784 |
# Under some circumstances, we need to create some symbolic links to |
| 2785 |
# properly handle out-of-tree builds. |
| 2786 |
if [ "${configured_oot}" = "yes" ]; then |
| 2787 |
|
| 2788 |
# If 'Makefile' symlink does not already exist in the current |
| 2789 |
# directory, create a symbolic link to it. If one does exist, we |
| 2790 |
# use -f to force creation of a new link. |
| 2791 |
if [ ! -e "./Makefile" ]; then |
| 2792 |
|
| 2793 |
echo "${script_name}: creating symbolic link to Makefile." |
| 2794 |
ln -s "${dist_path}/Makefile" |
| 2795 |
|
| 2796 |
elif [ -h "./Makefile" ]; then |
| 2797 |
echo "${script_name}: symbolic link to Makefile already exists; forcing creation of new link." |
| 2798 |
ln -sf "${dist_path}/Makefile" |
| 2799 |
else |
| 2800 |
echo "${script_name}: Non-symbolic link file or directory 'Makefile' blocks creation of symlink." |
| 2801 |
echo "${script_name}: *** Please remove this entity and re-run configure." |
| 2802 |
exit 1 |
| 2803 |
fi |
| 2804 |
|
| 2805 |
# If 'common.mk' symlink does not already exist in the current |
| 2806 |
# directory, create a symbolic link to it. If one does exist, we |
| 2807 |
# use -f to force creation of a new link. |
| 2808 |
if [ ! -e "./common.mk" ]; then |
| 2809 |
|
| 2810 |
echo "${script_name}: creating symbolic link to common.mk." |
| 2811 |
ln -s "${dist_path}/common.mk" |
| 2812 |
|
| 2813 |
elif [ -h "./common.mk" ]; then |
| 2814 |
echo "${script_name}: symbolic link to common.mk already exists; forcing creation of new link." |
| 2815 |
ln -sf "${dist_path}/common.mk" |
| 2816 |
else |
| 2817 |
echo "${script_name}: Non-symbolic link file or directory 'common.mk' blocks creation of symlink." |
| 2818 |
echo "${script_name}: *** Please remove this entity and re-run configure." |
| 2819 |
exit 1 |
| 2820 |
fi |
| 2821 |
|
| 2822 |
# If 'config' symlink does not already exist in the current |
| 2823 |
# directory, create a symbolic link to it. If one does exist, we |
| 2824 |
# use -f to force creation of a new link. |
| 2825 |
if [ ! -e "./config" ]; then |
| 2826 |
|
| 2827 |
echo "${script_name}: creating symbolic link to 'config' directory." |
| 2828 |
ln -s "${dist_path}/config" |
| 2829 |
|
| 2830 |
elif [ -h "./config" ]; then |
| 2831 |
echo "${script_name}: symbolic link to 'config' directory already exists; forcing creation of new link." |
| 2832 |
ln -sf "${dist_path}/config" |
| 2833 |
else |
| 2834 |
echo "${script_name}: Non-symbolic link file or directory 'config' blocks creation of symlink." |
| 2835 |
echo "${script_name}: *** Please remove this entity and re-run configure." |
| 2836 |
exit 1 |
| 2837 |
fi |
| 2838 |
|
| 2839 |
echo "${script_name}: configured to build outside of source distribution." |
| 2840 |
else |
| 2841 |
|
| 2842 |
echo "${script_name}: configured to build within top-level directory of source distribution." |
| 2843 |
fi |
| 2844 |
|
| 2845 |
|
| 2846 |
# Exit peacefully. |
| 2847 |
return 0 |
| 2848 |
} |
| 2849 |
|
| 2850 |
|
| 2851 |
# The script's main entry point, passing all parameters given. |
| 2852 |
main "$@" |
| 2853 |
|