4 void preconditionU(
double **u,
double *w,
int m,
int n)
6 for(
int j =0; j<n; j++)
10 if(w[j]) u[i][j]/= w[j];
17 void preconditionU_F(
float **u,
float *w,
int m,
int n)
19 for(
int j =0; j<n; j++)
23 if(w[j]) u[i][j]/= w[j];
30 void backsub_precond(
double **u,
double **v,
int m,
int n,
double *b,
double *x,
double *tmp)
34 double *vrow, *urow, _b;
58 x[j] = vrow[0]*tmp[0];
64 for (jj=1;jj<n;jj++) x[j] += vrow[jj]*tmp[jj];
68 void backsub_precond_F(
float **u,
float **v,
int m,
int n,
float *b,
float *x,
float *tmp)
72 float *vrow, *urow, _b;
104 x[j] = vrow[0]*tmp[0];
110 for (jj=1;jj<n;jj++) x[j] += vrow[jj]*tmp[jj];
128 void * threadsub(
void * ptr)
135 for(i=1;i<ta->m; i++)
140 for(j=ta->jmin;j<ta->jmax; j++)
142 ta->tmp[j] += urow[j]*_b;
150 void backsub_precond_F_threads(
float **u,
float **v,
int m,
int n,
float *b,
float *x,
float *tmp,
int nthreads)
152 struct sched_param schedpar;
153 schedpar.sched_priority = 99;
157 pthread_attr_init(&attr);
159 pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
160 pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
161 pthread_attr_setschedparam(&attr, &schedpar);
165 float *vrow, *urow, _b;
189 ta.jmax = n/nthreads;
192 pthread_create(&th1, 0, &threadsub, (
void *) &ta);
202 ta2.jmax = 2.*ta.jmax;
203 pthread_create(&th2, 0, &threadsub, (
void *) &ta2);
212 pthread_join(th1, 0);
216 if(!ta.done) pthread_join(th1, 0);
217 if(!ta2.done) pthread_join(th2, 0);
223 x[j] = vrow[0]*tmp[0];
229 for (jj=1;jj<n;jj++) x[j] += vrow[jj]*tmp[jj];