This project contains several CUDA examples demonstrating basic operations using CUDA programming. The examples include vector addition, matrix multiplication, and basic image processing tasks.
cuda-examples
├── src
│ ├── vector_addition.cu
│ ├── matrix_multiplication.cu
│ └── image_processing.cu
├── include
│ └── utils.cuh
├── CMakeLists.txt
├── .gitignore
└── README.md
The vector_addition.cu file contains a CUDA kernel for adding two vectors. It includes functions for memory allocation on the GPU, data transfer from the host to the device, kernel execution, and copying results back to the host.
The matrix_multiplication.cu file implements a CUDA kernel for multiplying two matrices. It includes functions for memory allocation, data transfer, kernel execution, and result retrieval.
The image_processing.cu file provides a CUDA implementation for basic image processing tasks, such as filtering or edge detection. It includes functions for loading images, applying filters using CUDA kernels, and saving the processed images.
The utils.cuh header file contains utility functions and definitions used across the CUDA source files, including error checking and memory management functions.
To build the project, you will need CMake and a CUDA-capable GPU. Follow these steps:
-
Clone the repository:
git clone <repository-url> cd cuda-examples -
Create a build directory:
mkdir build cd build -
Run CMake to configure the project:
cmake .. -
Build the project:
make
After building the project, you can run the examples by executing the compiled binaries located in the build directory.
- CUDA Toolkit (version X.X or higher)
- CMake (version X.X or higher)