Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2016-10-26 18:50:20 +0300
committerHieu Hoang <hieuhoang@gmail.com>2016-10-26 18:50:20 +0300
commit5ff958abac4182fb53b4ce4edfc841ea7c9cffde (patch)
tree63946b13ca8098ec0dc85fbb811fc1b7c0415d25
parent80ae436db177bfadc2db9e1d078f392acfde844c (diff)
slides
-rw-r--r--contrib/moses2/HypothesisColl.cpp1
-rw-r--r--contrib/moses2/HypothesisColl.h2
-rw-r--r--contrib/moses2/Main.cpp2
-rw-r--r--contrib/moses2/MemPool.h79
-rw-r--r--contrib/moses2/MemPoolAllocator.h90
-rw-r--r--contrib/moses2/PhraseBased/CubePruningMiniStack/Misc.h1
-rw-r--r--contrib/moses2/PhraseBased/CubePruningMiniStack/Search.h1
-rw-r--r--contrib/moses2/PhraseBased/CubePruningMiniStack/Stack.h1
-rw-r--r--contrib/moses2/SCFG/InputPath.cpp2
-rw-r--r--contrib/moses2/SCFG/InputPath.h1
-rw-r--r--contrib/moses2/Vector.h2
11 files changed, 99 insertions, 83 deletions
diff --git a/contrib/moses2/HypothesisColl.cpp b/contrib/moses2/HypothesisColl.cpp
index b101acdf8..2af5465e3 100644
--- a/contrib/moses2/HypothesisColl.cpp
+++ b/contrib/moses2/HypothesisColl.cpp
@@ -11,6 +11,7 @@
#include "HypothesisColl.h"
#include "ManagerBase.h"
#include "System.h"
+#include "MemPoolAllocator.h"
using namespace std;
diff --git a/contrib/moses2/HypothesisColl.h b/contrib/moses2/HypothesisColl.h
index 363f52a59..cea3bee1b 100644
--- a/contrib/moses2/HypothesisColl.h
+++ b/contrib/moses2/HypothesisColl.h
@@ -7,7 +7,7 @@
#pragma once
#include <boost/unordered_set.hpp>
#include "HypothesisBase.h"
-#include "MemPool.h"
+#include "MemPoolAllocator.h"
#include "Recycler.h"
#include "Array.h"
#include "legacy/Util2.h"
diff --git a/contrib/moses2/Main.cpp b/contrib/moses2/Main.cpp
index 8bf1ce86b..0661d1d0e 100644
--- a/contrib/moses2/Main.cpp
+++ b/contrib/moses2/Main.cpp
@@ -5,7 +5,7 @@
#include "System.h"
#include "Phrase.h"
#include "TranslationTask.h"
-#include "MemPool.h"
+#include "MemPoolAllocator.h"
#include "server/Server.h"
#include "legacy/InputFileStream.h"
#include "legacy/Parameter.h"
diff --git a/contrib/moses2/MemPool.h b/contrib/moses2/MemPool.h
index cca803775..eaa55915e 100644
--- a/contrib/moses2/MemPool.h
+++ b/contrib/moses2/MemPool.h
@@ -169,86 +169,7 @@ private:
};
//////////////////////////////////////////////////////////////////////////////////////////
-template<typename T>
-class MemPoolAllocator
-{
-public:
- typedef T value_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef T& reference;
- typedef const T& const_reference;
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
-
- template<class U>
- struct rebind
- {
- typedef MemPoolAllocator<U> other;
- };
-
- MemPoolAllocator(Moses2::MemPool &pool) :
- m_pool(pool)
- {
- }
- MemPoolAllocator(const MemPoolAllocator &other) :
- m_pool(other.m_pool)
- {
- }
-
- template<class U>
- MemPoolAllocator(const MemPoolAllocator<U>& other) :
- m_pool(other.m_pool)
- {
- }
-
- size_type max_size() const
- {
- return std::numeric_limits<size_type>::max();
- }
-
- void deallocate(pointer p, size_type n)
- {
- //std::cerr << "deallocate " << p << " " << n << std::endl;
- }
-
- pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0)
- {
- //std::cerr << "allocate " << n << " " << hint << std::endl;
- pointer ret = m_pool.Allocate<T>(n);
- return ret;
- }
-
- void construct(pointer p, const_reference val)
- {
- //std::cerr << "construct " << p << " " << n << std::endl;
- new ((void *) p) T(val);
- }
-
- void destroy(pointer p)
- {
- //std::cerr << "destroy " << p << " " << n << std::endl;
- }
-
- // return address of values
- pointer address (reference value) const {
- return &value;
- }
- const_pointer address (const_reference value) const {
- return &value;
- }
- bool operator==(const MemPoolAllocator<T> &allocator) const {
- return true;
- }
-
- bool operator!=(const MemPoolAllocator<T> &allocator) const {
- return false;
- }
-
- MemPool &m_pool;
-protected:
-};
}
diff --git a/contrib/moses2/MemPoolAllocator.h b/contrib/moses2/MemPoolAllocator.h
new file mode 100644
index 000000000..6cc699893
--- /dev/null
+++ b/contrib/moses2/MemPoolAllocator.h
@@ -0,0 +1,90 @@
+#pragma once
+#include "MemPool.h"
+
+namespace Moses2
+{
+
+template<typename T>
+class MemPoolAllocator
+{
+public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ template<class U>
+ struct rebind
+ {
+ typedef MemPoolAllocator<U> other;
+ };
+
+ MemPoolAllocator(Moses2::MemPool &pool) :
+ m_pool(pool)
+ {
+ }
+ MemPoolAllocator(const MemPoolAllocator &other) :
+ m_pool(other.m_pool)
+ {
+ }
+
+ template<class U>
+ MemPoolAllocator(const MemPoolAllocator<U>& other) :
+ m_pool(other.m_pool)
+ {
+ }
+
+ size_type max_size() const
+ {
+ return std::numeric_limits<size_type>::max();
+ }
+
+ void deallocate(pointer p, size_type n)
+ {
+ //std::cerr << "deallocate " << p << " " << n << std::endl;
+ }
+
+ pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0)
+ {
+ //std::cerr << "allocate " << n << " " << hint << std::endl;
+ pointer ret = m_pool.Allocate<T>(n);
+ return ret;
+ }
+
+ void construct(pointer p, const_reference val)
+ {
+ //std::cerr << "construct " << p << " " << n << std::endl;
+ new ((void *) p) T(val);
+ }
+
+ void destroy(pointer p)
+ {
+ //std::cerr << "destroy " << p << " " << n << std::endl;
+ }
+
+ // return address of values
+ pointer address (reference value) const {
+ return &value;
+ }
+ const_pointer address (const_reference value) const {
+ return &value;
+ }
+
+ bool operator==(const MemPoolAllocator<T> &allocator) const {
+ return true;
+ }
+
+ bool operator!=(const MemPoolAllocator<T> &allocator) const {
+ return false;
+ }
+
+ MemPool &m_pool;
+protected:
+};
+
+}
+
+
diff --git a/contrib/moses2/PhraseBased/CubePruningMiniStack/Misc.h b/contrib/moses2/PhraseBased/CubePruningMiniStack/Misc.h
index f6e396f13..535ef6ada 100644
--- a/contrib/moses2/PhraseBased/CubePruningMiniStack/Misc.h
+++ b/contrib/moses2/PhraseBased/CubePruningMiniStack/Misc.h
@@ -14,6 +14,7 @@
#include "../Hypothesis.h"
#include "../../TypeDef.h"
#include "../../Vector.h"
+#include "../../MemPoolAllocator.h"
#include "Stack.h"
namespace Moses2
diff --git a/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.h b/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.h
index 65fc82c8e..0dfe9dfb2 100644
--- a/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.h
+++ b/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.h
@@ -11,6 +11,7 @@
#include "Misc.h"
#include "Stack.h"
#include "../../legacy/Range.h"
+#include "../../MemPoolAllocator.h"
namespace Moses2
{
diff --git a/contrib/moses2/PhraseBased/CubePruningMiniStack/Stack.h b/contrib/moses2/PhraseBased/CubePruningMiniStack/Stack.h
index ed7025d1b..7601f90b2 100644
--- a/contrib/moses2/PhraseBased/CubePruningMiniStack/Stack.h
+++ b/contrib/moses2/PhraseBased/CubePruningMiniStack/Stack.h
@@ -12,6 +12,7 @@
#include "../../TypeDef.h"
#include "../../Vector.h"
#include "../../MemPool.h"
+#include "../../MemPoolAllocator.h"
#include "../../Recycler.h"
#include "../../HypothesisColl.h"
#include "../../legacy/Util2.h"
diff --git a/contrib/moses2/SCFG/InputPath.cpp b/contrib/moses2/SCFG/InputPath.cpp
index f0c34bbc6..1ebbbf327 100644
--- a/contrib/moses2/SCFG/InputPath.cpp
+++ b/contrib/moses2/SCFG/InputPath.cpp
@@ -9,7 +9,7 @@
#include "TargetPhrases.h"
#include "ActiveChart.h"
#include "../TranslationModel/PhraseTable.h"
-#include "../MemPool.h"
+#include "../MemPoolAllocator.h"
using namespace std;
diff --git a/contrib/moses2/SCFG/InputPath.h b/contrib/moses2/SCFG/InputPath.h
index e135276ff..c8a7253c2 100644
--- a/contrib/moses2/SCFG/InputPath.h
+++ b/contrib/moses2/SCFG/InputPath.h
@@ -11,6 +11,7 @@
#include <list>
#include <boost/unordered_map.hpp>
#include "../InputPathBase.h"
+#include "../MemPoolAllocator.h"
#include "TargetPhrases.h"
#include "ActiveChart.h"
#include "Word.h"
diff --git a/contrib/moses2/Vector.h b/contrib/moses2/Vector.h
index 7c7a172fd..f35e71825 100644
--- a/contrib/moses2/Vector.h
+++ b/contrib/moses2/Vector.h
@@ -7,7 +7,7 @@
#pragma once
#include <cassert>
-#include "MemPool.h"
+#include "MemPoolAllocator.h"
namespace Moses2
{