FastFlow  SVN-r182-Aug-14-2014
A high-level, lock-less, parallel programming (shared-memory) and distributed programming (distributed-memory) framework for multi-cores and many-cores systems
 All Classes Namespaces Files Functions Variables Typedefs Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
ff::threadMapper Class Reference

The thread mapper allows to map threads to specific core using a predefined mapping policy. More...

#include <mapper.hpp>

+ Collaboration diagram for ff::threadMapper:

Public Member Functions

 threadMapper ()
 
void setMappingList (const char *str)
 
int getCoreId ()
 
unsigned int getMask ()
 
unsigned int getCListSize ()
 
int getCoreId (unsigned int tid)
 
bool checkCPUId (const int cpuId) const
 

Static Public Member Functions

static threadMapperinstance ()
 

Detailed Description

The thread mapper allows to map threads to specific core using a predefined mapping policy.

The threadMapper stores a list of CPU ids. By default the list is simply a linear sequence of core ids of the system, for example in a quad-core system the default list is 0 1 2 3. It is possible to change the default list using the method setMappingList by passing a string of space-serated (or comma-separated) CPU ids. The policy implemented in the threadManager is to pick up a CPU id from the list using a round-robin policy.

This class is defined in mapper.hpp

Constructor & Destructor Documentation

ff::threadMapper::threadMapper ( )
inline

Member Function Documentation

bool ff::threadMapper::checkCPUId ( const int  cpuId) const
inline

It checks whether the taken core is within the range of the cores available on the machine.

Returns
It will return either true of false.
unsigned int ff::threadMapper::getCListSize ( )
inline

It is used for debugging.

Returns
TODO

References ff::svector< T >::size().

int ff::threadMapper::getCoreId ( )
inline

Returns the next CPU id using a round-robin mapping access on the mapping list. This is clearly a raound robind scheduling!

Returns
The identifier of the core.
int ff::threadMapper::getCoreId ( unsigned int  tid)
inline

It is used to get the identifier of the core.

Returns
The identifier of the core.
unsigned int ff::threadMapper::getMask ( )
inline

It is used for debugging.

Returns
TODO
static threadMapper* ff::threadMapper::instance ( )
inlinestatic

Get a static instance of the threadMapper object

Returns
TODO
void ff::threadMapper::setMappingList ( const char *  str)
inline

It allows to set a new list of CPU ids.

The str variable should contain a space-separated or a comma-separated list of CPU ids. For example if the string str is "0 1 1 2 3", then the first thread will be bind to CPU 0, the second to CPU 1, the third to CPU 1, the fourth to CPU 2, the fifth to CPU 3. Then it follows the same rule for the subsequent threads.

Returns
TODO

References ff::svector< T >::push_back(), ff::svector< T >::reserve(), and ff::svector< T >::size().


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