t06_TransformNoTmplObufRngSize.cpp File Reference

#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <set>
#include <rpa/testing.h>
#include <rpa/algorithms/transform.h>

Classes

struct  ConstChar2String

Defines

#define NB_THR   10
 Our thread pool. The threads are 'create'-d by the algorithm.
#define NB_SAMPLES   ( ( ( 1 << 20 ) + 1 ) * TST_RATIO )

Typedefs

typedef vector< string > VecStrT
typedef back_insert_iterator<
VecStrT
BackInsT
typedef deque< string > DeqStrT
typedef DeqStrT DeqStrBufAllocT [NB_THR]

Functions

static void Check06 (const char *ptrMsg, bool boolCond)
 This simply checks a boolean condition.
static VecStrT t_nobuf_back_insert (rpa::thr_nb_t aNbThr, int aArgC, const char *const *aArgV)
 Test without output buffer, but with a mutex to protect the back_inserter.
static VecStrT t_nobuf_plain (rpa::thr_nb_t aNbThr, int aArgC, const char *const *aArgV)
 Test without output buffer, but with a mutex to protect the output.
static VecStrT t_bounded_noall (rpa::thr_nb_t aNbThr, int aArgC, const char *const *aArgV)
static VecStrT t_bounded_alloc (rpa::thr_nb_t aNbThr, int aArgC, const char *const *aArgV)
static VecStrT t_unbounded_noall (rpa::thr_nb_t aNbThr, int aArgC, const char *const *aArgV)
 Test with an output buffer of unlimited size.
static VecStrT t_unbounded_alloc (rpa::thr_nb_t aNbThr, int aArgC, const char *const *aArgV)
 Test with an output buffer of unlimited size.
static void Compare (rpa::thr_nb_t aNbThr, size_t aArgC, const char *const *aArgV, bool *aTestFlags, const char *aMsgInfo, VecStrT(*aFunc)(rpa::thr_nb_t, int, const char *const *))
 Compares the results. The input elements are already sorted.
static void mainIntern (int aArgC, const char *const *aArgV, bool *aTstFlags, rpa::thr_nb_t aNbThr)
int main (int aArgC, const char **aArgV)
 The number of threads is divided by two at each loop.

Variables

static rpa::testing_thread myThr [NB_THR]
size_t gblBufSz = 10
rpa::testing_mutex myMtx
DeqStrBufAllocT myDeqBuf
static char myStr [NB_SAMPLES][RPA_INT_STR]
static char * myPtr [NB_SAMPLES]
static bool myTstFlags [NB_SAMPLES]
 Used to check that each value is seen only once.

Define Documentation

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

The number of tests is adjusted with a ratio which allows to reduce or increase the duration of tests.

#define NB_THR   10

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


Typedef Documentation

typedef back_insert_iterator< VecStrT > BackInsT

typedef DeqStrT DeqStrBufAllocT[NB_THR]

This container contains several buffers, one per thread. It will be shared along several executions of 'transform'.

typedef deque< string > DeqStrT

typedef vector< string > VecStrT


Function Documentation

static void Check06 ( const char *  ptrMsg,
bool  boolCond 
) [static]

This simply checks a boolean condition.

static void Compare ( rpa::thr_nb_t  aNbThr,
size_t  aArgC,
const char *const *  aArgV,
bool *  aTestFlags,
const char *  aMsgInfo,
VecStrT(*)(rpa::thr_nb_t, int, const char *const *)  aFunc 
) [static]

Compares the results. The input elements are already sorted.

This is used to test whether a value was seen twice.

This value is bigger than any other, in the container ?

This value does not exist in the other containers ?

This value was already seen ?

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

The number of threads is divided by two at each loop.

Fortran-style initialisation. It has to be fast. After that, the elements are sorted in ascending order.

Tries the algorithm with various sizes, much smaller and much bigger than the number of threads and the size of buffers.

At each loop, the number of elements is multiplied by two.

static void mainIntern ( int  aArgC,
const char *const *  aArgV,
bool *  aTstFlags,
rpa::thr_nb_t  aNbThr 
) [static]

static VecStrT t_bounded_alloc ( rpa::thr_nb_t  aNbThr,
int  aArgC,
const char *const *  aArgV 
) [static]

static VecStrT t_bounded_noall ( rpa::thr_nb_t  aNbThr,
int  aArgC,
const char *const *  aArgV 
) [static]

Tests with limited-size buffers, which are allocated on the stack, that is, without buffers given by the user.

* '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.

Simple syntax and consistency check.

static VecStrT t_nobuf_back_insert ( rpa::thr_nb_t  aNbThr,
int  aArgC,
const char *const *  aArgV 
) [static]

Test without output buffer, but with a mutex to protect the back_inserter.

static VecStrT t_nobuf_plain ( rpa::thr_nb_t  aNbThr,
int  aArgC,
const char *const *  aArgV 
) [static]

Test without output buffer, but with a mutex to protect the output.

The buffer is already allocated.

Checks the return value of the algorithm.

static VecStrT t_unbounded_alloc ( rpa::thr_nb_t  aNbThr,
int  aArgC,
const char *const *  aArgV 
) [static]

Test with an output buffer of unlimited size.

* '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.

Simple syntax and consistency check.

static VecStrT t_unbounded_noall ( rpa::thr_nb_t  aNbThr,
int  aArgC,
const char *const *  aArgV 
) [static]

Test with an output buffer of unlimited size.

* '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.

Simple syntax and consistency check.


Variable Documentation

size_t gblBufSz = 10

DeqStrBufAllocT myDeqBuf

rpa::testing_mutex myMtx

char* myPtr[NB_SAMPLES] [static]

char myStr[NB_SAMPLES][RPA_INT_STR] [static]

rpa::testing_thread myThr[NB_THR] [static]

bool myTstFlags[NB_SAMPLES] [static]

Used to check that each value is seen only once.


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