44
CUDA GPU Occupancy Calculator 1.) Select Compute Capability (click): 3.5 1.b) Select Shared Memory Size Config (bytes) 49152 2.) Enter your resource usage: Threads Per Block 256 Registers Per Thread 32 Shared Memory Per Block (bytes) 4096 (Don't edit anything below this line) 3.) GPU Occupancy Data is displayed here and in the graphs: Active Threads per Multiprocessor 2048 Active Warps per Multiprocessor 64 Active Thread Blocks per Multiprocessor 8 Occupancy of each Multiprocessor 100% Physical Limits for GPU Compute Capability: 3.5 Threads per Warp 32 Warps per Multiprocessor 64 Threads per Multiprocessor 2048 Thread Blocks per Multiprocessor 16 Total # of 32-bit registers per Multiprocessor 65536 Register allocation unit size 256 Register allocation granularity warp Registers per Thread 255 Shared Memory per Multiprocessor (bytes) 49152 Shared Memory Allocation unit size 256 Warp allocation granularity 4 Maximum Thread Block Size 1024 Allocated Resources Per Block Limit Per SM Warps (Threads Per Block / Threads Per Warp) 8 64 8 Registers (Warp limit per SM due to per-warp reg count) 8 64 8 Shared Memory (Bytes) 4096 49152 12 Note: SM is an abbreviation for (Streaming) Multiprocessor Maximum Thread Blocks Per Multiprocessor Blocks/SM * Warps/Block = Warps/SM Limited by Max Warps or Max Blocks per Multiprocessor 8 8 64 Limited by Registers per Multiprocessor 8 8 64 Limited by Shared Memory per Multiprocessor 12 8 0 Note: Occupancy limiter is shown in orange Physical Max Warps/SM = 64 Just follow steps 1, 2, and 3 below! (or click here for help) (Help) (Help) (Help) = Allocatable Blocks Per SM

CUDA Occupancy Calculator

Embed Size (px)

DESCRIPTION

Calculador de memoria en CUDA

Citation preview

Page 1: CUDA Occupancy Calculator

CUDA GPU Occupancy Calculator

1.) Select Compute Capability (click): 3.51.b) Select Shared Memory Size Config (bytes) 49152

2.) Enter your resource usage:Threads Per Block 256Registers Per Thread 32Shared Memory Per Block (bytes) 4096

(Don't edit anything below this line)

3.) GPU Occupancy Data is displayed here and in the graphs:Active Threads per Multiprocessor 2048Active Warps per Multiprocessor 64Active Thread Blocks per Multiprocessor 8Occupancy of each Multiprocessor 100%

Physical Limits for GPU Compute Capability: 3.5Threads per Warp 32Warps per Multiprocessor 64Threads per Multiprocessor 2048Thread Blocks per Multiprocessor 16Total # of 32-bit registers per Multiprocessor 65536Register allocation unit size 256Register allocation granularity warpRegisters per Thread 255Shared Memory per Multiprocessor (bytes) 49152Shared Memory Allocation unit size 256Warp allocation granularity 4Maximum Thread Block Size 1024

Allocated Resources Per Block Limit Per SMWarps (Threads Per Block / Threads Per Warp) 8 64 8

Registers (Warp limit per SM due to per-warp reg count) 8 64 8Shared Memory (Bytes) 4096 49152 12Note: SM is an abbreviation for (Streaming) Multiprocessor

Maximum Thread Blocks Per Multiprocessor Blocks/SM * Warps/Block = Warps/SMLimited by Max Warps or Max Blocks per Multiprocessor 8 8 64

Limited by Registers per Multiprocessor 8 8 64Limited by Shared Memory per Multiprocessor 12 8 0Note: Occupancy limiter is shown in orange Physical Max Warps/SM = 64

Just follow steps 1, 2, and 3 below! (or click here for help)

(Help)

(Help)

(Help)

= Allocatable Blocks Per SM

Page 2: CUDA Occupancy Calculator

Occupancy = 64 / 64 = 100%

CUDA Occupancy CalculatorVersion: 5.1

Threads Warps/Multiprocessor256 64

32 1264 2496 36

