【发布时间】:2012-09-04 23:58:32
【问题描述】:
我有一个 NVIDIA GTX 570 显卡,在 Ubuntu 10.10 系统 上运行 Cuda 4.0。
我知道,为了性能,我们需要有效地访问内存,并巧妙地使用设备上的注册和共享内存。
但是我不明白如何计算,每个线程可用的寄存器数量,或者单个块可以使用多少共享内存以及针对特定内核配置的其他简单/重要计算。
我想通过一个显式的例子来理解这一点。 顺便说一句,我目前正在尝试编写一个粒子代码,其中一个内核应该如下所示。
每个块是一个一维线程集合,每个网格是一个一维块的集合。
- 块数:16384
- 每个块的线程数:32(=>线程总数 32*16384 = 524288)
- 每个线程块都有一个 32 x 32 共享内存的二维整数数组 一起工作。
在一个线程中,我想存储一些double 类型的数字。但我不确定
我可以存储多少这样的double 数字而没有任何寄存器溢出到本地内存(在设备上)。谁能告诉
我这个内核配置每个线程可以存储多少个双精度数?
上面提到的我的每个块的共享内存配置是否有效?
一个关于如何推断这些事情的示例计算将非常 说明性和有用的
这是关于我的 GTX 570 的信息:(使用来自 CUDA-SDK 的 deviceQuery)
[deviceQuery] starting...
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Found 1 CUDA Capable device(s)
Device 0: "GeForce GTX 570"
CUDA Driver Version / Runtime Version 4.0 / 4.0
CUDA Capability Major/Minor version number: 2.0
Total amount of global memory: 1279 MBytes (1341325312 bytes)
(15) Multiprocessors x (32) CUDA Cores/MP: 480 CUDA Cores
GPU Clock Speed: 1.46 GHz
Memory Clock rate: 1900.00 Mhz
Memory Bus Width: 320-bit
L2 Cache Size: 655360 bytes
Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65535), 3D=(2048,2048,2048)
Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 32768
Warp size: 32
Maximum number of threads per block: 1024
Maximum sizes of each dimension of a block: 1024 x 1024 x 64
Maximum sizes of each dimension of a grid: 65535 x 65535 x 65535
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Concurrent kernel execution: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support enabled: No
Device is using TCC driver mode: No
Device supports Unified Addressing (UVA): Yes
Device PCI Bus ID / PCI location ID: 2 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 4.0, CUDA Runtime Version = 4.0, NumDevs = 1, Device = GeForce GTX 570
[deviceQuery] test results...
PASSED
Press ENTER to exit...
【问题讨论】:
-
“商店”是什么意思?在标量变量中(将进入寄存器),还是在数组中(将进入片外本地存储器)?
-
我的意思是标量变量或数组。从您的评论看来,如果我存储 8 个标量变量,它们将存储在一个线程中,但如果我存储一个 8 个双精度数组,那么该数组将存储在片外本地内存中?这似乎很奇怪。你能澄清一下吗?
-
This answer 应该说清楚。
标签: memory memory-management cuda