Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Kokkos_CrsArray.hpp
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 //
00005 //                             Kokkos
00006 //         Manycore Performance-Portable Multidimensional Arrays
00007 //
00008 //              Copyright (2012) Sandia Corporation
00009 // 
00010 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00011 // the U.S. Government retains certain rights in this software.
00012 // 
00013 // Redistribution and use in source and binary forms, with or without
00014 // modification, are permitted provided that the following conditions are
00015 // met:
00016 //
00017 // 1. Redistributions of source code must retain the above copyright
00018 // notice, this list of conditions and the following disclaimer.
00019 //
00020 // 2. Redistributions in binary form must reproduce the above copyright
00021 // notice, this list of conditions and the following disclaimer in the
00022 // documentation and/or other materials provided with the distribution.
00023 //
00024 // 3. Neither the name of the Corporation nor the names of the
00025 // contributors may be used to endorse or promote products derived from
00026 // this software without specific prior written permission.
00027 //
00028 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00029 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00031 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00032 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00033 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00034 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00035 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00036 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00037 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00038 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039 //
00040 // Questions?  Contact  H. Carter Edwards (hcedwar@sandia.gov)
00041 // 
00042 // ************************************************************************
00043 //@HEADER
00044 */
00045 
00046 #ifndef KOKKOS_CRSARRAY_HPP
00047 #define KOKKOS_CRSARRAY_HPP
00048 
00049 #include <string>
00050 #include <vector>
00051 
00052 #include <Kokkos_View.hpp>
00053 
00054 namespace Kokkos {
00055 
00086 template< class DataType,
00087           class Arg1Type,
00088           class Arg2Type = void,
00089           typename SizeType = typename ViewTraits<DataType*, Arg1Type, Arg2Type, void >::size_type>
00090 class CrsArray {
00091 private:
00092   typedef ViewTraits<DataType*, Arg1Type, Arg2Type, void> traits;
00093 
00094 public:
00095   typedef DataType                                            data_type;
00096   typedef typename traits::array_layout                       array_layout;
00097   typedef typename traits::device_type                        device_type;
00098   typedef SizeType                                            size_type;
00099 
00100   typedef CrsArray< DataType , Arg1Type , Arg2Type , SizeType > crsarray_type;
00101   typedef CrsArray< DataType , array_layout , typename device_type::host_mirror_device_type , SizeType > HostMirror;
00102   typedef View< const size_type* , array_layout, device_type >  row_map_type;
00103   typedef View<       DataType*  , array_layout, device_type >  entries_type;
00104 
00105   entries_type entries;
00106   row_map_type row_map;
00107 
00109   CrsArray () : entries(), row_map() {}
00110 
00112   CrsArray (const CrsArray& rhs) : entries (rhs.entries), row_map (rhs.row_map)
00113   {}
00114 
00119   CrsArray& operator= (const CrsArray& rhs) {
00120     entries = rhs.entries;
00121     row_map = rhs.row_map;
00122     return *this;
00123   }
00124 
00128   ~CrsArray() {}
00129 };
00130 
00131 //----------------------------------------------------------------------------
00132 
00133 template< class CrsArrayType , class InputSizeType >
00134 typename CrsArrayType::crsarray_type
00135 create_crsarray( const std::string & label ,
00136                  const std::vector< InputSizeType > & input );
00137 
00138 template< class CrsArrayType , class InputSizeType >
00139 typename CrsArrayType::crsarray_type
00140 create_crsarray( const std::string & label ,
00141                  const std::vector< std::vector< InputSizeType > > & input );
00142 
00143 //----------------------------------------------------------------------------
00144 
00145 template< class DataType ,
00146           class Arg1Type ,
00147           class Arg2Type ,
00148           typename SizeType >
00149 typename CrsArray< DataType , Arg1Type , Arg2Type , SizeType >::HostMirror
00150 create_mirror_view( const CrsArray<DataType,Arg1Type,Arg2Type,SizeType > & input );
00151 
00152 template< class DataType ,
00153           class Arg1Type ,
00154           class Arg2Type ,
00155           typename SizeType >
00156 typename CrsArray< DataType , Arg1Type , Arg2Type , SizeType >::HostMirror
00157 create_mirror( const CrsArray<DataType,Arg1Type,Arg2Type,SizeType > & input );
00158 
00159 } // namespace Kokkos
00160 
00161 //----------------------------------------------------------------------------
00162 //----------------------------------------------------------------------------
00163 
00164 #include <impl/Kokkos_CrsArray_factory.hpp>
00165 
00166 //----------------------------------------------------------------------------
00167 //----------------------------------------------------------------------------
00168 
00169 #endif /* #ifndef KOKKOS_CRSARRAY_HPP */
00170 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends