escript  Revision_
Pattern.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 /****************************************************************************/
19 
20 /* Paso: CSC/CSR sparse matrix pattern */
21 
22 /****************************************************************************/
23 
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25 
26 /****************************************************************************/
27 
28 #ifndef __PASO_PATTERN_H__
29 #define __PASO_PATTERN_H__
30 
31 #include "Paso.h"
32 
33 #include <escript/IndexList.h>
34 
35 namespace paso {
36 
37 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 {
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 
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 
65 
66  static Pattern_ptr fromIndexListArray(dim_t n0, dim_t n,
67  const escript::IndexList* index_list_array,
68  index_t range_min, index_t range_max, index_t index_offset);
69 
71 
72  dim_t getBandwidth(index_t* label) const;
73 
74  inline bool isEmpty() const
75  {
76  return (!ptr && !index);
77  }
78 
80  {
81  // make sure numColors is defined
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  loc_deg=std::max(loc_deg, ptr[i+1]-ptr[i]);
95  }
96 #pragma omp critical
97  {
98  deg = std::max(deg, loc_deg);
99  }
100  }
101  return deg;
102  }
103 
104 
105  int type;
106  // Number of rows in the ptr array [CSR] / number of cols for CSC
108  // Number of cols [CSR]
110  // number of non-zeros
112  // ptr[n] to ptr[n+1] lists indices (in index) of non-zeros in row n
114  // Non-major indices of non-zeros (in CSR this will be col numbers)
116  // pointer to main diagonal entry
118  // number of colors
120  // coloring index: inputs with the same color are not connected
122 };
123 
124 
125 } // namespace paso
126 
127 #endif // __PASO_PATTERN_H__
128 
boost::shared_ptr< Pattern > Pattern_ptr
Definition: Pattern.h:37
dim_t numColors
Definition: Pattern.h:119
void mis(index_t *mis_marker) const
Searches for a maximal independent set MIS in the matrix pattern.
Definition: Pattern_mis.cpp:48
static Pattern_ptr fromIndexListArray(dim_t n0, dim_t n, const escript::IndexList *index_list_array, index_t range_min, index_t range_max, index_t index_offset)
Definition: Pattern.cpp:101
index_t * ptr
Definition: Pattern.h:113
Pattern_ptr binop(int type, const_Pattern_ptr other) const
Definition: Pattern.cpp:329
dim_t maxDeg() const
Definition: Pattern.h:86
Definition: Pattern.h:41
dim_t numOutput
Definition: Pattern.h:107
index_t * borrowColoringPointer()
Definition: Pattern.cpp:162
Definition: AMG.cpp:45
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:59
dim_t numInput
Definition: Pattern.h:109
boost::shared_ptr< const Pattern > const_Pattern_ptr
Definition: Pattern.h:39
void reduceBandwidth(index_t *oldToNew)
Definition: Pattern_reduceBandwidth.cpp:144
dim_t getNumColors()
Definition: Pattern.h:79
int type
Definition: Pattern.h:105
Pattern_ptr multiply(int type, const_Pattern_ptr other) const
Definition: Pattern.cpp:307
index_t * coloring
Definition: Pattern.h:121
~Pattern()
Definition: Pattern.cpp:92
index_t * borrowMainDiagonalPointer()
Definition: Pattern.cpp:135
Pattern(int type, dim_t numOutput, dim_t numInput, index_t *ptr, index_t *index)
Definition: Pattern.cpp:38
index_t * main_iptr
Definition: Pattern.h:117
bool isEmpty() const
Definition: Pattern.h:74
Definition: escriptcore/src/IndexList.h:28
dim_t len
Definition: Pattern.h:111
index_t * index
Definition: Pattern.h:115
Pattern_ptr unrollBlocks(int newType, dim_t outputBlockSize, dim_t inputBlockSize)
Definition: Pattern.cpp:245
dim_t getBandwidth(index_t *label) const
Definition: Pattern_reduceBandwidth.cpp:42
index_t dim_t
Definition: DataTypes.h:64
Pattern_ptr getSubpattern(dim_t newNumRows, dim_t newNumCols, const index_t *rowList, const index_t *newColIndex) const
Definition: Pattern.cpp:195