cuda
Table of Content
Versions and Availability
About the Software
CUDA is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU).
Usage
Programming using GPU with CUDA depends on the language, choice of compilers, and toolset.
▶ Open Example?
Standard C:
void saxpy( int n, float a, float *x, float *y ) { for ( int i = 0; i < n; ++i ) y[i] = a * x[i] + y[i]; } int N = 1 << 20; saxpy( N, 2.0, x, y );
C with CUDA Extensions:
__global__ void saxpy( int n, float a, float *x, float *y ) { int i = blockIdx.x*blockDim.x + threadIdx.x; if ( i < n ) y[i] = a * x[i] + y[i]; } int N = 1 << 20; cudaMemcpy(x, d_x, N, cudaMemcpyHostToDevice); cudaMemcpy(y, d_y, N, cudaMemcpyHostToDevice); saxpy<<<4096,256>>>(N, 2.0, x, y); cudaMemcpy(d_y, y, N, cudaMemcpyDeviceToHost);
Resources
Extensive trainings and tutorials available online, such as:
Last modified: September 10 2020 11:58:50.