Parallel Model Calibration using MPI and Boost.MPI

The message passing standard MPI is a language-independent communication protocol. MPI supports the parallelization of numerical algorithms on both massive parallel computers and on symmetric multi processor systems. MPI is standardized, highly portable and the de facto standard on massive parallel supercomputers. Even though MPI can be used in a multi-threading environment it is normally used in a multi-process environment. Therefore MPI is tailor-made to parallelize algorithms based on the non thread-safe QuantLib.

The roots of the MPI specification are going back to the early 90’s and you will feel the age if you use the C-API, which is designed to achieve maximum performance. The Boost.MPI library – quoting from the web page – “is a C++ friendly interface to the standard Message Passing Interface… Boost.MPI can build MPI data types for user-defined types using the Boost.Serialization library”.

Model calibration can be a very time-consuming task, e.g. the calibration of a Heston or a Heston-Hull-White model using American puts with discrete dividends. The class MPICalibrationHelper acts as a MPI wrapper for a given CalibrationHelper and allows to parallelize an existing model calibration routine (hopefully with minimal impact/effort). The source code is available here. It contains the MPICalibrationHelper class and as an example the parallel version of the DAXCalibration test case (part of test-suite/hestonmodel.cpp). The code depends on QuantLib 1.0 or higher, Boost.Thread and Boost.MPI.

The diagram above shows the speed-up of a Heston-Hull-White calibration with discrete dividends on an eight core machine using a finite difference pricing engine. The main reason for the sub-linear scaling is the limited memory bandwidth between the CPUs and the main memory and not the MPI communication overhead.

Advertisement

6 thoughts on “Parallel Model Calibration using MPI and Boost.MPI

  1. Hello, I tried the source code below and a didn’t succeed on making it work. After installing MPICH and BOOST.MPI (it seem’s that examples from boost site work well), when i compile i have those erros, i don’t know how to fix that?? any idea???
    mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: int __thiscall boost::mpi::communicator::size(void)const ” (?size@communicator@mpi@boost@@QBEHXZ) référencé dans la fonction “public: __thiscall QuantLib::MPICalibrationHelper::MPICalibrationHelper(int,class QuantLib::Handle const &,class QuantLib::Handle const &,class boost::shared_ptr const &,enum QuantLib::CalibrationHelper::CalibrationErrorType)” (??0MPICalibrationHelper@QuantLib@@QAE@HABV?$Handle@VQuote@QuantLib@@@1@ABV?$Handle@VYieldTermStructure@QuantLib@@@1@ABV?$shared_ptr@VCalibrationHelper@QuantLib@@@boost@@W4CalibrationErrorType@CalibrationHelper@1@@Z)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: __thiscall boost::mpi::communicator::communicator(void)” (??0communicator@mpi@boost@@QAE@XZ) référencé dans la fonction “public: __thiscall QuantLib::MPICalibrationHelper::MPICalibrationHelper(int,class QuantLib::Handle const &,class QuantLib::Handle const &,class boost::shared_ptr const &,enum QuantLib::CalibrationHelper::CalibrationErrorType)” (??0MPICalibrationHelper@QuantLib@@QAE@HABV?$Handle@VQuote@QuantLib@@@1@ABV?$Handle@VYieldTermStructure@QuantLib@@@1@ABV?$shared_ptr@VCalibrationHelper@QuantLib@@@boost@@W4CalibrationErrorType@CalibrationHelper@1@@Z)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: void __thiscall boost::thread::join(void)” (?join@thread@boost@@QAEXXZ) référencé dans la fonction “public: virtual double __thiscall QuantLib::MPICalibrationHelper::modelValue(void)const ” (?modelValue@MPICalibrationHelper@QuantLib@@UBENXZ)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: int __thiscall boost::mpi::communicator::rank(void)const ” (?rank@communicator@mpi@boost@@QBEHXZ) référencé dans la fonction “public: virtual double __thiscall QuantLib::MPICalibrationHelper::modelValue(void)const ” (?modelValue@MPICalibrationHelper@QuantLib@@UBENXZ)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “private: void __thiscall boost::thread::start_thread(void)” (?start_thread@thread@boost@@AAEXXZ) référencé dans la fonction “public: __thiscall boost::thread::thread(class QuantLib::`anonymous namespace’::Worker,struct boost::thread::dummy *)” (??$?0VWorker@?A0x5302009a@QuantLib@@@thread@boost@@QAE@VWorker@?A0x5302009a@QuantLib@@PAUdummy@01@@Z)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: virtual __thiscall boost::mpi::exception::~exception(void)” (??1exception@mpi@boost@@UAE@XZ) référencé dans la fonction “void __cdecl boost::mpi::detail::broadcast_impl(class boost::mpi::communicator const &,double *,int,int,struct boost::mpl::bool_)” (??$broadcast_impl@N@detail@mpi@boost@@YAXABVcommunicator@12@PANHHU?$bool_@$00@mpl@2@@Z)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: __thiscall boost::mpi::exception::exception(char const *,int)” (??0exception@mpi@boost@@QAE@PBDH@Z) référencé dans la fonction “void __cdecl boost::mpi::detail::broadcast_impl(class boost::mpi::communicator const &,double *,int,int,struct boost::mpl::bool_)” (??$broadcast_impl@N@detail@mpi@boost@@YAXABVcommunicator@12@PANHHU?$bool_@$00@mpl@2@@Z)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: __thiscall boost::mpi::communicator::operator int(void)const ” (??Bcommunicator@mpi@boost@@QBEHXZ) référencé dans la fonction “void __cdecl boost::mpi::detail::broadcast_impl(class boost::mpi::communicator const &,double *,int,int,struct boost::mpl::bool_)” (??$broadcast_impl@N@detail@mpi@boost@@YAXABVcommunicator@12@PANHHU?$bool_@$00@mpl@2@@Z)
    1>mpicalibrationhelper.obj : error LNK2019: symbole externe non résolu “public: __thiscall boost::thread::~thread(void)” (??1thread@boost@@QAE@XZ) référencé dans la fonction “public: void * __thiscall boost::thread::`scalar deleting destructor'(unsigned int)” (??_Gthread@boost@@QAEPAXI@Z)
    1>mpi_calibration.obj : error LNK2019: symbole externe non résolu “public: __thiscall boost::mpi::environment::~environment(void)” (??1environment@mpi@boost@@QAE@XZ) référencé dans la fonction _main
    1>mpi_calibration.obj : error LNK2019: symbole externe non résolu “public: __thiscall boost::mpi::environment::environment(int &,char * * &,bool)” (??0environment@mpi@boost@@QAE@AAHAAPAPAD_N@Z) référencé dans la fonction _main

      • I dont think so because in the same project when i replace the 3 files with a boost mpi example in a main file it works well. I realy dont understand the problem source!!! Can you please remind me how can i chek the project set up, perhaps i miss something… Thanks a lot

  2. I’m running my examples under Linux and I’m not really a MSVC expert. Did you add the boost_mpi library directory to the “solution->properties->linker->general->additional library directories” and the library itself to “linker->input->additional dependencies”?

  3. yep, i think that all configuration issues were ok. I resolve the problem by modifying the files, just a little bit. like for example adding a #include and inverting the ordre of includion quantlib files with those of boost.mpi. It’s weird but it works. The problem now is that the prohect build correctly and when i excecute the exe file with the mpiexec.exe it takes a lot of time, it runs as if the optimisation problem where infinit (model-> Calibrate)… I try to execute on a local machine with 2 processors!! what do you think about that?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s