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
44{
45namespace Collections
46{
47
49{
50public:
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
119
120private:
121};
122
124{
125public:
126 // Constuctor
128 LibUtilities::SessionReaderSharedPtr pSession, const int shapedim,
129 ImplementationType defaultType = eStdMat);
130
132
134 {
135 return m_defaultType;
136 }
137
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
161private:
162 typedef std::pair<LibUtilities::ShapeType, int> ElmtOrder;
163 typedef std::map<OperatorType, std::map<ElmtOrder, ImplementationType>>
165 static std::map<size_t, std::map<OpImpTimingKey, OperatorImpMap>>
173
174 void ReadCollOps(TiXmlElement *xmlCol, GlobalOpMap &global, bool verbose);
175};
176
177} // namespace Collections
178} // namespace Nektar
179#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)
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:57
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2