A class to hold library-global state. More...
#include <Context.hpp>
Public Member Functions | |
sp::Stream | getStream () const |
void | setStream (const cudaStream_t &s) |
int | getMultiprocessors () const |
Get the SM count for the current GPU. More... | |
A class to hold library-global state.
This should be used as the base class for your library's "library handle" type. Extend sp::Context
and add any library-specific features. This is only useful if you're implementing a C-style API with a "handle" object. If you're writing a C++ program, you should just use libSCALE APIs directly.
This object is helpful as a base class for an opaque C-style library handle when you want your underlying implementation to be able to use libSCALE/speclib APIs.
For optimal performance:
Context
s between host threads (create one per thread that wants to use the library).Context
to communicate with each CUDA stream. It's fine to use multiple streams with one context, but there is a small overhead associated with using multiple contexts with one stream (which may also introduce exciting race conditions into your program).To comply with the documented behaviour of some CUDA libraries, it is safe to violate both of the above recommendations, including insane scenarios like concurrently executing setStream()
with math functions. This may lead to large amounts of host-side lock contention.
There is very little synchronisation overhead if the above recommendations are followed.
int sp::Context::getMultiprocessors | ( | ) | const |
Get the SM count for the current GPU.