#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <typeinfo>
#include <iostream>
#include <list>
#include <vector>
#include <set>
#include <deque>
#include <rpa/algorithms/accumulate.h>
#include <rpa/architectures/posix.h>
Namespaces | |
namespace | rpa |
Classes | |
struct | rpa::atomic< set< double >::const_iterator > |
struct | rpa::atomic< double_list_const_iter_t > |
struct | rpa::atomic< deque< double >::const_iterator > |
struct | rpa::atomic< double_vector_const_iter_t > |
struct | rpa::cas1< set< double >::const_iterator > |
struct | rpa::cas1< double_list_const_iter_t > |
struct | rpa::cas1< deque< double >::const_iterator > |
struct | rpa::cas1< double_vector_const_iter_t > |
Defines | |
#define | NB_THR ( (1 << 3) - 1 ) |
#define | MAX_NB_DBL (2000000 * TST_RATIO) |
The number of data to be processed. | |
#define | SUM_DBL ((double)MAX_NB_DBL * (MAX_NB_DBL-1) / 2.0) |
Functions | |
typedef | rpa::RPA_LIST_ITERATOR_CONST (double) double_list_const_iter_t |
typedef | rpa::RPA_VECTOR_ITERATOR_CONST (double, std::allocator< double >) double_vector_const_iter_t |
template<class InputRange> | |
void | TstMakeThr (size_t aNbThr, InputRange aRngIn) |
template<class Container> | |
void | Tst (const Container &aCont, rpa::thr_nb_t aNbThr) |
Test with a given type of input container, and a given number of threads. | |
int | main (int aArgC, const char **aArgV) |
Variables | |
static rpa::testing_thread | myThr [NB_THR] |
Our thread pool. The threads are actually created by the algorithm. | |
static double | myDbl [MAX_NB_DBL] |
The input data loaded in the input containers. | |
static rpa::posix_mutex | myMtx |
static rpa::posix_spinlock | mySpn |
#define MAX_NB_DBL (2000000 * TST_RATIO) |
The number of data to be processed.
#define NB_THR ( (1 << 3) - 1 ) |
At each loop, the number of iterations is divided by two. The starting value is calculated to have rarely-used numbers.
#define SUM_DBL ((double)MAX_NB_DBL * (MAX_NB_DBL-1) / 2.0) |
This is the result that each 'accumulate' call must return, whether it is sequential or parallel.
int main | ( | int | aArgC, | |
const char ** | aArgV | |||
) |
Main entry point. This loops with a decreasing number of threads. For each number of threads, it tries the tests with different kind of input containers. The inner tests is based on the use of the algorithm std:accumulate.
Test with many number of threads and many types on input containers. The number of threads is divided by eight at each iterations because it allows a wider range of tested values, for less iterations.
It is possible to use multiset as input because all elements are different.
void Tst | ( | const Container & | aCont, | |
rpa::thr_nb_t | aNbThr | |||
) |
Test with a given type of input container, and a given number of threads.
Splitting the input range into several pieces is always possible when the size of the container is known, and when the input iterator is at least of forward type.
Does not try all possible step sizes, multiplies by four each time.
With a POSIX mutex.
Without mutex.
With a POSIX spinlock.
void TstMakeThr | ( | size_t | aNbThr, | |
InputRange | aRngIn | |||
) |
Runs the algorithm 'accumulate', with a given number of threads, and a given input range (Static shceduling, dynamic scheduling or interleaved scheduling).
double myDbl[MAX_NB_DBL] [static] |
The input data loaded in the input containers.
rpa::posix_mutex myMtx [static] |
This mutex is used for synchronizing the dynamic scheduling (range_step). This object just needs to have the interface of a mutex to be usable by the library.
rpa::posix_spinlock mySpn [static] |
This spinlock is used for synchronizing a dynamic scheduling processing. It has the interface of a mutex, so this is transparent for the library.
rpa::testing_thread myThr[NB_THR] [static] |
Our thread pool. The threads are actually created by the algorithm.