Skip to content

Commit

Permalink
Implemented --omit-symbols=LIST configure option. (#823)
Browse files Browse the repository at this point in the history
Details:
- Added a new option to 'configure' that allows the user to specify a
  list of symbols to omit from the library. The format of the option is
  --omit-symbols=LIST where LIST is a comma-separated list of symbol
  names (excluding any trailing underscore). This list is parsed into
  a list of #define directives that causes the relevant parts of BLIS
  to be ignored (or not). As such, the nature of this option is to only
  support omitting symbols which have been pre-identified as potential
  troublemakers when linking BLIS with other libraries such as LAPACK
  or ScaLAPACK. (This list may grow in the future as additional symbols
  are identified.) Note: we leave lsame_() and xerbla_() prototypes 
  enabled even when their respective symbols are omitted from the 
  library.
- Re-implemented the --enable-scalapack-compat configure option to
  utilize the underlying --omit-symbols=LIST infrastructure.
- Implemented an --enable-lapack-compat option, which omits all of the
  known problematic symbols currently supported for omission.
- This commit addresses Issue #816. Thanks to Timo Betcke for bringing
  it to our attention and to Devin Matthews for his advice and for
  his initial implementation of --enable-scalapack-compat (PR #813).
- CREDITS file update.
  • Loading branch information
fgvanzee authored Oct 16, 2024
1 parent b36bc95 commit 827c50b
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 68 deletions.
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ but many others have contributed code, ideas, and feedback, including
Abhishek Bagusetty @abagusetty (Argonne National Laboratory)
Satish Balay @balay (Argonne National Laboratory)
Kihiro Bando @bandokihiro
Timo Betcke @tbetcke (University College London)
Matthew Brett @matthew-brett (University of Birmingham)
Jérémie du Boisberranger @jeremiedbb
Jed Brown @jedbrown (Argonne National Laboratory)
Expand Down
3 changes: 3 additions & 0 deletions build/bli_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
// Enabled kernel sets (kernel_list)
@kernel_list_defines@

// Disabled symbols (symbol_omit_list)
@omit_symbol_list_defines@

#define BLIS_VERSION_STRING "@version@"

#if @enable_system@
Expand Down
143 changes: 130 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,50 @@ print_usage()
library. If the shared library build is disabled, the
static library build must remain enabled.
--omit-symbols=LIST
Omit a custom set of compatibility symbols when building
BLIS. When given, LIST is parsed as a comma-separated
list of symbol names (excluding any trailing underscore).
This option is useful when (1) the user is planning to
link BLIS with another library that provides conflicting
symbols, and (2) the user wishes the symbols in this
other library to prevail at link time without relying on
weak/strong symbol semantics. Note that currently ONLY
the following symbols are supported for omission:
crot zrot lsame
csymv zsymv xerbla
csyr zsyr xerbla_array
csyr2 zsyr2
--enable-lapack-compat, --disable-lapack-compat
Enable strict compatibility with LAPACK. This option
causes BLIS to be built without some routines that we
consider to be BLAS compatibility routines but that
also happen to be provided by LAPACK. This option is
equivalent to using the --omit-symbols=LIST option
where LIST contains the following symbols:
crot zrot lsame
csymv zsymv xerbla
csyr zsyr xerbla_array
csyr2 zsyr2
--enable-scalapack-compat, --disable-scalapack-compat
Enable strict compatibility with ScaLAPACK. This option
causes BLIS to be built without some routines that we
consider to be BLAS compatibility routines but that
also happen to be provided by ScaLAPACK. This option is
equivalent to using the --omit-symbols=LIST option
where LIST contains the following symbols:
csymv zsymv
csyr zsyr
csyr2 zsyr2
--enable-rpath, --disable-rpath
Enable (disabled by default) setting an install_name for
Expand Down Expand Up @@ -303,12 +347,6 @@ print_usage()
which are determined by the BLIS subconfiguration used at
runtime.) By default, these customized files are disabled.
--enable-scalapack-compat, --disable-scalapack-compat
Enable strict compatibility with ScaLAPACK, which may
requiring disabling certain conflicting functionality
available through the BLAS and/or CBLAS interfaces.
-a NAME --enable-addon=NAME
Enable the code provided by an addon. An addon consists
Expand Down Expand Up @@ -3015,10 +3053,14 @@ blis_main()
enable_amd_frame_tweaks='no'
enable_memkind='' # The default memkind value is determined later on.
enable_trsm_preinversion='yes'
enable_lapack_compat='no'
enable_scalapack_compat='no'
force_version='no'
complex_return='default'

# The symbol omission list.
omit_symbol_list=''

# The addon flag and names.
addon_flag=''
addon_list=''
Expand Down Expand Up @@ -3155,6 +3197,10 @@ blis_main()
enable_shared='no'
;;

omit-symbols=*)
omit_symbol_list=${OPTARG#*=}
;;

enable-rpath)
enable_rpath='yes'
;;
Expand Down Expand Up @@ -3272,6 +3318,13 @@ blis_main()
enable_amd_frame_tweaks='no'
;;

