File size: 1,327 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/*
 * StatefulFeatureFunction.cpp
 *
 *  Created on: 24 Oct 2015
 *      Author: hieu
 */
#ifdef __linux
#include <pthread.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include <boost/foreach.hpp>
#include "StatefulFeatureFunction.h"
#include "../PhraseBased/Hypothesis.h"

using namespace std;

namespace Moses2
{

StatefulFeatureFunction::StatefulFeatureFunction(size_t startInd,
    const std::string &line) :
  FeatureFunction(startInd, line)
{
}

StatefulFeatureFunction::~StatefulFeatureFunction()
{
  // TODO Auto-generated destructor stub
}

void StatefulFeatureFunction::EvaluateWhenAppliedBatch(
  const System &system,
  const Batch &batch) const
{
  //cerr << "EvaluateWhenAppliedBatch:" << m_name << endl;
#ifdef __linux
  /*
   pthread_t handle;
   handle = pthread_self();

   int s;
   cpu_set_t cpusetOrig, cpuset;
   s = pthread_getaffinity_np(handle, sizeof(cpu_set_t), &cpusetOrig);

   CPU_ZERO(&cpuset);

   int core = handle % 8;
   core += 24;
   CPU_SET(core, &cpuset);

   s = pthread_setaffinity_np(handle, sizeof(cpu_set_t), &cpuset);
   */
#endif

  for (size_t i = 0; i < batch.size(); ++i) {
    Hypothesis *hypo = batch[i];
    hypo->EvaluateWhenApplied(*this);
  }

#ifdef __linux
  //    s = pthread_setaffinity_np(handle, sizeof(cpu_set_t), &cpusetOrig);
#endif
}

}