/[escript]/trunk/finley/src/Util.c
ViewVC logotype

Diff of /trunk/finley/src/Util.c

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

revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC revision 113 by jgs, Mon Feb 28 07:06:33 2005 UTC
# Line 15  Line 15 
15  #include "Common.h"  #include "Common.h"
16  #include "Finley.h"  #include "Finley.h"
17  #include "Util.h"  #include "Util.h"
18    #ifdef _OPENMP
19    #include <omp.h>
20    #endif
21    
22  /**************************************************************/  /**************************************************************/
23    
# Line 497  int Finley_Util_isAny(maybelong N,maybel Line 500  int Finley_Util_isAny(maybelong N,maybel
500     for (i=0;i<N;i++) out=out || (array[i]==value);     for (i=0;i<N;i++) out=out || (array[i]==value);
501     return out;     return out;
502  }  }
503    /* calculates the cummultative sum in array and returns the total sum */
504    maybelong Finley_Util_cumsum(maybelong N,maybelong* array) {
505       maybelong out=0,tmp,i;
506       #ifdef _OPENMP
507          maybelong partial_sums[omp_get_max_threads()],sum;
508          #pragma omp parallel private(sum,i,tmp)
509          {
510            sum=0;
511            #pragma omp for
512            for (i=0;i<N;++i) {
513              tmp=sum;
514              sum+=array[i];
515              array[i]=tmp;
516            }
517            #pragma omp critical
518            partial_sums[omp_get_thread_num()]=sum;
519            #pragma omp master
520            {
521              out=0;
522              for (i=0;i<omp_get_max_threads();++i) {
523                 tmp=out;
524                 out+=partial_sums[i];
525                 partial_sums[i]=tmp;
526               }
527            }
528            sum=partial_sums[omp_get_thread_num()];
529            #pragma omp for
530            for (i=0;i<N;++i) array[i]+=sum;
531          }
532       #else
533          for (i=0;i<N;++i) {
534             tmp=out;
535             out+=array[i];
536             array[i]=tmp;
537          }
538       #endif
539       return out;
540    }
541    
542  void Finley_copyDouble(int n,double* source, double* target) {  void Finley_copyDouble(int n,double* source, double* target) {
543    int i;    int i;
544    for (i=0;i<n;i++) target[i]=source[i];    for (i=0;i<n;i++) target[i]=source[i];
545  }  }
   
 /*  
  * $Log$  
  * Revision 1.2  2004/12/14 05:39:31  jgs  
  * *** empty log message ***  
  *  
  * Revision 1.1.1.1.2.1  2004/11/12 06:58:19  gross  
  * a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry  
  *  
  * Revision 1.1.1.1  2004/10/26 06:53:57  jgs  
  * initial import of project esys2  
  *  
  * Revision 1.3  2004/08/26 12:03:52  gross  
  * Some other bug in Finley_Assemble_gradient fixed.  
  *  
  * Revision 1.2  2004/07/02 04:21:13  gross  
  * Finley C code has been included  
  *  
  * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
  * Initial version of eys using boost-python.  
  *  
  *  
  */  

Legend:
Removed from v.97  
changed lines
  Added in v.113

  ViewVC Help
Powered by ViewVC 1.1.26