CUDA C++ stream and state

I am trying to follow this tutorial and make a simple c++ extension with CUDA backend.
My CPU implementation seems to work fine.

I am having trouble finding examples and documentation (it seems like things are constantly changing).

Specifically,

  1. I see pytorch cuda functions getting THCState *state argument - where does this argument comes from? How can i get a state for my function as well?

  2. state is then converted to cudaStream_t stream = THCState_getCurrentStream(state); For some reason, THCState_getCurrentStream is no longer defined? How can I get the stream from my state?

Thanks,

2 Likes

On the second question:
I am not an expert, but I dare to suggest using
c10::cuda::getCurrentCUDAStream()
c10::cuda::setCurrentCUDAStream()
instead.

3 Likes