Modified the parallel combination code so that properties of

parallel devices are prepended rather than appended, which avoids
having to search for the end of what may be a rapidly increasing
linked list of properties.  This reduces the amount of time spent
in the parallel combination code.  Thanks to Anton Blanchard for
pointing out this inefficiency.
This commit is contained in:
Tim Edwards 2022-01-15 12:06:43 -05:00
parent 68ec2b2a7c
commit 6195745b45
2 changed files with 21 additions and 25 deletions

View File

@ -1 +1 @@
1.5.217 1.5.218

View File

@ -3337,16 +3337,13 @@ int CombineParallel(char *model, int file)
/* "sob" to it. If "ob" does not have properties, then */ /* "sob" to it. If "ob" does not have properties, then */
/* create a property record and set property "M" to 1. */ /* create a property record and set property "M" to 1. */
/* Find last non-property record of sob ( = pob) */ /* Find last non-property record of sob ( = pob) */
/* Find first property record of sob ( = spropfirst) */ /* Find first property record of sob ( = spropfirst) */
/* Find last property record of sob ( = sproplast) */
spropfirst = sproplast = NULL; spropfirst = NULL;
for (ob2 = sob; ob2->type > FIRSTPIN || ob2 == sob; ob2 = ob2->next) for (ob2 = sob; ob2->type > FIRSTPIN || ob2 == sob; ob2 = ob2->next)
pob = ob2; pob = ob2;
if (ob2->type == PROPERTY) spropfirst = ob2; if (ob2->type == PROPERTY) spropfirst = ob2;
for (; ob2->type == PROPERTY; ob2 = ob2->next)
sproplast = ob2;
if (spropfirst == NULL) { if (spropfirst == NULL) {
/* Create new property instance record if one doesn't exist */ /* Create new property instance record if one doesn't exist */
@ -3372,8 +3369,9 @@ int CombineParallel(char *model, int file)
nob->next = pob->next; nob->next = pob->next;
pob->next = nob; pob->next = nob;
/* Handle case of contiguous entries */
if (lob == pob) lob = nob; if (lob == pob) lob = nob;
spropfirst = sproplast = nob; spropfirst = nob;
} }
if (propfirst == NULL) { if (propfirst == NULL) {
/* Create new property instance record if one doesn't exist */ /* Create new property instance record if one doesn't exist */
@ -3396,27 +3394,26 @@ int CombineParallel(char *model, int file)
kv->type = PROP_ENDLIST; kv->type = PROP_ENDLIST;
kv->value.ival = 0; kv->value.ival = 0;
/* Append to sob's property list */ /* Prepend to sob's property list */
nob->next = sproplast->next; nob->next = pob->next;
sproplast->next = nob; pob->next = nob;
if (lob == sproplast) lob = nob; /* Handle case of contiguous entries */
if (lob == pob) lob = nob;
} }
else {
if (propfirst != NULL) {
// Series/Parallel logic: // Series/Parallel logic:
// If propfirst has _tag in properties, // If spropfirst has _tag in properties,
// then add an "open" tag at propfirst // then add an "open" tag at spropfirst
add_prop_tag(propfirst, '('); add_prop_tag(spropfirst, '(');
// if spropfirst has _tag in properties then add an "open" tag // if propfirst has _tag in properties then add an "open" tag
// to spropfirst and a "close" tag to propfirst // to propfirst and a "close" tag to spropfirst
if (add_prop_tag(spropfirst, '(')) add_prop_tag(propfirst, ')'); if (add_prop_tag(propfirst, '(')) add_prop_tag(spropfirst, ')');
/* Append ob's property list to sob */ /* Prepend ob's property list to sob */
proplast->next = sproplast->next; proplast->next = pob->next;
sproplast->next = propfirst; pob->next = propfirst;
if (lob == sproplast) lob = proplast;
} }
/* Link up around object to be removed */ /* Link up around object to be removed */
@ -3429,7 +3426,6 @@ int CombineParallel(char *model, int file)
obr = nob; obr = nob;
} }
dcnt++; dcnt++;
} }
FREE((char *)pstr); FREE((char *)pstr);
} }