CUDA: Difference between revisions
m Spell enviroment => environment |
Dadu~enwiki (talk | contribs) |
||
Line 428: | Line 428: | ||
*[[Larrabee (GPU)]] |
*[[Larrabee (GPU)]] |
||
*[[Molecular modeling on GPU]] |
*[[Molecular modeling on GPU]] |
||
*[[AMD FireStream]] |
*[[AMD FireStream]] |
||
*[[Close to Metal]] |
*[[Close to Metal]] |
||
Revision as of 11:55, 13 December 2009
CUDA (an acronym for Compute Unified Device Architecture) is a parallel computing architecture developed by NVIDIA. CUDA is the computing engine in NVIDIA graphics processing units or GPUs that is accessible to software developers through industry standard programming languages. Programmers use 'C for CUDA' (C with NVIDIA extensions), compiled through a PathScale Open64 C compiler,[1] to code algorithms for execution on the GPU. CUDA architecture supports a range of computational interfaces including OpenCL[2] and DirectCompute[3]. Third party wrappers are also available for Python, Fortran, Java and Matlab.
The latest drivers all contain the necessary CUDA components. CUDA works with all NVIDIA GPUs from the G8X series onwards, including GeForce, Quadro and the Tesla line. NVIDIA states that programs developed for the GeForce 8 series will also work without modification on all future Nvidia video cards, due to binary compatibility. CUDA gives developers access to the native instruction set and memory of the parallel computational elements in CUDA GPUs. Using CUDA, the latest NVIDIA GPUs effectively become open architectures like CPUs. Unlike CPUs however, GPUs have a parallel "many-core" architecture, each core capable of running thousands of threads simultaneously - if an application is suited to this kind of an architecture, the GPU can offer large performance benefits.
In the computer gaming industry, in addition to graphics rendering, graphics cards are used in game physics calculations (physical effects like debris, smoke, fire, fluids); examples include PhysX and Bullet. CUDA has also been used to accelerate non-graphical applications in computational biology, cryptography and other fields by an order of magnitude or more.[4][5][6][7] An example of this is the BOINC distributed computing client.[8]
CUDA provides both a low level API and a higher level API. The initial CUDA SDK was made public on 15 February 2007, for Microsoft Windows and Linux. Mac OS X support was later added in version 2.0[9], which supersedes the beta released February 14, 2008.[10]
Advantages
CUDA has several advantages over traditional general purpose computation on GPUs (GPGPU) using graphics APIs.
- Scattered reads – code can read from arbitrary addresses in memory.
- Shared memory – CUDA exposes a fast shared memory region (16KB in size) that can be shared amongst threads. This can be used as a user-managed cache, enabling higher bandwidth than is possible using texture lookups.[11]
- Faster downloads and readbacks to and from the GPU
- Full support for integer and bitwise operations, including integer texture lookups.
Limitations
- It uses a recursion-free, function-pointer-free subset of the C language, plus some simple extensions. However, a single process must run spread across multiple disjoint memory spaces, unlike other C language runtime environments.
- Texture rendering is not supported.
- For double precision (only supported in newer GPUs like GTX 260[12]) there are some deviations from the IEEE 754 standard: round-to-nearest-even is the only supported rounding mode for reciprocal, division, and square root. In single precision, Denormals and signalling NaNs are not supported; only two IEEE rounding modes are supported (chop and round-to-nearest even), and those are specified on a per-instruction basis rather than in a control word; and the precision of division/square root is slightly lower than single precision.
- The bus bandwidth and latency between the CPU and the GPU may be a bottleneck.
- Threads should be running in groups of at least 32 for best performance, with total number of threads numbering in the thousands. Branches in the program code do not impact performance significantly, provided that each of 32 threads takes the same execution path; the SIMD execution model becomes a significant limitation for any inherently divergent task (e.g. traversing a space partitioning data structure during raytracing).
- Unlike OpenCL, CUDA-enabled GPUs are only available from NVIDIA (GeForce 8 series and above, Quadro and Tesla).[13]
Supported GPUs
A table of devices officially supporting CUDA (Note that many applications require at least 256 MB of dedicated VRAM).[14]
|
|
|
See the Comparison of Nvidia graphics processing units for more information.
Example
This example code in C++ loads a texture from an image into an array on the GPU:
cudaArray* cu_array;
texture<float, 2> tex;
// Allocate array
cudaChannelFormatDesc description = cudaCreateChannelDesc<float>();
cudaMallocArray(&cu_array, &description, width, height);
// Copy image data to array
cudaMemcpy(cu_array, image, width*height*sizeof(float), cudaMemcpyHostToDevice);
// Bind the array to the texture
cudaBindTextureToArray(tex, cu_array);
// Run kernel
dim3 blockDim(16, 16, 1);
dim3 gridDim(width / blockDim.x, height / blockDim.y, 1);
kernel<<< gridDim, blockDim, 0 >>>(d_odata, width, height);
cudaUnbindTexture(tex);
__global__ void kernel(float* odata, int height, int width)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
float c = tex2D(tex, x, y);
odata[y*width+x] = c;
}
Below is an example given in Python that computes the product of two arrays on the GPU. The python language bindings can be obtained from PyCUDA.
import pycuda.driver as drv
import numpy
import pycuda.autoinit
mod = drv.SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
const int i = threadIdx.x;
dest[i] = a[i] * b[i];
}
""")
multiply_them = mod.get_function("multiply_them")
a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)
dest = numpy.zeros_like(a)
multiply_them(
drv.Out(dest), drv.In(a), drv.In(b),
block=(400,1,1))
print dest-a*b
Additional Python bindings to simplify matrix multiplication operations can be found in the program pycublas.
import numpy
from pycublas import CUBLASMatrix
A = CUBLASMatrix( numpy.mat([[1,2,3],[4,5,6]],numpy.float32) )
B = CUBLASMatrix( numpy.mat([[2,3],[4,5],[6,7]],numpy.float32) )
C = A*B
print C.np_mat()
Language bindings
Future CUDA architectures
The next generation CUDA architecture (code name: "Fermi") that will be standard on NVIDIA's upcoming GeForce 300 Series (GT300 to be released available Q1 2010) GPU is designed from the ground up to natively support more programming languages such as C++ and other than it will have 8x the peak double precision floating-point performance compared to the previous generation NVIDIA's Tesla GPU it will also feature several new features[15] including:
- upto 512 CUDA cores and 3 billion transistors
- NVIDIA Parallel DataCache technology
- NVIDIA GigaThread™ engine
- ECC memory support
- Native support for Visual Studio
Current and Future usages of CUDA Architecture
- [1] - Real Time Cloth Simulation
- Distributed Calculations
- Medical Simulations
- Environment statistics
See also
- GeForce 8 series
- GeForce 9 series
- GeForce 200 Series
- GeForce 300 Series
- Nvidia Quadro - Nvidia's workstation graphics solution
- Nvidia Tesla - Nvidia's first dedicated general purpose GPU (graphics processing unit)
- GPGPU - general purpose computation on GPUs.
- OpenCL - The cross-platform standard supported by both NVidia and AMD/ATI
- DirectCompute - Microsoft API for GPU Computing in Windows Vista and Windows 7
- BrookGPU
- Lib Sh
- Comparison of MPI, OpenMP, and Stream Processing
- Nvidia Corporation
- Graphics Processing Unit (GPU)
- Stream processing
- Shader
- Jacket: A CUDA-engine for MATLAB
- Larrabee (GPU)
- Molecular modeling on GPU
- AMD FireStream (ATI GPUs)
- Close to Metal
References
- ^ NVIDIA Clears Water Muddied by Larrabee Shane McGlaun (Blog) - August 5, 2008 - DailyTech
- ^ First OpenCL demo on a GPU on YouTube
- ^ DirectCompute Ocean Demo Running on NVIDIA CUDA-enabled GPU on YouTube
- ^ Giorgos Vasiliadis, Spiros Antonatos, Michalis Polychronakis, Evangelos P. Markatos and Sotiris Ioannidis (2008, Boston, MA, USA). "Gnort: High Performance Network Intrusion Detection Using Graphics Processors" (PDF). Proceedings of the 11th International Symposium On Recent Advances In Intrusion Detection (RAID).
{{cite journal}}
: Check date values in:|year=
(help); Unknown parameter|month=
ignored (help)CS1 maint: multiple names: authors list (link) CS1 maint: year (link) - ^ Schatz, M.C., Trapnell, C., Delcher, A.L., Varshney, A. (2007). "High-throughput sequence alignment using Graphics Processing Units". BMC Bioinformatics. 8:474: 474. doi:10.1186/1471-2105-8-474.
{{cite journal}}
: CS1 maint: multiple names: authors list (link) CS1 maint: unflagged free DOI (link) - ^ Pyrit - Google Code http://code.google.com/p/pyrit/
- ^ Use your NVIDIA GPU for scientific computing, BOINC official site (December 18 2008)
- ^ NVIDIA CUDA Software Development Kit (CUDA SDK) - Release Notes Version 2.0 for MAC OSX
- ^ CUDA 1.1 - Now on Mac OS X- (Posted on Feb 14, 2008)
- ^ Silberstein, Mark (2007). "Efficient computation of Sum-products on GPUs" (PDF).
- ^ [http://www.herikstad.net/2009/05/cuda-and-double-precision-floating.html CUDA and double precision floating point numbers]
- ^ "CUDA-Enabled Products". CUDA Zone. NVIDIA Corporation. Retrieved 2008-11-03.
- ^ CUDA-Enabled GPU Products
- ^ http://www.nvidia.com/object/fermi_architecture.html The Next Generation CUDA Architecture, Code Named Fermi
External links
- Nvidia CUDA official website
- Nvidia Nexus, NVIDIA.
- Nvidia CUDA developer registration for professional developers and researchers
- Nvidia CUDA GPU Computing developer forums
- A conversation with Jen-Hsun Huang, CEO Nvidia Charlie Rose, February 5, 2009
- http://www.gpu4vision.org Scientific Publications, Videos and Software using CUDA
- Beyond3D – Introducing CUDA Nvidia's Vision for GPU Computing March 10, 2007
- University of Illinois Nvidia CUDA Course taught by Wen-mei Hwu and David Kirk, Spring 2009
- CUDA: Breaking the Intel & AMD Dominance
- A CUDA-based Engine for MATLAB
- NVidia CUDA Tutorial Slides (from DoD HPCMP2009)
- Ascalaph Liquid GPU molecular dynamics.
- CUDA implementation for multi-core processors
- Integrate CUDA with Visual C++, September 26, 2008
- CUDA.NET - .NET library for CUDA, Linux/Windows compliant
- Using NVIDIA GPU for scientific computing with BOINC software
- CUDA.CS.MSU.SU Russian CUDA developer community
- GPUmat: MATLAB(R) GPU Toolbox based on CUDA
- Enable Intellisense for CUDA in Visual Studio 2008, April 29, 2009
- CUDA Tutorials for high performance computing
- An introduction to CUDA (French)
- NVidia CUDA Tutorial & Examples (from ISC2009)
- GPUBrasil.com, First website on GPGPU in Portuguese
- [2], Implementation of CUDA in Cloth simulation
- DDJ CUDA series, First in the Doctor Dobb's Journal series teaching CUDA (over 13 articles by Rob Farber)