#include #include #include #include "System.h" #include "Phrase.h" #include "TranslationTask.h" #include "MemPool.h" #include "Search/Manager.h" #include "legacy/InputFileStream.h" #include "legacy/Parameter.h" #include "legacy/ThreadPool.h" #include "legacy/Timer.h" using namespace std; //extern size_t g_numHypos; istream &GetInputStream(Moses2::Parameter ¶ms) { const Moses2::PARAM_VEC *vec = params.GetParam("input-file"); if (vec && vec->size()) { Moses2::InputFileStream *stream = new Moses2::InputFileStream(vec->at(0)); return *stream; } else { return cin; } } void Temp(); int main(int argc, char** argv) { cerr << "Starting..." << endl; //Temp(); Moses2::Parameter params; params.LoadParam(argc, argv); Moses2::System system(params); istream &inStream = GetInputStream(params); cerr << "system.numThreads=" << system.numThreads << endl; Moses2::Timer timer; timer.start(); Moses2::ThreadPool pool(system.numThreads, system.cpuAffinityOffset, system.cpuAffinityOffsetIncr); long translationId = 0; string line; while (getline(inStream, line)) { boost::shared_ptr task(new Moses2::TranslationTask(system, line, translationId)); pool.Submit(task); //task->Run(); ++translationId; } pool.Stop(true); if (&inStream != &cin) { delete &inStream; } cerr << "Decoding took " << timer.get_elapsed_time() << endl; // cerr << "g_numHypos=" << g_numHypos << endl; cerr << "Finished" << endl; } //////////////////////////////////////////////////////////////////////////////////////////////// void Temp() { Moses2::MemPool pool; Moses2::MemPoolAllocator a(pool); boost::unordered_set, std::equal_to, Moses2::MemPoolAllocator > s(a); s.insert(3); s.insert(4); s.insert(3); s.erase(3); boost::pool_allocator alloc; std::vector > v(alloc); for (int i = 0; i < 1000; ++i) v.push_back(i); v.clear(); boost::singleton_pool:: purge_memory(); abort(); }