main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
kernel
trace
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
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
namespace
Gecode
{
35
37
class
TracerBase
:
public
HeapAllocated
{
38
protected
:
40
GECODE_KERNEL_EXPORT
41
static
Support::Mutex
m
;
42
};
43
44
template
<
class
View>
class
ViewTraceRecorder
;
45
50
template
<
class
View>
51
class
ViewTracer
:
public
TracerBase
{
52
template
<
class
ViewForTraceRecorder>
friend
class
ViewTraceRecorder
;
53
private
:
60
void
_init(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
67
void
_prune(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
,
68
const
ViewTraceInfo
& vti,
69
int
i
,
typename
TraceTraits<View>::TraceDelta
&
d
);
76
void
_fail(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
82
void
_fix(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
88
void
_done(
const
Space
& home,
const
ViewTraceRecorder<View>
&
t
);
89
public
:
91
ViewTracer
(
void
);
98
virtual
void
init
(
const
Space
& home,
99
const
ViewTraceRecorder<View>
&
t
) = 0;
109
virtual
void
prune
(
const
Space
& home,
110
const
ViewTraceRecorder<View>
&
t
,
111
const
ViewTraceInfo
& vti,
112
int
i
,
typename
TraceTraits<View>::TraceDelta
&
d
) = 0;
119
virtual
void
fail
(
const
Space
& home,
120
const
ViewTraceRecorder<View>
&
t
) = 0;
128
virtual
void
fix
(
const
Space
& home,
129
const
ViewTraceRecorder<View>
&
t
) = 0;
136
virtual
void
done
(
const
Space
& home,
137
const
ViewTraceRecorder<View>
&
t
) = 0;
139
virtual
~ViewTracer
(
void
);
140
};
141
142
143
144
149
class
Tracer
:
public
TracerBase
{
150
friend
class
Space
;
151
friend
class
PostInfo
;
152
private
:
159
void
_propagate(
const
Space
& home,
const
PropagateTraceInfo
& pti);
166
void
_commit(
const
Space
& home,
const
CommitTraceInfo
& cti);
173
void
_post(
const
Space
& home,
const
PostTraceInfo
& pti);
174
public
:
176
Tracer
(
void
);
183
virtual
void
propagate
(
const
Space
& home,
184
const
PropagateTraceInfo
& pti) = 0;
191
virtual
void
commit
(
const
Space
& home,
192
const
CommitTraceInfo
& cti) = 0;
199
virtual
void
post
(
const
Space
& home,
200
const
PostTraceInfo
& pti) = 0;
202
virtual
~Tracer
(
void
);
203
};
204
205
210
class
GECODE_KERNEL_EXPORT
StdTracer
:
public
Tracer
{
211
protected
:
213
std::ostream&
os
;
214
public
:
216
StdTracer
(std::ostream& os = std::cerr);
223
virtual
void
propagate(
const
Space
& home,
224
const
PropagateTraceInfo
& pti);
231
virtual
void
commit(
const
Space
& home,
232
const
CommitTraceInfo
& cti);
239
virtual
void
post
(
const
Space
& home,
240
const
PostTraceInfo
& pti);
242
static
StdTracer
def
;
243
};
244
245
246
/*
247
* View tracer
248
*/
249
250
template
<
class
View>
251
forceinline
252
ViewTracer<View>::ViewTracer
(
void
) {
253
}
254
255
template
<
class
View>
256
forceinline
void
257
ViewTracer<View>::_init
(
const
Space
& home,
258
const
ViewTraceRecorder<View>
&
t
) {
259
Support::Lock
l
(m);
260
init(home,
t
);
261
}
262
template
<
class
View>
263
forceinline
void
264
ViewTracer<View>::_prune(
const
Space& home,
265
const
ViewTraceRecorder<View>&
t
,
266
const
ViewTraceInfo& vti,
267
int
i
,
typename
TraceTraits<View>::TraceDelta&
d
) {
268
Support::Lock
l
(m);
269
prune
(home,
t
,vti,
i
,
d
);
270
}
271
template
<
class
View>
272
forceinline
void
273
ViewTracer<View>::_fail(
const
Space& home,
274
const
ViewTraceRecorder<View>&
t
) {
275
Support::Lock
l
(m);
276
fail(home,
t
);
277
}
278
template
<
class
View>
279
forceinline
void
280
ViewTracer<View>::_fix(
const
Space& home,
281
const
ViewTraceRecorder<View>&
t
) {
282
Support::Lock
l
(m);
283
fix(home,
t
);
284
}
285
template
<
class
View>
286
forceinline
void
287
ViewTracer<View>::_done(
const
Space& home,
288
const
ViewTraceRecorder<View>&
t
) {
289
Support::Lock
l
(m);
290
done(home,
t
);
291
}
292
293
template
<
class
View>
294
forceinline
295
ViewTracer<View>::~ViewTracer
(
void
) {
296
}
297
298
299
/*
300
* Tracer
301
*/
302
303
forceinline
304
Tracer::Tracer
(
void
) {
305
}
306
307
forceinline
void
308
Tracer::_propagate(
const
Space
& home,
309
const
PropagateTraceInfo
& pti) {
310
Support::Lock
l
(
m
);
311
propagate
(home,pti);
312
}
313
forceinline
void
314
Tracer::_commit(
const
Space& home,
315
const
CommitTraceInfo& cti) {
316
Support::Lock
l
(
m
);
317
commit
(home,cti);
318
}
319
forceinline
void
320
Tracer::_post(
const
Space& home,
321
const
PostTraceInfo& pti) {
322
Support::Lock
l
(
m
);
323
post
(home,pti);
324
}
325
326
forceinline
327
Tracer::~Tracer
(
void
) {
328
}
329
330
}
331
332
// STATISTICS: kernel-trace
Gecode::PostTraceInfo
Post trace information.
Definition:
core.hpp:1032
Gecode::StdTracer::def
static StdTracer def
Default tracer (printing to std::cerr)
Definition:
tracer.hpp:242
Gecode::ViewTracer::~ViewTracer
virtual ~ViewTracer(void)
Destructor.
Definition:
tracer.hpp:295
Gecode::StdTracer
Default tracer.
Definition:
tracer.hpp:210
Gecode::ViewTracer::ViewTracer
ViewTracer(void)
Constructor.
Definition:
tracer.hpp:252
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:230
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Support::Lock
A lock as a scoped frontend for a mutex.
Definition:
thread.hpp:191
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:41
Gecode::ViewTracer::fix
virtual void fix(const Space &home, const ViewTraceRecorder< View > &t)=0
Fixpoint function.
Gecode::CommitTraceInfo
Commit trace information.
Definition:
core.hpp:1005
Gecode::ViewTracer
Tracer that process view trace information.
Definition:
tracer.hpp:51
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition:
filter.cpp:138
Gecode::PostInfo
Class to set group information when a post function is executed.
Definition:
core.hpp:948
Gecode::ViewTraceRecorder
Propagator for recording view trace information.
Definition:
recorder.hpp:60
GECODE_KERNEL_EXPORT
#define GECODE_KERNEL_EXPORT
Definition:
kernel.hh:70
Gecode::HeapAllocated
Base class for heap allocated objects.
Definition:
heap.hpp:340
Gecode::Int::Count::prune
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition:
rel.hpp:264
Gecode::Tracer
Tracer.
Definition:
tracer.hpp:149
Gecode::TracerBase
Class to provide synchronization.
Definition:
tracer.hpp:37
Gecode::ViewTracer::init
virtual void init(const Space &home, const ViewTraceRecorder< View > &t)=0
Init function.
l
NNF * l
Left subtree.
Definition:
bool-expr.cpp:240
Gecode::TraceTraits
Traits for tracing.
Definition:
traits.hpp:49
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::ViewTraceInfo
View trace information.
Definition:
core.hpp:908
forceinline
#define forceinline
Definition:
config.hpp:185
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:327
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:304
Gecode::Support::Mutex
A mutex for mutual exclausion among several threads.
Definition:
thread.hpp:96
Gecode::PropagateTraceInfo
Propagate trace information.
Definition:
core.hpp:969
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::Tracer::post
virtual void post(const Space &home, const PostTraceInfo &pti)=0
Post function.
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:213