LAMA
/home/brandes/workspace/LAMA/src/lama/StorageIO.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_STORAGE_IO_HPP_
00034 #define LAMA_STORAGE_IO_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // others
00040 #include <lama/LAMAArray.hpp>
00041 #include <lama/io/FileType.hpp>
00042 
00043 #include <fstream>
00044 
00045 namespace lama
00046 {
00047 
00048 /* -------------------------------------------------------------------------- */
00049 
00058 class LAMA_DLL_IMPORTEXPORT _StorageIO 
00059 {
00060 public:
00061 
00075     static void writeCSRHeader( const IndexType numRows,
00076                                 const IndexType numValues,
00077                                 const File::FileType& fileType,
00078                                 const std::string& fileName,
00079                                 const PartitionId size,
00080                                 const PartitionId rank );
00081 
00082     static void readCSRHeader( IndexType& numRows,
00083                                IndexType& numColumns,
00084                                IndexType& numValues,
00085                                PartitionId& size,
00086                                PartitionId& rank,
00087                                File::FileType& fileType,
00088                                const std::string& fileName );
00089 
00090     static size_t getIndexDataTypeSize( const File::IndexDataType indexDataType );
00091 
00092 protected:
00093 
00094     LAMA_LOG_DECL_STATIC_LOGGER( logger );  
00095 
00096 private:
00097 
00098     static const int mIversion;
00099 };
00100 
00101 template<typename T>
00102 class LAMA_DLL_IMPORTEXPORT StorageIO : public _StorageIO
00103 {
00104 public:
00105 
00106     typedef T ValueType;    
00107 
00120     static void writeCSRToFile( const PartitionId size,
00121                                 const PartitionId rank,
00122                                 const LAMAArray<IndexType>& csrIA,
00123                                 const IndexType numColumns,
00124                                 const LAMAArray<IndexType>& csrJA,
00125                                 const LAMAArray<ValueType>& csrValues,
00126                                 const std::string& fileName,
00127                                 const File::FileType& fileType,
00128                                 const File::DataType& dataType,
00129                                 const File::IndexDataType indexDataTypeIA /*=LONG*/,
00130                                 const File::IndexDataType indexDataTypeJA /*=LONG*/
00131                               );
00132 
00133     static void writeCSRToFormattedFile( const LAMAArray<IndexType>& csrIA,
00134                                          const LAMAArray<IndexType>& csrJA,
00135                                          const LAMAArray<ValueType>& csrValues,
00136                                          const std::string& fileName );
00137 
00138     static void writeCSRToBinaryFile( const LAMAArray<IndexType>& csrIA,
00139                                       const LAMAArray<IndexType>& csrJA,
00140                                       const LAMAArray<ValueType>& csrValues,
00141                                       const std::string& fileName,
00142                                       const long indexDataTypeSizeIA,
00143                                       const long indexDataTypeSizeJA,
00144                                       const long dataTypeSize );
00145 
00146     static void writeCSRToXDRFile( const LAMAArray<IndexType>& csrIA,
00147                                    const LAMAArray<IndexType>& csrJA,
00148                                    const LAMAArray<ValueType>& csrValues,
00149                                    const std::string& fileName,
00150                                    const long indexDataTypeSizeIA,
00151                                    const long indexDataTypeSizeJA,
00152                                    const long dataTypeSize );
00153 
00154     static void writeCSRToMMFile( const LAMAArray<IndexType>& csrIA,
00155                                   const IndexType numColumns,
00156                                   const LAMAArray<IndexType>& csrJA,
00157                                   const LAMAArray<ValueType>& csrValues,
00158                                   const std::string& fileName,
00159                                   const File::DataType& dataType );
00160 
00161     static void readCSRFromFile( LAMAArray<IndexType>& csrIA,
00162                                  IndexType& numColumns,
00163                                  LAMAArray<IndexType>& csrJA,
00164                                  LAMAArray<ValueType>& csrValues,
00165                      const std::string& fileName );
00166 
00167     static void readCSRFromFormattedFile( LAMAArray<IndexType>& csrIA,
00168                                           LAMAArray<IndexType>& csrJA,
00169                                           LAMAArray<ValueType>& csrValues,
00170                           const std::string& fileName,
00171                           const IndexType numRows );
00172 
00179     static void readCSRFromBinaryFile( LAMAArray<IndexType>& csrIA,
00180                                        LAMAArray<IndexType>& csrJA,
00181                                        LAMAArray<ValueType>& csrValues,
00182                        const std::string& fileName,
00183                        const IndexType numRows );
00184 
00185     static void readCSRFromXDRFile( LAMAArray<IndexType>& csrIA,
00186                                     LAMAArray<IndexType>& csrJA,
00187                                     LAMAArray<ValueType>& csrValues,
00188                                     const std::string& fileName,
00189                                     const IndexType numRows );
00190 
00191     static void readCSRFromMMFile( LAMAArray<IndexType>& csrIA,
00192                                    IndexType& numColumns,
00193                                    LAMAArray<IndexType>& csrJA,
00194                                    LAMAArray<ValueType>& csrValues,
00195                                    const std::string& fileName );
00196 
00197     static size_t getDataTypeSize( const File::DataType dataType );
00198 };
00199 
00200 /* -------------------------------------------------------------------------- */
00201 
00202 }
00203 #endif // LAMA_CSRSTORAGE_HPP_