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

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

Parent Directory Parent Directory | Revision Log Revision Log


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


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

  ViewVC Help
Powered by ViewVC 1.1.26