Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Kokkos_CrsArray.hpp
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Kokkos
6 // Manycore Performance-Portable Multidimensional Arrays
7 //
8 // Copyright (2012) Sandia Corporation
9 //
10 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
11 // the U.S. Government retains certain rights in this software.
12 //
13 // Redistribution and use in source and binary forms, with or without
14 // modification, are permitted provided that the following conditions are
15 // met:
16 //
17 // 1. Redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. Redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the name of the Corporation nor the names of the
25 // contributors may be used to endorse or promote products derived from
26 // this software without specific prior written permission.
27 //
28 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
29 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
32 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
35 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 //
40 // Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
41 //
42 // ************************************************************************
43 //@HEADER
44 */
45 
46 #ifndef KOKKOS_CRSARRAY_HPP
47 #define KOKKOS_CRSARRAY_HPP
48 
49 #include <string>
50 #include <vector>
51 
52 #include <Kokkos_View.hpp>
53 
54 namespace Kokkos {
55 
86 template< class DataType,
87  class Arg1Type,
88  class Arg2Type = void,
89  typename SizeType = typename ViewTraits<DataType*, Arg1Type, Arg2Type, void >::size_type>
90 class CrsArray {
91 private:
93 
94 public:
95  typedef DataType data_type;
96  typedef typename traits::array_layout array_layout;
97  typedef typename traits::execution_space execution_space ;
98  typedef typename traits::memory_space memory_space ;
99  typedef SizeType size_type;
100 
105 
106  entries_type entries;
107  row_map_type row_map;
108 
110  CrsArray () : entries(), row_map() {}
111 
113  CrsArray (const CrsArray& rhs) : entries (rhs.entries), row_map (rhs.row_map)
114  {}
115 
120  CrsArray& operator= (const CrsArray& rhs) {
121  entries = rhs.entries;
122  row_map = rhs.row_map;
123  return *this;
124  }
125 
130 };
131 
132 //----------------------------------------------------------------------------
133 
134 template< class CrsArrayType , class InputSizeType >
135 typename CrsArrayType::crsarray_type
136 create_crsarray( const std::string & label ,
137  const std::vector< InputSizeType > & input );
138 
139 template< class CrsArrayType , class InputSizeType >
140 typename CrsArrayType::crsarray_type
141 create_crsarray( const std::string & label ,
142  const std::vector< std::vector< InputSizeType > > & input );
143 
144 //----------------------------------------------------------------------------
145 
146 template< class DataType ,
147  class Arg1Type ,
148  class Arg2Type ,
149  typename SizeType >
150 typename CrsArray< DataType , Arg1Type , Arg2Type , SizeType >::HostMirror
151 create_mirror_view( const CrsArray<DataType,Arg1Type,Arg2Type,SizeType > & input );
152 
153 template< class DataType ,
154  class Arg1Type ,
155  class Arg2Type ,
156  typename SizeType >
157 typename CrsArray< DataType , Arg1Type , Arg2Type , SizeType >::HostMirror
158 create_mirror( const CrsArray<DataType,Arg1Type,Arg2Type,SizeType > & input );
159 
160 } // namespace Kokkos
161 
162 //----------------------------------------------------------------------------
163 //----------------------------------------------------------------------------
164 
165 #include <impl/Kokkos_CrsArray_factory.hpp>
166 
167 //----------------------------------------------------------------------------
168 //----------------------------------------------------------------------------
169 
170 #endif /* #ifndef KOKKOS_CRSARRAY_HPP */
171 
Compressed row storage array.
CrsArray(const CrsArray &rhs)
Copy constructor (shallow copy).
CrsArray()
Construct an empty view.
~CrsArray()
Destroy this view of the array. If the last view then allocated memory is deallocated.
Traits class for accessing attributes of a View.
CrsArray & operator=(const CrsArray &rhs)
Assign to a view of the rhs array. If the old view is the last view then allocated memory is dealloca...