GemaCoreLib
The GeMA Core library
gmSparseMatrixOptions.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_SPARSE_MATRIX_OPTIONS_H_
25 #define _GEMA_SPARSE_MATRIX_OPTIONS_H_
26 
27 #include "gmCoreConfig.h"
28 
30 
31 class GmSimulationData;
32 class LuaTable;
33 
36 {
40  // ----------------------------------------------------------------------
49 };
50 
51 #define GM_MATRIX_OPTIONS_DEF_RESIZE_FACTOR 2.0
52 
55 {
56 public:
58 
60 
61  bool loadUserDefinitions(LuaTable& table, QString& err);
62 
64  GmSparseMatrixLayoutMode mode() const { return _mode; }
65 
67  const char* modeStr() const { return matrixModeToStr(_mode); }
68 
77  bool lowMemory() const { return _lowMemory; }
78 
85  {
86  if(_tripletSortStrategy < 0)
88  else
89  return (GmSparseMatrixTripletBufferSortStrategy)_tripletSortStrategy;
90  }
91 
95  size_t reserve() const { return _reserve; }
96 
100  double resizeFactor() const { return _resizeFactor; }
101 
108  int numThreads() const { return _nthreads; }
109 
110  void setNumThreads(int nthreads);
111 
113  void setMode(GmSparseMatrixLayoutMode mode) { _mode = mode; }
114 
116  void setLowMemory(bool mode) { _lowMemory = mode; }
117 
119  void setTripletSortStrategy(GmSparseMatrixTripletBufferSortStrategy st) { _tripletSortStrategy = st; }
120 
121 private:
122  static bool checkLowMemoryCondition(const GmSimulationData* simulation);
123  static const char* matrixModeToStr(GmSparseMatrixLayoutMode mode);
124  static int strToMatrixMode(const QString& str);
125 
127  bool _lowMemory;
128  size_t _reserve;
129  double _resizeFactor;
130  int _nthreads;
131  int _tripletSortStrategy;
132 };
133 
134 #endif
void setMode(GmSparseMatrixLayoutMode mode)
Updates the sparse matrix building mode.
Definition: gmSparseMatrixOptions.h:113
GmSparseMatrixLayoutMode mode() const
Returns the mode for building the sparse matrix.
Definition: gmSparseMatrixOptions.h:64
int _nthreads
The maximum number of threads that should be used by sparse matrix.
Definition: gmSparseMatrixOptions.h:130
Batch mode with a (per thread) triplet list.
Definition: gmSparseMatrixOptions.h:37
GmSparseMatrixTripletBufferSortStrategy tripletSortStrategy() const
Returns the sorting strategy used to process triplet lists. If the user didn't specified a value,...
Definition: gmSparseMatrixOptions.h:84
Declaration of usefull configuration definitions for the Core library.
void setLowMemory(bool mode)
Updates the sparse matrix low memory control (used by tests code only)
Definition: gmSparseMatrixOptions.h:116
Set of configuration options for Sparse matrices.
Definition: gmSparseMatrixOptions.h:54
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
GmSparseMatrixLayoutMode
Supported modes for building the sparse matrix.
Definition: gmSparseMatrixOptions.h:35
double _resizeFactor
A user given metric for resizing data structures. If 0, will be estimated by GeMA.
Definition: gmSparseMatrixOptions.h:129
void setTripletSortStrategy(GmSparseMatrixTripletBufferSortStrategy st)
Updates the trilet sort strategy control (used by tests code only)
Definition: gmSparseMatrixOptions.h:119
GmSparseMatrixLayoutMode _mode
The mode for building the sparse matrix.
Definition: gmSparseMatrixOptions.h:126
double resizeFactor() const
Returns the user given metric for resizing data structures. Returns 0.0 if the value should be estima...
Definition: gmSparseMatrixOptions.h:100
Declaration of the GmSparseMatrixTripletData and GmSparseMatrixTripletBuffer template classes.
bool lowMemory() const
Returns true if the matrix should favour low memory strategies, false otherwise. If the user didn't s...
Definition: gmSparseMatrixOptions.h:77
Vectors are concatenated and then parallel copy sorted. Faster when there is plenty of memory.
Definition: gmSparseMatrixTripletData.h:111
Layout mode with a vector based structure.
Definition: gmSparseMatrixOptions.h:39
size_t _reserve
A user given estimate of the expected number of triplets / layout entries. If 0, will be estimated by...
Definition: gmSparseMatrixOptions.h:128
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
GmSparseMatrixTripletBufferSortStrategy
The strategy used by the GmSparseMatrixTripletBuffer<T>::sortedData() methods.
Definition: gmSparseMatrixTripletData.h:109
Vectors are parallel inplace sorted, followed by a merge operation to the destination vector.
Definition: gmSparseMatrixTripletData.h:112
bool _lowMemory
User given setting to favour low memory strategies.
Definition: gmSparseMatrixOptions.h:127
const char * modeStr() const
Returns the mode for building the sparse matrix as a string.
Definition: gmSparseMatrixOptions.h:67
int numThreads() const
The number of threads that should be used by sparse matrix building code. A value of -1 means the max...
Definition: gmSparseMatrixOptions.h:108
Definition: gmSparseMatrixOptions.h:48
size_t reserve() const
Returns the user given estimate of the expected number of triplets / layout entries....
Definition: gmSparseMatrixOptions.h:95
Layout mode with a hash table.
Definition: gmSparseMatrixOptions.h:38