I am planning to change the behavior of the GPU context singleton.
I like the use of the singleton idiom, but you cannot use this idiom
unmodified with CUDA and expect it to end well. Currently, the CUDA library
is going out of scope before the GPU context. When that happens, all the
memory pointers are force-released and everything about CUDA is silently
destroyed.
Then the GPU context goes out of scope with the singleton and it throws a
pile of CUDA errors because CUDA has already left the building.
The solution IMO is restoring manual initialization and destruction of the
GPU context within the singleton, throwing loud and nasty error messages at
code that tries to access it before it is created or after it has been
destroyed. The singleton will otherwise behave as it currently does an this
will discourage people from doing strange hard to debug weirdness with it
going forward. One day, possibly, CUDA will be part of the C++ Runtime
library and it will stay in scope long enough to just use a vanilla
singleton. That day is not today.
Scott
_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
Received on Tue Jul 14 2020 - 10:00:05 PDT