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: 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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Collection top class definition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIBRARY_COLLECTIONS_COLLECTIONOPTIMISATION_H
37 #define NEKTAR_LIBRARY_COLLECTIONS_COLLECTIONOPTIMISATION_H
38 
40 #include <Collections/Collection.h>
42 #include <tinyxml.h>
43 
44 namespace Nektar
45 {
46 namespace Collections
47 {
48 
50 {
51  public:
52  /// Constructor
54  int ngeoms, int nbases):
55  m_exp(pExp),
56  m_ngeoms(ngeoms),
57  m_nbasis(nbases)
58  {
59  }
60 
61  /// Destructor
63  {
64  }
65 
66 
67  bool operator<(const OpImpTimingKey &rhs) const
68  {
69 
70  if(m_nbasis < rhs.m_nbasis)
71  {
72  return true;
73  }
74 
75  if(m_nbasis > rhs.m_nbasis)
76  {
77  return false;
78  }
79 
80  for(int i = 0; i < m_nbasis; ++i)
81  {
82  if( m_exp->GetBasis(i)->GetBasisKey() !=
83  rhs.m_exp->GetBasis(i)->GetBasisKey() )
84  {
85  return (m_exp->GetBasis(i)->GetBasisKey() <
86  rhs.m_exp->GetBasis(i)->GetBasisKey());
87  }
88  }
89 
90  if( (m_ngeoms < 100) && (rhs.m_ngeoms < 100) )
91  {
92  if(m_ngeoms < rhs.m_ngeoms)
93  {
94  return true;
95  }
96  else
97  {
98  return false;
99  }
100  }
101 
102  return false;
103  }
104 
106  int m_ngeoms;
107  int m_nbasis;
108 
109  private:
110 
111 };
112 
113 
115 {
116  public:
117  // Constuctor
120  ImplementationType defaultType = eStdMat);
121 
123 
125  {
126  return m_defaultType;
127  }
128 
129  unsigned int GetMaxCollectionSize()
130  {
131  return m_maxCollSize;
132  }
133 
135  {
136  return m_autotune;
137  }
138 
139  /// Get Operator Implementation Map from XMl or using default;
142 
143  // Get Map by doing autotuning testing.
145  std::vector<StdRegions::StdExpansionSharedPtr> pGeom,
146  OperatorImpMap &impTypes,
147  bool verbose = true);
148 
149  bool SetByXml(void)
150  {
151  return m_setByXml;
152  }
153 
154  private:
155  typedef std::pair<LibUtilities::ShapeType, int> ElmtOrder;
156 
157  static std::map<OpImpTimingKey,OperatorImpMap> m_opImpMap;
158  std::map<OperatorType, std::map<ElmtOrder, ImplementationType> > m_global;
162  unsigned int m_maxCollSize;
163 };
164 
165 }
166 }
167 #endif
COLLECTIONS_EXPORT OperatorImpMap SetWithTimings(std::vector< StdRegions::StdExpansionSharedPtr > pGeom, OperatorImpMap &impTypes, bool verbose=true)
COLLECTIONS_EXPORT OperatorImpMap GetOperatorImpMap(StdRegions::StdExpansionSharedPtr pExp)
Get Operator Implementation Map from XMl or using default;.
std::map< OperatorType, std::map< ElmtOrder, ImplementationType > > m_global
bool operator<(const OpImpTimingKey &rhs) const
StdRegions::StdExpansionSharedPtr m_exp
static std::map< OpImpTimingKey, OperatorImpMap > m_opImpMap
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
std::map< OperatorType, ImplementationType > OperatorImpMap
Definition: Operator.h:102
OpImpTimingKey(StdRegions::StdExpansionSharedPtr pExp, int ngeoms, int nbases)
Constructor.
COLLECTIONS_EXPORT CollectionOptimisation(LibUtilities::SessionReaderSharedPtr pSession, ImplementationType defaultType=eStdMat)
#define COLLECTIONS_EXPORT
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
std::pair< LibUtilities::ShapeType, int > ElmtOrder