General-purpose computing on graphics processing units
General-purpose computing on graphics processing units (GPGPU, also referred to as GPGP and less often GP²U) is the technique of using a GPU, which typically handles computation only for computer graphics, to perform computation in applications traditionally handled by the CPU. It is made possible by the addition of programmable stages and higher precision arithmetic to the rendering pipelines, which allows software developers to use stream processing on non-graphics data.
GPU improvements
GPU functionality has, traditionally, been very limited. In fact, for many years the GPU was only used to accelerate certain parts of the graphics pipeline. Some improvements were needed before GPGPU became feasible.
Programmability
Programmable vertex and fragment shaders were added to the graphics pipeline to enable game programmers to generate even more realistic effects. Vertex shaders allow the programmer to alter per-vertex attributes, such as position, color, texture coordinates, and normal vector. Fragment shaders are used to calculate the color of a fragment, or per-pixel. Programmable fragment shaders allow the programmer to substitute, for example, a lighting model other than those provided by default by the graphics card, typically simple Gouraud shading. Shaders have enabled graphics programmers to create lens effects, displacement mapping, and depth of field.
The programmability of the pipelines have trended[clarification needed] according to Microsoft’s DirectX specification[citation needed] , with DirectX 8 introducing Shader Model 1.1, DirectX 8.1 Pixel Shader Models 1.2, 1.3 and 1.4, and DirectX 9 defining Shader Model 2.x and 3.0. Each shader model increased the programming model flexibilities and capabilities, ensuring the conforming hardware follows suit. The DirectX 10 specification introduces Shader Model 4.0 which unifies the programming specification for vertex, geometry (“Geometry Shaders” are new to DirectX 10) and fragment processing allowing for a better fit for unified shader hardware, thus providing a single computational pool of programmable resource.[vague]
Data types
Pre-DirectX 9 graphics cards only supported paletted or integer color types. Various formats are available, each containing a red element, a green element, and a blue element[citation needed]. Sometimes an additional alpha value is added, to be used for transparency. Common formats are:
- 8 bits per pixel – Palette mode[vague], where each value is an index in a table with the real color value specified in one of the other formats. Possibly two bits for red, three bits for green, and three bits for blue.
- 16 bits per pixel – Usually allocated as five bits for red, six bits for green, and five bits for blue.
- 24 bits per pixel – eight bits for each of red, green, and blue
- 32 bits per pixel – eight bits for each of red, green, blue, and alpha
For early fixed-function or limited programmability graphics (i.e. up to and including DirectX 8.1-compliant GPUs) this was sufficient because this is also the representation used in displays. This representation does have certain limitations, however. Given sufficient graphics processing power even graphics programmers would like to use better formats, such as floating point data formats, in order to obtain effects such as high dynamic range imaging. Many GPGPU applications require floating point accuracy, which came with graphics cards conforming to the DirectX 9 specification.
DirectX 9 Shader Model 2.x suggested the support of two precision types: full and partial precision. Full precision support could either be FP32 and FP24 (floating point 24-bit per component) or greater, while partial precision was FP16. ATI’s R300 series of GPUs supported FP24 precision only in the programmable fragment pipeline (although FP32 was supported in the vertex processors) while Nvidia’s NV30 series supported both FP16 and FP32; other vendors such as S3 Graphics and XGI supported a mixture of formats up to FP24.
Shader Model 3.0 altered the specification, increasing full precision requirements to a minimum of FP32 support in the fragment pipeline. ATI’s Shader Model 3.0 compliant R5xx generation (Radeon X1000 series) supports just FP32 throughout the pipeline while Nvidia’s NV4x and G7x series continued to support both FP32 full precision and FP16 partial precisions. Although not stipulated by Shader Model 3.0, both ATI and Nvidia’s Shader Model 3.0 GPUs introduced support for blendable FP16 render targets, more easily facilitating the support for High Dynamic Range Rendering.[citation needed]
The implementations of floating point on Nvidia GPUs are mostly IEEE compliant; however, this is not true across all vendors.[1] This has implications for correctness which are considered important to some scientific applications. While 64-bit floating point values (double precision float) are commonly available on CPUs, these are not universally supported on GPUs; some GPU architectures sacrifice IEEE compliance while others lack double-precision altogether. There have been efforts to emulate double-precision floating point values on GPUs; however, the speed tradeoff negates any benefit to offloading the computation onto the GPU in the first place.[2]
Most operations on the GPU operate in a vectorized fashion: a single operation can be performed on up to four values at once. For instance, if one color <R1, G1, B1> is to be modulated by another color <R2, G2, B2>, the GPU can produce the resulting color <R1*R2, G1*G2, B1*B2> in a single operation. This functionality is useful in graphics because almost every basic data type is a vector (either 2-, 3-, or 4-dimensional). Examples include vertices, colors, normal vectors, and texture coordinates. Many other applications can put this to good use, and because of their higher performance, vector instructions (SIMD) have long been available on CPUs.
In November 2006 Nvidia launched CUDA, an SDK and API that allows a programmer to use the C programming language to code algorithms for execution on Geforce 8 series GPUs. AMD offers a similar SDK+API for their ATI-based GPUs, that SDK and technology is called FireStream SDK (formerly a thin hardware interface[clarification needed]Close to Metal), designed to compete directly with Nvidia's CUDA. OpenCL from Khronos Group is used paired with OpenGL to unify the C languages extension between different architectures; it supports both Nvidia and AMD/ATI GPUs, and general-purpose CPUs too. GPGPU compared, for example, to traditional floating point accelerators such as the 64-bit CSX700 boards from ClearSpeed that are used in today's supercomputers, current top-end GPUs from Nvidia and AMD emphasize single-precision (32-bit) computation; double-precision (64-bit) computation executes much more slowly[citation needed].
GPGPU programming concepts
GPUs are designed specifically for graphics and thus are very restrictive in terms of operations and programming. Because of their nature, GPUs are only effective at tackling problems that can be solved using stream processing and the hardware can only be used in certain ways.
Stream processing
GPUs can only process independent vertices and fragments, but can process many of them in parallel. This is especially effective when the programmer wants to process many vertices or fragments in the same way. In this sense, GPUs are stream processors – processors that can operate in parallel by running a single kernel on many records in a stream at once.
A stream is simply a set of records that require similar computation. Streams provide data parallelism. Kernels are the functions that are applied to each element in the stream. In the GPUs, vertices and fragments are the elements in streams and vertex and fragment shaders are the kernels to be run on them. Since GPUs process elements independently there is no way to have shared or static data. For each element we can only read from the input, perform operations on it, and write to the output. It is permissible to have multiple inputs and multiple outputs, but never a piece of memory that is both readable and writable [vague].
Arithmetic intensity is defined as the number of operations performed per word of memory transferred. It is important for GPGPU applications to have high arithmetic intensity else the memory access latency will limit computational speedup.[3]
Ideal GPGPU applications have large data sets, high parallelism, and minimal dependency between data elements.
GPU programming concepts
Computational resources
There are a variety of computational resources available on the GPU:
- Programmable processors – Vertex, primitive, and fragment pipelines allow programmer to perform kernel on streams of data
- Rasterizer – creates fragments and interpolates per-vertex constants such as texture coordinates and color
- Texture Unit – read only memory interface
- Framebuffer – write only memory interface
In fact, the programmer can substitute a write only texture for output instead of the framebuffer. This is accomplished either through Render to Texture (RTT), Render-To-Backbuffer-Copy-To-Texture (RTBCTT), or the more recent stream-out.
Textures as stream
The most common form for a stream to take in GPGPU is a 2D grid because this fits naturally with the rendering model built into GPUs. Many computations naturally map into grids: matrix algebra, image processing, physically based simulation, and so on.
Since textures are used as memory, texture lookups are then used as memory reads. Certain operations can be done automatically by the GPU because of this.
Kernels
Kernels can be thought of as the body of loops. For example, if the programmer were operating on a grid on the CPU they might have code that looked like this:
// Input and output grids have 10000 x 10000 or 100 million elements.
void transform_10k_by_10k_grid(float in[10000][10000], float out[10000][10000])
{
for(int x = 0; x < 10000; x++)
{
for(int y = 0; y < 10000; y++)
{
// The next line is executed 100 million times
out[x][y] = do_some_hard_work(in[x][y]);
}
}
}
On the GPU, the programmer only specifies the body of the loop as the kernel and what data to loop over by invoking geometry processing.
Flow control
In sequential code it is possible to control the flow of the program using if-then-else statements and various forms of loops. Such flow control structures have only recently been added to GPUs.[4] Conditional writes could be accomplished using a properly crafted series of arithmetic/bit operations, but looping and conditional branching were not possible.
Recent GPUs allow branching, but usually with a performance penalty. Branching should generally be avoided in inner loops, whether in CPU or GPU code, and various techniques, such as static branch resolution, pre-computation, predication, loop splitting[5], and Z-cull[6] can be used to achieve branching when hardware support does not exist.
GPU techniques
Map
The map operation simply applies the given function (the kernel) to every element in the stream. A simple example is multiplying each value in the stream by a constant (increasing the brightness of an image). The map operation is simple to implement on the GPU. The programmer generates a fragment for each pixel on screen and applies a fragment program to each one. The result stream of the same size is stored in the output buffer.
Reduce
Some computations require calculating a smaller stream (possibly a stream of only 1 element) from a larger stream. This is called a reduction of the stream. Generally a reduction can be accomplished in multiple steps. The results from the previous step are used as the input for the current step and the range over which the operation is applied is reduced until only one stream element remains.
Stream filtering
Stream filtering is essentially a non-uniform reduction. Filtering involves removing items from the stream based on some criteria.
Scatter
The scatter operation is most naturally defined on the vertex processor. The vertex processor is able to adjust the position of the vertex, which allows the programmer to control where information is deposited on the grid. Other extensions are also possible, such as controlling how large an area the vertex affects.
The fragment processor cannot perform a direct scatter operation because the location of each fragment on the grid is fixed at the time of the fragment's creation and cannot be altered by the programmer. However, a logical scatter operation may sometimes be recast or implemented with an additional gather step. A scatter implementation would first emit both an output value and an output address. An immediately following gather operation uses address comparisons to see whether the output value maps to the current output slot.
Gather
The fragment processor is able to read textures in a random access fashion, so it can gather information from any grid cell, or multiple grid cells, as desired[vague].
Sort
The sort operation transforms an unordered set of elements into an ordered set of elements. The most common implementation on GPUs is using sorting networks.[6]
Search
The search operation allows the programmer to find a particular element within the stream, or possibly find neighbors of a specified element. The GPU is not used to speed up the search for an individual element, but instead is used to run multiple searches in parallel.[citation needed]
Data structures
A variety of data structures can be represented on the GPU:
- Dense arrays
- Sparse arrays – static or dynamic
- Adaptive structures
Applications
The following are some of the areas where GPUs have been used for general purpose computing:
- Bitcoin peer-to-peer currency relies on distributed GPGPU network for performing SHA256 calculations, fundamental to its operation
- MATLAB acceleration using the Parallel Computing Toolbox and MATLAB Distributed Computing Server,[7] as well as 3rd party packages like Jacket.
- k-nearest neighbor algorithm[8]
- Computer clusters or a variation of a parallel computing (utilizing GPU cluster technology) for highly calculation-intensive tasks:
- High-performance computing clusters (HPC clusters) (often referred to as supercomputers)
- including cluster technologies like Message Passing Interface, and single-system image (SSI), distributed computing, and Beowulf
- Grid computing (a form of distributed computing) (networking many heterogeneous computers to create a virtual computer architecture)
- Load-balancing clusters (sometimes referred to as a server farm)
- High-performance computing clusters (HPC clusters) (often referred to as supercomputers)
- Physical based simulation and physics engines (usually based on Newtonian physics models)
- Conway's Game of Life, cloth simulation, incompressible fluid flow by solution of Navier-Stokes equations
- Statistical physics
- Lattice gauge theory
- Segmentation – 2D and 3D
- Level-set methods
- CT reconstruction
- Fast Fourier transform
- Tone mapping
- Audio signal processing
- Audio and Sound Effects Processing, to use a GPU for DSP (digital signal processing)
- Analog signal processing
- Speech processing
- Digital image processing
- Video Processing[9]
- Hardware accelerated video decoding and post-processing
- Motion compensation (mo comp)
- Inverse discrete cosine transform (iDCT)
- Variable-length decoding (VLD)
- Inverse quantization (IQ)
- In-loop deblocking
- Bitstream processing (CAVLC/CABAC) using special purpose hardware for this task because this is a serial task not suitable for regular GPGPU computation
- Deinterlacing
- Spatial-temporal de-interlacing
- Noise reduction
- Edge enhancement
- Color correction
- Hardware accelerated video encoding and pre-processing
- Hardware accelerated video decoding and post-processing
- Raytracing
- Global illumination – photon mapping, radiosity, subsurface scattering
- Geometric computing – constructive solid geometry, distance fields, collision detection, transparency computation, shadow generation
- Scientific computing
- Monte Carlo simulation of light propagation [10]
- Weather forecasting
- Climate research
- Molecular modeling on GPU
- Quantum mechanical physics
- Astrophysics[11]
- Bioinformatics[12][13]
- Computational finance
- Medical imaging
- Computer vision
- Digital signal processing / signal processing
- Control engineering
- Neural networks
- Database operations[14]
- Lattice Boltzmann methods
- Cryptography and cryptanalysis
- Electronic Design Automation[20][21][22]
- Antivirus software[23][24]
- Intrusion Detection[25][26]
See also
- OpenMP
- Graphics processing unit
- Stream processing
- BrookGPU
- Mark Harris founder of GPGPU.org, coined term "GPGPU".
- Physics engine is a computer program that simulates Newtonian physics (on CPU, GPU or PPU)
- Havok Physics / Havok FX, commercial physics engine middleware SDK for computer and video games
- PhysX SDK, commercial realtime physics engine middleware SDK developed by AGEIA
- AGEIA also designed a dedicated physics processing unit expansion card designed to accelerate the PhysX SDK
- GPU programming libraries/layers:
- Close to Metal, now called Stream, AMD/ATI's GPGPU technology for ATI Radeon-based GPUs
- CUDA (Compute Unified Device Architecture), Nvidia's GPGPU technology for Nvidia GeForce-, Quadro- and Tesla-based GPUs
- Sh, a GPGPU library for C++
- BrookGPU is the Stanford University Graphics group's compiler and runtime implementation of the Brook stream programming language.
- OpenCL (Open Computing Language) cross platform GPGPU language for GPUs (AMD/ATI/Nvidia) and general purpose CPUs
Apple's GPU utilization introduced in Mac OS X v10.6 ‘Snow Leopard’ - DirectCompute Microsoft's GPU Computing API - Initially released with the DirectX 11 API
- Audio processing unit (DSP can also be done on a GPU with GPGPU technology)
- List of emerging technologies
- Larrabee (microarchitecture)
References
![]() | This article includes a list of general references, but it lacks sufficient corresponding inline citations. (November 2008) |
- ^ Mapping computational concepts to GPUs: Mark Harris. Mapping computational concepts to GPUs. In ACM SIGGRAPH 2005 Courses (Los Angeles, California, July 31 – August 4, 2005). J. Fujii, Ed. SIGGRAPH '05. ACM Press, New York, NY, 50.
- ^ Double precision on GPUs (Proceedings of ASIM 2005): Dominik Goddeke, Robert Strzodka, and Stefan Turek. Accelerating Double Precision (FEM) Simulations with (GPUs). Proceedings of ASIM 2005 – 18th Symposium on Simulation Technique, 2005.
- ^ Asanovic, K., Bodik, R., Demmel, J., Keaveny, T., Keutzer, K., Kubiatowicz, J., Morgan, N., Patterson, D., Sen, K., Wawrzynek, J., Wessel, D., Yelick, K.: A view of the parallel computing landscape. Commun. ACM 52(10) (2009) 56–67
- ^ GPU Gems - Chapter 34, GPU Flow-Control Idioms
- ^ [1]: Future Chips. "Tutorial on removing branches", 2011
- ^ a b GPGPU survey paper: John D. Owens, David Luebke, Naga Govindaraju, Mark Harris, Jens Krüger, Aaron E. Lefohn, and Tim Purcell. "A Survey of General-Purpose Computation on Graphics Hardware". Computer Graphics Forum, volume 26, number 1, 2007, pp. 80-113.
- ^ "MATLAB Adds GPGPU Support". 2010-09-20.
- ^ Fast k nearest neighbor search using GPU. In Proceedings of the CVPR Workshop on Computer Vision on GPU, Anchorage, Alaska, USA, June 2008. V. Garcia and E. Debreuve and M. Barlaud.
- ^ Wilson, Ron (3 September 2009). "DSP brings you a high-definition moon walk". EDN. Retrieved 3 September 2009.
Lowry is reportedly using Nvidia Tesla GPUs (graphics-processing units) programmed in the company's CUDA (Compute Unified Device Architecture) to implement the algorithms. Nvidia claims that the GPUs are approximately two orders of magnitude faster than CPU computations, reducing the processing time to less than one minute per frame.
- ^ E. Alerstam, T. Svensson & S. Andersson-Engels, "Parallel computing with graphics processing units for high speed Monte Carlo simulation of photon migration" [2], J. Biomedical Optics 13, 060504 (2008) [3]
- ^ [4]
- ^ Schatz, M.C., Trapnell, C., Delcher, A.L., Varshney, A. (2007) High-throughput sequence alignment using Graphics Processing Units. BMC Bioinformatics 8:474.
- ^ GPU-based Sorting in PostgreSQL Naju Mancheril, School of Computer Science - Carnegie Mellon University
- ^ AES on SM3.0 compliant GPUs. Owen Harrison, John Waldron, AES Encryption Implementation and Analysis on Commodity Graphics Processing Units. In proceedings of CHES 2007.
- ^ AES and modes of operations on SM4.0 compliant GPUs. Owen Harrison, John Waldron, Practical Symmetric Key Cryptography on Modern Graphics Hardware. In proceedings of USENIX Security 2008.
- ^ RSA on SM4.0 compliant GPUs. Owen Harrison, John Waldron, Efficient Acceleration of Asymmetric Cryptography on Graphics Hardware. In proceedings of AfricaCrypt 2009.
- ^ "Teraflop Troubles: The Power of Graphics Processing Units May Threaten the World's Password Security System". Georgia Tech Research Institute. Retrieved 2010-11-07.
- ^ "Want to deter hackers? Make your password longer". MSNBC. 2010-08-19. Retrieved 2010-11-07.
- ^ Lerner, Larry (April 9, 2009). "Viewpoint: Mass GPUs, not CPUs for EDA simulations". EE Times. Retrieved May 3, 2009.
{{cite news}}
: Check date values in:|year=
(help)CS1 maint: date and year (link) CS1 maint: year (link) - ^ "GPU-Accelerated Time-Domain Circuit Simulation Paper at CICC". Signal Integrity. Agilent Technologies, Inc. 2 September 2009. Retrieved 3 September 2009.
- ^ "W2500 ADS Transient Convolution GT".
accelerates signal integrity simulations on workstations that have NVIDIA Compute Unified Device Architecture (CUDA)-based Graphics Processing Units (GPU)
- ^ GrAVity: A Massively Parallel Antivirus Engine. Giorgos Vasiliadis and Sotiris Ioannidis, GrAVity: A Massively Parallel Antivirus Engine. In proceedings of RAID 2010.
- ^ "Kaspersky Lab utilizes NVIDIA technologies to enhance protection". 14 December 2009.
During internal testing, the Tesla S1070 demonstrated a 360-fold increase in the speed of the similarity-defining algorithm when compared to the popular Intel Core 2 Duo central processor running at a clock speed of 2.6 GHz.
{{cite news}}
: Unknown parameter|company=
ignored (help) - ^ Gnort: High Performance Network Intrusion Detection Using Graphics Processors. Giorgos Vasiliadis et al, Gnort: High Performance Network Intrusion Detection Using Graphics Processors. In proceedings of RAID 2008.
- ^ Regular Expression Matching on Graphics Hardware for Intrusion Detection. Giorgos Vasiliadis et al, Regular Expression Matching on Graphics Hardware for Intrusion Detection. In proceedings of RAID 2009.
External links
- GPGPU.org - General-Purpose Computation Using Graphics Hardware
- GPGPU Wiki
- SIGGRAPH 2005 GPGPU Course Notes
- IEEE VIS 2005 GPGPU Course Notes
- NVIDIA Developer Zone
- AMD GPU Tools
- CPU vs. GPGPU
- Jacket: GPU Engine for MATLAB
- What is GPU Computing?
- Ascalaph Liquid GPU molecular dynamics.
- C# Backpropagation library written for GPU
- Slideshow for ATI GPGPU physics demonstration by Stanford grad student Mike Houston See p. 13 for overview of mapping of conventional program tasks to GPU hardware.
- Tech Report article: "ATI stakes claims on physics, GPGPU ground" by Scott Wasson
- Elemental Technologies
- Acceleware
- Visioan4Ce ruggeded PC with GPGPU accelerated image and signal processing
- GPGPU in Israel
- http://www.gpu4vision.org GPGPU Publications, Videos and Software
- GP-You Project
- GPU accelerated Monte Carlo simulation of the 2D and 3D Ising model - porting a standard model to GPU hardware
- GPGPU software catalog
- GPGPU Computing @ Duke Statistical Science
- Brahma - open-source library written for the .NET 3.5 framework (in C# 3.0), to provide high-level. Its focus is GPGPU.
- Penumbra - open-source library written for Clojure. Penumbra is a Clojure wrapper for LWJGL that includes s-expression representation of GLSL and GPGPU.
- OpenCL Studio An integrated development environment for OpenCL.
- Monte Carlo of diffuse light propagation (photon migration) CUDA-based codes for Monte Carlo simulation of light transport
- GPGPU Programming in F# using the Microsoft Research Accelerator system.
- ViennaCL is a scientific computing library compatible with uBLAS (part of the Boost C++ Libraries) for GPUs and multi-core CPUs written in C++ and based on OpenCL.
- GPGPU Image Post-Processing GPU accelerated examples of Paint.NET's blur effects with performance comparison.
- VizExperts provide HPC solutions and training.
- Intro to GPGPU featuring CUDA and OpenCL
- GPUBrasil.com, First website on GPGPU in Portuguese
- GPGPU Review, Tobias Preis, European Physical Journal Special Topics 194, 87-119 (2011)
- CUDAfy.NET Open source library for the .NET framework for programming CUDA GPUs. Supports device code in native .NET; and CURAND, CUBLAS and CUFFT.