---
title: "Stateful Dataflow Multigraphs — paper by Ben-Nun et al. (2019)"
description: "Stateful dataflow multigraphs let engineers tune how scientific programs move data on CPUs, GPUs, and FPGAs while keeping the source intact."
canonical: "https://research.elamur.ai/free/en/papers/ben-2019-nun-stateful-dataflow-multigraphs-data-centric/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/ben-2019-nun-stateful-dataflow-multigraphs-data-centric/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2019](https://md.research.elamur.ai/free/en/papers/2019/) / Stateful Dataflow Multigraphs: A Data-Centric Model for Performance Portability on Heterogeneous Architectures

# Stateful Dataflow Multigraphs: A Data-Centric Model for Performance Portability on Heterogeneous Architectures

Paper · 2019 · Tal Ben-Nun, Johannes de Fine Licht, Alexandros Nikolaos Ziogas et al.

**Authors:** [Tal Ben-Nun](https://md.research.elamur.ai/free/en/authors/tal-ben-nun/), Johannes de Fine Licht, Alexandros Nikolaos Ziogas, Timo Schneider and [Torsten Hoefler](https://md.research.elamur.ai/free/en/authors/torsten-hoefler/) · **Year:** 2019 · **Venue:** arXiv:1902.10345 · **Licence:** [arXiv — non-exclusive license to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

Cited by **25** papers in our library of more than 163,000 papers whose bibliographies we read · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/1902.10345)
- [arXiv 1902.10345](https://arxiv.org/abs/1902.10345)

## Summary

A scientific calculation can stay the same when it moves from a CPU to an accelerator, yet getting it to run well can require a substantial rewrite. The new device may need a different array layout, a different way of dividing work, or an explicit plan for transferring data. Ben-Nun and colleagues ask whether an engineer can make those changes while the scientist continues to work with a single version of the calculation. Their answer is the stateful dataflow multigraph, or SDFG, a program representation that makes data movement visible and editable. The authors implement it in DaCe, an open-source programming and compilation environment.

An SDFG represents computation at two levels. Within a state, it shows where data lives, which operations use it, and which portions of an array or stream pass between them. An operation can run once its inputs are ready, so independent work can proceed concurrently. Between states, conditional transitions express loops and decisions that depend on values produced during execution. The combination lets the same representation describe regular computations, such as repeated updates to a grid, and irregular ones, such as a search whose next round depends on the vertices it just discovered.

The authors lower scientific code into this graph and then tune the graph through rewrites. A rewrite can introduce a local buffer, change where a block of work runs, or eliminate an intermediate array whose contents can go straight to their destination. The operations that perform the calculation remain intact. Engineers can choose and parameterize rewrites through a graphical interface or a programming interface, and the compiler translates the resulting graph into code for the target device. The design puts the practical work of performance tuning into a representation that engineers can inspect, modify, and reuse.

The evaluation covers general benchmark programs, common kernels, graph search, and part of a quantum-transport simulator. Tuned CPU matrix multiplication reaches ∼98.6% of Intel MKL’s performance. The corresponding library comparisons are less favorable on the GPU. For multiplication of 1024 × 1024 matrices on an FPGA, DaCe takes 45 ms against the 878 ms reported for Spatial on the same chip. In the quantum-transport case, DaCe takes 29.93 s to compute scattering self-energies for a 4,864 atom nanostructure, a reported 32.26× speedup over the existing OMEN implementation of that calculation.

The experiments show that a shared scientific source can support substantially different implementations, with competitive performance on the tested hardware. They also show where the engineering effort goes. An initial graph can expose enough parallelism to perform well by itself, while the strongest results depend on how engineers order rewrites, choose parameters, and adapt data movement to a particular workload.

## Deep dive: Stateful Dataflow Multigraphs: A Data-Centric Model for Performance Portability on Heterogeneous Architectures

Stateful dataflow multigraphs let engineers tune how scientific programs move data on CPUs, GPUs, and FPGAs while keeping the source intact. · about 37 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Why moving a program can change its performance

The paper starts from a shift in the work of high-performance computing. A programmer used to be able to concentrate much of the parallelization effort on communication between nodes. As the authors describe it, a node itself became a more complicated target once many-core processors, graphics accelerators, and reconfigurable devices became common. A program now has to make good use of the equipment inside the node as well as divide work across nodes. The paper illustrates the change with OpenMP. Its specification grew from 63 pages in OpenMP 1.0 to 666 pages in OpenMP 5.0. The length of a specification is an illustration of the expanding interface a programmer might face. The performance problem itself is what the authors examine through [GPU and parallel computing](https://md.research.elamur.ai/free/en/topics/gpu-parallel-computing/) and the other hardware targets.

Consider matrix multiplication. The mathematical description says which products contribute to each output entry. It leaves open how the implementation groups those products, how it arranges the inputs in memory, and how long it can keep a useful piece of an input close to the units that need it. Those choices affect whether a processor reuses recently loaded data or fetches it again. They also affect whether groups of operations can run together efficiently. A new architecture can change the best answers to these questions even when the arrays and the arithmetic are identical.

The authors treat data locality as a common concern across their targets. Caches and registers offer places to retain values on a CPU. Accelerator code may also need to arrange transfers between the host and device or among levels of device memory. Reconfigurable hardware can express a computation as processing elements connected by streams. The mechanisms differ, but in each case the engineer needs to know which values a piece of work uses and how those values reach it. The paper takes the cost of moving data, in time and energy, as its motivation for representing those details explicitly. The experiments that follow measure performance.

#### The cost of keeping a fast implementation

Specialized libraries already offered a way for scientists to benefit from expert optimization. A library call can cover dense linear algebra, for example, without requiring the caller to maintain a tuned implementation. The difficulty rises when a calculation crosses library boundaries or when the available routines handle a different access pattern from the one the application needs. The paper describes a common response in which a performance engineer rewrites some of the original program in a lower-level language or a device-specific programming system. The tuned version then becomes another implementation that has to evolve when the scientific code changes.

Directives offer a different division of labor. In the authors’ account, OpenMP and OpenACC annotations can preserve the recognizable shape of the scientific source. Some directives, however, supply information about data placement or about how concurrent contributions should be combined. A change to the calculation can invalidate that information. The paper’s concern is maintenance across two kinds of expertise. The person changing the scientific operation needs to know which performance annotations depend on its old behavior, and the person repairing the annotations needs to locate that dependency.

The authors use *performance portability* in a stronger sense than the ability to compile or run on multiple devices. The scientist’s description should remain recognizable and stable, and the generated implementation on each device should compare well with an appropriate reference for that device. That reference can be the best implementation the authors know or a hardware performance limit. CPU and GPU runtimes can differ even in a successful port. The question is how effectively each implementation uses the hardware available to it.

The proposed workflow gives the scientist and the performance engineer a common representation to work from. The scientist defines the computation in a familiar source language, and the engineer works on the graph produced from it. This division has a condition. An edit that changes the way a calculation accesses data can alter the graph on which an optimization depends. The authors expect rewrite sequences to survive scientific changes that preserve the relevant dataflow. That expectation makes the graph interface important. It has to disclose enough about data use for a rewrite to check what it depends on.

#### What earlier systems already separated

The paper places DaCe alongside tools that already distinguish the computation from decisions about execution. In Halide, an image-processing pipeline specifies the operations, and a separately written schedule determines choices such as tiling, vectorization, and parallel execution. CHiLL lets users describe sequences of loop transformations in scripts that are combined with the program to produce optimized code. Tiramisu similarly offers operations for arranging loops and data. SPIRAL uses rewrite rules to derive optimized implementations from a specification of a computational kernel. These systems establish several ways to express performance choices outside the primary description of the arithmetic.

Legion supplies another close comparison. Its logical regions describe sets of accesses so that the system can reason about task dependencies and schedule work asynchronously. The authors relate those regions to the array subsets carried by SDFG edges. In their comparison, Legion uses the regions to infer the movement implied by tasks, while SDFGs give movement its own edges and attributes. Kokkos and RAJA expose parallel operations with execution policies for supported architectures. The paper also discusses separation of computation and accesses in systems from other application areas, including [TensorFlow](https://md.research.elamur.ai/free/en/papers/abadi-2016-tensorflow-system-large-scale-machine/).

A separate line of earlier work represents programs using graphs. LLVM organizes control flow into basic blocks, and the operations in a block can be represented as an acyclic dataflow graph. A program dependence graph connects statements and tests with data and control dependencies. The authors argue that those representations can lose the grouping needed to discuss a repeated operation and its memory footprint as a unit. In their comparison, an indirect read can look like a dependence on an entire array in a program dependence graph, whereas an SDFG can record the broad region containing the possible indices and still describe how much data an individual access moves. HPVM adds hierarchical dataflow for accelerators. The paper distinguishes its own approach by combining that kind of hierarchy with explicit state transitions and higher-level data movement.

The two-level structure also responds to a tension the authors identify between stateless dataflow and ordinary sequential code. Dataflow expresses independence naturally because work becomes ready when its inputs are available. Repeated or conditional execution needs an additional way to say when the program returns to a computation or chooses another one. In the SDFG, the inner graph answers the dependency question within a stage, while the outer state machine answers what the program does after that stage has finished. The performance engineer can inspect either level and can change the organization of one without treating every operation in the other as a separate editing problem.

### The method, step by step

#### Start with the scientific operation

DaCe begins with a program that describes the calculation and its data. The paper presents frontends for restricted Python, MATLAB, and TensorFlow, together with a builder interface for constructing graphs from other languages. Its main example of source programming uses decorated Python functions with typed array arguments. The functions can interact with existing code through arrays, and supported NumPy operations can supply graph structure directly. A matrix multiplication written with the array multiplication operator, for example, lowers to a graph for that operation.

The authors illustrate the workflow with a Laplace operator over a line of values. The scientific operation computes an output using neighboring input values. When that operation is expressed as a graph, it becomes possible to distinguish the values that an individual update needs from the region needed by a whole group of updates. A performance engineer can use the larger view to decide what to bring into local storage and the smaller view to retain the relationship between each output and its inputs. The example explains why the graphs have scopes. Simply listing the loads performed by each individual update would make the collective access pattern harder to see.

Size information can remain symbolic. An input array can have a dimension represented by a name whose value is supplied when the program is invoked. The same symbol can occur in the bounds of a parallel range and in the subset of an array that a computation accesses. The authors extend SymPy to handle the expressions and types used in DaCe. Symbolic sizes let a rewrite describe a family of graphs or specialize a particular case when a concrete size matters for tuning.

From scientific source to an executable DaCe library The steps in order.

The input to this procedure is source code and its description of data access. During tuning, measurements from running generated code can inform decisions about graph changes. DaCe also provides ways to extend the Python frontend. A program can supply a graph implementation of an unsupported operation. A call without such an implementation can sometimes fall back to Python, with array pointers exposed as NumPy arrays and a warning about potential slowdown. Unsupported syntax can instead fail during translation. The paper’s compiler therefore has a defined graph-building vocabulary even when the source resembles ordinary Python.

#### Separate storage, work, and movement

The formal definition gives the complete program an outer graph.

```
G = (S, T, s₀)
```

Here G is the SDFG, S is the collection of states, T is the collection of directed transitions, and s₀ is the designated entry state. The parentheses group the fields of the definition. More than one transition can connect the same pair of states, which makes the outer graph a multigraph. Its transitions can form cycles, so execution can return to a state.

A state has a separate graph of its own.

```
s = (V, E, name)
```

Here s denotes a state belonging to S, V is the set of nodes inside it, and E is the set of directed edges between those nodes. The field `name` identifies the state. The inner graph is acyclic. An execution can repeat work by returning through the outer state machine or by invoking a nested graph where the program needs local control flow.

The basic storage nodes represent arrays and streams. An array node identifies typed memory and carries its dimensions. A stream node represents an array of queues that can be pushed to and popped from concurrently. A node’s storage attribute specifies where the container lives. Depending on the target, an edge between containers can generate a copy, and an inaccessible source or destination can make a placement invalid. On FPGA hardware, a stream can give rise to a first-in, first-out interface between hardware modules.

A container may be transient. DaCe allocates such storage for the execution rather than receiving it as externally owned memory from the caller. This gives a rewrite room to change the layout of a temporary or remove it if all its uses permit that change. The distinction matters when a buffer is visible beyond the part of the program being tuned. The formal definition also requires differently named data nodes to refer to memory that does not alias. In other words, those names cannot secretly lead to overlapping storage whose updates would escape the graph’s account of dependencies.

A tasklet is a node that performs a local computation. Its connectors are named points where inputs arrive and outputs leave. The code inside uses those interfaces for access to outside data. A small tasklet might multiply values brought in on two connectors and place the product on an output connector. The graph can move the tasklet into a different schedule or feed it from a different buffer while preserving that operation. Tasklets can also have a larger granularity. The paper shows an external BLAS call expressed as a tasklet with declared array accesses, so an existing library can provide the computation while DaCe manages its place in the wider graph.

The edge annotation that specifies a movement is called a *memlet*. Its formal fields distinguish where the movement happens, which data it carries, and how the receiver interprets it.

```
(src_conn, dst_conn, subset, reindex, accesses, wcr)
```

Here `src_conn` and `dst_conn` are the connectors at the sending and receiving ends of the edge. The `subset` field selects the part of the source visible to the movement. The `reindex` field gives the receiving coordinates for those elements. The `accesses` field describes how many elements move, which can inform performance analysis. The optional `wcr` field specifies what happens when contributions meet at the same destination. The paper represents subsets and reindexing through integer sets, with per-dimension ranges that can express a start, an exclusive end, a stride, and a tile size. The tile size lets a range describe movements involving groups of elements, such as vector accesses.

Separating the subset from the access count is especially important for indirect reads. In sparse matrix–vector multiplication, a stored column number determines which element of the vector to fetch. Before looking up that column number, the program may only know that the selected element lies somewhere in the vector. The graph can show the read that obtains the column index, the larger region available to the indirect access, and the fact that the individual access takes one element from that region. DaCe lowers the indirection to a subgraph that exposes those pieces, with a tasklet making the dynamic selection. A rewrite can recognize the subgraph as an indirect access pattern.

The sparse example in the paper uses compressed sparse row storage. The array of row offsets marks the start and end of the stored entries belonging to each row. Separate arrays supply a value and a column index for each such entry. Written as a row sum, the operation in the graph is:

```
b[i] = Σⱼ A_val[j] × x[A_col[j]],  A_row[i] ≤ j < A_row[i + 1]
```

Here b is the output vector and i selects its row. The summation symbol Σ collects the products over entries indexed by j. `A_val[j]` supplies the stored matrix value, and `A_col[j]` supplies its column, which indexes the input vector x. The multiplication sign combines the two terms for each entry. `A_row[i]` and `A_row[i + 1]` are the offsets delimiting the row, with the next row’s starting offset excluded. The subscripts of Σ and the square brackets indicate the summation variable and the indexed array accesses, respectively. The graph can span one range over rows and a separate, data-dependent range over the entries of each row.

#### Describe the work that can run concurrently

A *Map* encloses a subgraph and specifies a range of parallel instances. Entry and exit nodes mark the boundary of the enclosed work. In the authors’ formal description, a node in the scope is dominated by the entry and post-dominated by the exit. In practical terms, the paths into and out of the scope go through the corresponding boundary. This makes it possible to summarize what the entire scope needs from outside and what it produces for the rest of the graph.

In the sparse multiplication, the outer Map spans output rows. The inner Map spans whatever entries the current row contains. The bounds of the inner Map come from the row offsets, so different outer instances can create different amounts of work. The indices introduced by Maps are available inside their scopes for use in expressions such as array subsets. A Map can also enclose other storage or computation, which allows an engineer to work on a repeated pattern without duplicating a drawing for every instance.

The formal execution of a Map expands the enclosed graph over the range described by its symbols. That is the meaning of the graph, while the schedule determines how the expansion is realized. A CPU schedule can generate parallel OpenMP loop work. GPU schedules can assign ranges to the device grid and to work within thread blocks. An FPGA schedule can create separate hardware processing elements. The representation can also use Maps with streams to describe systolic arrays. In such an arrangement, a pattern of processing elements passes data through queues so that work can proceed as a pipeline. The example in the paper replicates the structure through the Map and uses streams to connect the processing elements.

A *Consume* scope serves a different kind of parallel work. It attaches workers to a stream whose contents can change as the computation runs. The scope has a termination condition describing when processing has reached quiescence. In the paper’s Fibonacci example, a starting value is pushed to a stream, workers process pending values, and the computation can enqueue further values. Its duration depends on the work generated during execution. A statically listed Map range would describe a different kind of iteration. DaCe implements consumption with asynchronous stream operations, including batched dequeue and atomic operations.

Concurrent writes require a rule when multiple instances contribute to the same element. A write-conflict resolution function receives the old value at the destination and the contribution that is about to arrive.

```
wcr: S × S → S
```

In this signature, `wcr` names the write-conflict resolution function, and S denotes the value type here. The symbol × means the function takes a pair of values of that type, and the arrow points to the type of the result. The first argument is the stored value and the second is the incoming contribution. The result is the value that is stored. In sparse matrix–vector multiplication, summation can combine products from the same row. The target and the chosen function determine whether the implementation uses an atomic operation, a critical section, or hardware that accumulates the contributions.

A Reduce node packages a related idea for reducing one or more axes of an array. In the formal account, it is equivalent to a Map over the relevant data, with a tasklet that passes the input through and a conflict resolution function on the outgoing movement. An explicit Reduce node can still have its own target-optimized implementation. This gives the graph rewriter a useful choice. A computation can first be expressed as a Map producing an array followed by a Reduce, and a later rewrite can combine them if the intermediate is dispensable.

#### Use states to express decisions and repetition

Readiness inside a state depends on data. In the operational rules, an element can be processed when the values it needs are visible at its input connectors. A memlet selects values and gives them their receiving indices. A tasklet receives its inputs in local variables, executes its code, and publishes its outputs at the appropriate connectors. A data node can write the visible elements into its underlying allocation. For a stream, readiness also depends on whether a pop has an element available. As elements are processed, the pending work for that state is removed until the state is complete.

DaCe’s formal account keeps different kinds of information in the execution configuration. The mapping `loc` associates container names with memory locations, `sym` associates symbols with current values, and `vis` tracks the data visible at connectors. The memory store is denoted by M. At invocation, arguments identify data addresses or supply integer symbol values. The arguments initialize the applicable entries in `loc` and `sym`, and input data becomes visible at the relevant connectors. Execution starts from a working copy of the entry state. Queue sizes start at zero. These rules explain how the graph can use symbolic expressions while keeping the identity and contents of its containers distinct from the values of its scalar control variables.

Transitions carry their own information.

```
t = (source, destination, condition, assignments)
```

Here t denotes a transition in T. Its `source` and `destination` identify the states it connects. The `condition` is a test that can read symbols and data from the source state. The `assignments` specify new values for symbols. After a state completes, its outgoing conditions determine eligibility. The semantics permit selection of an enabled transition in arbitrary order. If none is enabled, the invocation completes. On a taken transition, the assignments update the symbol values for execution of the destination state.

This outer structure can express a loop with a symbolic iteration count, or it can let the values produced in one state determine where to go next. It can also appear inside a piece of parallel work. An Invoke node calls a nested SDFG with an explicit data interface. In the paper’s Mandelbrot example, a Map exposes per-pixel work and the nested graph handles the convergence loop for an individual pixel. The loop can take a different number of iterations for different pixels. The outer graph can retain the grouping of these independent calculations while the nested graph describes each calculation’s control flow. The paper disallows recursive calls to the same SDFG.

#### Rewrite the graph around the calculation

Once the frontend has produced the graph, DaCe gives the performance engineer two related jobs. The first is to identify an access or execution pattern that could be organized more efficiently. The second is to apply a rewrite whose conditions establish that the change is appropriate for this occurrence of the pattern. An engineer might recognize a buffer worth retaining near a computation, for instance, and then check that the affected graph can be reindexed so every use still sees the right values.

The formal description of a rewrite distinguishes a pattern graph, its replacement, and an occurrence of the pattern in the program.

```
p: L → R
```

Here p is a rewrite rule, L is the pattern subgraph on the left, and R is the replacement subgraph on the right. The arrow indicates the direction of the rewrite. The authors also use a relation r that maps vertices in L to vertices in R and edges in L to edges in R. This correspondence supplies the information needed to connect the replacement to the rest of the graph.

```
m: L → G
```

Here m is a match, L is the pattern, and G is the SDFG undergoing transformation. The arrow represents the relation that locates the pattern’s elements in G. DaCe uses the VF2 algorithm to find structurally matching subgraphs. A programmable test then checks the conditions specific to the transformation. A structural match may therefore be rejected where the rewrite would change an externally visible use or make an invalid assumption about the data.

```
⟨H, m′, r′⟩
```

Here H is the transformed graph. The angle brackets group the result with the induced relations m′ and r′. The first connects R to H, and the second connects the surviving structure of G to H. The primes distinguish these relations from the initial match m and correspondence r. The authors describe the construction in terms of a single pushout, an algebraic way to specify how the replacement and the remainder of the program form the new graph.

An example from the implementation removes a redundant temporary followed by another array. The small graph used for matching has a movement from one array access node to the next. A copy can have exactly that shape even when the first array has other uses, so the rewrite checks more than the connection. Among its checks are whether the first array is transient, whether the storage locations agree, and whether the first array appears elsewhere. Its strict case checks compatible shapes so the rewrite can avoid having to recompute symbolic subsets. When the conditions pass, upstream movements can be redirected to the destination and the redundant access node removed.

Another rewrite fuses a Map with a following Reduce when the intermediate array is available for elimination. Originally the computation writes products or other contributions to a temporary, and the reduction reads them from it. The replacement routes the values to the final destination with write-conflict resolution. A local-storage rewrite goes in the other direction by introducing a temporary on purpose. It creates a place to retain data near a group of operations and adjusts the downstream indices to address the new local region. Together these examples show why the authors make movements editable. Removing a copy and introducing a cache buffer are both dataflow changes, and which one helps depends on what the graph does with the data.

DaCe includes rewrites at several levels. Tiling divides a Map into ranges that can be grouped and scheduled. Double buffering allows processing from one buffer while another is being written. State fusion and inlining change the boundaries at which control flow is represented. Device transformations can introduce copies and change schedules to place work on an accelerator. The transformation library is extensible, so a domain-specific rewrite such as the tiling used for the Jacobi stencil can be added through the same interface as more widely applicable rewrites.

#### Inspect, compile, and measure

The authors provide a graphical environment called DIODE as well as a Python interface for selecting and applying transformations. DIODE can connect pieces of the original program to components of the SDFG and to the corresponding generated code. It can collapse parts of the graph, which helps an engineer focus on a region with a suspected bottleneck. An engineer can alter attributes, tune the arguments to a rewrite, run an implementation, and compare its performance with earlier versions. Transformation chains can be saved and can branch from a common graph when different targets require different choices.

Compilation starts with validation. The compiler checks the structure of scopes and memlets and checks that schedules and storage assignments describe feasible operations. It then propagates information about the accessed ranges from the inside of scopes to their boundaries. Conceptually, it takes the union of the accesses in a scope and maps them through the scope’s iteration range. The resulting description says what the whole scope needs, information the compiler can use to generate transfers between a host and an accelerator. This is a practical use of the hierarchy beyond making a graph easier to read.

Code generation starts with the external interface and the top-level state machine. Within a state, the compiler follows an order consistent with the edges and chooses code generators based on storage and schedule attributes. It continues into nested scopes and graphs, allowing different parts of the program to invoke different generators. The compiler emits structured loops and branches when it recognizes them in the transitions, with conditional jumps available as a fallback. Finally, DaCe invokes the appropriate compilers and exposes the resulting library to an application or to Python. A performance measurement can send the engineer back to the graph to revise a schedule or a transfer and repeat the process.

### Experiments and results

#### What the authors measure

The evaluation asks how much the initial graph representation delivers by itself and what engineers can achieve after rewriting it. PolyBench addresses the first question. The fundamental kernels and the case studies address the second, with comparisons that range from straightforward compiler-generated code to mature libraries and application-specific implementations. The data in these tests are arrays, graph inputs, and a simulated nanostructure. Each comparison is a measurement of a particular computation under specified hardware and workload conditions.

The server has an Intel 12-core Xeon E5-2650 v4 CPU clocked at 2.20GHz, with HyperThreading disabled and 64 GB of DDR4 memory. Its Tesla P100 GPU has 16 GB of HBM2 and connects to the host over PCI Express. The FPGA measurements use a Xilinx VCU1525 board with an XCVU9P device and DDR4 banks running at 2400 MT/s. The generated code is compiled with gcc 8 for the CPU, CUDA 9.2 for the GPU, and Xilinx SDAccel 2018.2 for the FPGA.

Under the general evaluation protocol, the authors perform 30 runs of the experiments and report the median runtime with memory copy time included. Error bars indicate a 95% confidence interval across the runs, and points identify outliers using Tukey fences at 1.5 IQR. PolyBench instead uses its supplied timing tool, which averages five runs. The fundamental kernels use single-precision floating point, while PolyBench uses its default types, predominantly double precision. The graph computation uses integers. The FPGA timings come from hardware execution after placement and routing, with simulation used in the PolyBench verification flow.

These details matter for interpreting the figures. Runtime captures the elapsed cost of executing the measured work, including transfers under the study’s protocol. A comparison against MKL, on the other hand, expresses the implementation’s performance relative to a library on that workload. Percent of hardware peak answers another question, especially when different implementations perform different amounts of arithmetic to produce the same result. The quantum-transport measurements report both kinds of information, which allows the authors to explain a runtime improvement that a peak percentage alone would obscure.

#### PolyBench before performance tuning

For PolyBench, the authors reimplement the kernels as SDFGs and use the Large dataset with the suite’s default flags. They omit the kernel-specific tuning rewrites. Accelerator runs still use the relevant automatic transformation to place the computation on a GPU or FPGA. They offload even cases in which the work contains little parallelism or looks unprofitable for the device. The study therefore tests broad coverage of the benchmark as well as generated performance.

The comparison includes ordinary compilers such as gcc, Clang, and ICC and tools that use polyhedral analysis or matching of computation patterns. Among the latter are Polly, Pluto, and the GPU-oriented PPCG. The appendix records flag variants and includes trials with compile-time specialization to the input size. The paper reports the best performance among the competing flag configurations it tries. The CPU and accelerator findings have different reference points, because a tool that optimizes loops for the CPU need not be the comparison used for a GPU kernel.

On the CPU, the authors find that the initial SDFGs generally run closer to the polyhedral implementations than to code produced by the general-purpose compilers. Cholesky and LU solvers and some basic linear algebra, including gemm, are among the cases closer to the ordinary compiler results. The authors point forward to the tuned matrix multiplication to show how much room those untuned results can leave. The initial graph exposes parallel work, while it can still produce a memory access pattern poorly suited to sustained reuse.

On the GPU, the SDFG implementations outperform PPCG in most of the reported cases. The `bicg` kernel is a standout at 11.8× faster than PPCG. The authors attribute the GPU outcomes to the parallel structure present in the graph and to avoiding unnecessary array copies where dependencies identify the data required. The study compares the outcome of whole compilation paths, so those explanations describe mechanisms available to the SDFG system. A separate test would be needed to estimate each mechanism’s share of the runtime improvement.

For the FPGA, the authors run the suite through automatic device mapping, check correctness using their simulation flow, and carry out placement and routing. They describe the result as the first complete placed-and-routed set of PolyBench kernels for an FPGA. That claim is about coverage of the suite. The dedicated FPGA kernel experiments use further transformations to make more effective use of the device.

#### The fundamental kernels

The tuned kernel study covers contrasting ways of using memory. Dense matrix multiplication uses two 2,048×2,048 matrices. The Jacobi calculation repeatedly applies a 5-point stencil on a 2,048 square domain for T = 1,024 iterations, with fixed zero values at the boundary. Here T is the number of iterations. A stencil uses values in a neighborhood to update an output location, and this workload applies the update repeatedly so that a later timestep uses earlier results. These kernels give the engineer regular index ranges with different opportunities for reusing data.

The other workloads stress less regular movement. Histogram counts values in bins across an 8,192 square image, with the input determining whether updates land in the same bin. Query filters a column of 67,108,864 elements, with the condition filtering roughly 50%. Sparse matrix–vector multiplication uses a square compressed sparse row matrix of dimension 8,192 with 33,554,432 non-zero entries. In that case the sequence of column indices determines which elements of the input vector are fetched. The workloads test more than the ability to generate a fast regular loop.

The applicable baselines vary by kernel and target. Conventional code is compiled with GCC, Clang, NVCC, or ICC. The CPU comparisons also use Intel MKL and HPX. On the GPU, the specialized comparisons include CUBLAS, CUSPARSE, and CUB, as well as a hybrid hexagonal tiling approach over PPCG for stencil work. The authors include automatically and manually tuned Halide implementations where applicable. On the FPGA, the reference points include the Xilinx high-level synthesis and SDAccel toolchain and a published Spatial result. Across the DaCe kernel experiments, the authors change the graph through data-centric rewrites while retaining the tasklet code.

Dense multiplication illustrates both strong and weaker comparisons. On the CPU, DaCe reaches ∼98.6% of Intel MKL’s performance. On the GPU, it reaches ∼70% of CUBLAS and ∼90% of CUTLASS. These are comparisons with different reference implementations on the GPU, and each percentage is relative to its named library. The FPGA implementation runs 4,992× faster than the naïve high-level synthesis implementation over SDAccel. That figure uses the naïve implementation as its reference, whereas the separate Spatial comparison below uses the reported runtime on the same FPGA chip.

FPGA matrix multiplication runtime for 1024 × 1024 matrices DaCe finishes faster than the runtime reported for Spatial on the same FPGA chip.

**The numbers**

| System or setting | ms |
| --- | --- |
| Spatial | 878 |
| DaCe (this paper) | 45 |

For those smaller FPGA matrices, the paper reports a 19.5× speedup for DaCe. The chart uses absolute runtime because it is available for both entries. The Spatial value comes from the earlier work, while the DaCe value comes from the authors’ measurement. That makes the provenance of this result different from a comparison in which both programs were rerun as part of the same experiment.

The sparse matrix–vector kernel reaches 99.9% of Intel MKL’s performance on the CPU, and the authors report successful vectorization on the GPU. The sparse row format makes this a different test from dense multiplication. Its arithmetic is straightforward, but the addresses of the vector loads depend on the stored column indices. For the histogram, DaCe achieves 8× the performance of gcc. The authors connect the improvement to vectorization and report that the other compilers in the comparison fail to vectorize the data-dependent accesses in that case.

The FPGA histogram uses 16 element vectors and distributes the work to 16 processing elements. Each processing element builds a separate histogram, after which a second stage merges the partial histograms on the device. Only then does the implementation copy the final result back. The paper reports a 10× hardware speedup for this arrangement. Keeping the partial accumulators separate during most of the computation is an example of choosing the movement and placement of intermediate results around the behavior of the hardware.

Query also uses streaming. On the CPU, the authors report better performance than HPX and the STL comparison. On the FPGA, the input is read in wide vectors, then a pipeline packs the values that pass the filter into dense output vectors. The kernel earns a reported 10× speedup there. The packing step matters because each group of input values can contain a different number of surviving elements. The resulting pattern is a stream of compact results even though the selected entries within each input group are irregularly placed.

For the Jacobi stencil, the authors use a domain-specific DiamondTiling transformation. On the CPU, they report 90× faster execution than Polly and a marginal advantage over Pluto, which uses related tiling. Halide obtains the fastest result in that comparison after all timesteps are written into the pipeline and its autotuner is used. The configured Halide result is 20% faster than DaCe, with compilation taking ∼68 minutes in the stateless representation described by the authors. The FPGA version organizes the updates as a systolic array and reaches 139 GOp/s. That figure measures operation throughput for the FPGA stencil, rather than an elapsed-time comparison with the CPU implementations.

#### Breadth-first search across graphs with different structure

The graph case study measures a push-based breadth-first search on a multicore CPU. Breadth-first search advances through a *frontier*, the set of vertices ready to be explored in the current round. A push implementation visits the outgoing neighbors of those vertices and contributes newly reached vertices to the next frontier. The graph input determines the amount of work in a round. Uneven vertex degrees and changes in the size of the frontier make it difficult to distribute work and coordinate writes efficiently.

The evaluation includes road networks, social networks, and a synthetic graph. The road graphs are USA and OSM-eur-k, the latter also referred to as osm-eur in the discussion. The USA graph has 24M nodes and 58M edges, with average degree 2.41. OSM-eur-k has 174M nodes and 348M edges, with average degree 2.00. These inputs test the search on large graphs where the number of neighbors of an individual vertex is relatively restrained in the datasets listed by the authors.

The social graphs are soc-LiveJournal1 and twitter. The twitter dataset has 51M nodes and 1,963M edges. Its average degree is 38.37, and the table lists a maximum degree of 779,958. The difference between average and maximum degree shows why a worker’s cost can depend heavily on the vertices it receives. The Kronecker input, `kron21.sym`, is the synthetic case. It has 2M nodes, 182M edges, and average degree 86.82. Running the same search across these inputs gives the authors a way to see whether an optimization is effective across different frontier and neighborhood patterns.

DaCe is compared with Galois and Gluon at 12 threads, with 1 thread per core. The authors use the default settings named in the paper, `SyncTile` for Galois and `bfs_push` for Gluon. They report broadly comparable performance across the graphs with differences by input. Galois is ∼1.53× faster on twitter and also leads on the Kronecker graph. On the road networks, DaCe is up to 2× faster than Galois. The authors suggest that the fine-grained scheduling afforded by Maps could contribute to the road-network result. The study measures the completed search implementations and does not isolate that proposed explanation.

#### Scattering self-energies in quantum transport

OMEN simulates quantum transport for applications such as estimating heat dissipation in nanoscale transistors. It is an established C++ and CUDA application using optimized linear algebra libraries. The DaCe case study targets the computation of scattering self-energies, a significant part of the simulator’s runtime. The paper focuses on the quantities labeled Σ with greater-than and less-than superscripts. The expression brings together small matrix multiplications and elementwise products, and sums contributions along parallel dimensions.

The initial SDFG makes those dimensions and their data uses visible. The authors split the computation into Maps, introducing temporary 5D and 6D arrays. They then rearrange dimensions and storage so that the small matrix multiplications can be submitted together through a strided batched CUBLAS call. Batching groups many products into one operation, and a strided layout positions successive matrices at regular offsets. The last rewrite replaces that call with a nested graph specialized for the small strided products. That nested implementation is tuned with the matrix dimensions and hardware cache sizes in mind.

The main comparison measures the scattering-self-energy computation for a 4,864 atom nanostructure. It includes the original OMEN calculation, a Python implementation using NumPy with MKL for its linear algebra, and the transformed DaCe implementation. These timings cover the targeted calculation within the simulation.

Scattering self-energy runtime for the 4,864 atom nanostructure The transformed DaCe implementation completes the calculation faster than OMEN and NumPy.

**The numbers**

| System or setting | s |
| --- | --- |
| OMEN | 965.45 |
| NumPy | 30,560.13 |
| DaCe (this paper) | 29.93 |

The reported DaCe speedup is 32.26× over OMEN and 1,021× over Python. The table assigns OMEN and Python 63.6 Tflop of work each and DaCe 31.8 Tflop. Its hardware utilization figures are 1.3% of peak for OMEN, 0.2% for Python, and 20.4% for DaCe. Elapsed time here reflects both how much arithmetic the implementation performs and how effectively the device executes that work. The distinction becomes clearer in the comparison of the batched multiplication alternatives.

The authors measure CUBLAS and the specialized DaCe multiplication on a P100 and a V100. On the P100, CUBLAS takes 6.73 ms and DaCe takes 4.03 ms. The reported V100 comparison is:

Strided matrix multiplication runtime on the V100 for the quantum-transport workload The specialized DaCe graph completes the strided batch faster than CUBLAS.

**The numbers**

| System or setting | ms |
| --- | --- |
| CUBLAS | 4.62 |
| DaCe SBSMM (this paper) | 0.97 |

The paper reports a speedup of up to 4.76× for the specialized multiplication. On the V100, CUBLAS executes 27.42 Gflop and reaches 84.8% of peak on that work, with 5.9% marked as useful peak performance for the problem. DaCe executes 1.92 Gflop and reaches 28.3% of peak. A high throughput on the larger body of work can coexist with a longer time to produce the result. This breakdown explains why the optimization includes a specialization of the nested operation as well as an improvement in how the larger calculation passes data to it.

### What the ablations show

#### Matrix multiplication improves through a sequence of changes

The paper’s most detailed analysis of transformations follows CPU matrix multiplication through a series of rewrites. The starting graph forms the pairwise products in a temporary tensor and reduces it to the output matrix. A Map–Reduce fusion removes the need for that large intermediate by letting values contribute directly to their destination through write-conflict resolution. This gives the engineer an accumulation pattern whose parallel iteration and memory accesses can be changed together.

The authors manually reorder the Map dimensions. They report a marginal improvement from the resulting change in movement. Subsequent tiling works at different levels. One tiling step creates pieces sized for the L3 cache, and another organizes work for vector registers. LocalStorage is used to pack tiles of one input and retain tiles of the output. Vectorization changes the accesses and generated instructions so that the machine can work with groups of values. The last change, ReducePeeling, expresses the inner conflict resolution as a state machine and peels the loop, separating a piece of that loop from the remaining repeated work.

The runtime trace shows that some steps yield little immediate benefit. A reorganization can still expose the structure a subsequent rewrite needs. That matters when judging a rewrite by compiling the graph immediately before and after it. The intermediate times describe one ordering of dependent changes, with some stages serving to make later ones possible. The authors report a ∼536x performance gain after 7 steps for the CPU case, reaching 75% of MKL, and 98.6% of MKL after tuning the transformation parameters for the tested size.

This is a cumulative analysis. It gives a concrete path from the original calculation to a competitive implementation and shows the effect of tuning the particular size after choosing that path. It leaves open what would happen with a different ordering, a different implementation of an individual transformation, or a final graph from which a single change had been removed. The measured benefit belongs to the resulting sequence and tuning configuration.

#### Search reveals the costs of the starting schedule

The breadth-first search case describes changes driven by two problems in the generated OpenMP implementation. Dynamic scheduling of the frontier gives a poor initial mapping of work to cores. The authors use MapTiling to group the work into tiles. The change acts on the frontier schedule while retaining the push-based computation. It illustrates how a graph with explicit ranges gives the engineer a place to intervene even when the total work is data-dependent.

Producing the next frontier also incurs atomic-operation overhead when concurrent updates go directly to the shared stream. The LocalStream rewrite accumulates contributions in a local stream and transfers them in bulk to the global frontier. LocalStorage applies the same principle of local accumulation to the frontier size. The central state of the resulting graph has 14 nodes once input and output data nodes are excluded. That count gives a sense of how much structure the representation uses to describe the tuned search stage.

The runtime comparison is for the combined transformed search. The account identifies concrete sources of overhead and the rewrites aimed at them, but supplies no independent timing for removing each rewrite from the final search. Across the datasets, the transformed search can lead on road networks while Galois leads on the twitter and Kronecker graphs. That variation is evidence that the input graph affects the relative performance of the complete implementations. It leaves the size of each scheduling and synchronization effect unresolved.

#### The untuned and specialized cases answer different questions

PolyBench provides a baseline for the graph representation with kernel-specific optimization omitted. Its stronger outcomes show that source-level parallel structure, explicit dependencies, and device mapping can already support competitive code on some inputs. Its weaker CPU linear algebra and solver outcomes show that the initial expression of work can leave substantial scope for tuning. The experiment intentionally includes kernels that are unpromising to offload, making it especially informative about what the mapping can express and compile.

The comparison between CUBLAS and the specialized DaCe multiplication is narrower. It holds the strided multiplication workload in view and measures each implementation on the named devices. DaCe’s improvement in elapsed time accompanies a reduction in executed arithmetic. That observation supports the decision to specialize the small-matrix stage for the quantum-transport workload. The larger scattering-self-energy improvement also includes splitting the surrounding calculation and reorganizing the data layout. Its final speedup measures those choices together. The multiplication experiment sheds light on one aspect of the result while leaving open how much of the overall application improvement came from switching libraries.

### Limitations

#### Limits the authors state

The current implementation concentrates on parallelism within a node. The authors discuss extending the approach across nodes, where moving less data would also mean communicating less. The transformation list includes an MPI mapping for a CPU Map, and the paper describes distributed execution as a direction for the approach. The measured cases concern the local CPU and accelerators. They do not establish performance portability for full scientific applications running across many nodes.

The workflow also relies on a performance engineer to select and order transformations. Matching and validity checks provide automation for applying a rule. Choosing an effective sequence and fitting its parameters to hardware are separate problems. The authors identify systematic selection of transformations as future work. They also suggest collecting information about tasklets, such as arithmetic intensity, to complement the movement information in memlets. The paper thus provides a representation, an extensible set of transformations, and ways to measure their effects, with broader automatic optimization left open.

The source interfaces have explicit boundaries. The Python path uses strong typing and a restricted set of language features. The tasklet compiler omits constructs including dictionaries, dynamically sized lists, and exceptions. External code can be incorporated through a tasklet with declared accesses, subject to the target’s ability to compile that code. These restrictions allow DaCe to track the dependencies on which its transformations rely. They also determine which code can be brought into the workflow directly and which requires an adapted interface or a fallback.

#### Limits apparent from the experiments

The evidence for portability comes from several types of hardware and calculation, with a particular device configuration for most experiments. There is an additional device comparison for the specialized strided multiplication. The evaluation shows that different schedules and layouts can be generated from a common scientific source on the tested targets. Generalizing the same parameter choices to additional devices or input sizes would require more measurements. The matrix multiplication case gives direct evidence of size-specific tuning in the progression from the general transformation chain to the strongest MKL comparison.

The baselines also answer questions of different scope. The FPGA comparison against naïve high-level synthesis estimates the gain from creating a much better implementation than the direct mapping. The reported Spatial result uses the same chip and a stated matrix size, and comes from a separate study. The CPU library comparisons ask how closely DaCe approaches well-tuned implementations on specific kernels. These observations can all support the authors’ case for the workflow. They cannot be pooled into a single speedup for SDFGs because the reference points, hardware, and workloads differ.

The evaluation centers on runtime, throughput, and selected breakdowns of hardware utilization. It demonstrates a graphical interface and shows how transformation chains can be saved and reused. It does not measure how much engineer time the workflow saves across teams, how frequently a rewrite survives a later scientific change, or how maintenance compares over the life of an application. The paper’s division of roles depends on stable dataflow where earlier optimizations are to be reused. A change to the data interface or access pattern may alter the applicability of those optimizations.

Finally, the quantum-transport timings apply to scattering self-energies and to the specialized multiplication within that computation. The paper describes OMEN as using a nonlinear solver, and gives the targeted calculation as a significant part of the runtime. The 32.26× result is for the scattering-self-energy calculation on the specified nanostructure. Assessing the speedup of an entire simulator run would require timing the rest of the application and measuring its interaction with the optimized calculation.

### What came after

The paper identifies no subsequent studies that extend or evaluate SDFGs. The work by Ziogas and colleagues discussed in the quantum-transport case is a companion study. It gives a fuller account of the application optimization that the SDFG paper uses to illustrate its method. In the case reported here, the shared contribution is to expose the small matrix products and their data layout as graph structure that engineers can reorganize and specialize for the simulation workload.

## Cite

Cite as Tal Ben-Nun, Johannes de Fine Licht, Alexandros Nikolaos Ziogas, Timo Schneider and Torsten Hoefler. 2019. Stateful Dataflow Multigraphs: A Data-Centric Model for Performance Portability on Heterogeneous Architectures. arXiv:1902.10345.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.48550/arxiv.1902.10345](https://doi.org/10.48550/arxiv.1902.10345) · [arXiv 1902.10345](https://arxiv.org/abs/1902.10345)

```bibtex
@misc{bennun2019stateful,
  title = {{Stateful Dataflow Multigraphs: A Data-Centric Model for Performance Portability on Heterogeneous Architectures}},
  author = {Tal Ben-Nun, Johannes {de Fine Licht}, Alexandros Nikolaos Ziogas, Timo Schneider and Torsten Hoefler},
  year = {2019},
  doi = {10.48550/arxiv.1902.10345},
  eprint = {1902.10345},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1902.10345}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
