Elamur Research

NAS Parallel Benchmarks with CUDA and beyond

Paper · 2021 · Gabriell Araujo, Dalvan Griebler, Dinei A. Rockenbach et al.

Summary

Moving a scientific program to a graphics processing unit can expose thousands of operations that could run together. The difficulty is arranging the work so that the hardware can actually do so. Some calculations must wait for earlier results, some threads receive more work than others, and some algorithms spend much of their time moving data. Araujo and colleagues study these problems by developing a CUDA version of the NAS Parallel Benchmarks, a suite for evaluating parallel hardware and software. Its numerical kernels and larger solver workloads represent different parts of computational fluid dynamics, making the suite a way to compare decisions in GPU and parallel computing.

The authors rework the suite’s five kernels and three pseudo-applications from a C++ implementation. They change how work is distributed across threads, how those threads access arrays, and where the program has to wait for results. The suite’s built-in correctness checks still pass. Users can also specify how many threads each block uses for each GPU routine in the CUDA implementation’s configuration file. That setting determines how many threads are grouped together for execution, and the best choice can differ between routines of the same benchmark and between sizes of the same workload.

The thread-block experiments explain why a single setting can be a poor fit. With class B of conjugate gradient, the most expensive routine was 8.76 times faster with 64 threads per block than with 1024. The block tri-diagonal solver had a different problem. Small blocks repeated more synchronization work, and its most expensive routine benefited from larger blocks. Of the five tuning strategies, Profiling, which times GPU routines separately and uses those measurements to configure the full program, gave the strongest overall results. The paper reports a 717% improvement over the slowest strategy for class B of conjugate gradient.

The comparison with earlier implementations records gains of up to 267% over the strongest prior comparison identified for a workload, for class B of the scalar penta-diagonal solver in the paper’s cross-GPU summary. The authors also measure GPU memory use and compare source-code size. Two of the most informative results come from workloads where an earlier implementation is faster. The Fourier transform benefits from putting often reused data in shared memory, even at the cost of more complicated GPU code. The lower-upper solver benefits from handling dependent steps within a single GPU launch, even when that limits how much work can run in parallel. The suite shows how the best design depends on what a particular calculation spends its time doing.

Deep dive: NAS Parallel Benchmarks with CUDA and beyond

The NAS Parallel Benchmarks in CUDA show how code structure, memory access, and threads per block affect the speed of scientific workloads on GPUs. · about 33 minutes to read

The problem and its context

Why the benchmark suite matters

A graphics processing unit derives much of its throughput from having many threads available to execute. For a scientific program, that creates several distinct problems. The program must supply enough independent work, arrange it so that neighboring threads can access memory efficiently, and coordinate the steps whose results depend on each other. A change that helps with one problem can make another more expensive. Dividing a large calculation into simpler pieces may expose more independent work, for instance, while increasing the number of times the program has to launch a GPU routine or wait for one to finish.

The NASA Advanced Supercomputing Division developed the NAS Parallel Benchmarks, or NPB, to evaluate parallel computing systems. The suite includes kernels that represent individual numerical methods and pseudo-applications that reproduce a larger solver’s computation and data movement. That range matters for GPU evaluation. A calculation made up of independent work items can show how well a device handles a large supply of parallel work. A solver whose calculations depend on one another can show where that supply runs out, and what it costs to resume the next group of operations.

The benchmarks have defined workload classes. S and W serve for simple tests, while A, B, C, D, E, and F provide larger cases for experiments. They also include checks on the computed answers. The combination gives a porting effort a starting point and an endpoint. The benchmark defines the work to be performed, and the verification step checks the result after the implementation has changed. Programs carrying out the same benchmark can therefore use different arrangements of loops, data, and threads and still be assessed against a common specification.

The paper describes the original Fortran implementations as a serial reference and an OpenMP version for multicore processors. NASA subsequently provided variants for clusters with MPI, for hybrid programming with NPB Multi-zone, and for grid computing with NAS Grid Benchmarks. Researchers also translated the suite to C++ and used it to study shared-memory programming approaches including FastFlow and TBB. By the time of the CUDA study, there was already a tradition of using the same numerical workloads to investigate what changed when programmers moved between languages, hardware, and parallel programming interfaces.

What earlier GPU ports had established

Seo and colleagues produced an OpenCL implementation that targeted both CPUs and GPUs. Xu and colleagues used OpenACC and discussed how compiler directives affect the work of porting an application and the performance of the resulting code. Do and colleagues built on the OpenCL work, applying a collection of GPU techniques and producing versions in both OpenCL and CUDA. Araujo and colleagues had previously implemented the NPB kernels in CUDA and compared their performance and memory use with earlier versions. The study extends that implementation to the solver workloads and revisits the kernels using a common set of design principles.

There were also narrower experiments on individual benchmarks. Gong and colleagues used CUDA for the embarrassingly parallel benchmark and compared it with OpenMP. Their block-size study used 64, 128, and 256 threads per block for that workload. Jin and colleagues studied the scalar penta-diagonal solver using CUDA and OpenACC, creating variants to investigate GPU optimizations. Malik and colleagues compared programming approaches that included CUDA and MATLAB, considering programming effort, memory, and performance. As Araujo and colleagues describe it, the tuning procedure in that comparison assigned a common block size to the GPU routines of a benchmark. A size that suited one part of a program could therefore also be imposed on a routine with quite different work.

Some early studies were constrained by the devices available for evaluation. Limited device memory made it difficult to run larger workload classes, and the available processing cores restricted what the experiments could establish about parallel strategies. The paper notes that some early GPU executions took longer than their CPU counterparts. The question that remained was how much a port could gain from arranging the work differently, and which differences would still matter once implementations were compared on the same hardware.

Two decisions at different levels

The first decision the authors investigate is what computation to give the device. An original CPU routine can contain several nested loops that mix independent work with steps that have to stay in order. Porting that whole routine as a unit may leave each GPU thread running a lengthy sequence with branches and memory accesses spread across an array. A refactoring can expose different units of work. Its success depends on the dependencies in the calculation and on how much extra communication or coordination the new arrangement introduces.

The second decision is how to group threads after choosing a unit of work. In CUDA, an operation launched on the GPU has a grid of thread blocks. A block contains threads that can work together, share a local store, and wait for one another when a calculation requires it. Within a block, threads execute in groups called warps. Assigning a larger block can change how much cooperation happens in each group, how many groups are needed to complete the task, and which blocks can reside on a multiprocessor at the same time. Those consequences depend on the routine’s work and resource demands.

The paper investigates both decisions. A comparison across implementations examines the consequences of different ways of organizing an entire port. A study within the authors’ CUDA implementation holds that code in place and changes how it groups threads. This distinction gives the paper two kinds of evidence. One concerns differences between complete implementations, where several design choices generally change together. The other concerns how a configurable launch parameter changes performance for a specified implementation and workload.

The method, step by step

From the C++ reference to a CUDA benchmark

The starting point is a C++ translation of NPB 3.4 that follows the Fortran implementation. The authors trace each program from initialization through its main computation to the final correctness check. They identify the routines that dominate execution, inspect their loops and memory accesses, and decide what work to move to the device. In most benchmarks the main calculation invokes expensive routines repeatedly. EP, the random-number workload, is an exception to that iterative structure. EP and IS, the integer sort, also concentrate their main work in a single function at the benchmark level, although a function can contain several distinct steps.

The timing interval begins after initialization and ends as verification begins. It includes the main calculation and the coordination needed to execute it. A benchmark can therefore spend time inside that interval even when the GPU is waiting for another launch or the CPU is managing the order of operations. The authors use the suite’s verification procedure to check the port after transforming it. They make the CUDA code available in the NPB-GPU repository. The inputs come from the suite’s workload definitions, so the procedure consists of choosing benchmark classes, executing the numerical work, checking the outputs, and collecting timings.

From the NPB reference to a timed CUDA run

The steps in order.

From the NPB reference to a timed CUDA runStep 1: Trace the benchmark’s main computation1. Trace the benchmark’s main computationStep 2: Locate costly routines and their dependencies2. Locate costly routines and their dependenciesStep 3: Restructure loops around independent work3. Restructure loops around independent workStep 4: Arrange array accesses for neighboring threads4. Arrange array accesses for neighboring threadsStep 5: Configure the block size for each routine5. Configure the block size for each routineStep 6: Time the benchmark’s main computation6. Time the benchmark’s main computationStep 7: Check the result with NPB verification7. Check the result with NPB verification

What a GPU routine should do

The authors prefer routines whose individual threads follow straightforward instruction sequences. In a warp, threads execute a common instruction together. If a conditional sends some threads down one path and others down another, a path can run while threads assigned to the other path wait. The paper calls this branch divergence. Its cost helps explain why a direct port of a complicated CPU loop may expose plenty of nominal parallel work while still leaving some GPU threads inactive during execution.

The authors also aim to limit expensive global-memory accesses. Global memory holds data for the device, while shared memory gives threads in a block a lower-latency place to exchange or reuse values. Moving data between the host CPU and the GPU is a separate cost. Where a sequence of operations already uses device-resident data, the authors generally keep the work on the device so that an intermediate step does not force a round trip. They also postpone or reduce synchronization where the dependencies allow it. A synchronization is a point where work must wait until other operations reach the required state.

When threads do need global memory, the authors try to give neighboring threads consecutive locations to access. The paper calls this memory coalescing. It allows requests that would otherwise touch separate parts of memory to be served together. Turning a multidimensional calculation into a coalesced access pattern requires choosing which array index varies from thread to thread. The appropriate choice can change between routines even when they operate on the same data.

A supply of independent work also gives the device something to execute while earlier operations wait on memory or another long-latency operation. The authors therefore look for ways to expose more parallel work without giving every thread a larger instruction sequence. Each of these choices has a cost that can change with the workload. Shared-memory staging can require additional steps, and splitting a routine can replace branching inside the device with more coordination around launches. The paper uses the benchmark implementations to examine where those costs become important.

How the loops change

