I have a caching scheme to manage the workspace for FFTs myself because there are a large number of different FFTs being applied and this substantially cuts down on memory usage. As part of this, I use cufftGetSize1d (...)
to determine the workspace size. However, if I am low on GPU memory, it returns a CUFFT_ALLOC_FAILED error.
From this Stack Overflow question about the same topic, What is the meaning of CUFFT_ALLOC_FAILED return value when calling cufftGetSize*()?, it was deduced that the error actually means the allocation would fail since cufftGetSize1d
doesn’t actually allocate memory.
In the debugger, I can estimate the amount to be about 1 GB based on the workspace sizes of similar FFTs currently created. There is less than 1 GB available, which I suspect is the reason for the error. My problem is, I need to know that number, even if there isn’t memory space available, because my application can free GPU memory to make room, it just needs to know how much to free. And in this specific case, the workspace allocated is actually already big enough, so I don’t even need to allocate more, but the program can’t know that since cufftGetSize1d
errors rather than telling me the answer. Is there anyway I can get this workspace size, even when the GPU is low on memory?
Even if the method return 16 PB as an answer (which is absolutely ridiculous), that would be good even though I obviously don’t have that much memory, because at least there is a value to report in the error message stating the user needs a GPU with xxx GB memory in order to process the supplied data/configuration.