forked from amd/blis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1557 lines (1252 loc) · 47 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# BLIS
# An object-based framework for developing high-performance BLAS-like
# libraries.
#
# Copyright (C) 2014, The University of Texas at Austin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - Neither the name of The University of Texas at Austin nor the names
# of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
#
# -- Helper functions ----------------------------------------------------------
#
print_usage()
{
# Echo usage info.
echo " "
echo " ${script_name} (BLIS ${version})"
#echo " "
#echo " BLIS ${version}"
echo " "
echo " Field G. Van Zee"
echo " "
echo " Configure BLIS's build system for compilation using a specified"
echo " configuration directory."
echo " "
echo " Usage:"
echo " "
echo " ${script_name} [options] [env. vars.] confname"
echo " "
echo " Arguments:"
echo " "
echo " confname The name of the sub-directory inside of the 'config'"
echo " directory containing the desired BLIS configuration."
echo " Note that confname MUST be specified; if it is not,"
echo " configure will complain. To build a completely generic"
echo " implementation, use the 'generic' configuration"
echo " "
echo " Options:"
echo " "
echo " -p PREFIX, --prefix=PREFIX"
echo " "
echo " The path to which make will install buid products."
echo " If not given, PREFIX defaults to \$(HOME)/blis. If"
echo " the path refers to a directory that does not exist,"
echo " it will be created."
echo " "
echo " -d DEBUG, --enable-debug[=DEBUG]"
echo " "
echo " Enable debugging symbols in the library. If argument"
echo " DEBUG is given as 'opt', then optimization flags are"
echo " kept in the framework, otherwise optimization is"
echo " turned off."
echo " "
echo " --enable-verbose-make, --disable-verbose-make"
echo " "
echo " Enable (disabled by default) verbose compilation"
echo " output during make."
echo " "
echo " --disable-static, --enable-static"
echo " "
echo " Disable (enabled by default) building BLIS as a static"
echo " library. May be combined with --enable-shared."
echo " "
echo " --enable-shared, --disable-static"
echo " "
echo " Enable (disabled by default) building BLIS as a shared"
echo " library. May be combined with --enable-static."
echo " "
echo " -t MODEL, --enable-threading[=MODEL], --disable-threading"
echo " "
echo " Enable threading in the library, using threading model"
echo " MODEL={openmp,pthreads,no}. If MODEL=no or "
echo " --disable-threading is specified, threading will be"
echo " disabled. The default is 'no'."
echo " "
echo " --disable-packbuf-pools, --enable-packbuf-pools"
echo " "
echo " Disable (enabled by default) use of internal memory"
echo " pools for managing packing buffers. When disabled,"
echo " the function specified by BLIS_MALLOC_POOL is called"
echo " on-demand, whenever a packing buffer is needed, and"
echo " the buffer is released via the function specified by"
echo " BLIS_FREE_POOL() when the loop in which it was"
echo " allocated terminates. When enabled, the memory pools"
echo " minimize calls to both BLIS_MALLOC_POOL() and"
echo " BLIS_FREE_POOL(), especially in a multithreaded"
echo " environment, but does so through a mechanism that may"
echo " incur additional overhead in some (but not all)"
echo " situations."
echo " "
echo " -q, --quiet Suppress informational output. By default, configure"
echo " is verbose. (NOTE: -q is not yet implemented)"
echo " "
echo " -i SIZE, --int-size=SIZE"
echo " "
echo " Set the size (in bits) of internal BLIS integers and"
echo " integer types used in native BLIS interfaces. The"
echo " default inteter type size is architecture dependent."
echo " (Hint: You can always find this value printed at the"
echo " beginning of the testsuite output.)"
echo " "
echo " -b SIZE, --blas-int-size=SIZE"
echo " "
echo " Set the size (in bits) of integer types in external"
echo " BLAS and CBLAS interfaces, if enabled. The default"
echo " integer type size used in BLAS/CBLAS is 32 bits."
echo " "
echo " --disable-blas, --enable-blas"
echo " "
echo " Disable (enabled by default) building the BLAS"
echo " compatibility layer."
echo " "
echo " --enable-cblas, --disable-cblas"
echo " "
echo " Enable (disabled by default) building the CBLAS"
echo " compatibility layer. This automatically enables the"
echo " BLAS compatibility layer as well."
echo " "
echo " --force-version=STRING"
echo " "
echo " Force configure to use an arbitrary version string"
echo " STRING. This option may be useful when repackaging"
echo " custom versions of BLIS by outside organizations."
echo " "
echo " -c, --show-config-lists"
echo " "
echo " Print the config and kernel lists, and kernel-to-config"
echo " map after they are read from file. This can be useful"
echo " when debugging certain configuration issues, and/or as"
echo " a sanity check to make sure these lists are constituted"
echo " as expected."
echo " "
echo " -h, --help Output this information and quit."
echo " "
echo " Environment Variables:"
echo " "
echo " CC Specifies the C compiler to use."
echo " "
echo " Environment variables may also be specified as command line"
echo " options, e.g.:"
echo " "
echo " ./configure [options] CC=gcc sandybridge"
echo " "
echo " Note that not all compilers are compatible with a given"
echo " configuration."
echo " "
# Exit with non-zero exit status
exit 1
}
query_array()
{
array_name=$1
key_name=$2
var_name="${array_name}_${key_name}"
echo "${!var_name}"
}
read_registry_file()
{
local cname clist
filename="$1"
while read -r line
do
curline="${line}"
#echo "curline: ${curline}"
# Remove leading whitespace from the current line.
# NOTE: read -r already prunes leading whitespace
#curline=$(echo "${curline}" | sed "s/^[ \t]*//")
# Remove everything after comment character '#'.
curline=${curline%%#*}
# We've stripped out leading whitespace and trailing comments. If
# the line is now empty, then we can skip it altogether.
if [ "x${curline}" = "x" ]; then
continue;
fi
# Read the config name and config list for the current line.
cname=${curline%%:*}
list=${curline##*:}
# If we encounter a slash, it means the name of the configuration
# and the kernel set needed by that configuration are different.
if [[ "${list}" == *[/]* ]]; then
#echo "Slash found."
klist=""
clist=""
for item in "${list}"; do
# The sub-configuration name is always the first sub-word in
# the slash-separated compound word.
config=${item%%/*}
# Delete the sub-configuration name from the front of the
# string, leaving the slash-separated kernel names (or just
# the kernel name, if there is only one).
kernels=${list#*/}
# Replace the slashes with spaces to transform the string
# into a space-separated list of kernel names.
kernels=$(echo -e ${kernels} | sed -e "s/\// /g")
clist="${clist} ${config}"
klist="${klist} ${kernels}"
done
else
#echo "Slash not found."
clist=${list}
klist=${list}
fi
# Strip out whitespace from the config name and config/kernel list
# on each line.
cname=$(canonicalize_ws "${cname}")
clist=$(canonicalize_ws "${clist}")
klist=$(canonicalize_ws "${klist}")
# Store the config and kernel lists to the entry in the associative
# arrays that corresponds to the config name.
#config_registry[${cname}]=${clist}
#kernel_registry[${cname}]=${klist}
printf -v "config_registry_${cname}" %s "${clist}"
printf -v "kernel_registry_${cname}" %s "${klist}"
done < "${filename}"
# Now go back through the kernel registry and substitute any remaining
# configuration names occurring in the kernel list (right side of ':')
# with its registered kernel set.
#for config in "${!kernel_registry[@]}"; do
for kr_var in ${!kernel_registry_*}; do
config=${kr_var##kernel_registry_}
#for ker in ${kernel_registry[$config]}; do
for ker in ${!kr_var}; do
#kers_ker="${kernel_registry[${ker}]}"
kers_ker=$(query_array "kernel_registry" ${ker})
# If kers_ker is empty string, then ker was not found as a key
# in the kernel list associative array. In that case, we continue
# and will echo an error later in the script.
if [ "${kers_ker}" == "" ]; then
#echo " kernel for ${ker} is empty string! no entry in kernel list."
continue;
fi
# If the current config/kernel (ker) differs from its singleton kernel
# entry (kers_ker), then that singleton entry was specified to use
# a different configuration's kernel set. Thus, we need to replace the
# occurrence in the current config/kernel name with that of the kernel
# set it needs.
if [ "${ker}" != "${kers_ker}" ]; then
#klist="${kernel_registry[$config]}"
klist=$(query_array "kernel_registry" ${config})
# Replace the current config with its requisite kernels,
# canonicalize whitespace, and then remove duplicate kernel
# set names, if they exist. Finally, update the kernel registry
# with the new kernel list.
newklist=$(echo -e "${klist}" | sed -e "s/${ker}/${kers_ker}/g")
newklist=$(canonicalize_ws "${newklist}")
newklist=$(rm_duplicate_words "${newklist}")
#kernel_registry[${config}]=${newklist}
printf -v "kernel_registry_${config}" %s "${newklist}"
fi
done
done
}
build_kconfig_registry()
{
familyname="$1"
#clist="${config_registry[${familyname}]}"
clist=$(query_array "config_registry" ${familyname})
for config in ${clist}; do
#echo "${config}"
# Look up the kernel for the current sub-configuration.
#kernels="${kernel_registry[${config}]}"
kernels=$(query_array "kernel_registry" ${config})
for kernel in ${kernels}; do
#echo " ${kernel}"
# Add the sub-configuration to the list associated with the
# kernel.
# Query the current sub-configs for the current ${kernel}.
#cur_configs="${kconfig_registry[${kernel}]}"
cur_configs=$(query_array "kconfig_registry" ${kernel})
# Add the current sub-configuration to the list of sub-configs
# we just queried.
newvalue=$(canonicalize_ws "${cur_configs} ${config}")
# Update the array.
#kconfig_registry[${kernel}]="${newvalue}"
printf -v "kconfig_registry_${kernel}" %s "${newvalue}"
done
done
}
is_word_in_list()
{
word="$1"
list="$2"
rval="false"
for item in ${list}; do
if [ "${item}" == "${word}" ]; then
rval="true"
break
fi
done
echo "${rval}"
}
is_singleton()
{
list="$1"
rval="false"
count_str=""
for item in ${list}; do
count_str="${count_str}x"
done
if [ "${count_str}" == "x" ]; then
rval="true"
fi
echo "${rval}"
}
canonicalize_ws()
{
local str="$1"
# Remove leading and trailing whitespace.
str=$(echo -e "${str}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Remove duplicate spaces between words.
str=$(echo -e "${str}" | tr -s " ")
# Update the input argument.
echo "${str}"
}
rm_duplicate_words()
{
str="$1"
str=$(echo "${str}" | awk '{for (i=1;i<=NF;i++) if (!a[$i]++) printf("%s%s",$i,FS)}{printf("\n")}')
echo "${str}"
}
select_cc()
{
local rval found_cc
se_suf="stderr.txt"
# Initialize our selected compiler to empty.
found_cc=""
# If CC was specified on the configure command line, see if it works.
if [ -n "${CC}" ]; then
se_file="cc_${se_suf}"
# See if CC works and/or is present.
rval=$(${CC} --version 2> ${se_file})
if [ -z "$(cat ${se_file})" ]; then
found_cc=${CC}
fi
rm ${se_file}
fi
# Now check if gcc works.
if [ -z "${found_cc}" ]; then
se_file="gcc_${se_suf}"
# See if CC works and/or is present.
rval=$(gcc --version 2> ${se_file})
if [ -z "$(cat ${se_file})" ]; then
found_cc=gcc
fi
rm ${se_file}
fi
# Now check if clang works.
if [ -z "${found_cc}" ]; then
se_file="clang_${se_suf}"
# See if CC works and/or is present.
rval=$(clang --version 2> ${se_file})
if [ -z "$(cat ${se_file})" ]; then
found_cc=clang
fi
rm ${se_file}
fi
# If neither $CC, nor gcc, nor clang work, then we're probably all dead,
# so this fallback selection won't matter.
if [ -z "${found_cc}" ]; then
found_cc=cc
fi
# Return the selected compiler.
echo "${found_cc}"
}
auto_detect()
{
local rval autocc config_defines
# Find a compiler that works.
autocc=$(select_cc)
# For debugging: reveal what compiler was chosen for auto-detection.
#touch "${autocc}.txt"
# Tweak the flags we use based on the compiler. This is mostly just
# an opportunity to turn off annoying warnings that some compilers
# may throw off.
if [ "${autocc}" == "clang" ]; then
autoccflags="-Wno-tautological-compare"
else
autoccflags=
fi
# Locate our source files.
bli_arch_c="bli_arch.c"
bli_cpuid_c="bli_cpuid.c"
main_c="auto_detect.c"
bli_arch_c_filepath=$(find ${dist_path}/frame -name "${bli_arch_c}")
bli_cpuid_c_filepath=$(find ${dist_path}/frame -name "${bli_cpuid_c}")
main_c_filepath=$(find ${dist_path}/build -name "${main_c}")
# Locate headers needed directly by the above files.
bli_arch_h="bli_arch.h"
bli_cpuid_h="bli_cpuid.h"
bli_typed_h="bli_type_defs.h"
bli_arch_h_filepath=$(find ${dist_path}/frame -name "${bli_arch_h}")
bli_cpuid_h_filepath=$(find ${dist_path}/frame -name "${bli_cpuid_h}")
bli_typed_h_filepath=$(find ${dist_path}/frame -name "${bli_typed_h}")
bli_arch_h_path=${bli_arch_h_filepath%/${bli_arch_h}}
bli_cpuid_h_path=${bli_cpuid_h_filepath%/${bli_cpuid_h}}
bli_typed_h_path=${bli_typed_h_filepath%/${bli_typed_h}}
# Locate other headers needed by bli_type_defs.h.
bli_mutex_h="bli_mutex.h"
bli_malloc_h="bli_malloc.h"
bli_mutex_h_filepath=$(find ${dist_path}/frame -name "${bli_mutex_h}")
bli_malloc_h_filepath=$(find ${dist_path}/frame -name "${bli_malloc_h}")
bli_mutex_h_path=${bli_mutex_h_filepath%/${bli_mutex_h}}
bli_malloc_h_path=${bli_malloc_h_filepath%/${bli_malloc_h}}
# Define the executable name.
autodetect_x="auto-detect.x"
# Create #defines for all of the BLIS_CONFIG_ macros in bli_cpuid.c.
config_defines=$(grep BLIS_CONFIG_ ${bli_cpuid_c_filepath} \
| sed -e 's/#ifdef /-D/g')
# Compile the auto-detect program using source code inside the
# framework.
$autocc ${config_defines} \
-DBLIS_CONFIGURETIME_CPUID \
-I${bli_cpuid_h_path} \
-I${bli_arch_h_path} \
-I${bli_typed_h_path} \
-I${bli_mutex_h_path} \
-I${bli_malloc_h_path} \
-std=c99 \
${autoccflags} \
${bli_arch_c_filepath} \
${bli_cpuid_c_filepath} \
${main_c_filepath} \
-o ${autodetect_x}
# Run the auto-detect program.
#detected_config=`./${autodetect_x}`
detected_config=$(./${autodetect_x})
# Remove the executable file.
rm -f ./${autodetect_x}
# Return the detected sub-configuration name.
echo "${detected_config}"
}
#
# -- main function -------------------------------------------------------------
#
main()
{
#declare -A config_registry
#declare -A kernel_registry
#declare -A kconfig_registry
# The name of the script, stripped of any preceeding path.
script_name=${0##*/}
# The path to the script. We need this to find the top-level directory
# of the source distribution in the event that the user has chosen to
# build elsewhere.
dist_path=${0%/${script_name}}
# The path to the directory in which we are building. We do this to
# make explicit that we distinguish between the top-level directory
# of the distribution and the directory in which we are building.
cur_dirpath="."
# The file in which the version string is kept.
version_file="version"
version_filepath="${dist_path}/${version_file}"
# The name of and path to the directory named "build" in the top-level
# directory of the source distribution.
build_dir='build'
build_dirpath="${dist_path}/${build_dir}"
# The name/path to the registry (master list) of supported configurations.
registry_file="config_registry"
registry_filepath=${dist_path}/${registry_file}
# The names/paths for the template config.mk.in and its instantiated
# counterpart.
config_mk_in='config.mk.in'
config_mk_out='config.mk'
config_mk_in_path="${build_dirpath}/${config_mk_in}"
config_mk_out_path="${cur_dirpath}/${config_mk_out}"
# The names/paths for the template bli_config.h.in and its instantiated
# counterpart.
bli_config_h_in='bli_config.h.in'
bli_config_h_out='bli_config.h'
bli_config_h_in_path="${build_dirpath}/${bli_config_h_in}"
bli_config_h_out_path="${cur_dirpath}/${bli_config_h_out}"
# Path to 'update-version-file.sh' script.
update_version_file_sh="${build_dirpath}/update-version-file.sh"
# Path to 'mirror-tree.sh' script.
mirror_tree_sh="${build_dirpath}/mirror-tree.sh"
# Path to 'gen-make-frags.sh' script and directory.
gen_make_frags_dirpath="${build_dirpath}/gen-make-frags"
gen_make_frags_sh="${gen_make_frags_dirpath}/gen-make-frag.sh"
# The name of the (top-level) configuration directory.
config_dir='config'
config_dirpath="${dist_path}/${config_dir}"
# The name of the (top-level) kernels directory.
kernels_dir='kernels'
kernels_dirpath="${dist_path}/${kernels_dir}"
# The name of the (top-level) reference kernels directory.
refkern_dir='ref_kernels'
refkern_dirpath="${dist_path}/${refkern_dir}"
# The root directory of the BLIS framework.
frame_dir='frame'
frame_dirpath="${dist_path}/${frame_dir}"
# The name of the directory in which object files will be kept.
obj_dir='obj'
obj_dirpath="${cur_dirpath}/${obj_dir}"
# The name of the directory in which libraries will be kept.
lib_dir='lib'
lib_dirpath="${cur_dirpath}/${lib_dir}"
# The name of the directory in which headers will be kept.
include_dir='include'
include_dirpath="${cur_dirpath}/${include_dir}"
# The name of the directory in which the test suite is kept.
testsuite_dir='testsuite'
# The install prefix flag.
install_prefix_def="${HOME}/blis"
install_prefix=''
prefix_flag=''
# The debug flag.
debug_type=''
debug_flag=''
# The threading flag.
threading_model='no'
# Option variables.
quiet_flag=''
show_config_list=''
# Additional flags.
enable_verbose='no'
enable_static='yes'
enable_shared='no'
enable_packbuf_pools='yes'
int_type_size=0
blas2blis_int_type_size=32
enable_blas2blis='yes'
enable_cblas='no'
force_version='no'
# The name of the chosen configuration (the configuration "family").
config_name=''
# The list of sub-configurations associated with config_name.
config_list=''
# The list of kernel sets that will be needed by the sub-configurations
# in config_list..
kernel_list=''
# The list of kernel:sub-configuration pairs for all kernels contained
# in kernel_list.
kconfig_map=''
# Dummy file. Used to check whether the cwd is the same as the top-level
# source distribution directory.
dummy_file='_blis_dir_detect.tmp'
# -- Command line option/argument parsing ----------------------------------
# Process our command line options.
while getopts ":hp:d:t:qci:b:-:" opt; do
case $opt in
-)
case "$OPTARG" in
help)
print_usage
;;
quiet)
quiet_flag=1
;;
prefix=*)
prefix_flag=1
install_prefix=${OPTARG#*=}
;;
enable-debug)
debug_flag=1
debug_type=noopt
;;
enable-debug=*)
debug_flag=1
debug_type=${OPTARG#*=}
;;
disable-debug)
debug_flag=0
;;
enable-verbose-make)
enable_verbose='yes'
;;
disable-verbose-make)
enable_verbose='no'
;;
enable-static)
enable_static='yes'
;;
disable-static)
enable_static='no'
;;
enable-shared)
enable_shared='yes'
;;
disable-shared)
enable_shared='no'
;;
enable-threading=*)
threading_model=${OPTARG#*=}
;;
disable-threading)
threading_model='no'
;;
enable-packbuf-pools)
enable_packbuf_pools='yes'
;;
disable-packbuf-pools)
enable_packbuf_pools='no'
;;
int-size=*)
int_type_size=${OPTARG#*=}
;;
blas-int-size=*)
blas2blis_int_type_size=${OPTARG#*=}
;;
enable-blas)
enable_blas2blis='yes'
;;
disable-blas)
enable_blas2blis='no'
;;
enable-cblas)
enable_cblas='yes'
;;
disable-cblas)
enable_cblas='no'
;;
force-version=*)
force_version=${OPTARG#*=}
;;
show-config-list)
show_config_list=1
;;
*)
print_usage
;;
esac;;
h)
print_usage
;;
p)
prefix_flag=1
install_prefix=$OPTARG
;;
d)
debug_flag=1
debug_type=$OPTARG
;;
q)
quiet_flag=1
;;
t)
threading_model=$OPTARG
;;
i)
int_type_size=$OPTARG
;;
b)
blas2blis_int_type_size=$OPTARG
;;
c)
show_config_list=1
;;
\?)
print_usage
;;
esac
done
shift $(($OPTIND - 1))
# Parse environment variables
while [ $# -gt 0 ]; do
case $1 in
CC=*)
CC=${1#*=}
shift
;;
*=*)
print_usage
;;
*)
break
;;
esac
done
# -- Read the configuration registry ---------------------------------------
# Make sure the config registry file exists and can be opened.
if [ ! -f "${registry_filepath}" ]; then
echo "${script_name}: could not open '${registry_file}' file; cannot continue."
echo "${script_name}: BLIS distribution appears to be incomplete."
exit 1
fi
# Read the registered configuration names and lists into an associative
# array.
echo -n "${script_name}: reading configuration registry..."
read_registry_file ${registry_filepath}
echo "done."
# -- Acquire the BLIS version ----------------------------------------------
# Check whether we need to update the version file.
${update_version_file_sh} -o "${script_name}" "${version_filepath}"
# Query which version of BLIS this is.
version=$(cat ${version_filepath})
# Initial message.
echo "${script_name}: starting configuration of BLIS ${version}."
# Check if the user requested a custom version string.
if [ "x${force_version}" = "xno" ]; then
echo "${script_name}: configuring with official version string."
else
echo "${script_name}: configuring with custom version string '${force_version}'."
version="${force_version}"
fi
# -- Various pre-configuration checks --------------------------------------
# Set config_name based on the number of arguments leftover (after command
# line option processing).
if [ $# = "0" ]; then
#configs_avail="auto "$(ls ${config_dirpath})
echo "${script_name}: "
echo "${script_name}: *** No configuration given! ***"
echo "${script_name}: "
echo "${script_name}: Default configuration behavior is not implemented (for your"
echo "${script_name}: own safety). Please re-run '${script_name}' and specify one"
echo "${script_name}: of the existing configurations in the source distribution's"
echo "${script_name} '${registry_file}' file:"
echo "${script_name}: "
#for k in "${!config_registry[@]}"; do
for cr_var in ${!config_registry_*}; do
#v=${config_registry[$k]}
k=${cr_var##config_registry_}; v=${!cr_var}
echo "${script_name}: $k (${v})"
done
echo "${script_name}: "
exit 1
elif [ $# != "1" ]; then # more than one configuration argument given.
print_usage
fi
if [ $1 = "auto" ]; then
echo "${script_name}: automatic configuration requested."
# Call the auto_detect() function and save the returned string in
# config_name.
config_name=$(auto_detect)
echo "${script_name}: hardware detection driver returned '${config_name}'."
else
# Use the command line argument as the configuration name.
config_name=$1
#echo "${script_name}: manual configuration requested."
echo "${script_name}: manual configuration requested; configuring with '${config_name}'."
fi
# Use the selected config name to look up the list of configurations
# and kernels associated with that name.
#config_list=${config_registry[${config_name}]}
#kernel_list=${kernel_registry[${config_name}]}
config_list=$(query_array "config_registry" ${config_name})
kernel_list=$(query_array "kernel_registry" ${config_name})
# Use the config_registry and kernel_registry to build a kconfig_registry
# for the selected config_name.
build_kconfig_registry "${config_name}"
# Print the configuration list and kernel list, if requested.
if [ "${show_config_list}" == "1" ]; then
echo "${script_name}: configuration list:"
#for k in "${!config_registry[@]}"; do
for cr_var in ${!config_registry_*}; do
#v=${config_registry[$k]}
k=${cr_var##config_registry_}; v=${!cr_var}
echo "${script_name}: $k: ${v}"
done
echo "${script_name}: kernel list:"
#for k in "${!kernel_registry[@]}"; do
for kr_var in ${!kernel_registry_*}; do
#v=${kernel_registry[$k]}
k=${kr_var##kernel_registry_}; v=${!kr_var}
echo "${script_name}: $k: ${v}"
done
echo "${script_name}: kernel-to-config map for '${config_name}':"
#for k in "${!kconfig_registry[@]}"; do
for kc_var in ${!kconfig_registry_*}; do
#v=${kconfig_registry[$k]}
k=${kc_var##kconfig_registry_}; v=${!kc_var}
echo "${script_name}: $k: ${v}"
done
fi
# For each kernel in the kernel list, reduce the list of associated
# sub-configurations (in the kconfig_registry) to a singleton using
# the following rules:
# 1. If the list is a singleton, use that name.
# 2. If the list contains a sub-configuration name that matches the
# kernel name, use that name.
# 3. Otherwise, use the first name in the list.
# We use the chosen singleton to ceate a "kernel:subconfig" pair, which
# we accumulate into a list. This list is the kernel-to-config map, or
# kconfig_map.
# We use a sorted version of kernel_list so that it ends up matching the
# display order of the kconfig_registry above.
kernel_list_sort=$(echo ${kernel_list} | xargs -n1 | sort -u)
kconfig_map=""
for kernel in ${kernel_list_sort}; do
#configs="${kconfig_registry[$kernel]}"
configs=$(query_array "kconfig_registry" ${kernel})
has_one_kernel=$(is_singleton "${configs}")
contains_kernel=$(is_word_in_list "${kernel}" "${configs}")
# Check if the list is a singleton.
if [ "${has_one_kernel}" == "true" ]; then
reducedclist="${configs}"
# Check if the list contains a sub-config name that matches the kernel.
elif [ "${contains_kernel}" == "true" ]; then
reducedclist="${kernel}"