main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
kernel
tracer.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Copyright:
7
* Christian Schulte, 2016
8
*
9
* Last modified:
10
* $Date: 2017-03-17 23:04:57 +0100 (Fri, 17 Mar 2017) $ by $Author: schulte $
11
* $Revision: 15597 $
12
*
13
* This file is part of Gecode, the generic constraint
14
* development environment:
15
* http://www.gecode.org
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining
18
* a copy of this software and associated documentation files (the
19
* "Software"), to deal in the Software without restriction, including
20
* without limitation the rights to use, copy, modify, merge, publish,
21
* distribute, sublicense, and/or sell copies of the Software, and to
22
* permit persons to whom the Software is furnished to do so, subject to
23
* the following conditions:
24
*
25
* The above copyright notice and this permission notice shall be
26
* included in all copies or substantial portions of the Software.
27
*
28
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
*
36
*/
37
38
namespace
Gecode
{
39
41
class
TracerBase
:
public
HeapAllocated
{
42
protected
:
44
GECODE_KERNEL_EXPORT
45
static
Support::Mutex
m
;
46
};
47
48
template
<
class
View>
class
ViewTraceRecorder
;
49
54
template
<
class
View>
55
class
ViewTracer
:
public
TracerBase
{
56
template
<
class
ViewForTraceRecorder>
friend
class
ViewTraceRecorder
;
57
private
:
64
void
_init(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
71
void
_prune(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
,
72
const
ViewTraceInfo
& vti,
73
int
i
,
typename
TraceTraits<View>::TraceDelta
&
d
);
80
void
_fail(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
86
void
_fix(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
92
void
_done(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
93
public
:
95
ViewTracer
(
void
);
102
virtual
void
init
(
const
Space
& home,
103
const
ViewTraceRecorder<View>
&
t
) = 0;
113
virtual
void
prune
(
const
Space
& home,
114
const
ViewTraceRecorder<View>
&
t
,
115
const
ViewTraceInfo
& vti,
116
int
i
,
typename
TraceTraits<View>::TraceDelta
&
d
) = 0;
123
virtual
void
fail
(
const
Space
& home,
124
const
ViewTraceRecorder<View>
&
t
) = 0;
132
virtual
void
fix
(
const
Space
& home,
133
const
ViewTraceRecorder<View>
&
t
) = 0;
140
virtual
void
done
(
const
Space
& home,
141
const
ViewTraceRecorder<View>
&
t
) = 0;
143
virtual
~ViewTracer
(
void
);
144
};
145
146
147
148
153
class
Tracer
:
public
TracerBase
{
154
friend
class
Space
;
155
private
:
162
void
_propagate(
const
Space
& home,
const
PropagateTraceInfo
& pti);
169
void
_commit(
const
Space
& home,
const
CommitTraceInfo
& cti);
170
public
:
172
Tracer
(
void
);
179
virtual
void
propagate
(
const
Space
& home,
180
const
PropagateTraceInfo
& pti) = 0;
187
virtual
void
commit
(
const
Space
& home,
188
const
CommitTraceInfo
& cti) = 0;
190
virtual
~Tracer
(
void
);
191
};
192
193
198
class
GECODE_KERNEL_EXPORT
StdTracer
:
public
Tracer
{
199
protected
:
201
std::ostream&
os
;
202
public
:
204
StdTracer
(std::ostream& os0 = std::cerr);
211
virtual
void
propagate(
const
Space
& home,
212
const
PropagateTraceInfo
& pti);
219
virtual
void
commit(
const
Space
& home,
220
const
CommitTraceInfo
& cti);
222
static
StdTracer
def
;
223
};
224
225
226
/*
227
* View tracer
228
*/
229
230
template
<
class
View>
231
forceinline
232
ViewTracer<View>::ViewTracer
(
void
) {
233
}
234
235
template
<
class
View>
236
forceinline
void
237
ViewTracer<View>::_init
(
const
Space
& home,
238
const
ViewTraceRecorder<View>
&
t
) {
239
m.acquire();
240
init(home,
t
);
241
m.release();
242
}
243
template
<
class
View>
244
forceinline
void
245
ViewTracer<View>::_prune(
const
Space& home,
246
const
ViewTraceRecorder<View>&
t
,
247
const
ViewTraceInfo& vti,
248
int
i
,
typename
TraceTraits<View>::TraceDelta&
d
) {
249
m.acquire();
250
prune
(home,
t
,vti,
i
,
d
);
251
m.release();
252
}
253
template
<
class
View>
254
forceinline
void
255
ViewTracer<View>::_fail(
const
Space& home,
256
const
ViewTraceRecorder<View>&
t
) {
257
m.acquire();
258
fail(home,
t
);
259
m.release();
260
}
261
template
<
class
View>
262
forceinline
void
263
ViewTracer<View>::_fix(
const
Space& home,
264
const
ViewTraceRecorder<View>&
t
) {
265
m.acquire();
266
fix(home,
t
);
267
m.release();
268
}
269
template
<
class
View>
270
forceinline
void
271
ViewTracer<View>::_done(
const
Space& home,
272
const
ViewTraceRecorder<View>&
t
) {
273
m.acquire();
274
done(home,
t
);
275
m.release();
276
}
277
278
template
<
class
View>
279
forceinline
280
ViewTracer<View>::~ViewTracer
(
void
) {
281
}
282
283
284
/*
285
* Tracer
286
*/
287
288
forceinline
289
Tracer::Tracer
(
void
) {
290
}
291
292
forceinline
void
293
Tracer::_propagate(
const
Space
& home,
294
const
PropagateTraceInfo
& pti) {
295
m
.
acquire
();
296
propagate
(home,pti);
297
m
.
release
();
298
}
299
forceinline
void
300
Tracer::_commit(
const
Space& home,
301
const
CommitTraceInfo& cti) {
302
m
.
acquire
();
303
commit
(home,cti);
304
m
.
release
();
305
}
306
307
forceinline
308
Tracer::~Tracer
(
void
) {
309
}
310
311
}
312
313
// STATISTICS: kernel-trace
Gecode::StdTracer::def
static StdTracer def
Default tracer (printing to std::cerr)
Definition:
tracer.hpp:222
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::ViewTracer::~ViewTracer
virtual ~ViewTracer(void)
Destructor.
Definition:
tracer.hpp:280
Gecode::StdTracer
Default tracer.
Definition:
tracer.hpp:198
Gecode::Support::Mutex::acquire
void acquire(void)
Acquire the mutex and possibly block.
Definition:
none.hpp:46
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::ViewTracer::ViewTracer
ViewTracer(void)
Constructor.
Definition:
tracer.hpp:232
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:234
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::Tracer::commit
virtual void commit(const Space &home, const CommitTraceInfo &cti)=0
Commit function.
Gecode::Tracer::propagate
virtual void propagate(const Space &home, const PropagateTraceInfo &pti)=0
Propagate function.
Gecode
Gecode toplevel namespace
Gecode::TracerBase::m
static Support::Mutex m
Mutex to provide synchronization.
Definition:
tracer.hpp:45
Gecode::ViewTracer::fix
virtual void fix(const Space &home, const ViewTraceRecorder< View > &t)=0
Fixpoint function.
Gecode::CommitTraceInfo
Commit trace information.
Definition:
core.hpp:1064
Gecode::ViewTracer
Tracer that process view trace information.
Definition:
tracer.hpp:55
Gecode::ViewTraceRecorder
Propagator for recording view trace information.
Definition:
trace-recorder.hpp:63
GECODE_KERNEL_EXPORT
#define GECODE_KERNEL_EXPORT
Definition:
kernel.hh:74
Gecode::HeapAllocated
Base class for heap allocated objects.
Definition:
heap.hpp:344
Gecode::Int::Count::prune
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition:
rel.hpp:257
Gecode::Tracer
Tracer.
Definition:
tracer.hpp:153
Gecode::TracerBase
Class to provide synchronization.
Definition:
tracer.hpp:41
Gecode::ViewTracer::init
virtual void init(const Space &home, const ViewTraceRecorder< View > &t)=0
Init function.
Gecode::TraceTraits
Traits for tracing.
Definition:
trace-traits.hpp:53
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::ViewTraceInfo
View trace information.
Definition:
core.hpp:974
Gecode::ViewTracer::fail
virtual void fail(const Space &home, const ViewTraceRecorder< View > &t)=0
Fail function.
Gecode::Tracer::~Tracer
virtual ~Tracer(void)
Destructor.
Definition:
tracer.hpp:308
Gecode::ViewTracer::done
virtual void done(const Space &home, const ViewTraceRecorder< View > &t)=0
Done function.
Gecode::Tracer::Tracer
Tracer(void)
Constructor.
Definition:
tracer.hpp:289
Gecode::Support::Mutex::release
void release(void)
Release the mutex.
Definition:
none.hpp:52
Gecode::Support::Mutex
A mutex for mutual exclausion among several threads.
Definition:
thread.hpp:99
Gecode::PropagateTraceInfo
Propagate trace information.
Definition:
core.hpp:1028
Gecode::ViewTracer::prune
virtual void prune(const Space &home, const ViewTraceRecorder< View > &t, const ViewTraceInfo &vti, int i, typename TraceTraits< View >::TraceDelta &d)=0
Prune function.
Gecode::StdTracer::os
std::ostream & os
Output stream to use.
Definition:
tracer.hpp:201