Skip to content

Two Running Modes for H2Pack

Huang, Hua edited this page Aug 14, 2020 · 3 revisions

H2Pack has two different running modes of matrix construction, matrix-vector multiplication, and matrix-matrix multiplication:

  • Ahead-of-time (AOT) mode
  • Just-in-time (JIT) mode

These two modes provide trade-offs between storage, computation, and communication, and can be adaptively used to obtain the optimal performance for different computing platforms and different kernel functions.

Some Mathematics

In an matrix representation of kernel matrix img, there are two components that simply kernel matrix blocks

  • inadmissible dense blocks for adjacent or identical point clusters img in the leaf level
  • intermediate blocks for the low-rank approximation of admissible blocks

where all these kernel blocks can be easily computed using the kernel function and the corresponding point.

How two modes work

In AOT mode, these and are precomputed and stored in memory during img matrix construction. In JIT mode, these blocks are constructed temporarily in img matrix-vector and img matrix-matrix multiplications, and are discarded after usage.

Respective advantages of the two modes

The AOT mode is designed to avoid redundant calculation when the kernel function evaluation is expensive. For example, kernel functions with transcendental arithmetic, e.g., exponential and logarithmic functions, have much higher evaluation cost than those without transcendental arithmetic. In this case, using AOT mode might be more efficient than using JIT mode. On the other hand, the AOT mode needs to fetch the precomputed kernel blocks from memory during multiplications, and thus takes significantly more communication cost than the JIT mode.

The JIT mode is designed to reduce the storage cost of an img matrix representation. The size of all and blocks usually can usually be 10 to 100 times larger than the remaining img matrix components. By not storing and blocks, H2Pack in the JIT mode can handle much larger kernel matrices. In some cases with fast CPUs, the runtime for computing these kernel blocks in the JIT mode can actually be cheaper than the runtime for fethcing these blocks from memory in the AOT mode, leading to a faster multiplication in the JIT mode.

In general, the performance of img matrix-vector and img matrix-matrix multiplications in the AOT/JIT mode depend on:

  • The complexity of kernel function
  • The implementation of kernel function
  • The code optimization ability of compiler
  • The performance of CPU and memory system
Clone this wiki locally