enable-lapack-compat)
enable_lapack_compat='yes'
;;
disable-lapack-compat)
enable_lapack_compat='no'
;;

enable-scalapack-compat)
enable_scalapack_compat='yes'
;;
Expand Down Expand Up @@ -3675,6 +3728,54 @@ blis_main()
exit 1
fi

# Check for the LAPACK compatibility option before the option for symbol
# omission since the former can imply/augment the latter.
if [[ ${enable_lapack_compat} = yes ]]; then
echo "${script_name}: LAPACK compatibility is enabled."
enable_lapack_compat_01=1
problematic_symbols="crot,zrot,csymv,zsymv,csyr,zsyr,csyr2,zsyr2,lsame,xerbla,xerbla_array"
omit_symbol_list="${omit_symbol_list},${problematic_symbols}"
else
echo "${script_name}: LAPACK compatibility is disabled."
enable_lapack_compat_01=0
fi

# Check for the ScaLAPACK compatibility option before the option for symbol
# omission since the former can imply/augment the latter.
if [[ ${enable_scalapack_compat} = yes ]]; then
echo "${script_name}: ScaLAPACK compatibility is enabled."
enable_scalapack_compat_01=1
problematic_symbols="csymv,zsymv,csyr,zsyr,csyr2,zsyr2"
omit_symbol_list="${omit_symbol_list},${problematic_symbols}"
else
echo "${script_name}: ScaLAPACK compatibility is disabled."
enable_scalapack_compat_01=0
fi

# Check if we are omitting any symbols.
if [[ ${omit_symbol_list} != "" ]]; then

# Create a list of #defines, one for each symbol the user requested
# that we omit. Note that first we convert the list's commas into
# spaces.

# Start by changing the comma-separated list to a space-separated list.
omit_symbol_list=$(echo "${omit_symbol_list}" | sed -e "s/,/ /g")

# Remove duplicates.
#omit_symbol_list=$(rm_duplicate_words_simple "${omit_symbol_list}")

# Sort the list, removing duplicates (via -u).
omit_symbol_list=$(echo "${omit_symbol_list}" | xargs -n1 | sort -u)

echo "${script_name}: omitting the following symbols from BLIS:"
for omit_symbol_name in ${omit_symbol_list}; do
echo "${script_name}: ${omit_symbol_name}"
done
else
echo "${script_name}: no symbols will be omitted."
fi

# Check if we are building with or without operating system support.
if [[ ${enable_system} = yes ]]; then
echo "${script_name}: enabling operating system support."
Expand Down Expand Up @@ -3947,13 +4048,6 @@ blis_main()
echo "${script_name}: memory tracing output is disabled."
enable_mem_tracing_01=0
fi
if [[ ${enable_scalapack_compat} = yes ]]; then
echo "${script_name}: ScaLAPACK compatibility is enabled."
enable_scalapack_compat_01=1
else
echo "${script_name}: ScaLAPACK compatibility is disabled."
enable_scalapack_compat_01=0
fi
if [[ ${has_memkind} = yes ]]; then
if [[ -z ${enable_memkind} ]]; then
# If no explicit option was given for libmemkind one way or the other,
Expand Down Expand Up @@ -4216,6 +4310,28 @@ blis_main()
addon_list_includes="${addon_list_includes}#include ${addon_header}\n"
done

