3

Is there any way to convert cudaStream_t object to CUStream?

I found this hack but I don't think its safe to use. Or, is there any way to call cudaLaunchKernel in JCuda application using cudaStream_t object in CUDA 7.5 only?

talonmies
  • 70,661
  • 34
  • 192
  • 269
sandeep.ganage
  • 1,409
  • 2
  • 21
  • 47
  • 1
    As talonmies pointed out: In C, one can simply cast these types, but in JCuda, the conversion should be done via the appropriate constructors: `CUstream s = new CUstream(myCudaStream)` - in fact, this constructor was only introduced in response to the thread in the forum that you linked to, in order to avoid the hack. – Marco13 Aug 28 '17 at 11:29

1 Answers1

3

At a C level within the runtime and driver APIs, cudaStream_t and CUStream are the same type and can be used interchangeably in either API.

At a JCUDA level, it appears that CUstream has a specialization of its constructor for initializing an instance with an existing cudaStream_t instance. The provision of this alternative constructor eliminates the need for the pointer swap you linked to in the question.

talonmies
  • 70,661
  • 34
  • 192
  • 269