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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1851 - (show annotations)
Mon Oct 6 03:16:43 2008 UTC (10 years, 11 months ago) by jfenwick
Original Path: branches/more_shared_ptrs_from_1812/paso/src/Pattern_coupling.c
File MIME type: text/plain
File size: 3257 byte(s)
Branch commit.
Added files while the merge op did not add.
Modified shake59 config for non-ken users.

1
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 void Paso_Pattern_cop(Paso_SparseMatrix* A, index_t* mis_marker) {
46
47 index_t index_offset=(A->pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0);
48 dim_t i;
49 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 flag=IS_IN_MIS_NOW;
65 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 if (naib!=i && A->val[naib]<threshold*A->val[i]) {
68 flag=IS_AVAILABLE;
69 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 if (naib!=i && mis_marker[i]==IS_IN_MIS_NOW && A->val[naib]/A->val[i]>=-threshold)
82 mis_marker[naib]=IS_IN_MIS;
83 }
84 mis_marker[i]=IS_CONNECTED_TO_MIS;
85 }
86 }
87 }
88 /* swap to TRUE/FALSE in mis_marker */
89 #pragma omp parallel for private(i) schedule(static)
90 for (i=0;i<n;i++) mis_marker[i]=(mis_marker[i]==IS_IN_MIS);
91 }
92 #undef IS_AVAILABLE
93 #undef IS_IN_MIS_NOW
94 #undef IS_IN_MIS
95 #undef IS_CONNECTED_TO_MIS

  ViewVC Help
Powered by ViewVC 1.1.26