# Make sure that omit_symbol_list only contains lowercase letters, digits,
# underscores, and commas.
omit_symbol_list_check=$(echo "${omit_symbol_list}" | sed -e "s/[a-z0-9_, ]//g")

if [[ "${omit_symbol_list_check}" != "" ]]; then
echo "${script_name}: --omit-symbol=LIST option contains unexpected characters: ${omit_symbol_list_check}"
exit 1
fi

# Create a list of #defines, one for each symbol the user requested that we
# omit. Note that first we convert the list's commas into spaces.
omit_symbol_list=$(echo "${omit_symbol_list}" | sed -e "s/,/ /g")
for sym in ${omit_symbol_list}; do

# Convert the current config name to uppercase.
sym=$(echo "${sym}" | tr '[:lower:]' '[:upper:]')

# Create a #define and add it to the running list.
omit_define="BLIS_DISABLE_${sym}"
omit_symbol_list_defines="${omit_symbol_list_defines}#define ${omit_define}\n"
done


# -- Determine whether we are performing an out-of-tree build --------------

Expand Down Expand Up @@ -4310,6 +4426,7 @@ blis_main()
add_config_var config_name_define
add_config_var config_list_defines
add_config_var kernel_list_defines
add_config_var omit_symbol_list_defines
add_config_var enable_tls enable_tls_01
add_config_var enable_openmp enable_openmp_01
add_config_var enable_openmp_as_def enable_openmp_as_def_01
Expand Down
12 changes: 7 additions & 5 deletions frame/compat/bla_symv.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ void PASTEF77(ch,blasname) \
}

#ifdef BLIS_ENABLE_BLAS
#ifdef BLIS_ENABLE_SCALAPACK_COMPAT
INSERT_GENTFUNCRO_BLAS( symv, symv )
#else
INSERT_GENTFUNC_BLAS( symv, symv )
GENTFUNC( float, s, symv, symv )
GENTFUNC( double, d, symv, symv )
#ifndef BLIS_DISABLE_CSYMV
GENTFUNC( scomplex, c, symv, symv )
#endif
#ifndef BLIS_DISABLE_ZSYMV
GENTFUNC( dcomplex, z, symv, symv )
#endif
#endif

16 changes: 6 additions & 10 deletions frame/compat/bla_symv.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@
*/

#if 1

//
// Prototype BLAS-to-BLIS interfaces.
//
#undef GENTPROT
#undef GENTPROTRO
#define GENTPROTRO GENTPROT
#define GENTPROT( ftype, ch, blasname ) \
\
BLIS_EXPORT_BLAS void PASTEF77(ch,blasname) \
Expand All @@ -54,12 +50,12 @@ BLIS_EXPORT_BLAS void PASTEF77(ch,blasname) \
);

#ifdef BLIS_ENABLE_BLAS
#ifdef BLIS_ENABLE_SCALAPACK_COMPAT
INSERT_GENTPROTRO_BLAS( symv )
#else
INSERT_GENTPROT_BLAS( symv )
GENTPROT( float, s, symv )
GENTPROT( double, d, symv )
#ifndef BLIS_DISABLE_CSYMV
GENTPROT( scomplex, c, symv )
#endif
#ifndef BLIS_DISABLE_ZSYMV
GENTPROT( dcomplex, z, symv )
#endif

#endif

12 changes: 7 additions & 5 deletions frame/compat/bla_syr.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ void PASTEF77(ch,blasname) \
}

