I'm trying to clean up specific memory objects created by a specific thread (hence only accessible to that thread). The only way for me to achieve that is to switch to that particular thread when freeing that memory block.
This is how I allocated the specific memory context:
This is what I attempted to do:
I have originally added the memory context creation and destruction in a manner like the following:
int Thread2::main()
{
CudaMemoryContext *theCudaObj = new CudaMemoryContext();
while(!TerminateStatus())
{
...
}
delete theCudaObj;
return 0;
}
However, this approach is not working very well, i.e. the program crashes right when I'm cleaning up on the "delete theCudaObj;" line. I'm wondering if I can switch active threads when cleaning up, or allocate the CUDA context to be accessible by both threads so that I can clean up and access it with ease through both threads. Thanks in advance for suggestions.