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

Annotation of /trunk/paso/src/PasoUtil.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1384 - (hide annotations)
Fri Jan 11 02:29:38 2008 UTC (11 years, 4 months ago) by phornby
Original Path: temp_trunk_copy/paso/src/PasoUtil.c
File MIME type: text/plain
File size: 2814 byte(s)
Make a temp copy of the trunk before checking in the windows changes


1 ksteube 1312
2 jgs 150 /* $Id$ */
3    
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15 dhawcroft 631
16 jgs 150 /**************************************************************/
17    
18     /* Some utility routines: */
19    
20     /**************************************************************/
21    
22     /* Copyrights by ACcESS Australia, 2003,2004,2005 */
23    
24     /**************************************************************/
25    
26     #include "Common.h"
27 jgs 482 #include "PasoUtil.h"
28 jgs 150 #ifdef _OPENMP
29     #include <omp.h>
30     #endif
31    
32     /* returns true if array contains value */
33     bool_t Paso_Util_isAny(dim_t N,index_t* array,index_t value) {
34     bool_t out=FALSE;
35     dim_t i;
36     #pragma omp parallel for private(i) schedule(static) reduction(||:out)
37     for (i=0;i<N;i++) out = out || (array[i]==value);
38     return out;
39     }
40    
41    
42     /* copies source to taget: */
43     void Paso_copyDouble(dim_t n,double* source, double* target) {
44     dim_t i;
45     for (i=0;i<n;i++) target[i]=source[i];
46     }
47    
48     /**************************************************************/
49    
50     /* calculates the cummultative sum in array and returns the total sum */
51    
52     /**************************************************************/
53     index_t Paso_Util_cumsum(dim_t N,index_t* array) {
54     index_t out=0,tmp;
55     dim_t i;
56     #ifdef _OPENMP
57     index_t partial_sums[omp_get_max_threads()],sum;
58     #pragma omp parallel private(sum,i,tmp)
59     {
60     sum=0;
61     #pragma omp for schedule(static)
62     for (i=0;i<N;++i) sum+=array[i];
63     partial_sums[omp_get_thread_num()]=sum;
64     #pragma omp barrier
65     #pragma omp master
66     {
67     out=0;
68     for (i=0;i<omp_get_max_threads();++i) {
69     tmp=out;
70     out+=partial_sums[i];
71     partial_sums[i]=tmp;
72     }
73     }
74     #pragma omp barrier
75     sum=partial_sums[omp_get_thread_num()];
76     #pragma omp for schedule(static)
77     for (i=0;i<N;++i) {
78     tmp=sum;
79     sum+=array[i];
80     array[i]=tmp;
81     }
82     }
83     #else
84     for (i=0;i<N;++i) {
85     tmp=out;
86     out+=array[i];
87     array[i]=tmp;
88     }
89     #endif
90     return out;
91     }
92    
93     /*
94     * $Log$
95     * Revision 1.2 2005/09/15 03:44:39 jgs
96     * Merge of development branch dev-02 back to main trunk on 2005-09-15
97     *
98     * Revision 1.1.2.1 2005/09/05 06:29:48 gross
99     * These files have been extracted from finley to define a stand alone libray for iterative
100     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
101     * has not been tested yet.
102     *
103     *
104     */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26