What is Universal?
Universal is a header-only C++ library providing thousands of custom number systems as plug-in replacements of the built-in integer and floating-point types.
With Universal, developing mixed-precision algorithms to maximize performance, improve latency or minimize energy consumption becomes as easy as changing a single line of code.
Quick introduction
The basic use pattern is as simple as:
In summary, parameterize your computational kernel by arithmetic type(s), and dispatch with the type(s) of your choice.
Linear algebra algorithms are key examples of the benefits of parameterization by arithmetic type. They are key computational components in commercial software, such as fraud detection, recommenders, and AI/Deep Learning. Furthermore, they are frequently bottlenecks to application performance. The benefits of increasing accuracy by replacing float with double, or improving computational performance by the inverse have been a well-honed practice. Popular general-purpose linear-algebra runtimes, Eigen and MTL, are parameterized by type and support mixed-precision algorithm design and use. Similarly, modern next-generation computational science and engineering programs, such as AutoDiff and G+Smo, have also been designed for mixed-precision optimization and can thus be immediately extended by Universal.
The benefits of mixed-precision algorithm design used to be limited to float/double/long double trade-offs for high-performance computing (HPC) applications, or short/int/long/fixed-point for digital signal processing (DSP) and instrumentation applications. With the Universal library, mixed-precision optimization can now tailor the precision, dynamic range, and even sampling profile of the arithmetic to the requirements of the application.
We frequently observe a 2-4x improvement by simply reducing the memory bandwidth by using smaller operands, i.e. the generalization of the double to float trick. In the examples that follow we will demonstrate that greater gains are feasible. By selecting a custom number system tailored to the application, orders of magnitude improvements in performance and/or energy efficiency are possible.
Let's get started!
Summary: Universal is a collection of parameterized number systems, for example, integer<24>, fixpnt<12,4>, cfloat<16,5>, posit<8,2>, or lns<5>.
Universal contains type aliases to important arithmetic types introduced by the Deep Learning innovators, such as Google's bfloat16, or Microsoft/NVIDIA's half, a half-precision 16-byte IEEE-style float.
Any of the Universal arithmetic types can be used as direct replacements of the built-in types.
The parameterization of the number systems is organized by total bits, size of exponent field, arithmetic (modulo or saturating), or encoding (signed/unsigned, IEEE, tapered floats, logarithmic, etc.).
The arithmetic types in Universal are bit-accurate encodings and enable algorithmic collaboration of mixed-precision algorithms between general purpose CPUs and custom hardware accelerators.
Last updated