Grappa  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Delegates

Helpers. More...

Namespaces

 Grappa::delegate
 

Classes

class  Grappa::delegate::Promise< R >
 A 'Promise' is a wrapper around a FullEmpty for async delegates with return values. More...
 
class  Grappa::delegate::FetchAddCombiner< T, U >
 Flat combines fetch_and_add to a single global address. More...
 

Macros

#define AUTO_INVOKE(expr)   decltype(expr) { return expr; }
 

Functions

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename F = decltype(nullptr)>
auto Grappa::delegate::call (Core dest, F f) -> AUTO_INVOKE((impl::Specializer< S, C, F >::call(dest, f,&F::operator())))
 
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename F = decltype(nullptr)>
auto Grappa::delegate::call (GlobalAddress< T > t, F func) -> AUTO_INVOKE((impl::call< S, C >(t, func,&F::operator())))
 Helper that makes it easier to implement custom delegate operations specifically on global addresses. More...
 
template<typename M , typename F >
auto Grappa::delegate::call (Core dest, M mutex, F func) -> decltype(func(mutex()))
 Try lock on remote mutex. More...
 
template<typename F >
auto Grappa::delegate::call_suspendable (Core dest, F func) -> decltype(func())
 Alternative version of delegate::call that spawns a privateTask to allow the delegate to perform suspending actions. More...
 
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr)>
Grappa::delegate::read (GlobalAddress< T > target)
 Read the value (potentially remote) at the given GlobalAddress, blocks the calling task until round-trip communication is complete. More...
 
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr)>
void Grappa::delegate::write (GlobalAddress< T > target, U value)
 Blocking remote write. More...
 
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr)>
Grappa::delegate::fetch_and_add (GlobalAddress< T > target, U inc)
 Fetch the value at target, increment the value stored there with inc and return the original value to blocking thread. More...
 
 Grappa::delegate::FetchAddCombiner< T, U >::FetchAddCombiner (GlobalAddress< T > target, uint64_t flush_threshold, U initVal)
 
void Grappa::delegate::FetchAddCombiner< T, U >::promise ()
 Promise that in the future you will call fetch_and_add. More...
 
Grappa::delegate::FetchAddCombiner< T, U >::fetch_and_add (U inc)
 
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr), typename V = decltype(nullptr)>
bool Grappa::delegate::compare_and_swap (GlobalAddress< T > target, U cmp_val, V new_val)
 If value at target equals cmp_val, set the value to new_val and return true, otherwise do nothing and return false. More...
 
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr)>
void Grappa::delegate::increment (GlobalAddress< T > target, U inc)
 
template<TaskMode B = TaskMode::Bound, GlobalCompletionEvent * C = &impl::local_gce, typename F = decltype(nullptr)>
void Grappa::spawnRemote (Core dest, F f)
 Synchronizing remote private task spawn. More...
 
Worker * Grappa::current_worker ()
 

Detailed Description

Helpers.

Macro Definition Documentation

#define AUTO_INVOKE (   expr)    decltype(expr) { return expr; }

Definition at line 96 of file Delegate.hpp.

Function Documentation

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename F = decltype(nullptr)>
auto Grappa::delegate::call ( Core  dest,
f 
) -> AUTO_INVOKE((impl::Specializer< S, C, F >::call(dest, f,&F::operator())))
template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename F = decltype(nullptr)>
auto Grappa::delegate::call ( GlobalAddress< T >  t,
func 
) -> AUTO_INVOKE((impl::call< S, C >(t, func,&F::operator())))
inline

Helper that makes it easier to implement custom delegate operations specifically on global addresses.

Does specialization based on return type of the lambda.

Example:

bool is_zero = delegate::call(xa, [](int* x){ return *x == 0; });
// or by reference:
bool is_zero = delegate::call(xa, [](int& x){ return x == 0; });
template<typename M , typename F >
auto Grappa::delegate::call ( Core  dest,
mutex,
func 
) -> decltype(func(mutex()))
inline

Try lock on remote mutex.

Does not lock or unlock, creates a SuspendedDelegate if lock has already been taken, which is triggered on unlocking of the Mutex.

Definition at line 143 of file Delegate.hpp.

template<typename F >
auto Grappa::delegate::call_suspendable ( Core  dest,
func 
) -> decltype(func())
inline

Alternative version of delegate::call that spawns a privateTask to allow the delegate to perform suspending actions.

Note
Use of this is not advised: suspending violates much of the assumptions about delegates we usually make, and can easily cause deadlock if no workers are available to execute the spawned privateTask. A better option for possibly-blocking delegates is to use the Mutex version of delegate::call(Core,M,F).

Definition at line 191 of file Delegate.hpp.

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr), typename V = decltype(nullptr)>
bool Grappa::delegate::compare_and_swap ( GlobalAddress< T >  target,
cmp_val,
new_val 
)

If value at target equals cmp_val, set the value to new_val and return true, otherwise do nothing and return false.

Warning
Target object must lie on a single node (not span blocks in global address space).

Definition at line 405 of file Delegate.hpp.

Worker* Grappa::current_worker ( )
inline

Definition at line 592 of file TaskingScheduler.hpp.

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr)>
T Grappa::delegate::fetch_and_add ( GlobalAddress< T >  target,
inc 
)

Fetch the value at target, increment the value stored there with inc and return the original value to blocking thread.

Warning
Target object must lie on a single node (not span blocks in global address space).

Definition at line 271 of file Delegate.hpp.

template<typename T , typename U >
T Grappa::delegate::FetchAddCombiner< T, U >::fetch_and_add ( inc)
inline

Definition at line 353 of file Delegate.hpp.

template<typename T , typename U >
Grappa::delegate::FetchAddCombiner< T, U >::FetchAddCombiner ( GlobalAddress< T >  target,
uint64_t  flush_threshold,
initVal 
)
inline

Definition at line 323 of file Delegate.hpp.

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr)>
void Grappa::delegate::increment ( GlobalAddress< T >  target,
inc 
)

Definition at line 426 of file Delegate.hpp.

template<typename T , typename U >
void Grappa::delegate::FetchAddCombiner< T, U >::promise ( )
inline

Promise that in the future you will call fetch_and_add.

Must be called before a call to fetch_and_add

After calling promise, this task must NOT have a dependence on any fetch_and_add occurring before it calls fetch_and_add itself or deadlock may occur.

For good performance, should allow other tasks to run before calling fetch_and_add

Definition at line 348 of file Delegate.hpp.

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr)>
T Grappa::delegate::read ( GlobalAddress< T >  target)

Read the value (potentially remote) at the given GlobalAddress, blocks the calling task until round-trip communication is complete.

Remove 'const' qualifier to do read.

Warning
Target object must lie on a single node (not span blocks in global address space).

Definition at line 231 of file Delegate.hpp.

template<TaskMode B = TaskMode::Bound, GlobalCompletionEvent * C = &impl::local_gce, typename F = decltype(nullptr)>
void Grappa::spawnRemote ( Core  dest,
f 
)

Synchronizing remote private task spawn.

Automatically enrolls task with GlobalCompletionEvent and sends complete message when done (if C is non-null).

Definition at line 441 of file Delegate.hpp.

template<SyncMode S = SyncMode::Blocking, GlobalCompletionEvent * C = &impl::local_gce, typename T = decltype(nullptr), typename U = decltype(nullptr)>
void Grappa::delegate::write ( GlobalAddress< T >  target,
value 
)

Blocking remote write.

Warning
Target object must lie on a single node (not span blocks in global address space).

Definition at line 254 of file Delegate.hpp.