LAMA
lama::HostContext Class Reference

This class implements the base class HOST context. More...

#include <HostContext.hpp>

Inheritance diagram for lama::HostContext:

Public Types

enum  HostContextType {
  DefaultHost, CUDAHost, OpenCLHost, PGAS,
  MaxHostContext
}
 Due to more efficient transfers between Host and other contexts there might be different HOST contexts that will be distinguished by their type. More...
enum  ContextType { Host, CUDA, OpenCL, MaxContext }
 Enumeration type for the supported contexts. More...

Public Member Functions

virtual ~HostContext ()
virtual bool canUseData (const Context &other) const
 This predicate returns true if one context can use data of another context.
virtual void writeAt (std::ostream &stream) const
 This method writes info about the device in the output stream The method should be overwritten by base classes to give more specific information about the device that might be useful for logging.
virtual HostContextType getHostType () const =0
virtual std::auto_ptr< SyncTokengetSyncToken () const
 Providing implementation for Context::getSyncToken.
ContextType getType () const
 Method to get the type of the context.
bool operator== (const Context &other) const
 This predicate returns true if two contexts can use same data and have the same type.
bool operator!= (const Context &other) const
 The inequality operator is just the inverse to operator==.
virtual void allocate (ContextData &contextData, const size_t size) const =0
 This method allocates memory and must be implemented by each Context.
virtual void free (void *pointer, const size_t size) const =0
 This method free's allocated data allocated by this allocator.
virtual void free (ContextData &contextData) const =0
 This method free's allocated data allocated by this allocator.
virtual void memcpy (void *dst, const void *src, const size_t size) const =0
 Memory copy within the same context.
virtual void memcpy (ContextData &dst, const ContextData &src, const size_t size) const =0
 Memory copy.
virtual std::auto_ptr< SyncTokenmemcpyAsync (void *dst, const void *src, const size_t size) const =0
virtual std::auto_ptr< SyncTokenmemcpyAsync (ContextData &dst, const ContextData &src, const size_t size) const =0
virtual bool cancpy (const ContextData &dst, const ContextData &src) const =0
 Checks if this Context can copy from src to dst.
virtual void enable (const char *file, int line) const
 Enable computations in the context.
virtual void disable (const char *file, int line) const
 Disable computations in the context.
class LAMAInterfacegetInterface () const
 This method returns interface for a given context.

Protected Member Functions

 HostContext ()
 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Protected Attributes

ContextType mContextType
bool mEnabled
 if true the context is currently accessed
const char * mFile
 File name where context has been enabled.
int mLine
 Line number where context has been enabled.

Detailed Description

This class implements the base class HOST context.

The class HostContext remains abstract as it does not provide routines to allocate/free memory.


Member Enumeration Documentation

enum lama::Context::ContextType [inherited]

Enumeration type for the supported contexts.

The type is used to select the appropriate code that will be used for the computations in the context.

The same context type does not imply that two different contexts can use the same data. Two CUDA contexts might allocate their own data where data must be transfered explicitly.

Enumerator:
Host 

context for cpu + main memory

CUDA 

CUDA GPU device.

OpenCL 

OpenCL GPU device.

MaxContext 

used for dimension of ContextType arrays

Due to more efficient transfers between Host and other contexts there might be different HOST contexts that will be distinguished by their type.

Enumerator:
DefaultHost 
CUDAHost 
OpenCLHost 
PGAS 
MaxHostContext 

Constructor & Destructor Documentation


Member Function Documentation

virtual void lama::Context::allocate ( ContextData contextData,
const size_t  size 
) const [pure virtual, inherited]

This method allocates memory and must be implemented by each Context.

Parameters:
[in]sizeis the number of bytes needed
Returns:
pointer to the allocated data, NULL if not enough data is available This method allocates memory and must be implemented by each Context. The pointer to the allocated memory is stored in contextData.pointer.
Parameters:
[out]contextDatathe ContextData the memory should be allocated for
[in]sizeis the number of bytes needed
Returns:
pointer to the allocated data, NULL if not enough data is available

Implemented in lama::CUDAContext, lama::DefaultHostContext, lama::CUDAHostContext, and lama::PGASContext.

virtual bool lama::Context::cancpy ( const ContextData dst,
const ContextData src 
) const [pure virtual, inherited]

Checks if this Context can copy from src to dst.

Parameters:
[in]dstthe dst ContextData
[in]srcthe src ContextData
Returns:
if this Context can copy from src to dst.

Implemented in lama::CUDAContext, lama::DefaultHostContext, lama::CUDAHostContext, and lama::PGASContext.

