Skip to content

Commit

Permalink
thread num argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ruoshui1126 committed Oct 22, 2013
1 parent d265cc3 commit a05b554
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/multi_cws_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void multithreaded_segment( void * args) {
}

int main(int argc, char ** argv) {
if (argc < 1 || (0 == strcmp(argv[1], "-h"))) {
std::cerr << "Example: ./multi_cws_cmdline [model path] [lexicon file]" << std::endl;
if (argc < 2 || (0 == strcmp(argv[1], "-h"))) {
std::cerr << "Example: ./multi_cws_cmdline [model path] [lexicon file]=NULL threadnum" << std::endl;
std::cerr << std::endl;
std::cerr << "This program recieve input word sequence from stdin." << std::endl;
std::cerr << "One sentence per line." << std::endl;
Expand All @@ -108,8 +108,10 @@ int main(int argc, char ** argv) {
if (!engine) {
return -1;
}

int num_threads = thread::hardware_concurrency();
int num_threads=atoi(argv[3]);
if(num_threads<0||num_threads>thread::hardware_concurrency()){
num_threads = thread::hardware_concurrency();
}
std::cerr << "TRACE: Model is loaded" << std::endl;
std::cerr << "TRACE: Running " << num_threads << " thread(s)" << std::endl;

Expand Down

0 comments on commit a05b554

Please sign in to comment.