aGrUM 3.1.1
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::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::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 110 of file threadsOMP_inl.h.

110 {
111#ifdef _OPENMP
112 return ((omp_get_dynamic() == 0) ? false : true);
113#else
114 return false;
115#endif
116 }

◆ 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 67 of file threadsOMP_inl.h.

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

◆ 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 61 of file threadsSTL_inl.h.

61 {
62 return std::max(1u, std::thread::hardware_concurrency());
63 }

◆ getNumberOfLogicalProcessors() [1/2]

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

Get the number of logical processors.

Returns
The number of logical processors.

Definition at line 75 of file threadsOMP_inl.h.

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

◆ getNumberOfLogicalProcessors() [2/2]

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

Get the number of logical processors.

Returns
The number of logical processors.

Definition at line 66 of file threadsSTL_inl.h.

66 {
67 return std::max(1u, std::thread::hardware_concurrency());
68 }

◆ 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 91 of file threadsOMP_inl.h.

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

◆ 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 83 of file threadsOMP_inl.h.

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

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 59 of file threadsOMP_inl.h.

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

◆ 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 99 of file threadsOMP_inl.h.

99 {
100#ifdef _OPENMP
101 omp_set_dynamic(((value == true) ? 1 : 0));
102#else
104 "openMP was not enabled at compilation (and you "
105 "asked for dynamic adjustment of the number of "
106 "threads !)");
107#endif
108 }
Exception : operation not allowed.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

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 71 of file threadsOMP.cpp.

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

References 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 73 of file threadsSTL.cpp.

73 {
74 if (number == 0) number = 1;
75 _nb_threads_ = number;
76 }

Referenced by gum::setNumberOfThreads().

Here is the caller graph for this function: