t10_TransformObufRngStepAtom.cpp File Reference

#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <list>
#include <set>
#include <rpa/platforms.h>
#include <rpa/testing.h>
#include <rpa/containers/list.h>
#include <rpa/algorithms/transform.h>

Classes

struct  FtorChar2String

Defines

#define NB_THR   10
 Our thread pool. The threads are 'create'-d by the algorithm.
#define MAX_BUFSZ   10
 Maximum buffer size, that we will create.
#define MAX_STEPS   10
 Maximum number of steps when createing dynamic range_step scheduling.
#define NB_SAMPLES   ( ( ( 1 << 18 ) + 1 ) * TST_RATIO )
#define MAX_SAMPLE_STR   12
 Maximum size for writing an integer.

Typedefs

typedef list< string > LstStrT
 The type of buffers used by each sub-thread.
typedef set< string > SetStrT
 For results comparisons only.
typedef back_insert_iterator<
LstStrT
BackInsT

Functions

template<class Thread>
static LstStrT main_list_unbounded (int aArgC, const char *const *aArgV, rpa::thr_nb_t aNbThr, Thread *aThrArr, size_t aNbSteps)
template<class Thread>
static LstStrT main_list_bounded (int aArgC, const char *const *aArgV, rpa::thr_nb_t aNbThr, Thread *aThrArr, size_t aNbSteps, size_t aBufSz)
template<class Thread>
static void mainIntern (int aArgC, const char *const *aArgV, size_t aBufSz, size_t aNbSteps, rpa::thr_nb_t aNbThr, Thread *aThrArr)
static void mainThr (int aArgC, const char *const *aArgV)
int main (int aArgC, const char **aArgV)

Variables

static char myStr [NB_SAMPLES][MAX_SAMPLE_STR]
 This array is global because it is too big for the stack.
static char * myPtr [NB_SAMPLES]
 This array is global because it is too big for the stack.

Define Documentation

#define MAX_BUFSZ   10

Maximum buffer size, that we will create.

#define MAX_SAMPLE_STR   12

Maximum size for writing an integer.

#define MAX_STEPS   10

Maximum number of steps when createing dynamic range_step scheduling.

#define NB_SAMPLES   ( ( ( 1 << 18 ) + 1 ) * TST_RATIO )

This is a power of two, because this is how the tests size grows. It is multiplied by a ratio for adjusting the time taken by tests.

#define NB_THR   10

Our thread pool. The threads are 'create'-d by the algorithm.

We use template specializations for lists. This file must be included before the templates are actually instantiated by the algorithms. Otherwise, the compiler would simply use the general templates definitions.


Typedef Documentation

typedef back_insert_iterator< LstStrT > BackInsT

typedef list< string > LstStrT

The type of buffers used by each sub-thread.

typedef set< string > SetStrT

For results comparisons only.


Function Documentation

int main ( int  aArgC,
const char **  aArgV 
)

Loops on internal data and on the command line. This ensures that a minimal and identical set of data is run, with the extra flexibility of adding other test samples on the command line.

Tries the algorithm with various sizes, much smaller and much bigger than the number of threads and the size of buffers. We multiply the number by two, at each loop, because we can test wider data range.

For commodity, tests with the command line.

template<class Thread>
static LstStrT main_list_bounded ( int  aArgC,
const char *const *  aArgV,
rpa::thr_nb_t  aNbThr,
Thread *  aThrArr,
size_t  aNbSteps,
size_t  aBufSz 
) [static]

This tests with an output buffer of limited size. The output buffers NEED A MUTEX: We have no way at the moment to use atomic stuff for flushing the buffers.

NO: This is a pseudo-mutex, different from 'void'. NO: Putting 'void' in an 'obuf_iterator' would mean 'limitless buffer'.

WE HAVE NO WAY AT THE MOMENT TO MAKE ATOMIC FLUSH OF THE OUTPUT BUFFERS.

* 'buffer_back_inserter' does the same is 'back_inserter', but allows more parallelization. 'make_thread_tree' creates, out of any threads iterator, a 'thread_tree' object which is necessary for parallel execution. A mutex is necessary because buffers have a limited size and will be periodically flushed into the output iterator.

template<class Thread>
static LstStrT main_list_unbounded ( int  aArgC,
const char *const *  aArgV,
rpa::thr_nb_t  aNbThr,
Thread *  aThrArr,
size_t  aNbSteps 
) [static]

Test with an output buffer of unlimited size. There is no mutex for protecting the input range. The output buffers do not need a mutex because they are flushed when the sub-threads terminate.

* 'obuf_iterator' does the same as 'back_inserter', but allows more parallelization. 'make_thread_tree' creates, out of any threads iterator, a 'thread_tree' object which is necessary for parallel execution. No mutex is necessary because the buffers have an unlimited size and will be flushed at the end of the execution.

template<class Thread>
static void mainIntern ( int  aArgC,
const char *const *  aArgV,
size_t  aBufSz,
size_t  aNbSteps,
rpa::thr_nb_t  aNbThr,
Thread *  aThrArr 
) [static]

Given a set of data, compares the results calculated with the parallel algorithms, with output buffers, when the buffers have a size limit and when they do not have one.

Because the resulats are computed in parallel, we may lose the original order. Therefore, with std::set, the order is the same for everyone.

static void mainThr ( int  aArgC,
const char *const *  aArgV 
) [static]

Loops on several number of threads. Tries several types of deterministic threads, to check that we can reproduce the right order.

This thread type executes the code when 'joined'.

This thread type executes the code 'created'.

Posix threads, with counting, when testing with threads.

It is not necessary to start with just one thread.


Variable Documentation

char* myPtr[NB_SAMPLES] [static]

This array is global because it is too big for the stack.

char myStr[NB_SAMPLES][MAX_SAMPLE_STR] [static]

This array is global because it is too big for the stack.


Generated on Tue Sep 25 10:20:31 2007 for rpa by  doxygen 1.4.7