Changes between Version 19 and Version 20 of LibrariesUnderConstruction


Ignore:
Timestamp:
Jan 14, 2009, 8:23:55 PM (14 years ago)
Author:
viboes
Comment:

Moving Threader/Joiner and Asynchronous Executors to LUD

Legend:

Unmodified
Added
Removed
Modified
  • LibrariesUnderConstruction

    v19 v20  
    2121 * '''Links:''' [http://www.drivehq.com/web/igaztanaga/allocplus/ Documentation] [http://www.drivehq.com/web/igaztanaga/allocplus.zip Download]
    2222 * '''Description:'''Allocators optimizations
     23
     24---------------------------------------------------------------------------------------------------
     25== !AsynchronousExecutors ==
     26 * '''Author(s):''' Vicente J. Botet Escriba
     27 * '''Version:''' 0.2
     28 * '''State:''' Preliminary
     29 * '''Last upload:''' 2009 Jan 14
     30 * '''Links:''' [http://www.boostpro.com/vault/index.php?action=downloadfile&filename=interthreads.zip&directory=Concurrent%20Programming& Boost Vault] [https://svn.boost.org/svn/boost/sandbox/interthreads Boost Sandbox]
     31 * '''Description:''' Asynchronous Executors (AE) and Asynchronous Completion Tokens (ACT) in a generic way (or at least this was my intention). The library can be considered as a front-end for several Asynchronous Execution models making it possible to share common algorithms and making easier to switch from an Asynchronous Executors to another.
     32
     33Next follows the motivation for the library and how the library can manage with this concepts.
     34
     35In N1833 - Preliminary Threading Library Proposal for TR2 Kevlin Henney introduce the concept of threader and a function thread that evaluate a function asynchronously and returns a joiner handle.
     36In N2185 - Proposed Text for Parallel Task Execution Peter Dimov introduce a fork function able to evaluate a function asynchronously and returns a future handle.
     37In N2276 - Thread Pools and Futures Anthony William introduce launch_in_thread and launch_in_pool function templates which evaluate a function asynchronously either in a specific thread or a thread pool and returns a unique_future handle.
     38In Boost.ThreadPool Oliver Kowalke propose a complete implementation of a thread pool with a submit function which evaluate a function asynchronously and returns a task handle.
     39
     40Behind all these proposal there is a concept of asynchronous executor, fork-launch-like function and the asynchronous completion token handle.
     41
     42|| Name             || executor    || fork-like          || ACT ||
     43|| Boost.Thread     || ??          || thread constructor || thread  ||
     44|| Boost.!ThreadPool || tp::pool    || submit             || tp::task  ||
     45|| N2276            || thread      || launch_in_thread   || unique_future<T>  ||
     46|| N2276            || thread_pool || launch_in_pool     || unique_future<T>  ||
     47|| N2185            || ??          || fork               || future<T>  ||
     48|| N1833            || threader    || thread             || joiner<T>  ||
     49
     50The asynchronous completion token models can follows two interfaces, the thread interface and the unique_future interface.
     51Some asynchronous completion token handles allows to recover the result of the evaluation of the function (futures), other allows to manage the underlying thread of execution (thread) and some both (joiner and tp::task).
     52
     53It seems natural to make a generic fork function that will evaluate a function asynchronously with respect to the calling thread and returns an ACT handle. The following meta-function associated an ACT handle to a asynchronous executor.
     54
     55{{{
     56#!cpp
     57template <typename AE, typename T>
     58struct asynchronous_completion_token {
     59    typedef typename AE::template handle<T>::type type;
     60};   
     61}}}
     62
     63The result of forking a nullary function by an asynchronous executor is given by the following meta-function:
     64
     65{{{
     66#!cpp
     67namespace result_of {
     68    template <typename AE,typename F>
     69    struct fork {
     70        typedef typename asynchronous_completion_token<AE, typename result_of<F()>::type>::type type;
     71    };   
     72}
     73}}}
     74
     75The default implementation of fork delegates on fork asynchronous executor function.
     76
     77{{{
     78#!cpp
     79template< typename AE, typename F >
     80result_of::fork<AE, F>::type fork( AE& ae, F fn ) {
     81    return ae.fork(fn);
     82}
     83}}}
     84
     85Forking n-ary functions relies on the nullary version and bind.
     86
     87{{{
     88#!cpp
     89template< typename AE, typename F, typename A1, ..., typename An >
     90asynchronous_completion_token<AE, typename result_of<F(A1,..., An)>::type >::type
     91fork( AE& ae, F fn, A1 a1, ..., An an ) {
     92    return ae.fork( bind( fn, a1, ..., an ) );
     93}
     94}}}
    2395
    2496---------------------------------------------------------------------------------------------------
     
    153225== Boost.!InterThreads ==
    154226 * '''Author(s):''' Vicente J. Botet Escriba
    155  * '''Version:''' 0.1
    156  * '''State:''' Not stable
    157  * '''Last upload:''' 2008 Nov 26
     227 * '''Version:''' 0.2
     228 * '''State:''' Preliminary
     229 * '''Last upload:''' 2009 Jan 14
    158230 * '''Links:''' [http://www.boostpro.com/vault/index.php?action=downloadfile&filename=interthreads.zip&directory=Concurrent%20Programming& Boost Vault] [https://svn.boost.org/svn/boost/sandbox/interthreads Boost Sandbox]
    159231 * '''Description:'''  Boost.!InterThreads extends Boost.Threads adding some features:
    160232     * thread decorator: thread_decorator allows to define setup/cleanup functions which will be called only once by thread: setup before the thread function and cleanup at thread exit.
     233     * thread_decorator can now decorate a nullary function in addition to a callable function
    161234     * thread specific shared pointer: this is an extension of the thread_specific_ptr providing access to this thread specific context from other threads. As it is shared the stored pointer is a shared_ptr instead of a raw one.
    162235     * thread keep alive mechanism: this mechanism allows to detect threads that do not prove that they are alive by calling to the keep_alive_point regularly. When a thread is declared dead a user provided function is called, which by default will abort the program.
     
    168241thread_decorator and thread_specific_shared_ptr are based on the original implementation of threadalert written by Roland Schwarz.
    169242
    170 
     243This library works well with [#Boost.AsynchronousExecutors AsynchronousExecutors].
    171244
    172245---------------------------------------------------------------------------------------------------
     
    256329 * '''Description:''' unique_ptr is a class template smart pointer currently in the [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2800.pdf C++0X CD1 draft]. It is intended to be a safer and more flexible replacement for auto_ptr. It represents sole (unique) ownership of a resource such as memory (like auto_ptr).
    257330The actual C++0X unique_ptr makes use of a new C++ language feature called rvalue reference which is similar to our current reference (&), but spelled &&. This emulation is intended to capture most of the behavior of the C++0X unique_ptr but work with C++03 compilers. Furthermore this emulation makes use of boost library facilities and has been placed in the boost namespace. Though at the time of this writing, this library is not part of the official boost library release.
     331
     332---------------------------------------------------------------------------------------------------
     333== Boost.!ThreaderJoiner  ==
     334 * '''Author(s):''' Vicente J. Botet Escriba
     335 * '''Version:''' 0.2
     336 * '''State:''' Preliminary
     337 * '''Last upload:''' 2009 Jan 14
     338 * '''Links:''' [http://www.boostpro.com/vault/index.php?action=downloadfile&filename=interthreads.zip&directory=Concurrent%20Programming& Boost Vault] [https://svn.boost.org/svn/boost/sandbox/interthreads Boost Sandbox]
     339 * '''Description:'''  Boost.!InterThreads extends Boost.Threads adding some features:
     340 * '''Description:''' Threader/Joiner as proposed by Kevlin Henney `[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1883.pdf Preliminary Threading Library Proposal for TR2]
     341
     342This library works well with [#Boost.AsynchronousExecutors AsynchronousExecutors].
    258343   
    259344---------------------------------------------------------------------------------------------------
     
    297382 * '''Description:''' Intel® Threading Building Blocks (TBB) offers a rich and complete approach to expressing parallelism in a C++ program. It is a library that helps you take advantage of multi-core processor performance without having to be a threading expert. Threading Building Blocks is not just a threads-replacement library. It represents a higher-level, task-based parallelism that abstracts platform details and threading mechanism for performance and scalability and performance.
    298383
    299 
    300 
    301 ---------------------------------------------------------------------------------------------------
     384---------------------------------------------------------------------------------------------------
     385
    302386= Libraries Under Discussion =
    303387This page is an index page for discussion of possible libraries as people get their ideas together.
     
    376460}}}
    377461
    378 ---------------------------------------------------------------------------------------------------
    379 == !AsynchronousExecutors ==
    380  * '''Suggested by:''' Vicente J. Botet Escriba 
    381  * '''Description:''' Asynchronous Executors (AE) and Asynchronous Completion Tokens (ACT) in a generic way (or at least this was my intention). The library can be considered as a front-end for several Asynchronous Execution models making it possible to share common algorithms and making easier to switch from an Asynchronous Executors to another.
    382 
    383 Next follows the motivation for the library and how the library can manage with this concepts.
    384 
    385 In N1833 - Preliminary Threading Library Proposal for TR2 Kevlin Henney introduce the concept of threader and a function thread that evaluate a function asynchronously and returns a joiner handle.
    386 In N2185 - Proposed Text for Parallel Task Execution Peter Dimov introduce a fork function able to evaluate a function asynchronously and returns a future handle.
    387 In N2276 - Thread Pools and Futures Anthony William introduce launch_in_thread and launch_in_pool function templates which evaluate a function asynchronously either in a specific thread or a thread pool and returns a unique_future handle.
    388 In Boost.ThreadPool Oliver Kowalke propose a complete implementation of a thread pool with a submit function which evaluate a function asynchronously and returns a task handle.
    389 
    390 Behind all these proposal there is a concept of asynchronous executor, fork-launch-like function and the asynchronous completion token handle.
    391 
    392 || Name             || executor    || fork-like          || ACT ||
    393 || Boost.Thread     || ??          || thread constructor || thread  ||
    394 || Boost.!ThreadPool || tp::pool    || submit             || tp::task  ||
    395 || N2276            || thread      || launch_in_thread   || unique_future<T>  ||
    396 || N2276            || thread_pool || launch_in_pool     || unique_future<T>  ||
    397 || N2185            || ??          || fork               || future<T>  ||
    398 || N1833            || threader    || thread             || joiner<T>  ||
    399 
    400 The asynchronous completion token models can follows two interfaces, the thread interface and the unique_future interface.
    401 Some asynchronous completion token handles allows to recover the result of the evaluation of the function (futures), other allows to manage the underlying thread of execution (thread) and some both (joiner and tp::task).
    402 
    403 It seems natural to make a generic fork function that will evaluate a function asynchronously with respect to the calling thread and returns an ACT handle. The following meta-function associated an ACT handle to a asynchronous executor.
    404 
    405 {{{
    406 #!cpp
    407 template <typename AE, typename T>
    408 struct asynchronous_completion_token {
    409     typedef typename AE::template handle<T>::type type;
    410 };   
    411 }}}
    412 
    413 The result of forking a nullary function by an asynchronous executor is given by the following meta-function:
    414 
    415 {{{
    416 #!cpp
    417 namespace result_of {
    418     template <typename AE,typename F>
    419     struct fork {
    420         typedef typename asynchronous_completion_token<AE, typename result_of<F()>::type>::type type;
    421     };   
    422 }
    423 }}}
    424 
    425 The default implementation of fork delegates on fork asynchronous executor function.
    426 
    427 {{{
    428 #!cpp
    429 template< typename AE, typename F >
    430 result_of::fork<AE, F>::type fork( AE& ae, F fn ) {
    431     return ae.fork(fn);
    432 }
    433 }}}
    434 
    435 Forking n-ary functions relies on the nullary version and bind.
    436 
    437 {{{
    438 #!cpp
    439 template< typename AE, typename F, typename A1, ..., typename An >
    440 asynchronous_completion_token<AE, typename result_of<F(A1,..., An)>::type >::type
    441 fork( AE& ae, F fn, A1 a1, ..., An an ) {
    442     return ae.fork( bind( fn, a1, ..., an ) );
    443 }
    444 }}}
    445462
    446463---------------------------------------------------------------------------------------------------
     
    463480---------------------------------------------------------------------------------------------------
    464481== !DenseSet ==
     482
    465483 * '''Suggested by:''' Vicente J. Botet Escriba 
    466484 * '''Description:''' Implementation of dense set of integers using intervals.
     
    664682 * '''Description:''' Transactional memory (TM) is a recent parallel programming concept which reduces challenges found in parallel programming. TM offers numerous advantages over other synchronization mechanisms.
    665683
    666 ---------------------------------------------------------------------------------------------------
    667 == !ThreaderJoiner  ==
    668  * '''Suggested by:''' Vicente J. Botet Escriba 
    669  * '''Description:''' Threader/Joiner as proposed by Kevlin Henney `[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1883.pdf Preliminary Threading Library Proposal for TR2]
    670 This library works well with [#Boost.AsynchronousExecutors AsynchronousExecutors].
    671684
    672685---------------------------------------------------------------------------------------------------
     
    717730---------------------------------------------------------------------------------------------------
    718731== Concurrent Programming ==
    719  * [#Boost.AsynchronousExecutors AsynchronousExecutors]
     732 * [#Boost.AsynchronousExecutors Asynchronous Executors]
    720733 * [#Boost.Coroutines Coroutines]
    721734 * [#Boost.Fiber Fiber]
     
    724737 * [#STM STM]
    725738 * [#Sync Sync]
    726  * [#ThreaderJoiner ThreaderJoiner]
     739 * [#Boost.ThreaderJoiner Threader-Joiner]
    727740
    728741---------------------------------------------------------------------------------------------------
     
    730743 * [#Accummulators.Ext Accummulators.Ext]
    731744 * [#Boost.Euclid Euclid]
    732 
    733745
    734746---------------------------------------------------------------------------------------------------