Commit ea46eab6 authored by Chris Cantwell's avatar Chris Cantwell

Further code formatting.

parent 479924a0
......@@ -53,23 +53,23 @@ enum GeomData
class CoalescedGeomData
{
public:
CoalescedGeomData(void);
public:
CoalescedGeomData(void);
virtual ~CoalescedGeomData(void);
virtual ~CoalescedGeomData(void);
const Array<OneD, const NekDouble> &GetJac(
std::vector<StdRegions::StdExpansionSharedPtr> &pColLExp);
const Array<OneD, const NekDouble> &GetJac(
std::vector<StdRegions::StdExpansionSharedPtr> &pColLExp);
const Array<OneD, const NekDouble> &GetJacWithStdWeights(
std::vector<StdRegions::StdExpansionSharedPtr> &pColLExp);
const Array<OneD, const NekDouble> &GetJacWithStdWeights(
std::vector<StdRegions::StdExpansionSharedPtr> &pColLExp);
const Array<TwoD, const NekDouble> &GetDerivFactors(
std::vector<StdRegions::StdExpansionSharedPtr> &pColLExp);
const Array<TwoD, const NekDouble> &GetDerivFactors(
std::vector<StdRegions::StdExpansionSharedPtr> &pColLExp);
private:
std::map<GeomData,Array<OneD, NekDouble> > m_oneDGeomData;
std::map<GeomData,Array<TwoD, NekDouble> > m_twoDGeomData;
private:
std::map<GeomData,Array<OneD, NekDouble> > m_oneDGeomData;
std::map<GeomData,Array<TwoD, NekDouble> > m_twoDGeomData;
};
typedef boost::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
......
......@@ -53,35 +53,35 @@ namespace Collections {
*/
class Collection
{
public:
COLLECTIONS_EXPORT Collection(
vector<StdRegions::StdExpansionSharedPtr> pCollExp,
OperatorImpMap &impTypes);
inline void ApplyOperator(
const OperatorType &op,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &output);
inline void ApplyOperator(
const OperatorType &op,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &output0,
Array<OneD, NekDouble> &output1);
inline void ApplyOperator(
const OperatorType &op,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &output0,
Array<OneD, NekDouble> &output1,
Array<OneD, NekDouble> &output2);
protected:
StdRegions::StdExpansionSharedPtr m_stdExp;
vector<SpatialDomains::GeometrySharedPtr> m_geom;
boost::unordered_map<OperatorType, OperatorSharedPtr> m_ops;
CoalescedGeomDataSharedPtr m_geomData;
public:
COLLECTIONS_EXPORT Collection(
vector<StdRegions::StdExpansionSharedPtr> pCollExp,
OperatorImpMap &impTypes);
inline void ApplyOperator(
const OperatorType &op,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &output);
inline void ApplyOperator(
const OperatorType &op,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &output0,
Array<OneD, NekDouble> &output1);
inline void ApplyOperator(
const OperatorType &op,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &output0,
Array<OneD, NekDouble> &output1,
Array<OneD, NekDouble> &output2);
protected:
StdRegions::StdExpansionSharedPtr m_stdExp;
vector<SpatialDomains::GeometrySharedPtr> m_geom;
boost::unordered_map<OperatorType, OperatorSharedPtr> m_ops;
CoalescedGeomDataSharedPtr m_geomData;
};
......
......@@ -48,118 +48,118 @@ namespace Collections
class OpImpTimingKey
{
public:
/// Constructor
OpImpTimingKey(StdRegions::StdExpansionSharedPtr pExp,
int ngeoms, int nbases):
m_exp(pExp),
m_ngeoms(ngeoms),
m_nbasis(nbases)
{
}
/// Destructor
~OpImpTimingKey(void)
{
}
bool operator<(const OpImpTimingKey &rhs) const
{
if(m_nbasis < rhs.m_nbasis)
public:
/// Constructor
OpImpTimingKey(StdRegions::StdExpansionSharedPtr pExp,
int ngeoms, int nbases):
m_exp(pExp),
m_ngeoms(ngeoms),
m_nbasis(nbases)
{
return true;
}
if(m_nbasis > rhs.m_nbasis)
/// Destructor
~OpImpTimingKey(void)
{
return false;
}
for(int i = 0; i < m_nbasis; ++i)
{
if( m_exp->GetBasis(i)->GetBasisKey() !=
rhs.m_exp->GetBasis(i)->GetBasisKey() )
{
return (m_exp->GetBasis(i)->GetBasisKey() <
rhs.m_exp->GetBasis(i)->GetBasisKey());
}
}
if( (m_ngeoms < 100) && (rhs.m_ngeoms < 100) )
bool operator<(const OpImpTimingKey &rhs) const
{
if(m_ngeoms < rhs.m_ngeoms)
if(m_nbasis < rhs.m_nbasis)
{
return true;
}
else
if(m_nbasis > rhs.m_nbasis)
{
return false;
}
}
return false;
}
for(int i = 0; i < m_nbasis; ++i)
{
if( m_exp->GetBasis(i)->GetBasisKey() !=
rhs.m_exp->GetBasis(i)->GetBasisKey() )
{
return (m_exp->GetBasis(i)->GetBasisKey() <
rhs.m_exp->GetBasis(i)->GetBasisKey());
}
}
if( (m_ngeoms < 100) && (rhs.m_ngeoms < 100) )
{
if(m_ngeoms < rhs.m_ngeoms)
{
return true;
}
else
{
return false;
}
}
StdRegions::StdExpansionSharedPtr m_exp;
int m_ngeoms;
int m_nbasis;
return false;
}
private:
StdRegions::StdExpansionSharedPtr m_exp;
int m_ngeoms;
int m_nbasis;
private:
};
class CollectionOptimisation
{
typedef pair<LibUtilities::ShapeType, int> ElmtOrder;
public:
// Constuctor
COLLECTIONS_EXPORT CollectionOptimisation(
LibUtilities::SessionReaderSharedPtr pSession,
ImplementationType defaultType = eStdMat);
~CollectionOptimisation(){};
ImplementationType GetDefaultImplementationType()
{
return m_defaultType;
}
unsigned int GetMaxCollectionSize()
{
return m_maxCollSize;
}
bool IsUsingAutotuning()
{
return m_autotune;
}
/// Get Operator Implementation Map from XMl or using default;
COLLECTIONS_EXPORT OperatorImpMap GetOperatorImpMap(
StdRegions::StdExpansionSharedPtr pExp);
// Get Map by doing autotuning testing.
COLLECTIONS_EXPORT OperatorImpMap SetWithTimings(
vector<StdRegions::StdExpansionSharedPtr> pGeom,
OperatorImpMap &impTypes,
bool verbose = true);
bool SetByXml(void)
{
return m_setByXml;
}
private:
static map<OpImpTimingKey,OperatorImpMap> m_opImpMap;
map<OperatorType, map<ElmtOrder, ImplementationType> > m_global;
bool m_setByXml;
bool m_autotune;
ImplementationType m_defaultType;
unsigned int m_maxCollSize;
public:
// Constuctor
COLLECTIONS_EXPORT CollectionOptimisation(
LibUtilities::SessionReaderSharedPtr pSession,
ImplementationType defaultType = eStdMat);
~CollectionOptimisation(){};
ImplementationType GetDefaultImplementationType()
{
return m_defaultType;
}
unsigned int GetMaxCollectionSize()
{
return m_maxCollSize;
}
bool IsUsingAutotuning()
{
return m_autotune;
}
/// Get Operator Implementation Map from XMl or using default;
COLLECTIONS_EXPORT OperatorImpMap GetOperatorImpMap(
StdRegions::StdExpansionSharedPtr pExp);
// Get Map by doing autotuning testing.
COLLECTIONS_EXPORT OperatorImpMap SetWithTimings(
vector<StdRegions::StdExpansionSharedPtr> pGeom,
OperatorImpMap &impTypes,
bool verbose = true);
bool SetByXml(void)
{
return m_setByXml;
}
private:
typedef pair<LibUtilities::ShapeType, int> ElmtOrder;
static map<OpImpTimingKey,OperatorImpMap> m_opImpMap;
map<OperatorType, map<ElmtOrder, ImplementationType> > m_global;
bool m_setByXml;
bool m_autotune;
ImplementationType m_defaultType;
unsigned int m_maxCollSize;
};
}
......
......@@ -39,6 +39,10 @@ namespace Nektar
{
namespace Collections
{
/**
*
*/
void QuadIProduct(bool colldir0, bool colldir1, int numElmt,
int nquad0, int nquad1,
int nmodes0, int nmodes1,
......@@ -121,6 +125,10 @@ void QuadIProduct(bool colldir0, bool colldir1, int numElmt,
}
}
/**
*
*/
void TriIProduct(bool sortTopVertex, int numElmt, int nquad0,
int nquad1, int nmodes0, int nmodes1,
const Array<OneD, const NekDouble> &base0,
......@@ -130,7 +138,8 @@ void TriIProduct(bool sortTopVertex, int numElmt, int nquad0,
Array<OneD, NekDouble> &output,
Array<OneD, NekDouble> &wsp)
{
int totmodes = LibUtilities::StdTriData::getNumberOfCoefficients(nmodes0,nmodes1);
int totmodes = LibUtilities::StdTriData::getNumberOfCoefficients(
nmodes0, nmodes1);
int totpoints = nquad0*nquad1;
Vmath::Vmul(numElmt*totpoints,jac,1,input,1,wsp,1);
......@@ -144,9 +153,10 @@ void TriIProduct(bool sortTopVertex, int numElmt, int nquad0,
// Inner product with respect to 'b' direction
for (mode=i=0; i < nmodes0; ++i)
{
Blas::Dgemm('T','N',nmodes1-i,numElmt,nquad1,1.0,base1.get()+mode*nquad1,
nquad1,wsp1.get() + i*nquad1*numElmt,nquad1,
0.0, &output[mode],totmodes);
Blas::Dgemm('T', 'N', nmodes1-i, numElmt, nquad1,
1.0, base1.get()+mode*nquad1, nquad1,
wsp1.get() + i*nquad1*numElmt, nquad1, 0.0,
&output[mode], totmodes);
mode += nmodes1 - i;
}
......@@ -160,6 +170,9 @@ void TriIProduct(bool sortTopVertex, int numElmt, int nquad0,
}
/**
*
*/
void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt,
int nquad0, int nquad1, int nquad2,
int nmodes0, int nmodes1, int nmodes2,
......@@ -186,7 +199,10 @@ void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt,
// Assign second half of workspace for 2nd DGEMM operation.
Array<OneD, NekDouble> wsp1 = wsp + totpoints*numElmt;
if(numElmt < nmodes0 || 1) // note sure what criterion we should use to swap around these strategies
// note sure what criterion we should use to swap around these
// strategies
if(numElmt < nmodes0 || 1)
{
Array<OneD, NekDouble> wsp2 = wsp1 + nmodes0*nquad1*nquad2;
......@@ -248,7 +264,8 @@ void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt,
}
else
{
Array<OneD, NekDouble> wsp2 = wsp1 + numElmt*(max(totpoints,totmodes));
Array<OneD, NekDouble> wsp2 = wsp1 + numElmt*(max(totpoints,
totmodes));
if(colldir0)
{
......@@ -294,14 +311,16 @@ void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt,
}
else
{
Blas::Dgemm('T','N', numElmt*nmodes0*nmodes1, nmodes2, nquad2,
1.0, &wsp2[0], nquad2, base2.get(), nquad2,
0.0, &wsp1[0], numElmt*nmodes0*nmodes1);
Blas::Dgemm('T', 'N', numElmt*nmodes0*nmodes1, nmodes2,
nquad2, 1.0, &wsp2[0], nquad2,
base2.get(), nquad2, 0.0,
&wsp1[0], numElmt*nmodes0*nmodes1);
}
for(int i = 0; i < totmodes; ++i)
{
Vmath::Vcopy(numElmt,&wsp1[i*numElmt],1,&output[i],totmodes);
Vmath::Vcopy(numElmt, &wsp1[i*numElmt], 1,
&output[i], totmodes);
}
}
......@@ -317,9 +336,10 @@ void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt,
}
else
{
Blas::Dgemm('T','N', numElmt*nmodes0*nmodes1, nmodes2, nquad2,
1.0, &wsp2[0], nquad2, base2.get(), nquad2,
0.0, &output[0], numElmt*nmodes0*nmodes1);
Blas::Dgemm('T','N', numElmt*nmodes0*nmodes1, nmodes2,
nquad2, 1.0, &wsp2[0], nquad2,
base2.get(), nquad2, 0.0,
&output[0], numElmt*nmodes0*nmodes1);
}
}
}
......@@ -327,6 +347,9 @@ void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt,
}
/**
*
*/
void PrismIProduct(bool sortTopVertex, int numElmt,
int nquad0, int nquad1, int nquad2,
int nmodes0, int nmodes1, int nmodes2,
......@@ -338,14 +361,17 @@ void PrismIProduct(bool sortTopVertex, int numElmt,
Array<OneD, NekDouble> &output,
Array<OneD, NekDouble> &wsp)
{
int totmodes = LibUtilities::StdPrismData::getNumberOfCoefficients(nmodes0,nmodes1,nmodes2);
int totmodes = LibUtilities::StdPrismData::getNumberOfCoefficients(
nmodes0,nmodes1,nmodes2);
int totpoints = nquad0*nquad1*nquad2;
int cnt;
int mode, mode1;
Vmath::Vmul(numElmt*totpoints,jac,1,input,1,wsp,1);
Array<OneD, NekDouble> wsp1 = wsp + numElmt*nquad2*(max(nquad0*nquad1,nmodes0*nmodes1));
Array<OneD, NekDouble> wsp1 = wsp + numElmt * nquad2
* (max(nquad0*nquad1,
nmodes0*nmodes1));
// Perform iproduct with respect to the '0' direction
Blas::Dgemm('T', 'N', nquad1*nquad2*numElmt, nmodes0, nquad0,
......@@ -359,7 +385,8 @@ void PrismIProduct(bool sortTopVertex, int numElmt,
nquad1, 0.0, wsp.get(), nquad2*numElmt*nmodes0);
// Inner product with respect to the '2' direction (not sure if it woudl be better to swap loops?)
// Inner product with respect to the '2' direction (not sure if it would
// be better to swap loops?)
mode = mode1 = cnt = 0;
for(int i = 0; i < nmodes0; ++i)
{
......@@ -392,6 +419,9 @@ void PrismIProduct(bool sortTopVertex, int numElmt,
}
/**
*
*/
void TetIProduct(bool sortTopEdge, int numElmt,
int nquad0, int nquad1, int nquad2,
int nmodes0, int nmodes1, int nmodes2,
......@@ -403,7 +433,8 @@ void TetIProduct(bool sortTopEdge, int numElmt,
Array<OneD, NekDouble> &output,
Array<OneD, NekDouble> &wsp)
{
int totmodes = LibUtilities::StdTetData::getNumberOfCoefficients(nmodes0,nmodes1,nmodes2);
int totmodes = LibUtilities::StdTetData::getNumberOfCoefficients(
nmodes0,nmodes1,nmodes2);
int totpoints = nquad0*nquad1*nquad2;
int cnt;
int mode, mode1;
......
......@@ -107,38 +107,38 @@ OperatorImpMap SetFixedImpType(ImplementationType defaultType);
/// Base class for operators on a collection of elements
class Operator
{
public:
/// Constructor
Operator(
vector<StdRegions::StdExpansionSharedPtr> pCollExp,
boost::shared_ptr<CoalescedGeomData> GeomData)
: m_stdExp(pCollExp[0]->GetStdExp()),
m_numElmt(pCollExp.size()),
m_wspSize(0)
{
}
/// Perform operation
COLLECTIONS_EXPORT virtual void operator()(
const Array<OneD, const NekDouble> &input,
Array<OneD, NekDouble> &output0,
Array<OneD, NekDouble> &output1,
Array<OneD, NekDouble> &output2,
Array<OneD, NekDouble> &wsp
= NullNekDouble1DArray) = 0;
COLLECTIONS_EXPORT virtual ~Operator();
/// Get the size of the required workspace
int GetWspSize()
{
return m_wspSize;
}
protected:
StdRegions::StdExpansionSharedPtr m_stdExp;
unsigned int m_numElmt;
unsigned int m_wspSize;
public:
/// Constructor
Operator(
vector<StdRegions::StdExpansionSharedPtr> pCollExp,
boost::shared_ptr<CoalescedGeomData> GeomData)
: m_stdExp(pCollExp[0]->GetStdExp()),
m_numElmt(pCollExp.size()),
m_wspSize(0)
{
}
/// Perform operation
COLLECTIONS_EXPORT virtual void operator()(
const Array<OneD, const NekDouble> &input,
Array<OneD, NekDouble> &output0,
Array<OneD, NekDouble> &output1,
Array<OneD, NekDouble> &output2,
Array<OneD, NekDouble> &wsp
= NullNekDouble1DArray) = 0;
COLLECTIONS_EXPORT virtual ~Operator();
/// Get the size of the required workspace
int GetWspSize()
{
return m_wspSize;
}
protected:
StdRegions::StdExpansionSharedPtr m_stdExp;
unsigned int m_numElmt;
unsigned int m_wspSize;
};
/// Shared pointer to an Operator object
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment