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