在CUDA中,是否保证默认流等于nullptr?

在CUDA中,是否保证默认流等于nullptr?,cuda,default-value,cuda-streams,Cuda,Default Value,Cuda Streams,在CUDA的driver\u types.h中,我们有: typedef __device_builtin__ struct CUstream_st *cudaStream_t; 在cuda_runtime.h中,我们在许多地方都有默认的初始化流参数。例如: template<class T> static __inline__ __host__ cudaError_t cudaLaunchKernel( const T *func, dim3 gridDi

在CUDA的
driver\u types.h
中,我们有:

typedef __device_builtin__ struct CUstream_st *cudaStream_t;
cuda_runtime.h
中,我们在许多地方都有默认的初始化流参数。例如:

template<class T>
    static __inline__ __host__ cudaError_t cudaLaunchKernel(
    const T *func,
    dim3 gridDim,
    dim3 blockDim,
    void **args,
    size_t sharedMem = 0,
    cudaStream_t stream = 0
)
模板
静态uuuu内联uuuuu主机uuuuuu错误uuu t cudaLaunchKernel(
常数T*func,
dim3网格DIM,
dim3块DIM,
void**args,
大小\u t sharedMem=0,
cudaStream\u t stream=0
)

假设默认流是
(cudaStream)nullptr
,安全性如何?

这在多个地方都有记录:

  • :
  • 未指定任何流参数的内核启动和主机设备内存拷贝,或将流参数设置为零的等效拷贝将被发送到默认流

  • cudaMemcpyAsync
  • 通过传递非零流参数,可以选择将副本关联到流


    出于好奇,假设默认流相当于
    (cudaStream_t)0

    似乎很安全:您为什么需要知道这一点?@m.s.:我没有注意到
    cudaGetDefaultStream()
    函数,我想做一些类似
    my_stream=condition的事情?foo():cudaGetDefaultStream()