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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (8 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 2931 byte(s)
Merging dudley and scons updates from branches

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* Paso: system matrix pattern */
18
19 /**************************************************************/
20
21 /* Author: Lutz Gross, l.gross@uq.edu.au */
22
23 /**************************************************************/
24
25 #include "Distribution.h"
26 #include "esysUtils/error.h" /* For checkPtr */
27
28 Paso_Distribution* Paso_Distribution_alloc( Esys_MPIInfo *mpi_info,
29 index_t *first_component,
30 index_t m, index_t b)
31 {
32 int i;
33 Paso_Distribution *out=NULL;
34 out = MEMALLOC( 1, Paso_Distribution );
35 if (Esys_checkPtr(out)) return NULL;
36 out->mpi_info = Esys_MPIInfo_getReference(mpi_info);
37 out->reference_counter = 0;
38 out->first_component=NULL;
39
40 out->first_component = MEMALLOC( (mpi_info->size)+1, index_t );
41 if (Esys_checkPtr(out->first_component)) {
42 Paso_Distribution_free(out);
43 return NULL;
44 }
45 for (i=0; i<(mpi_info->size)+1; ++i) out->first_component[i]=m*first_component[i]+b;
46 out->reference_counter++;
47 return out;
48 }
49
50 void Paso_Distribution_free( Paso_Distribution *in )
51 {
52 if (in != NULL) {
53 --(in->reference_counter);
54 if (in->reference_counter<=0) {
55 Esys_MPIInfo_free( in->mpi_info );
56 MEMFREE( in->first_component );
57 MEMFREE( in );
58 }
59 }
60 }
61
62 Paso_Distribution* Paso_Distribution_getReference( Paso_Distribution *in )
63 {
64 if ( in != NULL)
65 in->reference_counter++;
66 return in;
67 }
68
69 index_t Paso_Distribution_getFirstComponent(Paso_Distribution *in ) {
70 if (in !=NULL) {
71 return in->first_component[in->mpi_info->rank];
72 } else {
73 return 0;
74 }
75 }
76 index_t Paso_Distribution_getLastComponent(Paso_Distribution *in ){
77 if (in !=NULL) {
78 return in->first_component[(in->mpi_info->rank)+1];
79 } else {
80 return 0;
81 }
82 }
83
84 dim_t Paso_Distribution_getGlobalNumComponents(Paso_Distribution *in ){
85 return Paso_Distribution_getMaxGlobalComponents(in)-Paso_Distribution_getMinGlobalComponents(in);
86 }
87 dim_t Paso_Distribution_getMyNumComponents(Paso_Distribution *in ) {
88 return Paso_Distribution_getLastComponent(in)-Paso_Distribution_getFirstComponent(in);
89 }
90
91 dim_t Paso_Distribution_getMinGlobalComponents(Paso_Distribution *in ){
92 if (in !=NULL) {
93 return in->first_component[0];
94 } else {
95 return 0;
96 }
97 }
98 dim_t Paso_Distribution_getMaxGlobalComponents(Paso_Distribution *in ){
99 if (in !=NULL) {
100 return in->first_component[in->mpi_info->size];
101 } else {
102 return 0;
103 }
104 }
105

  ViewVC Help
Powered by ViewVC 1.1.26