Commit 90d29df9 authored by Roland Levillain's avatar Roland Levillain
Browse files

apps/bench: Split dilation-lena-bench.

	* apps/bench/dilation-lena-bench.cc: Remove and split into...
	* apps/bench/dilation-lena-bench-macros.hh,
	* apps/bench/dilation-lena-bench-fast.cc,
	* apps/bench/dilation-lena-bench-fast_static.cc,
	* apps/bench/dilation-lena-bench-gen.cc,
	* apps/bench/dilation-lena-bench-nongen.cc,
	* apps/bench/dilation-lena-bench-nongen_2ptr.cc:
	...these (new) files.
	* apps/bench/test-dilation-lena-bench.in: New test.
	* apps/bench/Makefile.am (noinst_PROGRAMS): Add
	dilation-lena-bench-nongen, dilation-lena-bench-nongen_2ptr,
	dilation-lena-bench-gen, dilation-lena-bench-fast and
	dilation-lena-bench-fast_static.
	Remove dilation-lena-bench.
	(noinst_HEADERS): Add dilation-lena-bench-macros.hh.
	(edit): New variable.
	(EXTRA_DIST): Add test-dilation-lena-bench.in.
	(test-dilation-lena-bench): New target.
	(TESTS, CLEANFILES): Add test-dilation-lena-bench.
parent b43f22a4
2011-01-11 Roland Levillain <roland@lrde.epita.fr>
apps/bench: Split dilation-lena-bench.
* apps/bench/dilation-lena-bench.cc: Remove and split into...
* apps/bench/dilation-lena-bench-macros.hh,
* apps/bench/dilation-lena-bench-fast.cc,
* apps/bench/dilation-lena-bench-fast_static.cc,
* apps/bench/dilation-lena-bench-gen.cc,
* apps/bench/dilation-lena-bench-nongen.cc,
* apps/bench/dilation-lena-bench-nongen_2ptr.cc:
...these (new) files.
* apps/bench/test-dilation-lena-bench.in: New test.
* apps/bench/Makefile.am (noinst_PROGRAMS): Add
dilation-lena-bench-nongen, dilation-lena-bench-nongen_2ptr,
dilation-lena-bench-gen, dilation-lena-bench-fast and
dilation-lena-bench-fast_static.
Remove dilation-lena-bench.
(noinst_HEADERS): Add dilation-lena-bench-macros.hh.
(edit): New variable.
(EXTRA_DIST): Add test-dilation-lena-bench.in.
(test-dilation-lena-bench): New target.
(TESTS, CLEANFILES): Add test-dilation-lena-bench.
2011-01-10 Roland Levillain <roland@lrde.epita.fr>
 
apps/bench: New experiment: dilation-lena-bench.
......@@ -25,7 +25,11 @@ EXTRA_DIST = lena1024.pgm lena2048.pgm
noinst_PROGRAMS = \
dilation-lena \
dilation-lena-bench \
dilation-lena-bench-nongen \
dilation-lena-bench-nongen_2ptr \
dilation-lena-bench-gen \
dilation-lena-bench-fast \
dilation-lena-bench-fast_static \
dilation-lena-table \
gradient-lena \
gradient-spe-lena
......@@ -33,6 +37,7 @@ noinst_PROGRAMS = \
noinst_HEADERS = \
and_not.hh \
dilation-lena.hh \
dilation-lena-bench-macros.hh \
minus.hh \
static_array.hh \
static_dpoints_pixter.hh \
......@@ -93,3 +98,20 @@ MOSTLYCLEANFILES = \
gradient-spe-lena-out-2.pgm \
gradient-spe-lena-out-3.pgm \
gradient-spe-lena-out-4.pgm
# Use Make to generate tests instead of `configure', as advised by
# Autoconf's manual (see section ``Installation Directory
# Variables'').
edit = sed -e 's|@top_srcdir[@]|$(top_srcdir)|g' \
-e 's|@srcdir[@]|$(srcdir)|g'
EXTRA_DIST += test-dilation-lena-bench.in
test-dilation-lena-bench: test-dilation-lena-bench.in Makefile
rm -f $@ $@.tmp
srcdir=''; \
test -f ./$< || srcdir=$(srcdir)/; \
$(edit) $${srcdir}$< >>$@.tmp
chmod a-w,a+x $@.tmp
mv $@.tmp $@
CLEANFILES = test-dilation-lena-bench
TESTS = test-dilation-lena-bench
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include "apps/bench/dilation-lena-bench-macros.hh"
void
usage(const std::string& program)
{
std::cerr << program << " input.pgm" << std::endl;
std::exit(1);
}
int
main(int argc, char* argv[])
{
DILATION(fast, win_c4p());
}
......@@ -23,81 +23,18 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include "apps/bench/dilation-lena.hh"
namespace tag
{
enum dilation
{
nongen = 1,
nongen_2ptr = 2,
gen = 3,
fast = 4,
fast_static = 5
};
}
#include "apps/bench/dilation-lena-bench-macros.hh"
void
usage(const std::string& program)
{
std::cerr << program << " implementation input.pgm\n\n" <<
" were implementation is\n"
" 1 : nongen\n"
" 2 : nongen_2ptr \n"
" 3 : gen\n"
" 4 : fast\n"
" 5 : fast_static\n";
std::cerr << program << " input.pgm" << std::endl;
std::exit(1);
}
#define DILATION_WITH_BUILTIN_WINDOW(Namespace) \
do \
{ \
image2d<int_u8> d = lena; \
t.start(); \
for (unsigned i = 0; i < 10; ++i) \
d = Namespace::dilation(d); \
t.stop(); \
} \
while (0)
#define DILATION(Namespace, Win) \
do \
{ \
image2d<int_u8> d = lena; \
t.start(); \
for (unsigned i = 0; i < 10; ++i) \
d = Namespace::dilation(d, Win); \
t.stop(); \
} \
while (0)
int
main(int argc, char* argv[])
{
using namespace mln;
using value::int_u8;
if (argc != 3)
usage(argv[0]);
int method = atoi(argv[1]);
std::string filename = argv[2];
border::thickness = 1;
image2d<int_u8> lena;
io::pgm::load(lena, filename);
util::timer t;
// Static windows and qixters.
const unsigned n = 5;
mln::dpoint2d dps[n] = { mln::dpoint2d( 0, -1),
......@@ -108,20 +45,5 @@ main(int argc, char* argv[])
mln::util::static_array<mln::dpoint2d, n> sa(dps, dps + n);
mln::static_window<mln::dpoint2d, n> static_win_c4p(sa);
switch (method)
{
case ::tag::nongen: DILATION_WITH_BUILTIN_WINDOW(nongen); break;
case ::tag::nongen_2ptr: DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr); break;
case ::tag::gen: DILATION(gen, win_c4p()); break;
case ::tag::fast: DILATION(fast, win_c4p()); break;
case ::tag::fast_static: DILATION(fast_static, static_win_c4p); break;
default:
usage(argv[0]);
}
// Fix the output format for floats.
std::cout << std::fixed << std::setprecision(4);
// Display the elapsed time.
std::cout << t.read() << std::endl;
DILATION(fast_static, static_win_c4p);
}
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include "apps/bench/dilation-lena-bench-macros.hh"
void
usage(const std::string& program)
{
std::cerr << program << " input.pgm" << std::endl;
std::exit(1);
}
int
main(int argc, char* argv[])
{
DILATION(gen, win_c4p());
}
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef APPS_BENCH_DILATION_LENA_MACROS_HH
# define APPS_BENCH_DILATION_LENA_MACROS_HH
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include "apps/bench/dilation-lena.hh"
#define DILATION_WITH_BUILTIN_WINDOW(Namespace) \
do \
{ \
using namespace mln; \
using value::int_u8; \
\
if (argc != 2) \
usage(argv[0]); \
\
std::string filename = argv[1]; \
\
border::thickness = 1; \
image2d<int_u8> lena; \
io::pgm::load(lena, filename); \
util::timer t; \
\
image2d<int_u8> d = lena; \
t.start(); \
for (unsigned i = 0; i < 10; ++i) \
d = Namespace::dilation(d); \
t.stop(); \
\
/* Fix the output format for floats. */ \
std::cout << std::fixed << std::setprecision(4); \
/* Display the elapsed time. */ \
std::cout << t.read() << std::endl; \
} \
while (0)
#define DILATION(Namespace, Win) \
do \
{ \
using namespace mln; \
using value::int_u8; \
\
if (argc != 2) \
usage(argv[0]); \
\
std::string filename = argv[1]; \
\
border::thickness = 1; \
image2d<int_u8> lena; \
io::pgm::load(lena, filename); \
util::timer t; \
\
image2d<int_u8> d = lena; \
t.start(); \
for (unsigned i = 0; i < 10; ++i) \
d = Namespace::dilation(d, Win); \
t.stop(); \
\
/* Fix the output format for floats. */ \
std::cout << std::fixed << std::setprecision(4); \
/* Display the elapsed time. */ \
std::cout << t.read() << std::endl; \
} \
while (0)
#endif // ! APPS_BENCH_DILATION_LENA_MACROS_HH
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include "apps/bench/dilation-lena-bench-macros.hh"
void
usage(const std::string& program)
{
std::cerr << program << " input.pgm" << std::endl;
std::exit(1);
}
int
main(int argc, char* argv[])
{
DILATION_WITH_BUILTIN_WINDOW(nongen);
}
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include "apps/bench/dilation-lena-bench-macros.hh"
void
usage(const std::string& program)
{
std::cerr << program << " input.pgm" << std::endl;
std::exit(1);
}
int
main(int argc, char* argv[])
{
DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr);
}
#! /bin/sh
./dilation-lena-bench-nongen @top_srcdir@/milena/img/lena.pgm
./dilation-lena-bench-nongen_2ptr @top_srcdir@/milena/img/lena.pgm
./dilation-lena-bench-gen @top_srcdir@/milena/img/lena.pgm
./dilation-lena-bench-fast @top_srcdir@/milena/img/lena.pgm
./dilation-lena-bench-fast_static @top_srcdir@/milena/img/lena.pgm
echo
./dilation-lena-bench-nongen @srcdir@/lena1024.pgm
./dilation-lena-bench-nongen_2ptr @srcdir@/lena1024.pgm
./dilation-lena-bench-gen @srcdir@/lena1024.pgm
./dilation-lena-bench-fast @srcdir@/lena1024.pgm
./dilation-lena-bench-fast_static @srcdir@/lena1024.pgm
echo
./dilation-lena-bench-nongen @srcdir@/lena2048.pgm
./dilation-lena-bench-nongen_2ptr @srcdir@/lena2048.pgm
./dilation-lena-bench-gen @srcdir@/lena2048.pgm
./dilation-lena-bench-fast @srcdir@/lena2048.pgm
./dilation-lena-bench-fast_static @srcdir@/lena2048.pgm
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment