CxxUtils Namespace Reference

Copy the elements of a sequence for which a predicate is true. More...

Classes

class  ArrayIteratorChooser
 Helper for defining iterators over Array's. More...
class  ArrayIteratorChooser< 1 >
class  Array
 Read-only multidimensional array. More...
class  Array< 0 >
class  ArrayIterator
 Iterator class for Array<N>. More...
class  WritableArray
 Read-write multidimensional array. More...
class  WritableArray< 0 >
class  WritableArrayData
class  ArrayScanner
 Helper class for converting strings to Array's. More...
class  BitPacker
 Pack a set of values bitwise into a stream. More...
class  BitPacker8
 Pack a set of values bitwise into a stream. More...
class  BitPacker16
 Pack a set of values bitwise into a stream. More...
class  BitUnpacker
 Helper to unpack a set of values bitwise from a stream. More...
class  BitUnpacker8
 Helper to unpack a set of values bitwise from a stream. More...
class  BitUnpacker16
 Helper to unpack a set of values bitwise from a stream. More...
class  ClassName
 Recursively separate out template arguments in a C++ class name. More...
struct  enable_if
 Define a member typedef type only if a boolean constant is true. More...
struct  enable_if< true, _Tp >
class  FloatPacker
 Pack/unpack floating-point data from/to a given number of bits. More...
class  PackedArray
 An array of unsigned values of some bit size, packed tightly. More...
class  pointer_list_base
 A fast way to store a variable-sized collection of pointers. More...
class  pointer_list
 A fast way to store a variable-sized collection of pointers. More...
struct  sincos
 Helper to simultaneously calculate sin and cos of the same angle. More...
struct  extrace_init

Enumerations

enum  { CacheLineSize = 64 }

Functions

template<typename InputIterator , typename OutputIterator , typename Predicate >
OutputIterator copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
template<class InputIterator , class OutputIterator , class InputTag , class OutputTag >
OutputIterator copy_bounded1 (InputIterator begi, InputIterator endi, OutputIterator bego, OutputIterator endo, const InputTag &, const OutputTag &)
 Copy a range with bounds restriction; generic version.
template<class InputIterator , class OutputIterator >
OutputIterator copy_bounded1 (InputIterator begi, InputIterator endi, OutputIterator bego, OutputIterator endo, const std::random_access_iterator_tag &, const std::random_access_iterator_tag &)
 Copy a range with bounds restriction; random_access_iterator version.
template<class InputIterator , class OutputIterator >
OutputIterator copy_bounded (InputIterator begi, InputIterator endi, OutputIterator bego, OutputIterator endo)
 Copy a range with bounds restriction.
template<class InputRange , class OutputRange >
boost::range_iterator
< OutputRange >::type 
copy_bounded (const InputRange &input, OutputRange &output)
 Copy a range with bounds restriction.
void exctrace (const std::exception &e, IOFD fd=IOFD_INVALID)
 Print out information for the last exception.
template<class T >
T ones (unsigned int n)
 Return a bit mask with the lower n bits set.
void prefetchOne (const void *address)
 Generic prefetch method.
template<size_t N>
void prefetchN (const void *ptr)
 Prefetch an N-byte block of memory.
template<typename T >
void prefetchObj (const T *ptr)
 Generic prefetch of the object of specific types (sizes).
template<typename Iter >
void prefetchNext (Iter iter, Iter endIter)
 Prefetch next object in sequence.
template<typename Iter >
void prefetchTwo (Iter iter, Iter endIter)
 Prefetch two objects.
std::string strformat (const char *fmt,...)
 return a `stdstring` according to a format `fmt` and varargs

Detailed Description

Copy the elements of a sequence for which a predicate is true.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
pred A predicate.
Returns:
An iterator designating the end of the resulting sequence.

Copies each element in the range [first,last) for which pred returns true to the range beginning at result.

copy_if() is stable, so the relative order of elements that are copied is unchanged.

Example:

  CxxUtils::copy_if( in.begin(), in.end(),
                     std::back_inserter(out), filter );

