Is there a relationship between on which of devices was created stream and on which device will executed code?

末鹿安然 提交于 2019-12-01 10:57:29

If I'm reading the following example from the CUDA webinar on using multiple GPUs correctly, it is an error to execute with a stream that is not on the currently selected device.

Example 2

cudaStream_t streamA, streamB;
cudaEvent_t eventA, eventB;
cudaSetDevice(0);
cudaStreamCreate(&streamA); // streamA and eventA belong to device-0
cudaEventCreaet(&eventA);
cudaSetDevice(1);
cudaStreamCreate(&streamB); // streamB and eventB belong to device-1
cudaEventCreate (&eventB);
kernel<<<...,  streamA>>>(...);
cudaEventRecord(eventB, streamB);
cudaEventSynchronize( eventB);

ERROR:

  • device-1 is current
  • streamA belongs to device-0
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!