/[escript]/trunk/paso/src/PCG.c
ViewVC logotype

Diff of /trunk/paso/src/PCG.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1579 by ksteube, Mon Jun 2 08:48:36 2008 UTC revision 1628 by phornby, Fri Jul 11 13:12:46 2008 UTC
# Line 78  err_t Paso_Solver_PCG( Line 78  err_t Paso_Solver_PCG(
78      Paso_Performance* pp) {      Paso_Performance* pp) {
79    
80    /* Local variables */    /* Local variables */
81    dim_t num_iter=0,maxit,num_iter_global, chunk_size=-1, len,rest, n_chunks, np, ipp;    dim_t num_iter=0,maxit,num_iter_global, chunk_size=-1, len,rest, np, ipp;
82    register double ss,ss1;    register double ss,ss1;
83    dim_t i0, istart, iend;    dim_t i0, istart, iend;
84    bool_t breakFlag=FALSE, maxIterFlag=FALSE, convergeFlag=FALSE;    bool_t breakFlag=FALSE, maxIterFlag=FALSE, convergeFlag=FALSE;
# Line 86  err_t Paso_Solver_PCG( Line 86  err_t Paso_Solver_PCG(
86    dim_t n = Paso_SystemMatrix_getTotalNumRows(A);    dim_t n = Paso_SystemMatrix_getTotalNumRows(A);
87    double *resid = tolerance, *rs=NULL, *p=NULL, *v=NULL, *x2=NULL ;    double *resid = tolerance, *rs=NULL, *p=NULL, *v=NULL, *x2=NULL ;
88    double tau_old,tau,beta,delta,gamma_1,gamma_2,alpha,sum_1,sum_2,sum_3,sum_4,sum_5,tol;    double tau_old,tau,beta,delta,gamma_1,gamma_2,alpha,sum_1,sum_2,sum_3,sum_4,sum_5,tol;
89    double norm_of_residual,norm_of_residual_global, loc_sum[2], sum[2];  #ifdef PASO_MPI
90    register double r_tmp,d,rs_tmp,x2_tmp,x_tmp;    double loc_sum[2], sum[2];
91    char* chksz_chr;  #endif
92    np=omp_get_max_threads();    double norm_of_residual,norm_of_residual_global;
93      register double d;
94    
95      /* Should not be any executable code before this ifdef */
96    
97  #ifdef USE_DYNAMIC_SCHEDULING  #ifdef USE_DYNAMIC_SCHEDULING
98    
99        /* Watch out for these declarations (see above) */
100        char* chksz_chr;
101        dim_t n_chunks;
102    
103      chksz_chr=getenv("PASO_CHUNK_SIZE_PCG");      chksz_chr=getenv("PASO_CHUNK_SIZE_PCG");
104      if (chksz_chr!=NULL) sscanf(chksz_chr, "%d",&chunk_size);      if (chksz_chr!=NULL) sscanf(chksz_chr, "%d",&chunk_size);
105        np=omp_get_max_threads();
106      chunk_size=MIN(MAX(1,chunk_size),n/np);      chunk_size=MIN(MAX(1,chunk_size),n/np);
107      n_chunks=n/chunk_size;      n_chunks=n/chunk_size;
108      if (n_chunks*chunk_size<n) n_chunks+=1;      if (n_chunks*chunk_size<n) n_chunks+=1;
109  #else  #else
110        np=omp_get_max_threads();
111      len=n/np;      len=n/np;
112      rest=n-len*np;      rest=n-len*np;
113  #endif  #endif
# Line 151  err_t Paso_Solver_PCG( Line 161  err_t Paso_Solver_PCG(
161         #endif         #endif
162      }      }
163      num_iter=0;      num_iter=0;
164    
165        /* PGH */
166        /* without this we get a use of an unititialised var below */
167        tau = 0;
168    
169      /* start of iteration */      /* start of iteration */
170      while (!(convergeFlag || maxIterFlag || breakFlag)) {      while (!(convergeFlag || maxIterFlag || breakFlag)) {
171             ++(num_iter);             ++(num_iter);
172    
173               /* PGH */
174               /* The next lines were commented out before I got here */
175             /* v=prec(r)  */             /* v=prec(r)  */
176               /* tau=v*r; */
177               /* leading to the use of an unititialised var below */
178    
179             Performance_stopMonitor(pp,PERFORMANCE_SOLVER);             Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
180             Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);             Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);
181             Paso_Solver_solvePreconditioner(A,v,r);             Paso_Solver_solvePreconditioner(A,v,r);
182             Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);             Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);
183             Performance_startMonitor(pp,PERFORMANCE_SOLVER);             Performance_startMonitor(pp,PERFORMANCE_SOLVER);
184             /* tau=v*r    */  
185         sum_1 = 0;         sum_1 = 0;
186             #pragma omp parallel private(i0, istart, iend, ipp, ss)             #pragma omp parallel private(i0, istart, iend, ipp, ss)
187             {             {

Legend:
Removed from v.1579  
changed lines
  Added in v.1628

  ViewVC Help
Powered by ViewVC 1.1.26