aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
scheduler.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
47
48
#ifndef GUM_SCHEDULER_H
49
#define GUM_SCHEDULER_H
50
51
#include <utility>
52
53
#include <
agrum/agrum.h
>
54
55
#include <
agrum/base/core/threads/threadNumberManager.h
>
56
#include <
agrum/base/graphicalModels/inference/scheduler/schedule.h
>
57
58
namespace
gum
{
59
61
enum
SchedulerType
{
62
SEQUENTIAL
,
// fully sequential scheduler
63
PARALLEL_OPERATORS
// combinations and projections are dispatched among threads
64
};
65
71
class
Scheduler
:
public
ThreadNumberManager
{
72
public
:
73
// ############################################################################
75
// ############################################################################
77
79
89
Scheduler
(
Size
nb_threads = 0,
double
max_megabyte_memory = 0.0);
90
92
[[nodiscard]]
virtual
Scheduler
*
clone
()
const
= 0;
93
95
~Scheduler
()
override
;
96
98
99
100
// ############################################################################
102
// ############################################################################
104
106
111
virtual
void
setMaxMemory
(
double
megabytes);
112
114
118
virtual
double
maxMemory
()
const
;
119
121
virtual
void
execute
(
Schedule
&) = 0;
122
125
virtual
double
nbOperations
(
const
Schedule
&) = 0;
126
128
135
virtual
std::pair< double, double >
memoryUsage
(
const
Schedule
&) = 0;
136
138
139
140
protected
:
142
double
_max_memory
{0.0};
143
144
146
Scheduler
(
const
Scheduler
& from);
147
149
Scheduler
(
Scheduler
&& from);
150
152
Scheduler
&
operator=
(
const
Scheduler
& from);
153
155
Scheduler
&
operator=
(
Scheduler
&& from);
156
};
157
158
}
/* namespace gum */
159
160
// include the inlined functions if necessary
161
#ifndef GUM_NO_INLINE
162
# include <
agrum/base/graphicalModels/inference/scheduler/scheduler_inl.h
>
163
#endif
/* GUM_NO_INLINE */
164
165
#endif
/* GUM_SCHEDULER_H */
agrum.h
gum::Schedule
Class containing a schedule of operations to perform on multidims.
Definition
schedule.h:79
gum::Scheduler::Scheduler
Scheduler(const Scheduler &from)
copy constructor
gum::Scheduler::operator=
Scheduler & operator=(Scheduler &&from)
move operator
gum::Scheduler::~Scheduler
~Scheduler() override
destructor
gum::Scheduler::Scheduler
Scheduler(Size nb_threads=0, double max_megabyte_memory=0.0)
default constructor
gum::Scheduler::execute
virtual void execute(Schedule &)=0
execute all the operations of a given schedule
gum::Scheduler::memoryUsage
virtual std::pair< double, double > memoryUsage(const Schedule &)=0
returns the memory consumption used during the execution of a schedule
gum::Scheduler::operator=
Scheduler & operator=(const Scheduler &from)
copy operator
gum::Scheduler::maxMemory
virtual double maxMemory() const
returns the Max memory (in megabytes) available for executing schedules
gum::Scheduler::nbOperations
virtual double nbOperations(const Schedule &)=0
returns an estimation of the number of elementary operations needed to perform a given schedule
gum::Scheduler::_max_memory
double _max_memory
the max memory usage possible (in bytes)
Definition
scheduler.h:142
gum::Scheduler::clone
virtual Scheduler * clone() const =0
virtual copy constructor
gum::Scheduler::setMaxMemory
virtual void setMaxMemory(double megabytes)
sets an upper bound on the memory consumption admissible
gum::Scheduler::Scheduler
Scheduler(Scheduler &&from)
move constructor
gum::ThreadNumberManager::ThreadNumberManager
ThreadNumberManager(Size nb_threads=0)
default constructor
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::SchedulerType
SchedulerType
the type of scheduler that can be used
Definition
scheduler.h:61
gum::PARALLEL_OPERATORS
@ PARALLEL_OPERATORS
Definition
scheduler.h:63
gum::SEQUENTIAL
@ SEQUENTIAL
Definition
scheduler.h:62
schedule.h
Class containing a schedule of operations to perform on multidims.
scheduler_inl.h
the common interface of all the schedulers
threadNumberManager.h
A class to manage the number of threads to use in an algorithm.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0