Nektar++
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
41#include <tinyxml.h>
42
43namespace Nektar::Collections
44{
45
47{
48public:
49 /// Constructor
51 int nbases)
52 : m_exp(pExp), m_ngeoms(ngeoms), m_nbasis(nbases)
53 {
54 }
55
56 /// Destructor
57 ~OpImpTimingKey(void) = default;
58
60 {
61 return m_exp->DetShapeType();
62 }
63
64 int GetExpOrder() const
65 {
66 return m_exp->GetBasis(0)->GetNumModes();
67 }
68
69 int GetNGeoms() const
70 {
71 return m_ngeoms;
72 }
73
74 bool operator<(const OpImpTimingKey &rhs) const
75 {
76
77 if (m_nbasis < rhs.m_nbasis)
78 {
79 return true;
80 }
81
82 if (m_nbasis > rhs.m_nbasis)
83 {
84 return false;
85 }
86
87 for (int i = 0; i < m_nbasis; ++i)
88 {
89 if (m_exp->GetBasis(i)->GetBasisKey() !=
90 rhs.m_exp->GetBasis(i)->GetBasisKey())
91 {
92 return (m_exp->GetBasis(i)->GetBasisKey() <
93 rhs.m_exp->GetBasis(i)->GetBasisKey());
94 }
95 }
96
97 if ((m_ngeoms < 100) && (rhs.m_ngeoms < 100))
98 {
99 if (m_ngeoms < rhs.m_ngeoms)
100 {
101 return true;
102 }
103 else
104 {
105 return false;
106 }
107 }
108
109 return false;
110 }
111
115
116private:
117};
118
120{
121public:
122 // Constuctor
124 LibUtilities::SessionReaderSharedPtr pSession, const int shapedim,
125 ImplementationType defaultType = eStdMat);
126
128
130 {
131 return m_defaultType;
132 }
133
135 {
136 return m_maxCollSize;
137 }
138
140 {
141 return m_autotune;
142 }
143
144 /// Get Operator Implementation Map from XMl or using default;
147
148 // Get Map by doing autotuning testing.
150 SetWithTimings(std::vector<StdRegions::StdExpansionSharedPtr> pGeom,
151 OperatorImpMap &impTypes, bool verbose = true);
152
153 // Wite out autotuning testing to file
154 COLLECTIONS_EXPORT void UpdateOptFile(std::string sessName,
156
157private:
158 typedef std::pair<LibUtilities::ShapeType, int> ElmtOrder;
159 typedef std::map<OperatorType, std::map<ElmtOrder, ImplementationType>>
161 static std::map<size_t, std::map<OpImpTimingKey, OperatorImpMap>>
169
170 void ReadCollOps(TiXmlElement *xmlCol, GlobalOpMap &global, bool verbose);
171};
172
173} // namespace Nektar::Collections
174#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)
static std::map< size_t, std::map< OpImpTimingKey, OperatorImpMap > > m_opImpMap
COLLECTIONS_EXPORT CollectionOptimisation(LibUtilities::SessionReaderSharedPtr pSession, const int shapedim, ImplementationType defaultType=eStdMat)
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)
~OpImpTimingKey(void)=default
Destructor.
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:126
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::shared_ptr< StdExpansion > StdExpansionSharedPtr