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:
authorheafield <heafield@1f5c12ca-751b-0410-a591-d2e778427230>2011-09-23 02:29:56 +0400
committerheafield <heafield@1f5c12ca-751b-0410-a591-d2e778427230>2011-09-23 02:29:56 +0400
commit19879a8b1ea6533e2a0b66e9c3e67f2ccd9d49af (patch)
tree178377fd00bada17a6b6dc2c7c27f30ecc223922 /moses-cmd
parentddbfee788c092a00dbeac4c71959aa84f64d3813 (diff)
-threads all option
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4252 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses-cmd')
-rw-r--r--moses-cmd/src/Main.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/moses-cmd/src/Main.cpp b/moses-cmd/src/Main.cpp
index 69fd9c797..0a0da3341 100644
--- a/moses-cmd/src/Main.cpp
+++ b/moses-cmd/src/Main.cpp
@@ -336,25 +336,6 @@ int main(int argc, char** argv)
}
- // create threadpool, if using multi-threaded decoding
- // note: multi-threading is done on sentence-level,
- // each thread translates one sentence
- int threadcount = (params->GetParam("threads").size() > 0) ?
- Scan<size_t>(params->GetParam("threads")[0]) : 1;
-
-#ifdef WITH_THREADS
- if (threadcount < 1) {
- cerr << "Error: Need to specify a positive number of threads" << endl;
- exit(1);
- }
- ThreadPool pool(threadcount);
-#else
- if (threadcount > 1) {
- cerr << "Error: Thread count of " << threadcount << " but moses not built with thread support" << endl;
- exit(1);
- }
-#endif
-
// initialize all "global" variables, which are stored in StaticData
// note: this also loads models such as the language model, etc.
if (!StaticData::LoadDataStatic(params)) {
@@ -370,6 +351,7 @@ int main(int argc, char** argv)
// shorthand for accessing information in StaticData
const StaticData& staticData = StaticData::Instance();
+
// set up read/writing class
IOWrapper* ioWrapper = GetIODevice(staticData);
if (!ioWrapper) {
@@ -441,6 +423,10 @@ int main(int argc, char** argv)
alignmentInfoCollector.reset(new OutputCollector(ioWrapper->GetAlignmentOutputStream()));
}
+#ifdef WITH_THREADS
+ ThreadPool pool(staticData.ThreadCount());
+#endif
+
// main loop over set of input sentences
InputType* source = NULL;
size_t lineCount = 0;
@@ -457,7 +443,7 @@ int main(int argc, char** argv)
alignmentInfoCollector.get() );
// execute task
#ifdef WITH_THREADS
- pool.Submit(task);
+ pool.Submit(task);
#else
task->Run();
#endif