Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
kokkos
Stokhos_BlockCrsMatrix.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Stokhos Package
5
// Copyright (2009) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#ifndef STOKHOS_BLOCKCRSMATRIX_HPP
43
#define STOKHOS_BLOCKCRSMATRIX_HPP
44
45
#include "Kokkos_Core.hpp"
46
#include "Kokkos_StaticCrsGraph.hpp"
47
48
#include "
Stokhos_Multiply.hpp
"
49
50
namespace
Stokhos
{
51
60
template
<
typename
BlockSpec,
typename
ValueType,
class
Device>
61
class
BlockCrsMatrix
{
62
public
:
63
64
typedef
Device
execution_space
;
65
typedef
typename
execution_space::size_type
size_type
;
66
typedef
ValueType
value_type
;
67
typedef
BlockSpec
block_spec
;
68
typedef
Kokkos::StaticCrsGraph< size_type , execution_space >
graph_type
;
69
typedef
Kokkos::View< value_type**, Kokkos::LayoutLeft, execution_space >
block_vector_type
;
70
71
block_vector_type
values
;
72
graph_type
graph
;
73
block_spec
block
;
74
};
75
76
template
<
typename
BlockSpec,
77
typename
MatrixValue,
78
typename
VectorValue,
79
typename
Device>
80
class
Multiply
<
BlockCrsMatrix
< BlockSpec, MatrixValue, Device >,
81
Kokkos
::
View
< VectorValue**, Kokkos::LayoutLeft, Device >,
82
Kokkos::View< VectorValue**, Kokkos::LayoutLeft, Device > >
83
{
84
public
:
85
86
typedef
Device
execution_space
;
87
typedef
typename
BlockSpec::size_type
size_type
;
88
typedef
Kokkos::View< VectorValue**, Kokkos::LayoutLeft, Device >
block_vector_type
;
89
typedef
BlockCrsMatrix< BlockSpec, MatrixValue, Device >
matrix_type
;
90
91
const
matrix_type
m_A
;
92
const
block_vector_type
m_x
;
93
block_vector_type
m_y
;
94
95
Multiply
(
const
matrix_type
& A,
96
const
block_vector_type
& x,
97
block_vector_type
& y )
98
:
m_A
( A )
99
,
m_x
( x )
100
,
m_y
( y )
101
{}
102
103
//--------------------------------------------------------------------------
104
// A( storage_size( m_A.block.size() ) , m_A.graph.row_map.size() );
105
// x( m_A.block.dimension() , m_A.graph.row_map.first_count() );
106
// y( m_A.block.dimension() , m_A.graph.row_map.first_count() );
107
//
108
109
KOKKOS_INLINE_FUNCTION
110
void
operator()
(
const
size_type
iBlockRow )
const
111
{
112
// Prefer that y[ m_A.block.dimension() ] be scratch space
113
// on the local thread, but cannot dynamically allocate
114
VectorValue *
const
y = &
m_y
(0,iBlockRow);
115
116
const
size_type
iEntryBegin =
m_A
.graph.row_map[ iBlockRow ];
117
const
size_type
iEntryEnd =
m_A
.graph.row_map[ iBlockRow + 1 ];
118
119
// Leading dimension guaranteed contiguous for LayoutLeft
120
for
(
size_type
j
= 0 ;
j
<
m_A
.block.dimension() ; ++
j
) { y[
j
] = 0 ; }
121
122
for
(
size_type
iEntry = iEntryBegin ; iEntry < iEntryEnd ; ++iEntry ) {
123
const
VectorValue *
const
x = &
m_x
( 0 ,
m_A
.graph.entries(iEntry) );
124
const
MatrixValue *
const
a = &
m_A
.values( 0 , iEntry );
125
126
BlockMultiply< BlockSpec >::apply
(
m_A
.block , a , x , y );
127
}
128
129
}
130
131
static
void
apply
(
const
matrix_type
& A,
132
const
block_vector_type
& x,
133
block_vector_type
& y )
134
{
135
const
size_t
row_count = A.
graph
.row_map.extent(0) - 1;
136
Kokkos::parallel_for( row_count ,
Multiply
(A,x,y) );
137
}
138
};
139
140
//----------------------------------------------------------------------------
141
//----------------------------------------------------------------------------
142
143
}
// namespace Stokhos
144
145
#endif
/* #ifndef STOKHOS_BLOCKCRSMATRIX_HPP */
View
View
Definition
Kokkos_View_MP_Vector_Interlaced.hpp:180
j
j
Definition
Sacado_Fad_Exp_MP_Vector.hpp:527
Stokhos_Multiply.hpp
Stokhos::BlockCrsMatrix
CRS matrix of dense blocks.
Definition
Stokhos_BlockCrsMatrix.hpp:61
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::block_vector_type
Kokkos::View< value_type **, Kokkos::LayoutLeft, execution_space > block_vector_type
Definition
Stokhos_BlockCrsMatrix.hpp:69
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::graph_type
Kokkos::StaticCrsGraph< size_type, execution_space > graph_type
Definition
Stokhos_BlockCrsMatrix.hpp:68
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::values
block_vector_type values
Definition
Stokhos_BlockCrsMatrix.hpp:71
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::value_type
MatrixValue value_type
Definition
Stokhos_BlockCrsMatrix.hpp:66
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::block_spec
BlockSpec block_spec
Definition
Stokhos_BlockCrsMatrix.hpp:67
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::block
block_spec block
Definition
Stokhos_BlockCrsMatrix.hpp:73
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::graph
graph_type graph
Definition
Stokhos_BlockCrsMatrix.hpp:72
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::execution_space
execution_space execution_space
Definition
Stokhos_BlockCrsMatrix.hpp:64
Stokhos::BlockCrsMatrix< BlockSpec, MatrixValue, execution_space >::size_type
execution_space::size_type size_type
Definition
Stokhos_BlockCrsMatrix.hpp:65
Stokhos::BlockMultiply
Definition
Stokhos_Multiply.hpp:174
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::m_y
block_vector_type m_y
Definition
Stokhos_BlockCrsMatrix.hpp:93
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::size_type
BlockSpec::size_type size_type
Definition
Stokhos_BlockCrsMatrix.hpp:87
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::m_x
const block_vector_type m_x
Definition
Stokhos_BlockCrsMatrix.hpp:92
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::execution_space
Device execution_space
Definition
Stokhos_BlockCrsMatrix.hpp:86
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::matrix_type
BlockCrsMatrix< BlockSpec, MatrixValue, Device > matrix_type
Definition
Stokhos_BlockCrsMatrix.hpp:89
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::m_A
const matrix_type m_A
Definition
Stokhos_BlockCrsMatrix.hpp:91
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::apply
static void apply(const matrix_type &A, const block_vector_type &x, block_vector_type &y)
Definition
Stokhos_BlockCrsMatrix.hpp:131
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::Multiply
Multiply(const matrix_type &A, const block_vector_type &x, block_vector_type &y)
Definition
Stokhos_BlockCrsMatrix.hpp:95
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::operator()
KOKKOS_INLINE_FUNCTION void operator()(const size_type iBlockRow) const
Definition
Stokhos_BlockCrsMatrix.hpp:110
Stokhos::Multiply< BlockCrsMatrix< BlockSpec, MatrixValue, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device >, Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > >::block_vector_type
Kokkos::View< VectorValue **, Kokkos::LayoutLeft, Device > block_vector_type
Definition
Stokhos_BlockCrsMatrix.hpp:88
Kokkos
Definition
Stokhos_CrsMatrix.hpp:663
Stokhos
Top-level namespace for Stokhos classes and functions.
Definition
Stokhos_AbstractPreconditionerFactory.hpp:48
Generated by
1.17.0