use unified macro USE_OMP and nthreads is set in setup once - not in load as clause

This commit is contained in:
dwarning 2012-06-13 18:23:12 +02:00
parent d072ab80d1
commit 9ea4897d06
15 changed files with 59 additions and 86 deletions

View File

@ -45,7 +45,7 @@ BSIM3destroy(
if(prev) FREE(prev);
}
if(oldmod) {
#ifdef USE_OMP3
#ifdef USE_OMP
/* free just once for all models */
FREE(oldmod->BSIM3InstanceArray);
#endif

View File

@ -32,10 +32,9 @@
#define DELTA_3 0.02
#define DELTA_4 0.02
#ifdef USE_OMP3
#ifdef USE_OMP
int BSIM3LoadOMP(BSIM3instance *here, CKTcircuit *ckt);
void BSIM3LoadRhsMat(GENmodel *inModel, CKTcircuit *ckt);
extern int nthreads;
#endif
@ -44,7 +43,7 @@ BSIM3load(
GENmodel *inModel,
CKTcircuit *ckt)
{
#ifdef USE_OMP3
#ifdef USE_OMP
int idx;
BSIM3model *model = (BSIM3model*)inModel;
int good = 0;
@ -52,7 +51,7 @@ CKTcircuit *ckt)
BSIM3instance **InstArray;
InstArray = model->BSIM3InstanceArray;
#pragma omp parallel for num_threads(nthreads) private(here)
#pragma omp parallel for private(here)
for (idx = 0; idx < model->BSIM3InstCount; idx++) {
here = InstArray[idx];
good = BSIM3LoadOMP(here, ckt);
@ -173,7 +172,7 @@ struct bsim3SizeDependParam *pParam;
int ByPass, Check, ChargeComputationNeeded, error;
/* double junk[50]; */
#ifdef USE_OMP3
#ifdef USE_OMP
model = here->BSIM3modPtr;
#endif
@ -182,7 +181,7 @@ ChargeComputationNeeded =
((ckt->CKTmode & (MODEAC | MODETRAN | MODEINITSMSIG)) ||
((ckt->CKTmode & MODETRANOP) && (ckt->CKTmode & MODEUIC)))
? 1 : 0;
#ifndef USE_OMP3
#ifndef USE_OMP
for (; model != NULL; model = model->BSIM3nextModel)
{ for (here = model->BSIM3instances; here != NULL;
here = here->BSIM3nextInstance)
@ -2933,7 +2932,7 @@ line900:
}
m = here->BSIM3m;
#ifdef USE_OMP3
#ifdef USE_OMP
here->BSIM3rhsG = m * ceqqg;
here->BSIM3rhsB = m * (ceqbs + ceqbd + ceqqb);
here->BSIM3rhsD = m * (ceqbd - cdreq - ceqqd);
@ -2955,7 +2954,7 @@ line900:
*/
T1 = qdef * here->BSIM3gtau;
#ifdef USE_OMP3
#ifdef USE_OMP
here->BSIM3DdPt = m * here->BSIM3drainConductance;
here->BSIM3GgPt = m * (gcggb - ggtg);
here->BSIM3SsPt = m * here->BSIM3sourceConductance;
@ -3059,14 +3058,14 @@ line900:
}
#endif
line1000: ;
#ifndef USE_OMP3
#ifndef USE_OMP
} /* End of Mosfet Instance */
} /* End of Model Instance */
#endif
return(OK);
}
#ifdef USE_OMP3
#ifdef USE_OMP
void BSIM3LoadRhsMat(GENmodel *inModel, CKTcircuit *ckt)
{
unsigned int InstCount, idx;

View File

@ -17,9 +17,8 @@
#include "ngspice/sperror.h"
#include "ngspice/suffix.h"
#ifdef USE_OMP3
#ifdef USE_OMP
#include "ngspice/cpextern.h"
int nthreads;
#endif
#define MAX_EXP 5.834617425e14
@ -46,7 +45,7 @@ CKTnode *tmp;
CKTnode *tmpNode;
IFuid tmpName;
#ifdef USE_OMP3
#ifdef USE_OMP
unsigned int idx, InstCount;
BSIM3instance **InstArray;
int nthreads;
@ -1015,7 +1014,7 @@ if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
}
}
#ifdef USE_OMP3
#ifdef USE_OMP
if (!cp_getvar("num_threads", CP_NUM, &nthreads))
nthreads = 2;

View File

@ -17,10 +17,6 @@ File: bsim3def.h
#include "ngspice/noisedef.h"
#ifdef USE_OMP
#define USE_OMP3
#endif
#ifdef USE_OMP3
#include <omp.h>
#endif
@ -172,7 +168,7 @@ typedef struct sBSIM3instance
double *BSIM3SPqPtr;
double *BSIM3BqPtr;
#ifdef USE_OMP3
#ifdef USE_OMP
/* per instance storage of results, to update matrix at a later stge */
double BSIM3rhsG;
double BSIM3rhsB;
@ -847,7 +843,7 @@ typedef struct sBSIM3model
struct bsim3SizeDependParam *pSizeDependParamKnot;
#ifdef USE_OMP3
#ifdef USE_OMP
int BSIM3InstCount;
struct sBSIM3instance **BSIM3InstanceArray;
#endif

View File

@ -25,11 +25,6 @@ File: b4soidef.h
#include "ngspice/noisedef.h"
#ifdef USE_OMP
#define USE_OMP4SOI
#endif
#ifdef USE_OMP4SOI
#include <omp.h>
#endif
@ -545,7 +540,7 @@ typedef struct sB4SOIinstance
double *B4SOIQjsPtr;
double *B4SOIQjdPtr;
#ifdef USE_OMP4SOI
#ifdef USE_OMP
/* per instance storage of results, to update matrix at a later stge */
int B4SOINode_sh;
double B4SOINode_1;
@ -2119,7 +2114,7 @@ typedef struct sB4SOImodel
struct b4soiSizeDependParam *pSizeDependParamKnot;
#ifdef USE_OMP4SOI
#ifdef USE_OMP
int B4SOIInstCount;
struct sB4SOIinstance **B4SOIInstanceArray;
#endif

View File

@ -63,10 +63,9 @@
#define FLOG(A) fabs(A) + 1e-14
#ifdef USE_OMP4SOI
#ifdef USE_OMP
int B4SOILoadOMP(B4SOIinstance *here, CKTcircuit *ckt);
void B4SOILoadRhsMat(GENmodel *inModel, CKTcircuit *ckt);
extern int nthreads;
#endif
/* B4SOIlimit(vnew,vold)
@ -107,7 +106,7 @@ B4SOIload(
GENmodel *inModel,
CKTcircuit *ckt)
{
#ifdef USE_OMP4SOI
#ifdef USE_OMP
int idx;
B4SOImodel *model = (B4SOImodel*)inModel;
int good = 0;
@ -115,7 +114,7 @@ B4SOIload(
B4SOIinstance **InstArray;
InstArray = model->B4SOIInstanceArray;
#pragma omp parallel for num_threads(nthreads) private(here)
#pragma omp parallel for private(here)
for (idx = 0; idx < model->B4SOIInstCount; idx++) {
here = InstArray[idx];
good = B4SOILoadOMP(here, ckt);
@ -488,11 +487,11 @@ int B4SOILoadOMP(B4SOIinstance *here, CKTcircuit *ckt) {
double eggbcp2, eggdep, agb1, bgb1, agb2, bgb2, agbc2n, agbc2p, bgbc2n, bgbc2p, Vtm00; /* v4.3.1 bugfix for mtrlMod=1 -Tanvir */
double m;
#ifdef USE_OMP4SOI
#ifdef USE_OMP
model = here->B4SOImodPtr;
#endif
#ifndef USE_OMP4SOI
#ifndef USE_OMP
for (; model != NULL; model = model->B4SOInextModel)
{ for (here = model->B4SOIinstances; here != NULL;
here = here->B4SOInextInstance)
@ -10303,7 +10302,7 @@ line900:
/* v3.1 */
#ifndef USE_OMP4SOI
#ifndef USE_OMP
/* v3.1 added ceqgcrg for RF */
(*(ckt->CKTrhs + here->B4SOIgNode) -= m * ((ceqgate + ceqqg)
+ Igtoteq - ceqgcrg));
@ -10451,7 +10450,7 @@ line900:
/* v3.1 added for RF */
geltd = here->B4SOIgrgeltd;
#ifndef USE_OMP4SOI
#ifndef USE_OMP
if (here->B4SOIrgateMod == 1)
{
*(here->B4SOIGEgePtr) += m * geltd;
@ -10944,7 +10943,7 @@ line900:
line1000: ;
#ifndef USE_OMP4SOI
#ifndef USE_OMP
} /* End of Mosfet Instance */
} /* End of Model Instance */
#endif
@ -10953,7 +10952,7 @@ line1000: ;
}
#ifdef USE_OMP4SOI
#ifdef USE_OMP
/* OpenMP parallelization:
Update of right hand side and matrix values from instance temporary storage.

View File

@ -25,9 +25,8 @@
#include "ngspice/sperror.h"
#include "ngspice/suffix.h"
#ifdef USE_OMP4SOI
#ifdef USE_OMP
#include "ngspice/cpextern.h"
int nthreads;
#endif
#define SMOOTHFACTOR 0.1
@ -58,7 +57,7 @@ double Cboxt;
/* v3.2 */
double Vbs0t, Qsi;
#ifdef USE_OMP4SOI
#ifdef USE_OMP
unsigned int idx, InstCount;
B4SOIinstance **InstArray;
int nthreads;
@ -2698,7 +2697,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\
}
}
#ifdef USE_OMP4SOI
#ifdef USE_OMP
if (!cp_getvar("num_threads", CP_NUM, &nthreads))
nthreads = 2;

View File

@ -47,7 +47,7 @@ BSIM4destroy(
if(prev) FREE(prev);
}
if(oldmod) {
#ifdef USE_OMP4
#ifdef USE_OMP
/* free just once for all models */
FREE(oldmod->BSIM4InstanceArray);
#endif

View File

@ -59,10 +59,9 @@
} \
}
#ifdef USE_OMP4
#ifdef USE_OMP
int BSIM4LoadOMP(BSIM4instance *here, CKTcircuit *ckt);
void BSIM4LoadRhsMat(GENmodel *inModel, CKTcircuit *ckt);
extern int nthreads;
#endif
int BSIM4polyDepletion(double phi, double ngate,double epsgate, double coxe, double Vgs, double *Vgs_eff, double *dVgs_eff_dVg);
@ -72,7 +71,7 @@ BSIM4load(
GENmodel *inModel,
CKTcircuit *ckt)
{
#ifdef USE_OMP4
#ifdef USE_OMP
int idx;
BSIM4model *model = (BSIM4model*)inModel;
int good = 0;
@ -80,7 +79,7 @@ CKTcircuit *ckt)
BSIM4instance **InstArray;
InstArray = model->BSIM4InstanceArray;
#pragma omp parallel for num_threads(nthreads) private(here)
#pragma omp parallel for private(here)
for (idx = 0; idx < model->BSIM4InstCount; idx++) {
here = InstArray[idx];
good = BSIM4LoadOMP(here, ckt);
@ -241,7 +240,7 @@ int ByPass, ChargeComputationNeeded, error, Check, Check1, Check2;
double m;
#ifdef USE_OMP4
#ifdef USE_OMP
model = here->BSIM4modPtr;
#endif
@ -251,7 +250,7 @@ ChargeComputationNeeded =
((ckt->CKTmode & MODETRANOP) && (ckt->CKTmode & MODEUIC)))
? 1 : 0;
#ifndef USE_OMP4
#ifndef USE_OMP
for (; model != NULL; model = model->BSIM4nextModel)
{ for (here = model->BSIM4instances; here != NULL;
here = here->BSIM4nextInstance)
@ -4906,7 +4905,7 @@ line900:
m = here->BSIM4m;
#ifdef USE_OMP4
#ifdef USE_OMP
here->BSIM4rhsdPrime = m * (ceqjd - ceqbd + ceqgdtot
- ceqdrn - ceqqd + Idtoteq);
here->BSIM4rhsgPrime = m * (ceqqg - ceqgcrg + Igtoteq);
@ -4992,7 +4991,7 @@ line900:
geltd = here->BSIM4grgeltd;
T1 = qdef * here->BSIM4gtau;
#ifdef USE_OMP4
#ifdef USE_OMP
if (here->BSIM4rgateMod == 1)
{ here->BSIM4_1 = m * geltd;
here->BSIM4_2 = m * geltd;
@ -5314,7 +5313,7 @@ line900:
line1000: ;
#ifndef USE_OMP4
#ifndef USE_OMP
} /* End of MOSFET Instance */
} /* End of Model Instance */
#endif
@ -5356,7 +5355,7 @@ int BSIM4polyDepletion(
return(0);
}
#ifdef USE_OMP4
#ifdef USE_OMP
void BSIM4LoadRhsMat(GENmodel *inModel, CKTcircuit *ckt)
{
unsigned int InstCount, idx;

View File

@ -31,9 +31,8 @@
#include "ngspice/sperror.h"
#include "ngspice/suffix.h"
#ifdef USE_OMP4
#ifdef USE_OMP
#include "ngspice/cpextern.h"
int nthreads;
#endif
#define MAX_EXP 5.834617425e14
@ -59,7 +58,7 @@ int noiseAnalGiven = 0, createNode; /* Criteria for new node creation */
double Rtot, DMCGeff, DMCIeff, DMDGeff;
JOB *job;
#ifdef USE_OMP4
#ifdef USE_OMP
unsigned int idx, InstCount;
BSIM4instance **InstArray;
int nthreads;
@ -2547,7 +2546,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\
}
}
#ifdef USE_OMP4
#ifdef USE_OMP
if (!cp_getvar("num_threads", CP_NUM, &nthreads))
nthreads = 2;

