Abstract
In scientific computing, optimal use of computing resources comes at the cost of extensive coding, tuning, and benchmarking. While the classic approach of “features first, performance later” is supported by a variety of tools such as T
1. Introduction
The field of high-performance computing is largely concerned with optimal resource utilization. Since performance depends on the choice of algorithms, parameters, libraries, and even computing environment, maximizing efficiency is a task that comes at the cost of extensive coding, tuning, and benchmarking. Many existing tools—an overview is provided in the following—are designed to assist developers in analyzing existing codes, exposing hot spots, bottlenecks, communication patterns, and other possible causes for low efficiency and/or scalability. To instead support dense linear algebra developers in performance-related decisions right from the early stages of development—even before the actual coding—we propose a rich and flexible environment for rapid algorithm and performance experimentation.
The Experimental Linear Algebra Performance Studies (ELAPS) framework allows users to create “experiments” to explore multiple algorithms and algorithmic variants, to test different parallelization strategies, to compare alternative libraries, to investigate the impact of caching, and to tune algorithmic parameters. Experiments are built by combining one or more constructs commonly encountered in linear algebra computations, and are specified either through Python scripts or a specialized and intuitive Graphical User Interface (GUI). They are then executed either locally or through batch-job systems, on hardware ranging from laptops to accelerators and multi-core nodes of clusters and supercomputers. Finally, their results can be visualized and analyzed interactively in terms of various performance metrics and statistics.
Since its development, ELAPS is used both in classroom and in research, to equally teach and investigate a variety of performance-related characteristics of matrix computations. It has made experimentation considerably faster and more portable, and eliminated the need for debugging of handwritten benchmarks.
In this article, in Section 3, we illustrate the features offered, and in Section 4, briefly present its intuitive and easy-to-use interface, and detail how the framework is realized. In Section 5, by means of four scenarios arising in actual applications, we then show how to construct experiments to efficiently make well-grounded performance-oriented decisions. Finally, we present a productivity study in Section 6, and conclude with a summary and an overview of future developments in Section 7.
2. Related work
In the typical development of scientific software, performance-related issues are tackled only at later stages, once the code already includes most desired features. To optimize the performance of an already existing (portion of) code by detecting hot spots and bottlenecks, many application-level tools, such as Performance Application Programming Interface (PAPI) (Browne et al., 2000), T
In scenarios in which the central performance optimization problem boils down to a search in a large, possibly high-dimensional parameter space, a popular approach is to rely on “auto-tuning.” On the one hand, domain-specific libraries such as ATLAS (Whaley and Dongarra, 1998) and FFTW (Frigo and Johnson, 2005) perform an automatic search—with or without explicit timing—to deliver hardware-specific code; on the other hand, general-purpose languages and libraries, such as A
A multitude of works are devoted entirely to optimizing the performance of specific applications, libraries, or even single operations. Here, we mention three examples from the field of linear algebra: The optimization of the algorithmic block size for Linear Algebra PACKage (LAPACK)’s routines (Whaley, 2008), the comparison of LAPACK’s symmetric tridiagonal eigensolvers (Demmel et al., 2008), and the study of algorithms for the reduction to tridiagonal form (Bientinesi et al., 2011). A recurring aspect in all such works is the performance studies of certain LAPACK routines; such studies, for which researchers had to write their own performance benchmarks, can be considerably simplified by the use of ELAPS.
3. Experiments
While performance experiments come in all kinds of shapes and sizes, many of them can be described by a few common features. Within the ELAPS framework, we combine and generalize such features to provide a versatile central concept of “experiment.” In this section, we discuss these basic features guided by deliberately simple examples. (More complicated examples arising in actual applications are presented in Section 5.)
We begin with a most elementary experiment: Measuring the performance of the matrix–matrix product kernel
As shown schematically above, this experiment runs on one core of an I
When combined with additional information on the hardware and the kernel’s complexity, the raw timing (in cycles) from this experiment leads to a number of metrics, which yield more insights into how efficiently the CPU is used.
Furthermore, if available, the PAPI (Browne et al., 2000) provides access to useful hardware counters.
With ELAPS, all these metrics are readily available and easily extensible.
3.1. Repetitions and statistics
Multiple executions of a kernel often result in fluctuating timings; the reasons for such differences include library initialization overhead, cache locality, and system jitter. As customarily done, in ELAPS, this issue is addressed by repeating each experiment several times while collecting statistics. As an example, let us consider an experiment that repeats the kernel execution 10 times on the same input matrices (i.e. the same memory locations):
This second experiment produces 10 measurements, from which we derive statistics as those presented in Figure 1: We chose to visualize all data points (all), the mean and a band of one standard deviation (std), a box plot (box), and a violin plot (violin). It is worth pointing out that whenever multiple repetitions are executed and timed, the first one almost inevitably represents an outlier; for the most part, this phenomenon is connected to the initialization of the kernel library, but it is also due to the loading and caching of data and instructions. In general, a more accurate representation of the effective performance is obtained by dropping the first measurement of the lot. In Figure 1, one can appreciate how significantly the first repetition affects various statistics, and most noticeably the minimum (exposed in the violin plot), mean, and standard deviation.