Loop collapsing turns a nested iteration space into a single space that can be assigned to GPU threads. A thread’s assigned position identifies the original combination of loop indices. This helps when the outer and inner indices together describe independent work. Dependencies along an inner loop can still require that each thread perform a sequence of calculations in order after the independent outer work has been distributed.

Loop fission divides a large loop into separate stages. In the Fourier transform, staging lets a GPU routine operate over the entire input for a particular step, with a simpler instruction sequence for each thread. Loop fusion combines loops where the data dependencies and iteration spaces permit it. In parts of multi-grid, the resulting routine can do several operations at each position without launching a separate device routine for every loop. The two transformations serve different purposes depending on whether the larger cost is complexity within the routine or coordination between routines.

Loop unrolling replaces a short loop with repeated copies of its body. The authors use it where the iteration count is small and fixed, conditions that occur often in the solver workloads. This removes the repeated loop bookkeeping from the thread’s execution. The pseudo-applications use all of these transformations because the original loops combine different kinds of work, including array initialization, independent updates, and calculations whose intermediate values must remain in order.

Mapping the numerical kernels

Conjugate gradient, or CG, contains irregular matrix calculations. Its dominant operation is written as follows.

q = A · p

Here A is the matrix, p is the input vector for this operation, and q is the resulting vector. The dot denotes matrix–vector multiplication, and = associates the result with q. The work for different parts of the matrix can vary considerably. The authors assign the work over a range of an array to a block, then distribute that range’s calculations among the threads in that block. They reorganize how the threads address data so that neighboring accesses can be coalesced. This mapping creates cooperation inside a task without requiring tasks of different sizes to finish together.

A second expensive CG operation uses a similar mapping.

‖r‖ = ‖x − A · z‖

Here r is the residual, x is the vector from which the matrix–vector product is subtracted, A is the matrix, and z is the vector multiplied by it. The dot indicates that product, − indicates vector subtraction, and paired bars denote a vector norm. The equation relates the norm on the left to the norm of the difference on the right. For the simpler CG loops, the port can assign an iteration to each thread directly. The uneven matrix tasks motivate the block-level mapping, while the straightforward loops need no comparable reorganization.

The embarrassingly parallel benchmark, EP, produces pseudorandom numbers and computes Gaussian deviates, values associated with a Gaussian distribution. Its random-number work can be divided among blocks, with individual threads handling the work for individual pseudorandom numbers. A direct mapping would give each thread a large array and make the memory footprint grow as the program creates more threads. The authors restructure the calculation to reuse a smaller array as it proceeds. They also use atomic operations to combine results. An atomic update allows concurrent threads to contribute safely to a shared result without a separate reduction procedure of the kind used by some earlier implementations.

The Fourier transform benchmark, FT, transforms an array of complex numbers along its x, y, and z axes. In the serial code, the axis routines read a portion of the data, transform it, write it out, and repeat the sequence for another portion. The CUDA port splits an axis routine into a read stage, a transform stage, and a write stage. Loop collapsing then gives the threads of each stage a larger iteration space to work on. For the x axis, the authors also change the address mapping to coalesce accesses. The y and z routines already have the required pattern. Independent setup functions can be offloaded concurrently because each can complete without values produced by the others.

The integer sort, IS, orders integer values. Its rank function contains a sequence of loops, each of which offers a straightforward way to assign iterations to threads. Progress through the sequence requires synchronization between the CPU and GPU after the offloaded loops. Some of the work also uses atomic operations and synchronization within a block. The straightforward mapping makes the computation easy to distribute, but the intervals of useful work are short enough that coordination matters to the overall result.

Multi-grid, or MG, offers different opportunities inside a single benchmark. In the psinv and resid routines, the authors collapse outer loops and leave each thread to execute a sequence of inner loops. In interp and rprj3, some loops visit the same iteration space and can be joined without violating data dependencies. Fusing those loops and collapsing the resulting nest lets individual GPU threads carry out the assigned work without repeating the original loops and branches. Array updates can give each thread a position to update. The norm calculation combines partial results by a binary-tree reduction, grouping them into progressively larger partial results until they are combined. The authors organize accesses for coalescing across the offloaded MG routines.

Handling the solver workloads

The block tri-diagonal solver, BT, solves a system associated with the Navier–Stokes equations. The main work proceeds through direction-specific solvers. The authors use xsolve to illustrate a division that they also apply to ysolve and zsolve. The first stage initializes data. Its nested iteration space can be collapsed and assigned to independent threads. The second stage contains loops with compatible work and no dependency between the values they process, so the authors fuse the loops and collapse the result into work for independent threads. In the third stage some calculations depend on earlier values. The CUDA version distributes the independent outer work and leaves a sequence of dependent operations within each thread.

That arrangement allows BT to use finer parallelism where the algorithm permits it and to preserve ordering where the solver requires it. The authors also divide the long rhs calculation into smaller stages and collapse the loops within them. The add routine has independent operations that can be distributed after collapsing its loops. Working with arrays of up to five dimensions makes the assignment of neighboring threads to consecutive addresses more involved than it is in a linear array.

The lower-upper Gauss–Seidel solver, LU, exposes a different boundary. Its blts and buts routines work along diagonals in a wavefront. Once the earlier diagonal is ready, the points on the current diagonal can be computed in parallel. The next diagonal must then wait for the values it needs. The paper illustrates this ordering on an 8 × 8 matrix with 15 diagonals. At diagonal 6, the earlier work is available but the later diagonals are still waiting. The shape of the work leaves parallelism within a diagonal and an ordered progression across diagonals.

The authors launch a GPU routine for each diagonal and assign a thread to each point. The host and device synchronize between successive diagonals. This gives the individual GPU threads a simple computation but makes the number of launches depend on the wavefront’s progress. The diagonal access pattern also prevented the authors from achieving the coalescing they used in other benchmarks. Elsewhere in LU, the array-update routine ssor is split into routines that update different arrays, and rhs is divided into stages before the authors apply loop fusion and collapsing within them.

The scalar penta-diagonal solver, SP, also performs direction-specific solves. In xsolve, the authors reorganize a loop containing several nested calculations into an arrangement where two outer loops can be collapsed. A GPU thread receives a position in that combined iteration space and then carries out the remaining sequence of loops. The same arrangement is used in ysolve and zsolve. The paper describes the change in the number of threads with these expressions.

nz

Here nz is the extent in the z direction used for the original assignment of threads.

nz ∗ ny

Here nz is the extent in the z direction, ny is the extent in the y direction, and ∗ denotes multiplication. The revised mapping exposes work over the combined extents. The authors also describe the growth of the amount of branching for the earlier organization.

O(ny ∗ nx)

O gives the order of growth, ny and nx are the extents in the y and x directions, and ∗ indicates their product. The corresponding expression after the refactoring is:

O(nx)

O again denotes the order of growth of the branch count, and nx is the extent in the x direction. The expressions describe how branching grows as the dimensions grow. They are separate from the measured run times.

The SP port also collapses loops in txinvr and add. It splits rhs into stages, with fusion used in the stage that still contains a sequence of loops. This simplifies branching, although the fused operations access different regions of memory and make coalescing more difficult. The authors change access patterns across the port, a substantial part of the work because SP, like BT, uses arrays with up to five dimensions.

Making launch settings configurable

The port reads block sizes from a text file named gpu.config. A setting identifies a benchmark and a GPU function, then supplies an integer thread count. For example, the paper describes setting IS’s rank routine to 256 threads per block. Each function can receive its own setting, so an experiment can change how rank runs without changing other routines or rebuilding the code. An omitted or invalid setting falls back to the device’s warp size.

A chosen block must fit the device’s resources. The authors use dynamic allocation of shared memory so that its size can follow the launch configuration. When the requested number of threads requires more shared memory than the device can supply, the implementation halves the requested size until it fits. The paper describes a similar adjustment when another hardware resource, such as registers, prevents a multiprocessor from accommodating a block. The configuration expresses the requested grouping, and resource checks determine whether that grouping is feasible.

The authors compare five ways to fill in the settings. Warp uses the device’s warp size throughout. Max uses the largest supported block size. Manual uses choices made by a programmer experienced with GPUs. Profiling sweeps the candidate block sizes, using a common size across a benchmark’s functions in each screening run. It then reads each function’s timing from those runs and chooses the size that gave that function its shortest measured time. The final configuration can therefore contain several different sizes.

Exhausting selects configurations using the elapsed time of the entire benchmark. For the routines included in its search, it tries combinations of block sizes and keeps the fastest measured combination. Because a search involving every GPU routine would be too expensive, it varies the sizes only for routines that account for at least 10% of the benchmark’s execution time. The remaining routines use the settings selected by Profiling. Thus the two strategies differ in how they create candidates and in what timing they use to choose among them.

Experiments and results

Machines, workloads, and comparison measures

The main evaluation used an Intel Xeon E5-2620 host with 16 GB of RAM and an NVIDIA Titan X Pascal with 12 GB of device memory. The host had 6 cores and 12 threads. The software environment included Ubuntu 16.04 LTS, CUDA 10, and GCC 9, and the authors enabled compiler optimization. The OpenMP comparison used the host’s 12 logical cores. The paper also summarizes experiments with an NVIDIA V100 Volta and an NVIDIA T4 Turing on machines equipped with an Intel Xeon E5-2698 v3.

The workloads were NPB classes B and C. Class C represents the larger case in these experiments. On the Titan X, device memory prevented execution of classes D, E, and F. Each test was run ten times and averaged, and the plots include standard deviations. The implementation comparison reports elapsed execution time, speedup relative to the sequential CPU implementation, and device memory use in MB. A separate source-code comparison counts source lines to give a rough indication of the size of each port.

For the performance comparison, the reference is the serial C++ version, and OpenMP provides a parallel CPU baseline. The GPU comparison includes the OpenACC implementation from Xu and colleagues and the OpenCL implementation from Seo and colleagues. The versions from Do and colleagues add another OpenCL comparison and an earlier CUDA one. The Xu version of IS could not be tested because its source for that benchmark was unavailable. For the Do implementations, the authors disabled a global-memory tiling option that imposed a substantial performance penalty in their tests. Araujo and colleagues used settings selected by Profiling for their CUDA version.

