Adiar 2.1.0
An External Memory Decision Diagram Library
Loading...
Searching...
No Matches
exec_policy.h
1#ifndef ADIAR_EXEC_POLICY_H
2#define ADIAR_EXEC_POLICY_H
3
4#include <algorithm>
5#include <limits>
6
7#include <adiar/type_traits.h>
8
9namespace adiar
10{
15
35 {
36 public:
54 enum class access : char
55 {
57 Auto,
62 };
63
78 enum class memory : char
79 {
81 Auto,
86 };
87
101 {
102 public:
106 enum algorithm : char
107 {
112 };
113 };
114
115 private:
116 // TODO: Merge all enums into a single 64 bit integer to safe on space?
117
121 access _access = access::Auto;
122
126 memory _memory = memory::Auto;
127
131 quantify::algorithm _quantify__algorithm = quantify::Nested;
132
133 public:
137 exec_policy() = default;
138
142 exec_policy(const exec_policy&) = default;
143
148
153 : _access(am)
154 {}
155
160 : _memory(mm)
161 {}
162
167 : _quantify__algorithm(qa)
168 {}
169
170 // TODO: constructor with defaults for a specific 'version number'?
171
172 public:
177 operator=(const exec_policy&) = default;
178
183 operator=(exec_policy&&) = default;
184
185 public:
189 template <typename T>
190 const T&
191 get() const;
192
193 public:
197 bool
199 {
200 // Order based from the most generic to the most specific setting.
201 return this->_memory == ep._memory && this->_access == ep._access
202 && this->_quantify__algorithm == ep._quantify__algorithm;
203 }
204
208 bool
210 {
211 return !(*this == ep);
212 }
213
214 public:
219 set(const access& am)
220 {
221 this->_access = am;
222 return *this;
223 }
224
229 operator&(const access& am) const
230 {
231 exec_policy ep = *this;
232 return ep.set(am);
233 }
234
239 set(const memory& mm)
240 {
241 this->_memory = mm;
242 return *this;
243 }
244
249 operator&(const memory& mm) const
250 {
251 exec_policy ep = *this;
252 return ep.set(mm);
253 }
254
260 {
261 this->_quantify__algorithm = qa;
262 return *this;
263 }
264
270 {
271 exec_policy ep = *this;
272 return ep.set(qa);
273 }
274 };
275
279 template <>
281 exec_policy::get<exec_policy::access>() const
282 {
283 return this->_access;
284 }
285
289 template <>
291 exec_policy::get<exec_policy::memory>() const
292 {
293 return this->_memory;
294 }
295
299 template <>
301 exec_policy::get<exec_policy::quantify::algorithm>() const
302 {
303 return this->_quantify__algorithm;
304 }
305
308
310
314 template <
315 typename A,
316 typename B,
318 exec_policy
319 operator&(const A& a, const B& b)
320 {
321 return exec_policy(a) & b;
322 }
323
325}
326
327#endif // ADIAR_EXEC_POLICY_H
Strategies and settings for Adiar to use in quantify/project algorithms.
Definition exec_policy.h:101
algorithm
to use for quantification and projection.
Definition exec_policy.h:107
@ Nested
Definition exec_policy.h:109
@ Singleton
Definition exec_policy.h:111
Settings to dictate the execution of Adiar's algorithms.
Definition exec_policy.h:35
exec_policy & set(const memory &mm)
Set the memory mode.
Definition exec_policy.h:239
memory
Whether Adiar should exclusively use internal or external memory or automatically pick either type ba...
Definition exec_policy.h:79
exec_policy operator&(const access &am) const
Create a copy with the access mode changed.
Definition exec_policy.h:229
exec_policy & operator=(const exec_policy &)=default
Copy assignment.
access
Whether Adiar should exclusively use random access or priority queues or automatically pick either wa...
Definition exec_policy.h:55
exec_policy()=default
Default constructor with all options set to their default value.
exec_policy & operator=(exec_policy &&)=default
Move assignment.
exec_policy(const memory &mm)
Conversion construction from memory enum.
Definition exec_policy.h:159
exec_policy operator&(const memory &mm) const
Create a copy with the memory mode changed.
Definition exec_policy.h:249
exec_policy(const access &am)
Conversion construction from access enum.
Definition exec_policy.h:152
bool operator==(const exec_policy &ep) const
Check for equality of settings.
Definition exec_policy.h:198
exec_policy(const quantify::algorithm &qa)
Conversion construction from quantify enum.
Definition exec_policy.h:166
const T & get() const
Obtain a value.
exec_policy & set(const quantify::algorithm &qa)
Set the quantify algorithm.
Definition exec_policy.h:259
exec_policy & set(const access &am)
Set the access mode.
Definition exec_policy.h:219
bool operator!=(const exec_policy &ep) const
Check for at least one mismatch in the settings.
Definition exec_policy.h:209
exec_policy(exec_policy &&)=default
Move constructor.
exec_policy(const exec_policy &)=default
Copy constructor.
exec_policy operator&(const quantify::algorithm &qa) const
Create a copy with the quantify algorithm changed.
Definition exec_policy.h:269
__bdd operator&(const bdd &lhs, const bdd &rhs)
consumer< ValueType > make_consumer(OutputIt &&iter)
Wrap an iterator into a consumer function.
Definition functional.h:71
Core types.
Definition adiar.h:40