bool lama::HostContext::canUseData ( const Context other) const [virtual]

This predicate returns true if one context can use data of another context.

This pure routine must be implemented by base classes.

Parameters:
[in]otheris the context against which the check is done

Implements lama::Context.

References lama::Context::getType(), and lama::Context::Host.

void lama::Context::disable ( const char *  file,
int  line 
) const [virtual, inherited]

Disable computations in the context.

Reimplemented in lama::CUDAContext.

References lama::Context::mEnabled, lama::Context::mFile, and lama::Context::mLine.

void lama::Context::enable ( const char *  file,
int  line 
) const [virtual, inherited]

Enable computations in the context.

Operations on the context like allocation, deallocation of data, computations can only be done if the context is enabled.

Different threads can enable a context, but only one at a time.

Reimplemented in lama::CUDAContext.

References lama::Context::mEnabled, lama::Context::mFile, and lama::Context::mLine.

virtual void lama::Context::free ( void *  pointer,
const size_t  size 
) const [pure virtual, inherited]

This method free's allocated data allocated by this allocator.

Parameters:
[in]pointeris the pointer to the allocated data.
[in]sizeis the number of bytes that have been allocated with pointer.

The pointer must have been allocated by the same allocator with the given size.

Implemented in lama::CUDAContext, lama::DefaultHostContext, lama::CUDAHostContext, and lama::PGASContext.

Referenced by lama::Context::ContextData::~ContextData().

virtual void lama::Context::free ( ContextData contextData) const [pure virtual, inherited]

This method free's allocated data allocated by this allocator.

Parameters:
[in]contextDatawhich holds the pointer to the allocated data.

The pointer must have been allocated by the same allocator.

Implemented in lama::CUDAContext, lama::DefaultHostContext, lama::CUDAHostContext, and lama::PGASContext.

std::auto_ptr< SyncToken > lama::HostContext::getSyncToken ( ) const [virtual]

Providing implementation for Context::getSyncToken.

Implements lama::Context.

virtual void lama::Context::memcpy ( void *  dst,
const void *  src,
const size_t  size 
) const [pure virtual, inherited]

Memory copy within the same context.

param[in] dst pointer to the destination param[in] src pointer to the source param[in] size is the number of bytes to be copied.

This memory copies size values

Implemented in lama::CUDAContext, lama::DefaultHostContext, lama::CUDAHostContext, and lama::PGASContext.

virtual void lama::Context::memcpy ( ContextData dst,
const ContextData src,
const size_t  size 
) const [pure virtual, inherited]

Memory copy.

Copies the first size bytes from src->pointer to dst->pointer. the memory pointed to by src might be registered in a certain way to allow faster memory transfers. However the memory pointed to by src->pointer will not be altered by this function.

param[in] dst pointer to the destination param[in] src pointer to the source param[in] size is the number of bytes to be copied.

This memory copies size values

Implemented in lama::CUDAContext, lama::DefaultHostContext, lama::CUDAHostContext, and lama::PGASContext.

virtual std::auto_ptr<SyncToken> lama::Context::memcpyAsync ( void *  dst,
const void *  src,
const size_t  size 
) const [pure virtual, inherited]
virtual std::auto_ptr<SyncToken> lama::Context::memcpyAsync ( ContextData dst,
const ContextData src,
const size_t  size 
) const [pure virtual, inherited]
bool lama::Context::operator!= ( const Context other) const [inherited]

The inequality operator is just the inverse to operator==.

References lama::Context::operator==().

bool lama::Context::operator== ( const Context other) const [inherited]

This predicate returns true if two contexts can use same data and have the same type.

References lama::Context::canUseData(), LAMA_ASSERT_EQUAL_DEBUG, and lama::Context::mContextType.

Referenced by lama::Context::operator!=().

void lama::HostContext::writeAt ( std::ostream &  stream) const [virtual]

This method writes info about the device in the output stream The method should be overwritten by base classes to give more specific information about the device that might be useful for logging.

Reimplemented from lama::Context.

Reimplemented in lama::CUDAHostContext, lama::PGASContext, and lama::DefaultHostContext.


Field Documentation

bool lama::Context::mEnabled [mutable, protected, inherited]

if true the context is currently accessed

Referenced by lama::Context::disable(), and lama::Context::enable().

const char* lama::Context::mFile [mutable, protected, inherited]

File name where context has been enabled.

Referenced by lama::Context::disable(), and lama::Context::enable().

int lama::Context::mLine [mutable, protected, inherited]

Line number where context has been enabled.

Referenced by lama::Context::disable(), and lama::Context::enable().


The documentation for this class was generated from the following files: