forked from flame/blis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·4603 lines (3774 loc) · 151 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
# Copyright (C) 2020-2022, Advanced Micro Devices, Inc.
#
# 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(s) of the copyright holder(s) 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()
{
# Use the version string in the 'version' file since we don't have
# the patched version string yet.
if [ -z "${version}" ]; then
version=$(cat "${version_filepath}")
fi
# Echo usage info.
echo " "
echo " ${script_name} (BLIS ${version})"
#echo " "
#echo " BLIS ${version}"
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 common installation prefix for all files. If given,"
echo " this option effectively implies:"
echo " --libdir=EXECPREFIX/lib"
echo " --includedir=PREFIX/include"
echo " --sharedir=PREFIX/share"
echo " where EXECPREFIX defaults to PREFIX. If this option is"
echo " not given, PREFIX defaults to '${prefix_def}'. If PREFIX"
echo " refers to a directory that does not exist, it will be"
echo " created."
echo " "
echo " --exec-prefix=EXECPREFIX"
echo " "
echo " The installation prefix for libraries. Specifically, if"
echo " given, this option effectively implies:"
echo " --libdir=EXECPREFIX/lib"
echo " If not given, EXECPREFIX defaults to PREFIX, which may be"
echo " modified by the --prefix option. If EXECPREFIX refers to"
echo " a directory that does not exist, it will be created."
echo " "
echo " --libdir=LIBDIR"
echo " "
echo " The path to which make will install libraries. If not"
echo " given, LIBDIR defaults to PREFIX/lib. If LIBDIR refers to"
echo " a directory that does not exist, it will be created."
echo " "
echo " --includedir=INCDIR"
echo " "
echo " The path to which make will install development header"
echo " files. If not given, INCDIR defaults to PREFIX/include."
echo " If INCDIR refers to a directory that does not exist, it"
echo " will be created."
echo " "
echo " --sharedir=SHAREDIR"
echo " "
echo " The path to which make will makefile fragments containing"
echo " make variables determined by configure (e.g. CC, CFLAGS,"
echo " and LDFLAGS). These files allow certain BLIS makefiles,"
echo " such as those in the examples or testsuite directories, to"
echo " operate on an installed copy of BLIS rather than a local"
echo " (and possibly uninstalled) copy. If not given, SHAREDIR"
echo " defaults to PREFIX/share. If SHAREDIR refers to a"
echo " directory that does not exist, it will be created."
echo " "
echo " --enable-verbose-make, --disable-verbose-make"
echo " "
echo " Enable (disabled by default) verbose compilation output"
echo " during make."
echo " "
echo " --enable-arg-max-hack --disable-arg-max-hack"
echo " "
echo " Enable (disabled by default) build system logic that"
echo " will allow archiving/linking the static/shared library"
echo " even if the command plus command line arguments exceeds"
echo " the operating system limit (ARG_MAX)."
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 " --disable-static, --enable-static"
echo " "
echo " Disable (enabled by default) building BLIS as a static"
echo " library. If the static library build is disabled, the"
echo " shared library build must remain enabled."
echo " "
echo " --disable-shared, --enable-shared"
echo " "
echo " Disable (enabled by default) building BLIS as a shared"
echo " library. If the shared library build is disabled, the"
echo " static library build must remain enabled."
echo " "
echo " --enable-rpath, --disable-rpath"
echo " "
echo " Enable (disabled by default) setting an install_name for"
echo " dynamic libraries on macOS which starts with @rpath rather"
echo " than the absolute install path."
echo " "
echo " -e SYMBOLS, --export-shared[=SYMBOLS]"
echo " "
echo " Specify the subset of library symbols that are exported"
echo " within a shared library. Valid values for SYMBOLS are:"
echo " 'public' (the default) and 'all'. By default, only"
echo " functions and variables that belong to public APIs are"
echo " exported in shared libraries. However, the user may"
echo " instead export all symbols in BLIS, even those that were"
echo " intended for internal use only. Note that the public APIs"
echo " encompass all functions that almost any user would ever"
echo " want to call, including the BLAS/CBLAS compatibility APIs"
echo " as well as the basic and expert interfaces to the typed"
echo " and object APIs that are unique to BLIS. Also note that"
echo " changing this option to 'all' will have no effect in some"
echo " environments, such as when compiling with clang on"
echo " Windows."
echo " "
echo " -t MODEL, --enable-threading[=MODEL], --disable-threading"
echo " "
echo " Enable threading in the library, using threading model(s)"
echo " MODEL={single,openmp,pthreads,hpx,auto}. If multiple values"
echo " are specified within MODEL, they will all be compiled into"
echo " BLIS, and the choice of which to use will be determined at"
echo " runtime. If the user does not express a preference (by"
echo " setting the BLIS_THREAD_IMPL environment variable to"
echo " 'single', 'openmp', 'pthreads', or 'hpx'; by calling the"
echo " global runtime API bli_thread_set_thread_impl(); or by"
echo " encoding a choice on a per-call basis within a rntm_t"
echo " passed into the expert API), then the first model listed"
echo " in MODEL will be used by default. Note that 'single' is"
echo " silently appended to whatever the user specifies in MODEL,"
echo " meaning that single-threaded functionality will always be"
echo " available, even if it is not requested and even if it is"
echo " not enabled by default. Even --disable-threading is"
echo " actually shorthand for --enable-threading=single (which is"
echo " the default when the option is not specified)."
echo " "
echo " --enable-system, --disable-system"
echo " "
echo " Enable conventional operating system support, such as"
echo " pthreads for thread-safety. The default state is enabled."
echo " However, in rare circumstances you may wish to configure"
echo " BLIS for use with a minimal or nonexistent operating"
echo " system (e.g. hardware simulators). In these situations,"
echo " --disable-system may be used to jettison all compile-time"
echo " and link-time dependencies outside of the standard C"
echo " library. When disabled, this option also forces the use"
echo " of --disable-threading."
echo " "
echo " --disable-pba-pools, --enable-pba-pools"
echo " --disable-sba-pools, --enable-sba-pools"
echo " "
echo " Disable (enabled by default) use of internal memory pools"
echo " within the packing block allocator (pba) and/or the small"
echo " block allocator (sba). The former is used to allocate"
echo " memory used to pack submatrices while the latter is used"
echo " to allocate control/thread tree nodes and thread"
echo " communicators. Both allocations take place in the context"
echo " of level-3 operations. When the pba is disabled, the"
echo " malloc()-like function specified by BLIS_MALLOC_POOL is"
echo " called on-demand whenever a packing block is needed, and"
echo " when the sba is disabled, the malloc()-like function"
echo " specified by BLIS_MALLOC_INTL is called whenever a small"
echo " block is needed, with the two allocators calling free()-"
echo " like functions BLIS_FREE_POOL and BLIS_FREE_INTL,"
echo " respectively when blocks are released. When enabled,"
echo " either or both pools are populated via the same functions"
echo " mentioned previously, and henceforth blocks are checked"
echo " out and in. The library quickly reaches a state in which"
echo " it no longer needs to call malloc() or free(), even"
echo " across many separate level-3 operation invocations."
echo " "
echo " --enable-mem-tracing, --disable-mem-tracing"
echo " "
echo " Enable (disabled by default) output to stdout that traces"
echo " the allocation and freeing of memory, including the names"
echo " of the functions that triggered the allocation/freeing."
echo " Enabling this option WILL NEGATIVELY IMPACT PERFORMANCE."
echo " Please use only for informational/debugging purposes."
echo " "
echo " --enable-asan, --disable-asan"
echo " "
echo " Enable (disabled by default) compiling and linking BLIS"
echo " framework code with the AddressSanitizer (ASan) library."
echo " Optimized kernels are NOT compiled with ASan support due"
echo " to limitations of register assignment in inline assembly."
echo " WARNING: ENABLING THIS OPTION WILL NEGATIVELY IMPACT"
echo " PERFORMANCE. Please use only for informational/debugging"
echo " purposes."
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 integer 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 " --disable-mixed-dt, --enable-mixed-dt"
echo " "
echo " Disable (enabled by default) support for mixing the"
echo " storage domain and/or storage precision of matrix"
echo " operands for the gemm operation, as well as support"
echo " for computing in a precision different from one or"
echo " both of matrices A and B."
echo " "
echo " --disable-mixed-dt-extra-mem, --enable-mixed-dt-extra-mem"
echo " "
echo " Disable (enabled by default) support for additional"
echo " mixed datatype optimizations that require temporarily"
echo " allocating extra memory--specifically, a single m x n"
echo " matrix (per application thread) whose storage datatype"
echo " is equal to the computation datatype. This option may"
echo " only be enabled when mixed domain/precision support is"
echo " enabled."
echo " "
echo " --disable-sup-handling, --enable-sup-handling"
echo " "
echo " Disable (enabled by default) handling of small/skinny"
echo " matrix problems via separate code branches. When disabled,"
echo " these small/skinny level-3 operations will be performed by"
echo " the conventional implementation, which is optimized for"
echo " medium and large problems. Note that what qualifies as"
echo " \"small\" depends on thresholds that may vary by sub-"
echo " configuration."
echo " "
echo " --enable-amd-frame-tweaks, --disable-amd-frame-tweaks"
echo " "
echo " Enable building with certain framework files that have"
echo " been customized by AMD for Zen-based microarchitectures."
echo " The default counterparts of these files must be portable,"
echo " and so these customized files may provide some (typically"
echo " modest) performance improvement for some select operations"
echo " and/or APIs, though there may a few (tiny dimension) cases"
echo " where the improvement is more pronounced. Note that the"
echo " target configuration must be Zen-based (or 'amd64') for"
echo " this option to have any effect. (Also note that this"
echo " option is NOT to be confused with enabling AMD *kernels*,"
echo " which are determined by the BLIS subconfiguration used at"
echo " runtime.) By default, these customized files are disabled."
echo " "
echo " -a NAME --enable-addon=NAME"
echo " "
echo " Enable the code provided by an addon. An addon consists"
echo " of a separate directory of code that provides additional"
echo " APIs, implementations, and/or operations that would"
echo " otherwise not be present within a build of BLIS. This"
echo " option may be used multiple times to specify the inclusion"
echo " of multiple addons. By default, no addons are enabled."
echo " "
echo " -s NAME --enable-sandbox=NAME"
echo " "
echo " Enable a separate sandbox implementation of gemm. This"
echo " option disables BLIS's conventional gemm implementation"
echo " (which shares common infrastructure with other level-3"
echo " operations) and instead compiles and uses the code in"
echo " the NAME directory, which is expected to be a sub-"
echo " directory of 'sandbox'. By default, no sandboxes are"
echo " enabled."
echo " "
echo " --with-memkind, --without-memkind"
echo " "
echo " Forcibly enable or disable the use of libmemkind's"
echo " hbw_malloc() and hbw_free() as substitutes for malloc()"
echo " and free(), respectively, when allocating memory for"
echo " BLIS's memory pools, which are used to manage buffers"
echo " into which matrices are packed. The default behavior"
echo " for this option is environment-dependent; if configure"
echo " detects the presence of libmemkind, libmemkind is used"
echo " by default, and otherwise it is not used by default."
echo " "
echo " -r METHOD, --thread-part-jrir=METHOD"
echo " "
echo " Select a strategy for partitioning computation in JR and"
echo " IR loops and assigning that computation to threads. Valid"
echo " values for METHOD are 'rr', 'slab', and 'tlb':"
echo " 'rr': Assign the computation associated with whole"
echo " columns of microtiles to threads in a round-"
echo " robin fashion. When selected, round-robin"
echo " assignment is also employed during packing."
echo " 'slab': Partition the computation into N contiguous"
echo " regions, where each region contains a whole"
echo " number of microtile columns, and assign one"
echo " region to each thread. For some operations, the"
echo " number of microtile columns contained within a"
echo " given region may differ from that of other"
echo " regions, depending on how much work is implied"
echo " by each region. When selected, slab assignment"
echo " is also employed during packing."
echo " 'tlb': Tile-level load balancing is similar to slab,"
echo " except that regions will be divided at a more"
echo " granular level (individual microtiles instead"
echo " of whole columns of microtiles) to ensure more"
echo " equitable assignment of work to threads. When"
echo " selected, tlb will only be employed for level-3"
echo " operations except trsm; due to practical and"
echo " algorithmic limitations, slab partitioning will"
echo " be used instead during packing and for trsm."
echo " The default strategy is 'slab'. NOTE: Specifying this"
echo " option constitutes a request, which may be ignored in"
echo " select situations if implementation has a good reason to"
echo " do so. (See description of 'tlb' above for an example of"
echo " this.)"
echo " "
echo " --disable-trsm-preinversion, --enable-trsm-preinversion"
echo " "
echo " Disable (enabled by default) pre-inversion of triangular"
echo " matrix diagonals when performing trsm. When pre-inversion"
echo " is enabled, diagonal elements are inverted outside of the"
echo " microkernel (e.g. during packing) so that the microkernel"
echo " can use multiply instructions. When disabled, division"
echo " instructions are used within the microkernel. Executing"
echo " these division instructions within the microkernel will"
echo " incur a performance penalty, but numerical robustness will"
echo " improve for certain cases involving denormal numbers that"
echo " would otherwise result in overflow in the pre-inverted"
echo " values."
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 " --complex-return=gnu|intel"
echo " "
echo " Specify the way in which complex numbers are returned"
echo " from Fortran functions, either \"gnu\" (return in"
echo " registers) or \"intel\" (return via hidden argument)."
echo " If not specified and the environment variable FC is set,"
echo " attempt to determine the return type from the compiler."
echo " Otherwise, the default is \"gnu\"."
echo " "
echo " -q, --quiet Suppress informational output. By default, configure"
echo " is verbose. (NOTE: -q is not yet implemented)"
echo " "
echo " -h, --help Output this information and quit."
echo " "
echo " Environment Variables:"
echo " "
echo " CC Specifies the C compiler to use."
echo " CXX Specifies the C++ compiler to use (sandbox only)."
echo " FC Specifies the Fortran compiler to use (only to determine --complex-return)."
echo " AR Specifies the static library archiver to use."
echo " RANLIB Specifies the ranlib (library indexer) executable to use."
echo " PYTHON Specifies the python interpreter to use."
echo " CFLAGS Specifies additional compiler flags to use (prepended)."
echo " LDFLAGS Specifies additional linker flags to use (prepended)."
echo " LIBPTHREAD Pthreads library to use."
echo " "
echo " Environment variables are traditionally set prior to running configure:"
echo " "
echo " CC=gcc ./configure [options] haswell"
echo " "
echo " However, they may also be specified as command line options, e.g.:"
echo " "
echo " ./configure [options] CC=gcc haswell"
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()
{
local arr key var_name
arr="$1"
key="$2"
var_name="${arr}_${key}"
echo "${!var_name}"
}
assign_key_value()
{
local arr key val
arr="$1"
key="$2"
val="$3"
printf -v "${arr}_${key}" %s "${val}"
}
#
# FGVZ: This commented-out function is being kept as an example how how
# to effectively "pass by reference" in bash. That is, pass the name of
# a variable, instead of its conents, and then let the function use the
# variable by prepending a $, at which time it can evaluate the string
# as if it were a literal variable occurance.
#
#filteradd_to_list()
#{
# local dlist ditem list_c item_c is_blacklisted
#
# # Add $1 to the list identified by $2, but only if $1 is not
# # found in a blacklist.
#
# # Note: $2 can actually be a list of items.
# ditem=\$"$1"
# dlist=\$"$2"
#
# # Acquire the contents of $dlist and $ditem and store them in list_c
# # and item_c, respectively.
# list_c=$(eval "expr \"$dlist\" ")
# item_c=$(eval "expr \"$ditem\" ")
#
# # Iterate over $item_c in case it is actually multiple items.
# for cur_item in $item_c; do
#
# is_blacklisted=$(is_in_list "${cur_item}" "${config_blist}")
# if [ ${is_blacklisted} == "false" ]; then
#
# # If cur_item is not blacklisted, add it to list_c.
# list_c="${list_c} ${cur_item}"
# fi
# done
#
# # Update the argument.
# eval "$2=\"${list_c}\""
#}
pass_config_kernel_registries()
{
local filename passnum
local all_blist
local curline list item config kernels
local cname clist klist
# Read function arguments:
# first argument: the file containing the configuration registry.
# second argument: the pass number: 0 or 1. Pass 0 builds the
# indirect config blacklist (indirect_blist) ONLY. Pass 1 actually
# begins populating the config and kernel registries, and assumes
# the indirect_blist has already been created.
filename="$1"
passnum="$2"
# Initialize a list of indirect blacklisted configurations for the
# current iteration. These are configurations that are invalidated by
# the removal of blacklisted configurations. For example, if haswell
# is registered as needing the 'haswell' and 'zen' kernel sets:
#
# haswell: haswell/haswell/zen
#
# and 'zen' was blacklisted because of the compiler version, then the
# 'haswell' configuration must be omitted from the registry, as it no
# longer has all of the kernel sets it was expecting.
if [ "${passnum}" == "0" ]; then
indirect_blist=""
fi
# For convenience, merge the original and indirect blacklists.
# NOTE: During pass 0, all_blist is equal to config_blist, since
# indirect_blist is still empty.
all_blist="${config_blist} ${indirect_blist}"
# Disable support for indirect blacklisting by returning early during
# pass 0. See issue #214 for details [1]. Basically, I realized that
# indirect blacklisting is not needed in the use case that I envisioned
# in the real-life example above. If a subconfiguration such as haswell
# is defined to require the zen kernel set, it implies that the zen
# kernels can be compiled with haswell compiler flags. That is, just
# because the zen subconfig (and its compiler flags) is blacklisted
# does not mean that the haswell subconfig cannot compile the zen
# kernels with haswell-specific flags.
#
# [1] https://github.com/flame/blis/issues/214
#
if [ "${passnum}" == "0" ]; then
return
fi
while read -r line
do
curline="${line}"
# 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}")
# Next, we prepare to:
# - pass 0: inspect klist for blacklisted configurations, which may
# reveal configurations as needing to be indirectly blacklisted.
# - pass 1: compare cname to the blacklists and commit clist/klist
# to their respective registries, as appropriate.
# Handle singleton and umbrella configuration entries separately.
if [ $(is_singleton_family "${cname}" "${clist}") == "true" ]; then
# Singleton configurations/families.
# Note: for singleton families, clist contains one item, which
# always equals cname, but klist could contain more than one
# item.
# Only consider updating the indirect blacklist (pass 0) or
# committing clist and klist to the registries (pass 1) if the
# configuration name (cname) is not blacklisted.
if [ $(is_in_list "${cname}" "${all_blist}") == "false" ]; then
if [ "${passnum}" == "0" ]; then
# Even if the cname isn't blacklisted, one of the requisite
# kernels might be, so we need to check klist for blacklisted
# items. If we find one, we must assume that the entire entry
# must be thrown out. (Ideally, we would simply fall back to
# reference code for the blacklisted kernels, but that is not
# at all straightforward under the current configuration
# system architecture.) Thus, we add cname to the indirect
# blacklist.
for item in ${klist}; do
if [ $(is_in_list "${item}" "${config_blist}") == "true" ]; then
indirect_blist="${indirect_blist} ${cname}"
break
fi
done
fi
if [ "${passnum}" == "1" ]; then
# Store the clist to the cname key of the config registry.
#config_registry[${cname}]=${clist}
#printf -v "config_registry_${cname}" %s "${clist}"
assign_key_value "config_registry" "${cname}" "${clist}"
fi
fi
if [ "${passnum}" == "1" ]; then
# Store the klist to the cname key of the kernel registry.
#kernel_registry[${cname}]=${klist}
#printf -v "kernel_registry_${cname}" %s "${klist}"
assign_key_value "kernel_registry" "${cname}" "${klist}"
fi
else
# Umbrella configurations/families.
# First we check cname, which should generally not be blacklisted
# for umbrella families, but we check anyway just to be safe.
if [ $(is_in_list "${cname}" "${all_blist}") == "false" ]; then
if [ "${passnum}" == "1" ]; then
# Check each item in the clist and klist. (At this point,
# clist == klist.) If any sub-config is blacklisted, we
# omit it from clist and klist.
for item in ${clist}; do
if [ $(is_in_list "${item}" "${all_blist}") == "true" ]; then
clist=$(remove_from_list "${item}" "${clist}")
klist=$(remove_from_list "${item}" "${klist}")
fi
done
# Store the config and kernel lists to entries 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}"
assign_key_value "config_registry" "${cname}" "${clist}"
assign_key_value "kernel_registry" "${cname}" "${klist}"
fi
fi
fi
done < "${filename}"
if [ "${passnum}" == "0" ]; then
# Assign the final indirect blacklist (with whitespace removed).
indirect_blist="$(canonicalize_ws ${indirect_blist})"
fi
}
read_registry_file()
{
local filename
local clist klist
local iterate_again config
local cr_var mem mems_mem newclist
local kr_var ker kers_ker newklist
filename="$1"
# Execute an initial pass through the config_registry file so that
# we can accumulate a list of indirectly blacklisted configurations,
# if any.
pass_config_kernel_registries "${filename}" "0"
# Now that the indirect_blist has been created, make a second pass
# through the 'config_registry' file, this time creating the actual
# config and kernel registry data structures.
pass_config_kernel_registries "${filename}" "1"
# Now we must go back through the config_registry and subsitute any
# configuration families with their constituents' members. Each time
# one of these substitutions occurs, we set a flag that causes us to
# make one more pass. (Subsituting a singleton definition does not
# prompt additional iterations.) This process stops when a full pass
# does not result in any subsitution.
iterate_again="1"
while [ "${iterate_again}" == "1" ]; do
iterate_again="0"
#for config in "${!config_registry[@]}"; do
for cr_var in ${!config_registry_*}; do
config=${cr_var##config_registry_}
clist=$(query_array "config_registry" ${config})
# The entries that define singleton families should never need
# any substitution.
if [ $(is_singleton_family "${config}" "${clist}") == "true" ]; then
continue
fi
#for mem in ${config_registry[$config]}; do
#for mem in ${!cr_var}; do
for mem in ${clist}; do
#mems_mem="${config_registry[${mem}]}"
mems_mem=$(query_array "config_registry" ${mem})
# If mems_mem is empty string, then mem was not found as a key
# in the config list associative array. In that case, we continue
# and will echo an error later in the script.
if [ "${mems_mem}" == "" ]; then
#echo " config for ${mem} is empty string! no entry in config list."
continue;
fi
if [ "${mem}" != "${mems_mem}" ]; then
#clist="${config_registry[$config]}"
clisttmp=$(query_array "config_registry" ${config})
# Replace the current config with its constituent config set,
# canonicalize whitespace, and then remove duplicate config
# set names, if they exist. Finally, update the config registry
# with the new config list.
# NOTE: WE must use substitute_words() rather than a simple sed
# expression because we need to avoid matching partial strings.
# For example, if clist above contains "foo bar barsk" and we use
# sed to substitute "bee boo" as the members of "bar", the
# result would (incorrectly) be "foo bee boo bee boosk",
# which would then get reduced, via rm_duplicate_words(), to
# "foo bee boo boosk".
#newclist=$(echo -e "${clist}" | sed -e "s/${mem}/${mems_mem}/g")
newclist=$(substitute_words "${mem}" "${mems_mem}" "${clisttmp}")
newclist=$(canonicalize_ws "${newclist}")
newclist=$(rm_duplicate_words "${newclist}")
#config_registry[${config}]=${newclist}
#printf -v "config_registry_${config}" %s "${newclist}"
assign_key_value "config_registry" "${config}" "${newclist}"
# Since we performed a substitution and changed the config
# list, mark the iteration flag to continue another round,
# but only if the config (mem) value is NOT present
# in the list of sub-configs. If it is present, then further
# substitution may not necessarily be needed this round.
if [ $(is_in_list "${mem}" "${mems_mem}") == "false" ]; then
iterate_again="1"
fi
fi
done
done
done
# Similar to what we just did for the config_registry, we now iterate
# through the kernel_registry and substitute any configuration families
# in the kernel list (right side of ':') with the members of that
# family's kernel set. This process continues iteratively, as before,
# until all families have been replaced with singleton configurations'
# kernel sets.
iterate_again="1"
while [ "${iterate_again}" == "1" ]; do
iterate_again="0"
#for config in "${!kernel_registry[@]}"; do
for kr_var in ${!kernel_registry_*}; do
config=${kr_var##kernel_registry_}
klist=$(query_array "kernel_registry" ${config})
# The entries that define singleton families should never need
# any substitution. In the kernel registry, we know it's a
# singleton entry when the cname occurs somewhere in the klist.
# (This is slightly different than the same test in the config
# registry, where we test that clist is one word and that
# clist == cname.)
if [ $(is_in_list "${config}" "${klist}") == "true" ]; then
#echo "debug: '${config}' not found in '${klist}'; skipping."
continue
fi
#for ker in ${kernel_registry[$config]}; do
#for ker in ${!kr_var}; do
for ker in ${klist}; 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 registry. While not common, this can happen
# when ker identifies a kernel set that does not correspond to
# any configuration. (Example: armv7a and armv8a kernel sets are
# used by cortexa* configurations, but do not corresond to their
# own configurations.)
if [ "${kers_ker}" == "" ]; then
#echo "debug: ${ker} not found in kernel registry."
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
#klisttmp="${kernel_registry[$config]}"
klisttmp=$(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.
# NOTE: WE must use substitute_words() rather than a simple sed
# expression because we need to avoid matching partial strings.
# For example, if klist above contains "foo bar barsk" and we use
# sed to substitute "bee boo" as the members of "bar", the
# result would (incorrectly) be "foo bee boo bee boosk",
# which would then get reduced, via rm_duplicate_words(), to
# "foo bee boo boosk".
#newklist=$(echo -e "${klisttmp}" | sed -e "s/${ker}/${kers_ker}/g")
newklist=$(substitute_words "${ker}" "${kers_ker}" "${klisttmp}")
newklist=$(canonicalize_ws "${newklist}")
newklist=$(rm_duplicate_words "${newklist}")
#kernel_registry[${config}]=${newklist}
#printf -v "kernel_registry_${config}" %s "${newklist}"
assign_key_value "kernel_registry" "${config}" "${newklist}"
# Since we performed a substitution and changed the kernel
# list, mark the iteration flag to continue another round,
# unless we just substituted using a singleton family
# definition, in which case we don't necessarily need to
# iterate further this round.
if [ $(is_in_list "${ker}" "${kers_ker}") == "false" ]; then
iterate_again="1"
fi
fi
done
done
done
}
substitute_words()
{
local word new_words list newlist
word="$1"
new_words="$2"
list="$3"
for str in ${list}; do
if [ "${str}" == "${word}" ]; then
newlist="${newlist} ${new_words}"
else
newlist="${newlist} ${str}"
fi
done
echo "${newlist}"
}
build_kconfig_registry()
{
local familyname clist config kernels kernel cur_configs newvalue
familyname="$1"
#clist="${config_registry[${familyname}]}"
clist=$(query_array "config_registry" ${familyname})
for config in ${clist}; do
# Look up the kernels for the current sub-configuration.
#kernels="${kernel_registry[${config}]}"
kernels=$(query_array "kernel_registry" ${config})
for kernel in ${kernels}; do
# 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}"
assign_key_value "kconfig_registry" "${kernel}" "${newvalue}"
done
done
}
is_in_list()
{
local word list rval item
word="$1"
list="$2"
rval="false"
for item in ${list}; do
if [ "${item}" == "${word}" ]; then
rval="true"
break
fi
done
echo "${rval}"
}
is_singleton()
{
local list rval count_str item
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}"
}
is_singleton_family()
{
local familyname memberlist rval
familyname="$1"
memberlist="$2"
rval="false"
if [ $(is_singleton "${memberlist}") ]; then
if [ "${memberlist}" == "${familyname}" ]; then