Public Member Functions | Protected Member Functions | Protected Attributes

MemSetter< T > Class Template Reference

Inheritance diagram for MemSetter< T >:
ParallelTask Task NamedObject CallBacker

List of all members.

Public Member Functions

 MemSetter ()
 MemSetter (T *, T val, int64_t sz)
 MemSetter (ValueSeries< T > &, T val, int64_t sz)
void setValue (const T &val)
void setTarget (T *ptr)
void setTarget (ValueSeries< T > &vs)
void setSize (int64_t sz)
bool doPrepare (int)
bool doWork (int64_t, int64_t, int)
int64_t nrIterations () const
int minThreadSize () const

Protected Member Functions

bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)
template<>
bool setPtr (int64_t start, int64_t size)

Protected Attributes

ValueSeries< T > * vs_
T * ptr_
int64_t sz_
val_

Detailed Description

template<class T>
class MemSetter< T >

Sets large amounts of values to a constant using multiple threads.


Constructor & Destructor Documentation

template<class T >
MemSetter< T >::MemSetter (  )  [inline]
template<class T >
MemSetter< T >::MemSetter ( T *  ptr,
val,
int64_t  sz 
) [inline]
template<class T >
MemSetter< T >::MemSetter ( ValueSeries< T > &  vs,
val,
int64_t  sz 
) [inline]

Member Function Documentation

template<class T >
bool MemSetter< T >::doPrepare ( int  nrthreads  )  [inline, virtual]

Called before any doWork is called.

Reimplemented from ParallelTask.

template<class T >
bool MemSetter< T >::doWork ( int64_t  start,
int64_t  stop,
int  threadid 
) [inline, virtual]

The functions that does the job. The function will be called with all intervals from 0 to ParallelTask::nrIterations()-1. The function must be designed to be able to run in parallel.

Parameters:
threadid gives an identifier (between 0 and nr of threads -1) that is unique to each call to doWork.

Implements ParallelTask.

template<class T>
int MemSetter< T >::minThreadSize (  )  const [inline, virtual]
Returns:
the minimum number of computations that effectively can be run in a separate thread. A small number will give a large overhead for when each step is quick and nrIterations is small.

Reimplemented from ParallelTask.

template<class T>
int64_t MemSetter< T >::nrIterations (  )  const [inline, virtual]
Returns:
the number of times the process should be run.

Implements ParallelTask.

template<>
bool MemSetter< short >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< int64_t >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< int >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<class T >
bool MemSetter< T >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< unsigned int >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< unsigned short >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< unsigned char >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< char >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< uint64_t >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< bool >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< double >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<>
bool MemSetter< float >::setPtr ( int64_t  start,
int64_t  size 
) [inline, protected]
template<class T>
void MemSetter< T >::setSize ( int64_t  sz  )  [inline]
template<class T>
void MemSetter< T >::setTarget ( T *  ptr  )  [inline]
template<class T>
void MemSetter< T >::setTarget ( ValueSeries< T > &  vs  )  [inline]
template<class T>
void MemSetter< T >::setValue ( const T &  val  )  [inline]

Member Data Documentation

template<class T>
T* MemSetter< T >::ptr_ [protected]
template<class T>
int64_t MemSetter< T >::sz_ [protected]
template<class T>
T MemSetter< T >::val_ [protected]
template<class T>
ValueSeries<T>* MemSetter< T >::vs_ [protected]