aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
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-2025 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-2025 *
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
57
58namespace gum {
59
62 SEQUENTIAL, // fully sequential scheduler
63 PARALLEL_OPERATORS // combinations and projections are dispatched among threads
64 };
65
72 public:
73 // ############################################################################
75 // ############################################################################
77
79
89 Scheduler(Size nb_threads = 0, double max_megabyte_memory = 0.0);
90
92 virtual Scheduler* clone() const = 0;
93
95 virtual ~Scheduler();
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
150
153
156 };
157
158} /* namespace gum */
159
160// include the inlined functions if necessary
161#ifndef GUM_NO_INLINE
163#endif /* GUM_NO_INLINE */
164
165#endif /* GUM_SCHEDULER_H */
Class containing a schedule of operations to perform on multidims.
Definition schedule.h:80
Scheduler(const Scheduler &from)
copy constructor
Scheduler & operator=(Scheduler &&from)
move operator
Scheduler(Size nb_threads=0, double max_megabyte_memory=0.0)
default constructor
virtual void execute(Schedule &)=0
execute all the operations of a given schedule
virtual std::pair< double, double > memoryUsage(const Schedule &)=0
returns the memory consumption used during the execution of a schedule
Scheduler & operator=(const Scheduler &from)
copy operator
virtual double maxMemory() const
returns the Max memory (in megabytes) available for executing schedules
virtual double nbOperations(const Schedule &)=0
returns an estimation of the number of elementary operations needed to perform a given schedule
double _max_memory
the max memory usage possible (in bytes)
Definition scheduler.h:142
virtual Scheduler * clone() const =0
virtual copy constructor
virtual ~Scheduler()
destructor
virtual void setMaxMemory(double megabytes)
sets an upper bound on the memory consumption admissible
Scheduler(Scheduler &&from)
move constructor
ThreadNumberManager(Size nb_threads=0)
default constructor
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
SchedulerType
the type of scheduler that can be used
Definition scheduler.h:61
@ PARALLEL_OPERATORS
Definition scheduler.h:63
@ SEQUENTIAL
Definition scheduler.h:62
Class containing a schedule of operations to perform on multidims.
the common interface of all the schedulers
A class to manage the number of threads to use in an algorithm.