From 088a13e59f41e759623dbe2322517178f49f518a Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 6 Nov 2016 19:27:56 +0100 Subject: [PATCH] fix omp --- src/spicelib/devices/bsim3/b3dest.c | 10 ++--- src/spicelib/devices/bsim3/b3set.c | 46 +++++++--------------- src/spicelib/devices/bsim3v32/b3v32dest.c | 8 ++-- src/spicelib/devices/bsim3v32/b3v32set.c | 48 ++++++++--------------- src/spicelib/devices/bsim4/b4dest.c | 8 ++-- src/spicelib/devices/bsim4/b4set.c | 48 ++++++++--------------- src/spicelib/devices/bsim4v5/b4v5dest.c | 8 ++-- src/spicelib/devices/bsim4v5/b4v5set.c | 46 +++++++--------------- src/spicelib/devices/bsim4v6/b4v6dest.c | 8 ++-- src/spicelib/devices/bsim4v6/b4v6set.c | 48 ++++++++--------------- src/spicelib/devices/bsim4v7/b4v7dest.c | 8 ++-- src/spicelib/devices/bsim4v7/b4v7set.c | 48 ++++++++--------------- src/spicelib/devices/bsimsoi/b4soidest.c | 3 ++ src/spicelib/devices/bsimsoi/b4soiset.c | 48 ++++++++--------------- src/spicelib/devices/hisim2/hsm2dest.c | 8 ++-- src/spicelib/devices/hisim2/hsm2set.c | 46 +++++++--------------- 16 files changed, 152 insertions(+), 287 deletions(-) diff --git a/src/spicelib/devices/bsim3/b3dest.c b/src/spicelib/devices/bsim3/b3dest.c index 27af1ba3b..c40be1abe 100644 --- a/src/spicelib/devices/bsim3/b3dest.c +++ b/src/spicelib/devices/bsim3/b3dest.c @@ -18,11 +18,6 @@ BSIM3destroy(GENmodel **inModel) { BSIM3model *mod = *(BSIM3model**) inModel; - #ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM3InstanceArray); - #endif - while (mod) { BSIM3model *next_mod = mod->BSIM3nextModel; BSIM3instance *inst = mod->BSIM3instances; @@ -42,6 +37,11 @@ BSIM3destroy(GENmodel **inModel) inst = next_inst; } +#ifdef USE_OMP + /* free just once for all models */ + FREE(mod->BSIM3InstanceArray); +#endif + /* mod->BSIM3modName to be freed in INPtabEnd() */ FREE(mod->BSIM3version); FREE(mod); diff --git a/src/spicelib/devices/bsim3/b3set.c b/src/spicelib/devices/bsim3/b3set.c index 33cb88f98..9963b2f6a 100644 --- a/src/spicelib/devices/bsim3/b3set.c +++ b/src/spicelib/devices/bsim3/b3set.c @@ -41,12 +41,6 @@ CKTnode *tmp; CKTnode *tmpNode; IFuid tmpName; -#ifdef USE_OMP -int idx, InstCount; -BSIM3instance **InstArray; -#endif - - /* loop through all the BSIM3 device models */ for( ; model != NULL; model = model->BSIM3nextModel ) { @@ -1085,34 +1079,24 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ } } #ifdef USE_OMP - InstCount = 0; - model = (BSIM3model*)inModel; - /* loop through all the BSIM3 device models - to count the number of instances */ - for( ; model != NULL; model = model->BSIM3nextModel ) + for (model = (BSIM3model*)inModel; model; model = model->BSIM3nextModel ) { - /* loop through all the instances of the model */ - for (here = model->BSIM3instances; here != NULL ; - here=here->BSIM3nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(BSIM3instance*, InstCount); - model = (BSIM3model*)inModel; - idx = 0; - for( ; model != NULL; model = model->BSIM3nextModel ) - { - /* loop through all the instances of the model */ - for (here = model->BSIM3instances; here != NULL ; - here=here->BSIM3nextInstance) - { - InstArray[idx] = here; + BSIM3instance **InstArray; + int idx; + + idx = 0; + for (here = model->BSIM3instances; here; here = here->BSIM3nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->BSIM3InstCount = InstCount; + + model->BSIM3InstCount = idx; + + InstArray = TMALLOC(BSIM3instance*, idx); + + idx = 0; + for (here = model->BSIM3instances; here; here = here->BSIM3nextInstance) + InstArray[idx++] = here; + model->BSIM3InstanceArray = InstArray; } diff --git a/src/spicelib/devices/bsim3v32/b3v32dest.c b/src/spicelib/devices/bsim3v32/b3v32dest.c index b20736ffc..eb8b1480a 100644 --- a/src/spicelib/devices/bsim3v32/b3v32dest.c +++ b/src/spicelib/devices/bsim3v32/b3v32dest.c @@ -19,11 +19,6 @@ BSIM3v32destroy (GENmodel **inModel) { BSIM3v32model *mod = *(BSIM3v32model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM3v32InstanceArray); -#endif - while (mod) { BSIM3v32model *next_mod = mod->BSIM3v32nextModel; BSIM3v32instance *inst = mod->BSIM3v32instances; @@ -40,6 +35,9 @@ BSIM3v32destroy (GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->BSIM3v32InstanceArray); +#endif FREE(mod->BSIM3v32version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim3v32/b3v32set.c b/src/spicelib/devices/bsim3v32/b3v32set.c index 991cb01ed..58d030044 100644 --- a/src/spicelib/devices/bsim3v32/b3v32set.c +++ b/src/spicelib/devices/bsim3v32/b3v32set.c @@ -38,11 +38,6 @@ CKTnode *tmp; CKTnode *tmpNode; IFuid tmpName; -#ifdef USE_OMP -int idx, InstCount; -BSIM3v32instance **InstArray; -#endif - /* loop through all the BSIM3v32 device models */ for( ; model != NULL; model = model->BSIM3v32nextModel ) { @@ -1096,35 +1091,26 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ } } -#ifdef USE_OMP - InstCount = 0; - model = (BSIM3v32model*)inModel; - /* loop through all the BSIM3 device models - to count the number of instances */ - for (; model != NULL; model = model->BSIM3v32nextModel) +#ifdef USE_OMP + + for (model = (BSIM3v32model*)inModel; model; model = model->BSIM3v32nextModel) { - /* loop through all the instances of the model */ - for (here = model->BSIM3v32instances; here != NULL; - here = here->BSIM3v32nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(BSIM3v32instance*, InstCount); - model = (BSIM3v32model*)inModel; - idx = 0; - for (; model != NULL; model = model->BSIM3v32nextModel) - { - /* loop through all the instances of the model */ - for (here = model->BSIM3v32instances; here != NULL; - here = here->BSIM3v32nextInstance) - { - InstArray[idx] = here; + BSIM3v32instance **InstArray; + int idx; + + idx = 0; + for (here = model->BSIM3v32instances; here; here = here->BSIM3v32nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->BSIM3v32InstCount = InstCount; + + model->BSIM3v32InstCount = idx; + + InstArray = TMALLOC(BSIM3v32instance*, idx); + + idx = 0; + for (here = model->BSIM3v32instances; here; here = here->BSIM3v32nextInstance) + InstArray[idx++] = here; + model->BSIM3v32InstanceArray = InstArray; } diff --git a/src/spicelib/devices/bsim4/b4dest.c b/src/spicelib/devices/bsim4/b4dest.c index ca8fab3fa..3f288c749 100644 --- a/src/spicelib/devices/bsim4/b4dest.c +++ b/src/spicelib/devices/bsim4/b4dest.c @@ -20,11 +20,6 @@ BSIM4destroy(GENmodel **inModel) { BSIM4model *mod = *(BSIM4model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4InstanceArray); -#endif - while (mod) { BSIM4model *next_mod = mod->BSIM4nextModel; BSIM4instance *inst = mod->BSIM4instances; @@ -41,6 +36,9 @@ BSIM4destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->BSIM4InstanceArray); +#endif FREE(mod->BSIM4version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index fa445937d..1bfb4cdbd 100644 --- a/src/spicelib/devices/bsim4/b4set.c +++ b/src/spicelib/devices/bsim4/b4set.c @@ -60,11 +60,6 @@ int noiseAnalGiven = 0, createNode; /* Criteria for new node creation */ double Rtot, DMCGeff, DMCIeff, DMDGeff; JOB *job; -#ifdef USE_OMP -int idx, InstCount; -BSIM4instance **InstArray; -#endif - /* Search for a noise analysis request */ for (job = ((TSKtask *)ft_curckt->ci_curTask)->jobs;job;job = job->JOBnextJob) { if(strcmp(job->JOBname,"Noise Analysis")==0) { @@ -2657,35 +2652,24 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL } #ifdef USE_OMP - InstCount = 0; - model = (BSIM4model*)inModel; - /* loop through all the BSIM4 device models - to count the number of instances */ - - for( ; model != NULL; model = model->BSIM4nextModel ) + for (model = (BSIM4model*)inModel; model; model = model->BSIM4nextModel) { - /* loop through all the instances of the model */ - for (here = model->BSIM4instances; here != NULL ; - here=here->BSIM4nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(BSIM4instance*, InstCount); - model = (BSIM4model*)inModel; - idx = 0; - for( ; model != NULL; model = model->BSIM4nextModel ) - { - /* loop through all the instances of the model */ - for (here = model->BSIM4instances; here != NULL ; - here=here->BSIM4nextInstance) - { - InstArray[idx] = here; + BSIM4instance **InstArray; + int idx; + + idx = 0; + for (here = model->BSIM4instances; here; here = here->BSIM4nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->BSIM4InstCount = InstCount; - model->BSIM4InstanceArray = InstArray; + + model->BSIM4InstCount = idx; + + InstArray = TMALLOC(BSIM4instance*, idx); + + idx = 0; + for (here = model->BSIM4instances; here; here = here->BSIM4nextInstance) + InstArray[idx++] = here; + + model->BSIM4InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4v5/b4v5dest.c b/src/spicelib/devices/bsim4v5/b4v5dest.c index 876062d46..00911df15 100644 --- a/src/spicelib/devices/bsim4v5/b4v5dest.c +++ b/src/spicelib/devices/bsim4v5/b4v5dest.c @@ -18,11 +18,6 @@ BSIM4v5destroy(GENmodel **inModel) { BSIM4v5model *mod = *(BSIM4v5model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4v5InstanceArray); -#endif - while (mod) { BSIM4v5model *next_mod = mod->BSIM4v5nextModel; BSIM4v5instance *inst = mod->BSIM4v5instances; @@ -39,6 +34,9 @@ BSIM4v5destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->BSIM4v5InstanceArray); +#endif FREE(mod->BSIM4v5version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim4v5/b4v5set.c b/src/spicelib/devices/bsim4v5/b4v5set.c index a803aa278..903a08749 100644 --- a/src/spicelib/devices/bsim4v5/b4v5set.c +++ b/src/spicelib/devices/bsim4v5/b4v5set.c @@ -52,11 +52,6 @@ int noiseAnalGiven = 0, createNode; /* Criteria for new node creation */ double Rtot, DMCGeff, DMCIeff, DMDGeff; JOB *job; -#ifdef USE_OMP -int idx, InstCount; -BSIM4v5instance **InstArray; -#endif - /* Search for a noise analysis request */ for (job = ft_curckt->ci_curTask->jobs; job; job = job->JOBnextJob) { if(strcmp(job->JOBname,"Noise Analysis")==0) { @@ -2083,34 +2078,23 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ } #ifdef USE_OMP - InstCount = 0; - model = (BSIM4v5model*)inModel; - /* loop through all the BSIM4v6 device models - to count the number of instances */ + for (model = (BSIM4v5model*)inModel; model; model = model->BSIM4v5nextModel) + { + BSIM4v5instance **InstArray; + int idx; - for (; model != NULL; model = model->BSIM4v5nextModel) - { - /* loop through all the instances of the model */ - for (here = model->BSIM4v5instances; here != NULL; - here = here->BSIM4v5nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(BSIM4v5instance*, InstCount); - model = (BSIM4v5model*)inModel; - idx = 0; - for (; model != NULL; model = model->BSIM4v5nextModel) - { - /* loop through all the instances of the model */ - for (here = model->BSIM4v5instances; here != NULL; - here = here->BSIM4v5nextInstance) - { - InstArray[idx] = here; + idx = 0; + for (here = model->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->BSIM4v5InstCount = InstCount; + + model->BSIM4v5InstCount = idx; + + InstArray = TMALLOC(BSIM4v5instance*, idx); + + idx = 0; + for (here = model->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) + InstArray[idx++] = here; + model->BSIM4v5InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4v6/b4v6dest.c b/src/spicelib/devices/bsim4v6/b4v6dest.c index 0d1c5e64a..a146df3a4 100644 --- a/src/spicelib/devices/bsim4v6/b4v6dest.c +++ b/src/spicelib/devices/bsim4v6/b4v6dest.c @@ -20,11 +20,6 @@ BSIM4v6destroy(GENmodel **inModel) { BSIM4v6model *mod = *(BSIM4v6model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4v6InstanceArray); -#endif - while (mod) { BSIM4v6model *next_mod = mod->BSIM4v6nextModel; BSIM4v6instance *inst = mod->BSIM4v6instances; @@ -41,6 +36,9 @@ BSIM4v6destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->BSIM4v6InstanceArray); +#endif FREE(mod->BSIM4v6version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim4v6/b4v6set.c b/src/spicelib/devices/bsim4v6/b4v6set.c index f009e7c91..ab71184be 100644 --- a/src/spicelib/devices/bsim4v6/b4v6set.c +++ b/src/spicelib/devices/bsim4v6/b4v6set.c @@ -59,11 +59,6 @@ double Rtot, DMCGeff, DMCIeff, DMDGeff; JOB *job; -#ifdef USE_OMP -int idx, InstCount; -BSIM4v6instance **InstArray; -#endif - /* Search for a noise analysis request */ for (job = ft_curckt->ci_curTask->jobs; job; job = job->JOBnextJob) { if(strcmp(job->JOBname,"Noise Analysis")==0) { @@ -2418,35 +2413,24 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ } /* end of loop through all the BSIM4v6 device models */ #ifdef USE_OMP - InstCount = 0; - model = (BSIM4v6model*)inModel; - /* loop through all the BSIM4v6 device models - to count the number of instances */ - - for( ; model != NULL; model = model->BSIM4v6nextModel ) + for (model = (BSIM4v6model*)inModel; model; model = model->BSIM4v6nextModel) { - /* loop through all the instances of the model */ - for (here = model->BSIM4v6instances; here != NULL ; - here=here->BSIM4v6nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(BSIM4v6instance*, InstCount); - model = (BSIM4v6model*)inModel; - idx = 0; - for( ; model != NULL; model = model->BSIM4v6nextModel ) - { - /* loop through all the instances of the model */ - for (here = model->BSIM4v6instances; here != NULL ; - here=here->BSIM4v6nextInstance) - { - InstArray[idx] = here; + BSIM4v6instance **InstArray; + int idx; + + idx = 0; + for (here = model->BSIM4v6instances; here; here = here->BSIM4v6nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->BSIM4v6InstCount = InstCount; - model->BSIM4v6InstanceArray = InstArray; + + model->BSIM4v6InstCount = idx; + + InstArray = TMALLOC(BSIM4v6instance*, idx); + + idx = 0; + for (here = model->BSIM4v6instances; here; here = here->BSIM4v6nextInstance) + InstArray[idx++] = here; + + model->BSIM4v6InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4v7/b4v7dest.c b/src/spicelib/devices/bsim4v7/b4v7dest.c index 206708b27..7125ba7f2 100644 --- a/src/spicelib/devices/bsim4v7/b4v7dest.c +++ b/src/spicelib/devices/bsim4v7/b4v7dest.c @@ -20,11 +20,6 @@ BSIM4v7destroy(GENmodel **inModel) { BSIM4v7model *mod = *(BSIM4v7model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4v7InstanceArray); -#endif - while (mod) { BSIM4v7model *next_mod = mod->BSIM4v7nextModel; BSIM4v7instance *inst = mod->BSIM4v7instances; @@ -41,6 +36,9 @@ BSIM4v7destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->BSIM4v7InstanceArray); +#endif /* mod->BSIM4v7modName to be freed in INPtabEnd() */ FREE(mod->BSIM4v7version); FREE(mod); diff --git a/src/spicelib/devices/bsim4v7/b4v7set.c b/src/spicelib/devices/bsim4v7/b4v7set.c index 00d0ea20d..c97999d97 100644 --- a/src/spicelib/devices/bsim4v7/b4v7set.c +++ b/src/spicelib/devices/bsim4v7/b4v7set.c @@ -58,11 +58,6 @@ int noiseAnalGiven = 0, createNode; /* Criteria for new node creation */ double Rtot, DMCGeff, DMCIeff, DMDGeff; JOB *job; -#ifdef USE_OMP -int idx, InstCount; -BSIM4v7instance **InstArray; -#endif - /* Search for a noise analysis request */ for (job = ((TSKtask *)ft_curckt->ci_curTask)->jobs;job;job = job->JOBnextJob) { if(strcmp(job->JOBname,"Noise Analysis")==0) { @@ -2573,35 +2568,24 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL } #ifdef USE_OMP - InstCount = 0; - model = (BSIM4v7model*)inModel; - /* loop through all the BSIM4v7 device models - to count the number of instances */ - - for( ; model != NULL; model = model->BSIM4v7nextModel ) + for (model = (BSIM4v7model*)inModel; model; model = model->BSIM4v7nextModel) { - /* loop through all the instances of the model */ - for (here = model->BSIM4v7instances; here != NULL ; - here=here->BSIM4v7nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(BSIM4v7instance*, InstCount); - model = (BSIM4v7model*)inModel; - idx = 0; - for( ; model != NULL; model = model->BSIM4v7nextModel ) - { - /* loop through all the instances of the model */ - for (here = model->BSIM4v7instances; here != NULL ; - here=here->BSIM4v7nextInstance) - { - InstArray[idx] = here; + BSIM4v7instance **InstArray; + int idx; + + idx = 0; + for (here = model->BSIM4v7instances; here; here = here->BSIM4v7nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->BSIM4v7InstCount = InstCount; - model->BSIM4v7InstanceArray = InstArray; + + model->BSIM4v7InstCount = idx; + + InstArray = TMALLOC(BSIM4v7instance*, idx); + + idx = 0; + for (here = model->BSIM4v7instances; here; here = here->BSIM4v7nextInstance) + InstArray[idx++] = here; + + model->BSIM4v7InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsimsoi/b4soidest.c b/src/spicelib/devices/bsimsoi/b4soidest.c index c66c177ce..f6f6ed0f8 100644 --- a/src/spicelib/devices/bsimsoi/b4soidest.c +++ b/src/spicelib/devices/bsimsoi/b4soidest.c @@ -32,6 +32,9 @@ B4SOIdestroy(GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->B4SOIInstanceArray); +#endif FREE(mod); mod = next_mod; } diff --git a/src/spicelib/devices/bsimsoi/b4soiset.c b/src/spicelib/devices/bsimsoi/b4soiset.c index e13d33960..804c79f93 100644 --- a/src/spicelib/devices/bsimsoi/b4soiset.c +++ b/src/spicelib/devices/bsimsoi/b4soiset.c @@ -53,11 +53,6 @@ double Cboxt; /* v3.2 */ double Vbs0t, Qsi; -#ifdef USE_OMP -int idx, InstCount; -B4SOIinstance **InstArray; -#endif - /* loop through all the B4SOI device models */ for( ; model != NULL; model = model->B4SOInextModel ) { @@ -2706,35 +2701,24 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL } #ifdef USE_OMP - InstCount = 0; - model = (B4SOImodel*)inModel; - /* loop through all the B4SOI device models - to count the number of instances */ - - for( ; model != NULL; model = model->B4SOInextModel ) + for (model = (B4SOImodel*)inModel; model; model = model->B4SOInextModel) { - /* loop through all the instances of the model */ - for (here = model->B4SOIinstances; here != NULL ; - here=here->B4SOInextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(B4SOIinstance*, InstCount); - model = (B4SOImodel*)inModel; - idx = 0; - for( ; model != NULL; model = model->B4SOInextModel ) - { - /* loop through all the instances of the model */ - for (here = model->B4SOIinstances; here != NULL ; - here=here->B4SOInextInstance) - { - InstArray[idx] = here; + B4SOIinstance **InstArray; + int idx; + + idx = 0; + for (here = model->B4SOIinstances; here; here = here->B4SOInextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->B4SOIInstCount = InstCount; - model->B4SOIInstanceArray = InstArray; + + model->B4SOIInstCount = idx; + + InstArray = TMALLOC(B4SOIinstance*, idx); + + idx = 0; + for (here = model->B4SOIinstances; here; here = here->B4SOInextInstance) + InstArray[idx++] = here; + + model->B4SOIInstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/hisim2/hsm2dest.c b/src/spicelib/devices/hisim2/hsm2dest.c index 32fbb857f..6047432aa 100644 --- a/src/spicelib/devices/hisim2/hsm2dest.c +++ b/src/spicelib/devices/hisim2/hsm2dest.c @@ -64,11 +64,6 @@ HSM2destroy(GENmodel **inModel) { HSM2model *mod = *(HSM2model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->HSM2InstanceArray); -#endif - while (mod) { HSM2model *next_mod = mod->HSM2nextModel; HSM2instance *inst = mod->HSM2instances; @@ -77,6 +72,9 @@ HSM2destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } +#ifdef USE_OMP + FREE(mod->HSM2InstanceArray); +#endif FREE(mod); mod = next_mod; } diff --git a/src/spicelib/devices/hisim2/hsm2set.c b/src/spicelib/devices/hisim2/hsm2set.c index 5f5a2abbd..4d6018f71 100644 --- a/src/spicelib/devices/hisim2/hsm2set.c +++ b/src/spicelib/devices/hisim2/hsm2set.c @@ -114,11 +114,6 @@ int HSM2setup( double Lgate =0.0, LG =0.0, Wgate =0.0, WG=0.0 ; double Lbin=0.0, Wbin=0.0, LWbin =0.0; /* binning */ -#ifdef USE_OMP - int idx, InstCount; - HSM2instance **InstArray; -#endif - /* loop through all the HSM2 device models */ for ( ;model != NULL ;model = model->HSM2nextModel ) { /* Default value Processing for HSM2 MOSFET Models */ @@ -1257,34 +1252,23 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL } /* End of model */ #ifdef USE_OMP - InstCount = 0; - model = (HSM2model*)inModel; - /* loop through all the HSM2 device models - to count the number of instances */ + for (model = (HSM2model*)inModel; model; model = model->HSM2nextModel) + { + HSM2instance **InstArray; + int idx; - for ( ; model != NULL; model = model->HSM2nextModel ) - { - /* loop through all the instances of the model */ - for (here = model->HSM2instances; here != NULL ; - here = here->HSM2nextInstance) - { - InstCount++; - } - } - InstArray = TMALLOC(HSM2instance*, InstCount); - model = (HSM2model*)inModel; - idx = 0; - for ( ; model != NULL; model = model->HSM2nextModel ) - { - /* loop through all the instances of the model */ - for (here = model->HSM2instances; here != NULL ; - here = here->HSM2nextInstance) - { - InstArray[idx] = here; + idx = 0; + for (here = model->HSM2instances; here; here = here->HSM2nextInstance) idx++; - } - /* set the array pointer and instance count into each model */ - model->HSM2InstCount = InstCount; + + model->HSM2InstCount = idx; + + InstArray = TMALLOC(HSM2instance*, idx); + + idx = 0; + for (here = model->HSM2instances; here; here = here->HSM2nextInstance) + InstArray[idx++] = here; + model->HSM2InstanceArray = InstArray; } #endif