Compromissos da memória global
Grande, lenta e visível para todas as threads.
Compromissos da memória global é uma aula grátis de CUDA Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de CUDA Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de CUDA Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
The Biggest Space You Have
Global memory is the GPU's main DRAM, often many gigabytes. It is where your big input and output arrays naturally live during a kernel.
Visible to Everyone
Every thread in every block can read and write global memory. That shared visibility is exactly why you copy your data there before launching. 🌍
You Allocate It with cudaMalloc
You reserve global memory from the host with cudaMalloc, which hands you a device pointer to that DRAM region.
float *d_a;
cudaMalloc(&d_a, n * sizeof(float));Large but Slow
The catch is latency. A single global memory read can cost hundreds of clock cycles, far more than a register access ever would.
Bandwidth Is the Real Limit
Many kernels are bound not by math but by how fast bytes flow from DRAM. We call these memory-bound kernels.
Hiding Latency with Threads
The GPU hides slow reads by switching to other ready warps while one waits. This latency hiding is why having many threads matters so much.
It Persists Across Launches
Data in global memory stays put between kernel launches until you free it. You can run several kernels over the same buffers.
Cached by L2
A unified L2 cache sits in front of global memory for the whole GPU. Reused addresses can be served from it instead of slow DRAM.
Access Pattern Decides Speed
How threads map to addresses hugely affects throughput. Neighboring threads touching neighboring addresses is what later lessons call coalescing.
Minimize the Trips
The core strategy is simple: touch global memory as few times as possible. Read once, reuse on-chip, then write once.
Free What You Allocate
Because global memory is a finite resource, release it with cudaFree when you are done to avoid leaking device memory.
cudaFree(d_a);Quick Check
Which statement best captures the tradeoff of global memory?
Recap: Big, Shared, Slow
You now know global memory is the GPU's large, all-visible DRAM that trades capacity for high latency. Touch it rarely and reuse data on-chip. 🚀
Perguntas Frequentes
A aula “Compromissos da memória global” é grátis?
Sim — o texto completo de “Compromissos da memória global” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de CUDA Academy, atualize para CoddyKit PRO. O curso de CUDA Academy inclui 4 aulas no total.
O que vou aprender em “Compromissos da memória global”?
Grande, lenta e visível para todas as threads. Você pratica CUDA Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar CUDA Academy?
Nenhuma experiência prévia é necessária. CUDA Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.
Quanto tempo leva a aula “Compromissos da memória global”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de CUDA Academy?
Sim. Cada aula de CUDA Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Registradores e memória local
- Compromissos da memória global
- Memória constante e seu cache
- Um modelo mental da hierarquia