Building Financial Numerical Recipes with Intel Compilers


Financial Numerical Recipes is a collection of C++ subroutines Professor Bernt Arne Ødegaard at the Norwegian School of Management wrote for general reference. The whole source code is made public under GNU Public License. I found this package at his website. You can download the latest version last updated in April 9, 2007. After untar/unzip the package, two additional directories are created: all_cc_progs, and example_cc a readme.txt describe how to build this package.

Building with GCC

Building the package with GCC is very straight forward. You start by doing “make lib” under all_cc_progs. This builds librecipes.a. Then you go to example_cc and type “make run”. This starts the process to build and run run_all_examples. For comparison purposes, we can time the execution and redirect the standard output into a log file by using time run_all_cc

Building with Intel Compilers

Building the package with Intel Compiler can also be very straight forward if we were to make a few minor changes. We assume that Intel Compiler is installed in the default directory at /opt/intel and you have entered the environment variables in a file under compiler’s /bin directory. In the line to specify how to make run_all_examples, change explicit reference of g++ to $(CXX). After that you can pass the CC=icc CXX=icpc CFLAGS=”-c –xT –O3” CXXFLAGS=”-c –xT –O3” as the parameter to the make command both for librecipes.a and run_all_examples. icc is Intel’s C Compiler and icpc is Intel’s C++ Compiler. -xT tells the compiler to generate vectorized code up to SSSE3; and –Q3 tells the compiler to generate the fastest code regardless of memory footprint. Normally, we can expect 20% more performance from the executable file created by an Intel Compiler.

Building with IT++

The next step is to build it with one of three 3rd party libraries. We use IT++ as an example. IT++ is an open source C++ library of mathematical, signal processing, speech processing classes and functions. It is being developed by researchers in these areas, both in the communications industry and universities. You can locate its source code at and start to build it on your favorite platforms. I downloaded IT++ 4.0.3 release and built it under RHEL5.1 using the Intel Compilers by following in two simple steps: configure and build. During configuring step, use the following command ./configure CC=”icc” CXX=”icpc” CFLAGS=”-c -xT –O3” CXXFLAGS=”-c -xT –O3” F77=”ifort”.  Make install builds the product and installs the source, library, scripts and man page in the default directories: /usr/local/include /usr/local/lib/ /usr/local/bin, /usr/lib/share/man respectively. Once the IT++ is ready, we can get back to building the library librecipes.a and test application run_all_examples.

First you need to modify the makefile under all_cc_progs. Just uncomment two lines of macro definition to add three more object files to LIBOBJS under IT++ section. After that make lib CC=”icc” CXX=”icpc” CFLAGS=”-xT –O3” CXXFLAGS=”-c -xT –O3”. Under examples_cc, add –limf to LIBS definition and then similarly make run CC=icc CXX=icpc CFLAGS=”-c -xT –O3” CXXFLAGS=”-c -xT –O3 –D_HAVE_ITPP_”. In the end, you can see two additional tests when you build run_all_examples with IT++.


For more complete information about compiler optimizations, see our Optimization Notice.

1 comment

anonymous's picture

compile for finance money allocation
psalm 91

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.