0Pricing
CUDA Academy · Lesson

Dynamic Shared Memory

Sizing shared memory at launch time.

When Size Is Not Known Yet

Sometimes the shared array size depends on a runtime value, so you cannot hardcode it. CUDA solves this with dynamic shared memory.

The extern Declaration

You declare it with extern __shared__ and empty brackets. No size goes in the code, so the compiler leaves it open.

extern __shared__ float sdata[];

All lessons in this course

  1. Declaring __shared__ Arrays
  2. Synchronizing with __syncthreads
  3. Avoiding Bank Conflicts
  4. Dynamic Shared Memory
← Back to CUDA Academy