44 template<
class Tracer>
49 template<
class Tracer>
54 template<
class Tracer>
55 forceinline
unsigned int
57 return static_cast<unsigned int>(
opt().
threads);
59 template<
class Tracer>
70 template<
class Tracer>
73 return _cmd.load(std::memory_order_acquire);
75 template<
class Tracer>
81 template<
class Tracer>
84 _cmd.store(c, std::memory_order_release);
87 template<
class Tracer>
97 template<
class Tracer>
101 path(s == nullptr ? 0 : e.
opt().nogoods_limit),
d(0),
118 template<
class Tracer>
127 has_stopped.store(
false, std::memory_order_release);
136 template<
class Tracer>
149 template<
class Tracer>
155 template<
class Tracer>
166 template<
class Tracer>
175 template<
class Tracer>
180 has_stopped.store(
true, std::memory_order_release);
190 template<
class Tracer>
203 template<
class Tracer>
212 template<
class Tracer>
219 template<
class Tracer>
238 template<
class Tracer>
247 template<
class Tracer>
256 template<
class Tracer>
268 template<
class Tracer>
290 template<
class Tracer>
299 template<
class Tracer>
311 has_stopped.store(
false, std::memory_order_release);
351 template<
class Tracer>
360 template<
class Tracer>
370 template<
class Tracer>
No-goods recorded from restarts.
double threads
Number of threads to use.
Support::Mutex m
Mutex for access to worker.
Engine & _engine
Reference to engine.
NoGoods & nogoods(void)
Return no-goods.
Statistics statistics(void)
Return statistics.
Space * cur
Current space being explored.
virtual ~Worker(void)
Destructor.
Tracer tracer
Search tracer.
Space * steal(unsigned long int &d, Tracer &myt, Tracer &ot)
Hand over some work (nullptr if no work available).
unsigned int d
Distance until next clone.
bool idle
Whether the worker is idle.
Path< Tracer > path
Current path ins search tree.
virtual Support::Terminator * terminator(void) const
Terminator (engine).
Engine & engine(void) const
Provide access to engine.
Parallel depth-first search engine
void idle(void)
Report that worker is idle.
void wait(void)
Ensure that worker waits.
Support::Event _e_terminate
Event for termination (all threads have terminated).
void ack_reset_stop(void)
For worker to acknowledge stop of reset cycle.
const Options & opt(void) const
Provide access to search options.
Support::Mutex _m_wait_terminate
Mutex for waiting for termination.
Support::Event e_reset_ack_stop
Event for reset acknowledgment stopped.
Support::Mutex _m_wait
Mutex for forcing workers to wait.
Support::Event e_search
Event for search (solution found, no more solutions, search stopped).
virtual Space * next(void)
Return next solution (nullptr, if none exists or search has been stopped).
Support::Event _e_term_ack
Event for termination acknowledgment.
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
virtual bool stopped(void) const
Check whether engine has been stopped.
void stop(void)
Report that worker has been stopped.
void block(void)
Block all workers.
Support::Mutex m_wait_reset
Mutex for waiting for reset.
Support::Mutex m_search
Mutex for search.
Support::Event e_reset_ack_start
Event for reset acknowledgment started.
Support::Mutex _m_term
Mutex for access to termination information.
std::atomic< bool > has_stopped
Whether a worker had been stopped.
Cmd cmd(void) const
Return current command.
virtual ~Engine(void)
Destructor.
Engine(const Options &o)
Initialize with options o.
Options _opt
Search options.
void busy(void)
Report that worker is busy.
volatile unsigned int _n_reset_not_ack
Number of workers that have not yet acknowledged reset.
void release(Cmd c)
Release all workers.
bool signal(void) const
Whether search state changed such that signal is needed.
void ack_reset_start(void)
For worker to acknowledge start of reset cycle.
volatile unsigned int _n_term_not_ack
Number of workers that have not yet acknowledged termination.
void wait_reset(void)
For worker to wait for all workers to reset.
volatile unsigned int _n_not_terminated
Number of not yet terminated workers.
virtual void terminated(void)
For worker to register termination.
void terminate(void)
For engine to perform thread termination.
std::atomic< Cmd > _cmd
The current command.
Support::Mutex _m_reset
Mutex for access to reset information.
volatile unsigned int n_busy
Number of busy workers.
void wait_terminate(void)
For worker to wait until termination is legal.
unsigned int workers(void) const
Return number of workers.
Cmd
Commands from engine to workers.
@ C_WAIT
Run into wait lock.
void ack_terminate(void)
For worker to acknowledge termination command.
Statistics(void)
Initialize.
unsigned long long int fail
Number of failed nodes in search tree.
An interface for objects that can be called after a thread has terminated (after running the thread's...
static void releaseGlobalMutex(Mutex *m)
release globally acquired mutex m
static void acquireGlobalMutex(Mutex *m)
acquire mutex m globally and possibly lock
Heap heap
The single global heap.
SpaceStatus status(StatusStatistics &stat)
Query space status.
@ SS_FAILED
Space is failed
Space * snapshot(Space *s, const Options &o)
Clone space s depending on options o.
Gecode toplevel namespace
#define GECODE_NEVER
Assert that this command is never executed.