/usr/include/osl/checkmate/dfpnParallel.h is in libosl-dev 0.4.2-1.
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 | /* dfpnParallel.h
*/
#ifndef OSL_DFPNPARALLEL_H
#define OSL_DFPNPARALLEL_H
#include "osl/checkmate/dfpn.h"
#include "osl/misc/lightMutex.h"
namespace osl
{
namespace checkmate
{
class DfpnShared
{
public:
struct ThreadData
{
HashKey restart_key;
volatile int depth;
volatile bool restart;
LightMutex mutex;
ThreadData() : depth(0), restart(false)
{
}
void clear()
{
restart = false;
restart_key = HashKey();
}
}
#ifdef __GNUC__
__attribute__ ((aligned (64)))
#endif
;
volatile bool stop_all;
CArray<ThreadData, 32> data;
DfpnShared() : stop_all(false)
{
}
void restartThreads(const HashKey& key, int depth, unsigned int threads)
{
for (int i=0; i<32; ++i)
if ((1u << i) & threads) {
SCOPED_LOCK(lk, data[i].mutex);
if (! data[i].restart || data[i].depth > depth) {
data[i].restart_key = key;
data[i].depth = depth;
data[i].restart = true;
}
}
}
void clear()
{
stop_all = false;
for (size_t i=0; i<data.size(); ++i)
data[i].clear();
}
};
#ifdef OSL_DFPN_SMP
class DfpnParallel : boost::noncopyable
{
private:
DfpnTable *table;
boost::scoped_array<Dfpn> workers;
size_t num_threads;
// working data
const NumEffectState *state;
HashKey key;
PathEncoding path;
Move last_move;
size_t limit;
struct WorkerData
{
Move best_move;
PieceStand proof;
ProofDisproof result;
};
boost::scoped_array<WorkerData> worker_data;
DfpnShared shared;
public:
explicit DfpnParallel(size_t num_threads=0);
~DfpnParallel();
void setTable(DfpnTable *new_table);
const ProofDisproof
hasCheckmateMove(const NumEffectState& state, const HashKey& key,
const PathEncoding& path, size_t limit, Move& best_move,
Move last_move=Move::INVALID(), vector<Move> *pv=0);
const ProofDisproof
hasCheckmateMove(const NumEffectState& state, const HashKey& key,
const PathEncoding& path, size_t limit, Move& best_move, PieceStand& proof,
Move last_move=Move::INVALID(), vector<Move> *pv=0);
const ProofDisproof
hasEscapeMove(const NumEffectState& state,
const HashKey& key, const PathEncoding& path,
size_t limit, Move last_move);
size_t nodeCount() const;
const DfpnTable& currentTable() const { return *table; }
void analyze(const PathEncoding& path,
const NumEffectState& state, const vector<Move>& moves) const;
void stopNow()
{
shared.stop_all = true;
}
struct AttackWorker;
struct DefenseWorker;
friend struct AttackWorker;
friend struct DefenseWorker;
};
#endif
}
}
#endif /* OSL_DFPNPARALLEL_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|