Conjugate gradient and random-number work

On the Titan X, the authors report CG speedups over the serial CPU reference of 65.44 for class B and 72.73 for class C. In class C the serial program took 254.93 seconds, while the authors’ CUDA program took 3.51 seconds. The Do OpenCL version finished in 3.44 seconds, and the earlier Do CUDA version in 3.55 seconds. Those timings put the authors’ implementation close to the stronger competing versions for this workload. The Xu OpenACC version took 232.34 seconds in the same experiment. The paper attributes much of that difference to the way the CUDA and OpenCL implementations isolate uneven work in the main matrix calculations.

The random-number benchmark, EP, recorded the authors’ largest reported speedups over the serial reference on the Titan X, 200.99 for class B and 197.71 for class C. The class B timings show how much of the gain was shared by several GPU implementations. The authors’ implementation finished in 0.52 seconds, and the strongest competing GPU versions were close. OpenMP reduced the serial time substantially, while the finer GPU mappings moved the workload into a different range of execution times.

EP class B execution time on the Titan X Pascal

The new CUDA port leads a close group of GPU implementations.

EP class B execution time on the Titan X PascalLöff serial: 104.51Löff serial104.51Löff OpenMP: 12.46Löff OpenMP12.46Xu OpenACC: 2.24Xu OpenACC2.24Seo OpenCL: 0.74Seo OpenCL0.74Do OpenCL: 0.54Do OpenCL0.54Do CUDA: 0.53Do CUDA0.53Authors’ CUDA (this paper): 0.52Authors’ CUDA (this paper)0.52
The numbers
System or settingseconds
Löff serial104.51
Löff OpenMP12.46
Xu OpenACC2.24
Seo OpenCL0.74
Do OpenCL0.54
Do CUDA0.53
Authors’ CUDA (this paper)0.52

The authors link EP’s results to how the different ports make work available to the device. The OpenACC version assigns a subset of the random-number work to a single thread. That coarser arrangement creates fewer independent threads. Some earlier ports use fine-grained work but use larger memory areas or reduce results through several steps. The authors’ version combines fine-grained work with smaller, reused storage and atomic updates. The exact margin between the competing GPU versions depends on the device, as the V100 and T4 experiments show.

Fourier transform, integer sort, and multi-grid

For FT, the authors report speedups of 22.93 on class B and 25.48 on class C over the serial CPU version on the Titan X. Their class C port took 10.15 seconds. This was substantially faster than the Xu OpenACC and Seo OpenCL implementations, which the authors describe as exposing coarser work in the axis transforms. The newer Do implementations finished sooner. Their class C timings were 3.86 seconds for OpenCL and 4.10 seconds for CUDA. The authors attribute this lead to the use of shared memory for repeatedly accessed values inside the transform. The transfers into and out of shared memory complicate the instruction sequence, but they reduce the latency paid when values are reused.

FT class C execution time across GPU implementations on the Titan X Pascal

The Do implementations finish ahead of the new CUDA port on the Fourier transform.

FT class C execution time across GPU implementations on the Titan X PascalXu OpenACC: 27.35Xu OpenACC27.35Seo OpenCL: 24.91Seo OpenCL24.91Do OpenCL (this paper): 3.86Do OpenCL (this paper)3.86Do CUDA: 4.10Do CUDA4.10Authors’ CUDA: 10.15Authors’ CUDA10.15
The numbers
System or settingseconds
Xu OpenACC27.35
Seo OpenCL24.91
Do OpenCL (this paper)3.86
Do CUDA4.10
Authors’ CUDA10.15

All available GPU implementations of IS had the same recorded execution time at the precision of the paper’s timing table on the Titan X. That was 0.18 seconds for class B and 1.29 seconds for class C. The authors report speedups for their version of 8.84 and 4.94, respectively, relative to serial CPU execution. The benchmark offers relatively little computation between coordination points. Even when implementations differ in how much work or data they leave on the host, they meet a common limit from the structure of the workload in this comparison.

MG showed a closer competition among the newer GPU versions. The authors’ CUDA version took 0.19 seconds in class B, compared with 0.20 for Do OpenCL and 0.21 for Do CUDA. For class C, the order changed. Do OpenCL took 1.54 seconds, Do CUDA took 1.55 seconds, and the authors’ port took 1.60 seconds. Its speedups over the serial CPU implementation were 23.01 and 23.96 for B and C. The paper associates the improvement over earlier ports with simplified interp and rprj3 routines and with coalesced access in psinv and resid. The closeness of the newer implementations is consistent with the authors’ observation that they use similar ways of distributing the work.

The three solver workloads

For BT, the authors’ CUDA implementation had the shortest recorded time on the Titan X for both workload classes. It took 5.39 seconds in class B and 22.18 seconds in class C, corresponding to reported speedups of 35.69 and 35.66 over the serial CPU version. The Do OpenCL implementation took 8.30 and 30.93 seconds in the respective classes. Much larger times were recorded for the older OpenCL port, which kept more of the original structure and exposed coarser work. The paper attributes the gains in the new port to distributing finer pieces of the solver and simplifying what each thread does where the dependency structure allows it.

LU shows how the cost of scheduling dependent work can change the ranking. The authors’ speedups over the serial CPU implementation on the Titan X were 22.20 for B and 21.37 for C. Their CUDA port took 6.25 seconds in B and 29.79 seconds in C, while Do OpenCL took 4.88 and 23.05 seconds. In the authors’ version, each launch handles a diagonal with a simple mapping to points. The competing design moves all the diagonals into one device routine. A single block handles the sequence, with more complex instructions and synchronization inside that block. On this workload the saved launches can outweigh the restriction to one block. The authors’ port beat Do CUDA in class B, and Do CUDA beat it in class C.

The largest advantage over a strong competing GPU implementation appears in SP. On the Titan X, the authors’ port recorded speedups of 33.19 for class B and 34.42 for class C against the serial CPU reference. For class C, it finished in 15.06 seconds, while Do OpenCL took 45.72 seconds and Do CUDA took 46.28 seconds. The paper reports that restructuring the main calculations initially brought the port to a level similar to the Do versions, with a further improvement after the authors changed the data access patterns. In the cross-device summary, class B of SP accounts for the reported 267% improvement over Do OpenCL, the strongest earlier implementation identified for that workload in the summary. The same table reports 282% for the comparison with Do CUDA. These cross-device percentages are distinct from the Titan X times.

SP class B execution time on the Titan X Pascal

The authors’ refactored CUDA solver has the shortest measured execution time.

SP class B execution time on the Titan X PascalLöff serial: 131.41Löff serial131.41Löff OpenMP: 75.83Löff OpenMP75.83Xu OpenACC: 14.98Xu OpenACC14.98Seo OpenCL: 20.92Seo OpenCL20.92Do OpenCL: 8.58Do OpenCL8.58Do CUDA: 8.95Do CUDA8.95Authors’ CUDA (this paper): 3.96Authors’ CUDA (this paper)3.96
The numbers
System or settingseconds
Löff serial131.41
Löff OpenMP75.83
Xu OpenACC14.98
Seo OpenCL20.92
Do OpenCL8.58
Do CUDA8.95
Authors’ CUDA (this paper)3.96

Memory, implementation size, and additional devices

The authors’ version generally consumed GPU memory comparable to the most economical earlier approaches. FT was the main exception. The Seo OpenCL version and the Do versions reuse a smaller memory allocation as the Fourier calculation proceeds. In EP, the memory comparison illustrates a different tradeoff. The Xu implementation retains larger per-thread storage requirements and uses fewer threads so that the workload fits. The authors’ smaller reused array makes a finer allocation of work feasible. In IS, the Do OpenCL version runs some operations on the CPU, which lowers its device-memory requirement. The GPU allocation describes where a program keeps its data as well as how much storage its algorithm needs.

The source-line counts add a measure of the extent of the porting work. The serial C++ and OpenMP versions are close in size, which the authors relate to OpenMP directives on loops. The directive-based OpenACC port is similar in size to the authors’ CUDA version, or larger, for most benchmarks. The paper identifies a specific reason for some of the added code. To reduce divergence, the OpenACC version can supply separate GPU routines for different paths through an original conditional. The Do OpenCL and CUDA versions use the same underlying parallelization strategy and are among the largest ports for many benchmarks. The authors’ simpler routines generally require fewer lines than those versions. Line counts are best read alongside these design choices, since a longer implementation can reflect specialized code that serves a performance purpose.

The V100 and T4 experiments broadly reproduce the relative performance patterns identified on the Titan X, with exceptions that help explain how dependent the results are on the setup. The paper’s summary across devices reports an EP improvement over Do CUDA of 66% for class B and 37% for class C. The authors associate the larger gains on newer devices with the handling of atomic operations, which their EP implementation uses to combine contributions. For IS on the T4 setup, the OpenMP version was faster than the GPU versions. That setup used a host with 16 physical cores, compared with 6 on the Titan X host. The OpenACC CG results also improved in the additional experiments, where the authors used PGI 19 because the cluster lacked a compatible GCC version for those codes. Both the accelerator and the rest of the system affect the interpretation of a cross-machine speedup.

What the ablations show

Changing the block size while keeping the routine fixed

The paper’s most direct controlled comparison varies threads per block for the most expensive routine in each benchmark. On the Titan X, the sweep starts at the warp size of 32 and extends to the device maximum of 1024. The authors record routine times for classes B and C. These measurements isolate a launch choice within the same CUDA code. Differences between entire ports, by comparison, combine changes in access patterns, the order of work, the number of launches, and sometimes the programming interface.

The largest response in the sweep came from the CG matrix–vector product. It accounted for 90.13% of the time in the authors’ class C breakdown at the warp-size setting. With 64 threads per block, it was 8.76 times faster than with 1024 for class B and 6.84 times faster for class C. The authors explain the result through the size of the tasks. Many tasks are small, and each task is assigned to a block. A large block can therefore contain many threads with no work for that task. Increasing the block size limits the efficiency of this particular assignment even though the benchmark has substantial parallel work overall.

