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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 633 - (show annotations)
Thu Mar 23 05:37:00 2006 UTC (13 years, 5 months ago) by dhawcroft
File MIME type: text/plain
File size: 3032 byte(s)


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26