Saltar al contenido ForoHackers

GPU programming: start here

Programación de GPU
#2979 · · Citar · Denunciar

A GPU is a processor built for doing the same small job on thousands of data items at once. It draws images, but it also speeds up simulation, image processing and machine learning. Programming one means thinking in massive parallelism and in memory movement, since moving data usually costs more than computing on it.

Key concepts

  • Data parallelism: one kernel or shader runs over many threads, each handling one element.
  • Execution model: threads grouped into blocks or workgroups, run in lockstep bundles; branches that diverge within a bundle slow it down.
  • Memory hierarchy: global memory is large and slow; shared or local memory is small and fast; registers are fastest.
  • Host and device: the CPU prepares data and launches work; copies across the bus must be minimised.
  • Occupancy and bandwidth: keep enough threads in flight to hide memory latency, and check whether you are limited by compute or by memory.

Vocabulary

  • Kernel: a function launched on the GPU across many threads.
  • Shader: a GPU program in the graphics pipeline, such as a vertex or fragment shader.
  • Coalescing: neighbouring threads reading neighbouring addresses so the hardware merges the loads.
  • Compute API: CUDA, OpenCL, or the compute stages of graphics APIs such as Vulkan.

What to study, in order

  1. Parallel thinking on the CPU: map, reduce and scan over arrays.
  2. Write a vector addition kernel and time it, including the copies.
  3. Implement a matrix multiplication naively, then with shared-memory tiling; measure the gap.
  4. Write a fragment shader that draws something, then a compute shader that processes an image.
  5. Use a profiler to decide whether each kernel is bound by memory or by arithmetic.

Related tags

#computer-graphics #hpc #computer-architecture #deep-learning

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder