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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 4 months ago) by ksteube
File MIME type: text/plain
File size: 2872 byte(s)
Copyright updated in all files

1 ksteube 1310
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 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 ksteube 1310
14 ksteube 1811
15 ksteube 1310 /**************************************************************/
16    
17     /* Paso: system matrix pattern */
18    
19     /**************************************************************/
20    
21     /* Author: gross@access.edu.au */
22    
23     /**************************************************************/
24    
25     #include "Distribution.h"
26    
27     Paso_Distribution* Paso_Distribution_alloc( Paso_MPIInfo *mpi_info,
28     index_t *first_component,
29     index_t m, index_t b)
30     {
31     int i;
32     Paso_Distribution *out=NULL;
33     out = MEMALLOC( 1, Paso_Distribution );
34     if (Paso_checkPtr(out)) return NULL;
35     out->mpi_info = Paso_MPIInfo_getReference(mpi_info);
36     out->reference_counter = 0;
37     out->first_component=NULL;
38    
39     out->first_component = MEMALLOC( (mpi_info->size)+1, index_t );
40     if (Paso_checkPtr(out->first_component)) {
41     Paso_Distribution_free(out);
42     return NULL;
43     }
44     for (i=0; i<(mpi_info->size)+1; ++i) out->first_component[i]=m*first_component[i]+b;
45     out->reference_counter++;
46     return out;
47     }
48    
49     void Paso_Distribution_free( Paso_Distribution *in )
50     {
51     if (in != NULL) {
52     --(in->reference_counter);
53     if (in->reference_counter<=0) {
54     Paso_MPIInfo_free( in->mpi_info );
55     MEMFREE( in->first_component );
56     MEMFREE( in );
57     }
58     }
59     }
60    
61     Paso_Distribution* Paso_Distribution_getReference( Paso_Distribution *in )
62     {
63     if ( in != NULL)
64     in->reference_counter++;
65     return in;
66     }
67    
68     index_t Paso_Distribution_getFirstComponent(Paso_Distribution *in ) {
69     if (in !=NULL) {
70     return in->first_component[in->mpi_info->rank];
71     } else {
72     return 0;
73     }
74     }
75     index_t Paso_Distribution_getLastComponent(Paso_Distribution *in ){
76     if (in !=NULL) {
77     return in->first_component[(in->mpi_info->rank)+1];
78     } else {
79     return 0;
80     }
81     }
82    
83     dim_t Paso_Distribution_getGlobalNumComponents(Paso_Distribution *in ){
84     return Paso_Distribution_getMaxGlobalComponents(in)-Paso_Distribution_getMinGlobalComponents(in);
85     }
86     dim_t Paso_Distribution_getMyNumComponents(Paso_Distribution *in ) {
87     return Paso_Distribution_getLastComponent(in)-Paso_Distribution_getFirstComponent(in);
88     }
89    
90     dim_t Paso_Distribution_getMinGlobalComponents(Paso_Distribution *in ){
91     if (in !=NULL) {
92     return in->first_component[0];
93     } else {
94     return 0;
95     }
96     }
97     dim_t Paso_Distribution_getMaxGlobalComponents(Paso_Distribution *in ){
98     if (in !=NULL) {
99     return in->first_component[in->mpi_info->size];
100     } else {
101     return 0;
102     }
103     }
104    

  ViewVC Help
Powered by ViewVC 1.1.26