Skip to content

Commit

Permalink
first version of a parallel test runner for Unix/Mac using boost
Browse files Browse the repository at this point in the history
interprocess
  • Loading branch information
klausspanderen committed Dec 13, 2015
1 parent 9c2f5b3 commit fd4fedb
Show file tree
Hide file tree
Showing 7 changed files with 484 additions and 11 deletions.
49 changes: 45 additions & 4 deletions QuantLib/acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ AC_DEFUN([QL_CHECK_BOOST_VERSION_1_58_OR_HIGHER],
])
])


# QL_CHECK_BOOST_UBLAS
# --------------------
# Check whether the Boost headers are available
Expand Down Expand Up @@ -187,8 +188,8 @@ AC_DEFUN([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM],
@%:@include <boost/signals2/signal.hpp>
#ifndef BOOST_THREAD_PLATFORM_PTHREAD
#error only pthread is supported on this plattform
#endif
#error only pthread is supported on this plattform
#endif
int main() {
boost::recursive_mutex m;
Expand All @@ -197,7 +198,7 @@ AC_DEFUN([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM],
boost::signals2::signal<void()> sig;
return 0;
}
}
])],
[boost_thread_found=$boost_thread_lib
break],
Expand All @@ -208,7 +209,8 @@ AC_DEFUN([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM],
AC_MSG_RESULT([no])
AC_SUBST([BOOST_THREAD_LIB],[""])
AC_MSG_ERROR([Boost thread, signals2 and system libraries not found.
These libraries are required by the thread-safe observer pattern.])
These libraries are required by the thread-safe observer pattern
or by the parallel unit test runner.])
else
AC_MSG_RESULT([yes])
AC_SUBST([BOOST_THREAD_LIB],[$boost_thread_lib])
Expand All @@ -217,6 +219,45 @@ AC_DEFUN([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM],

])

# QL_CHECK_BOOST_TEST_INTERPROCESS
# ------------------------
# Check whether the Boost interprocess is available
AC_DEFUN([QL_CHECK_BOOST_TEST_INTERPROCESS],
[AC_MSG_CHECKING([whether Boost interprocess is available])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM])
ql_original_LIBS=$LIBS
boost_interprocess_found=no
boost_interprocess_lib="-lrt"
LIBS="$ql_original_LIBS $boost_thread_lib $boost_interprocess_lib"
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/interprocess/ipc/message_queue.hpp>
using namespace boost::interprocess;
int main() {
message_queue mq(open_or_create,"message_queue",100,100);
message_queue::remove("message_queue");
return 0;
}
])],
[boost_interprocess_found=$boost_interprocess_lib
break],
[])
LIBS="$ql_original_LIBS"
if test "$boost_interprocess_found" = no ; then
AC_MSG_RESULT([no])
AC_SUBST([BOOST_INTERPROCESS_LIB],[""])
AC_MSG_ERROR([Boost interprocess library not found.
These libraries are required by the parallel unit test runner.])
else
AC_MSG_RESULT([yes])
AC_SUBST([BOOST_INTERPROCESS_LIB],[$boost_interprocess_lib])
fi
])

])


# QL_CHECK_BOOST_TEST_STREAM
Expand Down
32 changes: 26 additions & 6 deletions QuantLib/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,26 @@ else
AC_SUBST([BOOST_THREAD_LIB],[""])
fi

AC_MSG_CHECKING([whether to enable parallel unit test runner])
AC_ARG_ENABLE([parallel-unit-test-runner],
AC_HELP_STRING([--enable-parallel-unit-test-runner],
[If enabled, a parallel unit test runner is used
to execute the C++ test suite. This will reduce
the runtime on multi core CPUs.]),
[ql_use_parallel_test=$enableval],
[ql_use_parallel_test=no])
AC_MSG_RESULT([$ql_parallel_test])
if test "$ql_use_parallel_test" = "yes" ; then
AC_DEFINE([QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER],[1],
[Define this if you want to enable
the parallel unit test runner.])
QL_CHECK_BOOST_VERSION_1_58_OR_HIGHER
QL_CHECK_BOOST_TEST_THREAD_SIGNALS2_SYSTEM
QL_CHECK_BOOST_TEST_INTERPROCESS
else
AC_SUBST([BOOST_THREAD_LIB],[""])
fi

