有谁知道以下用法cudaSetDevice是否正确?我想随时在任何主机线程中重复调用在不同设备上创建的资源;有没有办法在 CUDA 中做到这一点?
 cudaSetDevice(0);
 /...create cuda streams and do some memory allocation on gpu.../
 cudaSetDevice(1);
 /...create cuda streams and do some memory allocation on gpu.../
 #pragma omp parallel num_threads(2)
 { 
   int omp_threadID=omp_get_thread_num();
    ....
   if (omp_threadID==0)
   {
    cudaSetDevice(0);
    /...calling streams/memory created on device 0.../
   }
   else
   {
    cudaSetDevice(1);
    /...calling streams/memory created on device 1.../
    }; 
  };