#ifdef BLIS_ENABLE_BLAS
#ifdef BLIS_ENABLE_SCALAPACK_COMPAT
INSERT_GENTFUNCRO_BLAS( syr, syr )
#else
INSERT_GENTFUNC_BLAS( syr, syr )
GENTFUNC( float, s, syr, syr )
GENTFUNC( double, d, syr, syr )
#ifndef BLIS_DISABLE_CSYR
GENTFUNC( scomplex, c, syr, syr )
#endif
#ifndef BLIS_DISABLE_ZSYR
GENTFUNC( dcomplex, z, syr, syr )
#endif
#endif

16 changes: 6 additions & 10 deletions frame/compat/bla_syr.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@
*/

#if 1

//
// Prototype BLAS-to-BLIS interfaces.
//
#undef GENTPROT
#undef GENTPROTRO
#define GENTPROTRO GENTPROT
#define GENTPROT( ftype, ch, blasname ) \
\
BLIS_EXPORT_BLAS void PASTEF77(ch,blasname) \
Expand All @@ -52,12 +48,12 @@ BLIS_EXPORT_BLAS void PASTEF77(ch,blasname) \
);

#ifdef BLIS_ENABLE_BLAS
#ifdef BLIS_ENABLE_SCALAPACK_COMPAT
INSERT_GENTPROTRO_BLAS( syr )
#else
INSERT_GENTPROT_BLAS( syr )
GENTPROT( float, s, syr )
GENTPROT( double, d, syr )
#ifndef BLIS_DISABLE_CSYR
GENTPROT( scomplex, c, syr )
#endif
#ifndef BLIS_DISABLE_ZSYR
GENTPROT( dcomplex, z, syr )
#endif

#endif

14 changes: 7 additions & 7 deletions frame/compat/bla_syr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
// Define BLAS-to-BLIS interfaces.
//
#undef GENTFUNC
#undef GENTFUNCRO
#define GENTFUNCRO GENTFUNC
#define GENTFUNC( ftype, ch, blasname, blisname ) \
\
void PASTEF77(ch,blasname) \
Expand Down Expand Up @@ -111,10 +109,12 @@ void PASTEF77(ch,blasname) \
}

#ifdef BLIS_ENABLE_BLAS
#ifdef BLIS_ENABLE_SCALAPACK_COMPAT
INSERT_GENTFUNCRO_BLAS( syr2, syr2 )
#else
INSERT_GENTFUNC_BLAS( syr2, syr2 )
GENTFUNC( float, s, syr2, syr2 )
GENTFUNC( double, d, syr2, syr2 )
#ifndef BLIS_DISABLE_CSYR2
GENTFUNC( scomplex, c, syr2, syr2 )
#endif
#ifndef BLIS_DISABLE_ZSYR2
GENTFUNC( dcomplex, z, syr2, syr2 )
#endif
#endif

16 changes: 6 additions & 10 deletions frame/compat/bla_syr2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@
*/

#if 1

//
// Prototype BLAS-to-BLIS interfaces.
//
#undef GENTPROT
#undef GENTPROTRO
#define GENTPROTRO GENTPROT
#define GENTPROT( ftype, ch, blasname ) \
\
BLIS_EXPORT_BLAS void PASTEF77(ch,blasname) \
Expand All @@ -53,12 +49,12 @@ BLIS_EXPORT_BLAS void PASTEF77(ch,blasname) \
);

#ifdef BLIS_ENABLE_BLAS
#ifdef BLIS_ENABLE_SCALAPACK_COMPAT
INSERT_GENTPROTRO_BLAS( syr2 )
#else
INSERT_GENTPROT_BLAS( syr2 )
GENTPROT( float, s, syr2 )
GENTPROT( double, d, syr2 )
#ifndef BLIS_DISABLE_CSYR2
GENTPROT( scomplex, c, syr2 )
#endif
#ifndef BLIS_DISABLE_ZSYR2
GENTPROT( dcomplex, z, syr2 )
#endif

#endif

Loading

0 comments on commit 827c50b

Please sign in to comment.