Browse Source

Per-device load timing support.

pre-master-46
Árpád Bűrmen 1 year ago
committed by Holger Vogt
parent
commit
d659943d77
  1. 18
      src/frontend/resource.c
  2. 4
      src/include/ngspice/optdefs.h
  3. 2
      src/spicelib/analysis/cktdest.c
  4. 17
      src/spicelib/analysis/cktload.c
  5. 3
      src/spicelib/devices/cktinit.c

18
src/frontend/resource.c

@ -14,6 +14,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
#include "ngspice/cpdefs.h" #include "ngspice/cpdefs.h"
#include "ngspice/ftedefs.h" #include "ngspice/ftedefs.h"
#include "ngspice/devdefs.h"
#include "circuits.h" #include "circuits.h"
#include "resource.h" #include "resource.h"
@ -325,7 +326,22 @@ printres(char *name)
/* Now get all the spice resource stuff. */ /* Now get all the spice resource stuff. */
if (ft_curckt && ft_curckt->ci_ckt) { if (ft_curckt && ft_curckt->ci_ckt) {
if (name && eq(name, "devtimes")) {
/* Per-device timings */
for(int i=0; i<=DEVmaxnum; i++) {
if (ft_curckt->ci_ckt->CKTstat->devCounts[i]==0) {
continue;
}
fprintf(cp_out, "%s: t=%f n=%ld t/n=%e\n",
(i==DEVmaxnum ? "\noverhead" : DEVices[i]->DEVpublic.name),
ft_curckt->ci_ckt->CKTstat->devTimes[i],
ft_curckt->ci_ckt->CKTstat->devCounts[i],
ft_curckt->ci_ckt->CKTstat->devTimes[i]/(double)(ft_curckt->ci_ckt->CKTstat->devCounts[i])
);
}
}
yy = TRUE;
#ifdef CIDER #ifdef CIDER
/* begin cider integration */ /* begin cider integration */
if (!name || eq(name, "circuit") || eq(name, "task")) if (!name || eq(name, "circuit") || eq(name, "task"))

4
src/include/ngspice/optdefs.h

@ -7,6 +7,8 @@ Modified: 2000 AlansFixes
#ifndef ngspice_OPTDEFS_H #ifndef ngspice_OPTDEFS_H
#define ngspice_OPTDEFS_H #define ngspice_OPTDEFS_H
#include <stddef.h>
/* structure used to describe the statistics to be collected */ /* structure used to describe the statistics to be collected */
typedef struct sSTATdevList { typedef struct sSTATdevList {
@ -46,6 +48,8 @@ typedef struct {
double STATacLoadTime; /* time spent in AC device loading */ double STATacLoadTime; /* time spent in AC device loading */
double STATacSyncTime; /* time spent in transient sync'ing */ double STATacSyncTime; /* time spent in transient sync'ing */
STATdevList *STATdevNum; /* PN: Number of instances and models for each device */ STATdevList *STATdevNum; /* PN: Number of instances and models for each device */
double *devTimes; /* Per-device load times, last entry is overhead */
size_t *devCounts; /* Per-device load counts, last entry is overhead */
} STATistics; } STATistics;
enum { enum {

2
src/spicelib/analysis/cktdest.c

@ -98,6 +98,8 @@ CKTdestroy(CKTcircuit *ckt)
#endif #endif
FREE(ckt->CKTstat->STATdevNum); FREE(ckt->CKTstat->STATdevNum);
FREE(ckt->CKTstat->devCounts);
FREE(ckt->CKTstat->devTimes);
FREE(ckt->CKTstat); FREE(ckt->CKTstat);
FREE(ckt->CKThead); FREE(ckt->CKThead);

17
src/spicelib/analysis/cktload.c

@ -27,12 +27,13 @@ Modified: 2000 AlansFixes
static int ZeroNoncurRow(SMPmatrix *matrix, CKTnode *nodes, int rownum); static int ZeroNoncurRow(SMPmatrix *matrix, CKTnode *nodes, int rownum);
// #define PER_DEVICE_STATS
int int
CKTload(CKTcircuit *ckt) CKTload(CKTcircuit *ckt)
{ {
int i; int i;
int size; int size;
double startTime;
double startTime, td0;
CKTnode *node; CKTnode *node;
int error; int error;
#ifdef STEPDEBUG #ifdef STEPDEBUG
@ -49,6 +50,13 @@ CKTload(CKTcircuit *ckt)
/* gtri - begin - Put resistors to ground at all nodes */ /* gtri - begin - Put resistors to ground at all nodes */
#endif #endif
td0 = SPfrontEnd->IFseconds();
#ifdef PER_DEVICE_STATS
ckt->CKTstat->devTimes[DEVmaxnum] += SPfrontEnd->IFseconds() - td0;
ckt->CKTstat->devCounts[DEVmaxnum]++;
#endif
startTime = SPfrontEnd->IFseconds(); startTime = SPfrontEnd->IFseconds();
size = SMPmatSize(ckt->CKTmatrix); size = SMPmatSize(ckt->CKTmatrix);
for (i = 0; i <= size; i++) { for (i = 0; i <= size; i++) {
@ -61,7 +69,14 @@ CKTload(CKTcircuit *ckt)
for (i = 0; i < DEVmaxnum; i++) { for (i = 0; i < DEVmaxnum; i++) {
if (DEVices[i] && DEVices[i]->DEVload && ckt->CKThead[i]) { if (DEVices[i] && DEVices[i]->DEVload && ckt->CKThead[i]) {
#ifdef PER_DEVICE_STATS
td0 = SPfrontEnd->IFseconds();
#endif
error = DEVices[i]->DEVload (ckt->CKThead[i], ckt); error = DEVices[i]->DEVload (ckt->CKThead[i], ckt);
#ifdef PER_DEVICE_STATS
ckt->CKTstat->devTimes[i] += SPfrontEnd->IFseconds() - td0;
ckt->CKTstat->devCounts[i]++;
#endif
if (ckt->CKTnoncon) if (ckt->CKTnoncon)
ckt->CKTtroubleNode = 0; ckt->CKTtroubleNode = 0;
#ifdef STEPDEBUG #ifdef STEPDEBUG

3
src/spicelib/devices/cktinit.c

@ -82,6 +82,9 @@ CKTinit(CKTcircuit **ckt) /* new circuit to create */
sckt->CKTstat->STATdevNum = TMALLOC(STATdevList, DEVmaxnum); sckt->CKTstat->STATdevNum = TMALLOC(STATdevList, DEVmaxnum);
if(sckt->CKTstat->STATdevNum == NULL) if(sckt->CKTstat->STATdevNum == NULL)
return(E_NOMEM); return(E_NOMEM);
/* Per-device timings */
sckt->CKTstat->devTimes = TMALLOC(double, DEVmaxnum+1);
sckt->CKTstat->devCounts = TMALLOC(size_t, DEVmaxnum+1);
sckt->CKTtroubleNode = 0; sckt->CKTtroubleNode = 0;
sckt->CKTtroubleElt = NULL; sckt->CKTtroubleElt = NULL;
sckt->CKTtimePoints = NULL; sckt->CKTtimePoints = NULL;

Loading…
Cancel
Save