View File

@ -29,11 +29,6 @@ Modified by Wenwei Yang, 07/31/2008.
#include "ngspice/noisedef.h"
#ifdef USE_OMP
#define USE_OMP4
#endif
#ifdef USE_OMP4
#include <omp.h>
#endif
@ -398,7 +393,7 @@ typedef struct sBSIM4instance
double *BSIM4GPqPtr;
double *BSIM4SPqPtr;
#ifdef USE_OMP4
#ifdef USE_OMP
/* per instance storage of results, to update matrix at a later stge */
double BSIM4rhsdPrime;
double BSIM4rhsgPrime;
@ -1775,7 +1770,7 @@ typedef struct sBSIM4model
struct bsim4SizeDependParam *pSizeDependParamKnot;
#ifdef USE_OMP4
#ifdef USE_OMP
int BSIM4InstCount;
struct sBSIM4instance **BSIM4InstanceArray;
#endif

View File

@ -49,7 +49,7 @@ BSIM4v6destroy(
if(prev) FREE(prev);
}
if(oldmod) {
#ifdef USE_OMP4
#ifdef USE_OMP
/* free just once for all models */
FREE(oldmod->BSIM4v6InstanceArray);
#endif

View File

@ -61,10 +61,9 @@
}
#ifdef USE_OMP4
#ifdef USE_OMP
int BSIM4v6LoadOMP(BSIM4v6instance *here, CKTcircuit *ckt);
void BSIM4v6LoadRhsMat(GENmodel *inModel, CKTcircuit *ckt);
extern int nthreads;
#endif
int BSIM4v6polyDepletion(double phi, double ngate,double epsgate, double coxe, double Vgs, double *Vgs_eff, double *dVgs_eff_dVg);
@ -74,7 +73,7 @@ BSIM4v6load(
GENmodel *inModel,
CKTcircuit *ckt)
{
#ifdef USE_OMP4
#ifdef USE_OMP
int idx;
BSIM4v6model *model = (BSIM4v6model*)inModel;
int good = 0;
@ -82,7 +81,7 @@ CKTcircuit *ckt)
BSIM4v6instance **InstArray;
InstArray = model->BSIM4v6InstanceArray;
#pragma omp parallel for num_threads(nthreads) private(here)
#pragma omp parallel for private(here)
for (idx = 0; idx < model->BSIM4v6InstCount; idx++) {
here = InstArray[idx];
good = BSIM4v6LoadOMP(here, ckt);
@ -241,7 +240,7 @@ int ByPass, ChargeComputationNeeded, error, Check, Check1, Check2;
double m;
#ifdef USE_OMP4
#ifdef USE_OMP
model = here->BSIM4v6modPtr;
#endif
@ -251,7 +250,7 @@ ChargeComputationNeeded =
((ckt->CKTmode & MODETRANOP) && (ckt->CKTmode & MODEUIC)))
? 1 : 0;
#ifndef USE_OMP4
#ifndef USE_OMP
for (; model != NULL; model = model->BSIM4v6nextModel)
{ for (here = model->BSIM4v6instances; here != NULL;
here = here->BSIM4v6nextInstance)
@ -4751,7 +4750,7 @@ line900:
m = here->BSIM4v6m;
#ifdef USE_OMP4
#ifdef USE_OMP
here->BSIM4v6rhsdPrime = m * (ceqjd - ceqbd + ceqgdtot
- ceqdrn - ceqqd + Idtoteq);
here->BSIM4v6rhsgPrime = m * (ceqqg - ceqgcrg + Igtoteq);
@ -4837,7 +4836,7 @@ line900:
geltd = here->BSIM4v6grgeltd;
T1 = qdef * here->BSIM4v6gtau;
#ifdef USE_OMP4
#ifdef USE_OMP
if (here->BSIM4v6rgateMod == 1)
{ here->BSIM4v6_1 = m * geltd;
here->BSIM4v6_2 = m * geltd;
@ -5159,7 +5158,7 @@ line900:
line1000: ;
#ifndef USE_OMP4
#ifndef USE_OMP
} /* End of MOSFET Instance */
} /* End of Model Instance */
#endif
@ -5201,7 +5200,7 @@ int BSIM4v6polyDepletion(
return(0);
}
#ifdef USE_OMP4
#ifdef USE_OMP
void BSIM4v6LoadRhsMat(GENmodel *inModel, CKTcircuit *ckt)
{
unsigned int InstCount, idx;

View File

@ -31,9 +31,8 @@
#include "ngspice/sperror.h"
#include "ngspice/suffix.h"
#ifdef USE_OMP4
#ifdef USE_OMP
#include "ngspice/cpextern.h"
int nthreads;
#endif
#define MAX_EXP 5.834617425e14
@ -60,7 +59,7 @@ double Rtot, DMCGeff, DMCIeff, DMDGeff;
JOB *job;
#ifdef USE_OMP4
#ifdef USE_OMP
unsigned int idx, InstCount;
BSIM4v6instance **InstArray;
int nthreads;
@ -2395,7 +2394,7 @@ if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
}
} /* end of loop through all the BSIM4v6 device models */
#ifdef USE_OMP4
#ifdef USE_OMP
if (!cp_getvar("num_threads", CP_NUM, &nthreads))
nthreads = 2;

View File

@ -28,11 +28,6 @@ Modified by Wenwei Yang, 07/31/2008.
#include "ngspice/noisedef.h"
#ifdef USE_OMP
#define USE_OMP4
#endif
#ifdef USE_OMP4
#include <omp.h>
#endif
@ -395,7 +390,7 @@ typedef struct sBSIM4v6instance
double *BSIM4v6GPqPtr;
double *BSIM4v6SPqPtr;
#ifdef USE_OMP4
#ifdef USE_OMP
/* per instance storage of results, to update matrix at a later stge */
double BSIM4v6rhsdPrime;
double BSIM4v6rhsgPrime;
@ -1704,7 +1699,7 @@ typedef struct sBSIM4v6model
struct bsim4v6SizeDependParam *pSizeDependParamKnot;
#ifdef USE_OMP4
#ifdef USE_OMP
int BSIM4v6InstCount;
struct sBSIM4v6instance **BSIM4v6InstanceArray;
#endif