Saturday, October 24, 2009

CUDA and Computational Finance

Saw this on my Google Reader list and wanted to share it with everyone. This URL contains some videos/presentations on using CUDA for Computational Finance. (thanks to Argyn)

Lots more CUDA tutorials coming at SC09 !!!

Tuesday, October 20, 2009

Installing Boost C++ libraries

I know that installing Boost C++ libraries has nothing to do with GPGPU and multi-cores. Nevertheless, I have posted my procedure for installing Boost C++ libraries on a Mac.

I use Macports on my Mac and I find that it is the easiest way to install any open-source software on Mac OSX.

1. Search for boost packages
bash-3.2$ sudo port search boost
boost @1.40.0 (devel)
Collection of portable C++ source libraries
boost-build @2.0-m12 (devel)
Build system for large project software construction
boost-gil-numeric @1.0 (devel)
An algorithm extension to boost-gil.
boost-jam @3.1.17 (devel)
Boost.Jam (BJam) is a build tool based on FTJam
py26-pyplusplus @1.0.0 (python, devel)
Py++ is an framework for creating a code generator for Boost.Python library and ctypes package
Found 5 ports.

2. Install
bash-3.2$ sudo port install boost-jam  
---> Fetching boost-jam
---> Verifying checksum for boost-jam
---> Extracting boost-jam
---> Configuring boost-jam
---> Building boost-jam with target all
---> Staging boost-jam into destroot
---> Installing boost-jam

bash-3.2$ sudo port install boost
---> Fetching boost
---> Verifying checksum for boost
---> Extracting boost
---> Configuring boost
---> Building boost with target all
---> Staging boost into destroot
---> Installing boost

bash-3.2$ sudo port install boost-build  
---> Fetching boost-build
---> Verifying checksum for boost-build
---> Extracting boost-build
---> Configuring boost-build
---> Building boost-build with target all
---> Staging boost-build into destroot
---> Installing boost-build

3. Here's my example program:
#include <iostream>
#include <boost/any.hpp>
using namespace std;
int main()
{
boost::any
a(5);
a = 7.67;
std:cout<<boost::any_cast<double>(a)<<std::endl;
}

Now when I tried compiling my example program, I got a lot of errors such as:
example3.cpp:11:25: error: boost/any.hpp: No such file or directory
example3.cpp: In function ‘int main()’:
example3.cpp:18: error: ‘boost’ has not been declared
example3.cpp:18: error: ‘any’ was not declared in this scope
example3.cpp:18: error: expected `;' before ‘a’
example3.cpp:19: error: ‘a’ was not declared in this scope
example3.cpp:20: error: ‘boost’ has not been declared
example3.cpp:20: error: ‘any_cast’ was not declared in this scope
example3.cpp:20: error: expected primary-expression before ‘double’
example3.cpp:20: error: expected `;' before ‘double’

So I googled around and came to this link and tried compiling using the full path:
$ g++ -I /opt/local/var/macports/software/boost/1.40.0_1/opt/local/include/ example3.cpp -o example3_new

and that worked...!!!!

I also did this as a shortcut for compiling my programs that need the Boost libraries:
$ export BOOST=/opt/local/var/macports/software/boost/1.40.0_1/opt/local/include/
$ echo $BOOST
/opt/local/var/macports/software/boost/1.40.0_1/opt/local/include/
$ g++ -I $BOOST example3.cpp -o example3_new
$./example3_new
7.67

Hope this helps :)