Commit Graph

930 Commits

Author SHA1 Message Date
Devin Matthews
f7df64daf6 Don't use memkind for skx configuration. Fixes #163. 2018-01-07 09:37:25 -06:00
Field G. Van Zee
0b3ca3cfb6 Intelligently select compiler for auto-detection.
Details:
- Rewrote code that selects the compiler for the purposes of compiling
  the auto-detection executable. CC (if specified) is tried first. Then
  gcc. Then clang. The absolute fallback is cc. The previous code was
  sort of broken, and seemed to unintentionally always use gcc.
- Moved various configuration-agnostic flags from config/*/make_defs.mk
  files to common.mk. The new mechanism appends the configuration-
  agnostic flags to the various compiler flag variables initialized in
  make_defs.mk. Flags specific to the sub-configuration are still set
  in make_defs.mk.
- Added -Wno-tautological-compare to CMISCFLAGS when clang is in use.
  Also added the flag to the compiler instantiation during configure-
  time hardware detection (when clang is selected).
- Added some missing (but mostly-optional) quotes to configure script.
2018-01-04 20:51:35 -06:00
Field G. Van Zee
0b9c5127e9 Enabled C99, added stdint.h to auto-detect build.
Details:
- Added "-std=c99" to compiler arguments when building auto-detection
  driver in configure script.
- Added #include <stdint.h> to all three source files needed by auto-
  detection program.
2017-12-23 15:53:44 -06:00
Field G. Van Zee
0ce5e19c31 Reimplemented configure-time hardware detection.
Details:
- Reimplemented the hardware detection functionality invoked when running
  "./configure auto". Previously, a standalone script in build/auto-detect
  that used CPUID was used. However, the script attempted to enumerate all
  models for each microarchitecture supported. The new approach recycles
  the same code used for runtime hardware detection introduced in 2c51356.
  This has two immediate benefits. First, it reduces and consolidates the
  code required to detect microarchitectures via the CPUID instruction.
  Second, it provides an indirect way of testing at configure-time the
  code that is used to detect hardware at runtime. This code is (a) only
  activated when targeting a configuration family (such as intel64 or
  amd64) at configure-time and (b) somewhat difficult to test in
  practice, since it relies on having access to older microarchitectures.
- The above change required placing conditional cpp macro blocks in
  bli_arch.c and bli_cpuid.c which either #include "blis.h" or #include
  a bare-bones set of headers that does not rely on the presence of a
  bli_config.h header. This is needed because bli_config.h has not been
  created yet when configure-time auto-detection takes places.
- Defined a new function in bli_arch.c, bli_arch_string(), which takes
  an arch_t id and returns a pointer to a string that contains the
  lowercase name of the corresponding microarchitecture. This function
  is used by the auto-detection script to printf() the name of the
  sub-configuration corresponding to the detected hardware.
2017-12-23 15:32:03 -06:00
Field G. Van Zee
9804adfd40 Added option to disable pack buffer memory pools.
Details:
- Added a new configure option, --[en|dis]able-packbuf-pools, which will
  enable or disable the use of internal memory pools for managing buffers
  used for packing. When disabled, the function specified by the cpp
  macro BLIS_MALLOC_POOL is called whenever a packing buffer is needed
  (and BLIS_FREE_POOL is called when the buffer is ready to be released,
  usually at the end of a loop). When enabled, which was the status quo
  prior to this commit, a memory pool data structure is created and
  managed to provide threads with packing buffers. The memory pool
  minimizes calls to bli_malloc_pool() (i.e., the wrapper that calls
  BLIS_MALLOC_POOL), but does so through a somewhat more complex
  mechanism that may incur additional overhead in some (but not all)
  situations. The new option defaults to --enable-packbuf-pools.
- Removed the reinitialization of the memory pools from the level-3
  front-ends and replaced it with automatic reinitialization within the
  pool API's implementation. This required an extra argument to
  bli_pool_checkout_block() in the form of a requested size, but hides
  the complexity entirely from BLIS. And since bli_pool_checkout_block()
  is only ever called within a critical section, this change fixes a
  potential race condition in which threads using contexts with different
  cache blocksizes--most likely a heterogeneous environment--can check
  out pool blocks that are too small for the submatrices it wishes to
  pack. Thanks to Nisanth Padinharepatt for reporting this potential
  issue.
- Removed several functions in light of the relocation of pool reinit,
  including bli_membrk_reinit_pools(), bli_memsys_reinit(),
  bli_pool_reinit_if(), and bli_check_requested_block_size_for_pool().
- Updated the testsuite to print whether the memory pools are enabled or
  disabled.
2017-12-21 19:22:57 -06:00
Field G. Van Zee
107801aaae Merge branch 'master' into selfinit 2017-12-18 16:29:28 -06:00
Field G. Van Zee
0084531d3e Updated flatten-headers.py for python3.
Details:
- Modifed flatten-headers.py to work with python 3.x. This mostly
  amounted to removing print statements (which I replaced with calls
  to my_print(), a wrapper to sys.stdout.write()). Thanks to Stefan
  Husmann for pointing out the script's incompatibility with python 3.
- Other minor changes/cleanups.
2017-12-17 18:58:25 -06:00
Field G. Van Zee
90b11b79c3 Modest performance boost to flatten-headers.py.
Details:
- Updated flatten-headers.py to pre-compile the main regular expression
  used to isolate #include directives and the header filenames they
  reference. The compiled regex object is then used over and over on
  each header file in the tree of referenced headers. This appears to
  have provided a 1.7-2x performance increase in the best case.
- Other minor tweaks, such as renaming the main recursive function from
  replace_pass() to flatten_header().
2017-12-17 17:34:32 -06:00
Field G. Van Zee
99dee87f30 Reimplemented flatten-headers.sh in python.
Details:
- Added flatten-headers.py, a python implementation of the bash script
  flatten-headers.sh. The new script appears to be 25-100x faster,
  depending on the operating system, filesystem, etc. The python script
  abides by the same command line interface as its predecessor and
  targets python 2.7 or later. (Thanks to Devin Matthews for suggesting
  that I look into a python replacement for higher performance.)
- Activated use of flatten-headers.py in common.mk via the FLATTEN_H
  variable.
- Made minor tweaks to flatten-headers.sh such as spelling corrections
  in comments.
2017-12-17 16:47:27 -06:00
Field G. Van Zee
d9c0574599 Allow travis failures of OS X builds that run testsuite.
Details:
- Added an allowance for OS X builds that run the testsuite to fail.
  There seems to be an issue with 1m when running in Travis CI under
  OS X and clang, but only in double-precision. Haven't been able to
  reproduce the error on my own, and thus, I can't debug it. (Hopefully
  it is simply a version-specific compiler bug.)
2017-12-14 17:13:42 -06:00
Field G. Van Zee
86cd23b737 Fixed testsuite Makefile brokenness from 9091a207.
Details:
- Fixed a makefile error encountered when building the testsuite directly
  in its directory (as opposed to indirectly via 'make test'). The fix
  involves introducing a new variable, BUILD_PATH, alongside the existing
  DIST_PATH variable. By default, BUILD_PATH is set to the current
  directory, and is overridden by other Makefiles used by, for example,
  the testsuite and standalone test drivers in testsuite or test,
  respectively.
- Some files/directories in common.mk were redefined in terms of
  BUILD_DIR, such as the locations of config.mk file and the intermediate
  include directory.
2017-12-14 15:47:41 -06:00
Field G. Van Zee
6a3a8924c0 Temporarily show Makefile's testsuite output.
Details:
- Disabled redirection of testsuite output for 'test' target. This is
  part of an attempt to debug a segmentation fault on OS X via Travis.
2017-12-14 13:20:02 -06:00
Field G. Van Zee
9a01080dd4 Merge branch 'master' into selfinit 2017-12-14 11:27:19 -06:00
Field G. Van Zee
a32e8a47c0 Added an exclusion to .travis.yml.
Details:
- Added exclusion for out-of-tree builds on OS X (clang).
2017-12-13 16:31:36 -06:00
Field G. Van Zee
b9f7d987df Cleaned up after previous travis oot debugging.
Details:
- Removed debugging output from common.mk related to Travis CI
  out-of-tree builds.
- Other minor cleanups to common.mk.
2017-12-13 16:22:09 -06:00
Field G. Van Zee
9091a207aa Attempted fix to travis oot build failure.
Details:
- Found the likely cause of the Travis CI out-of-tree build failures:
  config.mk was being read from DIST_PATH, rather than the current
  directory.
2017-12-13 16:12:34 -06:00
Field G. Van Zee
c01c71c33e Added debugging output to Makefile.
Details:
- Added $(info ...) statements in key locations in an attempt to reveal
  why Travis CI doesn't like building BLIS out-of-tree.
2017-12-13 15:58:50 -06:00
Field G. Van Zee
784289d69d Updated SHELL in common.mk from /bin/bash to bash. 2017-12-13 15:31:27 -06:00
Field G. Van Zee
d9bb1d1d4e Defined SHELL in common.mk so "echo -n" works.
Details:
- Defined the SHELL variable in common.mk as "/bin/bash" so that the
  -n option can be used with echo in the Makefile rule for flattening
  blis.h. Thanks to Devin Matthews for suggesting this fix.
2017-12-13 15:27:54 -06:00
Field G. Van Zee
9289a08667 Attempt 3 on .travis.yml. 2017-12-13 15:14:27 -06:00
Field G. Van Zee
720bfcf0ef More fixes to .travis.yml.
Details:
- Fixed a mistake (hopefully) in d0c4dd0 that resulted in many more
  osx/clang sub-tests than intended.
- Shortened the variable names in an effort to make them more readable
  via the Travis CI web interface.
2017-12-13 14:52:28 -06:00
Field G. Van Zee
8717c9c97f Added 'pwd' commands to .travis.yml for debugging.
Details:
- Added 'pwd' commands to the script portion of the .travis.yml file in
  an attempt to uncover the problem with the recent out-of-tree build
  testing changes made in d0c4dd0.
2017-12-13 14:36:37 -06:00
Field G. Van Zee
83316485ce Simplified/fixed self-initialization.
Details:
- Fixed a race condition in self-initialization whereby the bli_is_init
  static variable could be erroneously read as TRUE by thread 1 while
  thread 0 is still executing bli_init_apis(), thus allowing thread 1 to
  use the library before it is actually ready. Thanks to to Minh Quan Ho
  and Devin Matthews for pointing out this issue.
- Part of the solution to the aforementioned race condition was involved
  replacing the runtime initialization of the global scalar constants
  (e.g., BLIS_ONE, BLIS_ZERO, etc.) in bli_const.c with a static
  initialization of those same constants. This eliminates the need for
  bli_const_init() altogether. (The static initialization is made concise
  via preprocess macros.)
- Defined bli_gks_query_cntx_noinit(), which behaves just like
  bli_gks_query_cntx(), except that it does not call bli_init_once(). This
  function is called in lieu of bli_gks_query_cntx() in bli_ind_init() and
  bli_memsys_init() so as to not result in any recursion into
  bli_init_once().
- Removed BLIS_ONE_HALF, BLIS_MINUS_ONE_HALF global scalar constants.
  They have no use in BLIS or its test products, and we have little reason
  to believe they are used by others.
- Removed testsuite/out file, which was accidentally committed as part
  of 70640a3.
2017-12-13 14:14:50 -06:00
Field G. Van Zee
6526d1d4ae Added temp_dir argument to flatten-headers.sh.
Details:
- Added "temp_dir" argument to flatten-headers.sh so that the caller can
  specify where intermediate files should be created as the script runs.
- Updated flatten-headers.sh to create intermediate files in temp_dir
  instead of alongside the corresponding source files. This should now
  (once again) allow out-of-tree builds where the BLIS distribution is
  read-only, or where the out-of-tree build is running concurrently with
  another out-of-tree build. (Thanks to Devin Matthews for pointing out
  the possibility of simultaneous out-of-tree builds.)
2017-12-12 13:50:43 -06:00
Field G. Van Zee
94755017c9 Merge branch 'master' of github.com:flame/blis 2017-12-12 12:50:41 -06:00
Field G. Van Zee
d0c4dd000f Added out-of-tree build test to .travis.yml file.
Details:
- Modified .travis.yml file to include an out-of-tree build test (using
  the "auto" configure target). Thanks to Devin Matthews for this
  suggestion.
2017-12-12 12:47:53 -06:00
Devin Matthews
5cf7b0c4e5 Ignore blis.h.interm [ci skip] 2017-12-12 12:38:48 -06:00
Field G. Van Zee
8d8ff74d15 Further attempt to fix out-of-tree builds.
Details:
- Fix applied in 87978f6 was necessary but not sufficient to fix
  out-of-tree builds. It turns out that using a source tree that had
  already built the target erroneously gave the impression that
  out-of-tree builds were working again, when in fact they were still
  broken. The additional changes in this commit should complete the
  fix that was started in the aforementioned commit. Thanks to Devin
  Matthews and Shaden Smith for their help in isolating this issue.
2017-12-12 12:32:50 -06:00
Field G. Van Zee
70640a3710 Implemented library self-initialization.
Details:
- Defined two new functions in bli_init.c: bli_init_once() and
  bli_finalize_once(). Each is implemented with pthread_once(), which
  guarantees that, among the threads that pass in the same pthread_once_t
  data structure, exactly one thread will execute a user-defined function.
  (Thus, there is now a runtime dependency against libpthread even when
  multithreading is not enabled at configure-time.)
- Added calls to bli_init_once() to top-level user APIs for all
  computational operations as well as many other functions in BLIS to
  all but guarantee that BLIS will self-initialize through the normal
  use of its functions.
- Rewrote and simplified bli_init() and bli_finalize() and related
  functions.
- Added -lpthread to LDFLAGS in common.mk.
- Modified the bli_init_auto()/_finalize_auto() functions used by the
  BLAS compatibility layer to take and return no arguments. (The
  previous API that tracked whether BLIS was initialized, and then
  only finalized if it was initialized in the same function, was too
  cute by half and borderline useless because by default BLIS stays
  initialized when auto-initialized via the compatibility layer.)
- Removed static variables that track initialization of the sub-APIs in
  bli_const.c, bli_error.c, bli_init.c, bli_memsys.c, bli_thread, and
  bli_ind.c. We don't need to track initialization at the sub-API level,
  especially now that BLIS can self-initialize.
- Added a critical section around the changing of the error checking
  level in bli_error.c.
- Deprecated bli_ind_oper_has_avail() as well as all functions
  bli_<opname>_ind_get_avail(), where <opname> is a level-3 operation
  name. These functions had no use cases within BLIS and likely none
  outside of BLIS.
- Commented out calls to bli_init() and bli_finalize() in testsuite's
  main() function, and likewise for standalone test drivers in 'test'
  directory, so that self-initialization is exercised by default.
2017-12-11 17:18:43 -06:00
Field G. Van Zee
70a64432ee Fixed off-by-one indexing in bli_cpuid.c.
Details:
- In bli_cpuid.c, fixed an off-by-one indexing statement in vpu_count()
  whereby a string-terminating NULL character, '\0', is written beyond
  the bounds of the model_num string.
- Minor whitespace and formatting edits to bli_cpuid.c.
2017-12-11 13:14:20 -06:00
Field G. Van Zee
87978f6261 Fixed broken out-of-tree builds since 52f9e6f.
Details:
- Added missing $(DIST_PATH)/ prefix to relative path to flatten-headers.sh
  script in common.mk so that the script could be found during out-of-tree
  builds. Thanks to Devin Matthews for reporting this bug.
2017-12-11 12:49:03 -06:00
Field G. Van Zee
513ef4d040 Various typecasting fixes, mis-typed enums, etc.
Details:
- Fixed implicit typecasting of conj_t to trans_t in bli_[un]packm_cxk.c.
- Properly typecast integer arguments to match format specifier in various
  calls to printf() in bli_l3_thrinfo.c, bli_cntx.c, bli_pool.c, and
  bli_util_oapi.c.
- Fixed "unsigned less-than-comparison with zero" checks in bli_check.c,
  bli_cntx.h.
- Fixed mis-typed enums in bli_cntx.c (e.g., l1mkr_t that should have been
  l1fkr_t or l1vkr_t).
- Fixed instances of opid_t value BLIS_GEMM that should have been l3ukr_t
  value BLIS_GEMM_UKR in bli_cntx_ref.c.
- NOTE: These issues were identified via compiler warnings when building
  BLIS with clang on a rather old installation of OS X:
    $ clang --version
    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
    Target: x86_64-apple-darwin15.2.0
    Thread model: posix
2017-12-11 12:35:59 -06:00
Field G. Van Zee
b150870397 Removed most "old" directories.
Details:
- Removed the vast majority of directories named "old", which contained
  deprecated code that I wasn't quite ready to jettison from the source
  tree.
2017-12-08 16:08:41 -06:00
Field G. Van Zee
270c65985d Modified bli_getopt() for thread-safety.
Details:
- Changed the interface of bli_getopt() to take a new argument, a getopt_t
  struct, that stores the values of optarg, optind, opterr, and optopt,
  and updated the implementation accordingly. (Previously,  these
  variables were assumed to be global.)
- Added a function for initializing a getopt_t struct.
- Changed test_libblis.c--currently the only consumer of bli_getopt()--to
  utilize the new getopt_t state object.
2017-12-08 15:21:18 -06:00
Field G. Van Zee
ce4d8fabc2 Merge branch 'master' of github.com:flame/blis 2017-12-07 17:36:44 -06:00
Field G. Van Zee
39be59f2a8 Replaced several macros with static function APIs.
Details:
- Reimplemented several sets of get/set-style preprocessor macros with
  static functions, including those in the following frame/base headers:
  auxinfo, cntl, mbool, mem, membrk, opid, and pool. A few headers in
  frame/thread were touched as well: mutex_*, thrcomm, and thrinfo.
2017-12-07 17:35:20 -06:00
dnp
e05a8dfa7c Merge branch 'rt' 2017-12-06 16:45:24 -06:00
dnp
4423e33dc5 Adding SKX kernels and configuration. 2017-12-06 16:35:03 -06:00
Field G. Van Zee
79507337e1 Various checks to ensure that arch_t id is in range.
Details:
- Expanded checking of the arch_t id in bli_gks.c--either passed in from
  the caller or as returned from bli_arch_query_id()--against the expected
  range of id values. Thanks to Devangi Parikh for suggesting these
  additional sanity checks.
2017-12-06 16:21:35 -06:00
Field G. Van Zee
fde7c1126c Added 'uninstall-old-headers' target to Makefile.
Details:
- Defined a new 'uninstall-old-headers' target that allows users of BLIS to
  uninstall no-longer-needed headers left over from previous installations.
- Fixed the 'uninstall-old' target so that it will install both .a and .so
  libraries.
- Renamed 'uninstall-old' to 'uninstall-old-libs'.
- Added 'uninstall-old' target (different from previous 'uninstall-old'
  target) that combines 'uninstall-old-libs' and 'uninstall-old-headers'.
2017-12-04 16:11:01 -06:00
Field G. Van Zee
d4ee770bde Create/install monolithic cblas.h.
Details:
- When CBLAS is enabled at configure-time, BLIS now creates a monolithic
  cblas.h using the same flatten-header.sh script that was recently
  introduced for creating monolithic blis.h header files. The top-level
  Makefile will also install this cblas.h file into the install prefix
  alongside blis.h when the 'install' target is invoked. The two header
  files are compatible with one another. Regardless whether the user's
  source #includes cblas.h, both blis.h and cblas.h, or just blis.h,
  the user will get the CBLAS function prototypes and enums, as expected.
2017-12-04 14:53:43 -06:00
Field G. Van Zee
52f9e6f1b6 Merge branch 'rt' 2017-12-01 12:28:09 -06:00
Field G. Van Zee
21360dd8e2 Fixed cntx_t packm query when ker_id > _NUM_PACKM_KERS.
Details:
- Fixed a subtle bug in bli_cntx_get_[un]packm_ker_dt() in which the
  function fails to return NULL when passed a kernel id argument that is
  equal to or beyond BLIS_NUM_[UN]PACKM_KERS. Instead, the function was
  attempting to index into the cntx_t's packm kernel array, which resulted
  in undefined behvaior. Thanks to Devangi Parikh for finding this bug.
2017-11-29 14:11:34 -06:00
Field G. Van Zee
244a6f4e66 Fixed POSIX sed non-compliance in flatten-header.sh.
Details:
- Changed GNU usage of 'i' and 'a' sed commands used in flatten-header.sh
  to POSIX-compliant usage that will work on OS X's sed.
2017-11-28 17:48:48 -06:00
Field G. Van Zee
4507862167 Generate/compile with/install monolithic blis.h.
Details:
- Rewrote monolithify-header.sh (and renamed to flatten-header.sh) so that
  headers are inserted recursively. This improves performance by a factor
  of 3-4x.
- Modified configure to create an 'include/<configname>' directory in which
  make can create a monolithic header.
- Modified the top-level Makefile so that a monolithic header is generated
  unconditionally prior to compilation (stored in include/<configname>) and
  so that the single header is installed instead of the 450 or so header
  files that reside throughout the framework source tree.
- Added "include/*/*.h" to .gitignore file.
- Removed some pnacl/emscripten leftovers that I intended to include in
  a1caeba (mostly in testsuite/Makefile).
- Trivial comment changes to frame/include/bli_f2c.h.
2017-11-28 15:16:22 -06:00
Field G. Van Zee
1f30b1301b Added missing framework support for x86_64 family.
Details:
- Added support for the x86_64 configuration family to bli_arch.c and
  bli_arch_config.h. Thanks to Johannes Dieterich for reporting this
  issue.
- Bumped the default value for BLIS_SIMD_NUM_REGISTERS from 16 to 32 and
  the default value for BLIS_SIMD_SIZE from 32 to 64. This will support
  configuration families that include Skylake and newer processors without
  any supported needed in the bli_family_*.h file. The semantics of these
  values have always been "maximum" and not exact values; comments in
  bli_kernel_macro_defs.h and the github wiki have been adjusted
  accordingly.
2017-11-25 16:54:26 -06:00
Field G. Van Zee
9f39806c4e Fixed a bug in e31f0b3/b131b9a.
Details:
- Erroneously placed the "don't overwrite existing blocksize" logic in
  bli_blksz_init*() rather than in bli_cntx_set_blkszs(). It belongs in
  the latter because that function copies blocksizes as-is from the
  blksz_t function argument to the appropriate field in the cntx_t. If
  the blksz_t was previously initialized selectively, based on the sign
  of the blocksize value passed into bli_blksz_init*(), that just leaves
  some fields possibly uninitialized (with garbage values), which
  definitely will not work.
- The aforementioned logic has been moved to bli_cntx_set_blkszs() via
  a new function bli_blksz_copy_if_pos(), which selectively copies only
  the blocksizes that are greater than zero.
2017-11-21 16:03:56 -06:00
Field G. Van Zee
b131b9a025 Updated configs to omit setting some blocksizes.
Details:
- Employ the new semantics of bli_blksz_init*() in e31f0b3 in various
  sub-configurations' bli_cntx_init_*() functions by passing in 0 for
  register and cache blocksizes that correpond to gemm microkernel
  datatypes that were not registered, allowing the default values
  set by the bli_cntx_init_*_ref() function call to remain.
2017-11-21 14:30:26 -06:00
Field G. Van Zee
499a4c002f Merge branch 'rt' of github.com:flame/blis into rt 2017-11-21 14:25:08 -06:00
Field G. Van Zee
e31f0b3e2d Subtle update to bli_blksz_init*() API.
Details:
- Updated the semantics of bli_blksz_init() and bli_blksz_init_ed() so
  that non-positive blocksize values are ignored entirely. This provides
  an easy way to indicate that certain existing values should not be
  touched by the update. Thanks to Devangi Parikh for feedback that led
  to these changes.
2017-11-21 14:21:25 -06:00