Ventajas y costes de la memoria global
Es grande, lenta y visible para todos los hilos.
Ventajas y costes de la memoria global es una lección gratuita de CUDA Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de CUDA Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de CUDA Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en 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. 🚀
Preguntas frecuentes
¿La lección «Ventajas y costes de la memoria global» es gratis?
Sí — el texto completo de «Ventajas y costes de la memoria global» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de CUDA Academy, actualiza a CoddyKit PRO. El curso de CUDA Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Ventajas y costes de la memoria global»?
Es grande, lenta y visible para todos los hilos. Practicas CUDA Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar CUDA Academy?
No se requiere experiencia previa. CUDA Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Ventajas y costes de la memoria global»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de CUDA Academy?
Sí. Cada lección de CUDA Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Registros y memoria local
- Ventajas y costes de la memoria global
- Memoria constante y su caché
- Un modelo mental de la jerarquía