Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CUDA Kernels

A collection of high-performance CUDA kernels for parallel computing tasks. I'm writing these as I learn CUDA.

Kernels

kernel time reference impl.
vector add 0.017 ± 0.001 ms 0.016 ± 0.001 ms

Measured on my RTX 3090 discrete GPU. Size of arrays found in tests (./src/tests), also same sizes between my kernels and the PyTorch/Triton ones.

Usage

1. Clone the repository:

git clone https://github.com/stefanasandei/cuda-kernels.git --recursive
cd cuda-kernels

If you forgot the --recursive flag, run this to fetch submodules:

git submodule update --init --recursive

2. Create build directory:

mkdir build && cd build

3. Configure with CMake:

cmake ..

4. Build the project:

make -j$(nproc)

Afterwards you can run the tests:

./tests/tests

Project Structure

cuda-kernels/
├── CMakeLists.txt          # Root build configuration
├── lib/
│   ├── CMakeLists.txt      # Library build config
│   ├── common/             # Common utility files
│   └── googletest/         # Google Test framework
├── src/
│   ├── CMakeLists.txt      # Source build config
│   └── example_kernel/
│       └── example_kernel.cu   # kernel implementation
└── tests/
    ├── CMakeLists.txt      # Test build configuration
    └── example_kernel.cpp   # tests for the kernel

Adding New Kernels

  1. Create a new directory in src/ for your kernel
  2. Implement the kernel in a .cu file
  3. Add the host wrapper function declaration in the ./src/kernels.h file
  4. Add unit tests in tests/, a cpp file that calls the host wrapper

The vector_add kernel is the simplest one, as an example for the implementation.

License

MIT © Asandei Stefan-Alexandru. All rights reserved.

About

a few kernels I'm writing while learning CUDA

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages