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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 969 - (hide annotations)
Tue Feb 13 23:02:23 2007 UTC (13 years ago) by ksteube
File MIME type: text/plain
File size: 5099 byte(s)
Parallelization using MPI for solution of implicit problems.

Parallelization for explicit problems has already been accomplished in
the main SVN branch.

This is incomplete and is not ready for use.


1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631 /*
4     ********************************************************************************
5 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
6 dhawcroft 631 * *
7     * http://www.access.edu.au *
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 jgs 150 /**************************************************************/
15    
16     /* Paso: SystemMatrixPatternPattern */
17    
18     /**************************************************************/
19    
20     /* Copyrights by ACcESS Australia 2003, 2004,2005 */
21     /* Author: gross@access.edu.au */
22    
23     /**************************************************************/
24    
25     #include "Paso.h"
26     #include "SystemMatrixPattern.h"
27    
28     /**************************************************************/
29    
30     /* allocates a SystemMatrixPattern */
31    
32 ksteube 969 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int type, int n_ptr, index_t* ptr,index_t* index, Paso_MPIInfo *mpi_info) {
33 jgs 150 Paso_SystemMatrixPattern*out;
34 gross 415 index_t index_offset=(type & PATTERN_FORMAT_OFFSET1 ? 1:0);
35     index_t loc_min_index,loc_max_index,min_index=index_offset,max_index=index_offset-1;
36 jgs 150 dim_t i;
37     Paso_resetError();
38    
39 gross 415 if (type & PATTERN_FORMAT_SYM) {
40     Paso_setError(TYPE_ERROR,"symmetric matrix pattern is not supported yet");
41     return NULL;
42     }
43 jgs 150 #pragma omp parallel private(loc_min_index,loc_max_index,i)
44 gross 415 {
45     loc_min_index=index_offset;
46     loc_max_index=index_offset-1;
47     if (type & PATTERN_FORMAT_OFFSET1) {
48     #pragma omp for schedule(static)
49     for (i=0;i<n_ptr;++i) {
50     if (ptr[i]<ptr[i+1]) {
51     qsort(&(index[ptr[i]-1]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
52     loc_min_index=MIN(loc_min_index,index[ptr[i]-1]);
53 gross 425 loc_max_index=MAX(loc_max_index,index[ptr[i+1]-2]);
54 gross 415 }
55 jgs 150 }
56 gross 415 } else {
57     #pragma omp for schedule(static)
58     for (i=0;i<n_ptr;++i) {
59     if (ptr[i]<ptr[i+1]) {
60 woo409 757 #ifdef USE_QSORTG
61     qsortG(&(index[ptr[i]]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
62     #else
63 gross 415 qsort(&(index[ptr[i]]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
64 woo409 757 #endif
65 gross 415 loc_min_index=MIN(loc_min_index,index[ptr[i]]);
66     loc_max_index=MAX(loc_max_index,index[ptr[i+1]-1]);
67     }
68     }
69     }
70     #pragma omp critical
71     {
72     min_index=MIN(loc_min_index,min_index);
73     max_index=MAX(loc_max_index,max_index);
74     }
75 jgs 150 }
76 gross 415 if (min_index<index_offset) {
77 jgs 150 Paso_setError(TYPE_ERROR,"Matrix pattern index out of range.");
78     return NULL;
79     }
80    
81     out=MEMALLOC(1,Paso_SystemMatrixPattern);
82     if (Paso_checkPtr(out)) return NULL;
83     out->n_ptr=n_ptr;
84 gross 425 out->n_index=max_index-index_offset+1;
85 jgs 150 out->ptr=ptr;
86     out->index=index;
87 gross 425 out->len=out->ptr[out->n_ptr]-index_offset;
88 jgs 150 out->reference_counter=1;
89 gross 415 out->type=type;
90 ksteube 969 out->MPIInfo = Paso_MPIInfo_getReference(mpi_info);
91     out->numLocal = n_ptr;
92     printf("ksteube Paso_SystemMatrixPattern_alloc cpu=%d numLocal=%d\n", mpi_info->rank, n_ptr);
93 jgs 150 #ifdef Paso_TRACE
94     printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");
95     #endif
96     return out;
97     }
98    
99     /* returns a reference to in */
100    
101     Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_reference(Paso_SystemMatrixPattern* in) {
102     if (in!=NULL) {
103     ++(in->reference_counter);
104     }
105     return in;
106     }
107    
108     /* deallocates a SystemMatrixPattern: */
109    
110     void Paso_SystemMatrixPattern_dealloc(Paso_SystemMatrixPattern* in) {
111     if (in!=NULL) {
112     in->reference_counter--;
113     if (in->reference_counter<=0) {
114     MEMFREE(in->ptr);
115     MEMFREE(in->index);
116     MEMFREE(in);
117     #ifdef Paso_TRACE
118     printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been deallocated.\n");
119     #endif
120     }
121     }
122     }
123     /* *************************************************************/
124    
125     /* some routines which help to get the matrix pattern from elements: */
126    
127     /* this routine is used by qsort called in Paso_SystemMatrixPattern_alloc */
128    
129     int Paso_comparIndex(const void *index1,const void *index2){
130     index_t Iindex1,Iindex2;
131     Iindex1=*(index_t*)index1;
132     Iindex2=*(index_t*)index2;
133     if (Iindex1<Iindex2) {
134     return -1;
135     } else {
136     if (Iindex1>Iindex2) {
137     return 1;
138     } else {
139     return 0;
140     }
141     }
142     }
143     /*
144     * $Log$
145     * Revision 1.2 2005/09/15 03:44:38 jgs
146     * Merge of development branch dev-02 back to main trunk on 2005-09-15
147     *
148     * Revision 1.1.2.1 2005/09/05 06:29:47 gross
149     * These files have been extracted from finley to define a stand alone libray for iterative
150     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
151     * has not been tested yet.
152     *
153     *
154     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26