x // This variable contains the thread index within the block in x-dimension. Unlike global memory, there is no penalty for strided access of shared memory. One use of shared memory is to extract a 2D tile of a multidimensional array from global memory in a coalesced fashion into shared memory, and then have contiguous threads stride through the shared memory tile. ![]() Shared memory is an on-chip memory shared by all threads in a thread block. ![]() We can handle these cases by using a type of CUDA memory called shared memory. When accessing multidimensional arrays it is often necessary for threads to index the higher dimensions of the array, so strided access is simply unavoidable. Threads can access data in shared memory loaded from global memory by other threads within the same thread block. Shared memory is allocated per thread block, so all threads in the block have access to the same shared memory. In fact, shared memory latency is roughly 100x lower than uncached global memory latency (provided that there are no bank conflicts between the threads). Has the lifetime ofīecause the shared memory is on-chip, it is much faster than local and global memory. Has the lifetime of theĪpplication - it is persistent between kernel launches.Ī potential performance gotcha, it resides in global memory and can be 150x slower Accessible from either the host or device. Potentially 150x slower than register or shared memory - watch out for uncoalesced Accessible by any thread of the block from which it was created.Īccessible by all threads. Is only accessible by the thread.Ĭan be as fast as a register when there are no bank conflicts or when reading from The fastest form of memory on the multi-processor. _device_ is optional when used with _local_, _shared_, or _constant_
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |