通过cudaStreamCreate与cudaStreamCreateWithFlags创建的流的行为?

我注意到cudaStreamCreate是一个__host __-唯一函数,但cudaStreamCreateWithFlags是一个__host__ __device__函数.

这两者之间是否存在重要区别,使得cudaStreamCreate在__device__函数中不可用?

我看到这个documentation for the cudaStreamCreateWithFlags flags parameter

Creates a new asynchronous stream. The flags argument determines the
behaviors of the stream. Valid values for flags are

  • cudaStreamDefault: Default stream creation flag.
  • cudaStreamNonBlocking: Specifies that work running in the created
    stream may run concurrently with work in stream 0 (the NULL stream),
    and that the created stream should perform no implicit synchronization
    with stream 0.

“默认流创建标志”究竟是什么意思?创建的流将如何表现?

最佳答案 的行为

cudaStreamCreateWithFlags(&stream, cudaStreamDefault);

是完全相同的

cudaStreamCreate(&stream);

除了cudaStreamCreate是__host__函数,cudaStreamCreateWithFlags是__host__ __device__函数.

点赞