Nektar++
CollectionOptimisation.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Collection.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 top class definition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIBRARY_COLLECTIONS_COLLECTIONOPTIMISATION_H
36 #define NEKTAR_LIBRARY_COLLECTIONS_COLLECTIONOPTIMISATION_H
37 
39 #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 ngeoms, int nbases):
54  m_exp(pExp),
55  m_ngeoms(ngeoms),
56  m_nbasis(nbases)
57  {
58  }
59 
60  /// Destructor
62  {
63  }
64 
65 
66  bool operator<(const OpImpTimingKey &rhs) const
67  {
68 
69  if(m_nbasis < rhs.m_nbasis)
70  {
71  return true;
72  }
73 
74  if(m_nbasis > rhs.m_nbasis)
75  {
76  return false;
77  }
78 
79  for(int i = 0; i < m_nbasis; ++i)
80  {
81  if( m_exp->GetBasis(i)->GetBasisKey() !=
82  rhs.m_exp->GetBasis(i)->GetBasisKey() )
83  {
84  return (m_exp->GetBasis(i)->GetBasisKey() <
85  rhs.m_exp->GetBasis(i)->GetBasisKey());
86  }
87  }
88 
89  if( (m_ngeoms < 100) && (rhs.m_ngeoms < 100) )
90  {
91  if(m_ngeoms < rhs.m_ngeoms)
92  {
93  return true;
94  }
95  else
96  {
97  return false;
98  }
99  }
100 
101  return false;
102  }
103 
105  int m_ngeoms;
106  int m_nbasis;
107 
108  private:
109 
110 };
111 
112 
114 {
115  public:
116  // Constuctor
119  ImplementationType defaultType = eStdMat);
120 
122 
124  {
125  return m_defaultType;
126  }
127 
128  unsigned int GetMaxCollectionSize()
129  {
130  return m_maxCollSize;
131  }
132 
134  {
135  return m_autotune;
136  }
137 
138  /// Get Operator Implementation Map from XMl or using default;
141 
142  // Get Map by doing autotuning testing.
144  std::vector<StdRegions::StdExpansionSharedPtr> pGeom,
145  OperatorImpMap &impTypes,
146  bool verbose = true);
147 
148  bool SetByXml(void)
149  {
150  return m_setByXml;
151  }
152 
153  private:
154  typedef std::pair<LibUtilities::ShapeType, int> ElmtOrder;
155 
156  static std::map<OpImpTimingKey,OperatorImpMap> m_opImpMap;
157  std::map<OperatorType, std::map<ElmtOrder, ImplementationType> > m_global;
161  unsigned int m_maxCollSize;
162 };
163 
164 }
165 }
166 #endif
#define COLLECTIONS_EXPORT
COLLECTIONS_EXPORT OperatorImpMap SetWithTimings(std::vector< StdRegions::StdExpansionSharedPtr > pGeom, OperatorImpMap &impTypes, bool verbose=true)
std::map< OperatorType, std::map< ElmtOrder, ImplementationType > > m_global
static std::map< OpImpTimingKey, OperatorImpMap > m_opImpMap
COLLECTIONS_EXPORT OperatorImpMap GetOperatorImpMap(StdRegions::StdExpansionSharedPtr pExp)
Get Operator Implementation Map from XMl or using default;.
std::pair< LibUtilities::ShapeType, int > ElmtOrder
COLLECTIONS_EXPORT CollectionOptimisation(LibUtilities::SessionReaderSharedPtr pSession, ImplementationType defaultType=eStdMat)
StdRegions::StdExpansionSharedPtr m_exp
bool operator<(const OpImpTimingKey &rhs) const
OpImpTimingKey(StdRegions::StdExpansionSharedPtr pExp, int ngeoms, int nbases)
Constructor.
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:108
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1