BLIS Framework

repository·master·Indexed 25 days ago

https://github.com/flame/blis

A portable software framework written in ISO C99 for instantiating high-performance BLAS-like dense linear algebra libraries. BLIS isolates computational kernels to enable optimized implementations across diverse architectures and supports multiple interface layers, including a BLAS compatibility layer, a Typed API, and an Object-based API. It features support for mixed-datatype and mixed-precision GEMM, generalized matrix storage formats (row-major, column-major, and general stride), and symmetric multithreading via OpenMP, POSIX threads, or HPX.

Tokens
64.1K
Snippets
142
Records
340
Agent score
80%

What's inside BLIS

  1. Overview of BLIS computational kernels

    master

    BLIS provides high-performance dense linear algebra by isolating a small set of optimized kernels that drive many higher-level operations. This architecture allows developers to achieve high performance across various operation levels (Level-1 through Level-3) by focusing optimization efforts on a limited number of core routines.

    Supported operation groups include:

    • Level-1v: Vector operations (e.g., addv, dotv, scalv).
    • Level-1d: Matrix diagonal element-wise operations (e.g., addd, scald).
    • Level-1m: Matrix element-wise operations (e.g., addm, scalm).
    • Level-1f: Fused vector operations (e.g., axpyf, dotxf).
    • Level-2: Matrix-vector operations (e.g., gemv, syr).
    • Level-3: Matrix-matrix multiplication-like operations (e.g., gemm, trsm).
    • Utility: Miscellaneous operations (e.g., norm1v, randm).
  2. Overview of the BLIS Object API

    master

    The Object API is one of the primary native APIs in BLIS. It abstracts floating-point types and other operand properties within a typedef struct {...} data structure. This contrasts with the Typed API (which uses explicit types) and the BLAS compatibility layer (which mimics Fortran-77 BLAS).

    This API is designed to provide a high-level abstraction for numerical operations, though it is recommended to study the provided example code in the BLIS source distribution for practical application patterns.

  3. Overview of the BLIS framework

    master

    BLIS is a portable software framework for instantiating high-performance BLAS-like dense linear algebra libraries. It is written in ISO C99 and is available under a new/modified/3-clause BSD license. The framework is designed to isolate essential computation kernels, allowing for optimized implementations of intensive operations.

    BLIS provides three primary ways to interact with it:

    1. BLAS compatibility layer: Allows access via traditional BLAS routine calls.
    2. New BLAS-like API: A specialized API designed for the BLIS framework.
    3. Object-based API: A unique API specific to BLIS.

    It is highly portable and can be used to instantiate level-3 BLAS implementations on various architectures, including general-purpose, low-power, and multicore systems.

  4. Understand BLIS configuration types

    master

    BLIS uses two distinct types of configurations to manage hardware support and kernel optimization:

    1. Sub-configurations: Encapsulate all information required to build BLIS for a specific microarchitecture (e.g., haswell). This includes optimized kernels and the specific cache and register blocksizes optimized for that hardware.
    2. Configuration families: A collection of registered sub-configurations or other families (e.g., intel64). Families allow building a library that supports multiple microarchitectures simultaneously, using runtime hardware detection (like CPUID) to select the appropriate configuration.

    Both types are organized as directories of files and must be registered in the config_registry file located in the top-level directory.

  5. Understand BLIS Configuration Families

    master

    BLIS uses configuration families to manage how the library is built for different architectures. There are two types of families:

    1. Singleton families: These are equivalent to a single sub-configuration. When you run the ./configure script, you can target a singleton family to build a specific sub-configuration.
    2. Umbrella families: These are collections of architecturally related sub-configurations. An umbrella family allows you to build a single instance of BLIS that supports multiple configurations, enabling runtime selection (e.g., choosing the correct kernel for a specific x86_64 microarchitecture at runtime).

    Note: An umbrella family name must be unique and different from the names of any of its constituent sub-configurations.

  6. Use the small block allocator (SBA)

    master
    BLIS includes a pool-based small block allocator (SBA) designed to minimize calls to malloc() and free() for small internal data structures (typically around 100 bytes). This helps reduce memory fragmentation and can improve performance. The SBA is thread-safe and is enabled by default via the configure process.
  7. Locate the BLIS testsuite

    master

    The BLIS test suite is located in the testsuite directory within the top-level source distribution. It contains the source code (src), object files (obj), input configuration files (input.*), and a Makefile for compilation.

    $ ls
    CHANGELOG        Makefile   common.mk        examples     sandbox     version
    CONTRIBUTING.md  README.md  config           frame        so_version  windows
    CREDITS          RELEASING  config_registry  kernels      test
    INSTALL          blastest   configure        mpi_test     testsuite
    LICENSE          build      docs             ref_kernels  travis
  8. Understand the BLIS Configuration Registry

    master

    The config_registry file (located at the top-level of the BLIS distribution) is the central authority for declaring sub-configurations and configuration families. It determines what targets are valid for the ./configure command.

    The registry encodes three types of information:

    1. Configuration list: Enumerates available sub-configurations and their membership in umbrella families.
    2. Kernel list: Specifies which kernel sets are required by each sub-configuration/family.
    3. Kernel-to-configuration map: Tracks reverse dependencies (which sub-configurations pull in which kernel sets) to determine which compiler flags to use when building shared kernel sets.
  9. Understand the BLIS plugin file structure

    master

    A generated BLIS plugin follows a specific directory structure. Key files include:

    • bli_plugin_<name>.h: The main header file for the plugin. It should be #included by users of the plugin. It typically contains macros for registration arguments, enumerations for kernel/blocksize IDs, and kernel prototypes.
    • bli_plugin_register.c: Implements the registration function (e.g., bli_plugin_register_<name>). This function must be called by any code using the plugin before utilizing its functionality. It registers kernels, blocksizes, and preferences.
    • config_registry: Maps kernel sets to subconfigurations and configuration families.
    • config/<config>/bli_plugin_init_<config>.c: Initializes the context with kernels or blocksizes optimized for a specific subconfiguration.
    • ref_kernels/: Contains reference kernel implementations.
    • kernels/: Contains architecture-specific optimized kernels (e.g., kernels/zen3/).
    • Makefile & config.mk: Automatically generated build files. Use make and make clean to build the plugin.
  10. Understand BLIS version numbering and branching strategy

    master

    BLIS follows a major.minor versioning scheme:

    • Major Release: Indicated by an increase in the major version number. These typically introduce significant new functionality and may include ABI incompatibilities.
    • Release Candidate (rc): Preliminary versions (e.g., 2.0-rc0, 2.0-rc1) distributed for bug discovery before a full major release.
    • Point Release: Indicated by an increase in the minor version number (e.g., 1.1 -> 1.2). These incorporate bugfixes or minor changes since the last major or point release.

    Branching Strategy:

    • All releases and RCs are managed along a linear git branch named for the major release lineage (e.g., r1.x).
    • Commits are both tagged (e.g., 1.0, 1.1) and associated with a non-tip branch (e.g., r1.0, r1.1).
    • New commits should primarily be made on the r1.x lineage branch.
    • Release lineage branches diverge from master starting with the first RC. Most changes on release branches should be cherry-picked from master.
  11. Explore BLIS API types: Object API vs Typed API

    master

    BLIS offers two primary ways to interact with its linear algebra routines:

    • Typed API (BLAS-like): This is the API most users familiar with standard BLAS will prefer. It uses explicit type names for functions.
    • Object API: This API abstracts away the properties of vectors and matrices using obj_t structs. Properties are accessed via accessor functions. Many developers and experts prefer this API for its abstraction capabilities.

    Detailed references for both can be found in docs/BLISTypedAPI.md and docs/BLISObjectAPI.md respectively.