The third stage of BT’s xsolve responded in the opposite direction. Its best setting was 256 threads per block in B and 512 in C. The corresponding best-to-worst factors were 2.55 and 2.94, with 32 the slowest setting for both classes. The solver performs many synchronizations within blocks. With small blocks, more blocks execute the work and more groups perform those synchronizations. For the benchmark’s solver computations, the paper reports 10 times fewer synchronizations with 1024 threads per block than with 32. The lowest observed time for xsolve3 occurred at intermediate sizes, so the synchronization count explains the cost of small blocks without by itself specifying the fastest block size.

EP shows a resource limit of a different kind. Its random-number routine uses many registers, and a multiprocessor can accommodate fewer blocks at once when each block needs a large share of the available registers. The fastest settings were 128 threads per block for B and 32 for C. The fastest class B run was 1.6 times faster than the slowest one, which used 512 threads per block. For class C the factor was 1.2, with 1024 at the slow end. The change in fastest setting between workload sizes matters even though the arrangement of the calculation is the same.

Why some routines move very little

The resid routine in MG accounts for 50.41% of the time in the class C breakdown, so it matters to overall performance even when it is relatively insensitive to block size. The reported best-to-worst factor is 1.02 for B and 1.25 for C. Its best setting was 256 in B and 1024 in C. The paper compares it with BT because both use synchronization within blocks, but describes MG as performing fewer such operations. In IS, rank also uses synchronization within blocks and atomic operations. Its best setting was 512 in both classes, compared with 32 at the slow end. The best-to-worst factors were 1.2 for B and 1.11 for C.

The Fourier transform’s ftx2 stage was fastest with 32 threads per block and slowest with 64 in both classes. The reported factors were 1.14 in B and 1.04 in C. The paper emphasizes the effect of its loops and conditional instructions, which can leave some threads inactive on divergent paths. The authors reason that smaller blocks leave more opportunity to schedule other work. This covers one stage of their implementation. The much larger timing difference between the authors’ FT and the Do versions concerns a different change, how the transform stores and reuses data.

The selected LU and SP routines showed little meaningful sensitivity across the sweep. The authors describe LU’s blts as a simple sequence of instructions for each point. The wavefront’s cost mostly comes from waiting and scheduling between diagonals, while the routine being timed performs the work on a diagonal. SP’s xsolve still contains some loops within each thread, but showed a similarly flat response. The two cases clarify what the sweep can reveal. A workload can be costly to execute on a GPU and still offer little scope for improvement through block size alone.

Choosing settings for the whole benchmark

Profiling yielded the strongest overall benchmark timings in the strategy comparison, often sharing the leading result. For CG it was 8.16 times faster than Max on class B and 6.46 times faster on class C in the authors’ discussion of the overall benchmark. Their strategy table gives the corresponding improvements over the worst case as 717% for B and 546% for C. Those are whole-benchmark comparisons. The separate factors for the matrix–vector multiplication come from the routine sweep. CG’s concentration of execution time in irregular matrix operations explains why the grouping of those operations has such a large effect on the total.

For EP in class B, Manual, Profiling, and Exhausting shared the best result, while in class C Profiling and Exhausting led. The paper reports that Manual was 14% slower than Profiling on class C. The difference illustrates how a plausible setting can carry over poorly as the workload grows. BT is another case with large gains from tuning. The strategy table reports that Profiling improved on Manual by 91% for B and 108% for C. At the other end, the authors describe improvements across the LU and SP strategy comparisons as less than 5% for both workload classes. How much tuning helps depends on how much of the benchmark’s time lies in routines that respond to block size.

The strategies sometimes choose different launch settings even for a single familiar function. On rank in class B, Warp chose 32 and Max chose 1024. Manual selected 256, Profiling selected 512, and Exhausting selected 128. Some of the full-benchmark times were still described as equivalent. The setting that times best for an individual routine and the setting selected from full-program timings can differ, and a discrete choice of block size can look more definitive than the timing evidence warrants when measurements are close.

Exhausting tested 6156 configurations after the authors restricted the search using the 10% cutoff. The complete study covered 6300 combinations and took a few weeks. Despite that effort, Exhausting was often slower in the follow-up comparisons than Profiling. The authors point to the host work, synchronizations, and launches included in whole-benchmark time, which can make the contribution of an individual routine harder to detect. The comparison demonstrates how the two procedures worked in this experiment. Exhausting searched a restricted set of combinations, and its selection was based on the whole run, while Profiling used shorter intervals that more directly reflected the work under adjustment.

What the implementation comparisons explain

The cross-port results identify cases where the authors’ design choices are a good fit and cases where a different cost dominates. FT benefits from separating a complicated transform into stages, as shown by the improvement over older GPU ports, while the Do versions achieve shorter times by staging frequently reused data in shared memory. In MG, some short operations can be fused to save launches without creating the elaborate control flow found in a transform. Taken together, the cases explain why the same project uses both fission and fusion. Their effects depend on the work being combined or divided.

