# Programowanie GPU (CUDA)

EN: **GPU programming (CUDA)** · id `gpuprog`

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Inferencja i infrastruktura](https://aiatlasgraph.com/t/systems.md) › [GPU i obliczenia rozproszone](https://aiatlasgraph.com/t/compute.md) › Programowanie GPU (CUDA)

## Description

- PL: Model wykonania na GPU: wątki, bloki, hierarchia pamięci.
- EN: The GPU execution model: threads, blocks, the memory hierarchy.

## In one sentence

- PL: To pisanie obliczeń tak, żeby wiele małych zadań pracowało równocześnie na karcie graficznej.
- EN: This programs computations as many small tasks running simultaneously on a graphics card.

## Problem it solves

- PL: Program napisany jak zwykłe kolejne instrukcje nie wykorzystuje dobrze równoległej pracy karty.
- EN: A program written as ordinary sequential instructions does not make good use of a card's parallel execution.

## What it does

- PL: Zadania grupuje się w wątki i bloki, dobierając dostęp do różnych poziomów pamięci oraz współpracę między nimi.
- EN: Tasks are grouped into threads and blocks, with memory access and cooperation arranged across different memory levels.

## Everyday example

- PL: Dzielisz przeliczanie dużej tabeli liczb między równoległe grupy, zamiast obrabiać każdy element po kolei.
- EN: You split a large numerical table across parallel groups instead of processing each element sequentially.

## This concerns you if you…

- PL: piszesz własne obliczenia dla karty graficznej
- PL: chcesz wykorzystać równoległość sprzętu
- EN: write custom graphics-card computations
- EN: want to use hardware parallelism

## Keywords

CUDA · thread blocks · warps · shared memory · memory coalescing · register pressure · warp divergence

## How it works

- PL: Kernel uruchamia siatkę bloków wątków, które mapują indeksy pracy na dane. Wątki współdzielą zasoby według hierarchii wykonania, a układ dostępu, synchronizacja i wykorzystanie rejestrów wpływają na przepustowość.
- EN: A kernel launches a grid of thread blocks mapping work indices to data. Threads share resources according to the execution hierarchy, while access patterns, synchronisation and register usage affect throughput.

## Limits

- PL: Rozbieżne ścieżki i niespójne dostępy do pamięci marnują przepustowość. Bariery muszą być poprawnie użyte; liczba rejestrów oraz pamięć współdzielona ograniczają współbieżne bloki.
- EN: Divergent paths and incoherent memory access waste throughput. Barriers require correct use; register counts and shared memory limit concurrent blocks.

## Key terms

- PL: **blok wątków**: Grupa wątków mogących współdzielić lokalną pamięć i synchronizację.
- PL: **coalescing**: Łączenie sąsiednich dostępów wątków w wydajne transfery pamięci.
- EN: **thread block**: A thread group able to share local memory and synchronisation.
- EN: **coalescing**: Combining neighbouring thread accesses into efficient memory transfers.

## Know first

- [Algebra liniowa: wektory i macierze (Linear algebra: vectors and matrices)](https://aiatlasgraph.com/t/linearalgebra.md)
- [Akceleratory (AI hardware)](https://aiatlasgraph.com/t/hardware.md)

## Examples

- PL: CUDA · wątki i bloki · pamięć współdzielona
- EN: CUDA · threads and blocks · shared memory

## Sources

- [Performance Engineering for AI Infra — learning guide](<https://github.com/wafer-ai/gpu-perf-engineering-resources>) `wafer-gpu` · GitHub repository · tiered curriculum (Tier 1–3) · MIT licence · by Wafer (wafer-ai): Company material with a hiring note, but the evidence is mostly primary sources. Table of contents sieved: only topics became nodes; tiers kept as link labels.

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/gpuprog · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
