# Streams and CUFFT

**URL:** <https://forums.developer.nvidia.com/t/streams-and-cufft/2897>\
**Category:** CUDA Programming and Performance\
**Created:** [March 5, 2008, 7:02pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897 "2008-03-05T19:02:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bidger](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bidger](https://forums.developer.nvidia.com/u/bidger)\
**Post date:** [March 5, 2008, 7:02pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/1 "2008-03-05T19:02:17Z")

</div>

I think I cannot do this, but I wanted to confirm:

I wanted to call cufftExecC2C (or any CUFFT really) within different  
streams. I _think_ the cufft calls are not callable from within kernel  
routines, and I _think_ that means I am out of luck. I had a simple  
kernel defined like:

**global** void  
fftKernel(cufftHandle fftPlan, cufftComplex \*d\_fftArrayA, cufftComplex \*d\_fftArrayB)  
{  
// now call our fft  
CUFFT\_SAFE\_CALL(cufftExecC2C(fftPlan, d\_fftArrayA, d\_fftArrayB, CUFFT\_FORWARD));  
}

Then I wanted to call that as in:

fftKernel\<\<\<nblocks, nthreads, streamArr[i]\>\>\>(fftPlan[i], fftDeviceArrayA[i], fftDeviceArrayB[i]);

I get nvcc compile errors for this; I believe it is angry about trying to call  
the cufft routine within another kernel – I recall reading somewhere that  
cufft calls were esentially kernel calls in and of themselves.

So - is there a way to call a cufft routine within a stream? Thoughts on this would  
be appreciated, thanks.

---

<div class="post-metadata">

**Author:** ![jimh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jimh](https://forums.developer.nvidia.com/u/jimh)\
**Post date:** [March 5, 2008, 7:09pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/2 "2008-03-05T19:09:03Z")

</div>

I’d like to know if CUFFT works in a stream as well.

---

<div class="post-metadata">

**Author:** ![mfatica](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mfatica](https://forums.developer.nvidia.com/u/mfatica)\
**Post date:** [March 5, 2008, 7:17pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/3 "2008-03-05T19:17:49Z")

</div>

I am not sure it will work with streams, you may try to modify the source code. Also remember that in order to use async calls, the data need to be in pinned memory.

By the way, your call is wrong:

fftKernel\<\<\<nblocks, nthreads, streamArr[i]\>\>\>(fftPlan[i], fftDeviceArrayA[i], fftDeviceArrayB[i]);

should be  
fftKernel\<\<\<nblocks, nthreads, 0, streamArr[i]\>\>\>(fftPlan[i], fftDeviceArrayA[i], fftDeviceArrayB[i]);

You are missing the shared memory info.

---

<div class="post-metadata">

**Author:** ![jimh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jimh](https://forums.developer.nvidia.com/u/jimh)\
**Post date:** [March 6, 2008, 10:43pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/4 "2008-03-06T22:43:52Z")

</div>

> [@](#):
>
> I am not sure it will work with streams, you may try to modify the source code. Also remember that in order to use async calls, the data need to be in pinned memory.
> 
> [snapback]338191[/snapback]

Thanks for the info, Massimiliano.

---

<div class="post-metadata">

**Author:** ![skb](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@skb](https://forums.developer.nvidia.com/u/skb)\
**Post date:** [March 21, 2008, 6:40pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/5 "2008-03-21T18:40:12Z")

</div>

> [@](#):
>
> Thanks for the info, Massimiliano.
> 
> [snapback]338794[/snapback]

Has anyone got cufft running in a stream as yet? Also, when I run cufft through the profiler, I see kernel code with \_mpsm and \_mpgm extensions. I assume this has to do with shared mem and global mem access? I don’t see this in the CUFFT source code release… do we have the complete source code to get equivalent performance as running the host callable CUFFT routines?

Thank you,

skb

---

<div class="post-metadata">

**Author:** ![Charley](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Charley](https://forums.developer.nvidia.com/u/Charley)\
**Post date:** [March 22, 2008, 1:16am UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/6 "2008-03-22T01:16:46Z")

</div>

I think CUFFT works with streams if you use batched FFTs.

---

<div class="post-metadata">

**Author:** ![skb](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@skb](https://forums.developer.nvidia.com/u/skb)\
**Post date:** [March 26, 2008, 7:03pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/7 "2008-03-26T19:03:53Z")

</div>

> [@](#):
>
> I think CUFFT works with streams if you use batched FFTs.
> 
> [snapback]348192[/snapback]

I thought the batched ffts only changes the grid dimensions on the kernel code of cufft. Have you had success using batched ffts and launching cufft on a stream?

I have noticed that not all the CUFFT code is provided to us, so it will take some time to get it to work with streams if we have to modify the source code. I have posted a request to NVIDIA to see whether they have any advice or (preferably) make the entire CUFFT library source code available to us. No answer either way yet … :(

skb

---

<div class="post-metadata">

**Author:** ![Charley](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Charley](https://forums.developer.nvidia.com/u/Charley)\
**Post date:** [March 26, 2008, 11:40pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/8 "2008-03-26T23:40:24Z")

</div>

> [@](#):
>
> I thought the batched ffts only changes the grid dimensions on the kernel code of cufft.&nbsp; Have you had success using batched ffts and launching cufft on a stream?
> 
> I have noticed that not all the CUFFT code is provided to us, so it will take some time to get it to work with streams if we have to modify the source code.&nbsp; I have posted a request to NVIDIA to see whether they have any advice or (preferably) make the entire CUFFT library source code available to us.&nbsp; No answer either way yet …&nbsp; :(
> 
> skb
> 
> [snapback]351513[/snapback]

I thought I did, but I was confused about streaming. Does anyone know if someone else has written an FFT routine for CUDA?

---

<div class="post-metadata">

**Author:** ![mstgpuser](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mstgpuser](https://forums.developer.nvidia.com/u/mstgpuser)\
**Post date:** [June 16, 2008, 11:16pm UTC](https://forums.developer.nvidia.com/t/streams-and-cufft/2897/9 "2008-06-16T23:16:12Z")

</div>

Does anybody know where to download the source code for CUFFT?

Thanks.
