简体   繁体   English

调用cufftGetSize *()时CUFFT_ALLOC_FAILED返回值是什么意思?

[英]What is the meaning of CUFFT_ALLOC_FAILED return value when calling cufftGetSize*()?

cufftGetSize*() is not supposed to allocate any memory, and it doesn't (I checked available memory before and after calling cufftGetSize*). cufftGetSize *()不应该分配任何内存,它也不分配(我在调用cufftGetSize *之前和之后检查了可用内存)。 Does it return CUFFT_ALLOC_FAILED if a later allocation would fail? 如果以后的分配失败,是否返回CUFFT_ALLOC_FAILED?

Example code: 示例代码:

#include <iostream>
#include <stdio.h>
#include <cuda.h>
#include <cufft.h>

int main() {
  for (int N=1; N<1800; ++N) {
    std::cerr << "N = "<< N << " ";

    cufftResult r;
    cufftHandle planR2C;

    cudaDeviceReset();

    r = cufftCreate(&planR2C);
    if(r) return 1;
    r = cufftSetCompatibilityMode(planR2C, CUFFT_COMPATIBILITY_FFTW_PADDING);
    if(r) return 1;
    r = cufftSetAutoAllocation(planR2C, 0);
    if(r) return 1;

    size_t workSize;
    r = cufftGetSize3d(planR2C, 1800, 1800, N, CUFFT_R2C, &workSize);
    if(r==CUFFT_ALLOC_FAILED) std::cerr << "CUFFT_ALLOC_FAILED\n";

    std::cerr << " Estimated workSize: "
              << workSize / ( 1024 * 1024 )
              << " MB" << std::endl;

    cudaDeviceReset();
  }
  std::cerr << "****** Done.\n";
  return 0;
}

On a GPU with 4693 MB free memory at the start of the process, above code produces the following output: 在此过程开始时,在具有4693 MB可用内存的GPU上,以上代码产生以下输出:

N = 1  Estimated workSize: 197 MB
N = 2  Estimated workSize: 395 MB
...
N = 15  Estimated workSize: 791 MB
N = 16  Estimated workSize: 197 MB
N = 17 CUFFT_ALLOC_FAILED
N = 18  Estimated workSize: 222 MB
...

From N=73 on all odd N fail and even N pass. 从N = 73开始,所有奇数N个失败,甚至N个通过。 From N=166 all N fail. 从N = 166开始,所有N均失败。

Since required memory would not grow linearly with N, I assume (!) that the answer to my question indeed is: "it return[s] CUFFT_ALLOC_FAILED if a later allocation would fail" Although, a prove of that statement would be nice. 由于所需的内存不会随N线性增长,因此我假设(!)我的问题的答案确实是:“如果以后的分配失败,它将返回CUFFT_ALLOC_FAILED”尽管,对该语句的证明将是不错的。

(My problem arises under CUDA 5.5.22, I have not checked any other version) (我的问题出现在CUDA 5.5.22下,我没有检查任何其他版本)

To mark this question answered: 要标记此问题的答案:

Confidence among readers is high that "CUFFT_ALLOC_FAILED return value when calling cufftGetSize*()" actually means "CUFFT_ALLOC_WOULD_FAIL". 读者对“调用cufftGetSize *()时的CUFFT_ALLOC_FAILED返回值”实际上意味着“ CUFFT_ALLOC_WOULD_FAIL”的信心很高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM