Commit 39b19188 by Pavel Burovskiy

### Cleaning up the code from different svtvp implementations

parent ee6dc08d
 #include"Svtvp-explicit-inst-inc.hpp" #include #include #include using namespace std; double experiment(int size) { vector a(size, 1.0/rand()); vector b(size, 2.0/rand()); vector c(size, 3.0/rand()); SvtvpExplInstInc::Svtvp(size, 5.0, &a[0], 1, &b[0], 1, &c[0], 1); return c[size-1]; } int main() { int n = 1000000; for (int i = 0; i < n; i++) { experiment(10000); } }
 #include"Svtvp-explicit-inst-inc.hpp" namespace SvtvpExplInstInc { template void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz) { ++n; if (incx == 1 && incy == 1 && incz == 1) { while( --n ) { *z = alpha * (*x) + (*y); ++x; ++y; ++z; } } else { while( --n ) { *z = alpha * (*x) + (*y); x += incx; y += incy; z += incz; } } } // explicit instantiation template void Svtvp(int n, const double alpha, const double *x, const int incx, const double *y, const int incy, double *z, const int incz); } \ No newline at end of file
 namespace SvtvpExplInstInc { /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y template void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz); } \ No newline at end of file
 #include"Svtvp-explicit-inst.hpp" #include #include #include using namespace std; double experiment(int size) { vector a(size, 1.0/rand()); vector b(size, 2.0/rand()); vector c(size, 3.0/rand()); SvtvpExplInst::Svtvp(size, 5.0, &a[0], &b[0], &c[0]); return c[size-1]; } int main() { int n = 1000000; for (int i = 0; i < n; i++) { experiment(10000); } }
 #include"Svtvp-explicit-inst.hpp" namespace SvtvpExplInst { template void Svtvp(int n, const T alpha, const T *x, const T *y, T *z) { ++n; while( --n ) { *z = alpha * (*x) + (*y); ++x; ++y; ++z; } } // explicit instantiation template void Svtvp(int n, const double alpha, const double *x, const double *y, double *z); } \ No newline at end of file
 namespace SvtvpExplInst { /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y template void Svtvp(int n, const T alpha, const T *x, const T *y, T *z); } \ No newline at end of file
 #include"Svtvp-header-inline.hpp" #include #include #include using namespace std; double experiment(int size) { vector a(size, 1.0/rand()); vector b(size, 2.0/rand()); vector c(size, 3.0/rand()); SvtvpHeaderInline::Svtvp(size, 5.0, &a[0], 1, &b[0], 1, &c[0], 1); return c[size-1]; } int main() { int n = 1000000; for (int i = 0; i < n; i++) { experiment(10000); } }
 namespace SvtvpHeaderInline { /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y template inline void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz) { ++n; if (incx == 1 && incy == 1 && incz == 1) { while( --n ) { *z = alpha * (*x) + (*y); ++x; ++y; ++z; } } else { while( --n ) { *z = alpha * (*x) + (*y); x += incx; y += incy; z += incz; } } } } \ No newline at end of file
 #include"Svtvp-header.hpp" #include #include #include #include using namespace std; double experiment(int size) { vector a(size, 1.0/rand()); vector b(size, 2.0/rand()); vector c(size, 3.0/rand()); SvtvpHeader::Svtvp(size, 5.0, &a[0], 1, &b[0], 1, &c[0], 1); Vmath::Svtvp(size, 5.0, &a[0], 1, &b[0], 1, &c[0], 1); return c[size-1]; } double experimentVmath(int size) { vector a(size, 1.0/rand()); vector b(size, 2.0/rand()); vector c(size, 3.0/rand()); Vmath::Svtvp(size, 5.0, &a[0], 1, &b[0], 1, &c[0], 1); return c[size-1]; } int main() { int n = 1000000; for (int i = 0; i < n; i++) { experiment(10000); } }
 namespace SvtvpHeader { /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y template void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz) { ++n; if (incx == 1 && incy == 1 && incz == 1) { while( --n ) { *z = alpha * (*x) + (*y); ++x; ++y; ++z; } } else { while( --n ) { *z = alpha * (*x) + (*y); x += incx; y += incy; z += incz; } } } } \ No newline at end of file
 ... ... @@ -492,25 +492,9 @@ namespace Vmath } } /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y template LIB_UTILITIES_EXPORT void Svtvp(int n, const T alpha, const T *x, const T *y, T *z) { ++n; while( --n ) { *z = alpha * (*x) + (*y); ++x; ++y; ++z; } } template LIB_UTILITIES_EXPORT void Svtvp(int n, const double alpha, const double *x, const int incx, const double *y, const int incy, double *z, const int incz); template LIB_UTILITIES_EXPORT void Svtvp(int n, const double alpha, const double *x, const double *y, double *z); /// \brief svtvp (scalar times vector plus vector): z = alpha*x - y ... ...
 ... ... @@ -153,35 +153,6 @@ namespace Vmath template LIB_UTILITIES_EXPORT void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz); template LIB_UTILITIES_EXPORT void Svtvp(int n, const T alpha, const T *x, const T *y, T *z); /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y template LIB_UTILITIES_EXPORT void Svtvph(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz) { ++n; if (incx == 1 && incy == 1 && incz == 1) { while( --n ) { *z = alpha * (*x) + (*y); ++x; ++y; ++z; } } else { while( --n ) { *z = alpha * (*x) + (*y); x += incx; y += incy; z += incz; } } } /// \brief svtvp (scalar times vector plus vector): z = alpha*x - y template LIB_UTILITIES_EXPORT void Svtvm(int n, const T alpha, const T *x, ... ...
 ... ... @@ -453,36 +453,6 @@ namespace Nektar v_DoMatrixMultiply(w_A, s_A); k = 0; Timer t; int rank = vComm->GetRank(); cout << "MPI " << rank << ": calling Svtvp 1000 times on array with " << nNonDir << " elements" << endl; t.Start(); for (int i = 0 ; i < 1000; i++) { Vmath::Svtvp(nNonDir, beta, &p_A[0], 1, &w_A[nDir], 1, &tmp_A[0], 1); } t.Stop(); cout << "MPI " << rank << ": One call to cpp Svtvp with increment takes " << t.TimePerTest(1000) << endl; t.Start(); for (int i = 0 ; i < 1000; i++) { Vmath::Svtvph(nNonDir, beta, &p_A[0], 1, &w_A[nDir], 1, &tmp_A[0], 1); } t.Stop(); cout << "MPI " << rank << ": One call to hpp Svtvp with increment takes " << t.TimePerTest(1000) << endl; t.Start(); for (int i = 0 ; i < 1000; i++) { Vmath::Svtvp(nNonDir, beta, &p_A[0], &w_A[nDir], &tmp_A[0]); } t.Stop(); cout << "MPI " << rank << ": One call to cpp Svtvp without increment takes " << t.TimePerTest(1000) << endl; vExchange[0] = Vmath::Dot2(nNonDir, r_A, w_A + nDir, ... ... @@ -513,18 +483,14 @@ namespace Nektar //q = s + beta * q; Vmath::Svtvp(nNonDir, beta, &p_A[0], 1, &w_A[nDir], 1, &p_A[0], 1); Vmath::Svtvp(nNonDir, beta, &q_A[0], 1, &s_A[nDir], 1, &q_A[0], 1); //Vmath::Svtvp(nNonDir, beta, &p_A[0], &w_A[nDir], &p_A[0]); //Vmath::Svtvp(nNonDir, beta, &q_A[0], &s_A[nDir], &q_A[0]); // Update solution x_{k+1} //out = out + alpha * p; Vmath::Svtvp(nNonDir, alpha, &p_A[0], 1, &pOutput[nDir], 1, &pOutput[nDir], 1); //Vmath::Svtvp(nNonDir, alpha, &p_A[0], &pOutput[nDir], &pOutput[nDir]); // Update residual vector r_{k+1} //r = r - alpha * q; Vmath::Svtvp(nNonDir, -alpha, &q_A[0], 1, &r_A[0], 1, &r_A[0], 1); //Vmath::Svtvp(nNonDir, -alpha, &q_A[0], &r_A[0], &r_A[0]); // Apply preconditioner m_precon->DoPreconditioner(r_A, tmp = w_A + nDir); ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!