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

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

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

revision 3441 by jfenwick, Mon Oct 11 01:48:14 2010 UTC revision 3442 by gross, Tue Jan 18 01:47:36 2011 UTC
# Line 191  void Paso_Coupler_free(Paso_Coupler* in) Line 191  void Paso_Coupler_free(Paso_Coupler* in)
191          MEMFREE(in->mpi_stati);          MEMFREE(in->mpi_stati);
192          Esys_MPIInfo_free(in->mpi_info);          Esys_MPIInfo_free(in->mpi_info);
193          MEMFREE(in);          MEMFREE(in);
         #ifdef Paso_TRACE  
         printf("Paso_Coupler_dealloc: system matrix pattern as been deallocated.\n");  
         #endif  
194       }       }
195     }     }
196  }  }
# Line 264  double* Paso_Coupler_finishCollect(Paso_ Line 261  double* Paso_Coupler_finishCollect(Paso_
261    
262    return coupler->recv_buffer;    return coupler->recv_buffer;
263  }  }
264    
265    dim_t Paso_Coupler_getNumSharedValues(const Paso_Coupler* in) {
266       return in->connector->send->numSharedComponents * coupler->block_size;
267    }
268    dim_t Paso_Coupler_getNumOverlapValues(const Paso_Coupler* in) {
269       return in->connector->recv->numSharedComponents * coupler->block_size;
270    }
271    
272  dim_t Paso_Coupler_getLocalLength(const Paso_Coupler* in) {  dim_t Paso_Coupler_getLocalLength(const Paso_Coupler* in) {
273       return in->connector->send->local_length;       return in->connector->send->local_length;
274  }  }
# Line 282  void Paso_Coupler_copyAll(const Paso_Cou Line 287  void Paso_Coupler_copyAll(const Paso_Cou
287       }       }
288    }    }
289  }  }
290    
291    /* adds a local vector x * a to the vector y including overlap :*/
292    void Paso_Coupler_add(const dim_t my_n, double* x, const double a, const double* y, Paso_Coupler *coupler)
293    {
294       double *remote_values = NULL;
295       const dim_t overlap_n = Paso_Coupler_getNumOverlapValues(coupler) ;
296       const dim_t n= my_n + overlap_n;
297       dim_t i;
298      
299       if (ABS(a) > 0 ) {
300          Paso_Coupler_startCollect(coupler, x);
301          
302          if ( a == 1.) {
303         #pragma omp parallel for private(i)
304         for (i=0; i<my_n; i++) {
305            x[i]+=y[i];
306         }
307          } else {
308         #pragma omp parallel for private(i)
309         for (i=0; i<my_n; i++) {
310            x[i]+=a*y[i];
311         }
312          }
313          
314          Paso_Coupler_finishCollect(coupler);
315          remote_values=coupler->recv_buffer;
316          
317          if ( a == 1.) {
318         #pragma omp parallel for private(i)
319         for (i=0;i<overlap_n; ++i) {
320            x[i+overlap_n]+=remote_values[i];
321         }
322          } else {
323         #pragma omp parallel for private(i)
324         for (i=0;i<overlap_n; ++i) {
325            x[i+overlap_n]+=a*remote_values[i];
326         }
327          }
328       }
329    }

Legend:
Removed from v.3441  
changed lines
  Added in v.3442

  ViewVC Help
Powered by ViewVC 1.1.26