From e660340dfafc49f2d59a1a405b6b7b491609efd6 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 19 Jan 2017 06:28:05 +0000 Subject: [PATCH] get/set nuthreads --- Common/CommandLine.cpp | 11 +++++++++-- Common/GmshMessage.cpp | 2 ++ Common/GmshMessage.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index ba9a6e00a0..d1b536d0c4 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -630,14 +630,14 @@ void GetOptions(int argc, char *argv[]) else Msg::Fatal("Missing file name"); } - else if(!strcmp(argv[i] + 1, "nw")) { + else if(!strcmp(argv[i] + 1, "windows")) { i++; if(argv[i]) CTX::instance()->numWindows = atoi(argv[i++]); else Msg::Fatal("Missing number"); } - else if(!strcmp(argv[i] + 1, "nt")) { + else if(!strcmp(argv[i] + 1, "tiles")) { i++; if(argv[i]) CTX::instance()->numTiles = atoi(argv[i++]); @@ -996,6 +996,13 @@ void GetOptions(int argc, char *argv[]) else Msg::Fatal("Missing number"); } + else if(!strcmp(argv[i] + 1, "nt")) { + i++; + if(argv[i]) + Msg::SetNumThreads(atoi(argv[i++])); + else + Msg::Fatal("Missing number"); + } #if defined(HAVE_FLTK) else if(!strcmp(argv[i] + 1, "term")) { terminal = 1; diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index b5822d95e7..35d422fba3 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -1548,12 +1548,14 @@ void Msg::Barrier() #include <omp.h> int Msg::GetNumThreads(){ return omp_get_num_threads(); } +void Msg::SetNumThreads(int num){ printf("Setting num threads = %d", num); omp_set_num_threads(num); } int Msg::GetMaxThreads(){ return omp_get_max_threads(); } int Msg::GetThreadNum(){ return omp_get_thread_num(); } #else int Msg::GetNumThreads(){ return 1; } +void Msg::SetNumThreads(int num){ } int Msg::GetMaxThreads(){ return 1; } int Msg::GetThreadNum(){ return 0; } diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index fa992d893a..b016a93110 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -73,6 +73,7 @@ class Msg { static GmshMessage *GetCallback(); static void Barrier(); static int GetNumThreads(); + static void SetNumThreads(int num); static int GetMaxThreads(); static int GetThreadNum(); static void SetVerbosity(int val); -- GitLab