29 #include "apps/bench/dilation-lena.hh"
30 #include "apps/data.hh"
35 #define DILATION_WITH_BUILTIN_WINDOW(Namespace, Suffix, Headline) \
40 for (unsigned i = 0; i < niters; ++i) \
41 d = Namespace::dilation(d); \
43 std::cerr << Headline << t.read() << " s" << std::endl; \
44 io::pgm::save(d, prefix + '-' + length + '-' + Suffix + ".pgm"); \
45 times.push_back(t.read()); \
49 #define DILATION(Namespace, Win, Suffix, Headline) \
54 for (unsigned i = 0; i < niters; ++i) \
55 d = Namespace::dilation(d, Win); \
57 std::cerr << Headline << t.read() << " s" << std::endl; \
58 io::pgm::save(d, prefix + '-' + length + '-' + Suffix + ".pgm"); \
59 times.push_back(t.read()); \
65 run(
const std::string&
filename,
const std::string& length,
unsigned niters)
77 std::string prefix =
"dilation-lena-table-out";
78 std::cerr <<
"== " << filename << std::endl;
80 std::vector<float>
times;
83 DILATION_WITH_BUILTIN_WINDOW(nongen,
"nongen",
"nongen\t\t");
84 DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr,
"nongen_2ptr",
"nongen_2ptr\t");
87 DILATION_WITH_BUILTIN_WINDOW(nongen_1ptr,
"nongen_1ptr",
"nongen_1ptr\t");
90 DILATION(gen,
win_c4p(),
"gen",
"gen\t\t");
93 DILATION(fast,
win_c4p(),
"fast",
"fast\t\t");
96 DILATION(fast_noaccu,
win_c4p(),
"fast_noaccu",
"fast_noaccu\t");
97 DILATION(faster,
win_c4p(),
"faster",
"faster\t\t");
98 DILATION(faster_noaccu,
win_c4p(),
"faster_noaccu",
"faster_noaccu\t");
102 const unsigned n = 5;
111 DILATION(fast_static, static_win_c4p,
"fast_static",
"fast_static\t");
114 DILATION(faster_static, static_win_c4p,
"faster_static",
"faster_static\t");
117 std::cerr << std::endl;
123 main (
int ,
char* argv[])
125 unsigned niters = 10;
126 typedef std::vector<float> times_t;
129 times_t times_512 = run(MLN_IMG_DIR
"/lena.pgm",
"512", niters);
130 times_t times_1024 = run(MLN_APPS_DIR
"/bench/lena1024.pgm",
"1024", niters);
131 times_t times_2048 = run(MLN_APPS_DIR
"/bench/lena2048.pgm",
"2048", niters);
134 times_t::const_iterator i_512 = times_512.begin();
135 times_t::const_iterator i_1024 = times_1024.begin();
136 times_t::const_iterator i_2048 = times_2048.begin();
138 "% Generated by `" << argv[0] <<
"', do not modify.\n"
140 "\\begin{table}[tbp]\n"
142 " \\begin{tabular}{lrrr}\n"
144 " Implementation & \\multicolumn{3}{c}{Execution times (s)} \\\\\n"
145 " & $512^2$ & $1024^2$ & $2048^2$ \\\\\n"
150 std::cout << std::fixed << std::setprecision(4);
158 " Non generic (\\algref{lst:non-gen-dilation}) & " <<
159 *i_512++ <<
" & " << *i_1024++ <<
" & " << *i_2048++ <<
" \\\\\n"
164 " Non generic, pointer-based\\footnotemark[1] & " <<
165 *i_512++ <<
" & " << *i_1024++ <<
" & " << *i_2048++ <<
" \\\\\n"
170 " Generic (\\algref{lst:gen-dilation}) & " <<
171 *i_512++ <<
" & " << *i_1024++ <<
" & " << *i_2048++ <<
" \\\\\n"
176 " Fast, partly generic (\\algref{lst:fast-dilation}) & " <<
177 *i_512++ <<
" & " << *i_1024++ <<
" & " << *i_2048++ <<
" \\\\\n"
182 " Fast, partly generic with & " <<
183 *i_512++ <<
" & " << *i_1024++ <<
" & " << *i_2048++ <<
" \\\\\n"
184 " static window (\\algref{lst:fast-static-dilation}) & & & \\\\\n"
189 " \\caption{Execution times of various dilation implementations.}\n"
190 " \\label{tab:results}\n"
192 "\\footnotetext[1]{Implementation not shown in this paper for space\n"
193 " reasons.}\n" << std::flush;