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

Contents of /trunk-mpi-branch/paso/src/Distribution.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1090 - (show annotations)
Thu Apr 12 23:26:13 2007 UTC (12 years, 6 months ago) by gross
File MIME type: text/plain
File size: 2576 byte(s)
and another missing file
1 /*
2 ********************************************************************************
3 * Copyright 2006,2007 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 ********************************************************************************
10 */
11
12 /**************************************************************/
13
14 /* Paso: system matrix pattern */
15
16 /**************************************************************/
17
18 /* Copyrights by ACcESS Australia 2004,2005,2007 */
19 /* Author: gross@access.edu.au */
20
21 /**************************************************************/
22
23 #include "Distribution.h"
24
25 Paso_Distribution* Paso_Distribution_alloc( Paso_MPIInfo *mpi_info,
26 index_t *first_component,
27 index_t m, index_t b)
28 {
29 int i;
30 Paso_Distribution *out=NULL;
31 out = MEMALLOC( 1, Paso_Distribution );
32 if (Paso_checkPtr(out)) return NULL;
33 out->mpi_info = Paso_MPIInfo_getReference(mpi_info);
34 out->reference_counter = 0;
35 out->first_component=NULL;
36
37 out->first_component = MEMALLOC( (mpi_info->size)+1, index_t );
38 if (Paso_checkPtr(out->first_component)) {
39 Paso_Distribution_free(out);
40 return NULL;
41 }
42 for (i=0; i<(mpi_info->size)+1; ++i) out->first_component[i]=m*first_component[i]+b;
43 out->reference_counter++;
44 out->numComponents=first_component[mpi_info->size]-first_component[0];
45 out->firstComponent=first_component[0];
46 out->myNumComponents=first_component[(mpi_info->rank)+1]-first_component[mpi_info->rank];
47 out->maxNumComponents=out->myNumComponents;
48 for (i=0; i< mpi_info->size; ++i) out->maxNumComponents=MAX(out->maxNumComponents,first_component[i+1]-first_component[i]);
49 out->myFirstComponent=first_component[mpi_info->rank];
50 return out;
51 }
52
53 void Paso_Distribution_free( Paso_Distribution *in )
54 {
55 index_t i;
56
57 if ( in && !(--in->reference_counter) )
58 {
59 Paso_MPIInfo_dealloc( in->mpi_info );
60 MEMFREE( in->first_component );
61 MEMFREE( in );
62 }
63 }
64
65 Paso_Distribution* Paso_Distribution_getReference( Paso_Distribution *in )
66 {
67 if ( in )
68 in->reference_counter++;
69
70 return in;
71 }

  ViewVC Help
Powered by ViewVC 1.1.26