where in and out are STL-like containers and filter is a predicate


Enumeration Type Documentation

anonymous enum

While it is possible to determine cache line size at run time (e.g. using sysconf(_SC_LEVEL1_DCACHE_LINESIZE) on Linux or sysctlbyname("hw.cachelinesize", ...) on Apple systems) that approach creates more problems: the location that stores cache line size will probably be out of cache when one needs to know it. This is why we use a compile time constant for cache line size. Cache line size is 64 for the current generation of Intel/AMD CPUs.

If an object spans multiple cache lines then prefetching whole object should be done by prefetching at least one address from each of the cache lines that object occupies. How many lines are needed depends on three things: object size, cache line size, and object starting address. If CacheLineSize is lower than the actual line size then more prefetches than necessary will be generated (2, 4, or more per cache line if cache line size is power of 2). This may be somewhat wasteful so this number may need to be adjusted in the far future when _all_ CPUs have wider cache lines.


Function Documentation

template<class InputRange , class OutputRange >
boost::range_iterator<OutputRange>::type CxxUtils::copy_bounded ( const InputRange &  input,
OutputRange &  output 
) [inline]

Copy a range with bounds restriction.

Parameters:
input Input range
output Output range

copy_bounded written in terms of iterator ranges.

template<class InputIterator , class OutputIterator >
OutputIterator CxxUtils::copy_bounded ( InputIterator  begi,
InputIterator  endi,
OutputIterator  bego,
OutputIterator  endo 
) [inline]

Copy a range with bounds restriction.

Parameters:
begi Start of input range.
endi End of input range.
bego Start of output range.
endo End of output range.

Like std::copy(begi, endi, bego), except that it will not copy more than std::distance(bego, endo) elements.

Copies exactly n = std::min (std::distance(begi,endi), std::distance(bego,endo)) elements. Returns bego + n.

void CxxUtils::exctrace ( const std::exception &  e,
IOFD  fd = IOFD_INVALID 
)

Print out information for the last exception.

Prints the supplied exception, plus the backtrace from the last exception, if available.

Parameters:
e The exception to print.
fd The file descriptor to which to write.
template<size_t N>
void CxxUtils::prefetchN ( const void *  ptr  )  [inline]

Prefetch an N-byte block of memory.

Parameters:
[in] ptr Starting address of the block.
template<typename Iter >
void CxxUtils::prefetchNext ( Iter  iter,
Iter  endIter 
) [inline]

Prefetch next object in sequence.

Parameters:
iter Current iteration position.
endIter End of the sequence.

Iter is a ForwardIterator over pointers.

Prefetches next object in a collection of pointers. Accepts two iterators: the first iterator is the current iteration position, and the second iterator is the end iterator for the whole sequence. The first iterator must not be equal to the end iterator (this is not checked). This increments the iterator and, if not equal to the end, prefetches the complete object referenced by the pointer.

template<typename T >
void CxxUtils::prefetchObj ( const T ptr  )  [inline]

Generic prefetch of the object of specific types (sizes).

Parameters:
[in] address memory location to prefetch

This method will prefetch as many cache lines as needed to store the object of the specified type in memory. Type is specified as a template argument.

void CxxUtils::prefetchOne ( const void *  address  )  [inline]

Generic prefetch method.

Parameters:
[in] address memory location to prefetch

This is generic method that does not have any extra behavior. It only prefetches the whole cache line which contains the specified memory location. It does not incur any additional overhead and may be the most efficient method for small objects which have a high chance of being on just a single cache line.

template<typename Iter >
void CxxUtils::prefetchTwo ( Iter  iter,
Iter  endIter 
) [inline]

Prefetch two objects.

Parameters:
iter Current iteration position.
endIter End of the sequence.

Iter is a ForwardIterator over pointers.

Prefetches the current and next objects in a collection of pointers. Accepts two iterators: the first iterator is the current iteration position, and the second is the end iterator for the whole sequence. If the first iterator is not equal to end the iterator, the object to which it points is prefetched. Then the iterator is incremented and, if not equal to the end iterator, the next objects is also prefetched.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1