cudaresourcesassertioncuda-context

Check context of given resource


Lets imagine the situation, that I have a lot of initialized resources for example: streams, host and device memory end events, part of them are initialized in context of one GPU and the rest of them belong to the other GPU context.

Is there a way to check if given resource (event, stream or memory) belongs to certain GPU context?

In some case it would worthy to assert such things, before order memory copy or kernel execution and then get cudaErrorInvalidArgument.


Solution

  • I am not really aware of such option in CUDA API itself. It is just a low-level sets of orders that you can issue to your GPU.

    What I would do is to wrap the CUDA API functions into some nice class which would track what is where and what is initialised. A class representing a GPU might be useful as well.