Pattern.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2017 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014 by Centre for Geoscience Computing (GeoComp)
*
*****************************************************************************/
/****************************************************************************/
/* Paso: CSC/CSR sparse matrix pattern */
/****************************************************************************/
/* Author: Lutz Gross, l.gross@uq.edu.au */
/****************************************************************************/
#ifndef __PASO_PATTERN_H__
#define __PASO_PATTERN_H__
#include "Paso.h"
#include <escript/IndexList.h>
namespace paso {
struct Pattern;
typedef boost::shared_ptr<Pattern> Pattern_ptr;
typedef boost::shared_ptr<const Pattern> const_Pattern_ptr;
struct Pattern : boost::enable_shared_from_this<Pattern>
{
Pattern(int type, dim_t numOutput, dim_t numInput, index_t* ptr,
index_t* index);
~Pattern();
Pattern_ptr unrollBlocks(int newType, dim_t outputBlockSize,
dim_t inputBlockSize);
Pattern_ptr getSubpattern(dim_t newNumRows, dim_t newNumCols,
const index_t* rowList,
const index_t* newColIndex) const;
void mis(index_t* mis_marker) const;
void reduceBandwidth(index_t* oldToNew);
Pattern_ptr multiply(int type, const_Pattern_ptr other) const;
Pattern_ptr binop(int type, const_Pattern_ptr other) const;
index_t* borrowMainDiagonalPointer();
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);
index_t* borrowColoringPointer();
dim_t getBandwidth(index_t* label) const;
inline bool isEmpty() const
{
return (!ptr && !index);
}
inline dim_t getNumColors()
{
// make sure numColors is defined
borrowColoringPointer();
return numColors;
}
inline dim_t maxDeg() const
{
dim_t deg = 0;
#pragma omp parallel
{
dim_t loc_deg=0;
#pragma omp for
for (dim_t i = 0; i < numInput; ++i) {
loc_deg=std::max(loc_deg, ptr[i+1]-ptr[i]);
}
#pragma omp critical
{
deg = std::max(deg, loc_deg);
}
}
return deg;
}
int type;
// Number of rows in the ptr array [CSR] / number of cols for CSC
dim_t numOutput;
// Number of cols [CSR]
dim_t numInput;
// number of non-zeros
dim_t len;
// ptr[n] to ptr[n+1] lists indices (in index) of non-zeros in row n
index_t* ptr;
// Non-major indices of non-zeros (in CSR this will be col numbers)
index_t* index;
// pointer to main diagonal entry
index_t* main_iptr;
// number of colors
dim_t numColors;
// coloring index: inputs with the same color are not connected
index_t* coloring;
};
} // namespace paso
#endif // __PASO_PATTERN_H__
Paso.h
paso::Pattern_ptr
boost::shared_ptr< Pattern > Pattern_ptr
Definition: Pattern.h:37
paso::Pattern::numColors
dim_t numColors
Definition: Pattern.h:119
paso::Pattern::mis
void mis(index_t *mis_marker) const
Searches for a maximal independent set MIS in the matrix pattern.
Definition: Pattern_mis.cpp:48
paso::Pattern::fromIndexListArray
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
paso::Pattern::ptr
index_t * ptr
Definition: Pattern.h:113
paso::Pattern::binop
Pattern_ptr binop(int type, const_Pattern_ptr other) const
Definition: Pattern.cpp:329
paso::Pattern::maxDeg
dim_t maxDeg() const
Definition: Pattern.h:86
paso::Pattern
Definition: Pattern.h:41
paso::Pattern::numOutput
dim_t numOutput
Definition: Pattern.h:107
paso::Pattern::borrowColoringPointer
index_t * borrowColoringPointer()
Definition: Pattern.cpp:162
paso
Definition: AMG.cpp:45
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:59
paso::Pattern::numInput
dim_t numInput
Definition: Pattern.h:109
paso::const_Pattern_ptr
boost::shared_ptr< const Pattern > const_Pattern_ptr
Definition: Pattern.h:39
paso::Pattern::reduceBandwidth
void reduceBandwidth(index_t *oldToNew)
Definition: Pattern_reduceBandwidth.cpp:144
paso::Pattern::getNumColors
dim_t getNumColors()
Definition: Pattern.h:79
paso::Pattern::type
int type
Definition: Pattern.h:105
paso::Pattern::multiply
Pattern_ptr multiply(int type, const_Pattern_ptr other) const
Definition: Pattern.cpp:307
paso::Pattern::coloring
index_t * coloring
Definition: Pattern.h:121
paso::Pattern::~Pattern
~Pattern()
Definition: Pattern.cpp:92
paso::Pattern::borrowMainDiagonalPointer
index_t * borrowMainDiagonalPointer()
Definition: Pattern.cpp:135
paso::Pattern::Pattern
Pattern(int type, dim_t numOutput, dim_t numInput, index_t *ptr, index_t *index)
Definition: Pattern.cpp:38
paso::Pattern::main_iptr
index_t * main_iptr
Definition: Pattern.h:117
paso::Pattern::isEmpty
bool isEmpty() const
Definition: Pattern.h:74
escript::IndexList
Definition: escriptcore/src/IndexList.h:28
paso::Pattern::len
dim_t len
Definition: Pattern.h:111
paso::Pattern::index
index_t * index
Definition: Pattern.h:115
paso::Pattern::unrollBlocks
Pattern_ptr unrollBlocks(int newType, dim_t outputBlockSize, dim_t inputBlockSize)
Definition: Pattern.cpp:245
paso::Pattern::getBandwidth
dim_t getBandwidth(index_t *label) const
Definition: Pattern_reduceBandwidth.cpp:42
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:64
paso::Pattern::getSubpattern
Pattern_ptr getSubpattern(dim_t newNumRows, dim_t newNumCols, const index_t *rowList, const index_t *newColIndex) const
Definition: Pattern.cpp:195