Skip to content

Commit

Permalink
Add check to disable armsve on Apple M1.
Browse files Browse the repository at this point in the history
- (cherry picked from commit c803b03)

Fix auto-detection of firestorm (Apple M1).

- (cherry picked from commit 2dd692b)

Added Discord documentation (#677)

Details:
- Added a docs/Discord.md markdown document that walks the reader
  through creating a Discord account, obtaining the invite link, and
  using the link to join the BLIS Discord server.
- Updated README.md to reference the new Discord.md document in multiple
  places, including via the official Discord logo (used with explicit
  permission from representatives at Discord Inc.).
- (cherry picked from commit 88105db)

Shuffled checked properties in bli_l3_check.c. (#676)

Details:
- Added certain checks for matrix structure to the level-3 operations'
  _check() functions, and slightly reorganized existing checks.
- (cherry picked from commit 23f5b8d)

CREDITS file update.

Details:
- This attribution was intended to go in PR #647.
- (cherry picked from commit 9453e0f)

Reinstate sanity check in bli_pool_finalize. (#671)

Details:
- Added a reinit argument to bli_pool_finalize(). This bool will signal
  whether or not the function is being called from bli_pool_reinit(). If
  it is not being called from _reinit(), we can safely check to confirm
  that .top_index == 0 (i.e., all blocks have been checked in). But if
  it *is* being called from _reinit(), then that check will be skipped
  since one of the predicted use cases for bli_pool_reinit() anticipates
  that some blocks are (probably) checked out when the pool_t is
  reinitialized.
- Updated existing invocations of bli_pool_finalize() to pass in either
  FALSE (from bli_apool_free_block() or bli_pba_finalize_pools()) or
  TRUE (from bli_pool_reinit()) for the new reinit argument.
- (cherry picked from commit 76a23bd)

Fix some bugs in bli_pool.c (#670)

Details:
- Add a check for premature pool exhaustion when checking in blocks via
  bli_pool_checkin_block(). This detects "double-free" and other bad
  conditions that don't necessarily result in a segfault.
- Make sure to copy all block pointers when growing the pool size.
  Previously, checked-out block pointers (which are guaranteed to be set
  to NULL) were not being copied, leading to the presence of
  uninitialized data.
- (cherry picked from commit 63470b4)

Add AddressSanitizer (-fsanitize=address) option. (#669)

Details:
- Added support for AddressSanitizer (ASan), a compiler-integrated
  memory error detector. The option (disabled by default) enables
  compiling and linking with the -fsanitize=address flag supported by
  clang, gcc, and probably others. This flag is employed during
  compilation of all BLIS source files *except* for optimized kernels,
  which are exempted because ASan usually requires an extra register,
  which violates the constraints for many gemm microkernels.
- Minor whitespace, comment, ordering, and configure help text updates.
- (cherry picked from commit 42d0e66)

Add consistent NaN/Inf handling in sumsqv. (#668)

Details:
- Changed sumsqv implementation as follows:
  - If there is a NaN (either real or imaginary), then return a sum of
    NaN and unit scale.
  - Else, if there is an Inf (either real or imaginary), then return a
    sum of +Inf and unit scale.
  - Otherwise behave as normal.
- (cherry picked from commit b861c71)

Parameterized test/3 drivers via command line args. (#667)

Details:
- Rewrote the drivers in test/3, the Makefile, and the runme.sh script
  so that most of the important parameters, including parameter combo,
  datatype, storage combo, induced method, problem size range, dimension
  bindings, number of repeats, and alpha/beta values can be passed in
  via command line arguments. (Previously, most of these parameters were
  hard-coded into the driver source, except a few that were hard-coded
  into the Makefile.) If no argument is given for any particular option,
  it will be assigned a sane default. Either way, the values employed at
  runtime will be printed to stdout before the performance data in a
  section that is commented out with '%' characters (which is used by
  matlab and octave for comments), unless the -q option is given, in
  which case the driver will proceed quietly and output only performance
  data. Each driver also provides extensive help via the -h option, with
  the help text tailored for the operation in question (e.g. gemm, hemm,
  herk, etc.). In this help text, the driver reminds the user which
  implementation it was linked to (e.g. blis, openblas, vendor, eigen).
  Thanks to Jeff Diamond for suggesting this CLI-based reimagining of
  the test/3 drivers.
- In the test/3 drivers: converted cpp macro string constants, as well
  as two string literals (for the opname and pc_str) used in each test
  driver, to global (or static) const char* strings, and replaced the
  use of strncpy() for storing the results of the command line argument
  parsing with pointer copies from the corresponding strings in argv.
  This works because the argv array is guaranteed by the C99 standard
  to persist throughout the life of the program. This new approach uses
  less storage and executes faster. Thanks to Minh Quan Ho for
  recommending this change.
- Renamed the IMP_STR cpp macro that gets defined on the command line,
  via the test/3/Makefile, to IMPL_STR.
- Updated runme.sh to set the problem size ranges for single-threaded
  and multithreaded execution independently from one another, as well as
  on a per-system basis.
- Added a 'quiet' variable to runme.sh that can easily toggle quiet mode
  for the test drivers' output.
- Very minor typecast fix in call to bli_getopt() in bli_utils.c.
- In bli_getopt(), changed the nextchar variable from being a local
  static variable to a field of the getopt_t state struct. (Not sure why
  it was ever declared static to begin with.)
- Other minor changes to bli_getopt() to accommodate the rewritten test
  drivers' command line parsing needs.
- (cherry picked from commit ee81efc)
  • Loading branch information
fgvanzee committed Oct 27, 2023
1 parent 3e727c0 commit 751d0a1
Show file tree
Hide file tree
Showing 27 changed files with 2,464 additions and 922 deletions.
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ but many others have contributed code and feedback, including
Roman Gareev @gareevroman
Richard Goldschmidt @SuperFluffy
Chris Goodyer
Alexander Grund @Flamefire
John Gunnels @jagunnels (IBM, T.J. Watson Research Center)
Ali Emre Gülcü @Lephar
Jeff Hammond @jeffhammond (Intel)
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ showconfig: check-env
@echo "install includedir: $(INSTALL_INCDIR)"
@echo "install sharedir: $(INSTALL_SHAREDIR)"
@echo "debugging status: $(DEBUG_TYPE)"
@echo "enable AddressSanitizer? $(MK_ENABLE_ASAN)"
@echo "enabled threading model(s): $(THREADING_MODEL)"
@echo "enable BLAS API? $(MK_ENABLE_BLAS)"
@echo "enable CBLAS API? $(MK_ENABLE_CBLAS)"
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Build Status](https://api.travis-ci.com/flame/blis.svg?branch=master)](https://app.travis-ci.com/github/flame/blis)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/flame/blis?branch=master&svg=true)](https://ci.appveyor.com/project/shpc/blis/branch/master)

[<img alt="Discord logo" title="Join us on Discord!" height="32px" src="docs/images/discord.svg" />](docs/Discord.md)

Contents
--------

Expand Down Expand Up @@ -97,6 +99,17 @@ all of which are available for free via the [edX platform](http://www.edx.org/).
What's New
----------

* **Join us on Discord!** In 2021, we soft-launched our [Discord](https://discord.com/)
server by privately inviting current and former collaborators, attendees of our BLIS
Retreat, as well as other participants within the BLIS ecosystem. We've been thrilled by
the results thus far, and are happy to announce that our new community is now open to
the broader public! If you'd like to hang out with other BLIS users and developers,
ask a question, discuss future features, or just say hello, please feel free to join us!
We've put together a [step-by-step guide](docs/Discord.md) for creating an account and
joining our cozy enclave. We even have a monthly "BLIS happy hour" event where people
can casually come together for a video chat, Q&A, brainstorm session, or whatever it
happens to unfold into!

* **Addons feature now available!** Have you ever wanted to quickly extend BLIS's
operation support or define new custom BLIS APIs for your application, but were
unsure of how to add your source code to BLIS? Do you want to isolate your custom
Expand Down Expand Up @@ -417,6 +430,9 @@ If/when you have time, we *strongly* encourage you to read the detailed
walkthrough of the build system found in our [Build System](docs/BuildSystem.md)
guide.

If you are still having trouble, you are welcome to [join us on Discord](docs/Discord.md)
for further information and/or assistance.

Example Code
------------

Expand Down Expand Up @@ -500,6 +516,10 @@ empirically measured performance of `gemm` on select hardware architectures
within BLIS and other BLAS libraries when performing matrix problems where one
or two dimensions is exceedingly small.

* **[Discord](docs/Discord.md).** This document describes how to: create an
account on Discord (if you don't already have one); obtain a private invite
link; and use that invite link to join our BLIS server on Discord.

* **[Release Notes](docs/ReleaseNotes.md).** This document tracks a summary of
changes included with each new version of BLIS, along with contributor credits
for key features.
Expand Down Expand Up @@ -610,16 +630,15 @@ has Linux, OSX and Windows binary packages for x86_64.
Discussion
----------

You can keep in touch with developers and other users of the project by joining
one of the following mailing lists:
Most of the active discussions are now happening on our [Discord](https://discord.com/)
server. Users and developers alike are welcome! Please see the
[BLIS Discord guide](docs/Discord.md) for a walkthrough of how to join us.

You can also still stay in touch by using either of the following mailing lists:

* [blis-devel](https://groups.google.com/group/blis-devel): Please join and
post to this mailing list if you are a BLIS developer, or if you are trying
to use BLIS beyond simply linking to it as a BLAS library.
**Note:** Most of the interesting discussions happen here; don't be afraid to
join! If you would like to submit a bug report, or discuss a possible bug,
please consider opening a [new issue](https://github.com/flame/blis/issues) on
github.

* [blis-discuss](https://groups.google.com/group/blis-discuss): Please join and
post to this mailing list if you have general questions or feedback regarding
Expand Down
3 changes: 3 additions & 0 deletions build/config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ LDFLAGS_PRESET := @ldflags_preset@
# The level of debugging info to generate.
DEBUG_TYPE := @debug_type@

# Whether to compile and link the AddressSanitizer library.
MK_ENABLE_ASAN := @enable_asan@

# Whether operating system support was requested via --enable-system.
ENABLE_SYSTEM := @enable_system@

Expand Down
34 changes: 27 additions & 7 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ get-noopt-cxxflags-for = $(strip $(CFLAGS_PRESET) \
get-refinit-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
-DBLIS_CNAME=$(1) \
$(BUILD_ASANFLAGS) \
$(BUILD_CPPFLAGS) \
$(BUILD_SYMFLAGS) \
-DBLIS_IN_REF_KERNEL=1 \
Expand All @@ -129,6 +130,7 @@ get-refkern-cflags-for = $(strip $(call load-var-for,CROPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(COMPSIMDFLAGS) \
-DBLIS_CNAME=$(1) \
$(BUILD_ASANFLAGS) \
$(BUILD_CPPFLAGS) \
$(BUILD_SYMFLAGS) \
-DBLIS_IN_REF_KERNEL=1 \
Expand All @@ -137,12 +139,14 @@ get-refkern-cflags-for = $(strip $(call load-var-for,CROPTFLAGS,$(1)) \

get-config-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(BUILD_ASANFLAGS) \
$(BUILD_CPPFLAGS) \
$(BUILD_SYMFLAGS) \
)

get-frame-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
$(BUILD_ASANFLAGS) \
$(BUILD_CPPFLAGS) \
$(BUILD_SYMFLAGS) \
)
Expand Down Expand Up @@ -201,11 +205,14 @@ get-sandbox-cxxflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
# Define a separate function that will return appropriate flags for use by
# applications that want to use the same basic flags as those used when BLIS
# was compiled. (NOTE: This is the same as the $(get-frame-cflags-for ...)
# function, except that it omits two variables that contain flags exclusively
# for use when BLIS is being compiled/built: BUILD_CPPFLAGS, which contains a
# cpp macro that confirms that BLIS is being built; and BUILD_SYMFLAGS, which
# contains symbol export flags that are only needed when a shared library is
# being compiled/linked.)
# function, except that it omits a few variables that contain flags exclusively
# for use when BLIS is being compiled/built:
# - BUILD_CPPFLAGS, which contains a cpp macro that confirms that BLIS
# is being built;
# - BUILD_SYMFLAGS, which contains symbol export flags that are only
# needed when a shared library is being compiled/linked; and
# - BUILD_ASANFLAGS, which contains a flag that causes the compiler to
# insert instrumentation for memory error detection.
get-user-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
$(call get-noopt-cflags-for,$(1)) \
)
Expand Down Expand Up @@ -563,6 +570,11 @@ ifeq ($(DEBUG_TYPE),sde)
LDFLAGS := $(filter-out $(LIBMEMKIND),$(LDFLAGS))
endif

# If AddressSanitizer is enabled, add the compiler flag to LDFLAGS.
ifeq ($(MK_ENABLE_ASAN),yes)
LDFLAGS += -fsanitize=address
endif

# Specify the shared library's 'soname' field.
# NOTE: The flag for creating shared objects is different for Linux and OS X.
ifeq ($(OS_NAME),Darwin)
Expand Down Expand Up @@ -808,11 +820,19 @@ $(foreach c, $(CONFIG_LIST_FAM), $(eval $(call append-var-for,CXXLANGFLAGS,$(c))
CPPROCFLAGS := -D_POSIX_C_SOURCE=200112L
$(foreach c, $(CONFIG_LIST_FAM), $(eval $(call append-var-for,CPPROCFLAGS,$(c))))

# --- AddressSanitizer flags ---

ifeq ($(MK_ENABLE_ASAN),yes)
BUILD_ASANFLAGS := -fsanitize=address
else
BUILD_ASANFLAGS :=
endif

# --- Threading flags ---

# NOTE: We don't have to explicitly omit -pthread when --disable-system is given
# since that option forces --enable-threading=none, and thus -pthread never gets
# added to begin with.
# since that option forces --enable-threading=single, and thus -pthread never
# gets added to begin with.

CTHREADFLAGS :=

Expand Down
82 changes: 66 additions & 16 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,22 @@ print_usage()
echo " "
echo " --enable-mem-tracing, --disable-mem-tracing"
echo " "
echo " Enable (disable by default) output to stdout that traces"
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"
Expand Down Expand Up @@ -1325,6 +1335,17 @@ blacklistbu_add()
fi
}

blacklistos_add()
{
# Check whether we've already blacklisted the given sub-config so
# we don't output redundant messages.
if [ $(is_in_list "$1" "${config_blist}") == "false" ]; then

echowarn "The operating system does not support building '$1'; adding to blacklist."
config_blist="${config_blist} $1"
fi
}

blacklist_init()
{
config_blist=""
Expand Down Expand Up @@ -1979,6 +2000,13 @@ check_assembler()
fi
}

check_os()
{
if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]]; then
blacklistos_add "armsve"
fi
}

try_assemble()
{
local cc cflags asm_src asm_base asm_bin rval
Expand Down Expand Up @@ -2451,6 +2479,9 @@ main()
debug_type=''
debug_flag=''

# A flag indicating whether AddressSanitizer should be used.
enable_asan='no'

# The system flag.
enable_system='yes'

Expand Down Expand Up @@ -2576,6 +2607,12 @@ main()
disable-debug)
debug_flag=0
;;
enable-asan)
enable_asan='yes'
;;
disable-asan)
enable_asan='no'
;;
enable-verbose-make)
enable_verbose='yes'
;;
Expand Down Expand Up @@ -2867,6 +2904,9 @@ main()
get_binutils_version
check_assembler

# Check if there is any incompatibility due to the operating system.
check_os

# Remove duplicates and whitespace from the blacklist.
blacklist_cleanup

Expand Down Expand Up @@ -3357,6 +3397,20 @@ main()
echo "${script_name}: no preset LDFLAGS detected."
fi

# Check if the verbose make flag was specified.
if [ "x${enable_verbose}" = "xyes" ]; then
echo "${script_name}: enabling verbose make output. (disable with 'make V=0'.)"
else
echo "${script_name}: disabling verbose make output. (enable with 'make V=1'.)"
fi

# Check if the ARG_MAX hack was requested.
if [ "x${enable_arg_max_hack}" = "xyes" ]; then
echo "${script_name}: enabling ARG_MAX hack."
else
echo "${script_name}: disabling ARG_MAX hack."
fi

# Check if the debug flag was specified.
if [ -n "${debug_flag}" ]; then
if [ "x${debug_type}" = "xopt" ]; then
Expand All @@ -3373,29 +3427,24 @@ main()
echo "${script_name}: debug symbols disabled."
fi

# Check if the verbose make flag was specified.
if [ "x${enable_verbose}" = "xyes" ]; then
echo "${script_name}: enabling verbose make output. (disable with 'make V=0'.)"
else
echo "${script_name}: disabling verbose make output. (enable with 'make V=1'.)"
fi

# Check if the ARG_MAX hack was requested.
if [ "x${enable_arg_max_hack}" = "xyes" ]; then
echo "${script_name}: enabling ARG_MAX hack."
# Check if the AddressSanitizer flag was specified.
if [ "x${enable_asan}" = "xyes" ]; then
echo "${script_name}: enabling AddressSanitizer support (except for optimized kernels)."
else
echo "${script_name}: disabling ARG_MAX hack."
enable_asan='no'
echo "${script_name}: AddressSanitizer support disabled."
fi

enable_shared_01=1
# Check if the static lib flag was specified.
if [ "x${enable_static}" = "xyes" -a "x${enable_shared}" = "xyes" ]; then
echo "${script_name}: building BLIS as both static and shared libraries."
enable_shared_01=1
elif [ "x${enable_static}" = "xno" -a "x${enable_shared}" = "xyes" ]; then
echo "${script_name}: building BLIS as a shared library (static library disabled)."
enable_shared_01=1
elif [ "x${enable_static}" = "xyes" -a "x${enable_shared}" = "xno" ]; then
echo "${script_name}: building BLIS as a static library (shared library disabled)."
enable_shared_01=0
elif [ "x${enable_static}" = "xno" -a "x${enable_shared}" = "xyes" ]; then
echo "${script_name}: building BLIS as a shared library (static library disabled)."
else
echo "${script_name}: Both static and shared libraries were disabled."
echo "${script_name}: *** Please enable one (or both) to continue."
Expand Down Expand Up @@ -3917,7 +3966,7 @@ main()
# Create a #define for the configuration family (config_name).
uconf=$(echo ${config_name} | tr '[:lower:]' '[:upper:]')
config_name_define="#define BLIS_FAMILY_${uconf}\n"

# Create a list of #defines, one for each configuration in config_list.
config_list_defines=""
for conf in ${config_list}; do
Expand Down Expand Up @@ -4012,6 +4061,7 @@ main()
| sed -e "s/@libpthread@/${libpthread_esc}/g" \
| sed -e "s/@cflags_preset@/${cflags_preset_esc}/g" \
| sed -e "s/@ldflags_preset@/${ldflags_preset_esc}/g" \
| sed -e "s/@enable_asan@/${enable_asan}/g" \
| sed -e "s/@debug_type@/${debug_type}/g" \
| sed -e "s/@enable_system@/${enable_system}/g" \
| sed -e "s/@threading_model@/${threading_model}/g" \
Expand Down

0 comments on commit 751d0a1

Please sign in to comment.