AC_MSG_CHECKING([whether to install examples])
AC_ARG_ENABLE([examples],
AC_HELP_STRING([--enable-examples],
Expand Down Expand Up @@ -384,12 +404,12 @@ AC_CONFIG_FILES([
ql/math/statistics/Makefile
ql/methods/Makefile
ql/methods/finitedifferences/Makefile
ql/methods/finitedifferences/meshers/Makefile
ql/methods/finitedifferences/operators/Makefile
ql/methods/finitedifferences/schemes/Makefile
ql/methods/finitedifferences/solvers/Makefile
ql/methods/finitedifferences/stepconditions/Makefile
ql/methods/finitedifferences/utilities/Makefile
ql/methods/finitedifferences/meshers/Makefile
ql/methods/finitedifferences/operators/Makefile
ql/methods/finitedifferences/schemes/Makefile
ql/methods/finitedifferences/solvers/Makefile
ql/methods/finitedifferences/stepconditions/Makefile
ql/methods/finitedifferences/utilities/Makefile
ql/methods/lattices/Makefile
ql/methods/montecarlo/Makefile
ql/models/Makefile
Expand Down
4 changes: 3 additions & 1 deletion QuantLib/test-suite/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ endif

quantlib_test_suite_SOURCES = ${QL_TESTS}
quantlib_test_suite_LDADD = libUnitMain.la ${top_builddir}/ql/libQuantLib.la \
-l${BOOST_UNIT_TEST_LIB} ${BOOST_THREAD_LIB}
-l${BOOST_UNIT_TEST_LIB} ${BOOST_THREAD_LIB} ${BOOST_INTERPROCESS_LIB}

quantlib_benchmark_SOURCES = ${QL_BENCHMARKS}
quantlib_benchmark_LDADD = libUnitMain.la ${top_builddir}/ql/libQuantLib.la \
Expand All @@ -215,6 +215,7 @@ benchmark: quantlib-benchmark$(EXEEXT)
BOOST_TEST_LOG_LEVEL=message ./quantlib-benchmark$(EXEEXT)

EXTRA_DIST = \
unixparalleltestrunner.hpp \
README.txt \
testsuite_vc8.vcproj \
testsuite_vc9.vcproj \
Expand All @@ -226,6 +227,7 @@ else

EXTRA_DIST = \
${QL_TESTS} \
unixparalleltestrunner.hpp \
quantlibbenchmark.cpp \
README.txt \
testsuite_vc8.vcproj \
Expand Down
2 changes: 2 additions & 0 deletions QuantLib/test-suite/inflationcpibond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ namespace {


void InflationCPIBondTest::testCleanPrice() {
IndexManager::instance().clearHistories();

CommonVars common;

Real notional = 1000000.0;
Expand Down
9 changes: 9 additions & 0 deletions QuantLib/test-suite/quantlibbenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
# include <boost/config/auto_link.hpp>
# undef BOOST_LIB_NAME

#ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN
# define BOOST_LIB_NAME boost_system
# include <boost/config/auto_link.hpp>
# undef BOOST_LIB_NAME
# define BOOST_LIB_NAME boost_thread
# include <boost/config/auto_link.hpp>
# undef BOOST_LIB_NAME
#endif

/* uncomment the following lines to unmask floating-point exceptions.
See http://www.wilmott.com/messageview.cfm?catid=10&threadid=9481
*/
Expand Down
7 changes: 7 additions & 0 deletions QuantLib/test-suite/quantlibtestsuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
#include <ql/types.hpp>
#include <ql/settings.hpp>
#include <ql/version.hpp>

#ifdef QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER
#include "unixparalleltestrunner.hpp"
#else
#include <boost/test/unit_test.hpp>
#endif

#include <boost/timer.hpp>

/* Use BOOST_MSVC instead of _MSC_VER since some other vendors (Metrowerks,
Expand Down Expand Up @@ -286,6 +292,7 @@ test_suite* init_unit_test_suite(int, char* []) {
test->add(BusinessDayConventionTest::suite());
test->add(CalendarTest::suite());
test->add(CapFloorTest::suite());

test->add(CapFlooredCouponTest::suite());
test->add(CashFlowsTest::suite());
test->add(CliquetOptionTest::suite());
Expand Down
Loading

0 comments on commit fd4fedb

Please sign in to comment.