Tuesday 30 May 2017

Which memory is used by all threads in a single block?


                       All threads in a single block share the Shared Memory.

 Shared Memory:
On one SP, one or more threads can be run. A collection of threads is called a Block. On one SM, one or more blocks can be run. Shared memory is shared by all the threads in one block. Shared memory is used to reduce the latency(memory access delay). How? See, Global memory is very big in size as compared to shared memory. So definitely, search time for a location of variable is lesser for shared memory compared to global memory. Keep in mind, shared memory in one SM is shared by all threads in one block. When we have to use shared memory for a variable, it should be prefixed with keyword __shared__ during its declaration. For e.g. __shared__ int x. 

No comments:

Post a Comment