diff --git a/bench1/bench1.cpp b/bench1/bench1.cpp index d36c4759..0f97d853 100644 --- a/bench1/bench1.cpp +++ b/bench1/bench1.cpp @@ -18,7 +18,6 @@ void header (std::string text) { std::cout << text << std::endl; - std::cerr << text << std::endl; } template @@ -38,9 +37,6 @@ struct peak_c_plus { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -60,9 +56,6 @@ struct peak_c_multiplies { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -77,163 +70,57 @@ void peak::operator () (int runs) { peak_c_multiplies () (runs); } -template struct peak; -template struct peak; -template struct peak >; -template struct peak >; -#ifdef BOOST_MSVC -// Standard new handler is not standard compliant. -#include -int __cdecl std_new_handler (unsigned) { - throw std::bad_alloc (); +template +void do_bench (std::string type_string, int scale) +{ + header (type_string); + peak () (1000000 * scale); + + header (type_string + ", 3"); + bench_1 () (1000000 * scale); + bench_2 () (300000 * scale); + bench_3 () (100000 * scale); + + header (type_string + ", 10"); + bench_1 () (300000 * scale); + bench_2 () (30000 * scale); + bench_3 () (3000 * scale); + + header (type_string + ", 30"); + bench_1 () (100000 * scale); + bench_2 () (3000 * scale); + bench_3 () (100 * scale); + + header (type_string + ", 100"); + bench_1 () (30000 * scale); + bench_2 () (300 * scale); + bench_3 () (3 * scale); } -#endif int main (int argc, char *argv []) { -#ifdef BOOST_MSVC - _set_new_handler (std_new_handler); -#endif - -#ifdef USE_FLOAT - header ("float"); - peak () (100000000); -#endif - -#ifdef USE_DOUBLE - header ("double"); - peak () (100000000); -#endif - -#ifdef USE_STD_COMPLEX -#ifdef USE_FLOAT - header ("std:complex"); - peak > () (100000000); -#endif - -#ifdef USE_DOUBLE - header ("std:complex"); - peak > () (100000000); -#endif -#endif int scale = 1; if (argc > 1) -#ifndef BOOST_NO_STDC_NAMESPACE scale = std::atoi (argv [1]); -#else - scale = ::atoi (argv [1]); -#endif #ifdef USE_FLOAT - header ("float, 3"); - - bench_1 () (1000000 * scale); - bench_2 () (300000 * scale); - bench_3 () (100000 * scale); - - header ("float, 10"); - - bench_1 () (300000 * scale); - bench_2 () (30000 * scale); - bench_3 () (3000 * scale); - - header ("float, 30"); - - bench_1 () (100000 * scale); - bench_2 () (3000 * scale); - bench_3 () (100 * scale); - - header ("float, 100"); - - bench_1 () (30000 * scale); - bench_2 () (300 * scale); - bench_3 () (3 * scale); + do_bench ("FLOAT", scale); #endif #ifdef USE_DOUBLE - header ("double, 3"); - - bench_1 () (1000000 * scale); - bench_2 () (300000 * scale); - bench_3 () (100000 * scale); - - header ("double, 10"); - - bench_1 () (300000 * scale); - bench_2 () (30000 * scale); - bench_3 () (3000 * scale); - - header ("double, 30"); - - bench_1 () (100000 * scale); - bench_2 () (3000 * scale); - bench_3 () (100 * scale); - - header ("double, 100"); - - bench_1 () (30000 * scale); - bench_2 () (300 * scale); - bench_3 () (3 * scale); + do_bench ("DOUBLE", scale); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT - header ("std::complex, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("std::complex, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("std::complex, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("std::complex, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); + do_bench > ("COMPLEX", scale); #endif #ifdef USE_DOUBLE - header ("std::complex, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("std::complex, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("std::complex, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("std::complex, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); + do_bench > ("COMPLEX", scale); #endif #endif return 0; } - - - - diff --git a/bench1/bench1.hpp b/bench1/bench1.hpp index da17518a..e2fa5886 100644 --- a/bench1/bench1.hpp +++ b/bench1/bench1.hpp @@ -38,10 +38,6 @@ struct footer { << (multiplies * ublas::type_traits::multiplies_complexity + plus * ublas::type_traits::plus_complexity) * runs / (1024 * 1024 * elapsed) << " Mflops" << std::endl; - std::cerr << "elapsed: " << elapsed << " s, " - << (multiplies * ublas::type_traits::multiplies_complexity + - plus * ublas::type_traits::plus_complexity) * runs / - (1024 * 1024 * elapsed) << " Mflops" << std::endl; } }; @@ -56,18 +52,9 @@ struct c_matrix_traits { template struct initialize_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_vector_traits::type v) { -#else void operator () (typename c_vector_traits::type &v) { -#endif for (int i = 0; i < N; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif // v [i] = 0.f; } }; @@ -76,29 +63,16 @@ BOOST_UBLAS_INLINE void initialize_vector (V &v) { int size = v.size (); for (int i = 0; i < size; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif // v [i] = 0.f; } template struct initialize_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_matrix_traits::type m) { -#else void operator () (typename c_matrix_traits::type &m) { -#endif for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE m [i] [j] = std::rand () * 1.f; -#else - m [i] [j] = ::rand () * 1.f; -#endif // m [i] [j] = 0.f; } }; @@ -109,11 +83,7 @@ void initialize_matrix (M &m) { int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) for (int j = 0; j < size2; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE m (i, j) = std::rand () * 1.f; -#else - m (i, j) = ::rand () * 1.f; -#endif // m (i, j) = 0.f; } @@ -125,12 +95,7 @@ void sink_scalar (const T &s) { template struct sink_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_vector_traits::type v) { -#else void operator () (const typename c_vector_traits::type &v) { -#endif static typename c_vector_traits::type g_v; for (int i = 0; i < N; ++ i) g_v [i] = v [i]; @@ -144,12 +109,7 @@ void sink_vector (const V &v) { template struct sink_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_matrix_traits::type m) { -#else void operator () (const typename c_matrix_traits::type &m) { -#endif static typename c_matrix_traits::type g_m; for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) @@ -185,7 +145,7 @@ struct bench_3 { struct safe_tag {}; struct fast_tag {}; -#define USE_FLOAT +//#define USE_FLOAT #define USE_DOUBLE // #define USE_STD_COMPLEX @@ -193,7 +153,7 @@ struct fast_tag {}; // #define USE_BOUNDED_ARRAY #define USE_UNBOUNDED_ARRAY // #define USE_STD_VALARRAY -#define USE_STD_VECTOR +//#define USE_STD_VECTOR #endif diff --git a/bench1/bench11.cpp b/bench1/bench11.cpp index 5c5767d6..d75a3172 100644 --- a/bench1/bench11.cpp +++ b/bench1/bench11.cpp @@ -38,9 +38,6 @@ struct bench_c_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -63,9 +60,6 @@ struct bench_my_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -88,9 +82,6 @@ struct bench_cpp_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -115,9 +106,6 @@ struct bench_c_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -139,9 +127,6 @@ struct bench_my_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -158,9 +143,6 @@ struct bench_my_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -182,9 +164,6 @@ struct bench_cpp_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -308,5 +287,3 @@ template struct bench_1, 30>; template struct bench_1, 100>; #endif #endif - - diff --git a/bench1/bench12.cpp b/bench1/bench12.cpp index 0dbc8a23..90ebc054 100644 --- a/bench1/bench12.cpp +++ b/bench1/bench12.cpp @@ -40,9 +40,6 @@ struct bench_c_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -65,9 +62,6 @@ struct bench_my_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -85,9 +79,6 @@ struct bench_my_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -114,9 +105,6 @@ struct bench_cpp_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -145,9 +133,6 @@ struct bench_c_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -170,9 +155,6 @@ struct bench_my_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -190,9 +172,6 @@ struct bench_my_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -218,9 +197,6 @@ struct bench_cpp_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -247,9 +223,6 @@ struct bench_c_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -271,9 +244,6 @@ struct bench_my_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -290,9 +260,6 @@ struct bench_my_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -314,9 +281,6 @@ struct bench_cpp_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -525,5 +489,3 @@ template struct bench_2, 30>; template struct bench_2, 100>; #endif #endif - - diff --git a/bench1/bench13.cpp b/bench1/bench13.cpp index fca4f4a3..9b983610 100644 --- a/bench1/bench13.cpp +++ b/bench1/bench13.cpp @@ -42,9 +42,6 @@ struct bench_c_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -66,9 +63,6 @@ struct bench_my_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -85,9 +79,6 @@ struct bench_my_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -115,9 +106,6 @@ struct bench_cpp_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -206,6 +194,3 @@ template struct bench_3, 30>; template struct bench_3, 100>; #endif #endif - - - diff --git a/bench2/bench2.cpp b/bench2/bench2.cpp index 82d1a463..680b99bc 100644 --- a/bench2/bench2.cpp +++ b/bench2/bench2.cpp @@ -18,7 +18,6 @@ void header (std::string text) { std::cout << text << std::endl; - std::cerr << text << std::endl; } template @@ -38,9 +37,6 @@ struct peak_c_plus { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -60,9 +56,6 @@ struct peak_c_multiplies { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -77,160 +70,57 @@ void peak::operator () (int runs) { peak_c_multiplies () (runs); } -template struct peak; -template struct peak; -template struct peak >; -template struct peak >; -#ifdef BOOST_MSVC -// Standard new handler is not standard compliant. -#include -int __cdecl std_new_handler (unsigned) { - throw std::bad_alloc (); +template +void do_bench (std::string type_string, int scale) +{ + header (type_string); + peak () (1000000 * scale); + + header (type_string + ", 3"); + bench_1 () (1000000 * scale); + bench_2 () (300000 * scale); + bench_3 () (100000 * scale); + + header (type_string + ", 10"); + bench_1 () (300000 * scale); + bench_2 () (30000 * scale); + bench_3 () (3000 * scale); + + header (type_string + ", 30"); + bench_1 () (100000 * scale); + bench_2 () (3000 * scale); + bench_3 () (100 * scale); + + header (type_string + ", 100"); + bench_1 () (30000 * scale); + bench_2 () (300 * scale); + bench_3 () (3 * scale); } -#endif int main (int argc, char *argv []) { -#ifdef BOOST_MSVC - _set_new_handler (std_new_handler); -#endif - -#ifdef USE_FLOAT - header ("float"); - peak () (100000000); -#endif - -#ifdef USE_DOUBLE - header ("double"); - peak () (100000000); -#endif - -#ifdef USE_STD_COMPLEX -#ifdef USE_FLOAT - header ("std:complex"); - peak > () (100000000); -#endif - -#ifdef USE_DOUBLE - header ("std:complex"); - peak > () (100000000); -#endif -#endif int scale = 1; if (argc > 1) -#ifndef BOOST_NO_STDC_NAMESPACE scale = std::atoi (argv [1]); -#else - scale = ::atoi (argv [1]); -#endif #ifdef USE_FLOAT - header ("float, 3"); - - bench_1 () (1000000 * scale); - bench_2 () (300000 * scale); - bench_3 () (100000 * scale); - - header ("float, 10"); - - bench_1 () (300000 * scale); - bench_2 () (30000 * scale); - bench_3 () (3000 * scale); - - header ("float, 30"); - - bench_1 () (100000 * scale); - bench_2 () (3000 * scale); - bench_3 () (100 * scale); - - header ("float, 100"); - - bench_1 () (30000 * scale); - bench_2 () (300 * scale); - bench_3 () (3 * scale); + do_bench ("FLOAT", scale); #endif #ifdef USE_DOUBLE - header ("double, 3"); - - bench_1 () (1000000 * scale); - bench_2 () (300000 * scale); - bench_3 () (100000 * scale); - - header ("double, 10"); - - bench_1 () (300000 * scale); - bench_2 () (30000 * scale); - bench_3 () (3000 * scale); - - header ("double, 30"); - - bench_1 () (100000 * scale); - bench_2 () (3000 * scale); - bench_3 () (100 * scale); - - header ("double, 100"); - - bench_1 () (30000 * scale); - bench_2 () (300 * scale); - bench_3 () (3 * scale); + do_bench ("DOUBLE", scale); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT - header ("std::complex, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("std::complex, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("std::complex, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("std::complex, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); + do_bench > ("COMPLEX", scale); #endif #ifdef USE_DOUBLE - header ("std::complex, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("std::complex, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("std::complex, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("std::complex, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); + do_bench > ("COMPLEX", scale); #endif #endif return 0; } - diff --git a/bench2/bench2.hpp b/bench2/bench2.hpp index b6b01566..e7a7ad76 100644 --- a/bench2/bench2.hpp +++ b/bench2/bench2.hpp @@ -39,10 +39,6 @@ struct footer { << (multiplies * ublas::type_traits::multiplies_complexity + plus * ublas::type_traits::plus_complexity) * runs / (1024 * 1024 * elapsed) << " Mflops" << std::endl; - std::cerr << "elapsed: " << elapsed << " s, " - << (multiplies * ublas::type_traits::multiplies_complexity + - plus * ublas::type_traits::plus_complexity) * runs / - (1024 * 1024 * elapsed) << " Mflops" << std::endl; } }; @@ -57,18 +53,9 @@ struct c_matrix_traits { template struct initialize_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_vector_traits::type v) { -#else void operator () (typename c_vector_traits::type &v) { -#endif for (int i = 0; i < N; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif // v [i] = 0.f; } }; @@ -77,29 +64,16 @@ BOOST_UBLAS_INLINE void initialize_vector (V &v) { int size = v.size (); for (int i = 0; i < size; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif // v [i] = 0.f; } template struct initialize_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_matrix_traits::type m) { -#else void operator () (typename c_matrix_traits::type &m) { -#endif for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE m [i] [j] = std::rand () * 1.f; -#else - m [i] [j] = ::rand () * 1.f; -#endif // m [i] [j] = 0.f; } }; @@ -110,11 +84,7 @@ void initialize_matrix (M &m, ublas::row_major_tag) { int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) for (int j = 0; j < size2; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE m (i, j) = std::rand () * 1.f; -#else - m (i, j) = ::rand () * 1.f; -#endif // m (i, j) = 0.f; } template @@ -124,11 +94,7 @@ void initialize_matrix (M &m, ublas::column_major_tag) { int size2 = m.size2 (); for (int j = 0; j < size2; ++ j) for (int i = 0; i < size1; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE m (i, j) = std::rand () * 1.f; -#else - m (i, j) = ::rand () * 1.f; -#endif // m (i, j) = 0.f; } template @@ -146,12 +112,7 @@ void sink_scalar (const T &s) { template struct sink_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_vector_traits::type v) { -#else void operator () (const typename c_vector_traits::type &v) { -#endif static typename c_vector_traits::type g_v; for (int i = 0; i < N; ++ i) g_v [i] = v [i]; @@ -165,12 +126,7 @@ void sink_vector (const V &v) { template struct sink_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_matrix_traits::type m) { -#else void operator () (const typename c_matrix_traits::type &m) { -#endif static typename c_matrix_traits::type g_m; for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) @@ -224,5 +180,3 @@ struct fast_tag {}; #define USE_COORDINATE_MATRIX #endif - - diff --git a/bench2/bench21.cpp b/bench2/bench21.cpp index 99c34528..070d6b34 100644 --- a/bench2/bench21.cpp +++ b/bench2/bench21.cpp @@ -38,9 +38,6 @@ struct bench_c_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -63,9 +60,6 @@ struct bench_my_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -88,9 +82,6 @@ struct bench_cpp_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -115,9 +106,6 @@ struct bench_c_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -139,9 +127,6 @@ struct bench_my_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -158,9 +143,6 @@ struct bench_my_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -182,9 +164,6 @@ struct bench_cpp_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -303,5 +282,3 @@ template struct bench_1, 30>; template struct bench_1, 100>; #endif #endif - - diff --git a/bench2/bench22.cpp b/bench2/bench22.cpp index e6673b78..ea1bfe1b 100644 --- a/bench2/bench22.cpp +++ b/bench2/bench22.cpp @@ -40,9 +40,6 @@ struct bench_c_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -65,9 +62,6 @@ struct bench_my_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -85,9 +79,6 @@ struct bench_my_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -114,9 +105,6 @@ struct bench_cpp_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -145,9 +133,6 @@ struct bench_c_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -170,9 +155,6 @@ struct bench_my_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -190,9 +172,6 @@ struct bench_my_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -218,9 +197,6 @@ struct bench_cpp_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -247,9 +223,6 @@ struct bench_c_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -271,9 +244,6 @@ struct bench_my_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -290,9 +260,6 @@ struct bench_my_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -314,9 +281,6 @@ struct bench_cpp_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -503,5 +467,3 @@ template struct bench_2, 30>; template struct bench_2, 100>; #endif #endif - - diff --git a/bench2/bench23.cpp b/bench2/bench23.cpp index dd96ee13..a59d9f6d 100644 --- a/bench2/bench23.cpp +++ b/bench2/bench23.cpp @@ -42,9 +42,6 @@ struct bench_c_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -67,9 +64,6 @@ struct bench_my_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -87,9 +81,6 @@ struct bench_my_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -117,9 +108,6 @@ struct bench_cpp_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -210,5 +198,3 @@ template struct bench_3, 30>; template struct bench_3, 100>; #endif #endif - - diff --git a/bench3/bench3.cpp b/bench3/bench3.cpp index dafceec7..a073e195 100644 --- a/bench3/bench3.cpp +++ b/bench3/bench3.cpp @@ -18,7 +18,6 @@ void header (std::string text) { std::cout << text << std::endl; - std::cerr << text << std::endl; } template @@ -38,9 +37,6 @@ struct peak_c_plus { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -60,9 +56,6 @@ struct peak_c_multiplies { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -77,160 +70,57 @@ void peak::operator () (int runs) { peak_c_multiplies () (runs); } -template struct peak; -template struct peak; -template struct peak >; -template struct peak >; -#ifdef BOOST_MSVC -// Standard new handler is not standard compliant. -#include -int __cdecl std_new_handler (unsigned) { - throw std::bad_alloc (); +template +void do_bench (std::string type_string, int scale) +{ + header (type_string); + peak () (1000000 * scale); + + header (type_string + ", 3"); + bench_1 () (1000000 * scale); + bench_2 () (300000 * scale); + bench_3 () (100000 * scale); + + header (type_string + ", 10"); + bench_1 () (300000 * scale); + bench_2 () (30000 * scale); + bench_3 () (3000 * scale); + + header (type_string + ", 30"); + bench_1 () (100000 * scale); + bench_2 () (3000 * scale); + bench_3 () (100 * scale); + + header (type_string + ", 100"); + bench_1 () (30000 * scale); + bench_2 () (300 * scale); + bench_3 () (3 * scale); } -#endif int main (int argc, char *argv []) { -#ifdef BOOST_MSVC - _set_new_handler (std_new_handler); -#endif - -#ifdef USE_FLOAT - header ("float"); - peak () (100000000); -#endif - -#ifdef USE_DOUBLE - header ("double"); - peak () (100000000); -#endif - -#ifdef USE_STD_COMPLEX -#ifdef USE_FLOAT - header ("std:complex"); - peak > () (100000000); -#endif - -#ifdef USE_DOUBLE - header ("std:complex"); - peak > () (100000000); -#endif -#endif int scale = 1; if (argc > 1) -#ifndef BOOST_NO_STDC_NAMESPACE scale = std::atoi (argv [1]); -#else - scale = ::atoi (argv [1]); -#endif #ifdef USE_FLOAT - header ("float, 3"); - - bench_1 () (1000000 * scale); - bench_2 () (300000 * scale); - bench_3 () (100000 * scale); - - header ("float, 10"); - - bench_1 () (300000 * scale); - bench_2 () (30000 * scale); - bench_3 () (3000 * scale); - - header ("float, 30"); - - bench_1 () (100000 * scale); - bench_2 () (3000 * scale); - bench_3 () (100 * scale); - - header ("float, 100"); - - bench_1 () (30000 * scale); - bench_2 () (300 * scale); - bench_3 () (3 * scale); + do_bench ("FLOAT", scale); #endif #ifdef USE_DOUBLE - header ("double, 3"); - - bench_1 () (1000000 * scale); - bench_2 () (300000 * scale); - bench_3 () (100000 * scale); - - header ("double, 10"); - - bench_1 () (300000 * scale); - bench_2 () (30000 * scale); - bench_3 () (3000 * scale); - - header ("double, 30"); - - bench_1 () (100000 * scale); - bench_2 () (3000 * scale); - bench_3 () (100 * scale); - - header ("double, 100"); - - bench_1 () (30000 * scale); - bench_2 () (300 * scale); - bench_3 () (3 * scale); + do_bench ("DOUBLE", scale); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT - header ("std::complex, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("std::complex, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("std::complex, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("std::complex, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); + do_bench > ("COMPLEX", scale); #endif #ifdef USE_DOUBLE - header ("std::complex, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("std::complex, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("std::complex, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("std::complex, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); + do_bench > ("COMPLEX", scale); #endif #endif return 0; } - diff --git a/bench3/bench3.hpp b/bench3/bench3.hpp index c4885fb6..287a7251 100644 --- a/bench3/bench3.hpp +++ b/bench3/bench3.hpp @@ -39,10 +39,6 @@ struct footer { << (multiplies * ublas::type_traits::multiplies_complexity + plus * ublas::type_traits::plus_complexity) * runs / (1024 * 1024 * elapsed) << " Mflops" << std::endl; - std::cerr << "elapsed: " << elapsed << " s, " - << (multiplies * ublas::type_traits::multiplies_complexity + - plus * ublas::type_traits::plus_complexity) * runs / - (1024 * 1024 * elapsed) << " Mflops" << std::endl; } }; @@ -57,18 +53,9 @@ struct c_matrix_traits { template struct initialize_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_vector_traits::type v) { -#else void operator () (typename c_vector_traits::type &v) { -#endif for (int i = 0; i < N; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif // v [i] = 0.f; } }; @@ -77,29 +64,16 @@ BOOST_UBLAS_INLINE void initialize_vector (V &v) { int size = v.size (); for (int i = 0; i < size; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif // v [i] = 0.f; } template struct initialize_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_matrix_traits::type m) { -#else void operator () (typename c_matrix_traits::type &m) { -#endif for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE m [i] [j] = std::rand () * 1.f; -#else - m [i] [j] = ::rand () * 1.f; -#endif // m [i] [j] = 0.f; } }; @@ -110,11 +84,7 @@ void initialize_matrix (M &m) { int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) for (int j = 0; j < size2; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE m (i, j) = std::rand () * 1.f; -#else - m (i, j) = ::rand () * 1.f; -#endif // m (i, j) = 0.f; } @@ -126,12 +96,7 @@ void sink_scalar (const T &s) { template struct sink_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_vector_traits::type v) { -#else void operator () (const typename c_vector_traits::type &v) { -#endif static typename c_vector_traits::type g_v; for (int i = 0; i < N; ++ i) g_v [i] = v [i]; @@ -145,12 +110,7 @@ void sink_vector (const V &v) { template struct sink_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_matrix_traits::type m) { -#else void operator () (const typename c_matrix_traits::type &m) { -#endif static typename c_matrix_traits::type g_m; for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) @@ -197,5 +157,3 @@ struct fast_tag {}; #define USE_STD_VECTOR #endif - - diff --git a/bench3/bench31.cpp b/bench3/bench31.cpp index 3be711ef..6d783f05 100644 --- a/bench3/bench31.cpp +++ b/bench3/bench31.cpp @@ -38,9 +38,6 @@ struct bench_c_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -65,9 +62,6 @@ struct bench_my_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -90,9 +84,6 @@ struct bench_cpp_inner_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -117,9 +108,6 @@ struct bench_c_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -145,9 +133,6 @@ struct bench_my_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -167,9 +152,6 @@ struct bench_my_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -191,9 +173,6 @@ struct bench_cpp_vector_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -317,5 +296,3 @@ template struct bench_1, 30>; template struct bench_1, 100>; #endif #endif - - diff --git a/bench3/bench32.cpp b/bench3/bench32.cpp index 41e4089d..68c01783 100644 --- a/bench3/bench32.cpp +++ b/bench3/bench32.cpp @@ -40,9 +40,6 @@ struct bench_c_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -68,9 +65,6 @@ struct bench_my_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -91,9 +85,6 @@ struct bench_my_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -120,9 +111,6 @@ struct bench_cpp_outer_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -151,9 +139,6 @@ struct bench_c_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -179,9 +164,6 @@ struct bench_my_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -202,9 +184,6 @@ struct bench_my_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -230,9 +209,6 @@ struct bench_cpp_matrix_vector_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -259,9 +235,6 @@ struct bench_c_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -283,9 +256,6 @@ struct bench_my_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -302,9 +272,6 @@ struct bench_my_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -326,9 +293,6 @@ struct bench_cpp_matrix_add { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -537,5 +501,3 @@ template struct bench_2, 30>; template struct bench_2, 100>; #endif #endif - - diff --git a/bench3/bench33.cpp b/bench3/bench33.cpp index 56bd8e59..57e20c2c 100644 --- a/bench3/bench33.cpp +++ b/bench3/bench33.cpp @@ -42,9 +42,6 @@ struct bench_c_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -69,9 +66,6 @@ struct bench_my_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } void operator () (int runs, fast_tag) const { try { @@ -91,9 +85,6 @@ struct bench_my_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -121,9 +112,6 @@ struct bench_cpp_matrix_prod { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -212,5 +200,3 @@ template struct bench_3, 30>; template struct bench_3, 100>; #endif #endif - - diff --git a/bench4/bench4.cpp b/bench4/bench4.cpp index 82db22c6..824676f3 100644 --- a/bench4/bench4.cpp +++ b/bench4/bench4.cpp @@ -14,11 +14,12 @@ // GeNeSys mbH & Co. KG in producing this work. // -#include "bench4.hpp" +#include +#include +#include "../bench1/bench1.hpp" void header (std::string text) { std::cout << text << std::endl; - std::cerr << text << std::endl; } template @@ -38,9 +39,6 @@ struct peak_c_plus { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; template @@ -60,9 +58,6 @@ struct peak_c_multiplies { catch (std::exception &e) { std::cout << e.what () << std::endl; } - catch (...) { - std::cout << "unknown exception" << std::endl; - } } }; @@ -87,155 +82,58 @@ template struct peak > >; #endif -#ifdef BOOST_MSVC -// Standard new handler is not standard compliant. -#include -int __cdecl std_new_handler (unsigned) { - throw std::bad_alloc (); + + +template +void do_bench (std::string type_string, int scale) +{ + header (type_string); + peak () (1000000 * scale); + + header (type_string + ", 3"); + bench_1 () (1000000 * scale); + bench_2 () (300000 * scale); + bench_3 () (100000 * scale); + + header (type_string + ", 10"); + bench_1 () (300000 * scale); + bench_2 () (30000 * scale); + bench_3 () (3000 * scale); + + header (type_string + ", 30"); + bench_1 () (100000 * scale); + bench_2 () (3000 * scale); + bench_3 () (100 * scale); + + header (type_string + ", 100"); + bench_1 () (30000 * scale); + bench_2 () (300 * scale); + bench_3 () (3 * scale); } -#endif int main (int argc, char *argv []) { -#ifdef BOOST_MSVC - _set_new_handler (std_new_handler); -#endif + + int scale = 1; + if (argc > 1) + scale = std::atoi (argv [1]); #ifdef USE_FLOAT - header ("boost::numeric::interval"); - peak > () (100000000); + do_bench > ("boost::numeric::interval", scale); #endif #ifdef USE_DOUBLE - header ("boost::numeric::interval"); - peak > () (100000000); + do_bench > ("boost::numeric::interval", scale); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT - header ("std:complex >"); - peak > > () (100000000); + do_bench > > ("boost::numeric::interval>", scale); #endif #ifdef USE_DOUBLE - header ("std:complex >"); - peak > > () (100000000); -#endif -#endif - - int scale = 1; - if (argc > 1) -#ifndef BOOST_NO_STDC_NAMESPACE - scale = std::atoi (argv [1]); -#else - scale = ::atoi (argv [1]); -#endif - -#ifdef USE_FLOAT - header ("boost::numeric::interval, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("boost::numeric::interval, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("boost::numeric::interval, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("boost::numeric::interval, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); -#endif - -#ifdef USE_DOUBLE - header ("boost::numeric::interval, 3"); - - bench_1, 3> () (1000000 * scale); - bench_2, 3> () (300000 * scale); - bench_3, 3> () (100000 * scale); - - header ("boost::numeric::interval, 10"); - - bench_1, 10> () (300000 * scale); - bench_2, 10> () (30000 * scale); - bench_3, 10> () (3000 * scale); - - header ("boost::numeric::interval, 30"); - - bench_1, 30> () (100000 * scale); - bench_2, 30> () (3000 * scale); - bench_3, 30> () (100 * scale); - - header ("boost::numeric::interval, 100"); - - bench_1, 100> () (30000 * scale); - bench_2, 100> () (300 * scale); - bench_3, 100> () (3 * scale); -#endif - -#ifdef USE_BOOST_COMPLEX -#ifdef USE_FLOAT - header ("boost::complex >, 3"); - - bench_1 >, 3> () (1000000 * scale); - bench_2 >, 3> () (300000 * scale); - bench_3 >, 3> () (100000 * scale); - - header ("boost::complex >, 10"); - - bench_1 >, 10> () (300000 * scale); - bench_2 >, 10> () (30000 * scale); - bench_3 >, 10> () (3000 * scale); - - header ("boost::complex >, 30"); - - bench_1 >, 30> () (100000 * scale); - bench_2 >, 30> () (3000 * scale); - bench_3 >, 30> () (100 * scale); - - header ("boost::complex >, 100"); - - bench_1 >, 100> () (30000 * scale); - bench_2 >, 100> () (300 * scale); - bench_3 >, 100> () (3 * scale); -#endif - -#ifdef USE_DOUBLE - header ("boost::complex >, 3"); - - bench_1 >, 3> () (1000000 * scale); - bench_2 >, 3> () (300000 * scale); - bench_3 >, 3> () (100000 * scale); - - header ("boost::complex >, 10"); - - bench_1 >, 10> () (300000 * scale); - bench_2 >, 10> () (30000 * scale); - bench_3 >, 10> () (3000 * scale); - - header ("boost::complex >, 30"); - - bench_1 >, 30> () (100000 * scale); - bench_2 >, 30> () (3000 * scale); - bench_3 >, 30> () (100 * scale); - - header ("boost::complex >, 100"); - - bench_1 >, 100> () (30000 * scale); - bench_2 >, 100> () (300 * scale); - bench_3 >, 100> () (3 * scale); + do_bench > > ("boost::numeric::interval>", scale); #endif #endif return 0; } - diff --git a/bench4/bench4.hpp b/bench4/bench4.hpp deleted file mode 100644 index 7355a163..00000000 --- a/bench4/bench4.hpp +++ /dev/null @@ -1,202 +0,0 @@ -// -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch -// -// Permission to use, copy, modify, distribute and sell this software -// and its documentation for any purpose is hereby granted without fee, -// provided that the above copyright notice appear in all copies and -// that both that copyright notice and this permission notice appear -// in supporting documentation. The authors make no representations -// about the suitability of this software for any purpose. -// It is provided "as is" without express or implied warranty. -// -// The authors gratefully acknowledge the support of -// GeNeSys mbH & Co. KG in producing this work. -// - -#ifndef BENCH4_H -#define BENCH4_H - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -namespace ublas = boost::numeric::ublas; - -void header (std::string text); - -template -struct footer { - void operator () (int multiplies, int plus, int runs, double elapsed) { - std::cout << "elapsed: " << elapsed << " s, " - << (multiplies * ublas::type_traits::multiplies_complexity + - plus * ublas::type_traits::plus_complexity) * runs / - (1024 * 1024 * elapsed) << " Mflops" << std::endl; - std::cerr << "elapsed: " << elapsed << " s, " - << (multiplies * ublas::type_traits::multiplies_complexity + - plus * ublas::type_traits::plus_complexity) * runs / - (1024 * 1024 * elapsed) << " Mflops" << std::endl; - } -}; - -template -struct c_vector_traits { - typedef T type [N]; -}; -template -struct c_matrix_traits { - typedef T type [N] [M]; -}; - -template -struct initialize_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_vector_traits::type v) { -#else - void operator () (typename c_vector_traits::type &v) { -#endif - for (int i = 0; i < N; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE - v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif -// v [i] = 0.f; - } -}; -template -BOOST_UBLAS_INLINE -void initialize_vector (V &v) { - int size = v.size (); - for (int i = 0; i < size; ++ i) -#ifndef BOOST_NO_STDC_NAMESPACE - v [i] = std::rand () * 1.f; -#else - v [i] = ::rand () * 1.f; -#endif -// v [i] = 0.f; -} - -template -struct initialize_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (typename c_matrix_traits::type m) { -#else - void operator () (typename c_matrix_traits::type &m) { -#endif - for (int i = 0; i < N; ++ i) - for (int j = 0; j < M; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE - m [i] [j] = std::rand () * 1.f; -#else - m [i] [j] = ::rand () * 1.f; -#endif -// m [i] [j] = 0.f; - } -}; -template -BOOST_UBLAS_INLINE -void initialize_matrix (M &m) { - int size1 = m.size1 (); - int size2 = m.size2 (); - for (int i = 0; i < size1; ++ i) - for (int j = 0; j < size2; ++ j) -#ifndef BOOST_NO_STDC_NAMESPACE - m (i, j) = std::rand () * 1.f; -#else - m (i, j) = ::rand () * 1.f; -#endif -// m (i, j) = 0.f; -} - -template -BOOST_UBLAS_INLINE -void sink_scalar (const T &s) { - static T g_s = s; -} - -template -struct sink_c_vector { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_vector_traits::type v) { -#else - void operator () (const typename c_vector_traits::type &v) { -#endif - static typename c_vector_traits::type g_v; - for (int i = 0; i < N; ++ i) - g_v [i] = v [i]; - } -}; -template -BOOST_UBLAS_INLINE -void sink_vector (const V &v) { - static V g_v (v); -} - -template -struct sink_c_matrix { -#ifdef BOOST_MSVC - BOOST_UBLAS_INLINE - void operator () (const typename c_matrix_traits::type m) { -#else - void operator () (const typename c_matrix_traits::type &m) { -#endif - static typename c_matrix_traits::type g_m; - for (int i = 0; i < N; ++ i) - for (int j = 0; j < M; ++ j) - g_m [i] [j] = m [i] [j]; - } -}; -template -BOOST_UBLAS_INLINE -void sink_matrix (const M &m) { - static M g_m (m); -} - -template -struct peak { - void operator () (int runs); -}; - -template -struct bench_1 { - void operator () (int runs); -}; - -template -struct bench_2 { - void operator () (int runs); -}; - -template -struct bench_3 { - void operator () (int runs); -}; - -struct safe_tag {}; -struct fast_tag {}; - -// #define USE_FLOAT -#define USE_DOUBLE -// #define USE_STD_COMPLEX - -#define USE_C_ARRAY -// #define USE_BOUNDED_ARRAY -#define USE_UNBOUNDED_ARRAY -// #define USE_STD_VALARRAY -#define USE_STD_VECTOR - -#endif - - diff --git a/bench4/bench41.cpp b/bench4/bench41.cpp index eda0a1b3..bf3fbf20 100644 --- a/bench4/bench41.cpp +++ b/bench4/bench41.cpp @@ -14,270 +14,10 @@ // GeNeSys mbH & Co. KG in producing this work. // -#include "bench4.hpp" +#include +#include +#include "../bench1/bench11.cpp" -template -struct bench_c_inner_prod { - typedef T value_type; - - void operator () (int runs) const { - try { - static typename c_vector_traits::type v1, v2; - initialize_c_vector () (v1); - initialize_c_vector () (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - static value_type s (0); - for (int j = 0; j < N; ++ j) { - s += v1 [j] * v2 [j]; - } -// sink_scalar (s); - } - footer () (N, N - 1, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_my_inner_prod { - typedef typename V::value_type value_type; - - void operator () (int runs) const { - try { - static V v1 (N), v2 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - static value_type s (0); - s = ublas::inner_prod (v1, v2); -// sink_scalar (s); - } - footer () (N, N - 1, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_cpp_inner_prod { - typedef typename V::value_type value_type; - - void operator () (int runs) const { - try { - static V v1 (N), v2 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - static value_type s (0); - s = (v1 * v2).sum (); -// sink_scalar (s); - } - footer () (N, N - 1, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; - -template -struct bench_c_vector_add { - typedef T value_type; - - void operator () (int runs) const { - try { - static typename c_vector_traits::type v1, v2, v3; - initialize_c_vector () (v1); - initialize_c_vector () (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - v3 [j] = - (v1 [j] + v2 [j]); - } -// sink_c_vector () (v3); - } - footer () (0, 2 * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_my_vector_add { - typedef typename V::value_type value_type; - - void operator () (int runs, safe_tag) const { - try { - static V v1 (N), v2 (N), v3 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - v3 = - (v1 + v2); -// sink_vector (v3); - } - footer () (0, 2 * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } - void operator () (int runs, fast_tag) const { - try { - static V v1 (N), v2 (N), v3 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - v3.assign (- (v1 + v2)); -// sink_vector (v3); - } - footer () (0, 2 * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_cpp_vector_add { - typedef typename V::value_type value_type; - - void operator () (int runs) const { - try { - static V v1 (N), v2 (N), v3 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - v3 = - (v1 + v2); -// sink_vector (v3); - } - footer () (0, 2 * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; - -// Benchmark O (n) -template -void bench_1::operator () (int runs) { - header ("bench_1"); - - header ("inner_prod"); - - header ("C array"); - bench_c_inner_prod () (runs); - -#ifdef USE_C_ARRAY - header ("c_vector"); - bench_my_inner_prod, N> () (runs); -#endif - -#ifdef USE_BOUNDED_ARRAY - header ("vector"); - bench_my_inner_prod >, N> () (runs); -#endif - -#ifdef USE_UNBOUNDED_ARRAY - header ("vector"); - bench_my_inner_prod >, N> () (runs); -#endif - -#ifdef USE_STD_VALARRAY - header ("vector"); - bench_my_inner_prod >, N> () (); -#endif - -#ifdef USE_STD_VECTOR - header ("vector"); - bench_my_inner_prod >, N> () (runs); -#endif - -#ifdef USE_STD_VALARRAY - header ("std::valarray"); - bench_cpp_inner_prod, N> () (runs); -#endif - - header ("vector + vector"); - - header ("C array"); - bench_c_vector_add () (runs); - -#ifdef USE_C_ARRAY - header ("c_vector safe"); - bench_my_vector_add, N> () (runs, safe_tag ()); - - header ("c_vector fast"); - bench_my_vector_add, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_BOUNDED_ARRAY - header ("vector safe"); - bench_my_vector_add >, N> () (runs, safe_tag ()); - - header ("vector fast"); - bench_my_vector_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_UNBOUNDED_ARRAY - header ("vector safe"); - bench_my_vector_add >, N> () (runs, safe_tag ()); - - header ("vector fast"); - bench_my_vector_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("vector safe"); - bench_my_vector_add >, N> () (runs, safe_tag ()); - - header ("vector fast"); - bench_my_vector_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VECTOR - header ("vector safe"); - bench_my_vector_add >, N> () (runs, safe_tag ()); - - header ("vector fast"); - bench_my_vector_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("std::valarray"); - bench_cpp_vector_add, N> () (runs); -#endif -} #ifdef USE_FLOAT template struct bench_1, 3>; @@ -308,5 +48,3 @@ template struct bench_1 >, 30>; template struct bench_1 >, 100>; #endif #endif - - diff --git a/bench4/bench42.cpp b/bench4/bench42.cpp index 811f342d..f0640cdf 100644 --- a/bench4/bench42.cpp +++ b/bench4/bench42.cpp @@ -14,487 +14,10 @@ // GeNeSys mbH & Co. KG in producing this work. // -#include "bench4.hpp" +#include +#include +#include "../bench1/bench12.cpp" -template -struct bench_c_outer_prod { - typedef T value_type; - - void operator () (int runs) const { - try { - static typename c_matrix_traits::type m; - static typename c_vector_traits::type v1, v2; - initialize_c_vector () (v1); - initialize_c_vector () (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - for (int k = 0; k < N; ++ k) { - m [j] [k] = - v1 [j] * v2 [k]; - } - } -// sink_c_matrix () (m); - } - footer () (N * N, N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_my_outer_prod { - typedef typename M::value_type value_type; - - void operator () (int runs, safe_tag) const { - try { - static M m (N, N); - static V v1 (N), v2 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m = - ublas::outer_prod (v1, v2); -// sink_matrix (m); - } - footer () (N * N, N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } - void operator () (int runs, fast_tag) const { - try { - static M m (N, N); - static V v1 (N), v2 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m.assign (- ublas::outer_prod (v1, v2)); -// sink_matrix (m); - } - footer () (N * N, N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_cpp_outer_prod { - typedef typename M::value_type value_type; - - void operator () (int runs) const { - try { - static M m (N * N); - static V v1 (N), v2 (N); - initialize_vector (v1); - initialize_vector (v2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - for (int k = 0; k < N; ++ k) { - m [N * j + k] = - v1 [j] * v2 [k]; - } - } -// sink_vector (m); - } - footer () (N * N, N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; - -template -struct bench_c_matrix_vector_prod { - typedef T value_type; - - void operator () (int runs) const { - try { - static typename c_matrix_traits::type m; - static typename c_vector_traits::type v1, v2; - initialize_c_matrix () (m); - initialize_c_vector () (v1); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - v2 [j] = 0; - for (int k = 0; k < N; ++ k) { - v2 [j] += m [j] [k] * v1 [k]; - } - } -// sink_c_vector () (v2); - } - footer () (N * N, N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_my_matrix_vector_prod { - typedef typename M::value_type value_type; - - void operator () (int runs, safe_tag) const { - try { - static M m (N, N); - static V v1 (N), v2 (N); - initialize_matrix (m); - initialize_vector (v1); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - v2 = ublas::prod (m, v1); -// sink_vector (v2); - } - footer () (N * N, N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } - void operator () (int runs, fast_tag) const { - try { - static M m (N, N); - static V v1 (N), v2 (N); - initialize_matrix (m); - initialize_vector (v1); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - v2.assign (ublas::prod (m, v1)); -// sink_vector (v2); - } - footer () (N * N, N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_cpp_matrix_vector_prod { - typedef typename M::value_type value_type; - - void operator () (int runs) const { - try { - static M m (N * N); - static V v1 (N), v2 (N); - initialize_vector (m); - initialize_vector (v1); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - std::valarray row (m [std::slice (N * j, N, 1)]); - v2 [j] = (row * v1).sum (); - } -// sink_vector (v2); - } - footer () (N * N, N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; - -template -struct bench_c_matrix_add { - typedef T value_type; - - void operator () (int runs) const { - try { - static typename c_matrix_traits::type m1, m2, m3; - initialize_c_matrix () (m1); - initialize_c_matrix () (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - for (int k = 0; k < N; ++ k) { - m3 [j] [k] = - (m1 [j] [k] + m2 [j] [k]); - } - } -// sink_c_matrix () (m3); - } - footer () (0, 2 * N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_my_matrix_add { - typedef typename M::value_type value_type; - - void operator () (int runs, safe_tag) const { - try { - static M m1 (N, N), m2 (N, N), m3 (N, N); - initialize_matrix (m1); - initialize_matrix (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m3 = - (m1 + m2); -// sink_matrix (m3); - } - footer () (0, 2 * N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } - void operator () (int runs, fast_tag) const { - try { - static M m1 (N, N), m2 (N, N), m3 (N, N); - initialize_matrix (m1); - initialize_matrix (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m3.assign (- (m1 + m2)); -// sink_matrix (m3); - } - footer () (0, 2 * N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_cpp_matrix_add { - typedef typename M::value_type value_type; - - void operator () (int runs) const { - try { - static M m1 (N * N), m2 (N * N), m3 (N * N); - initialize_vector (m1); - initialize_vector (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m3 = - (m1 + m2); -// sink_vector (m3); - } - footer () (0, 2 * N * N, runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; - -// Benchmark O (n ^ 2) -template -void bench_2::operator () (int runs) { - header ("bench_2"); - - header ("outer_prod"); - - header ("C array"); - bench_c_outer_prod () (runs); - -#ifdef USE_C_ARRAY - header ("c_matrix, c_vector safe"); - bench_my_outer_prod, - ublas::c_vector, N> () (runs, safe_tag ()); - - header ("c_matrix, c_vector fast"); - bench_my_outer_prod, - ublas::c_vector, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_BOUNDED_ARRAY - header ("matrix, vector safe"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_UNBOUNDED_ARRAY - header ("matrix, vector safe"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("matrix, vector safe"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VECTOR - header ("matrix, vector safe"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_outer_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("std::valarray"); - bench_cpp_outer_prod, std::valarray, N> () (runs); -#endif - - header ("prod (matrix, vector)"); - - header ("C array"); - bench_c_matrix_vector_prod () (runs); - -#ifdef USE_C_ARRAY - header ("c_matrix, c_vector safe"); - bench_my_matrix_vector_prod, - ublas::c_vector, N> () (runs, safe_tag ()); - - header ("c_matrix, c_vector fast"); - bench_my_matrix_vector_prod, - ublas::c_vector, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_BOUNDED_ARRAY - header ("matrix, vector safe"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_UNBOUNDED_ARRAY - header ("matrix, vector safe"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("matrix, vector safe"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VECTOR - header ("matrix, vector safe"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, safe_tag ()); - - header ("matrix, vector fast"); - bench_my_matrix_vector_prod >, - ublas::vector >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("std::valarray"); - bench_cpp_matrix_vector_prod, std::valarray, N> () (runs); -#endif - - header ("matrix + matrix"); - - header ("C array"); - bench_c_matrix_add () (runs); - -#ifdef USE_C_ARRAY - header ("c_matrix safe"); - bench_my_matrix_add, N> () (runs, safe_tag ()); - - header ("c_matrix fast"); - bench_my_matrix_add, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_BOUNDED_ARRAY - header ("matrix safe"); - bench_my_matrix_add >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_UNBOUNDED_ARRAY - header ("matrix safe"); - bench_my_matrix_add >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("matrix safe"); - bench_my_matrix_add >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VECTOR - header ("matrix safe"); - bench_my_matrix_add >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_add >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("std::valarray"); - bench_cpp_matrix_add, N> () (runs); -#endif -} #ifdef USE_FLOAT template struct bench_2, 3>; @@ -525,5 +48,3 @@ template struct bench_2 >, 30>; template struct bench_2 >, 100>; #endif #endif - - diff --git a/bench4/bench43.cpp b/bench4/bench43.cpp index 11d1c88f..432283ae 100644 --- a/bench4/bench43.cpp +++ b/bench4/bench43.cpp @@ -14,168 +14,10 @@ // GeNeSys mbH & Co. KG in producing this work. // -#include "bench4.hpp" +#include +#include +#include "../bench1/bench13.cpp" -template -struct bench_c_matrix_prod { - typedef T value_type; - - void operator () (int runs) const { - try { - static typename c_matrix_traits::type m1, m2, m3; - initialize_c_matrix () (m1); - initialize_c_matrix () (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - for (int k = 0; k < N; ++ k) { - m3 [j] [k] = 0; - for (int l = 0; l < N; ++ l) { - m3 [j] [k] += m1 [j] [l] * m2 [l] [k]; - } - } - } -// sink_c_matrix () (m3); - } - footer () (N * N * N, N * N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_my_matrix_prod { - typedef typename M::value_type value_type; - - void operator () (int runs, safe_tag) const { - try { - static M m1 (N, N), m2 (N, N), m3 (N, N); - initialize_matrix (m1); - initialize_matrix (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m3 = ublas::prod (m1, m2); -// sink_matrix (m3); - } - footer () (N * N * N, N * N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } - void operator () (int runs, fast_tag) const { - try { - static M m1 (N, N), m2 (N, N), m3 (N, N); - initialize_matrix (m1); - initialize_matrix (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - m3.assign (ublas::prod (m1, m2)); -// sink_matrix (m3); - } - footer () (N * N * N, N * N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; -template -struct bench_cpp_matrix_prod { - typedef typename M::value_type value_type; - - void operator () (int runs) const { - try { - static M m1 (N * N), m2 (N * N), m3 (N * N); - initialize_vector (m1); - initialize_vector (m2); - boost::timer t; - for (int i = 0; i < runs; ++ i) { - for (int j = 0; j < N; ++ j) { - std::valarray row (m1 [std::slice (N * j, N, 1)]); - for (int k = 0; k < N; ++ k) { - std::valarray column (m2 [std::slice (k, N, N)]); - m3 [N * j + k] = (row * column).sum (); - } - } -// sink_vector (m3); - } - footer () (N * N * N, N * N * (N - 1), runs, t.elapsed ()); - } - catch (std::exception &e) { - std::cout << e.what () << std::endl; - } - catch (...) { - std::cout << "unknown exception" << std::endl; - } - } -}; - -// Benchmark O (n ^ 3) -template -void bench_3::operator () (int runs) { - header ("bench_3"); - - header ("prod (matrix, matrix)"); - - header ("C array"); - bench_c_matrix_prod () (runs); - -#ifdef USE_C_ARRAY - header ("c_matrix safe"); - bench_my_matrix_prod, N> () (runs, safe_tag ()); - - header ("c_matrix fast"); - bench_my_matrix_prod, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_BOUNDED_ARRAY - header ("matrix safe"); - bench_my_matrix_prod >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_prod >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_UNBOUNDED_ARRAY - header ("matrix safe"); - bench_my_matrix_prod >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_prod >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("matrix safe"); - bench_my_matrix_prod >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_prod >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VECTOR - header ("matrix safe"); - bench_my_matrix_prod >, N> () (runs, safe_tag ()); - - header ("matrix fast"); - bench_my_matrix_prod >, N> () (runs, fast_tag ()); -#endif - -#ifdef USE_STD_VALARRAY - header ("std::valarray"); - bench_cpp_matrix_prod, N> () (runs); -#endif -} #ifdef USE_FLOAT template struct bench_3, 3>; @@ -206,5 +48,3 @@ template struct bench_3 >, 30>; template struct bench_3 >, 100>; #endif #endif - - diff --git a/index.html b/index.html deleted file mode 100644 index 81d68369..00000000 --- a/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - -Awaiting automatic redirection to uBLAS documentation index. -Please go to doc/index.htm. - - \ No newline at end of file