GPU resources https://github.com/karpathy/llm.c
https://siboehm.com/articles/22/CUDA-MMM
Tiling1 : https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/writing-tile-kernels.html
Tiling2 : https://cvw.cac.cornell.edu/cuda-intro/gpu-performance-topics/tiling Tiling video : http://youtube.com/watch?v=ccHyFnEZt7M
Cornell cuda intro : https://cvw.cac.cornell.edu/cuda-intro/ Tensor cores : https://youtu.be/Yt1A-vaWTck Tensor cores2 : https://tgautam03.github.io/2024/10/30/TensorCores/
tensor cores3 : https://www.glennklockwood.com/garden/tensor-cores
Theory of GPU Basic Terms : Host : CPU device Device : GPU device CUDA : compute unified device architecture, these are used when we need to do write code for nvidia gpus ROCm : Radeon open compute platform, used when we need to write for amd gpus MSL : Metal shading language to run directly on apple graphics, for macos Logical : a software construct, something that is written in software to make it simpler / easier for people to understand Physical : its a physical / hardware level definition that we make here means this is present in hardware Terms: Threads : So smallest execution unit on a GPU is a thread, its role is to complete an atomic instruction on SM Warp : Group of 32 threads that are sequential and in same thread block is called a warp ( they are faster cause they use Shared memory) .. this is useful if the data needs to be shared among all like in reduce operations. Active mask : So this is used to define which all threads to use in a warp so a mask looks like this 0x00000001 or this 0xFFFFFFFF blocks : Group / Collection of threads (cuda limits this no. of threads to 1024) make up a thread block grid : group of blocks in a gpu makes up a grid ( where blocks are arranged ) Streaming Multiprocessors : the fundamental building block of an NVIDIA GPU, this is where the operations are executed on cuda cores Tiling : A software memory strategy. It is a technique where you break down large datasets into small chunks (“tiles”) that fit inside fast, local SRAM (Shared Memory or Registers) to avoid pulling repeatedly from slow VRAM. (memory bound ops with high data reuse) SIMT (Single Instruction, Multiple Threads) means that multiple threads execute the same instruction at the same time, but each thread operates on its own data. Here we need a global thread index , loads SIMD (Single instruction multiple data) : TODO Tile kernel : level of entire tile block, load a whole tile, perform ops on that tile and store back the tile Single thread : There is nothing as single thread in a GPU execution. even if you define <<<1,1>>> its basically initiating a full 32 thread hardware warp to execute a single thread. Just that active mask changes in this case Cuda stream : single stream vs multiple streams TODO sync vs async GPU operations Memory layout in GPU memory dimension in GPU
...