/[escript]/trunk/paso/src/Pattern.h
ViewVC logotype

Annotation of /trunk/paso/src/Pattern.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (hide annotations)
Mon Jan 20 03:37:18 2020 UTC (4 weeks, 1 day ago) by uqaeller
File MIME type: text/plain
File size: 3622 byte(s)
Updated the copyright header.


1 ksteube 1313
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 uqaeller 6939 * Copyright (c) 2003-2020 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13 uqaeller 6939 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14     * Development from 2019 by School of Earth and Environmental Sciences
15     **
16 jfenwick 3981 *****************************************************************************/
17 ksteube 1313
18 ksteube 1811
19 caltinay 4803 /****************************************************************************/
20 ksteube 1313
21 caltinay 4819 /* Paso: CSC/CSR sparse matrix pattern */
22 ksteube 1313
23 caltinay 4803 /****************************************************************************/
24 ksteube 1313
25 jfenwick 2608 /* Author: Lutz Gross, l.gross@uq.edu.au */
26 ksteube 1313
27 caltinay 4803 /****************************************************************************/
28 ksteube 1313
29 caltinay 4803 #ifndef __PASO_PATTERN_H__
30     #define __PASO_PATTERN_H__
31 ksteube 1313
32 gross 3312 #include "Paso.h"
33 ksteube 1313
34 caltinay 6001 #include <escript/IndexList.h>
35    
36 caltinay 4803 namespace paso {
37 ksteube 1313
38 caltinay 4819 struct Pattern;
39     typedef boost::shared_ptr<Pattern> Pattern_ptr;
40     typedef boost::shared_ptr<const Pattern> const_Pattern_ptr;
41    
42     struct Pattern : boost::enable_shared_from_this<Pattern>
43 caltinay 4803 {
44 caltinay 4819 Pattern(int type, dim_t numOutput, dim_t numInput, index_t* ptr,
45     index_t* index);
46    
47     ~Pattern();
48    
49     Pattern_ptr unrollBlocks(int newType, dim_t outputBlockSize,
50     dim_t inputBlockSize);
51    
52     Pattern_ptr getSubpattern(dim_t newNumRows, dim_t newNumCols,
53     const index_t* rowList,
54     const index_t* newColIndex) const;
55    
56     /// Searches for a maximal independent set MIS in the matrix pattern
57     void mis(index_t* mis_marker) const;
58    
59     void reduceBandwidth(index_t* oldToNew);
60    
61     Pattern_ptr multiply(int type, const_Pattern_ptr other) const;
62    
63     Pattern_ptr binop(int type, const_Pattern_ptr other) const;
64    
65     index_t* borrowMainDiagonalPointer();
66    
67     static Pattern_ptr fromIndexListArray(dim_t n0, dim_t n,
68 caltinay 6001 const escript::IndexList* index_list_array,
69 caltinay 4819 index_t range_min, index_t range_max, index_t index_offset);
70    
71     index_t* borrowColoringPointer();
72    
73     dim_t getBandwidth(index_t* label) const;
74    
75     inline bool isEmpty() const
76     {
77     return (!ptr && !index);
78     }
79    
80     inline dim_t getNumColors()
81     {
82     // make sure numColors is defined
83     borrowColoringPointer();
84     return numColors;
85     }
86    
87     inline dim_t maxDeg() const
88     {
89     dim_t deg = 0;
90     #pragma omp parallel
91     {
92     dim_t loc_deg=0;
93     #pragma omp for
94     for (dim_t i = 0; i < numInput; ++i) {
95 caltinay 4869 loc_deg=std::max(loc_deg, ptr[i+1]-ptr[i]);
96 caltinay 4819 }
97     #pragma omp critical
98     {
99 caltinay 4869 deg = std::max(deg, loc_deg);
100 caltinay 4819 }
101     }
102     return deg;
103     }
104    
105    
106 caltinay 4803 int type;
107     // Number of rows in the ptr array [CSR] / number of cols for CSC
108     dim_t numOutput;
109     // Number of cols [CSR]
110     dim_t numInput;
111     // number of non-zeros
112     dim_t len;
113     // ptr[n] to ptr[n+1] lists indices (in index) of non-zeros in row n
114     index_t* ptr;
115     // Non-major indices of non-zeros (in CSR this will be col numbers)
116     index_t* index;
117     // pointer to main diagonal entry
118 caltinay 4819 index_t* main_iptr;
119 caltinay 4803 // number of colors
120     dim_t numColors;
121     // coloring index: inputs with the same color are not connected
122     index_t* coloring;
123     };
124 ksteube 1313
125 phornby 2071
126 caltinay 4803 } // namespace paso
127 phornby 2071
128 caltinay 4803 #endif // __PASO_PATTERN_H__
129    

  ViewVC Help
Powered by ViewVC 1.1.26