From Pheet
Jump to: navigation, search

The Pheet class is a static class used to access the most common Pheet features and default components.



All methods are static, und unless explicitly specified otherwise always return valid values inside a corresponding Pheet::Environment. Please be aware that the corresponding environment needs to be exactly the same Configuration as the class from which you access the methods.

Spawning Tasks

void Pheet::spawn(ftor, parameters...)

The most basic way to spawn a task in Pheet is using the Pheet::spawn method. It takes a functor (function pointer, function object), and the parameters necessary to call the functor as parameters.


void quicksort(int* begin, int* end) {

void main() {
  Pheet::spawn(quicksort, begin, end);
template <class TaskObject>
void Pheet::spawn(parameters...)

Pheet::spawn can also be called using Task Objects. In this case the class of the task object is given as a template parameter to spawn, like in the following example:

Pheet::spawn<QuicksortTask>(begin, end);
void Pheet::spawn_s(strategy, ftor, parameters...)
template <class TaskObject>
void Pheet::spawn_s(strategy, parameters...)

When using strategies, the corresponding Pheet::spawn_s methods can be called. If the current configuration uses a scheduler that does not support strategies (e.g. the Basic Scheduler, Pheet::spawn_s ignores the strategy and performs a normal spawn.

Calling Tasks

void Pheet::call(ftor, parameters...)
template <class TaskObject>
void Pheet::call(parameters...)

To allow a consistent interface for synchroneous function calls as well, Pheet provides the [[Pheet::call]] methods. For functors, the semantics are identical to a normal function call. Pheet::call does not provide any synchronization for tasks spawned inside the call.

Finishing Tasks

void Pheet::finish(ftor, parameters...)
template <class TaskObject>
void Pheet::finish(parameters...)

Similar to a synchroneous call of a task, but automatically creates a finish region. This provides automatic synchronization for all tasks transitively spawned inside the given task.

Getting the current Place

Pheet::Place* Pheet::get_place()
procs_t Pheet::get_place_id()

This methods allow to query for the Place the current task is executing on. The method Pheet::get_place() returns a pointer to the Place object of the current place. This object can be used to perform place-specific operations. The place id returned by Pheet::get_place_id() is an unsigned integer in the range [0;P-1], where P is the number of places in the system. Place id's are ordered by locality, so it is guaranteed that a place x+1 is at least as close to place x as place x+2. In case a place needs to be stored somewhere for locality reasons, the preferred way is to store the pointer to the place object, not the place id.

Place singletons

template <typename T> 
T& place_singleton()

Parallel applications often require to have a singleton of a certain type per place (e.g. memory management, random number generation). Access to such a singleton can be obtained in Pheet using the Pheet::place_singleton method.


MemoryManager& mm = Pheet::place_singleton<MemoryManager>;

Random number generators

// Get random number generator
std::mt19937& get_rng();

// Returns an integer in the range [0;max]
template <typename IntT> 
IntT rand_int(IntT max);

// Returns an integer in the range [min;max]
template <typename IntT> 
IntT rand_int(IntT min, IntT max);

For convenience, Pheet provides a single random number generator per place.



Default Types

Personal tools