Commit Graph

201 Commits

Author SHA1 Message Date
Francisco Igual
f28a152938 Fixed clobber list bug in ARMv8 ukernel 2018-05-17 09:26:14 +00:00
Field G. Van Zee
2e31dd7852 Inserted missing integer typecasting into ukernels.
Details:
- Inserted missing safeguards into most microkernels to ensure that the
  integers read by the microkernel's assembly instructions are of the
  appropriate size. In many cases, this bug was going undetected likely
  because the compiler was inserting zero padding before the integers
  in the calling function, allowing the assembly code to read 64-bits
  in a way that did not corrupt the "lower" 32 integer bits with garbage
  in the higher bits. Thanks to Francisco Igual and Devangi Parikh for
  finding this issue.
2018-05-16 17:28:33 -05:00
Field G. Van Zee
4b36e85be9 Converted function-like macros to static functions.
Details:
- Converted most C preprocessor macros in bli_param_macro_defs.h and
  bli_obj_macro_defs.h to static functions.
- Reshuffled some functions/macros to bli_misc_macro_defs.h and also
  between bli_param_macro_defs.h and bli_obj_macro_defs.h.
- Changed obj_t-initializing macros in bli_type_defs.h to static
  functions.
- Removed some old references to BLIS_TWO and BLIS_MINUS_TWO from
  bli_constants.h.
- Whitespace changes in select files (four spaces to single tab).
2018-05-08 14:26:30 -05:00
Field G. Van Zee
75d0d1057d Renamed various datatype-related macros/functions.
Details:
- Renamed the following macros in bli_obj_macro_defs.h and
  bli_param_macro_defs.h:
  - bli_obj_datatype()                 -> bli_obj_dt()
  - bli_obj_target_datatype()          -> bli_obj_target_dt()
  - bli_obj_execution_datatype()       -> bli_obj_exec_dt()
  - bli_obj_set_datatype()             -> bli_obj_set_dt()
  - bli_obj_set_target_datatype()      -> bli_obj_set_target_dt()
  - bli_obj_set_execution_datatype()   -> bli_obj_set_exec_dt()
  - bli_obj_datatype_proj_to_real()    -> bli_obj_dt_proj_to_real()
  - bli_obj_datatype_proj_to_complex() -> bli_obj_dt_proj_to_complex()
  - bli_datatype_proj_to_real()        -> bli_dt_proj_to_real()
  - bli_datatype_proj_to_complex()     -> bli_dt_proj_to_complex()
- Renamed the following functions in bli_obj.c:
  - bli_datatype_size()                -> bli_dt_size()
  - bli_datatype_string()              -> bli_dt_string()
  - bli_datatype_union()               -> bli_dt_union()
- Removed a pair of old level-1f penryn intrinsics kernels that were no
  longer in use.
2018-04-30 14:57:33 -05:00
Field G. Van Zee
24b3c3149c Merge branch 'dev' of github.com:flame/blis into dev 2018-04-16 18:49:38 -05:00
Field G. Van Zee
60366a3fab Updates to knl kernels and related code.
Details:
- Imported the 24x16 knl sgemm microkernel (and its corresonding spackm
  kernel) from TBLIS and enabled its use in the knl sub-config. Also
  Added sgemm microkernel prototype to bli_kernels_knl.h.
- Updated dgemm and dpackm microkernels from TBLIS, which included an
  important change regarding the offsets array (changed from extern
  declaration to static declaration/definition).
- Activated use of level-1v and -1f zen kernels in skx and knl
  sub-configs.
- Removed some old macros no longer needed in bli_family_skx.h now that
  libmemkind support exists in configure.
- Moved bli_avx512_macros.h to frame/include and adjusted #includes in
  skx and knl kernels accordingly.
- Moved unused kernels in kernels/knl/3 to kernels/knl/3/other
  directory.
- Fixed a minor bug in the 'make' output per compile when verboseness
  is not turned on. The rule-generating function 'make-kernel-rule' was
  previously passing in the name of the config, rather than the name of
  the kernel set returned by get-config-for-kset, which could give
  misleading information to the user when the kconfig_map mapped a
  kernel set to a sub-configuration that did not share the same name.
  (This didn't affect the CFLAGS that were actually used.)
- Updated test/3m4m/Makefile, removing acml targets and renaming the
  remaining targets.
2018-04-16 18:46:21 -05:00
Field G. Van Zee
67c9c2f86d Retired haswell gemm microkernels.
Details:
- Moved microkernels in kernels/haswell/3 to kernels/haswell/3/old. These
  microkernels were no longer being used and only sowed confusion to
  anyone inspecting the repository without being fully cognizant of the
  build system and how it works (and sometimes even to those who wrote
  the build system). Note that the haswell configuration currently
  employs the zen microkernels.
2018-04-16 14:03:12 -05:00
Field G. Van Zee
78a24e7dad Updated bli_avx512_macros.h in knl and skx configs.
Details:
- Downloaded updated version of bli_avx512_macros.h from TBLIS [1] in
  attempt to address issue #192.
  [1] https://github.com/devinamatthews/tblis/
2018-04-09 17:02:13 -05:00
dnp
ca982148b3 Fixed bug in SKX sgemm microkernel. Modified SKX dgemm mircokernel to be consistent with the sgemm microkernel 2018-04-08 21:27:10 -05:00
dnp
ae9a5be56d Fixed bug in skx sgemm microkernel 2018-03-27 17:01:23 -05:00
Field G. Van Zee
3f02af0905 Row storage optimizations to zen dotxf kernels.
Details:
- Split the main loop bodies of zen's [sd]dotxf kernels into two cases:
  one to handle a column-stored matrix A and one to handle a row-stored
  matrix A. This allows vector instructions to be employed even if A is
  stored by rows (and A^T appears stored as columns). Both storage cases
  use a common edge case loop. Thanks to Devin Matthews for this idea
  and for prototyping the change needed for sdotxf kernel.
2018-03-26 17:40:04 -05:00
Field G. Van Zee
679dcc331d Make k_iter/k_left uint64_t in bulldozer fma ukrs.
Details:
- Changed the declaration of k_iter and k_left for d, c, z microkernels
  from dim_t to uint64_t. This is needed to ensure compatibility with
  the movq instruction used to load the value into registers. This
  change should have been made a long time ago, but for some reason
  only recently began showing up via Travis CI.
2018-03-26 15:35:17 -05:00
Field G. Van Zee
e2192a8fd5 Removed vzeroupper intrinsics from zen kenels.
Details:
- Fixed a bug in the zen (also used by haswell) dotxf kernels whereby a
  vzeroupper instruction destoryed part of the intermediate result
  stored by the vdpps instructions that came right before. (The
  vzeroupper instrinsic was removed.)
- Removed remaining vzeroupper instrinsics from other zen kernels.
  Previously, the vzeroupper instructions were included because BLIS is
  typically compiled with -mfpmath=sse. But it was brought to my
  attention that inserting these vzeroupper instructions is unnecessary
  for our purposes, since (a) -mfpmath=sse results in VEX-encoded scalar
  code rather than literal SSE instructions, and (b) compilers already
  (likely) insert vzeroupper instructions where necessary. Thanks to
  Devin Matthews for zeroing in on the dotxf bug.
- Removed -malign-double from bulldozer make_defs.mk. This alignment
  was already happening by default since bulldozer is an x86_64 system.
2018-03-23 12:53:48 -05:00
Field G. Van Zee
c09fffa827 Added missing cntx_t* arg in knl packm kernels.
Details:
- Added the missing cntx_t* argument to the function signature of packm
  kernels in kernels/knl/1m/. Thanks to Dave Love for reporting this
  issue.
2018-03-03 13:13:39 -06:00
Field G. Van Zee
3defc7265c Applied 34b72a3 to non-active/unused microkernels.
Details:
- Applied the read-beyond-bounds bugfix in 34b72a3 to other haswell and
  zen kernels (ie: other microtile shapes) which are not used by default.
  This was done mostly in case someone decided to pick up these kernels
  and start using them, not because it affects BLIS's behavior
  out-of-the-box.
2018-02-23 17:38:19 -06:00
Field G. Van Zee
34b72a3517 Fixed obscure read-beyond-bounds bug in sgemm ukrs.
Details:
- Fixed an obscure bug in the bli_sgemm_haswell_asm_6x16 and
  bli_sgemm_zen_asm_6x16 microkernels when the input/output matrix C
  is stored with general stride (ie: both rs and cs are non-unit). The
  bug was rooted in the way those microkernels read from matrix C--
  namely, they used vmovlps/vmovhps instead of movss. By loading two
  floats at a time, even if one of them was treated as junk, the
  assembly code could be written in a more concise manner. However,
  under certain conditions--if m % mr == 0 and n % nr == 0 and the
  underlying matrix is not an internal "view" into a larger matrix--
  this could result in the very last vmovhps of the last (bottom-right)
  microkernel invocation reading beyond valid memory. Specifically, the
  low 32 bits read would always be valid, but the high 32 bits could
  reside beyond the bounds of the array in which the output C matrix is
  contained. To remedy this situation, we now selectively use movss to
  load any element that could be the last element in the matrix.
2018-02-23 16:33:32 -06:00
Field G. Van Zee
5112e1859e Added missing 'restrict' to some kernels' cntx_t*.
Details:
- Added missing 'restrict' keyword to cntx_t* argument of function
  signatures corresponding to level-1v, level-1f, and level-1m kernels.
  This affected bli_l1v_ker_prot.h, bli_l1f_ker_prot.h, and
  bli_l1m_ker_prot.h. (The 'restrict' was already being used to
  qualify cntx_t* arguments for kernels defined in bli_l3_ker_prot.h.)
- Added comments to bli_l1v_ker.h, bli_l1f_ker.h, bli_l1m_ker.h, and
  bli_l3_ukr.h that help explain how those headers function to produce
  kernel prototypes using the prototype macros defined in the files
  mentioned above.
2018-02-23 14:31:26 -06:00
Field G. Van Zee
1fa8af95d8 Merge branch 'rt' 2018-02-21 17:54:02 -06:00
Field G. Van Zee
16813335bd Merge branch 'amd' into rt
Details:
- Merged contributions made by AMD via 'amd' branch (see summary below).
  Special thanks to AMD for their contributions to-date, especially with
  regard to intrinsic- and assembly-based kernels.
- Added column storage output cases to microkernels in
  bli_gemm_zen_asm_d6x8.c and bli_gemmtrsm_l_zen_asm_d6x8.c. Even with
  the extra cost of transposing the microtile in registers, this is
  much faster than using the general storage case when the underlying
  matrix is column-stored.
- Added s and d assembly-based zen gemmtrsm_u microkernel (including
  column storage optimization mentioned above).
- Updated zen sub-configuration to reflect presence of new native
  kernels.
- Temporarily reverted zen sub-configuration's level-3 cache blocksizes
  to smaller haswell values.
- Temporarily disabled small matrix handling for zen configuration
  family in config/zen/bli_family_zen.h.
- Updated zen CFLAGS according to changes in 1e4365b.
- Updated haswell microkernels such that:
  - only one vzeroupper instruction is called prior to returning
  - movapd/movupd are used in leiu of movaps/movups for double-real
    microkernels. (Note that single-real microkernels still use
    movaps/movups.)
- Added kernel prototypes to kernels/zen/bli_kernels_zen.h, which is
  now included via frame/include/bli_arch_config.h.
- Minor updates to bli_amaxv_ref.c (and to inlined "test" implementation
  in testsuite/src/test_amaxv.c).
- Added early return for alpha == 0 in bli_dotxv_ref.c.
- Integrated changes from f07b176, including a fix for undefined
  behavior when executing the 1m method under certain conditions.
- Updated config_registry; no longer need haswell kernels for zen
  sub-configuration.
- Tweaked marginal and pass thresholds for dotxf.
- Reformatted level-1v, -1f, and -3 amd kernels and inserted additional
  comments.
- Updated LICENSE file to explicitly mention that parts are copyright
  UT-Austin and AMD.
- Added AMD copyright to header templates in build/templates.

Summary of previous changes from 'amd' branch.
- Added s and d assembly-based zen gemm microkernels (d6x8 and d8x6) and
  s and d assembly-based zen gemmtrsm_l microkernels (d6x8).
- Added s and d intrinsics-based zen kernels for amaxv, axpyv, dotv, dotxv,
  and scalv, with extra-unrolling variants for axpyv and scalv.
- Added a small matrix handler to bli_gemm_front(), with the handler
  implemented in kernels/zen/3/bli_gemm_small_matrix.c.
- Added additional logic to sumsqv that first attempts to compute the
  sum of the squares via dotv(). If there is a floating-point exception
  (FE_OVERFLOW), then the previous (numerically conservative) code is
  used; otherwise, the result of dotv() is square-rooted and stored as
  the result. This new implementation is only enabled when FE_OVERFLOW
  is #defined. If the macro is not #defined, then the previous
  implementation is used.
- Added axpyv and dotv standalone test drivers to test directory.
- Added zen support to old cpuid_x86.c driver in build/auto-detect/old.
- Added thread-local and __attribute__-related macros to bli_macro_defs.h.
2018-02-21 17:43:32 -06:00
Devin Matthews
5d03b6e6e1 Fix asm macro include line for KNL. Fixes #167. 2018-02-19 11:31:30 -06:00
Field G. Van Zee
24e64a9d08 Removed a duplicate bli_avx512_macros.h header.
Details:
- Removed a duplicate header file that was causing problems during
  installation for the 'knl' configuration. Thanks to Victor Eijkhout
  for reporting this issue.
2017-12-11 12:12:29 +05:30
Devin Matthews
537fb2a895 Add vzeroupper to Intel AVX kernels. 2017-12-11 12:12:29 +05:30
sthangar
997628ed97 Reducing the framework overhead of GEMV routines
Change-Id: I83607ad767bff74e305e915b54b0ea34ec3e5684
2017-12-11 12:08:58 +05:30
sthangar
3485abba4b Checked in the small matrix code to compute GEMM called with A transpose case
Change-Id: I29f40046d43d7a4b037c1cb322503ee26495f462
2017-12-11 12:07:31 +05:30
Devin Matthews
de16beb83b PACKDIM_MR=8 didn't work out, but messing with the prefetching helps 2%. 2017-12-11 12:07:31 +05:30
Devin Matthews
25d0e61854 Revert "Change PACKDIM_MR (double) for haswell to 8."
This reverts commit 681eec913d.
2017-12-11 12:07:31 +05:30
Devin Matthews
c5bdd84b35 Change PACKDIM_MR (double) for haswell to 8. 2017-12-11 12:07:31 +05:30
Field G. Van Zee
db4a0bb8ba Whitespace reformatting to armv8a kernels file.
Details:
- Updated formatting of function signature/header in
  kernels/armv8a/3/bli_gemm_opt_4x4.c.
2017-12-11 11:58:33 +05:30
dnp
4423e33dc5 Adding SKX kernels and configuration. 2017-12-06 16:35:03 -06:00
Field G. Van Zee
25eee3cc49 Added a dummy file to kernels/generic.
Details:
- Added a dummy file to kernels/generic, which was previously empty, so
  that git would begin tracking the otherwise-empty directory. This
  directory's existence is necessary for proper execution of configure
  for any configuration family that contains the 'generic'
  sub-configuration. Thanks to Johannes Dieterich for reporting the
  issue that led to this fix.
2017-11-21 12:34:20 -06:00
Field G. Van Zee
2553734d1d Merge branch 'master' into rt 2017-10-18 13:46:50 -05:00
Field G. Van Zee
375342799c Removed a duplicate bli_avx512_macros.h header.
Details:
- Removed a duplicate header file that was causing problems during
  installation for the 'knl' configuration. Thanks to Victor Eijkhout
  for reporting this issue.
2017-10-18 13:41:25 -05:00
Field G. Van Zee
453deb2906 Implemented runtime kernel management.
Details:
- Reworked the build system around a configuration registry file, named
  config_registry', that identifies valid configuration targets, their
  constituent sub-configurations, and the kernel sets that are needed by
  those sub-configurations. The build system now facilitates the building
  of a single library that can contains kernels and cache/register
  blocksizes for multiple configurations (microarchitectures). Reference
  kernels are also built on a per-configuration basis.
- Updated the Makefile to use new variables set by configure via the
  config.mk.in template, such as CONFIG_LIST, KERNEL_LIST, and KCONFIG_MAP,
  in determining which sub-configurations (CONFIG_LIST) and kernel sets
  (KERNEL_LIST) are included in the library, and which make_defs.mk files'
  CFLAGS (KCONFIG_MAP) are used when compiling kernels.
- Reorganized 'kernels' directory into a "flat" structure. Renamed kernel
  functions into a standard format that includes the kernel set name
  (e.g. 'haswell'). Created a "bli_kernels_<kernelset>.h" file in each
  kernels sub-directory. These files exist to provide prototypes for the
  kernels present in those directories.
- Reorganized reference kernels into a top-level 'ref_kernels' directory.
  This directory includes a new source file, bli_cntx_ref.c (compiled on
  a per-configuration basis), that defines the code needed to initialize
  a reference context and a context for induced methods for the
  microarchitecture in question.
- Rewrote make_defs.mk files in each configuration so that the compiler
  variables (e.g. CFLAGS) are "stored" (renamed) on a per-configuration
  basis.
- Modified bli_config.h.in template so that bli_config.h is generated with
  #defines for the config (family) name, the sub-configurations that are
  associated with the family, and the kernel sets needed by those
  sub-configurations.
- Deprecated all kernel-related information in bli_kernel.h and transferred
  what remains to new header files named "bli_arch_<configname>.h", which
  are conditionally #included from a new header bli_arch.h. These files
  are still needed to set library-wide parameters such as custom
  malloc()/free() functions or SIMD alignment values.
- Added bli_cntx_init_<configname>.c files to each configuration directory.
  The files contain a function, named the same as the file, that initializes
  a "native" context for a particular configuration (microarchitecture). The
  idea is that optimized kernels, if available, will be initialized into
  these contexts. Other fields will retain pointers to reference functions,
  which will be compiled on a per-configuration basis. These bli_cntx_init_*()
  functions will be called during the initialization of the global kernel
  structure. They are thought of as initializing for "native" execution, but
  they also form the basis for contexts that use induced methods. These
  functions are prototyped, along with their _ref() and _ind() brethren, by
  prototype-generating macros in bli_arch.h.
- Added a new typedef enum in bli_type_defs.h to define an arch_t, which
  identifies the various sub-configurations.
- Redesigned the global kernel structure (gks) around a 2D array of cntx_t
  structures (pointers to cntx_t, actually). The first dimension is indexed
  over arch_t and the inner dimension is the ind_t (induced method) for
  each microarchitecture. When a microarchitecture (configuration) is
  "registered" at init-time, the inner array for that configuration in the
  2D array is initialized (and allocated, if it hasn't been already). The
  cntx_t slot for BLIS_NAT is initialized immediately and those for other
  induced method types are initialized and cached on-demand, as needed. At
  cntx_t registration, we also store function pointers to cntx_init functions
  that will initialize (a) "reference" contexts and (b) contexts for use with
  induced methods. We don't cache the full contexts for reference contexts
  since they are rarely needed. The functions that initialize these two kinds
  of contexts are generated automatically for each targeted sub-configuration
  from cpp-templatized code at compile-time. Induced method contexts that
  need "stage" adjustments can still obtain them via functions in
  bli_cntx_ind_stage.c.
- Added new functions and functionality to bli_cntx.c, such as for setting
  the level-1f, level-1v, and packm kernels, and for converting a native
  context into one for executing an induced method.
- Moved the checking of register/cache blocksize consistency from being cpp
  macros in bli_kernel_macro_defs.h to being runtime checks defined in
  bli_check.c and called from bli_gks_register_cntx() at the time that the
  global kernel structure's internal context is initialized for a given
  microarchitecture/configuration.
- Deprecated all of the old per-operation bli_*_cntx.c files and removed
  the previous operation-level cntx_t_init()/_finalize() invocations.
  Instead, we now query the gks for a suitable context, usually via
  bli_gks_query_cntx().
- Deprecated support for the 3m2 and 3m3 induced methods. (They required
  hackery that I was no longer willing to support.)
- Consolidated the 1e and 1r packm kernels for any given register blocksize
  into a single kernel that will branch on the schema and support packing
  to both formats.
- Added the cntx_t* argument to all packm kernel signatures.
- Deprecated the local function pointer array in all bli_packm_cxk*.c files
  and instead obtain the packm kernel from the cntx_t.
- Added bli_calloc_intl(), which serves as the calloc-equivalent to to
  bli_malloc_intl(). Useful when we wish to allocate and initialize to
  zero/NULL.
- Converted existing cpp macro functions defined in bli_blksz.h, bli_func.h,
  bli_cntx.h into static functions.
2017-10-18 13:29:32 -05:00
Devin Matthews
7dc78b49f9 Add vzeroupper to Intel AVX kernels. 2017-08-15 10:02:25 -05:00
Devin Matthews
7f41bb0a0b PACKDIM_MR=8 didn't work out, but messing with the prefetching helps 2%. 2017-05-26 14:49:31 -04:00
Devin Matthews
d87614af3f Revert "Change PACKDIM_MR (double) for haswell to 8."
This reverts commit 681eec913d.
2017-05-26 14:47:36 -04:00
Devin Matthews
681eec913d Change PACKDIM_MR (double) for haswell to 8. 2017-05-26 12:28:09 -05:00
sthangar
42e7f6fb2a fixed license attribute issues in AMD added files
Change-Id: I303f870a777c7cd1c1af29ea0b93f3e0a27948e4
2017-03-31 14:33:02 +05:30
Field G. Van Zee
f484c6cd43 Whitespace reformatting to armv8a kernels file.
Details:
- Updated formatting of function signature/header in
  kernels/armv8a/3/bli_gemm_opt_4x4.c.
2017-03-17 12:07:27 -05:00
Kiran Varaganti
0b19029342 Code cleanup, removed warnings from trsm, removed unused routines in axpyv & scalv
Change-Id: I02867f394c5f416194c4b1769a6c75f39243ec81
2017-03-14 14:51:31 +05:30
praveeng
825363bd2a Merge code from master to amd-staging as on 2017_03_08 by praveeng
Change-Id: I80740081b2cb54c9b77a3e78b9fe540e170be23d
2017-03-08 15:43:42 +05:30
sthangar
093bdb80c8 Checked in Unpacked DGEMM code
Change-Id: I39dcc7b238b328f73ee2675d21a5e521d0488723
2017-03-07 13:35:50 +05:30
Kiran Varaganti
33923da9a1 Added variant 10 for double precision axpyv microkernel
Change-Id: I7a20cc113a422603250bc450825c965136354974
2017-03-06 14:31:31 +05:30
Kiran Varaganti
bc828f7f8e Added new axpyv (single precision) microkernel where it performs 10 FMAs per loop- This gives better performance than all other implementations of axpyv
Change-Id: Ic4f0e4c67e367d67d0b24febcf34f81a70a39972
2017-03-03 14:45:35 +05:30
sthangar
c9949f4603 Checked in DGEMMTRSM and edge case handling routine in DDOTXF
Change-Id: I65f00661af6c09b2507294fd43e0a10641c0597e
2017-03-01 11:14:34 +05:30
Devin Matthews
0e18f68cf1 Handle k=0 correctly in KNL dgemm ukernel. 2017-02-20 09:03:21 -06:00
Devin Matthews
7d42fc0796 Cast dim_t and inc_t parameters to 64-bit in KNL microkernels. 2017-02-19 21:10:55 -05:00
Kiran Varaganti
04245c9ff7 Reoptimized scalv routines - two vector multiplies are done per iteration, and these routines are enabled in bli_kernel.h
Change-Id: Ic5654508573d1f6bde2edef06aefe117e581feb5
2017-02-10 14:24:30 +05:30
Kiran Varaganti
58b5b77e5f Fixed a bug in axpyv, the arguments passed to intrinsic fmad instruction are corrected
Change-Id: If12f24c6bc74b22ac9e4acd6b9378e06d79f2f5e
2017-02-08 21:43:34 +05:30
Kiran Varaganti
85de4ebf74 variant 4 axpyv single precision modified: explicitly used FMA intrinsics, replaced vector multiply and add operations
Change-Id: I975feef56696d479d2b9e9441b0660021cf4f6ff
2017-02-08 14:41:04 +05:30