/usr/include/gecode/kernel/tracer.hpp is in libgecode-dev 5.1.0-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2016
*
* Last modified:
* $Date: 2017-03-17 23:04:57 +0100 (Fri, 17 Mar 2017) $ by $Author: schulte $
* $Revision: 15597 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode {
/// Class to provide synchronization
class TracerBase : public HeapAllocated {
protected:
/// Mutex to provide synchronization
GECODE_KERNEL_EXPORT
static Support::Mutex m;
};
template<class View> class ViewTraceRecorder;
/**
* \brief Tracer that process view trace information
* \ingroup TaskTrace
*/
template<class View>
class ViewTracer : public TracerBase {
template<class ViewForTraceRecorder> friend class ViewTraceRecorder;
private:
/**
* \brief Init function synchronization
*
* Just calls the actual init function protected by a mutex.
*
*/
void _init(const Space& home, const ViewTraceRecorder<View>& t);
/**
* \brief Prune function synchronization
*
* Just calls the actual prune function protected by a mutex.
*
*/
void _prune(const Space& home, const ViewTraceRecorder<View>& t,
const ViewTraceInfo& vti,
int i, typename TraceTraits<View>::TraceDelta& d);
/**
* \brief Fail function synchronization
*
* Just calls the actual fail function protected by a mutex.
*
*/
void _fail(const Space& home, const ViewTraceRecorder<View>& t);
/**
* \brief Fixpoint function synchronization
*
* Just calls the actual fixpoint function protected by a mutex.
*/
void _fix(const Space& home, const ViewTraceRecorder<View>& t);
/**
* \brief Done function synchronization
*
* Just calls the actual done function protected by a mutex.
*/
void _done(const Space& home, const ViewTraceRecorder<View>& t);
public:
/// Constructor
ViewTracer(void);
/**
* \brief Init function
*
* The init function is called when the trace collector has
* been initialized.
*/
virtual void init(const Space& home,
const ViewTraceRecorder<View>& t) = 0;
/**
* \brief Prune function
*
* The variable at position \a i has been modified where
* the modification is described by \a d. Additional
* information about how the variable has been changed is
* provided by the trace collector \a t and execution
* information \a ei.
*/
virtual void prune(const Space& home,
const ViewTraceRecorder<View>& t,
const ViewTraceInfo& vti,
int i, typename TraceTraits<View>::TraceDelta& d) = 0;
/**
* \brief Fail function
*
* The fail function is called whenever \a home containing the
* trace collector \a t has been failed.
*/
virtual void fail(const Space& home,
const ViewTraceRecorder<View>& t) = 0;
/**
* \brief Fixpoint function
*
* The fixpoint function is called whenever \a home containing
* the trace collector \a t reaches a fixpoint (and fixpoint
* tracing is enabled).
*/
virtual void fix(const Space& home,
const ViewTraceRecorder<View>& t) = 0;
/**
* \brief Done function
*
* The done function is called whenever the trace collector \a t
* is done and will terminate.
*/
virtual void done(const Space& home,
const ViewTraceRecorder<View>& t) = 0;
/// Destructor
virtual ~ViewTracer(void);
};
/**
* \brief Tracer
* \ingroup TaskTrace
*/
class Tracer : public TracerBase {
friend class Space;
private:
/**
* \brief Propagate function synchronization
*
* Just calls the actual propagate function protected by a mutex.
*
*/
void _propagate(const Space& home, const PropagateTraceInfo& pti);
/**
* \brief Commit function synchronization
*
* Just calls the actual commit function protected by a mutex.
*
*/
void _commit(const Space& home, const CommitTraceInfo& cti);
public:
/// Constructor
Tracer(void);
/**
* \brief Propagate function
*
* The propagate function is called when a propagator has been
* executed.
*/
virtual void propagate(const Space& home,
const PropagateTraceInfo& pti) = 0;
/**
* \brief Commit function
*
* The commit function is called when a brancher has executed
* a commit operation.
*/
virtual void commit(const Space& home,
const CommitTraceInfo& cti) = 0;
/// Destructor
virtual ~Tracer(void);
};
/**
* \brief Default tracer
* \ingroup TaskTrace
*/
class GECODE_KERNEL_EXPORT StdTracer : public Tracer {
protected:
/// Output stream to use
std::ostream& os;
public:
/// Initialize with output stream \a os0
StdTracer(std::ostream& os0 = std::cerr);
/**
* \brief Propagate function
*
* The propagate function is called when a propagator has been
* executed.
*/
virtual void propagate(const Space& home,
const PropagateTraceInfo& pti);
/**
* \brief Commit function
*
* The commit function is called when a brancher has executed
* a commit operation.
*/
virtual void commit(const Space& home,
const CommitTraceInfo& cti);
/// Default tracer (printing to std::cerr)
static StdTracer def;
};
/*
* View tracer
*/
template<class View>
forceinline
ViewTracer<View>::ViewTracer(void) {
}
template<class View>
forceinline void
ViewTracer<View>::_init(const Space& home,
const ViewTraceRecorder<View>& t) {
m.acquire();
init(home,t);
m.release();
}
template<class View>
forceinline void
ViewTracer<View>::_prune(const Space& home,
const ViewTraceRecorder<View>& t,
const ViewTraceInfo& vti,
int i, typename TraceTraits<View>::TraceDelta& d) {
m.acquire();
prune(home,t,vti,i,d);
m.release();
}
template<class View>
forceinline void
ViewTracer<View>::_fail(const Space& home,
const ViewTraceRecorder<View>& t) {
m.acquire();
fail(home,t);
m.release();
}
template<class View>
forceinline void
ViewTracer<View>::_fix(const Space& home,
const ViewTraceRecorder<View>& t) {
m.acquire();
fix(home,t);
m.release();
}
template<class View>
forceinline void
ViewTracer<View>::_done(const Space& home,
const ViewTraceRecorder<View>& t) {
m.acquire();
done(home,t);
m.release();
}
template<class View>
forceinline
ViewTracer<View>::~ViewTracer(void) {
}
/*
* Tracer
*/
forceinline
Tracer::Tracer(void) {
}
forceinline void
Tracer::_propagate(const Space& home,
const PropagateTraceInfo& pti) {
m.acquire();
propagate(home,pti);
m.release();
}
forceinline void
Tracer::_commit(const Space& home,
const CommitTraceInfo& cti) {
m.acquire();
commit(home,cti);
m.release();
}
forceinline
Tracer::~Tracer(void) {
}
}
// STATISTICS: kernel-trace
|