Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 687 Bytes

File metadata and controls

23 lines (15 loc) · 687 Bytes

Vector Addition

Basic CUDA program demonstrating parallel vector addition.

Description

This program performs element-wise addition of two vectors using CUDA. Each thread computes one element of the result vector, demonstrating the fundamental CUDA programming pattern of parallel execution.

Building and Running

cd vector_add
nvcc main.cpp vector_add.cu -o vector_add
./vector_add

How it Works

  • The program generates two random vectors
  • Launches a CUDA kernel where each thread computes one element: C[i] = A[i] + B[i]
  • Uses 256 threads per block with appropriate grid sizing
  • Demonstrates basic CUDA memory management (allocation, copying, freeing)