CUDA Deep Dive – Performance
CSE 6230
Jee Choi September 10, 2013
Performance Target Tesla M2090 512 CUDA processors @ 1.3 GHz each - - PowerPoint PPT Presentation
CUDA Deep Dive Performance CSE 6230 Jee Choi September 10, 2013 Performance Target Tesla M2090 512 CUDA processors @ 1.3 GHz each processor is capable of issuing 1 FMA (2 flops) instruction per cycle throughput = 512 1.3
Jee Choi September 10, 2013
warp ¡ scheduler ¡ warp ¡ scheduler ¡ shared ¡memory ¡/ ¡ ¡ L1 ¡cache ¡(64 ¡KB) ¡ register ¡file ¡ (32,768 ¡× 32-bit) ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡ CP ¡
– in each cycle, dual warp scheduler selects two warps and issues one instruction from each warp to a group of sixteen cores
– each thread currently residing on the multiprocessor gets its own register set
– an instruction that has been scheduled from a warp is assigned to a group of 16 cores – it takes 2 cycles to issue 1 warp (first half-warp
second cycle)
– 64 KB can be configured to give 48 KB or 16 KB to shared memory, and the rest to L1 cache – shared memory is “shared” amongst the thread blocks currently residing on the SM
Streaming ¡ MulGprocessor ¡(SM) ¡
a = a * b + c; // 1) takes 24 cycles to complete a = a * b + c; // 2) stalled because of dependency on 1) x = x * y + z; // 3) issued immediately after 2) because no dependency a = a * b + c; // 4) stalled because of dependency on 2) X = x * y + z; // 5) immediately issued after 4) because by the time 4) // was issued 3) was on its last cycle
a = a * b + c; // 1) takes 24 cycles to complete a = a * b + c; // 2) stalled because of dependency on 1) x = x * y + z; // 3) issued immediately after 2) because no dependency a = a * b + c; // 4) stalled because of dependency on 2) X = x * y + z; // 5) immediately issued after 4) because by the time 4) // was issued 3) was on its last cycle
instrucGon ¡1 ¡ instrucGon ¡1 ¡issued ¡
a = a * b + c; // 1) takes 24 cycles to complete a = a * b + c; // 2) stalled because of dependency on 1) x = x * y + z; // 3) issued immediately after 2) because no dependency a = a * b + c; // 4) stalled because of dependency on 2) X = x * y + z; // 5) immediately issued after 4) because by the time 4) // was issued 3) was on its last cycle
instrucGon ¡1 ¡ instrucGon ¡2 ¡issued ¡ instrucGon ¡2 ¡ 24 ¡cycles ¡
a = a * b + c; // 1) takes 24 cycles to complete a = a * b + c; // 2) stalled because of dependency on 1) x = x * y + z; // 3) issued immediately after 2) because no dependency a = a * b + c; // 4) stalled because of dependency on 2) X = x * y + z; // 5) immediately issued after 4) because by the time 4) // was issued 3) was on its last cycle
instrucGon ¡1 ¡ instrucGon ¡3 ¡issued ¡ instrucGon ¡2 ¡ instrucGon ¡3 ¡ 26 ¡cycles ¡
a = a * b + c; // 1) takes 24 cycles to complete a = a * b + c; // 2) stalled because of dependency on 1) x = x * y + z; // 3) issued immediately after 2) because no dependency a = a * b + c; // 4) stalled because of dependency on 2) X = x * y + z; // 5) immediately issued after 4) because by the time 4) // was issued 3) was on its last cycle
instrucGon ¡1 ¡ instrucGon ¡2 ¡ instrucGon ¡3 ¡ instrucGon ¡4 ¡
a = a * b + c; // 1) takes 24 cycles to complete a = a * b + c; // 2) stalled because of dependency on 1) x = x * y + z; // 3) issued immediately after 2) because no dependency a = a * b + c; // 4) stalled because of dependency on 2) X = x * y + z; // 5) immediately issued after 4) because by the time 4) // was issued 3) was on its last cycle
instrucGon ¡1 ¡ instrucGon ¡2 ¡ instrucGon ¡3 ¡ instrucGon ¡4 ¡ instrucGon ¡5 ¡
have ¡completed ¡
73 ¡instrucGons ¡to ¡ achieve ¡peak ¡ 73 ¡cycles ¡
Latency (W) Bandwidth (λ) tens of thousands of in-flight requests!!!
for(i=0; i< N; i++) { a = a * b + c; // no ILP; requires 6 warps to achieve peak } `
for(i=0; i< N; i++) { a = a * b + c; // 2 independent instructions; ILP is 2 d = d * e + f; } `
for(i=0; i< N; i++) { a = a * b + c;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.6
GFLOP/s
1/2 1 2 4 8 16 32 64 128
Intensity (FLOP:Byte) Relative performance
system’s “balance”
1/32 1/16 1/8 1/4 1/2 1
3.6
GFLOP/s
1/2 1 2 4 8 16 32 64 128
Intensity (FLOP:Byte) Relative performance
Compute bound Memory (bandwidth) bound
1/32 1/16 1/8 1/4 1/2 1
3.6
GFLOP/s
1/2 1 2 4 8 16 32 64 128
Intensity (FLOP:Byte) Relative performance
application’s computational intensity
1/32 1/16 1/8 1/4 1/2 1
3.6
GFLOP/s
1/2 1 2 4 8 16 32 64 128
Intensity (FLOP:Byte) Relative performance
expected performance
for(i=0; i< N; i++) { // row for(j=0; j < N; j++) { // column for(k = 0; k < N; k++) C[i][j] += A[i][k] * B[k][j]; // 2 flops and 2 words } } }
N ¡ Time ¡ Performance ¡ Speedup ¡ Naïve ¡ 1024 ¡ 29.63 ¡ms ¡ 72.48 ¡GFLOP/s ¡ 1.0× ¡
C B A
N ¡ Time ¡ Performance ¡ Speedup ¡ Naïve ¡ 1024 ¡ 29.63 ¡ms ¡ 72.48 ¡GFLOP/s ¡ 1.0× ¡ shared ¡ memory ¡ 1024 ¡ 9.44 ¡ms ¡ 227.6 ¡GFLOP/s ¡ 3.1× ¡
N ¡ Time ¡ Performance ¡ Speedup ¡ Naïve ¡ 1024 ¡ 29.63 ¡ms ¡ 72.5 ¡GFLOP/s ¡ 1.0× ¡ shared ¡ memory ¡ 1024 ¡ 9.44 ¡ms ¡ 227.6 ¡GFLOP/s ¡ 3.1× ¡ shared ¡ memory ¡+ ¡2 ¡ targets/thread ¡ 1024 ¡ 6.46 ¡ms ¡ 332.3 ¡GFLOP/s ¡ 4.6× ¡
N ¡ Time ¡ Performance ¡ Speedup ¡ Naïve ¡ 1024 ¡ 29.63 ¡ms ¡ 72.5 ¡GFLOP/s ¡ 1.0× ¡ shared ¡ memory ¡ 1024 ¡ 9.44 ¡ms ¡ 227.6 ¡GFLOP/s ¡ 3.1× ¡ shared ¡ memory ¡+ ¡2 ¡ targets/thread ¡ 1024 ¡ 6.46 ¡ms ¡ 332.3 ¡GFLOP/s ¡ 4.6× ¡ shared ¡ memory ¡+ ¡4 ¡ targets/thread ¡ 1024 ¡ 5.05 ¡ms ¡ 424.7 ¡GFLOP/s ¡ 5.9× ¡
N ¡ Time ¡ Performance ¡ Speedup ¡ Naïve ¡ 1024 ¡ 29.63 ¡ms ¡ 72.5 ¡GFLOP/s ¡ 1.0× ¡ shared ¡ memory ¡ 1024 ¡ 9.44 ¡ms ¡ 227.6 ¡GFLOP/s ¡ 3.1× ¡ shared ¡ memory ¡+ ¡2 ¡ targets/thread ¡ 1024 ¡ 6.46 ¡ms ¡ 332.3 ¡GFLOP/s ¡ 4.6× ¡ shared ¡ memory ¡+ ¡4 ¡ targets/thread ¡ 1024 ¡ 5.05 ¡ms ¡ 424.7 ¡GFLOP/s ¡ 5.9× ¡ shared ¡ memory ¡+ ¡8 ¡ targets/thread ¡ 1024 ¡ 4.53 ¡ms ¡ 474.2 ¡GFLOP/s ¡ 6.5× ¡