aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
Basic data structures
Collaboration diagram for Basic data structures:

Topics

 Hash Tables
 A efficient and flexible implementation of hash tables.
 Hash functions
 This module lists all hash functions provided by aGrUM.
 Bijections
 Set of pairs of elements with fast search for both elements.
 Heaps
 An implementation of heaps.
 Lists
 This file provides class List for manipulating generic lists as well as List<>::iterator, List<>::const_iterator, List<>::iterator_safe and List<>::const_iterator_safe for parsing lists.
 Priority queue
 This file provides class MultiPriorityQueue that is essentially a heap in which elements are sorted according to a dynamically modifiable priority.
 Sequences
 A Sequence<Key> is quite similar to a vector<Key> in that it stores an ordered set of elements.
 Sets
 A Set is a structure that contains arbitrary elements.
 Splay Trees
 A splay tree is a self-balancing binary search tree.

Classes

class  gum::ThreadExecutorBase
 Set the max number of threads to be used. More...
class  gum::AVLTree< Val, Cmp >
 AVL binary search tree. More...
class  gum::AVLTreeIterator< Val, Cmp >
 AVL binary search tree iterator. More...
class  gum::AVLTreeIteratorSafe< Val, Cmp >
 AVL binary search tree safe (w.r.t. More...
class  gum::AVLTreeReverseIterator< Val, Cmp >
 AVL binary search tree reverse iterator. More...
class  gum::AVLTreeReverseIteratorSafe< Val, Cmp >
 AVL binary search tree safe (w.r.t. More...
class  gum::Bijection< T1, T2 >
 Set of pairs of elements with fast search for both elements. More...
class  gum::BinSearchTree< Val, Cmp, Node >
 A generic binary search tree. More...
class  gum::BinSearchTreeIterator< Val, Cmp, Node >
 A Generic binary search tree. More...
class  gum::BinTreeNode< Val >
 Nodes of a binary trees. More...
class  gum::ParseError
 This class is used to represent parsing errors for the different parser implemented in aGrUM. More...
class  gum::ErrorsContainer
 This class is used contain and manipulate gum::ParseError. More...
class  gum::HashTable< Key, Val >
 The class for generic Hash Tables. More...
class  gum::Heap< Val, Cmp >
 Heap data structure. More...
class  gum::IndexedTree< Key, Data >
 The class for storing the nodes of the Arborescence. More...
class  gum::List< Val >
 Generic doubly linked lists. More...
class  gum::ListIteratorSafe< Val >
 Safe iterators for Lists. More...
class  gum::MultiPriorityQueue< Val, Priority, Cmp >
 A MultiPriorityQueue is a heap in which each element has a mutable priority and duplicates are allowed. More...
class  gum::PriorityQueue< Val, Priority, Cmp >
 A priorityQueue is a heap in which each element has a mutable priority. More...
class  gum::RefPtr< Val >
 Smart pointers. More...
class  gum::Sequence< Key >
 The generic class for storing (ordered) sequences of objects. More...
class  gum::Set< Key >
 Representation of a set. More...
class  gum::SortedPriorityQueueIterator< Val, Priority, Cmp >
 Sorted priority queue iterator. More...
class  gum::SortedPriorityQueueIteratorSafe< Val, Priority, Cmp >
 Sorted priority queues safe (w.r.t. More...
class  gum::SortedPriorityQueueReverseIterator< Val, Priority, Cmp >
 Sorted priority queue reverse iterator. More...
class  gum::SortedPriorityQueueReverseIteratorSafe< Val, Priority, Cmp >
 Sorted priority queue safe (w.r.t. More...
class  gum::SplayTree< Element >
 A splay tree. More...
class  gum::ThreadData< T_DATA >
 A wrapper that enables to store data in a way that prevents false cacheline sharing. More...
class  gum::Timer
 Class used to compute response times for benchmark purposes. More...

Functions

void gum::setNumberOfThreads (unsigned int number)
 Set the max number of threads to be used when entering the next parallel region.
bool gum::threadsOMP::hasOMPSupport ()
 Is OMP active ?
unsigned int gum::threadsOMP::getMaxNumberOfThreads ()
 Returns the maximum number of threads that should be used at any time.
unsigned int gum::threadsOMP::getNumberOfLogicalProcessors ()
 Get the number of logical processors.
void gum::threadsOMP::setNumberOfThreads (unsigned int number)
 Set the number of threads to be used when entering the next parallel region.
unsigned int gum::threadsOMP::getThreadNumber ()
 Get the calling thread id.
unsigned int gum::threadsOMP::getNumberOfRunningThreads ()
 Get the current number of running threads.
void gum::threadsOMP::setNestedParallelism (bool value)
 Set nested parallelism (false bu default).
bool gum::threadsOMP::getNestedParallelism ()
 Get nested parallelism status.
void gum::threadsOMP::setDynamicThreadsNumber (bool value)
 Set the dynamic threads number (false by default).
bool gum::threadsOMP::getDynamicThreadsNumber ()
 Get the dynamic thread number adjustment status.
unsigned int gum::threadsSTL::getMaxNumberOfThreads ()
 Returns the maximum number of threads you should use at any time.
unsigned int gum::threadsSTL::getNumberOfLogicalProcessors ()
 Get the number of logical processors.
void gum::threadsSTL::setNumberOfThreads (unsigned int number)
 Set the max number of threads to be used when entering the next parallel region.

Detailed Description

Function Documentation

◆ getDynamicThreadsNumber()

INLINE bool gum::threadsOMP::getDynamicThreadsNumber ( )

Get the dynamic thread number adjustment status.

Returns
True if dynamic adjustment is enabled, False otherwise.

Definition at line 127 of file threadsOMP_inl.h.

127 {
128#ifdef _OPENMP
129 return ((omp_get_dynamic() == 0) ? false : true);
130#else
131 return false;
132#endif
133 }

◆ getMaxNumberOfThreads() [1/2]

INLINE unsigned int gum::threadsOMP::getMaxNumberOfThreads ( )

Returns the maximum number of threads that should be used at any time.

By default, it should be the number of CPU cores available. Note that it is preferable to use function getNumberOfThreads(), which corresponds to the max number of threads the user wants to launch in parallel regions (this is by default equal to getMaxNumberOfThreads(), but the user may wish to change it for some reason).

Returns
Returns the maximum number of threads at any time.

Definition at line 66 of file threadsOMP_inl.h.

66 {
67#ifdef _OPENMP
68 return omp_get_max_threads();
69#else
70 return 1;
71#endif
72 }

◆ getMaxNumberOfThreads() [2/2]

INLINE unsigned int gum::threadsSTL::getMaxNumberOfThreads ( )

Returns the maximum number of threads you should use at any time.

By default, it should be the number of CPU cores available. Note that it is preferable to use function getNumberOfThreads(), which corresponds to the max number of threads the user wants to launch in parallel regions (this is by default equal to getMaxNumberOfThreads(), but the user may wish to change it for some reason).

Returns
Returns the maximum number of threads that should be used at any time.

Definition at line 60 of file threadsSTL_inl.h.

60{ return std::thread::hardware_concurrency(); }

◆ getNestedParallelism()

INLINE bool gum::threadsOMP::getNestedParallelism ( )

Get nested parallelism status.

Returns
True if nested parallelism is enabled, False otherwise.

Definition at line 108 of file threadsOMP_inl.h.

108 {
109#ifdef _OPENMP
110 return ((omp_get_nested() == 0) ? false : true);
111#else
112 return false;
113#endif
114 }

◆ getNumberOfLogicalProcessors() [1/2]

INLINE unsigned int gum::threadsOMP::getNumberOfLogicalProcessors ( )

Get the number of logical processors.

Returns
The number of logical processors.

Definition at line 74 of file threadsOMP_inl.h.

74 {
75#ifdef _OPENMP
76 return omp_get_num_procs();
77#else
78 return std::thread::hardware_concurrency();
79#endif
80 }

◆ getNumberOfLogicalProcessors() [2/2]

INLINE unsigned int gum::threadsSTL::getNumberOfLogicalProcessors ( )

Get the number of logical processors.

Returns
The number of logical processors.

Definition at line 63 of file threadsSTL_inl.h.

63 {
64 return std::thread::hardware_concurrency();
65 }

◆ getNumberOfRunningThreads()

INLINE unsigned int gum::threadsOMP::getNumberOfRunningThreads ( )

Get the current number of running threads.

Call this from a parallel region.

Returns
The current number of running threads.

Definition at line 90 of file threadsOMP_inl.h.

90 {
91#ifdef _OPENMP
92 return omp_get_num_threads();
93#else
94 return 1;
95#endif
96 }

◆ getThreadNumber()

INLINE unsigned int gum::threadsOMP::getThreadNumber ( )

Get the calling thread id.

Call this from a parallel region.

Returns
The calling thread id.

Definition at line 82 of file threadsOMP_inl.h.

82 {
83#ifdef _OPENMP
84 return omp_get_thread_num();
85#else
86 return 0;
87#endif
88 }

Referenced by gum::credal::MultipleInferenceEngine< GUM_SCALAR, BNInferenceEngine >::updateOldMarginals_().

Here is the caller graph for this function:

◆ hasOMPSupport()

INLINE bool gum::threadsOMP::hasOMPSupport ( )

Is OMP active ?

Returns
True if OMP has been set at compilation, False otherwise.

Definition at line 58 of file threadsOMP_inl.h.

58 {
59#ifdef _OPENMP
60 return true;
61#else
62 return false;
63#endif
64 }

◆ setDynamicThreadsNumber()

INLINE void gum::threadsOMP::setDynamicThreadsNumber ( bool value)

Set the dynamic threads number (false by default).

Automatically adjust the number of running threads within a parallel region.

Desactivated by default.

Parameters
valueTrue if dynamic thread number should be used, False otherwise.

Definition at line 116 of file threadsOMP_inl.h.

116 {
117#ifdef _OPENMP
118 omp_set_dynamic(((value == true) ? 1 : 0));
119#else
121 "openMP was not enabled at compilation (and you "
122 "asked for dynamic adjustment of the number of "
123 "threads !)");
124#endif
125 }
Exception : operation not allowed.
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References GUM_ERROR.

◆ setNestedParallelism()

INLINE void gum::threadsOMP::setNestedParallelism ( bool value)

Set nested parallelism (false bu default).

Nested parallelism, i.e. parallel activity within another parallel activity : threads creating more threads.

Off by default.

Parameters
valueTrue if nested parallelism should be activated, False otherwise.

Definition at line 98 of file threadsOMP_inl.h.

98 {
99#ifdef _OPENMP
100 omp_set_nested(((value == true) ? 1 : 0));
101#else
103 "openMP was not enabled at compilation (and you "
104 "asked for nested parallelism !)");
105#endif
106 }

References GUM_ERROR.

◆ setNumberOfThreads() [1/3]

void gum::setNumberOfThreads ( unsigned int number)

Set the max number of threads to be used when entering the next parallel region.

To avoid spare cycles (less then 100% CPU occupied), you may want to use more threads than logical processors (x2 could be a good all-around value).

Parameters
numberThe number of threads to be used in the next parallel region.

Definition at line 55 of file threads.cpp.

55 {
56 if (number == 0) number = 1;
57
59
60#ifdef _OPENMP
62#endif
63 }
void setNumberOfThreads(unsigned int number)
Set the max number of threads to be used when entering the next parallel region.
void setNumberOfThreads(unsigned int number)
Set the number of threads to be used when entering the next parallel region.

References gum::threadsOMP::setNumberOfThreads(), and gum::threadsSTL::setNumberOfThreads().

Here is the call graph for this function:

◆ setNumberOfThreads() [2/3]

void gum::threadsOMP::setNumberOfThreads ( unsigned int number)

Set the number of threads to be used when entering the next parallel region.

To avoid spare cycles (less then 100% CPU occupied), you may want to use more threads than logical processors (x2 could be a good all-around value).

Parameters
numberThe number of threads to be used in the next parallel region.

Definition at line 69 of file threadsOMP.cpp.

69 {
70 if (number == 0) number = 1;
71#ifdef _OPENMP
72 omp_set_num_threads(number);
73 _nb_threads_ = number;
74#else
75 if (number != 1) {
77 "openMP was not enabled at compilation (or "
78 "you asked for 0 threads !)");
79 }
80#endif
81 }
static unsigned int _nb_threads_

References _nb_threads_, and GUM_ERROR.

Referenced by gum::setNumberOfThreads().

Here is the caller graph for this function:

◆ setNumberOfThreads() [3/3]

void gum::threadsSTL::setNumberOfThreads ( unsigned int number)

Set the max number of threads to be used when entering the next parallel region.

To avoid spare cycles (less then 100% CPU occupied), you may want to use more threads than logical processors (x2 could be a good all-around value).

Parameters
numberThe number of threads to be used in the next parallel region.

Definition at line 71 of file threadsSTL.cpp.

71 {
72 if (number == 0) number = 1;
73 _nb_threads_ = number;
74 }
static unsigned int _nb_threads_

References _nb_threads_.

Referenced by gum::setNumberOfThreads().

Here is the caller graph for this function: