

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















Several slides from Wen-Mei Hwu and David Kirk’s course
-^
-> Blocks, Warps
-^
Thread Processor
-> Threads
-^
-^
Registers
available processing and memory resources
Use results only when computations are complete
-^
No simultaneous writes, etc.
-^
-^
Parallel Memory Sharing
-^
Private per thread
-^
Auto variables, register spill
-^
Shared by threads of the sameblock
-^
Inter-thread communication
-^
Shared by all threads
-^
Inter-Grid communication
-^
Results; Host communication
Thread
Local Memory
Grid 0
...
GlobalMemory
...
Grid 1
SequentialGridsin Time
Block
SharedMemory
SM Memory Architecture
-^
In Memory and Shared Memory
-^
Synchronize at barrier instruction
-^
Keeps data close to processor
-^
Minimize trips to global Memory
-^
Shared Memory is
dynamically
allocated
to blocks, one of the
limiting resources
t0 t1 t2 … tm^ Blocks
Texture L MT IU SP SharedMemory
MT IU SP SharedMemory
TF
L
Memory
t0 t1 t2 … tm
Blocks
Courtesy:John Nicols, NVIDIA
Matrix Multiplication Example
-^
If each Block has 16×16 threads and each thread uses10 registers, how many threads can run on each SM?^ – Each block requires 10*256 = 2560 registers– 8192 =
-^
How about if each thread increases the use of registersby 1?^ – Each Block now requires 11*256 = 2816 registers– 8192 < 2816 *3– Only two Blocks can now fit on the SM,–
More on Dynamic Partitioning
-^
Dynamic partitioning gives more flexibility tocompilers/programmers^ – One can run a smaller number of threads that require many
models.
Global Memory
-^
global memory space is not cached
-^
important to follow the right access pattern to getmaximum memory bandwidth
-^
access is costly – 400-600 clock cycles
-^
For efficiency the access must result in fewerinstructions, and fewer address computations
-^
Device can read 32-bit, 64-bit, or 128-bit words fromglobal memory into registers in a single instruction.
-^
Structures and arrays must align on these byteboundaries to minimize number of instructions.
Example
-^
struct align(16) {float a;float b;float c;float d;float e;};
-^
Examples of CoalescedGlobal Memory Access
-^
Left: coalesced
float
memory access,resulting in a singlememory transaction.
-^
Right: coalesced
float
memory access(divergent warp),resulting in a singlememory transaction.
Noncoalesced access •^
Left: non-sequential float
memory access,
resulting in 16memory transactions.
-^
Right: access with amisaligned startingaddress, resulting in16 memorytransactions.
-^
In newer machinesthis is fixed
M
2,
M
1, M
1,
M
0, M
0,
M
3,
M
2,
M
3,
Memory Layout of a Matrix in C^ M
2,
M
1,
M
0,
M
3,
M
1,
M
0,
M
2,
M
3,
M
1,
M
0,
M
2,
M
3,
M
1,
M
0,
M
2,
M
3,
M
1,
M
0,
M
2,
M
3,
M
1,
M
0,
M
2,
M
3,
Memory Coalescing
-^
When accessing global memory, peak performanceutilization occurs when all threads in a half warpaccess continuous memory locations.
Md
Nd
WIDTH
WIDTH
Shared Memory
-^
banks
of 32 bit words
-^
read and write access
I$L MultithreadedInstruction Buffer RF
C$L
SharedMem
Operand Select MAD
SFU
Parallel Memory Architecture
-^
In a parallel machine, many threads access memory^ –
-^
Each bank can service one address per cycle^ –
-^
Multiple simultaneous accesses to a bankresult in a
bank conflict
Bank 0 Bank 1 Bank 2 Bank 3 Bank 4 Bank 5 Bank 6 Bank 7 Bank 15