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
- Declaring __shared__ Arrays
- Synchronizing with __syncthreads
- Avoiding Bank Conflicts
- Dynamic Shared Memory