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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (19 months, 1 week ago) by jfenwick
File MIME type: text/plain
File size: 3546 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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

  ViewVC Help
Powered by ViewVC 1.1.26