Un modelo mental de la jerarquía
Asigne los datos al espacio adecuado.
Un modelo mental de la jerarquía es una lección gratuita de CUDA Academy en CoddyKit. Esta es la lección 4 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.
A Pyramid of Tradeoffs
Think of GPU memory as a pyramid. The top is tiny and lightning fast, while the base is huge but slow. Your job is to use each layer well.
Top: Registers
At the peak sit registers: per-thread, fastest, and very limited. Keep your hottest working values here whenever you possibly can.
Next: Shared Memory
Just below comes shared memory, an on-chip scratchpad visible to all threads in a block. It is your tool for fast intra-block teamwork.
Side Path: Constant Cache
Alongside sits the constant cache, ideal for small read-only values that a warp reads uniformly and broadcasts in one fetch.
Base: Global Memory
The wide base is global memory: gigabytes, visible to everyone, but high-latency. It holds your big inputs and outputs.
The Trap: Local Memory
Watch out for local memory. It sounds close by but lives in slow DRAM, used only when registers spill. Avoid relying on it.
Scope Decides the Space
Pick by who needs the data. One thread alone wants registers, a block working together wants shared memory, everyone wants global.
Lifetime Decides Too
Registers and shared memory vanish when a kernel ends, but global memory persists across launches. Match storage to how long data must live.
The Golden Rule
The winning pattern is load once from global, compute in fast on-chip memory, then write once back. This minimizes slow global memory traffic.
Capacity Costs Occupancy
Spending lots of registers or shared memory per block lets fewer blocks run at once. Occupancy is the balance you constantly tune.
Putting It Together
Great kernels deliberately route each piece of data to the right layer. That single habit is what separates slow code from fast CUDA code. 💪
Quick Check
Two threads in the SAME block need to share intermediate results. Which space fits best?
Recap: Match Data to Layer
You built a mental map: registers, shared, constant, and global trade speed for size and scope. Routing data to the right layer is the whole game. 🧠
Preguntas frecuentes
¿La lección «Un modelo mental de la jerarquía» es gratis?
Sí — el texto completo de «Un modelo mental de la jerarquía» 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 «Un modelo mental de la jerarquía»?
Asigne los datos al espacio adecuado. 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 4 de 4.
¿Cuánto tiempo toma la lección «Un modelo mental de la jerarquía»?
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