Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CAP 4730
Spring 2012
Tushar Athawale
Resources
• What is GPGPU?
– General purpose computing on GPUs
• Why GPGPU?
– Massively parallel computing power
– Hundreds of cores, thousands of concurrent
threads
– Inexpensive
CPU v/s GPU
• How?
– CUDA
– OpenCL
– DirectCompute
CUDA
void main(){
…
[CPU (serial) code]
…
matrix_mul<<<dimGrid, dimBlock>>>(…)
…
[CPU (serial) code]
…
}
Compiling
© NVIDIA Corporation
Programming Model
© NVIDIA Corporation
Transparent Scalability
© NVIDIA Corporation
Memory Model
Block (0,0) Block (1,0)
Shared Memory Shared Memory
Global
Memory
Constant
Host Memory
Texture
Memory
© NVIDIA Corporation
#include <stdio.h>
#include <cuda.h>
int i;
// Initialize vectors on host
for( i = 0; i < n; i++ ) {
h_a[i] = sin(i)*sin(i);
h_b[i] = cos(i)*cos(i);
}
// Sum up vector c and print result divided by n, this should equal 1 within error
double sum = 0;
for(i=0; i<n; i++)
sum += h_c[i];
printf("final result: %f\n", sum/n);
return 0;
}
Thank you
• http://developer.download.nvidia.com/prese
ntations/2009/SIGGRAPH/Alternative_Ren
dering_Pipelines.mp4