Cuda 3.1: must cudaStreamCreate/cudaStreamDestroy be called in same (Windows) thread?

Hi there,

I’m currently changing from CUDA 2.3 to 3.1 and get access violations when calling [font=“Courier New”]cudaStreamDestroy()[/font]. I assume that this is because [font=“Courier New”]cudaStreamCreate()[/font] and [font=“Courier New”]cudaStreamDestroy()[/font] are called from different Windows threads.

Did the CUDA runtime change and now requires the same thread for [font=“Courier New”]cudaStream[/font] (and [font=“Courier New”]cudaEvent[/font] as well, btw) creation and destruction?! Where would that be documented? Or isn’t it the different threads that cause my crashes??

That’s always been true. Contexts are bound per thread unless you explicitly move them, so calling cudaStreamDestroy from a separate thread never did what you thought it did (it would create a context on device 0, try to destroy a stream, realize that the stream doesn’t exist, and fail to do so).

Well, ok. But in 2.3 nothing happend (neither a crash nor an error was returned)…

Different question: How costly is the stream creation?! Would it be feasible to create/destroy the stream every frame? Or would that drop performance noticeably?