LU shows the cost of preserving a simple instruction sequence by launching a separate computation at every diagonal. The Do implementation performs more coordination inside the device routine but pays the launch cost fewer times. SP provides a different observation. The authors describe similar performance to the Do implementations after the main refactoring, followed by a substantial gain once they changed how the routines accessed memory. The paper gives final timings for the resulting versions. It does not give a complete numerical breakdown of the contribution of each intermediate change.

The authors also report that experiments with CUDA streams and CUDA Dynamic Parallelism produced no improvement in the routines they tried and added overhead. This observation is narrower than the benchmark results with the reported final code. The paper offers the outcome of trying those features in this port, rather than a timing study that covers all possible uses of either feature.

Limitations

Limits stated by the authors

Each run uses a single GPU board. Testing separate accelerator architectures shows how the implementations behave on different hardware, while leaving open how the work should be divided across several devices. The main experimental workload range was also constrained by memory. The Titan X could run B and C, and the authors identify D, E, and F as too large for that setup. The results consequently describe ports that can keep the tested workloads in device memory. The authors identify efficient execution of workloads larger than that capacity as an open question.

The paper also names design choices that merit further investigation. These include the use of shared memory, different memory access patterns, and how the implementation principles would translate to another GPU programming framework. The authors suggest that exceptional cases could help refine those principles. FT and LU already illustrate the reason. Favoring a simple instruction sequence and exposing more threads helped several NPB workloads, while inexpensive repeated access in FT and avoiding repeated launches in LU could be worth greater complexity inside a routine.

The paper provides only a condensed account of the V100 and T4 experiments. It describes some changes in the relative performance of the ports but does not present a routine-by-routine block-size analysis for those devices comparable to the main Titan X study. The strongest conclusion about thread-block choices therefore comes from the routines, workload classes, and primary device for which the sweep is reported.

Limits visible in the setup

The NPB programs reproduce selected calculations and data movement found in computational fluid dynamics. The pseudo-applications make the study more informative than a collection of isolated routines would be, since they include several interacting steps. Performance in a complete application will also depend on its own data, execution sequence, and memory demands. The benchmark gives concrete evidence about the solver patterns that it includes, and the scope of that evidence follows the benchmark’s design.

The comparison between ports changes several things at the same time. Routines may differ in loop organization, data layout, resource consumption, and frequency of coordination. Some comparisons also use different programming interfaces and compilers. The block-size sweep provides controlled evidence about a single setting within the authors’ code, while the explanation of differences between complete ports draws in part on inspection of the programs. A statement that the SP access pattern helped, for instance, follows the authors’ account of their implementation process. Its exact contribution holds no separately reported timing alongside the final SP results.

Conditions also vary across the machine comparisons. The V100 and T4 setups use a different CPU from the Titan X setup, and the OpenACC compiler changes for the additional experiments. The reported speedup is defined against serial CPU execution, so it can move when the reference execution changes. The OpenMP result for IS on the T4 setup combines the properties of that GPU with those of the host used in the experiment. Likewise, the main Do results apply with global-memory tiling disabled. That choice makes the comparison more informative for workloads that fit, while leaving the speed and memory tradeoff for larger workloads unresolved.

The percentages deserve particular care because the paper uses different comparisons in different places. In the strategy discussion, the class C BT paragraph describes Warp as the slowest case and gives a factor of 2.07 for Profiling against it. The strategy table lists Manual as the slowest for class C, with a reported 108% improvement over Manual. The paper does not reconcile those identifications. The directly tabulated execution times are a clearer basis for comparing the ports on the Titan X, and the cross-device percentage summary is most useful when read with its named comparator and workload class.

Finally, source lines characterize the size of the resulting implementation. They give only an indirect estimate of development effort. The authors’ account of finding dependencies, designing access patterns, and testing alternate versions documents work that a line count cannot capture. In the same way, the time spent screening block configurations is part of the cost of obtaining a tuned result. The paper reports timings once those choices have been made and the scale of the search used to make them. It gives no basis for treating the chosen settings as fixed across architectures or even across the two classes of one benchmark.

What came after

No subsequent study is documented that shows how another group used this CUDA port or tested its tuning strategy. The paper closes by identifying efficient execution beyond a single GPU’s memory capacity, multi-GPU execution, and further study of memory access as possible extensions. Those are directions the authors proposed. Their experiments establish the behavior of the benchmark implementations under the reported single-device conditions.

Cite

Cite as Gabriell Araujo, Dalvan Griebler, Dinei A. Rockenbach, Marco Danelutto and Luiz Gustavo Fernandes. 2021. NAS Parallel Benchmarks with CUDA and beyond. Software Practice and Experience.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.1002/spe.3056

@inproceedings{araujo2021nas,
  title = {{NAS Parallel Benchmarks with CUDA and beyond}},
  author = {Gabriell Araujo, Dalvan Griebler, Dinei A. Rockenbach, Marco Danelutto and Luiz Gustavo Fernandes},
  booktitle = {Software Practice and Experience},
  year = {2021},
  doi = {10.1002/spe.3056},
  url = {https://doi.org/10.1002/spe.3056}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/araujo-2021-nas-parallel-benchmarks-cuda-beyond/