From 9648238ed75e1156988faae7ce2f46e2c5269b58 Mon Sep 17 00:00:00 2001 From: dwarning Date: Fri, 15 Jun 2012 23:14:08 +0200 Subject: [PATCH] call omp_set_num_threads once in central place instead in model routines --- src/spicelib/analysis/cktsetup.c | 17 ++++++++++++++++- src/spicelib/devices/bsim3/b3set.c | 13 ------------- src/spicelib/devices/bsim3/bsim3def.h | 4 ---- src/spicelib/devices/bsim3soi/b4soidef.h | 4 ---- src/spicelib/devices/bsim3soi/b4soiset.c | 13 ------------- src/spicelib/devices/bsim4/b4set.c | 9 --------- src/spicelib/devices/bsim4/bsim4def.h | 4 ---- src/spicelib/devices/bsim4v6/b4v6set.c | 9 --------- src/spicelib/devices/bsim4v6/bsim4v6def.h | 4 ---- 9 files changed, 16 insertions(+), 61 deletions(-) diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index f24c216cb..3ac5186da 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -15,7 +15,11 @@ Author: 1985 Thomas L. Quarles #include "ngspice/devdefs.h" #include "ngspice/sperror.h" - +#ifdef USE_OMP +#include +#include "ngspice/cpextern.h" +int nthreads; +#endif #define CKALLOC(var,size,type) \ if(size && ((var = TMALLOC(type, size)) == NULL)){\ @@ -58,6 +62,17 @@ CKTsetup(CKTcircuit *ckt) matrix = ckt->CKTmatrix; +#ifdef USE_OMP + if (!cp_getvar("num_threads", CP_NUM, &nthreads)) + nthreads = 2; + + omp_set_num_threads(nthreads); + if (nthreads == 1) + printf("OpenMP: %d thread is requested in ngspice\n", nthreads); + else + printf("OpenMP: %d threads are requested in ngspice\n", nthreads); +#endif + for (i=0;iptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ } } #ifdef USE_OMP - if (!cp_getvar("num_threads", CP_NUM, &nthreads)) - nthreads = 2; - - omp_set_num_threads(nthreads); - if (nthreads == 1) - printf("OpenMP: %d thread is requested in BSIM3\n", nthreads); - else - printf("OpenMP: %d threads are requested in BSIM3\n", nthreads); InstCount = 0; model = (BSIM3model*)inModel; /* loop through all the BSIM3 device models diff --git a/src/spicelib/devices/bsim3/bsim3def.h b/src/spicelib/devices/bsim3/bsim3def.h index 4ae8a50c4..17f1a825b 100644 --- a/src/spicelib/devices/bsim3/bsim3def.h +++ b/src/spicelib/devices/bsim3/bsim3def.h @@ -16,10 +16,6 @@ File: bsim3def.h #include "ngspice/complex.h" #include "ngspice/noisedef.h" -#ifdef USE_OMP -#include -#endif - typedef struct sBSIM3instance { struct sBSIM3model *BSIM3modPtr; diff --git a/src/spicelib/devices/bsim3soi/b4soidef.h b/src/spicelib/devices/bsim3soi/b4soidef.h index 431693af3..3433636c9 100644 --- a/src/spicelib/devices/bsim3soi/b4soidef.h +++ b/src/spicelib/devices/bsim3soi/b4soidef.h @@ -24,10 +24,6 @@ File: b4soidef.h #include "ngspice/complex.h" #include "ngspice/noisedef.h" -#ifdef USE_OMP -#include -#endif - typedef struct sB4SOIinstance { struct sB4SOImodel *B4SOImodPtr; diff --git a/src/spicelib/devices/bsim3soi/b4soiset.c b/src/spicelib/devices/bsim3soi/b4soiset.c index d1ac685d3..eb1e21db4 100644 --- a/src/spicelib/devices/bsim3soi/b4soiset.c +++ b/src/spicelib/devices/bsim3soi/b4soiset.c @@ -25,10 +25,6 @@ #include "ngspice/sperror.h" #include "ngspice/suffix.h" -#ifdef USE_OMP -#include "ngspice/cpextern.h" -#endif - #define SMOOTHFACTOR 0.1 #define EPSOX 3.453133e-11 #define EPSSI 1.03594e-10 @@ -60,7 +56,6 @@ double Vbs0t, Qsi; #ifdef USE_OMP unsigned int idx, InstCount; B4SOIinstance **InstArray; -int nthreads; #endif /* loop through all the B4SOI device models */ @@ -2698,14 +2693,6 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ } #ifdef USE_OMP - if (!cp_getvar("num_threads", CP_NUM, &nthreads)) - nthreads = 2; - - omp_set_num_threads(nthreads); - if (nthreads == 1) - printf("OpenMP: %d thread is requested in B4SOI\n", nthreads); - else - printf("OpenMP: %d threads are requested in B4SOI\n", nthreads); InstCount = 0; model = (B4SOImodel*)inModel; /* loop through all the B4SOI device models diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index 0314e399a..2a18d59df 100644 --- a/src/spicelib/devices/bsim4/b4set.c +++ b/src/spicelib/devices/bsim4/b4set.c @@ -61,7 +61,6 @@ JOB *job; #ifdef USE_OMP unsigned int idx, InstCount; BSIM4instance **InstArray; -int nthreads; #endif /* Search for a noise analysis request */ @@ -2547,14 +2546,6 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ } #ifdef USE_OMP - if (!cp_getvar("num_threads", CP_NUM, &nthreads)) - nthreads = 2; - - omp_set_num_threads(nthreads); - if (nthreads == 1) - printf("OpenMP: %d thread is requested in BSIM4\n", nthreads); - else - printf("OpenMP: %d threads are requested in BSIM4\n", nthreads); InstCount = 0; model = (BSIM4model*)inModel; /* loop through all the BSIM4 device models diff --git a/src/spicelib/devices/bsim4/bsim4def.h b/src/spicelib/devices/bsim4/bsim4def.h index 7a779aced..3e36a0e74 100644 --- a/src/spicelib/devices/bsim4/bsim4def.h +++ b/src/spicelib/devices/bsim4/bsim4def.h @@ -28,10 +28,6 @@ Modified by Wenwei Yang, 07/31/2008. #include "ngspice/complex.h" #include "ngspice/noisedef.h" -#ifdef USE_OMP -#include -#endif - typedef struct sBSIM4instance { struct sBSIM4model *BSIM4modPtr; diff --git a/src/spicelib/devices/bsim4v6/b4v6set.c b/src/spicelib/devices/bsim4v6/b4v6set.c index 20a245ee3..acb5cdc61 100644 --- a/src/spicelib/devices/bsim4v6/b4v6set.c +++ b/src/spicelib/devices/bsim4v6/b4v6set.c @@ -62,7 +62,6 @@ JOB *job; #ifdef USE_OMP unsigned int idx, InstCount; BSIM4v6instance **InstArray; -int nthreads; #endif /* Search for a noise analysis request */ @@ -2395,14 +2394,6 @@ if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ } /* end of loop through all the BSIM4v6 device models */ #ifdef USE_OMP - if (!cp_getvar("num_threads", CP_NUM, &nthreads)) - nthreads = 2; - - omp_set_num_threads(nthreads); - if (nthreads == 1) - printf("OpenMP: %d thread is requested in BSIM4v6\n", nthreads); - else - printf("OpenMP: %d threads are requested in BSIM4v6\n", nthreads); InstCount = 0; model = (BSIM4v6model*)inModel; /* loop through all the BSIM4v6 device models diff --git a/src/spicelib/devices/bsim4v6/bsim4v6def.h b/src/spicelib/devices/bsim4v6/bsim4v6def.h index 67c4392ef..7d84e24dc 100644 --- a/src/spicelib/devices/bsim4v6/bsim4v6def.h +++ b/src/spicelib/devices/bsim4v6/bsim4v6def.h @@ -27,10 +27,6 @@ Modified by Wenwei Yang, 07/31/2008. #include "ngspice/complex.h" #include "ngspice/noisedef.h" -#ifdef USE_OMP -#include -#endif - typedef struct sBSIM4v6instance { struct sBSIM4v6model *BSIM4v6modPtr;