cuda-driver

What does cudaSetDevice() do to a CUDA device's context stack?

僤鯓⒐⒋嵵緔 提交于 2020-08-08 07:02:08
问题 Suppose I have an active CUDA context associated with device i , and I now call cudaSetDevice(i) . What happens? : Nothing? Primary context replaces the top of the stack? Primary context is pushed onto the stack? It actually seems to be inconsistent. I've written this program, running on a machine with a single device: #include <cuda.h> #include <cuda_runtime_api.h> #include <cassert> #include <iostream> int main() { CUcontext ctx1, primary; cuInit(0); auto status = cuCtxCreate(&ctx1, 0, 0);