38 #ifndef __GECODE_SEARCH_PARALLEL_ENGINE_HH__
39 #define __GECODE_SEARCH_PARALLEL_ENGINE_HH__
46 namespace Gecode {
namespace Search {
namespace Parallel {
86 unsigned int workers(
void)
const;
192 virtual bool stopped(
void)
const;
210 return static_cast<unsigned int>(
opt().
threads);
Cmd
Commands from engine to workers.
Support::Event e_reset_ack_start
Event for reset acknowledgment started.
volatile Cmd _cmd
The current command.
virtual ~Worker(void)
Destructor.
Search engine implementation interface
Support::Event _e_term_ack
Event for termination acknowledgment.
void ack_terminate(void)
For worker to acknowledge termination command.
void wait_terminate(void)
For worker to wait until termination is legal.
Depth-first path (stack of edges) supporting recomputation.
void wait_reset(void)
For worker to wait for all workers to reset.
void terminate(void)
For engine to peform thread termination.
Path path
Current path ins search tree.
void idle(void)
Report that worker is idle.
virtual bool stopped(void) const
Check whether engine has been stopped.
An interface for objects that can be run by a thread.
Statistics statistics(void)
Return statistics.
Support::Event _e_terminate
Event for termination (all threads have terminated)
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped)
void acquire(void)
Acquire the mutex and possibly block.
unsigned long int fail
Number of failed nodes in search tree.
void stop(void)
Report that worker has been stopped.
volatile unsigned int _n_not_terminated
Number of not yet terminated workers.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntConLevel icl)
Post propagator such that x forms a Hamiltonian path.
void block(void)
Block all workers.
void signal(void)
Signal the event.
Support::Mutex _m_term
Mutex for access to termination information.
void busy(void)
Report that worker is busy.
volatile unsigned int n_busy
Number of busy workers.
Heap heap
The single global heap.
A mutex for mutual exclausion among several threads.
Support::Mutex _m_wait_terminate
Mutex for waiting for termination.
void release(void)
Release the mutex.
Gecode::FloatVal c(-8, 8)
double threads
Number of threads to use.
void wait(void)
Ensure that worker waits.
int n
Number of negative literals for node type.
An event for synchronization.
Support::Mutex m_wait_reset
Mutex for waiting for reset.
unsigned int d
Distance until next clone.
bool idle
Whether the worker is idle.
Cmd cmd(void) const
Return current command.
void terminated(void)
For worker to register termination.
volatile unsigned int _n_term_not_ack
Number of workers that have not yet acknowledged termination.
Space * cur
Current space being explored.
bool clone
Whether engines create a clone when being initialized.
unsigned int workers(void) const
Return number of workers.
const Options & opt(void) const
Provide access to search options.
Support::Mutex _m_wait
Mutex for forcing workers to wait.
volatile bool has_stopped
Whether a worker had been stopped.
Space * steal(unsigned long int &d)
Hand over some work (NULL if no work available)
Support::Event e_search
Event for search (solution found, no more solutions, search stopped)
Parallel depth-first search engine
Queue with arbitrary number of elements.
const Options _opt
Search options.
Support::Mutex _m_reset
Mutex for access to reset information.
void ack_reset_stop(void)
For worker to acknowledge stop of reset cycle.
Engine(const Options &o)
Initialize with options o.
No-goods recorded from restarts.
void release(Cmd c)
Release all workers.
Parallel depth-first search worker
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
Engine & _engine
Reference to engine.
Space * snapshot(Space *s, const Options &o, bool share=true)
Clone space s dependening on options o.
volatile unsigned int _n_reset_not_ack
Number of workers that have not yet acknowledged reset.
Engine & engine(void) const
Provide access to engine.
Gecode toplevel namespace
const unsigned int nogoods_limit
Depth limit for no-good generation during search.
void ack_reset_start(void)
For worker to acknowledge start of reset cycle.
NoGoods & nogoods(void)
Return no-goods.
void wait(void)
Wait until the event becomes signalled.
Support::Event e_reset_ack_stop
Event for reset acknowledgment stopped.
Support::Mutex m
Mutex for access to worker.
bool signal(void) const
Whether search state changed such that signal is needed.
Support::Mutex m_search
Mutex for search.