Skylark (Sketching Library)
0.1
|
00001 #ifndef SKYLARK_TIMER_HPP 00002 #define SKYLARK_TIMER_HPP 00003 00004 #ifdef SKYLARK_HAVE_PROFILER 00005 00006 #define SKYLARK_TIMER_INITIALIZE(X) \ 00007 boost::mpi::timer X##_timer; \ 00008 double X##_time = 0.0; \ 00009 00010 #define SKYLARK_TIMER_RESTART(X) \ 00011 X##_timer.restart(); \ 00012 00013 #define SKYLARK_TIMER_ACCUMULATE(X) \ 00014 X##_time += X##_timer.elapsed(); \ 00015 00016 #define SKYLARK_TIMER_PRINT(X, BOOST_COMM) \ 00017 if (BOOST_COMM.rank() == 0) { \ 00018 double X##_time_min, X##_time_max, X##_time_ave; \ 00019 boost::mpi::reduce(BOOST_COMM, \ 00020 X##_time, \ 00021 X##_time_min, \ 00022 boost::mpi::minimum<double>(), \ 00023 0); \ 00024 boost::mpi::reduce(BOOST_COMM, \ 00025 X##_time, \ 00026 X##_time_max, \ 00027 boost::mpi::maximum<double>(), \ 00028 0); \ 00029 boost::mpi::reduce(BOOST_COMM, \ 00030 X##_time, \ 00031 X##_time_ave, \ 00032 std::plus<double>(), \ 00033 0); \ 00034 X##_time_ave = X##_time_ave / BOOST_COMM.size(); \ 00035 std::cout << #X << " time (secs)" << std::endl; \ 00036 std::cout << "Min: " << X##_time_min << std::endl; \ 00037 std::cout << "Max: " << X##_time_max << std::endl; \ 00038 std::cout << "Ave: " << X##_time_ave << std::endl; \ 00039 std::cout << std::endl; \ 00040 } else { \ 00041 boost::mpi::reduce(BOOST_COMM, \ 00042 X##_time, \ 00043 boost::mpi::minimum<double>(), \ 00044 0); \ 00045 boost::mpi::reduce(BOOST_COMM, \ 00046 X##_time, \ 00047 boost::mpi::maximum<double>(), \ 00048 0); \ 00049 boost::mpi::reduce(BOOST_COMM, \ 00050 X##_time, \ 00051 std::plus<double>(), \ 00052 0); \ 00053 } \ 00054 00055 #else //SKYLARK_HAVE_PROFILER 00056 00057 #define SKYLARK_TIMER_INITIALIZE(X) 00058 #define SKYLARK_TIMER_RESTART(X) 00059 #define SKYLARK_TIMER_ACCUMULATE(X) 00060 #define SKYLARK_TIMER_PRINT(X, BOOST_COMM) 00061 00062 #endif //SKYLARK_HAVE_PROFILER 00063 00064 #endif //SKYLARK_TIMER_HPP