128 48160 60192 60224 63256 64288 63320 60352 55384 60416 52

Copyright and License

Page 3: CUDA Occupancy Calculator

448 56480 60512 64544 51576 54608 57640 60672 63704 44736 46768 48800 50832 52864 54896 56928 58960 60992 62

1024 641056 331088 341120 351152 361184 371216 381248 391280 401312 411344 421376 431408 441440 451472 461504 471536 48156816001632166416961728176017921824185618881920195219842016

Page 4: CUDA Occupancy Calculator

204820802112214421762208224022722304233623682400243224642496252825602592262426562688272027522784281628482880291229442976300830403072

Page 5: CUDA Occupancy Calculator
Page 6: CUDA Occupancy Calculator
Page 7: CUDA Occupancy Calculator
Page 8: CUDA Occupancy Calculator

Click Here for detailed instructions on how to use this occupancy calculator.For more information on NVIDIA CUDA, visit http://developer.nvidia.com/cuda

Your chosen resource usage is indicated by the red triangle on the graphs. The other data points represent the range of possible block sizes, register counts, and shared memory allocation.

0 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 10240

8

16

24

32

40

48

56

64 1

Impact of Varying Block Size

Threads Per Block

Mu

ltip

roce

sso

r W

arp

Occ

up

an

cy(#

wa

rps)

0 16

32 48

64 80

96 112

12

8

144

160

17

6

192

20

8

224

24

0

256

0

8

16

24

32

40

48

56

64 1

Impact of Varying Register Count Per Thread

Registers Per Thread

Mu

ltip

roce

sso

r W

arp

Occ

up

an

cy(#

wa

rps)

Page 9: CUDA Occupancy Calculator

Registers Warps/Multiprocessor Shared MeWarps/Multiprocessor32 64 4096 64

1 64 0 642 64 512 643 64 1024 644 64 1536 645 64 2048 646 64 2560 647 64 3072 648 64 3584 649 64 4096 64

10 64 4608 6411 64 5120 6412 64 5632 6413 64 6144 64

0 16

32 48

64 80

96 112

12

8

144

160

17

6

192

20

8

224

24

0

256

0

8

16

24

32

40

48

56

64 1

Impact of Varying Register Count Per Thread

Registers Per Thread

Mu

ltip

roce

sso

r W

arp

Occ

up

an

cy(#

wa

rps)

0 409

6

819

2

122

88

163

84

204

80

245

76

286

72

327

68

3686

4

409

60

450

56

491

52

0

8

16

24

32

40

48

56

64 1

Impact of Varying Shared Memory Usage Per Block

Shared Mem ory Per Block

Mu

ltip

roce

sso

r W

arp

Occ

up

an

cy(#

wa

rps)

Page 10: CUDA Occupancy Calculator

14 64 6656 5615 64 7168 4816 64 7680 4817 64 8192 4818 64 8704 4019 64 9216 4020 64 9728 4021 64 10240 3222 64 10752 3223 64 11264 3224 64 11776 3225 64 12288 3226 64 12800 2427 64 13312 2428 64 13824 2429 64 14336 2430 64 14848 2431 64 15360 2432 64 15872 2433 48 16384 2434 48 16896 1635 48 17408 1636 48 17920 1637 48 18432 1638 48 18944 1639 48 19456 1640 48 19968 1641 40 20480 1642 40 20992 1643 40 21504 1644 40 22016 1645 40 22528 1646 40 23040 1647 40 23552 1648 40 24064 1649 32 24576 1650 32 25088 851 32 25600 852 32 26112 853 32 26624 854 32 27136 855 32 27648 856 32 28160 857 32 28672 858 32 29184 859 32 29696 860 32 30208 861 32 30720 862 32 31232 863 32 31744 8

Page 11: CUDA Occupancy Calculator

64 32 32256 865 24 32768 866 24 33280 867 24 33792 868 24 34304 869 24 34816 870 24 35328 871 24 35840 872 24 36352 873 24 36864 874 24 37376 875 24 37888 876 24 38400 877 24 38912 878 24 39424 879 24 39936 880 24 40448 881 16 40960 882 16 41472 883 16 41984 884 16 42496 885 16 43008 886 16 43520 887 16 44032 888 16 44544 889 16 45056 890 16 45568 891 16 46080 892 16 46592 893 16 47104 894 16 47616 895 16 48128 896 16 48640 897 16 49152 898 1699 16

