본문 바로가기

프로그래밍

CUDA intro

CUDA

Main-Features

  • C/C++ with extensions
  • Heterogeneous programming model
  • Host(CPU) => Device(GPU) Cuda kernel function
    • Parallel kernel

CUDA Device and Threads

  • Device(GPU)
    • Has access to DRAM (device memory)
    • Runs many threads in parallel
    • GPU threads are extremely lightweight
    • GPU needs 1000s of threads for full efficiency

Grid, Block, Thread

1 Kernel = 1 Grid

  • C Language Extention
    • <<<BlocksPerGrid, threadsPerBlock>>>
    • dim3 blcoksPerGrid(65535, 65535, 1)
    • dim3 threadsPerBlock(1024, 1,1)
    • <<<blocksPerGrid, ThreadsPerBlock>>>>

Codes

  • Device pointers point to GPU memory
  • Host pointers point to CPU memroy
  • cudaMalloc(), cudaFree(), cudaMemcpy()