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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1883 - (hide annotations)
Tue Oct 14 04:46:27 2008 UTC (10 years, 11 months ago) by artak
File MIME type: text/plain
File size: 3336 byte(s)
< changed to >=
1 jfenwick 1851
2     /*******************************************************
3     *
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    
14    
15     /**********************************************************************/
16    
17     /* Paso: Pattern: Paso_Pattern_coupling
18    
19     searches for a maximal independent set MIS in the matrix pattern
20     vertices in the maximal independent set are marked in mis_marker
21     nodes to be considered are marked by -1 on the input in mis_marker
22    
23     */
24     /**********************************************************************/
25    
26     /* Copyrights by ACcESS Australia 2003,2004,2005 */
27     /* Author: artak@uq.edu.au */
28    
29     /**************************************************************/
30    
31     #include "mpi_C.h"
32     #include "Paso.h"
33     #include "PasoUtil.h"
34     #include "Pattern.h"
35     #include "Solver.h"
36    
37    
38     /***************************************************************/
39    
40     #define IS_AVAILABLE -1
41     #define IS_IN_MIS_NOW -2
42     #define IS_IN_MIS -3
43     #define IS_CONNECTED_TO_MIS -4
44    
45 artak 1882 void Paso_Pattern_coup(Paso_SparseMatrix* A, index_t* mis_marker) {
46 jfenwick 1851
47     index_t index_offset=(A->pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0);
48 artak 1881 dim_t i,j;
49 jfenwick 1851 double threshold=0.05;
50     index_t naib,iptr;
51     bool_t flag;
52     dim_t n=A->pattern->numOutput;
53     if (A->pattern->type & PATTERN_FORMAT_SYM) {
54     Paso_setError(TYPE_ERROR,"Paso_Pattern_mis: symmetric matrix pattern is not supported yet");
55     return;
56     }
57    
58     /* is there any vertex available ?*/
59     while (Paso_Util_isAny(n,mis_marker,IS_AVAILABLE)) {
60    
61     #pragma omp parallel for private(naib,i,iptr,flag) schedule(static)
62     for (i=0;i<n;++i) {
63     if (mis_marker[i]==IS_AVAILABLE) {
64 artak 1881 flag=IS_AVAILABLE;
65 jfenwick 1851 for (iptr=A->pattern->ptr[i]-index_offset;iptr<A->pattern->ptr[i+1]-index_offset; ++iptr) {
66     naib=A->pattern->index[iptr]-index_offset;
67 artak 1883 if (naib!=i && A->val[iptr]>=threshold*A->val[i]) {
68 artak 1881 flag=IS_IN_MIS;
69 jfenwick 1851 break;
70     }
71     }
72     mis_marker[i]=flag;
73     }
74     }
75    
76     #pragma omp parallel for private(naib,i,iptr) schedule(static)
77     for (i=0;i<n;i++) {
78     if (mis_marker[i]==IS_AVAILABLE) {
79     for (iptr=A->pattern->ptr[i]-index_offset;iptr<A->pattern->ptr[i+1]-index_offset; ++iptr) {
80     naib=A->pattern->index[iptr]-index_offset;
81 artak 1883 if (naib!=i && mis_marker[naib]==IS_IN_MIS && A->val[iptr]/A->val[i]>=-threshold){
82 artak 1881 mis_marker[i]=IS_IN_MIS;
83 artak 1883 }
84     else {
85 artak 1881 mis_marker[i]=IS_CONNECTED_TO_MIS;
86 artak 1883 }
87 jfenwick 1851 }
88     }
89     }
90     }
91     /* swap to TRUE/FALSE in mis_marker */
92     #pragma omp parallel for private(i) schedule(static)
93     for (i=0;i<n;i++) mis_marker[i]=(mis_marker[i]==IS_IN_MIS);
94     }
95     #undef IS_AVAILABLE
96     #undef IS_IN_MIS_NOW
97     #undef IS_IN_MIS
98     #undef IS_CONNECTED_TO_MIS

  ViewVC Help
Powered by ViewVC 1.1.26