100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16

Page 12: CUDA Occupancy Calculator

114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8

Page 13: CUDA Occupancy Calculator

164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8

Page 14: CUDA Occupancy Calculator

214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8

Page 15: CUDA Occupancy Calculator
Page 16: CUDA Occupancy Calculator
Page 17: CUDA Occupancy Calculator
Page 18: CUDA Occupancy Calculator
Page 19: CUDA Occupancy Calculator
Page 20: CUDA Occupancy Calculator
Page 21: CUDA Occupancy Calculator
Page 22: CUDA Occupancy Calculator
Page 23: CUDA Occupancy Calculator
Page 24: CUDA Occupancy Calculator
Page 25: CUDA Occupancy Calculator
Page 26: CUDA Occupancy Calculator
Page 27: CUDA Occupancy Calculator
Page 28: CUDA Occupancy Calculator
Page 29: CUDA Occupancy Calculator
Page 30: CUDA Occupancy Calculator
Page 31: CUDA Occupancy Calculator
Page 32: CUDA Occupancy Calculator

IMPORTANTThis spreadsheet requires Excel macros for full functionality. When you load this file, make sure you enable macros because they are often disabled by default by Excel.

Overview

capability 1.2-1.3, N = 16384. On GPUs with compute capability 2.0-2.1, N = 32768. On GPUs with compute capability 3.0,N=65536.

InstructionsUsing the CUDA Occupancy Calculator is as easy as 1-2-3. Change to the calculator sheet and follow these three steps.

Determining Registers Per Thread and Shared Memory Per Thread Block

The CUDA Occupancy Calculator allows you to compute the multiprocessor occupancy of a GPU by a given CUDA kernel. The multiprocessor occupancy is the ratio of active warps to the maximum number of warps supported on a multiprocessor of the GPU. Each multiprocessor on the device has a set of N registers available for use by CUDA program threads. These registers are a shared resource that are allocated among the thread blocks executing on a multiprocessor. The CUDA compiler attempts to minimize register usage to maximize the number of thread blocks that can be active in the machine simultaneously. If a program tries to launch a kernel for which the registers used per thread times the thread block size is greater than N, the launch will fail.

The size of N on GPUs with compute capability 1.0-1.1 is 8192 32-bit registers per multiprocessor. On GPUs with compute

Maximizing the occupancy can help to cover latency during global memory loads that are followed by a __syncthreads(). The occupancy is determined by the amount of shared memory and registers used by each thread block. Because of this, programmers need to choose the size of thread blocks with care in order to maximize occupancy. This GPU Occupancy Calculator can assist in choosing thread block size based on shared memory and register requirements.

1.) First select your device's compute capability in the green box.

Click to go there…

1.b) If your compute capability supports it, you will be shown a second green box in which you can select the size in bytes of the shared memory (configurable at run time in CUDA).

Click to go there…

2.) For the kernel you are profiling, enter the number of threads per thread block, the registers used per thread, and the total shared memory used per thread block in bytes in the orange block. See below for how to find the registers used per thread.

Click to go there…

3.) Examine the blue box and the graph to the right. This will tell you the occupancy, as well as the number of active threads, warps, and thread blocks per multiprocessor, and the maximum number of active blocks on the GPU. The graph will show you the occupancy for your chosen block size as a red triangle, and for all other possible block sizes as a line graph.

Click to go there…

You can now experiment with how different thread block sizes, register counts, and shared memory usages can affect your GPU occupancy.

To determine the number of registers used per thread in your kernel, simply compile the kernel code using the option --ptxas-options=-v to nvcc. This will output information about register, local memory, shared memory, and constant memory usage for each kernel in the .cu file. However, if your kernel declares any external shared memory that is allocated dynamically, you will need to add the (statically allocated) shared memory reported by ptxas to the amount you dynamically allocate at run time to get the correct shared memory usage. An example of the verbose ptxas output is as follows:

Page 33: CUDA Occupancy Calculator

ptxas info : Compiling entry function '_Z8my_kernelPf' for 'sm_10'ptxas info : Used 5 registers, 8+16 bytes smem

Notes about Occupancy

Let's say "my_kernel" contains an external shared memory array which is allocated to be 2048 bytes at run time. Then our total shared memory usage per block is 2048+8+16 = 2072 bytes. We enter this into the box labeled "shared memory per block (bytes)" in this occupancy calculator, and we also enter the number of registers used by my_kernel, 5, in the box labeled registers per thread. We then enter our thread block size and the calculator will display the occupancy.

Higher occupancy does not necessarily mean higher performance. If a kernel is not bandwidth-limited or latency-limited, then increasing occupancy will not necessarily increase performance. If a kernel grid is already running at least one thread block per multiprocessor in the GPU, and it is bottlenecked by computation and not by global memory accesses, then increasing occupancy may have no effect. In fact, making changes just to increase occupancy can have other effects, such as additional instructions, more register spills to local memory (which is off-chip), more divergent branches, etc. As with any optimization, you should experiment to see how changes affect the *wall clock time* of the kernel execution. For bandwidth-bound applications, on the other hand, increasing occupancy can help better hide the latency of memory accesses, and therefore improve performance.

For more information on NVIDIA CUDA, visit http://developer.nvidia.com/cuda

Page 34: CUDA Occupancy Calculator
Page 35: CUDA Occupancy Calculator
Page 36: CUDA Occupancy Calculator
Page 37: CUDA Occupancy Calculator
Page 38: CUDA Occupancy Calculator

Compute Capability 1.0 1.1 1.2 1.3 2.0 2.1 3.0 3.5SM Version sm_10 sm_11 sm_12 sm_13 sm_20 sm_21 sm_30 sm_35Threads / Warp 32 32 32 32 32 32 32 32Warps / Multiprocessor 24 24 32 32 48 48 64 64Threads / Multiprocessor 768 768 1024 1024 1536 1536 2048 2048Thread Blocks / Multiprocessor 8 8 8 8 8 8 16 16Max Shared Memory / Multiprocessor (bytes) 16384 16384 16384 16384 49152 49152 49152 49152

Register File Size 8192 8192 16384 16384 32768 32768 65536 65536

Register Allocation Unit Size 256 256 512 512 64 64 256 256

Allocation Granularity block block block block warp warp warp warp

Max Registers / Thread 124 124 124 124 63 63 63 255

Shared Memory Allocation Unit Size 512 512 512 512 128 128 256 256

Warp allocation granularity 2 2 2 2 2 2 4 4

Max Thread Block Size 512 512 512 512 1024 1024 1024 1024

Shared Memory Size Configurations (bytes) 16384 16384 16384 16384 49152 49152 49152 49152

[note: default at top of list] 16384 16384 16384 16384

32768 32768

Warp register allocation granularities 64 64 256 256

[note: default at top of list] 128 128

Page 39: CUDA Occupancy Calculator
Page 40: CUDA Occupancy Calculator
Page 41: CUDA Occupancy Calculator

Copyright 1993-2012 NVIDIA Corporation. All rights reserved.

NOTICE TO USER:

This spreadsheet and data is subject to NVIDIA ownership rights under U.S. and international Copyright laws. Users and possessors of this spreadsheet and data are hereby granted a nonexclusive, royalty-free license to use it in individual and commercial software.

NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SPREADSHEET AND DATA FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SPREADSHEET AND DATA, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SPREADSHEET AND DATA.

U.S. Government End Users. This spreadsheet and data are a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of "commercial computer software" and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the spreadsheet and data with only those rights set forth herein. Any use of this spreadsheet and data in individual and commercial software must include, in the user documentation and internal comments to the code, the above Disclaimer and U.S. Government End Users Notice.

For more information on NVIDIA CUDA, visit http://www.nvidia.com/cuda

Page 42: CUDA Occupancy Calculator
Page 43: CUDA Occupancy Calculator
Page 44: CUDA Occupancy Calculator