Performance statistics from 10 repetitions of
In order to avoid the impact of “first-execution” outliers, in all following examples and studies, we always discard the measurement from the first repetition.
3.2. Data placement: Varying operands
In experiment 2, the matrices A, B, and C were reused across repetitions, causing them to stay in cache; this scenario is also known as “warm data.” Depending on the application, the assumption of warm data may or may not be realistic; to reflect this in our experiments, we allow to “vary” the operands (i.e. use different memory locations) individually in each repetition. Furthermore, in ELAPS, one can freely control the relative position of varying operands: They can be stacked horizontally or vertically (indicated by a subscript ↓), with or without an arbitrary offset.
In the following experiment, while A and B are fixed and quite small, C varies in each repetition (hence the subscript in C rep) and is therefore never cached (“cold data”).
In Figure 2, we present the results of experiment 3 and another experiment in which the matrices A, B, and C are all fixed. The performance loss due to the enforced out-of-cache scenario for C is clearly visible.

Influence of data locality on
3.3. Sequences of kernels
In addition to isolated kernels, allows to experiment with sequences of calls. Let us use the solution of a linear system as an example: The problem
is typically solved by first LU-decomposing A (
For this experiment, Figure 3 shows both the total execution time and the time spent in each individual kernel. It is easy to see that for 200 right-hand sides, the LU decomposition

Breakdown of the timings for the solution of a linear system.
3.4. Parameter range
So far, we only considered experiments in which the sizes of the kernel operands were fixed. In many practical experiments, however, one wants to study the performance of a routine over a range of parameters. In the following example, we use the routine
Performance results from experiment 5 are shown in Figure 4; the plot displays the increase in performance for increasing problem size, as typical for dense linear algebra kernels.

Solution of linear systems: performance.
3.5. Threads range
Scalability studies are extremely common examples of experiments that make use of ranges. In the following experiments, we compute the eigenvalue decomposition of a symmetric matrix (of fixed size) using 1 up to 8 threads, and compare LAPACK’s solvers
As one can appreciate from Figure 5, ELAPS makes it easy to set up, execute, and compare the results of multiple experiments with varying degrees of parallelism.

Scalability of LAPACK’s symmetric dense eigensolvers on random matrices.
3.6. Sum- and Open MP-range
In loop-based algorithms, the total execution time is often more meaningful than an iteration-by-iteration breakdown. For this purpose, in addition to the “parameter range” described in the previous subsection, ELAPS also provides a “sum-range,” which yields the total contribution of the loop. For instance, experiment 7 models the inversion of a lower triangular matrix 2 of size 1000 via a blocked algorithm that traverses the matrix in steps of a fixed block size b.
Figure 6 reports the performance attained by this algorithm for different block sizes b; the maximum is observed for b = 100. The choice of parameters represents an important step to tailor algorithms for a given architecture; for instance, the tuning of block sizes is required by many of the algorithms included in LAPACK (Anderson et al., 1999; Whaley, 2008). Notice that a simpler and finer-grained experiment to optimize the block size is obtained by combining the sum range with a parameter range for b.

Influence of block size on triangular inversion.
O
The results in Figure 7 suggest that the parallel

Performance of threaded dtrsm versus parallel
4. The ELAPS framework
The ELAPS framework is built to support performance experiments combining the features and scenarios described in Section 3. In this section, we present the structure of the framework, focusing on the aspects that make it general and intuitive, yet powerful. A more user-oriented guide can be found as part of its documentation on G
As shown in Figure 8, ELAPS is structured in three layers. The first, “bottom” layer is written in C/C++ and contains the S The second, “middle” layer is the Python library This layer also includes the The third, “top” layer adds a graphical user interface, written in P

Structure of the ELAPS framework.
The design of these three layers is discussed in the next subsections.
4.1. The Sampler
The S read from standard input a list of calls, that is, kernel names with corresponding lists of arguments; execute the specified calls, thereby measuring their performance in terms of CPU cycles, and optionally through performance counters provided by the PAPI; print the measured performance numbers to the standard output.
While reading the list of kernels from the standard input, the S
The S
In a dense linear algebra kernel, these arguments are of one of two types.
Scalar arguments point to scalar values, some of which may influence the kernel’s behavior and control flow. Examples include: flag arguments (e.g. side, Within the S
Data arguments point to memory regions that hold the mathematical objects (such as vectors or matrices) involved in the kernel call. Generally,
7
the actual contents of these arguments do not affect the control flow; nonetheless, these arguments may still have a significant impact on performance, depending on their location in the memory hierarchy.
The Sampler has two mechanisms to treat data arguments:
Named variables are designated memory regions referenced by a variable names. A set of features to allocate (
Dynamic memory offers a fast way to pass “unnamed” memory regions as data arguments. Within one call, all such regions are guaranteed to be disjoint; across calls, however, the same memory regions may be reused arbitrarily.
To set up the contents of data arguments, the S
4.2. The
elaps
package
The middle layer of the ELAPS framework centers around the experimental features introduced in Section 3, encoded in the Python class
4.2.1. Experiments
The kernel configurations at the center of each experiment are its connection to libraries such as BLAS or LAPACK. While the interfaces of such libraries aim to be general by accommodating multiple functionalities, precisely because of their generality they are often unintuitive and hard to memorize. To counter this problem,

ELAPS
The execution of an
4.2.2. Execution on Samplers
In this section, we describe how the
As input, the S
Data arguments in kernels are allocated as named variables in the S
Finally, PAPI counters are also set at the beginning through the
4.2.3. Reports
Each
To turn these structured yet raw measurement results into more meaningful quantities, metrics combine them with the kernels’ Floating Point Operation (FLOP) counts and information on the execution environment. The easily extensible set of metrics ranges from “execution time in seconds” to “Gflops/s” and “efficiency.”
While a metric converts measurements values one-by-one, results from multiple repetitions are combined by statistics, such as “minimum,” “maximum,” “median,” or “standard deviation.” As motivated in Section 3, the results from the first repetitions are optionally discarded to hide overhead effects and make statistics more representative of in-application invocations.
4.2.4. Plotting
ELAPS’s
4.3. The graphical user interface
ELAPS’s
The P

ELAPS’s graphical user interface. ELAPS: Experimental Linear Algebra Performance Studies.
The V
5. Application examples
In this section, we demonstrate the use of the ELAPS framework in several application examples. For this purpose, we deliberately chose a wide range of hardware systems and kernel libraries.
5.1. Algorithm selection: Tensor contractions
Let us consider the tensor contraction (in Einstein notation)
with
and can be visualized as follows:
A natural approach to efficiently compute such tensor contractions is to utilize the highly optimized
An inspection of these algorithms reveals that they both execute a
We perform experiments 10 and 11 on a 16-core IBM P
Figure 11 suggests that neither of the two algorithms is optimal for all cases: While for a small dimension n, algorithm “∀b” is better, algorithm “∀c” dominates for large n. Interestingly, the crossover point is not at n = 500, where both algorithms work with matrices of equal size, but already around n = 300.

Comparison of
5.2. Library selection: Sylvester equation
Choosing the right library can be a crucial step in attaining high performance. In this section, we demonstrate its importance by considering the triangular Sylvester equation
to be solved for X, which is central to problems in control theory. In addition to LAPACK’s LAPACK 3.5 (Anderson et al., 1999) linked to O RECSY 0.01 (Jonsson and Kågström, 2003) linked to OpenBLAS;
Intel’s commercial Math Kernel Library (MKL) 11.0 (Intel a).
To compare these libraries, we launch experiment 12 on a 10-core I
Figure 12 shows the performance attained by the different libraries. LAPACK, which only provides an unblocked algorithm for

Comparison of libraries for the triangular Sylvester equation.
5.3. Multi-threading: Sequence of LUs
In a certain type of electronic structure calculations (Bauer and Blügel, 2013), one has to solve a series of fairly small linear systems. As already mentioned, a possible approach involves the LU decomposition (
On multi-core machines, the sequence of LUs can be parallelized at the granularity of one matrix via a multi-threaded
The next three experiments use ELAPS’s sum range and O
These three experiments are executed on a
Figure 13 indicates that of the two “pure” approaches, when more than eight LUs are performed (i.e. more than the CPU has hardware threads), O

Multithreading paradigms for a sequence of LUs. 13
5.4. Algorithmic optimization: Genome wide association studies
Genome wide association studies (GWAS) investigate how human traits (e.g. eye color or genetic diseases) are related to certain locations in the human genome (Boerwinkle et al., 1986; Yu et al., 2006). Computationally, GWAS can be cast as a sequence of generalized least squares (GLS) problems
where
A straightforward implementation of this equation (e.g. using R or MATLAB) might compute each bi individually by solving equation (7) from right to left, as modeled in this next experiment (with n = 1000 and p = 4):
For experiment 15, we choose a 60-core
Figure 14 shows both the execution time of experiment 15, as well as a breakdown thereof. The runtime is clearly dominated by the

Timing breakdown for a sequence of GLS solves. GLS: generalized least squares.
From a first analysis of these two kernels, one realizes that the dposv (
A further analysis reveals that all the
For the selected range of m, the runtime of this experiment is around 115 ms, i.e., already more than one order of magnitude less than the previous experiment. Furthermore, for larger problems, the
6. Productivity study
Ultimately, ELAPS’s main purpose is to increase the productivity of application developers by providing a simple, yet powerful, performance experimentation framework for dense linear algebra operations. In order to evaluate the productivity gain (over traditional, handwritten performance experiments) achieved when using ELAPS, we conducted a productivity study. Specifically, we chose 10 individuals with considerably different backgrounds in linear algebra and high-performance computing, ranging from novice (approaching BLAS and LAPACK for the first time), to expert (developer of linear algebra libraries), yet all without prior experience with ELAPS.
The test subjects were asked to repeat the same performance study twice—first with ELAPS, then using C and any visualization tool (
Across the board, the subjects reported a productivity boost. Despite the fact that the study was first performed with ELAPS—including the solution-independent problem analysis and understanding—in all cases it was reported that with ELAPS the process was faster. The speedups ranged between 4× and 9×, and the average productivity boost was of a factor of 6. In particular, the experiment setup, execution, and evaluation in ELAPS took on average around 10–12 min (including familiarization with the user interface), while the handwritten benchmarks and their evaluation took most subjects more than 1 h.
The participants stressed that the increase in productivity was not only due to the simple experiment setup in the P
7. Conclusion
We introduced the ELAPS framework, a set of tools and features to easily experiment and interact with dense linear algebra operations. Similar to how high-level frameworks such as MATLAB and Mathematica enable fast prototyping of new ideas, ELAPS enables the fast investigation of performance-related aspects of linear algebra algorithms; this is achieved by allowing users to easily design, execute, measure, and analyze algorithms. In contrast to the traditional “features first, performance later” approach, this investigation takes place before any actual coding, and serves to gain insights towards high-performance implementations.
Throughout this article, we applied ELAPS to a wide range of scenarios, including parameter optimization (Section 3), algorithm selection (Sections 3 and 5), library comparison (Section 5), and parallelism and library threading (Sections 3 and 5). We demonstrated the framework’s flexibility by linking it with seven kernel libraries, and by executing experiments on five different platforms, including a X
Having established the foundations of a framework for rapid experimentation, we foresee many opportunities for extensions. In particular, we envision (1) coverage of a broader range of architectures, including GPUs and ARM-based CPUs, (2) support for metrics related to data movement and energy consumption, and (3) interfaces for kernels and paradigms of distributed-memory libraries such as
Footnotes
Acknowledgements
The authors would like to thank their colleagues in the HPAC research group for many fruitful discussions and valuable feedback, and the J
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the D
