Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CollectionOptimisation.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CollectionOptimisation.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Collection optimization definition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIBRARY_COLLECTIONS_COLLECTIONOPTIMISATION_H
36 #define NEKTAR_LIBRARY_COLLECTIONS_COLLECTIONOPTIMISATION_H
37 
38 #include <Collections/Collection.h>
41 #include <tinyxml.h>
42 
43 namespace Nektar
44 {
45 namespace Collections
46 {
47 
49 {
50 public:
51  /// Constructor
53  int nbases)
54  : m_exp(pExp), m_ngeoms(ngeoms), m_nbasis(nbases)
55  {
56  }
57 
58  /// Destructor
60  {
61  }
62 
64  {
65  return m_exp->DetShapeType();
66  }
67 
68  int GetExpOrder() const
69  {
70  return m_exp->GetBasis(0)->GetNumModes();
71  }
72 
73  int GetNGeoms() const
74  {
75  return m_ngeoms;
76  }
77 
78  bool operator<(const OpImpTimingKey &rhs) const
79  {
80 
81  if (m_nbasis < rhs.m_nbasis)
82  {
83  return true;
84  }
85 
86  if (m_nbasis > rhs.m_nbasis)
87  {
88  return false;
89  }
90 
91  for (int i = 0; i < m_nbasis; ++i)
92  {
93  if (m_exp->GetBasis(i)->GetBasisKey() !=
94  rhs.m_exp->GetBasis(i)->GetBasisKey())
95  {
96  return (m_exp->GetBasis(i)->GetBasisKey() <
97  rhs.m_exp->GetBasis(i)->GetBasisKey());
98  }
99  }
100 
101  if ((m_ngeoms < 100) && (rhs.m_ngeoms < 100))
102  {
103  if (m_ngeoms < rhs.m_ngeoms)
104  {
105  return true;
106  }
107  else
108  {
109  return false;
110  }
111  }
112 
113  return false;
114  }
115 
117  int m_ngeoms;
118  int m_nbasis;
119 
120 private:
121 };
122 
124 {
125 public:
126  // Constuctor
128  LibUtilities::SessionReaderSharedPtr pSession, const int shapedim,
129  ImplementationType defaultType = eStdMat);
130 
132 
134  {
135  return m_defaultType;
136  }
137 
138  unsigned int GetMaxCollectionSize()
139  {
140  return m_maxCollSize;
141  }
142 
144  {
145  return m_autotune;
146  }
147 
148  /// Get Operator Implementation Map from XMl or using default;
151 
152  // Get Map by doing autotuning testing.
154  SetWithTimings(std::vector<StdRegions::StdExpansionSharedPtr> pGeom,
155  OperatorImpMap &impTypes, bool verbose = true);
156 
157  // Wite out autotuning testing to file
158  COLLECTIONS_EXPORT void UpdateOptFile(std::string sessName,
160 
161 private:
162  typedef std::pair<LibUtilities::ShapeType, int> ElmtOrder;
163  typedef std::map<OperatorType, std::map<ElmtOrder, ImplementationType>>
165  static std::map<OpImpTimingKey, OperatorImpMap> m_opImpMap;
169  unsigned int m_maxCollSize;
170  unsigned int m_shapeDim;
171 
172  void ReadCollOps(TiXmlElement *xmlCol, GlobalOpMap &global, bool verbose);
173 };
174 
175 } // namespace Collections
176 } // namespace Nektar
177 #endif
#define COLLECTIONS_EXPORT
COLLECTIONS_EXPORT OperatorImpMap SetWithTimings(std::vector< StdRegions::StdExpansionSharedPtr > pGeom, OperatorImpMap &impTypes, bool verbose=true)
COLLECTIONS_EXPORT void UpdateOptFile(std::string sessName, LibUtilities::CommSharedPtr &comm)
COLLECTIONS_EXPORT CollectionOptimisation(LibUtilities::SessionReaderSharedPtr pSession, const int shapedim, ImplementationType defaultType=eStdMat)
static std::map< OpImpTimingKey, OperatorImpMap > m_opImpMap
COLLECTIONS_EXPORT OperatorImpMap GetOperatorImpMap(StdRegions::StdExpansionSharedPtr pExp)
Get Operator Implementation Map from XMl or using default;.
std::map< OperatorType, std::map< ElmtOrder, ImplementationType > > GlobalOpMap
std::pair< LibUtilities::ShapeType, int > ElmtOrder
void ReadCollOps(TiXmlElement *xmlCol, GlobalOpMap &global, bool verbose)
StdRegions::StdExpansionSharedPtr m_exp
bool operator<(const OpImpTimingKey &rhs) const
LibUtilities::ShapeType GetShapeType(void) const
OpImpTimingKey(StdRegions::StdExpansionSharedPtr pExp, int ngeoms, int nbases)
Constructor.
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:112
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2