我正在尝试从float4
值的5000个元素数组创建一维纹理。
当我尝试分配数组时,出现以下错误:
invalid argument
这就是它所说的全部。
以下是代码:
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));
这里发生了什么?我的阵列太大了吗?它似乎不是一个令人难以置信的记忆。有没有更好的技术将大数组绑定到纹理?
这是我的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)
答案 0 :(得分:0)
我想出来了。
分配应该是
CUDA_CHECK_RETURN(cudaMallocArray(&p_atmosphere, &channel, size);
而不是
CUDA_CHECK_RETURN(cudaMallocArray(&p_atmosphere, &channel, size * sizeof(type));