/[escript]/branches/intelc_win32/paso/src/SystemMatrixPattern.c
ViewVC logotype

Contents of /branches/intelc_win32/paso/src/SystemMatrixPattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 752 - (show annotations)
Mon Jun 26 02:25:41 2006 UTC (13 years, 2 months ago) by woo409
File MIME type: text/plain
File size: 4770 byte(s)
+ Added a qsort.c file which contains a drop in replacement for qsort (call it as qsortG). This one appears to be a stable implementation and the test .msh files on windows have been set up to be the same as unix again except for the exponent digits (3 instead of 2).
With ALL the qsorts replaced with qsortG only two tests fail now on win32:
test_normal_onFunctionOnContactOne
test_normal_onFunctionOnContactZero

Both give wrong result errors.

I will check this same code on the altix (including the use of qsortG and see if Altix has the same problem.
1 /* $Id$ */
2
3 /*
4 ********************************************************************************
5 * Copyright 2006 by ACcESS MNRF *
6 * *
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 /**************************************************************/
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 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int type, int n_ptr, index_t* ptr,index_t* index) {
33 Paso_SystemMatrixPattern*out;
34 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 dim_t i;
37 Paso_resetError();
38
39 if (type & PATTERN_FORMAT_SYM) {
40 Paso_setError(TYPE_ERROR,"symmetric matrix pattern is not supported yet");
41 return NULL;
42 }
43 #pragma omp parallel private(loc_min_index,loc_max_index,i)
44 {
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 qsortG(&(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 loc_max_index=MAX(loc_max_index,index[ptr[i+1]-2]);
54 }
55 }
56 } else {
57 #pragma omp for schedule(static)
58 for (i=0;i<n_ptr;++i) {
59 if (ptr[i]<ptr[i+1]) {
60 qsortG(&(index[ptr[i]]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
61 loc_min_index=MIN(loc_min_index,index[ptr[i]]);
62 loc_max_index=MAX(loc_max_index,index[ptr[i+1]-1]);
63 }
64 }
65 }
66 #pragma omp critical
67 {
68 min_index=MIN(loc_min_index,min_index);
69 max_index=MAX(loc_max_index,max_index);
70 }
71 }
72 if (min_index<index_offset) {
73 Paso_setError(TYPE_ERROR,"Matrix pattern index out of range.");
74 return NULL;
75 }
76
77 out=MEMALLOC(1,Paso_SystemMatrixPattern);
78 if (Paso_checkPtr(out)) return NULL;
79 out->n_ptr=n_ptr;
80 out->n_index=max_index-index_offset+1;
81 out->ptr=ptr;
82 out->index=index;
83 out->len=out->ptr[out->n_ptr]-index_offset;
84 out->reference_counter=1;
85 out->type=type;
86 #ifdef Paso_TRACE
87 printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");
88 #endif
89 return out;
90 }
91
92 /* returns a reference to in */
93
94 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_reference(Paso_SystemMatrixPattern* in) {
95 if (in!=NULL) {
96 ++(in->reference_counter);
97 }
98 return in;
99 }
100
101 /* deallocates a SystemMatrixPattern: */
102
103 void Paso_SystemMatrixPattern_dealloc(Paso_SystemMatrixPattern* in) {
104 if (in!=NULL) {
105 in->reference_counter--;
106 if (in->reference_counter<=0) {
107 MEMFREE(in->ptr);
108 MEMFREE(in->index);
109 MEMFREE(in);
110 #ifdef Paso_TRACE
111 printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been deallocated.\n");
112 #endif
113 }
114 }
115 }
116 /* *************************************************************/
117
118 /* some routines which help to get the matrix pattern from elements: */
119
120 /* this routine is used by qsort called in Paso_SystemMatrixPattern_alloc */
121
122 int Paso_comparIndex(const void *index1,const void *index2){
123 index_t Iindex1,Iindex2;
124 Iindex1=*(index_t*)index1;
125 Iindex2=*(index_t*)index2;
126 if (Iindex1<Iindex2) {
127 return -1;
128 } else {
129 if (Iindex1>Iindex2) {
130 return 1;
131 } else {
132 return 0;
133 }
134 }
135 }
136 /*
137 * $Log$
138 * Revision 1.2 2005/09/15 03:44:38 jgs
139 * Merge of development branch dev-02 back to main trunk on 2005-09-15
140 *
141 * Revision 1.1.2.1 2005/09/05 06:29:47 gross
142 * These files have been extracted from finley to define a stand alone libray for iterative
143 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
144 * has not been tested yet.
145 *
146 *
147 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26