Skip to content

Commit 93b599e

Browse files
LWisteriamaherou
authored andcommitted
[Proposal] Use std::unordered_map for A.globalToLocalMap instead of std::map (hpcg-benchmark#42)
[Proposal] Use std::unordered_map for A.globalToLocalMap instead of std::map This is a good idea. Thanks for the contribution.
1 parent 81e88bf commit 93b599e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/SparseMatrix.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121
#ifndef SPARSEMATRIX_HPP
2222
#define SPARSEMATRIX_HPP
2323

24-
#include <map>
2524
#include <vector>
2625
#include <cassert>
2726
#include "Geometry.hpp"
2827
#include "Vector.hpp"
2928
#include "MGData.hpp"
29+
#if __cplusplus <= 201103L
30+
// for C++03
31+
#include <map>
32+
typedef std::map< global_int_t, local_int_t > GlobalToLocalMap;
33+
#else
34+
// for C++11 or greater
35+
#include <unordered_map>
36+
using GlobalToLocalMap = std::unorderd_map< global_int_t, local_int_t >;
37+
#endif
3038

3139
struct SparseMatrix_STRUCT {
3240
char * title; //!< name of the sparse matrix
@@ -41,7 +49,7 @@ struct SparseMatrix_STRUCT {
4149
local_int_t ** mtxIndL; //!< matrix indices as local values
4250
double ** matrixValues; //!< values of matrix entries
4351
double ** matrixDiagonal; //!< values of matrix diagonal entries
44-
std::map< global_int_t, local_int_t > globalToLocalMap; //!< global-to-local mapping
52+
GlobalToLocalMap globalToLocalMap; //!< global-to-local mapping
4553
std::vector< global_int_t > localToGlobalMap; //!< local-to-global mapping
4654
mutable bool isDotProductOptimized;
4755
mutable bool isSpmvOptimized;

0 commit comments

Comments
 (0)