[英]Possible CUDA memory allocation bug?
I'm attempting to create a 1D texture from a 5000 element array of float4
values. 我试图从float4
值的5000个元素数组创建1D纹理。
When I attempt to allocate the array, I get the following error: 当我尝试分配数组时,出现以下错误:
invalid argument
That's literally all it says. 就是这么说。
Here is the code: 这是代码:
cudaChannelFormatDesc channel = cudaCreateChannelDesc<float4>();
const std::size_t size = 5000;
float4 atmosphere[size];
cudaArray *p_atmosphere;
CUDA_CHECK_RETURN(cudaMallocArray(&p_atmosphere, &channel, size * sizeof(float4));
What's going on here? 这里发生了什么? Is my array too large? 我的数组太大了吗? It doesn't seem like an outrageous amount of memory. 它看起来似乎不算是太多的内存。 Is there a better technique to bind a large array to a texture? 是否有更好的技术将大型数组绑定到纹理?
And here is my GPU information: 这是我的GPU信息:
--- General information about Device 0
Name: Quadro 2000
Compute Capability: 2.1
Clock Rate: 1251000 kHz
Device Overlap:
Enabled
Kernel Execution Timeout:
Enabled
--- Memory information for Device 0
Total Global Memory: 1023 MB
Total Constant Memory: 65536 K
Max Memory Pitch: 2147483647
Texture Alignment: 512
--- Multi Processor Information for Device 0
Multiprocessor Count: 4
Shared Memory Per MP: 49152 K
Registers Per MP: 32768
Threads in Warp: 32
Max threads per block: 1024
Max thread dimension: (1024, 1024, 1024)
Max grid dimension: (65535, 65535, 65535)
I figured this out. 我想通了。
The allocation should be 分配应为
CUDA_CHECK_RETURN(cudaMallocArray(&p_atmosphere, &channel, size);
instead of 代替
CUDA_CHECK_RETURN(cudaMallocArray(&p_atmosphere, &channel, size * sizeof(type));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.