LAMA
|
Singleton class that provides (shared) pointers to a context. More...
#include <ContextFactory.hpp>
Public Member Functions | |
ContextManager * | getContextManager (const Context::ContextType type) |
This method can be used to get access to a context so that data can be allocated on it. | |
void | addContextManager (const Context::ContextType type, ContextManager &contextManager) |
Each context type that should be supported must add its context manager so that the the factory can forward a query for a context type to the corresponding manager. | |
Static Public Member Functions | |
static ContextPtr | getContext (const Context::ContextType type, int deviceNr=LAMA_DEFAULT_DEVICE_NUMBER) |
This method can be used to get access to a context so that data can be allocated on it. | |
static bool | hasContext (const Context::ContextType type) |
checks if a context of the passed type is available. | |
static ContextFactory & | getFactory () |
Method that returns a reference to the context factory. | |
static void | release () |
Release all context managers. | |
Private Member Functions | |
ContextFactory () | |
virtual | ~ContextFactory () |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
ContextManager * | mContextManager [Context::MaxContext] |
Each possible context will have its own context manager. | |
Static Private Attributes | |
static const char * | theContextIds [Context::MaxContext] |
Set NULL manager as defaults for all devices. | |
static ContextFactory * | theContextFactory = NULL |
Singleton class that provides (shared) pointers to a context.
of a given type.
ContextPtr hostContext = ContextFactory::getContext( Context::Host ); ContextPtr cudaContext = ContextFactory::getContext( Context::CUDA ); ContextPtr cudaContext1 = ContextFactory::getContext( Context::CUDA, 1 );
Each context is returned via a shared pointer so the context is freed automatically if no more reference is kept.
For each supported context type a context manager must register to the factory otherwise the type remains unsupported.
lama::ContextFactory::ContextFactory | ( | ) | [private] |
lama::ContextFactory::~ContextFactory | ( | ) | [private, virtual] |
void lama::ContextFactory::addContextManager | ( | const Context::ContextType | type, |
ContextManager & | contextManager | ||
) |
Each context type that should be supported must add its context manager so that the the factory can forward a query for a context type to the corresponding manager.
[in] | type | is the type of context for which the manager is responsibile |
[in] | contextManager | reference to the manager for all contexts of a given type. |
References LAMA_ASSERT_DEBUG.
Referenced by lama::ContextManager::registerFactory().
ContextPtr lama::ContextFactory::getContext | ( | const Context::ContextType | type, |
int | deviceNr = LAMA_DEFAULT_DEVICE_NUMBER |
||
) | [static] |
This method can be used to get access to a context so that data can be allocated on it.
The shared pointer guarantees that a context will live at least as long as arrays are allocated on it.
[in] | type | is the type of context that is wanted |
[in] | deviceNr | is used for multiple devices of the same type (default is LAMA_DEFAULT_DEVICE_NUMBER) |
Exception | if the context of the requested type is not available |
References lama::ContextManager::getContext(), LAMA_ASSERT_DEBUG, LAMA_DEFAULT_DEVICE_NUMBER, LAMA_THROWEXCEPTION, and mContextManager.
Referenced by lama::LAMAArrayUtils::assignImpl2(), lama::CSRStorage< T >::buildRowIndexes(), lama::ELLStorage< T >::compress(), lama::LUSolver::computeLUFactorization(), lama::NoCommunicator::getCommunicationContext(), lama::PGASCommunicator::getCommunicationContext(), lama::MPICommunicator::getCommunicationContext(), lama::DenseStorageView< T >::invertDense(), lama::SpecializedJacobi::iterateTyped(), lama::ELLStorage< T >::matrixAddMatrixELL(), lama::ELLStorage< T >::matrixTimesMatrixELL(), lama::DIAStorage< T >::matrixTimesVector(), lama::COOStorage< T >::matrixTimesVector(), lama::COOStorage< T >::matrixTimesVectorAsyncToDo(), lama::DenseStorageView< T >::setCSRDataImpl(), lama::CSRStorage< T >::setCSRDataImpl(), lama::COOStorage< T >::setCSRDataImpl(), and lama::GMRES::updateX().
This method can be used to get access to a context so that data can be allocated on it.
The shared pointer guarantees that a context will live at least as long as arrays are allocated on it.
[in] | type | is the type of context that is wanted |
[in] | deviceNr | is used for multiple devices of the same type (default is LAMA_DEFAULT_DEVICE_NUMBER) |
Exception | if the context of the requested type is not available |
References LAMA_ASSERT_DEBUG.
Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar().
ContextFactory & lama::ContextFactory::getFactory | ( | ) | [static] |
Method that returns a reference to the context factory.
Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar(), and lama::ContextManager::registerFactory().
bool lama::ContextFactory::hasContext | ( | const Context::ContextType | type | ) | [static] |
checks if a context of the passed type is available.
[in] | type | is the type of context that is wanted |
References mContextManager.
lama::ContextFactory::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
void lama::ContextFactory::release | ( | ) | [static] |
Release all context managers.
References mContextManager.
Each possible context will have its own context manager.
Referenced by getContext(), hasContext(), and release().
ContextFactory * lama::ContextFactory::theContextFactory = NULL [static, private] |
const char * lama::ContextFactory::theContextIds [static, private] |
{ "HostContext", "CudaContext", "OpenCLContext" }
Set NULL manager as defaults for all devices.