/[escript]/branches/doubleplusgood/paso/src/PCG.cpp
ViewVC logotype

Diff of /branches/doubleplusgood/paso/src/PCG.cpp

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

revision 495 by gross, Mon Feb 6 06:32:06 2006 UTC revision 631 by dhawcroft, Thu Mar 23 04:27:32 2006 UTC
# Line 1  Line 1 
1  /* $Id$ */  /* $Id$ */
2    
3    
4    /*
5    ********************************************************************************
6    *               Copyright 2006 by ACcESS MNRF                                *
7    *                                                                              *
8    *                 http://www.access.edu.au                                     *
9    *           Primary Business: Queensland, Australia                            *
10    *     Licensed under the Open Software License version 3.0             *
11    *        http://www.opensource.org/licenses/osl-3.0.php                        *
12    ********************************************************************************
13    */
14    
15  /* PCG iterations */  /* PCG iterations */
16    
17  #include "SystemMatrix.h"  #include "SystemMatrix.h"
# Line 52  err_t Paso_Solver_PCG( Line 63  err_t Paso_Solver_PCG(
63      double * r,      double * r,
64      double * x,      double * x,
65      dim_t *iter,      dim_t *iter,
66      double * tolerance) {      double * tolerance,
67        Paso_Performance* pp) {
68    
69    
70    /* Local variables */    /* Local variables */
# Line 90  err_t Paso_Solver_PCG( Line 102  err_t Paso_Solver_PCG(
102      #pragma omp parallel firstprivate(maxit,tol,convergeFlag,maxIterFlag,breakFlag) \      #pragma omp parallel firstprivate(maxit,tol,convergeFlag,maxIterFlag,breakFlag) \
103                                             private(tau_old,tau,beta,delta,gamma_1,gamma_2,alpha,norm_of_residual,num_iter)                                             private(tau_old,tau,beta,delta,gamma_1,gamma_2,alpha,norm_of_residual,num_iter)
104      {      {
105           Performance_startMonitor(pp,PERFORMANCE_SOLVER);
106         /* initialize data */         /* initialize data */
107         #pragma omp for private(i0) schedule(static)         #pragma omp for private(i0) schedule(static)
108         for (i0=0;i0<n;i0++) {         for (i0=0;i0<n;i0++) {
# Line 115  err_t Paso_Solver_PCG( Line 128  err_t Paso_Solver_PCG(
128             sum_5 = 0;             sum_5 = 0;
129             }             }
130             /* v=prec(r)  */             /* v=prec(r)  */
131               Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
132               Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);
133             Paso_Solver_solvePreconditioner(A,v,r);             Paso_Solver_solvePreconditioner(A,v,r);
134               Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);
135               Performance_startMonitor(pp,PERFORMANCE_SOLVER);
136             /* tau=v*r    */             /* tau=v*r    */
137             #pragma omp for private(i0) reduction(+:sum_1) schedule(static)             #pragma omp for private(i0) reduction(+:sum_1) schedule(static)
138             for (i0=0;i0<n;i0++) sum_1+=v[i0]*r[i0];             for (i0=0;i0<n;i0++) sum_1+=v[i0]*r[i0];
# Line 131  err_t Paso_Solver_PCG( Line 148  err_t Paso_Solver_PCG(
148                 for (i0=0;i0<n;i0++) p[i0]=v[i0]+beta*p[i0];                 for (i0=0;i0<n;i0++) p[i0]=v[i0]+beta*p[i0];
149             }             }
150             /* v=A*p */             /* v=A*p */
151               Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
152               Performance_startMonitor(pp,PERFORMANCE_MVM);
153         Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(ONE, A, p,ZERO,v);         Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(ONE, A, p,ZERO,v);
154               Performance_stopMonitor(pp,PERFORMANCE_MVM);
155               Performance_startMonitor(pp,PERFORMANCE_SOLVER);
156             /* delta=p*v */             /* delta=p*v */
157             #pragma omp for private(i0) reduction(+:sum_2) schedule(static)             #pragma omp for private(i0) reduction(+:sum_2) schedule(static)
158             for (i0=0;i0<n;i0++) sum_2+=v[i0]*p[i0];             for (i0=0;i0<n;i0++) sum_2+=v[i0]*p[i0];
# Line 175  err_t Paso_Solver_PCG( Line 196  err_t Paso_Solver_PCG(
196             } else if (breakFlag) {             } else if (breakFlag) {
197                 status = SOLVER_BREAKDOWN;                 status = SOLVER_BREAKDOWN;
198             }             }
199           }         }
200           Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
201      }  /* end of parallel region */      }  /* end of parallel region */
202      TMPMEMFREE(rs);      TMPMEMFREE(rs);
203      TMPMEMFREE(x2);      TMPMEMFREE(x2);

Legend:
Removed from v.495  
changed lines
  Added in v.631

  ViewVC Help
Powered by ViewVC 1.1.26