Skip to content
Snippets Groups Projects
Commit 63a5333b authored by Christian Engwer's avatar Christian Engwer
Browse files

disable debug output when using expression templates

[[Imported from SVN: r3642]]
parent 4730f208
Branches
Tags
No related merge requests found
......@@ -268,7 +268,9 @@ namespace Dune {
#ifdef DUNE_ISTL_WITH_CHECKING
assert(N() == x.N());
#endif
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "Assign Vector from Expression\n";
#endif
++INDENT;
for (int i=0; i<N(); ++i) { asImp()[i] = x[i]; }
--INDENT;
......@@ -279,7 +281,9 @@ namespace Dune {
#ifdef DUNE_ISTL_WITH_CHECKING
assert(N() == v.N());
#endif
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "Assign Vector from Vector\n";
#endif
++INDENT;
for (int i=0; i<N(); ++i) { asImp()[i] = v[i]; }
--INDENT;
......@@ -287,7 +291,9 @@ namespace Dune {
}
/*
I& assignFrom(const Vector<block_type> & x) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "Assign Vector block_type\n";
#endif
++INDENT;
for (int i=0; i < asImp().N(); i++) asImp()[i] = x;
--INDENT;
......@@ -295,7 +301,9 @@ namespace Dune {
}
*/
I& assignFrom(field_type x) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "Assign Vector from field_type\n";
#endif
++INDENT;
for (int i=0; i<N(); ++i) { asImp()[i] = x; }
--INDENT;
......@@ -348,7 +356,9 @@ namespace Dune {
typedef typename ExpressionImp<BlockExpr>::type BlockExprImp;
ConstRef (const Vector<V> & _v) : v(_v) {}
BlockExpr operator[] (int i) const {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "ConstRef->dereference " << v[i] << std::endl;
#endif
return BlockExprImp(v[i]);
}
int N() const { return v.N(); };
......
......@@ -17,6 +17,8 @@
namespace Dune {
#ifndef DUNE_EXPRESSIONTEMPLATES
/** @defgroup DenseMatVec Dense Matrix and Vector Template Library
@ingroup Common
@{
......@@ -148,6 +150,8 @@ namespace Dune {
}
};
#endif
// template meta program for operator==
template<int I>
struct fvmeta_equality {
......@@ -166,6 +170,8 @@ namespace Dune {
}
};
#ifndef DUNE_EXPRESSIONTEMPLATES
// template meta program for axpy
template<int I>
struct fvmeta_axpy {
......@@ -330,6 +336,8 @@ namespace Dune {
}
};
#endif
//! Iterator class for sequential access to FieldVector and FieldMatrix
template<class C, class T>
class FieldIterator :
......@@ -620,6 +628,7 @@ namespace Dune {
//! Constructor making uninitialized vector
FieldVector() {}
#ifndef DUNE_EXPRESSIONTEMPLATES
//! Constructor making vector with identical coordinates
explicit FieldVector (const K& t)
{
......@@ -634,25 +643,49 @@ namespace Dune {
return *this;
}
#ifdef DUNE_EXPRESSIONTEMPLATES
#else
//! Constructor making vector with identical coordinates
explicit FieldVector (const K& t)
{
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector Copy Constructor Scalar\n";
#endif
assignFrom(t);
}
//! Assignment operator for scalar
FieldVector& operator= (const K& k)
{
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector Assignment Operator Scalar\n";
#endif
return assignFrom(k);
}
template <class E>
FieldVector (Dune::ExprTmpl::Expression<E> op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector Copy Constructor Expression\n";
#endif
assignFrom(op);
}
template <class V>
FieldVector (const Dune::ExprTmpl::Vector<V> & op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector Copy Operator Vector\n";
#endif
assignFrom(op);
}
template <class E>
FieldVector& operator = (Dune::ExprTmpl::Expression<E> op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector Assignment Operator Expression\n";
#endif
return assignFrom(op);
}
template <class V>
FieldVector& operator = (const Dune::ExprTmpl::Vector<V> & op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector Assignment Operator Vector\n";
#endif
return assignFrom(op);
}
#endif
......@@ -753,6 +786,7 @@ namespace Dune {
return ConstIterator(*this,n);
}
#ifndef DUNE_EXPRESSIONTEMPLATES
//===== vector space arithmetic
//! vector space addition
......@@ -769,7 +803,6 @@ namespace Dune {
return *this;
}
#ifndef DUNE_EXPRESSIONTEMPLATES
//! Binary vector addition
FieldVector<K, size> operator+ (const FieldVector<K, size>& b) const
{
......@@ -783,7 +816,6 @@ namespace Dune {
FieldVector<K, size> z = *this;
return (z-=b);
}
#endif
//! vector space add scalar to all comps
FieldVector& operator+= (const K& k)
......@@ -813,6 +845,8 @@ namespace Dune {
return *this;
}
#endif
//! Binary vector comparison
bool operator== (const FieldVector& y) const
{
......@@ -822,11 +856,15 @@ namespace Dune {
//! vector space axpy operation
FieldVector& axpy (const K& a, const FieldVector& y)
{
#ifndef DUNE_EXPRESSIONTEMPLATES
fvmeta_axpy<n-1>::axpy(*this,a,y);
#else
*this = (*this)*a + y;
#endif
return *this;
}
#ifndef DUNE_EXPRESSIONTEMPLATES
//===== Euclidean scalar product
//! scalar product
......@@ -873,7 +911,7 @@ namespace Dune {
{
return fvmeta_infinity_norm_real<n-1>::infinity_norm_real(*this);
}
#endif
//===== sizes
......@@ -975,22 +1013,30 @@ namespace Dune {
#ifdef DUNE_EXPRESSIONTEMPLATES
template <class E>
FieldVector (Dune::ExprTmpl::Expression<E> op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector<1> Copy Constructor Expression\n";
#endif
assignFrom(op);
}
template <class V>
FieldVector (const Dune::ExprTmpl::Vector<V> & op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector<1> Copy Operator Vector\n";
#endif
assignFrom(op);
}
template <class E>
FieldVector& operator = (Dune::ExprTmpl::Expression<E> op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector<1> Assignment Operator Expression\n";
#endif
return assignFrom(op);
}
template <class V>
FieldVector& operator = (const Dune::ExprTmpl::Vector<V> & op) {
#ifdef DUNE_VVERBOSE
Dune::dvverb << INDENT << "FieldVector<1> Assignment Operator Vector\n";
#endif
return assignFrom(op);
}
#endif
......
......@@ -43,14 +43,16 @@ settest_SOURCES=settest.cc
gcdlcdtest_SOURCES = gcdlcdtest.cc
# bin_PROGRAMS = exprtmpl timing_old timing_xpr
bin_PROGRAMS = exprtmpl timing_old timing_xpr timing_flt
exprtmpl_SOURCES = exprtmpl.cc
exprtmpl_CXXFLAGS = -DDUNE_EXPRESSIONTEMPLATES -DDUNE_ISTL_WITH_CHECKING
exprtmpl_CXXFLAGS = -DDUNE_EXPRESSIONTEMPLATES -DDUNE_ISTL_WITH_CHECKING -g
# -DNOPRINT
dist_noinst_DATA = timing.cc
timing_old_SOURCES = timing.cc
timing_xpr_SOURCES = timing.cc
timing_xpr_CXXFLAGS = -DDUNE_EXPRESSIONTEMPLATES -g
timing_xpr_CXXFLAGS = -DDUNE_EXPRESSIONTEMPLATES -g -finline-limit=1200
timing_flt_SOURCES = timing.cc
timing_flt_CXXFLAGS = -DDUNE_FLATIT -g
include $(top_srcdir)/am/global-rules
......@@ -38,12 +38,25 @@ void timing_vector()
Dune::Timer stopwatch;
stopwatch.reset();
for (int i=0; i<100; i++)
for (int i=0; i<10; i++)
{
#ifdef DUNE_EXPRESSIONTEMPLATES
bbv2 = bbv2 + 2 * bbv;
#ifdef DUNE_FLATIT
Dune::FlatIterator<BBV> it1 = bbv.begin();
Dune::FlatIterator<BBV> it2 = bbv2.begin();
Dune::FlatIterator<BBV> end = bbv.end();
for (; it1 != end; ++it1)
{
(*it2) = 2*(*it2) + (*it1);
++ it2;
}
#else
bbv2 = 2*bbv2 + bbv;
#endif
#else
bbv2.axpy(2,bbv);
#endif
}
std::cout << "Time [bbv*=2] " << stopwatch.elapsed() << std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment