선정목록으로
Collecting and Presenting Reproducible Intranode Stencil Performance: INSPECT
패션 · (24) 패션(코오롱FnC)
기본 정보
- 저자
- DOI
- 10.14529/jsfi190301
- 저널
- Supercomputing Frontiers and Innovations
- 발행년도
- 2019
- 발행기관
- Publishing center of the South Ural State University
- 피인용수
- 1
- 라이선스
- cc-by-nc
- 논문 유형
- –
- 언어
- –
- 원문 페이지
- https://doi.org/10.14529/jsfi190301
- 토픽
- Advancements in Photolithography Techniques
- OpenAlex ID
- W2949272455
평가 내용
- 관련도
- 사업분야
- 패션 · (24) 패션(코오롱FnC)
- 부 분야
- –
- R&D 측면
- –
- 확신도
- –
- 근거 용어
- –
- 판단 근거
- 임베딩 유사도 기반 평가로 '패션 > 패션(코오롱FnC)' 분야에 선정된 논문입니다.
- R&D 활용 포인트
- –
- 평가 입력
- –
초록
Stencil algorithms have been receiving considerable interest in HPC research\nfor decades. The techniques used to approach multi-core stencil performance\nmodeling and engineering span basic runtime measurements, elaborate performance\nmodels, detailed hardware counter analysis, and thorough scaling behavior\nevaluation. Due to the plurality of approaches and stencil patterns, we set out\nto develop a generalizable methodology for reproducible measurements\naccompanied by state-of-the-art performance models. Our open-source toolchain,\nand collected results are publicly available in the "Intranode Stencil\nPerformance Evaluation Collection" (INSPECT). We present the underlying\nmethodologies, models and tools involved in gathering and documenting the\nperformance behavior of a collection of typical stencil patterns across\nmultiple architectures and hardware configuration options. Our aim is to endow\nperformance-aware application developers with reproducible baseline performance\ndata and validated models to initiate a well-defined process of performance\nassessment and optimization.\n
본문 68,399자
본문 펼치기
## Collecting and Presenting Reproducible Intranode Stencil Performance: INSPECT
_Julian_ _Hornich_ <sup>1</sup> _,_ _Julian_ _Hammer_ <sup>1</sup> _,_ _Georg_ _Hager_ <sup>1</sup> _,_ _Thomas_ _Gruber_ <sup>1</sup> _,_ _Gerhard_
_Wellein_ <sup>2</sup>
_⃝_ c The Author 2019. This paper is published with open access at SuperFri.org
Stencil algorithms have been receiving considerable interest in HPC research for decades. The
techniques used to approach multi-core stencil performance modeling and engineering span basic run
time measurements, elaborate performance models, detailed hardware counter analysis, and thorough
scaling behavior evaluation. Due to the plurality of approaches and stencil patterns, we set out to
develop a generalizable methodology for reproducible measurements accompanied by state-of-the-art
performance models. Our open-source toolchain, and collected results are publicly available in the
“Intranode Stencil Performance Evaluation Collection” (INSPECT).
We present the underlying methodologies, models and tools involved in gathering and documenting
the performance behavior of a collection of typical stencil patterns across multiple architectures and
hardware configuration options. Our aim is to endow performance-aware application developers with
reproducible baseline performance data and validated models to initiate a well-defined process of
performance assessment and optimization.
_Keywords:_ _performance_ _modelling,_ _performance_ _analysis,_ _stencils,_ _single-node,_ _multi-core,_ _ECM,_
_Roofline,_ _memory_ _hierarchy,_ _cache_ _effects._
## 1. Introduction
Stencils are relative data access and computation patterns that emerge from the discretization
of differential operators on regular grids. Stencils appear in many fields, from image processing, fluid
dynamics, material sciences to mechanical engineering, and are typically embedded in loop nests
that are at least as deep as the number of dimensions in the original continuous problem. Despite
their apparent simplicity, stencil algorithms show a rich set of performance patterns and allow for
various optimizations in terms of data access and work reduction. For instance, the performance
of most simple stencil algorithms (such as the 3D 7-point constant-coefficient variant encountered
with a simple finite-difference discretization of the Laplace operator on a regular Cartesian grid) is
limited by the memory bandwidth for in-memory working sets on multicore CPUs. Spatial blocking
can reduce the code balance to a theoretical minimum but will not decouple from memory band
width. Temporal blocking can finally render the implementation cache or core bound with significant
performance gains, but there are many different approaches and the number of parameters is sig
nificant [23]. Moreover, even recent publications often fail to assess performance baselines correctly,
rendering all reported speedups meaningless.
1.1. A Stencil Baseline Performance Collection
We set out to compile an extensible collection of stencil runtime performance characteristics
from a variety of architectures and backed up by analytic performance models and performance
1Erlangen Regional Computing Center (RRZE) at Friedrich-Alexander-Universit¨at Erlangen-N¨urnberg (FAU), Ger
many
2Department for Computer Science at Friedrich-Alexander-Universit¨at Erlangen-N¨urnberg (FAU), Germany
counter analysis. The stencil update iteration is embedded in a Jacobi algorithm without advanced
optimizations. All resulting information is available in a public online collection, organized based
on an abstract classification scheme, and can be easily reproduced with the presented information
and available open-source tool chain. The collection is also enriched with specific comments on the
[performance behavior and model predictions. It can be browsed at https://rrze-hpc.github.](https://rrze-hpc.github.io/INSPECT)
[io/INSPECT.](https://rrze-hpc.github.io/INSPECT)
1.2. Stencil Classification
In order to span a space of possible stencils we use a classification based on the following
properties:
_•_ _dimensions_ : dimensionality of the stencil, typically 3D or 2D
_•_ _radius_ : longest relative offset from the center point in any dimension, usually _r_ = 1, _r_ = 2, or
_r_ = 3
_•_ _coefficient weighting_ : how are coefficients applied, e.g. homogeneous, heterogeneous, isotropic,
or point-symmetric
_•_ _stencil_ _type_ : general shape of stencil, e.g., star or box
_•_ _coefficient_ _type_ : constant throughout grid or variable at each grid point
_•_ _data_ _type_ : numeric type of grid elements, e.g., double or float
These properties may have a large performance impact depending on the details of the underlying
CPU architecture and its features and configuration, making runtime predictions difficult. Much of
the complexity lies in the cache hierarchy, where data transfers may be handled before they reach
dimensions radius
2D/r1/star
3D/r1/star
stencil type
2D/r1/star
2D/r1/box
coefficient type
variable constant
2D/r1/box
3D/r2/star
2D/r3/star
coefficient
weighting
2D/r1/box
2D/r1/box
2D/r1/box
2D/r1/box
datatype
float double
Figure 1. Classification of stencils used by INSPECT. These properties do not capture all aspects,
but are representative for a large number of discretizations.
main memory and behavior depends on spatial and temporal locality. On the other hand, in-core
bottlenecks such as pipeline latencies, throughput limits, may also play a decisive role, especially
with more complicated stencils. A visual overview of the stencil classification is given in Figure 1.
Isotropic coefficient weighting deserves special attention: All nodes with the same distance to the
origin share the same coefficient; different distances have distinct coefficients.
With the given set of classification properties this leads to at least 192 relevant combinations.
We have not yet gathered data for all possible combinations and architectures available to us, but
a representative set is already available.
This paper is organized as follows: In Section 2 we briefly describe the computer architectural
features of the benchmark systems, the analysis tools, and the performance models we employ to
set up the stencil performance collection. Section 3 details on our automated workflow and includes
a description of the structure and origin of the data presented on the INSPECT website. Section 4
uses a few distinct stencil examples to showcase the data presentation and possible insights gained.
Finally, Section 6 gives related work and Section 7 concludes the paper.
1.3. Contributions
This work makes the following contributions:
_•_ a simple classification scheme of stencil characteristics, based on the underlying numerical
problem, and defining the architecture dependent performance behavior (see Sec. 1.2),
_•_ support for automatic analytic performance model generation for the AMD Zen microarchi
tecture (see Sec.4.2),
_•_ a first-of-its-kind collection, presentation and method to match the measured performance
data with automatically generated single- and multicore performance models in order to gain
insight into relevant performance bottlenecks and uncover compiler deficiencies and to guide
performance optimization strategies (see Sec. 3, 4 and 5),
_•_ an automatic extraction of the Phenomenological ECM model from hardware performance
counters (see Sec. 2.5.3), based on ideas from [23],
_•_ a public website on which the gathered data, performance models, and reproducibility infor
[mation are presented in a clear and structured way (see https://rrze-hpc.github.io/](https://rrze-hpc.github.io/INSPECT/)
[INSPECT/),](https://rrze-hpc.github.io/INSPECT/)
_•_ built-in reproducibility by transparently making all necessary runtime information and system
configurations available to developers—including the exact commands to execute for repro
duction (see Sec. 4).
## 2. Background & Methodology
To support our methodology, we use STEMPEL [9] for code generation based on the classifica
tion shown above, and Kerncraft [13] for the generation of Roofline and Execution-Cache-Memory
(ECM) models based on micro-architectural and memory hierarchy features as well as benchmarking
of single- and multi-core scenarios.
We will briefly introduce STEMPEL, Kerncraft and their underlying models ECM and Roofline
as well as hardware features which have a significant impact on similar codes.
2.1. STEMPEL
STEMPEL is used to generate stencil codes from the parameters mentioned in Section 1 (dimen
sions, radius, coefficient weighting, stencil type, coefficient type and data type). The resulting kernel
code is used as input for Kerncraft, but STEMPEL also supports generation of benchmarkable code
which can be compiled and executed stand-alone. The generated code may also include OpenMP
multithreading support or spatial blocking. The latter is used to investigate blocking behavior for
INSPECT. For accurate extraction of performance data, the code is additionally instrumented with
LIKWID markers to be used with the likwid-perfctr tool.
2.2. ECM & Roofline Model
The Execution-Cache-Memory (ECM) [28] and Roofline [30] models are resource-centered per
formance models that assume certain hardware limitations (such as data transfer bandwidths, in
struction throughput limits, instruction latencies, etc.) and try to map the application to a simplified
version of the hardware in order to expose the relevant bottleneck(s). This analysis depends on the
dataset size and dimensions, as well as the computational effort during each iteration. Both models
generally neglect data access latencies although they can be added as “penalties”. Latency predic
tions would require other models and are usually not of relevance for stencil code performance. In
some cases, latency penalties need to be considered for “perfect” predictions [17], but this correction
is usually small and is neglected in this work.
The compute performance bottleneck is analyzed based on the loop body’s maximum in-core
performance. Assuming that all load operations will hit the L1 cache, one can estimate the optimistic
runtime the loop body in cycles. The necessary information has been published by Intel, Agner
Fog [6], uops.info [1] or through the Intel Architecture Code Analyzer (IACA) [14]. Although
none of those sources are complete, they are good enough for a well-informed estimation. The
resulting inverse throughput of cycles per cacheline (lower is faster) exposes the bottleneck, for
both ECM and Roofline. Cachelines are considered as the basic work unit, since it is also the basic
unit of caches. E.g., for a double precision code with 8 Byte per element, on a machine with 64 Byte
cachlines, there are eight iterations per cacheline. For Roofline most publications use performance
(higher is faster) as the baseline metric, but both units can be converted into one another trivially:
clock _/_ performance _×_ work = inverse throughput
- <u>cycle</u>
second
_/_
- <u>FLOP</u>
second
_×_
- <u>FLOP</u>
iteration
_×_
- <u>iteration</u>
cacheline
=
- <u>cycle</u>
cacheline
Memory and cache bottlenecks require a prediction of which data access will be served by which
memory hierarchy level. This is either done using a cache simulator (e.g. pycachesim [11]) or the
analytical layer-condition model [10, 13]. The result from this prediction are the expected traffic
volumes between the levels of the memory hierarchy. The Roofline model then combines the data
volume per cacheline (e.g., eight iterations with double precision) for each hierarchy level with
previously measured bandwidths for the same level and core count, and selects the slowest as the
bottleneck. The ECM model combines all inter-cache transfers with theoretical bandwidths from
documentation, and volumes between memory and last level cache with a measured full-socket
Table 1. Host configuration used for INSPECT. See [https://rrze-hpc.github.io/](https://rrze-hpc.github.io/INSPECT/machinefiles)
<u>[INSPECT/machinefiles](https://rrze-hpc.github.io/INSPECT/machinefiles)</u> <u>for</u> <u>all</u> <u>details.</u>
Host HSW BDW SKX ZEN
Intel Intel Intel AMD
CPU model
Xeon E5-2695v3 Xeon E5-2697v4 Xeon Gold 6148 EPYC 7451
base clock (fixed) 2.3 GHz 2.3 GHz 2.4 GHz 2.3 GHz
uncore clock (fixed) 2.3 GHz 2.3 GHz 2.4 GHz n/a
turbo mode disabled disabled disabled disabled
cores per socket 14 18 20 24
cores per NUMA domain 7 9 10 6
cluster-on-die (CoD) / subCoD enabled CoD enabled SNC enabled n/a
NUMA-clustering (SNC)
Haswell Broadwell Skylake X Zen
microarchitecture
see Fig. 2a see Fig. 2a see Fig. 2b see Fig. 3
INSPECT machine name BroadwellEP ~~E~~ 5-2697 ~~C~~ oD BroadwellEP E5-2697 ~~C~~ oD SkylakeSP [Gold-6148](https://rrze-hpc.github.io/INSPECT/machines/SkylakeSP_Gold-6148_SNC) ~~S~~ NC Zen [EPYC-7451](https://rrze-hpc.github.io/INSPECT/machines/Zen_EPYC-7451)
bandwidth. These inverse throughputs are either combined using summation if no overlapping is
assumed, maximization for full overlapping, or any more complicated function for intermediate
situations.
For Intel processors, assuming that no overlap between any load, store, inter-cache and memory
transfers happens has proven to be the best fitting model assumption. This might change in future
microarchitectures and does not hold for other vendors.
For the AMD Zen microarchitecture, in-core computations and all inter-cache and register
transfers overlap down to the L2 cache. Transfers between L2, L3 and main memory serialize [15].
Another approach is to measure transfers using hardware provided performance counters and
base the ECM model on these empirical volumes and predict the runtime using the non-overlapping
assumption. This is referred to as the _Phenomenological_ _ECM_ _model_, also discussed in Section 2.5.3.
The model parameters used by the models are shown in Figure 2 and Table 1. The corresponding
machine files can be found on the INSPECT webpage. For the ECM model parameters, except for the
measured memory bandwidth highlighted by the preceding tilde (˜), all throughputs are published
in vendor documentation. The throughputs of execution ports, scheduler and decoder are not shown
here, but most may be found in official documentation, public resources, or can be benchmarked [12].
The overall instruction-level parallelism capability is represented with the different ports.
While in this work the Roofline model is always presented with a single (reciprocal) throughput
(TP), the ECM model is produced from architecture-dependent combinations of in-core computation
TP _T_ comp, load/store TP _T_ RegL1, inter-L1/L2 transfer TP _T_ L1L2, inter-L2/L3 transfer TP _T_ L2L3 and
main memory transfer TP _T_ L3MEM), with the unit of cycles per cacheline.
2.3. Intel Microarchitectures
The Intel microarchitectures Haswell (HSW) and Broadwell (BDW) have no differences in
regard to our modeling and performance analysis. Figure 2a shows their architectural diagram.
Both architectures have seven execution ports; most important are the two AVX2 fused-multiply
add (FMA) ports, two load ports able to handle 256-bit per cycle and one 256-bit store port. AVX
<mark>Queue, Decode, Out-of-Order Scheduler</mark>
<mark>Queue, Decode, Out-of-Order Scheduler</mark>
Port 6
...
Port 2
Port 3
Port 4
Port 7
Port 0
...
Port 6
...
Port 2
Port 3
Port 4
Port 7
Port 0
...
Port 1
...
Port 5
...
Port 1
...
Port 5
...
~~<mark>3×512</mark>~~ ~~<mark>bit/cycle</mark>~~
<mark>32kB L1 D-Cache</mark>
<mark>512bit/cycle</mark>
<mark>1MB unif</mark> i <mark>ed L2 Cache</mark>
~~<mark>2×128</mark>~~ ~~<mark>bit/cycle</mark>~~
~~<mark>3×256</mark>~~ ~~<mark>bit/cycle</mark>~~
<mark>32kB L1 D-Cache</mark>
<mark>256</mark> <mark>bit/cycle</mark>
<mark>256kB unif</mark> i <mark>ed L2 Cache</mark>
~~<mark>256</mark>~~ ~~<mark>bit/cycle</mark>~~
<mark>1536kB/</mark> core shared
Memory
<mark>~64 GB/s*</mark> L3 Cache
<u>* depends on runtime confguration and load/store ratioi</u>
<mark>~120 GB/s*</mark> L3
<u>* depends on runtime confguration and load/store ratioi</u>
avx512
Memory
<mark>1375kB/</mark> core shared
L3 <mark>Victim-Cache</mark>
(a) Haswell (HSW) and Broadwell (BDW) (b) Skylake X (SKX)
Figure 2. Simplified block diagrams for Intel Haswell, Broadwell and Skylake X, including the
execution ports and cache hierarchy. Differences have been highlighted. The Skylake architecture
(without X) has no AVX512 support.
and AVX2 instructions can make use of sixteen 256-bit YMM registers. On the memory side, there is
a linear inclusive cache hierarchy. Due to the double ring interconnect between individual HSW and
BDW cores and separate memory controllers residing on each ring, a cluster-on-die mode can be
enabled to allow NUMA separation of the two rings. With cluster-on-die mode, the last-level cache
(i.e., L3) is split and only used by a core on the same ring and a slightly higher memory bandwidth
can be attained. Results for HSW and BDW are presented with cluster-on-die (CoD) mode enabled.
The Skylake X (SKX) microarchitecture is shown in Figure 2b. It supports AVX512, which
boosts load, store and FMA ports from 256-bit to 512-bit width. To allow two AVX512 FMA
instructions to be executed in parallel (i.e., combined throughput of 0.5 cycles) an AVX512 pipeline
was added to Port 5 and the existing 256-bit pipelines at Ports 0 and 1 may be used in lockstep
to reach 2 _×_ 512-bit width. There are 32 512-bit YMM registers and the number of 256-bit registers
was also doubled to 32. The SKX microarchitecture has a non-inclusive last level victim cache,
which may cache evicted cachelines from L2 and is used to write back to but not to load from
memory. All data coming from memory is loaded directly into the L2 cache of the requesting core.
Unmodified cachelines may also be dropped from L2. The criteria which decide if a cacheline is
evicted from L2 to the victim cache or not have not been disclosed. For our models we assume that
all evicts will be passed on to the last-level cache and—if changed—stored from there into memory.
Sub-NUMA-clustering (SNC) is similar to CoD, which was also enabled during our measurements.
The changed cache structure of the Skylake microarchitecture with its undocumented decision
heuristic for L3 cache usage and unavailable hardware counters for some of the inter-cache and
memory data paths, still poses a problem. As we will see later, assuming the traditional linear
inclusive cache hierarchy often yields reasonable results, but is still under investigation.
In the architecture diagrams, two-way arrows represent half-duplex capabilities and two in
dividual arrows means full-duplex capabilities. The factor along with the bandwidth is meant to
emphasize the half- and full-duplex behavior (e.g., between L2 and L3 on Skylake X 128 bits per
<mark>Queue, Decode, Out-of-Order Scheduler</mark>
P. 9
<mark>agu</mark>
Port 3
...
Port 4
Port 5
Port 6
Port 7
P. 8
<mark>agu</mark>
<mark>load</mark>
<mark>load</mark>
<mark>store</mark>
Port 0
...
Port 1
...
Port 2
...
3×128 bit/cycle
<mark>32kB L1 D-Cache</mark>
2×256 bit/cycle
<mark>512kB unif</mark> i <mark>ed L2 Cache</mark>
256 bit/cycle
Memory
8MB/core shared
L3 Victim-Cache
~160 GB/s*
- depends on runtime confguration and load/store ratioi
Figure 3. Simplified block diagram for AMD Zen microarchitecture, including execution ports and
cache hierarchy.
cycle may be transferred both ways concurrently). This information and more is used to construct
a machine file for Kerncraft and will be explained in Section 2.5.1.
The specific systems that are used for INSPECT are documented at [https://rrze-hpc.](https://rrze-hpc.github.io/INSPECT/machinefiles)
[github.io/INSPECT/machinefiles.](https://rrze-hpc.github.io/INSPECT/machinefiles) A summary of the relevant configuration details, in ad
dition to the micro architectural details in Figure 2, is given in Table 1.
2.4. AMD Zen Microarchitecture
The AMD Zen microarchitecture has ten ports, the first four of which (0, 1, 2 and 3) support
128-bit wide floating-point SSE instructions (see Figure 3). Each execution unit, except for divide,
is present on two ports, e.g., FMA and MUL on 0 and 1, and ADD on 2 and 3. The decoder stage
supports AVX instructions by utilizing two SSE ports simultaneously (similar to AVX512 on Port
0 an 1 with Skylake X). Ports 4 through 7 handle integer and control flow instructions.
Ports 8 and 9 each have their own address generation unit (AGU) and can utilize the two shared
load ports and the single shared store port. The store and load ports each operate on up to 128 bits
and can issue one load/store to the 32 kB first-level (L1) cache. Thus either two loads or one load
and one store can be executed per cycle at maximum. The 512 kB inclusive L2 cache is connected
to the L1 cache with 256-bit per cycle full-duplex (i.e., a 64 B cacheline takes two cycles to transfer,
and loads and stores are done in parallel). Between L2 and the last-level cache (L3), 256 bits can
be transferred per cycle, but only half-duplex (i.e., either load or store). The exact heuristics of
the victim cache are not publicly available. In addition to that, support for hardware performance
counters is much more limited, which does not allow us to inspect many of the transfers between
memory levels.
The maximum main memory bandwidth achievable is close to 160 GB/s, 30% higher than what
we were able to measure on Skylake X. The specific AMD CPU used here has 24 cores, split over
four NUMA domains of 6 cores each.
2.5. Kerncraft
Kerncraft brings together static analysis of the kernel code with microarchitecture data and
execution models into a coherent performance prediction model, based on the Roofline and ECM
models. It also allows benchmarking of the kernel codes with single and multiple cores (using
OpenMP) and collection of hardware performance counter data during execution.
_2.5.1._ _Machine_ _Model_
The specific machine model for each microarchitecture is described in the _machine_ _files_,
which are provided either with Kerncraft or can be generated semi-automatically using
likwid ~~b~~ ench ~~a~~ uto—a tool distributed with Kerncraft. All machine models mentioned in this
paper are provided with Kerncraft in the examples directory. When using the semi-automatic gener
ation, it must be executed on such a machine and the resulting file needs to be completed manually
from vendor documentation, model assumptions or from existing—similar—architecture files.
Machine model files contain detailed information on the architecture and memory hierarchy
as well as benchmark results, necessary to construct the Roofline and ECM model. In particular
STREAM [24] benchmark results, cache sizes and parameters, NUMA topology, base clock and
architecture specific compiler arguments make up the majority of the description. Some of it can
be collected automatically, some needs to be provided manually.
The INSPECT website presents a breakdown of the architecture information in the machine
files: [https://rrze-hpc.github.io/INSPECT/machinefiles. There may be known issues,](https://rrze-hpc.github.io/INSPECT/machinefiles)
which are also documented on INSPECT. E.g., Haswell’s L1-L2 bandwidth is theoretically 64 Byte
per cycle, but benchmarks show that the achievable bandwidth may be as low as 32 B/cy. Kerncraft
assumes the optimistic 64 B/cy.
_2.5.2._ _Model_ _Construction_
The static analysis and model building is split in two parts: in-core execution and data analysis;
both of which are done without execution of the kernel code and can be performed on any hardware.
The in-core analysis is done via the Intel Architecture Code Analyzer tool (IACA) [14] for
Intel architectures and the Open Source Architecture Code Analyzer (OSACA) [20], which yields
the number of cycles each execution port is occupied by the kernel’s assembly instructions ( _T_ comp
and _T_ RegL1 for the ECM model). Kerncraft takes care of compilation, unrolling and vectorization
in order to correctly interpret the IACA/OSACA result and relate it to high-level loop iterations
found in the kernel source code.
The data analysis predicts inter-cache and memory transfer data volumes either using the
analytical layer-condition model (LC) or the pycachesim [11] cache simulator. This yields _T_ L1L2,
_T_ L2L3 and _T_ L3MEM for the ECM model. The LC model analysis is very fast and gives a closed form
analytical model, but relies on an idealistic full-associative inclusive and least-recently-used cache
hierarchy. The cache simulator can handle more realistic and complex cache configurations, such as
associativity and non-inclusive cache hierarchies—at the cost of speed and without a closed form
solution. Certain aspects of real hardware can not be simulated due to missing documentation, e.g.,
cache placement algorithm for last-level cache on current Intel microarchitectures.
For multi-core scaling, we use the memory latency penalty estimation as described by Hof
mann [16].
_2.5.3._ _Benchmark_ _Mode_ _and_ _Phenomenological_ _ECM_
Benchmarking of any code can be tricky, this is the same for stencil codes. Kerncraft takes care
of pinning and hardware performance counter monitoring with LIKWID [29], as well as ensuring
a minimal runtime, checking machine configuration and derivation of relevant metrics from the
measurements. The underlying performance counters are defined in the machine model and based
on validated metrics provided by LIKWID.
In addition, metrics based on measurement of the runtime, such as memory bandwidths and
lattice updated per second, data transfer volumes can be measured accurately. From these Kerncraft
can construct a _Phenomenological_ _ECM_ _model_ . This phenomenological model is not based on the
measured runtime or derived bandwidths, but uses inter-cache and memory data volumes as well
as counts of executed _µ_ ops per port. The overall prediction is then compiled in the same way as the
analytical ECM prediction is compiled from vendor documented transfer rates, measured memory
bandwidth and instruction throughput information.
The specific counters necessary have been compiled from Intel documentation and their correct
ness validated with microbenchmarks, where possible. This process is part of the ongoing LIKWID
development. Kerncraft’s machine models put the counter in relation to ECM model parameters,
such as L1-L2 traffic or execution port utilization. To measure all necessary counters, multiple exe
cutions are unavoidable, because only a limited number of counter registers are available for use. On
Intel’s server microarchitectures, many performance counters are available and a complete model
can be assembled as presented in Figure 4f. On AMD Zen, however, essential contributions, such
as main memory traffic can not be examined and a complete phenomenological model may not be
constructed.
## 3. Data Collection
In order to build a comprehensive single-node stencil performance database, preexisting open
source tools STEMPEL [9], Kerncraft [13] and LIKWID [29] have been combined in the “Intranode
Stencil Performance Evaluation Collection” (INSPECT). For given stencil parameters all benchmark
and automated performance modeling data for the present machine can be collected with a single
(job) script. The data collection work flow can be seen in Algorithm 1.
For the stencil source code generation, to be supplied to kerncraft, STEMPEL is used. Possible
parameters are: dimension, radius, stencil type, coefficient weighting and type as well as the data
type. Examples of the produced stencil code by STEMPEL are shown in Listings 1, 2 and 3. If a
custom stencil is to be be used, this step can be omitted.
The stencil code is then supplied to Kerncraft in order to do layer condition analysis and
determine sensible ranges for grid sizes to be examined. Data ranges are chosen such that the last
<u>Algorithm</u> <u>1</u> <u>INSPECT</u> <u>data</u> <u>collection</u> <u>workflow</u>
fix frequency
for dimension, radius, kind, coefficients, weighting, data type do
stempel: generate stencil
kerncraft: layer condition analysis
LCL3,3D _←_ compute L3 3D layer condition size
NL3,3D’ _←_ 1 _._ 5 _·_ LCL3,3D
if NL3,3D’ _<_ available Memory per NUMA-domain then
reduce grid ~~s~~ ize until it fits in memory
end if
for _n ←_ 10 _,_ NL3,3D’ do _▷_ single core grid scaling
kerncraft: (LC, CS) _×_ (RooflineIACA, ECM)
kerncraft: Benchmark
end for
for _Threads ←_ 1 _,_ N _threads_ do _▷_ thread scaling @ NL3,3D’
kerncraft: (RooflineIACA, ECM, Benchmark)
end for
stempel: generate 3D spatial blocking code
for _n ←_ 10 _,_ NL3,3D’ do _▷_ single core grid scaling
determine ’good’ 3D blocking factors
likwid-perfctr: Benchmark
end for
csv data + graphs + website _▷_ post processing
<u>end</u> <u>for</u>
level cache 3D layer condition is violated and a steady state will be reached as long as the available
main memory per NUMA domain is not exceeded (see 1 _._ 5 _· LCL_ 3 _,_ 3 _D_ in Algorithm 1).
The next step is data collection. For single core grid scaling, Kerncraft is used to generate
Roofline and ECM performance models with layer conditions and cache simulation, as well as
benchmark and Phenomenological ECM data. Multi-core thread scaling is done for the largest
previously calculated, memory bound grid size for all cores of one socket. Here Kerncraft is again
used to generate Roofline, ECM and Benchmark data. In a last step spatial blocking is performed.
Here STEMPEL is once more used to generate executable benchmark code with spatial blocking
from the basic stencil code, generated before. This spatial blocking code is then instrumented with
LIKWID to obtain the required benchmark data.
In a final step all data is collected, postprocessed and archived. The outputs are the data files
that are needed for the visualization on the website. Those files can be pushed to the git repository
to automatically include the inspected stencil on the INSPECT website.
For every stencil-machine configuration the website shows general stencil information, graphs
of the measured and predicted performance and step-by-step instructions for the replication of the
shown data. The general stencil information contains: stencil parameters, kernel source code, kernel
assembly and layer condition analysis, as well as IACA throughput analysis and information about
the state of the machine and operating system, the data was collected on. Performance prediction
and benchmark data are shown in 5 different graph types:
_•_ stacked ECM (with layer condition, cache simulation and phenomenological)
_•_ Roofline performance (with layer condition and cache simulation)
_•_ data transfers for single core grid scaling
_•_ full-socket thread scaling (one grid size by default, but possibly more)
_•_ spatial blocking performance plots (3D-L3 cache blocking by default, but possibly more)
An example of the plots visible for each stencil configuration is shown in Figure 4. The reproducibility
information contains detailed steps on how to generate the stencil code with STEMPEL and all
necessary commands to retrieve the data shown on the site.
Additionally all shown data can be commented and validated with a traffic light system re
flecting the quality of the shown plots. This allows to highlight problems or unintuitive results of a
specific stencil or hardware configuration, that could otherwise be mistaken for incorrect data.
## 4. Examples
Three different exemplary stencil configurations were selected from the INSPECT website:
short-/long-ranged and star/boxed stencils, on three different machines. We will start with a very
basic 7-point stencil on a Haswell Xeon E5-2695v3 machine, then continue with a long-ranged stencil
on Skylake Xeon Gold 6148 and compare a boxed stencil on Broadwell Xeon E5-2697v4 and Skylake
Xeon Gold 6148; we will conclude with the basic 7-point stencil on an AMD EPYC 7451 machine.
In addition to the presented architectures, the INSPECT website also contains analyses and
measurements on Intel Sandy Bridge and Ivy Bridge architectures.
dimension, radius, coefficients
kind, weighting, datatype
STEMPEL
Kerncraft
Roofline ECM
Benchmark
(c) Single Core Spatial Blocking
400
350
1 _,_ 200
800
400
Roofline
ECM
~~Benchmark~~
L3-3D blocking
750 950
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
(a) Model Prediction with Layer Conditions
60
50
40
30
20
10
305
365
460
615
920
1850
1 _,_ 200
800
400
(d) Multi Core Thread Scaling @ 1020 <sup>3</sup>
Benchmark
ECM LC
~~Roof~~ l ~~ine~~
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Threads
(e) Data Transfers
L1-L2 Measured
~~L2-L3~~ ~~Measured~~
L3-Mem Measured
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
(b) Model Prediction with Cache Simulation
60
50
40
30
20
10
<u>L1-L2</u> <u>Model</u>
L2-L3 Model
<u>L3-Mem</u> <u>Model</u>
60
50
40
30
20
10
305
365
460
615
920
1850
60
50
40
30
20
10
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
(f) Phenomenological ECM Model
305
365
460
615
920
1850
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
_<mark>×</mark>_ <sup>Benchmark</sup> _~~<mark>◦</mark>~~_ <sup>Roofline</sup> _T_ comp _T_ RegL1 _T_ L1L2 _T_ L2L3 _T_ L3MEM
Figure 4. Flow chart visualizing the connections between STEMPEL and Kerncraft and the result
ing data. STEMPEL is used to generate the kernel and spatial blocking code. Kerncraft performs
Roofline and ECM analysis on the kernel code for layer condition and cache simulation. Kerncraft’s
benchmark mode provides the measurement data for grid scaling, data transfers and Phenomeno
logical ECM, as well as multi core thread scaling. The shown data is for a 3D star stencil with radius
1 and constant, homogeneous coefficients with double precision floating-point numbers on a Haswell
Xeon E5-2695v3 machine with Cluster on Die mode enabled. Underlying data, plots and additional
model information may be viewed at [https://git.io/fjqzy](https://git.io/fjqzy) on the INSPECT website.
double a[M][N][P], b[M][N][P], c0;
for ( long k = 1; k < M - 1; ++k) {
for ( long j = 1; j < N - 1; ++j) {
for ( long i = 1; i < P - 1; ++i) {
b[k][j][i] = c0 - ( a[k][j][i]
+ a[k][j][i-1] + a[k][j][i+1]
+ a[k][j-1][i] + a[k][j+1][i]
+ a[k-1][j][i] + a[k+1][j][i] );
}}}
Listing 1. 3D stencil code with radius 1, constant homo-geneous coefficients, star structure and
double data type.
4.1. A Simple Short-ranged Stencil on Haswell (Intel Xeon E5-2695v3)
The first stencil configuration presented here is the simple 3D 7-point stencil on the well under
stood Haswell microarchitecture (Intel Xeon E5-2695v3 in CoD mode): 3D, radius 1, star stencil,
constant and homogeneous coefficients with double precision floating-point accuracy. The stencil
source code is shown in Listing 1. Figure 4 displays all graphs presented on the INSPECT website,
as well as the workflow from stencil generation with STEMPEL to data acquisition with Kerncraft,
as already outlined by Algorithm 1. The model prediction graphs show a stacked ECM prediction
( _T_ ECM = max( _T_ comp _,_ sum( _T_ RegL1 _, T_ L1L2 _, T_ L2L3 _, T_ L3MEM))), together with the Roofline prediction
and benchmark measurement data.
All the presented data and plots on this specific kernel, including commands to reproduce,
system configuration used and very verbose information on the analysis (such as the IACA output)
may be viewed at: [https://git.io/fjqzy.](https://git.io/fjqzy)
Figure 4a shows the ECM and Roofline prediction generated by Kerncraft, based on the layer
condition prediction. Figure 4b is based on the cache simulation. The stacked colored regions repre
sent the data transfers in the ECM model, where the upper boundary is equal to the ECM prediction
including all data transfers ( _T_ RegL1 + _T_ L1L2 + _T_ L2L3 + _T_ L3MEM). The red line represents the compute bottleneck ( _T_ comp), as predicted with IACA. The Roofline prediction is the thin blue line with
circles. The black line with x’s are the measurement results from running Kerncraft in benchmark
mode.
The Roofline prediction is accurate when all layer conditions are violated and all stencil data is
coming from main memory. Before that, its prediction is about 25% too optimistic. In the transition
zone, there are a few points where the Roofline model is too pessimistic, because the mathematical
layer condition is sharp but the performance shows a smooth transition because of the cache re
placement policy. The ECM model results in a much more accurate prediction. All layer condition
jumps (30 <sup>3</sup> : L1-3D, 90 <sup>3</sup> : L2-3D, 680 <sup>3</sup> : L1-2D, 760 <sup>3</sup> : L3-3D) are clearly visible and correspond to the
measured performance. The large deviation between models and measurement in the initial section
( _N_ _<_ 100 <sup>3</sup> ) comes from loop overheads and large impacts of remainder loop iterations, while this
is expected, it is not modeled by neither ECM nor Roofline.
Comparing the cache simulator (Fig. 4b) with the layer conditions (Fig. 4a) shows that some
peaks or dips in the measurement can be explained by using a more accurate cache model as
provided by the cache simulator. It also allows for a smoother transition between broken layer
conditions, but nonetheless fails at accurately predicting the transition behavior. Perfect tracking
of those transitions, as seen in the benchmark measurements, would only be possible with precise
knowledge of the underlying caching algorithms implemented in the different cache levels. Due to a
lack of information from the CPU vendors a perfect LRU cache is assumed, as well as other idealized
implementation details.
In the Phenomenological ECM graph, cf. Figure 4f, the smooth transition between broken layer
conditions can be tracked very well. Apart from the transitions zones, the individual contributions
as modeled by the analytical ECM model ((Fig. 4a and 4b) and derived from measurements in the
Phenomenological ECM model match up very well. It also shows why the measured performance
differs immensely from the predictions below 100 <sup>3</sup>, which now shows as very high in-core execution
time an load instructions because of short scalar loops. The difference between measurement and
model towards the right side of the graph hints that there are saturation effects in the memory
interface which we do not yet understand fully.
The data transfer volumes predicted by the layer conditions and their comparison with measured
data volumes through hardware performance counters can be seen in Figure 4e. The solid lines show
the data transfer prediction between cache levels and main memory and the dashed lines are the
measured data transfers. Between 100 <sup>3</sup> and 500 <sup>3</sup> as well as after 850 <sup>3</sup> the predicted transfers at each
level and the measured data fit perfectly and show the accuracy of this method. As layer condition
break the measured cache transfers show a smooth transition, until it realigns with the predicted
data volume.
Figure 4c shows the impact of cache blocking for specific layer conditions. In this case, blocking
was performed for the L3-3D layer condition, where only the middle loop (e.g., j-loop in Listing 1)
is blocked to keep the relevant data at least in the L3 cache and reduce main memory traffic to
a minimum. As intended, performance stays constant after the L3-3D layer condition is broken,
with spatial cache blocking enabled (green line). This behavior can be predicted from Fig. 4a,
where spatial blocking means to preserve the throughput of an earlier plateau while increasing the
dataset size. Reasonable blocking factors are given by the range of the plateau (e.g., here the block
dimensions should be _N_ block <sup>1</sup> <sup>_/_</sup> <sup>3</sup> <sup>_<_</sup> <sup>700).</sup> <sup>Blocking</sup> <sup>for</sup> <sup>the</sup> <sup>next</sup> <sup>lower</sup> <sup>plateau</sup> <sup>(i.e.,</sup> <sup>_N_</sup> block <sup>1</sup> <sup>_/_</sup> <sup>3</sup> <sup>_<_</sup> <sup>100)</sup> <sup>may</sup>
introduce too much overhead due to short loops. Another, more complicated option would be the
use of temporal blocking, which is expected to yield about the same performance as _N_ <sup>1</sup> <sup>_/_</sup> <sup>3</sup>
block <sup>_<_</sup> <sup>100,</sup>
because stripping the top contribution from the stacked plot would bring the throughput to the
same plateau.
Moving on from the single core to multi core scaling, Figure 4d shows the in-socket thread
scaling behavior at 1020 <sup>3</sup> . Due to the Cluster-on-Die configuration of the machine, the performance
flattens out at the end of the first NUMA-domain (7 cores). With the addition of the second NUMA
domain a linear increase can be seen, due to the linear addition of bandwidth from the added cores
based on the compact scheduling scheme. Predictions of ECM and Roofline models fit very well in
the second, linear part of the graph, and the ECM is also able to capture the phase before memory
bandwidth saturation.
_~~×~~_ Benchmark _~~◦~~_ Roofline _~~2~~_ _T_ comp _~~⋆~~_ _T_ RegL1 _~~△~~_ _T_ L1L2 _T_ L2L3 _T_ L3Mem
_~~×~~_ Benchmark _~~◦~~_ Roofline _T_ comp _T_ RegL1 _T_ L1L2 _T_ L2L3 _T_ L3Mem
190
240
320
480
960
100
80
60
40
20
40
30
20
10
0
100 300 500 700
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
460
610
920
1840
Figure 5. ECM and Roofline predictions with
benchmark results for 3D 7-point star stencil on
AMD ZEN.
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
Figure 6. ECM and Roofline predic
tions for SKX, based on layer con
ditions, with benchmark results for
3D/3r/heterogeneous/star/constant/double
stencil.
4.2. A Simple Short-ranged Stencil on AMD Zen
In Figure 5 we show an analysis on the AMD Zen microarchitecture, presenting results for
the same kernel as in Listing 1. These and additional results may be found at [https://git.](https://git.io/fj4yq)
[io/fj4yq.](https://git.io/fj4yq) As described in Section 2.2, the AMD Zen architecture shows strong overlap in data
transfers. The port execution model is based on the OSACA implementation [20], and the Kerncraft
version used for this is based on the latest feature/OSACA branch. For data volume prediction
we use the layer condition model, as for SKX.
The ECM prediction for the AMD Zen microarchitecture is based on the following model, which
has fewer serializing terms:
_T_ ECM = max( _T_ comp _, T_ RegL1 _, T_ L1L2 _,_ sum( _T_ L2L3 _, T_ L3MEM))
This difference is also visible in Figure 5, where the overlapping parallel terms ( _T_ comp, _T_ RegL1 and
_T_ L1L2) are simple lines and the serial contribution terms ( _T_ L2L3 and _T_ L3MEM) are stacked onto one
another.
As with Skylake X, the benchmark follows the trend of the model qualitatively, but measure
ments yield better throughput with increased main memory traffic. This effect is seen in both the
ECM and the Roofline model and we believe it is linked to the undisclosed behavior of the L3 cache.
The cache simulator apparently overestimates the number of L2 or L3 misses and predicts a higher
main memory traffic volume. Unfortunately, AMD Zen does not have main memory traffic hardware
performance counters, so we are unable to validate this assumption.
In light of the large main memory traffic contribution, we would suggest temporal blocking to
bring the inverse throughput down to the _T_ RegL1 level. _T_ L3Mem contains all memory accesses (i.e.,
transfers between main memory, L3 and L2).
double a[M][N][P], b[M][N][P];
double c0, c1, c2, c3, c4, c5, c6, c7, c8, c9;
double c10, c11, c12, c13, c14, c15, c16, c17, c18;
for ( int k = 3; k < M-3; k++) {
for ( int j = 3; j < N-3; j++) {
for ( int i = 3; i < P-3; i++) {
b[k][j][i] = c0 - a[k][j][i]
+ c1 - <sup>a[k][j][i-1]</sup> <sup>+</sup> <sup>c2</sup> - <sup>a[k][j][i+1]</sup> <sup>+</sup> <sup>c3</sup> - <sup>a[k-1][j][i]</sup>
+ c4 - <sup>a[k+1][j][i]</sup> <sup>+</sup> <sup>c5</sup> - <sup>a[k][j-1][i]</sup> <sup>+</sup> <sup>c6</sup> - <sup>a[k][j+1][i]</sup>
+ c7 - <sup>a[k][j][i-2]</sup> <sup>+</sup> <sup>c8</sup> - <sup>a[k][j][i+2]</sup> <sup>+</sup> <sup>c9</sup> - <sup>a[k-2][j][i]</sup>
+ c10 - a[k+2][j][i] + c11 - a[k][j-2][i] + c12 - a[k][j+2][i]
+ c13 - a[k][j][i-3] + c14 - a[k][j][i+3] + c15 - a[k-3][j][i]
+ c16 - a[k+3][j][i] + c17 - a[k][j-3][i] + c18 - a[k][j+3][i];
}}}
Listing 2. 3D stencil code with radius 3, constant hetero-geneous coefficients, star structure and
double datatype.
4.3. A Long-ranged Stencil on Skylake X (Intel Xeon Gold 6148)
The second example showcases a long-ranged heterogeneous star stencil on the Skylake X ar
chitecture (Intel Xeon Gold 6148), the stencil source code is shown in Listing 2. It features more
floating point operations compared to the previous kernel because of the heterogeneous coefficients
classification, but also higher memory traffic due to the long stencil range (i.e., range = 3 or r3
classification). For brevity, only the stacked ECM prediction with layer conditions as cache predictor
is shown in Figure 6. All remaining information and graphs can be found on the INSPECT website:
[https://git.io/fjq2a.](https://git.io/fjq2a)
Qualitatively, both—Roofline and ECM prediction—represent the measured performance be
havior well. The Roofline model is a bit too optimistic and the ECM model a bit too pessimistic.
The reason for that is the new organization of the cache hierarchy in the Skylake microarchitecture,
seen in Figure 2b and discussed in Sec. 2.3. At the moment it is not possible to correctly model
the data transfers between L2 and L3 cache, in combination with main memory. With the ECM
model a worst case scenario is assumed, such that all data dropped or evicted from L2 is passed
onto L3. Taking that into account and with better knowledge of the actual caching algorithms and
heuristics, the ECM prediction would become faster and more closely match the measured data.
The layer condition analysis, correlates very well with the measured data and all relevant breaks
(i.e., plateaus) can be seen. The slow performance in the beginning until 120 <sup>3</sup> is again related to
the high _T_ comp fraction and scalar loads of the remainder loop.
Data shown on the INSPECT website for full-socket thread scaling shows that the prediction
fits perfectly to the measured data. Also cache blocking for the L2-3D layer condition works very
well, due to the larger L2 cache in this architecture. In contrast to that, L3-3D cache blocking works
very poorly, as is in accordance with Intel’s recommendations: “Using just the last level cache size
per core may result in non-optimal use of available on-chip cache” [19] (p. 41).
Overall it can be said, that except for the uncertainty with the L2-L3-MEM caching behavior,
the applied Skylake machine model works well and gives accurate predictions.
Performance optimization potential is again predicted by the plateaus (for spatial blocking) and
contributions (for temporal blocking). Spatial blocking to _N_ <sup>1</sup> <sup>_/_</sup> <sup>3</sup>
block <sup>_<_</sup> <sup>300</sup> <sup>may</sup> <sup>increase</sup> <sup>performance</sup>
by up to 30%. Temporal blocking would only make sense, in comparison to spatial, if it is done in
the L2 cache, stripping the two upper contributions off the non-overlapping ECM prediction and
possibly hitting the instruction throughput bottleneck ( _T_ comp) at 40 cy/CL.
4.4. Comparison of a Short-ranged Box Stencil on Broadwell and Skylake X
Finally, we present a comparison of Broadwell (Intel Xeon E5-2697v4) and Skylake X (Intel Xeon
Gold 6148) with a short-ranged box stencil with heterogeneous constant coefficients, cf. Listing 3.
Compared to star stencils, box stencils need more loads and registers, which may have a large
performance impact. In Figures 7a and 7b benchmark data and model predictions are shown. On
the INSPECT website a complete list of graphs, data sets and modeling information may be viewed:
[https://git.io/fjqav](https://git.io/fjqav) for Broadwell and [https://git.io/fjqaU](https://git.io/fjqaU) for Skylake X.
On Broadwell performance does not seem to be impacted by data traffic nor in-core execution
( _T_ comp). Reasons for the poor and almost constant performance across all grid sizes is a register
dependency chain that is visible in the assembly code, to be seen on the INSPECT website under
“Kernel Source Code” by clicking on the “Assembly Code” button, but undetected by IACA.
This dependency chain slows down the execution so much, that all other effects are suppressed
and the performance becomes independent of the grid size. Since the number of available registers
has been doubled with the introduction of the Skylake X architecture, this disastrous effect is
eliminated there. Instead, until 300 <sup>3</sup> the in-core bottleneck _T_ comp dominates and limits the reciprocal
throughput to _∼_ 60 cy/CL. This prediction, originating from an IACA analysis, is obviously too
pessimistic, since measurements show better performance compared to ECM and Roofline models.
Looking into the IACA analysis, it only gives an explanation for 46 out of the 60 cycles and adds
14 cycles based on an unknown heuristic. Considering this, 46 cycles per cacheline would explain
the measured performance much better and calls for a better in-core model, as aimed for by the
_~~×~~_ Benchmark _~~◦~~_ Roofline _T_ comp _T_ RegL1 _T_ L1L2 _T_ L2L3 _T_ L3Mem
_~~×~~_ Benchmark _~~◦~~_ Roofline _T_ comp _T_ RegL1 _T_ L1L2 _T_ L2L3 _T_ L3Mem
120
100
80
60
40
20
150
185
230
305
<u>460</u>
920
160
190
240
~~320~~
480
960
120
100
80
60
40
20
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
0
100 400 700 1 _,_ 000
Grid Size (N <sup>1</sup> <sup>_/_</sup> <sup>3</sup> )
(a) Broadwell (BDW) (b) Skylake X (SKX)
Figure 7. ECM and Roofline model predictions based on layer conditions, with benchmark results
for 3D/1r/heterogenous/box/constant/double stencil on Broadwell and Skylake X architectures.
double a[M][N][P], b[M][N][P], W[27][M][N][P];
for ( int k = 1; k < M - 1; ++k) {
for ( int j = 1; j < N - 1; ++j) {
for ( int i = 1; i < P - 1; ++i) {
b[k][j][i] = W[0][k][j][i] - a[k][j][i]
+ W[1][k][j][i] - <sup>a[k-1][j-1][i-1]</sup> <sup>+</sup> <sup>W[2][k][j][i]</sup> - <sup>a[k][j-1][i-1]</sup>
+ W[3][k][j][i] - <sup>a[k+1][j-1][i-1]</sup> <sup>+</sup> <sup>W[4][k][j][i]</sup> - <sup>a[k-1][j][i-1]</sup>
+ W[5][k][j][i] - <sup>a[k][j][i-1]</sup> + W[6][k][j][i] - <sup>a[k+1][j][i-1]</sup>
+ W[7][k][j][i] - <sup>a[k-1][j+1][i-1]</sup> <sup>+</sup> <sup>W[8][k][j][i]</sup> - <sup>a[k][j+1][i-1]</sup>
+ W[9][k][j][i] - <sup>a[k+1][j+1][i-1]</sup> <sup>+</sup> <sup>W[10][k][j][i]</sup> - <sup>a[k-1][j-1][i]</sup>
+ W[11][k][j][i] - a[k][j-1][i] + W[12][k][j][i] - a[k+1][j-1][i]
+ W[13][k][j][i] - a[k-1][j][i] + W[14][k][j][i] - a[k+1][j][i]
+ W[15][k][j][i] - a[k-1][j+1][i] + W[16][k][j][i] - a[k][j+1][i]
+ W[17][k][j][i] - a[k+1][j+1][i] + W[18][k][j][i] - a[k-1][j-1][i+1]
+ W[19][k][j][i] - a[k][j-1][i+1] + W[20][k][j][i] - a[k+1][j-1][i+1]
+ W[21][k][j][i] - a[k-1][j][i+1] + W[22][k][j][i] - a[k][j][i+1]
+ W[23][k][j][i] - a[k+1][j][i+1] + W[24][k][j][i] - a[k-1][j+1][i+1]
+ W[25][k][j][i] - a[k][j+1][i+1] + W[26][k][j][i] - a[k+1][j+1][i+1];
}}}
Listing 3. 3D stencil code with radius 1, variable hetero-geneous coefficients, box structure and
double datatype.
OSACA project [20]. Beyond _N_ _≈_ 400 <sup>3</sup>, data transfers become more dominant and slow down the
execution, as qualitatively predicted by the ECM model. Roofline sticks with the 60 cy/CL, because
no single memory level surpasses them. In light of the discrepancy between modeled and measured
performance, the graph can not be used to guide performance optimization, but it sheds light on
the IACA misprediction at hand.
For Skylake, simple spatial blocking with _N_ <sup>1</sup> <sup>_/_</sup> <sup>3</sup>
block <sup>_<_</sup> <sup>400</sup> <sup>is</sup> <sup>advisable.</sup> <sup>Temporal</sup> <sup>blocking</sup> <sup>would</sup>
not yield better results, because of the hard _T_ comp limit.
## 5. How to Make Use of INSPECT
When developing stencil-driven applications and especially when publishing performance results
based on stencil codes, authors have to compare to a suitable, well-understood baseline. In order
to make use of INSPECT in this context, the user must first classify their stencil according to our
scheme and select a microarchitecture and CPU model from the INSPECT website that is similar
or identical to their own. If that is not possible, INSPECT provides the toolchain and automation
to compile a new baseline for future reference.
Depending on the programming language and software architecture, stencil patterns in applica
tions may be hidden under several abstraction layers but come to light during detailed performance
analysis. It is also the user’s task to isolate the stencil code in order to be able to measure its
performance. This may be done either “in situ” via suitable instrumentation or by writing a proxy
application that only performs stencil updates. Once a stencil is classified and a comparison is
established, optimization strategies may be guided by the INSPECT ECM model report: Spatial
blocking should bring the performance of large data sets on the level of smaller data set sizes by
better use of caches (moving to a plateau left in the plots), whereas temporal blocking strategies
eliminate data transfers to lower memory hierarchy levels (peeling off layers in the stacked ECM
plot contributions).
If the measured stencil performance in the application code does not coincide with the INSPECT
data and model at least qualitatively, as seen in Sec. 4.4, the culprit is usually the compiler not
generating efficient code, but other scenarios are possible: specific hardware features in the user’s
benchmarking setup (e.g., different DIMM organization), unfavorable system settings (e.g., small OS
pages, uncontrolled clock speed, Cluster-on-Die settings, disabled prefetchers), simple benchmarking
mistakes such as wrong or no thread affinity, etc.. Whatever the reason, it will be worth investigating,
which usually leads to better insight.
## 6. Related Work
Our work comprises three parts: stencil classification and generation with STEMPEL, bench
marking and modeling with Kerncraft, and presentation and publication of results on the INSPECT
website.
Collecting and presenting benchmark results is a common approach for a variety of reasons. To
name a few examples:
_•_ The TOP500 [25] ranks the performance of HPC systems world-wide based on the High
Performance LINPACK [4] benchmark performance.
_•_ The HPCG benchmark [5] takes the same approach as the TOP500, with a different bench
mark.
_•_ SPEC [27] has a spectrum of benchmarks suites for different aspects and allows its members
to publish the results on their website. Their suites come with real applications embedded
as test cases. They produce detailed reports on the runtime environment, with the goal of
comparing the performance of systems.
_•_ The STREAM benchmark [24] is the de facto standard for measuring main memory band
width. The website has results for machines in tabulated form.
_•_ The HPC Challenge Benchmark Suite [21] combines multiple benchmarks and allows users to
publish results through HPCC’s website.
All of these benchmark collections are focused on comparing machine performance by a set of pre
defined benchmarks, which is extremely valuable for purchasing decisions and as a reference for
researchers and developers. In contrast, we try to explain the observed performance based on the
characteristics of the stencil structure, which is usually defined by the underlying model and dis
cretization. This makes it more informative and adaptable for a particular developer to compare and
explain their own code’s performance with similarly structured reference implementations provided
by our framework.
The Ginkgo Performance Explorer [2] focuses on presenting performance data gathered by
automatic benchmarks as part of a continuous integration (CI) pipeline. This project is generically
applicable to other workflows, but lacks the focus on a specific field to allow the fine grained
presentation of model predictions and measurements as is done by INSPECT, nor does it comprise
any modeling component.
Methodologies for performance analysis most often fall into the category of performance models,
such as the already mentioned ECM and Roofline models. Their application to specific stencils
or stencil-based algorithms was at the focus of intense research [3, 7, 18, 22, 26]. Our concept
goes beyond these approaches in that it enables easy reproduction of performance numbers and
encourages discussion via an open workflow.
Datta et al. published a study of a stencil kernel on multiple architectures in 2009 [3]. It is based
on the same modeling principles but does not provide a unified process and presentation reusable
for other kernels.
## 7. Conclusion and Outlook
We have presented a comprehensive code generation, performance evaluation, modeling, and
data presentation framework for stencil algorithms. It includes a classification scheme for stencil
characteristics, a data collection methodology, automatic analytic performance modeling via ad
vanced tools and a publicly available website that allows to browse results and models across a
variety of processor architectures in a convenient way.
The presented baseline performance and model data provides valuable insight and points of
comparison for developers who have to write performance critical stencil code. The automatic spa
tially optimized version is given as an optimization example. INSPECT already contains a large
range of different stencil parameters and will be continuously extended to eventually comprise a full
coverage of the parameter space. To this end, we plan on optimizing the tool chain to reduce the
total runtime considerably. The choice of an analytic performance model over machine learning was
deliberate as not only prediction but also insight into bottlenecks is desired.
Kerncraft support of non-Intel architectures is still rudimentary. Support for AMD’s latest x86
implementations is already available and we have presented its preliminary use, while ARM will
require more effort but is on our shortlist of upcoming features. These additions will be integrated
into future updates of the INSPECT website.
An interesting spin-off of this work would be the integration of more web-enabled tools, such
as the layer-condition analysis [10], into INSPECT to allow users to interactively analyze their own
code. Compiler explorer [8] would be one potential tool to inspect compiler behavior for different
architectures.
A generalization from stencils to dense linear algebra and streaming kernels is straightforward
from Kerncraft’s perspective, but the classification scheme would have to be extended.
## Acknowledgements
The authors gratefully acknowledge funding of the German Federal Ministry for Education
and Research (BMBF) via the SeASiTe, SKAMPY, and METACCA projects. We are thankful for
support by the Bavarian Competence Network for Scientific High Performance Computing (KON
WIHR).
_This paper is distributed under the terms of the Creative Commons Attribution-Non Commercial_
_3.0_ _License_ _which_ _permits_ _non-commercial_ _use,_ _reproduction_ _and_ _distribution_ _of_ _the_ _work_ _without_
_further_ _permission_ _provided_ _the_ _original_ _work_ _is_ _properly_ _cited._
## References
1. Abel, A., Reineke, J.: uops.info: Characterizing Latency, Throughput, and Port Usage of
Instructions on Intel Microarchitectures. In: ASPLOS (April 2019)
2. Anzt, H., Cojean, T., Flegar, G., Gr¨utzmacher, T., Nayak, P., Ribizel, T.: An Automated
Performance Evaluation Framework for the GINKGO Software Ecosystem. In: 90th Annual
Meeting of the International Associaten of Applied Mathematics and Mechanics. GAMM (2019)
3. Datta, K., Kamil, S., Williams, S., Oliker, L., Shalf, J., Yelick, K.: Optimization and Per
formance Modeling of Stencil Computations on Modern Microprocessors. SIAM Review 51(1),
129–159 (2009), DOI: [10.1137/070693199](http://dx.doi.org/10.1137/070693199)
4. Dongarra, J.: The LINPACK Benchmark: An Explanation. In: Proceedings of the 1st Interna
tional Conference on Supercomputing. pp. 456–474. Springer-Verlag, London, UK, UK (1988),
[http://dl.acm.org/citation.cfm?id=647970.742568](http://dl.acm.org/citation.cfm?id=647970.742568)
5. Dongarra, J., Heroux, M.A., Luszczek, P.: High-performance conjugate-gradient benchmark: A
new metric for ranking high-performance computing systems. The International Journal of High
[Performance Computing Applications 30(1), 3–10 (Aug 2015), DOI: 10.1177/1094342015593158](http://dx.doi.org/10.1177/1094342015593158)
6. Fog, A.: 4. Instruction tables (Sep 2018), [https://www.agner.org/optimize/](https://www.agner.org/optimize/instruction_tables.pdf)
[instruction_tables.pdf](https://www.agner.org/optimize/instruction_tables.pdf)
7. Ghysels, P., Vanroose, W.: Modeling the Performance of Geometric Multigrid Stencils on Multi
core Computer Architectures. SIAM Journal on Scientific Computing 37(2), C194–C216 (2015),
DOI: [10.1137/130935781](http://dx.doi.org/10.1137/130935781)
8. Godbolt, M.: Compiler Explorer (2019), [https://godbolt.org/](https://godbolt.org/)
9. Guerrera, D.: STEMPEL: Stencil TEMPlate Engineering Library (2019), [https://github.](https://github.com/RRZE-HPC/stempel)
[com/RRZE-HPC/stempel](https://github.com/RRZE-HPC/stempel)
10. Hammer, J.: Layer Conditions: Interactive Web Calculator (2017), [https://rrze-hpc.](https://rrze-hpc.github.io/layer-condition/)
[github.io/layer-condition/](https://rrze-hpc.github.io/layer-condition/)
11. Hammer, J.: pycachesim: [Python Cache Hierarchy Simulator (2018), https://github.com/](https://github.com/RRZE-HPC/pycachesim)
[RRZE-HPC/pycachesim](https://github.com/RRZE-HPC/pycachesim)
12. Hammer, J.: asmbench: A Benchmark Toolkit for Assembly Instructions Using the LLVM JIT
(2019), [https://github.com/RRZE-HPC/asmbench](https://github.com/RRZE-HPC/asmbench)
13. Hammer, J., Eitzinger, J., Hager, G., Wellein, G.: Kerncraft: A Tool for Analytic Perfor
mance Modeling of Loop Kernels. Tools for High Performance Computing 2016 pp. 1–22 (2017),
DOI: [10.1007/978-3-319-56702-0](http://dx.doi.org/10.1007/978-3-319-56702-0_1) ~~1~~
14. Hirsch, I., S., G.: [Intel Architecture Code Analyzer (Nov 2017), https://software.intel.](https://software.intel.com/en-us/articles/intel-architecture-code-analyzer)
[com/en-us/articles/intel-architecture-code-analyzer](https://software.intel.com/en-us/articles/intel-architecture-code-analyzer)
15. Hofmann, J., Alappat, C.L., Hager, G., Fey, D., Wellein, G.: Bridging the Architecture Gap:
[Abstracting Performance-Relevant Properties of Modern Server Processors, https://arxiv.](https://arxiv.org/abs/1907.00048)
[org/abs/1907.00048,](https://arxiv.org/abs/1907.00048) submitted.
16. Hofmann, J., Hager, G., Fey, D.: On the Accuracy and Usefulness of Analytic Energy Models
for Contemporary Multicore Processors. In: Yokota, R., Weiland, M., Keyes, D., Trinitis,
C. (eds.) High Performance Computing. pp. 22–43. Springer International Publishing, Cham
(2018), DOI: [10.1007/978-3-319-92040-5](http://dx.doi.org/10.1007/978-3-319-92040-5_2) ~~2~~
17. Hofmann, J., Hager, G., Wellein, G., Fey, D.: An Analysis of Core- and Chip-Level Architectural
Features in Four Generations of Intel Server Processors. In: Kunkel, J.M., Yokota, R., Balaji, P.,
Keyes, D. (eds.) High Performance Computing. pp. 294–314. Springer International Publishing,
Cham (2017), DOI: [10.1007/978-3-319-58667-0](http://dx.doi.org/10.1007/978-3-319-58667-0_16) ~~1~~ 6
18. Hornich, J., Pflaum, C., Hager, G.: Efficient optical simulation of nano structures in thin-film
solar cells. Computational Optics II (May 2018), DOI: [10.1117/12.2312545](http://dx.doi.org/10.1117/12.2312545)
19. Intel Corporation: Intel _⃝_ R 64 and IA-32 Architectures Optimization Reference Manual
(April 2019), [https://software.intel.com/sites/default/files/managed/9e/](https://software.intel.com/sites/default/files/managed/9e/bc/64-ia-32-architectures-optimization-manual.pdf)
[bc/64-ia-32-architectures-optimization-manual.pdf](https://software.intel.com/sites/default/files/managed/9e/bc/64-ia-32-architectures-optimization-manual.pdf)
20. Laukemann, J., Hammer, J., Hofmann, J., Hager, G., Wellein, G.: Automated Instruction
Stream Throughput Prediction for Intel and AMD Microarchitectures. In: 2018 IEEE/ACM
Performance Modeling, Benchmarking and Simulation of High Performance Computer Systems
(PMBS). pp. 121–131 (Nov 2018), DOI: [10.1109/PMBS.2018.8641578](http://dx.doi.org/10.1109/PMBS.2018.8641578)
21. Luszczek, P., Luszczek, P., Dongarra, J.J., Koester, D., Rabenseifner, R., Lucas, B., Kepner, J.,
Mccalpin, J., Bailey, D., Takahashi, D.: Introduction to the HPC Challenge Benchmark Suite
(2005), DOI: [10.1.1.112.1817](http://dx.doi.org/10.1.1.112.1817)
22. Malas, T., Hager, G., Ltaief, H., Stengel, H., Wellein, G., Keyes, D.: Multicore-Optimized Wave
front Diamond Blocking for Optimizing Stencil Updates. SIAM Journal on Scientific Computing
37(4), C439–C464 (2015), DOI: [10.1137/140991133](http://dx.doi.org/10.1137/140991133)
23. Malas, T.M., Hager, G., Ltaief, H., Keyes, D.E.: Multidimensional Intratile Parallelization for
Memory-Starved Stencil Computations. ACM Trans. Parallel Comput. 4(3), 12:1–12:32 (Dec
2017), DOI: [10.1145/3155290](http://dx.doi.org/10.1145/3155290)
24. McCalpin, J.D.: Memory Bandwidth and Machine Balance in Current High Performance
Computers. IEEE Computer Society Technical Committee on Computer Architecture (TCCA)
Newsletter pp. 19–25 (Dec 1995)
25. Meuer, H.W., Strohmaier, E., Dongarra, J., Simon, H.D.: The TOP500: History, Trends, and
Future Directions in High Performance Computing. Chapman & Hall/CRC, 1st edn. (2014)
26. Sch¨afer, A., Fey, D.: A Predictive Performance Model for Stencil Codes on Multicore CPUs.
High Performance Computing for Computational Science - VECPAR 2012 pp. 451–466 (2013),
DOI: [10.1007/978-3-642-38718-0](http://dx.doi.org/10.1007/978-3-642-38718-0_40) ~~4~~ 0
27. SPEC: Standard Performance Evaluation Corporation (March 2019), [https://www.spec.](https://www.spec.org)
[org](https://www.spec.org)
28. Stengel, H., Treibig, J., Hager, G., Wellein, G.: Quantifying Performance Bottlenecks of Stencil
Computations Using the Execution-Cache-Memory Model. Proceedings of the 29th ACM on
International Conference on Supercomputing - ICS ’15 (2015), DOI: [10.1145/2751205.2751240](http://dx.doi.org/10.1145/2751205.2751240)
29. Treibig, J., Hager, G., Wellein, G.: LIKWID: A Lightweight Performance-Oriented Tool Suite
for x86 Multicore Environments. In: 2010 39th International Conference on Parallel Processing
Workshops. pp. 207–216 (Sep 2010), DOI: [10.1109/ICPPW.2010.38](http://dx.doi.org/10.1109/ICPPW.2010.38)
30. Williams, S., Waterman, A., Patterson, D.: Roofline. Communications of the ACM 52(4), 65
(Apr 2009), DOI: [10.1145/1498765.1498785](http://dx.doi.org/10.1145/1498765.1498785)
섹션 본문
섹션 본문이 없습니다.
참고문헌
참고문헌 정보가 없습니다.