make res changes more generic
This commit is contained in:
parent
a5b7f048d0
commit
ec2c710ecc
|
|
@ -486,8 +486,8 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
|
|
||||||
#ifdef USE_CUSPICE
|
#ifdef USE_CUSPICE
|
||||||
RESmodel *model = RESmodPtr(here) ;
|
RESmodel *model = RESmodPtr(here) ;
|
||||||
if (model->RESinitCUDA) {
|
if (model->gen.GENinitCUDA) {
|
||||||
model->RESparamCPU.RESconductArray[here->REScudaIndex] = here->RESconduct;
|
model->RESparamCPU.RESconductArray[here->gen.GENcudaIndex] = here->RESconduct;
|
||||||
status = cuREStemp ((GENmodel *)model);
|
status = cuREStemp ((GENmodel *)model);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return E_NOMEM;
|
return E_NOMEM;
|
||||||
|
|
|
||||||
|
|
@ -47,17 +47,17 @@ GENmodel *inModel, CKTcircuit *ckt
|
||||||
/* Determining how many blocks should exist in the kernel */
|
/* Determining how many blocks should exist in the kernel */
|
||||||
thread_x = 1 ;
|
thread_x = 1 ;
|
||||||
thread_y = 256 ;
|
thread_y = 256 ;
|
||||||
if (model->RESnInstances % thread_y != 0)
|
if (model->gen.GENnInstances % thread_y != 0)
|
||||||
block_x = (int)((model->RESnInstances + thread_y - 1) / thread_y) ;
|
block_x = (int)((model->gen.GENnInstances + thread_y - 1) / thread_y) ;
|
||||||
else
|
else
|
||||||
block_x = model->RESnInstances / thread_y ;
|
block_x = model->gen.GENnInstances / thread_y ;
|
||||||
|
|
||||||
dim3 thread (thread_x, thread_y) ;
|
dim3 thread (thread_x, thread_y) ;
|
||||||
|
|
||||||
/* Kernel launch */
|
/* Kernel launch */
|
||||||
status = cudaGetLastError () ; // clear error status
|
status = cudaGetLastError () ; // clear error status
|
||||||
|
|
||||||
cuRESload_kernel <<< block_x, thread >>> (model->RESparamGPU, ckt->d_CKTrhsOld, model->RESnInstances,
|
cuRESload_kernel <<< block_x, thread >>> (model->RESparamGPU, ckt->d_CKTrhsOld, model->gen.GENnInstances,
|
||||||
model->d_PositionVector, ckt->d_CKTloadOutput) ;
|
model->d_PositionVector, ckt->d_CKTloadOutput) ;
|
||||||
|
|
||||||
cudaDeviceSynchronize () ;
|
cudaDeviceSynchronize () ;
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ GENmodel *inModel
|
||||||
cudaError_t status ;
|
cudaError_t status ;
|
||||||
RESmodel *model = (RESmodel *)inModel ;
|
RESmodel *model = (RESmodel *)inModel ;
|
||||||
|
|
||||||
size = (long unsigned int) model->RESnInstances ;
|
size = (long unsigned int) model->gen.GENnInstances ;
|
||||||
|
|
||||||
/* Space Allocation to GPU */
|
/* Space Allocation to GPU */
|
||||||
status = cudaMalloc ((void **)&(model->d_PositionVector), size * sizeof(int)) ;
|
status = cudaMalloc ((void **)&(model->d_PositionVector), size * sizeof(int)) ;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ GENmodel *inModel
|
||||||
cudaError_t status ;
|
cudaError_t status ;
|
||||||
RESmodel *model = (RESmodel *)inModel ;
|
RESmodel *model = (RESmodel *)inModel ;
|
||||||
|
|
||||||
size = (long unsigned int) model->RESnInstances ;
|
size = (long unsigned int) model->gen.GENnInstances ;
|
||||||
|
|
||||||
/* DOUBLE */
|
/* DOUBLE */
|
||||||
status = cudaMemcpy (model->RESparamGPU.d_RESconductArray, model->RESparamCPU.RESconductArray, size * sizeof(double), cudaMemcpyHostToDevice) ;
|
status = cudaMemcpy (model->RESparamGPU.d_RESconductArray, model->RESparamCPU.RESconductArray, size * sizeof(double), cudaMemcpyHostToDevice) ;
|
||||||
|
|
|
||||||
|
|
@ -95,11 +95,6 @@ typedef struct sRESinstance {
|
||||||
BindElement *RESnegPosBinding ;
|
BindElement *RESnegPosBinding ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_CUSPICE
|
|
||||||
#define REScudaIndex gen.GENcudaIndex
|
|
||||||
#define RESnInstances gen.GENnInstances
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} RESinstance ;
|
} RESinstance ;
|
||||||
|
|
||||||
#ifdef USE_CUSPICE
|
#ifdef USE_CUSPICE
|
||||||
|
|
@ -177,8 +172,6 @@ typedef struct sRESmodel { /* model structure for a resistor */
|
||||||
int n_Ptr ;
|
int n_Ptr ;
|
||||||
int *PositionVector ;
|
int *PositionVector ;
|
||||||
int *d_PositionVector ;
|
int *d_PositionVector ;
|
||||||
|
|
||||||
#define RESinitCUDA gen.GENinitCUDA
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} RESmodel;
|
} RESmodel;
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@ RESparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
RESmodel *model ;
|
RESmodel *model ;
|
||||||
|
|
||||||
model = RESmodPtr(here) ;
|
model = RESmodPtr(here) ;
|
||||||
if (model->RESinitCUDA) {
|
if (model->gen.GENinitCUDA) {
|
||||||
model->RESparamCPU.RESconductArray[here->REScudaIndex] = here->RESconduct;
|
model->RESparamCPU.RESconductArray[here->gen.GENcudaIndex] = here->RESconduct;
|
||||||
status = cuREStemp ((GENmodel *)model);
|
status = cuREStemp ((GENmodel *)model);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return E_NOMEM;
|
return E_NOMEM;
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
||||||
j++ ;
|
j++ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
model->n_values = model->RESnInstances ;
|
model->n_values = model->gen.GENnInstances ;
|
||||||
ckt->total_n_values += model->n_values ;
|
ckt->total_n_values += model->n_values ;
|
||||||
|
|
||||||
model->n_Ptr = j ;
|
model->n_Ptr = j ;
|
||||||
|
|
@ -116,9 +116,9 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
||||||
|
|
||||||
|
|
||||||
/* Position Vector assignment */
|
/* Position Vector assignment */
|
||||||
model->PositionVector = TMALLOC (int, model->RESnInstances) ;
|
model->PositionVector = TMALLOC (int, model->gen.GENnInstances) ;
|
||||||
|
|
||||||
for (j = 0 ; j < model->RESnInstances ; j++)
|
for (j = 0 ; j < model->gen.GENnInstances ; j++)
|
||||||
model->PositionVector [j] = model->offset + j ;
|
model->PositionVector [j] = model->offset + j ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +129,7 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return (E_NOMEM) ;
|
return (E_NOMEM) ;
|
||||||
|
|
||||||
model->RESinitCUDA = 1 ;
|
model->gen.GENinitCUDA = 1 ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,10 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
RESupdate_conduct(here, TRUE);
|
RESupdate_conduct(here, TRUE);
|
||||||
|
|
||||||
#ifdef USE_CUSPICE
|
#ifdef USE_CUSPICE
|
||||||
model->RESparamCPU.RESposNodeArray[here->REScudaIndex] = here->RESposNode;
|
int i = here->gen.GENcudaIndex;
|
||||||
model->RESparamCPU.RESnegNodeArray[here->REScudaIndex] = here->RESnegNode;
|
model->RESparamCPU.RESposNodeArray[i] = here->RESposNode;
|
||||||
model->RESparamCPU.RESconductArray[here->REScudaIndex] = here->RESconduct;
|
model->RESparamCPU.RESnegNodeArray[i] = here->RESnegNode;
|
||||||
|
model->RESparamCPU.RESconductArray[i] = here->RESconduct;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue