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 :)

Monday, September 28, 2009

OpenCL drivers available from Nvidia

OpenCL drivers are available for download from Nvidia.

You can download the SDK, Best Practices guide from here: Nvidia OpenCL download

Waiting to try some sample code examples using OpenCL and evaluate how it differs from CUDA :)



Wednesday, August 19, 2009

SAAHPC presentation

I recently presented my work at the SAAHPC conference, held at NCSA Urbana, IL. The Keynote talk was by Pradeep Dubey on Massive Data Computing using Intel Larrabee. Excellent overview on why data transfer and management is the challenge in today's computing. I liked the Connected Computing factor - Content, Connect and Compute. I have found out from real-time problems that having the fastest computation platform is not enough, it's even more important to sustain the streaming bandwidth of the data into the platform. Obviously, once the data is inside the memory, computation is fast. But the real bottleneck is in importing and offloading the data and trying to streamline and synchronize the data (some of my PhD dissertation grumble).

I liked the talk by Michael Garland on GPU Computing using CUDA. This was informative in terms of his insight on the Thrust template. Thrust is open source and is hosted on Google Code. I have to start using this for my next CUDA project.

Finally, here's a link to my presentation on "Accelerating Particle Image Velocimetry using Hybrid Architectures".

Friday, July 31, 2009

Installing CUDA 2.3

Installing CUDA 2.3 is pretty easy and straightforward. However, on my Mac, the CUDA SDK examples are now in
/Developer/GPU Computing

In addition to the drivers for Leopard, there's a separate version for Snow Leopard :) New documentation includes the CUDA Best Practices Guide. This is the correct link, thanks to the NVIDIA forums post. The CUDA Resource page does not point you to the correct link.

Have a good time accelerating your apps using CUDA :)

Monday, June 29, 2009

cuda-gdb error on CentOS

CUDA 2.2 comes with its native debugger support through cuda-gdb. However, I had some problems configuring cuda-gdb on my Linux distro (CentOS).
When I execute cuda-gdb fresh after my installation, here's what I see:
$ cuda-gdb
cuda-gdb: error while loading shared libraries: libtermcap.so.2: cannot open shared object file: No such file or directory

I tried searching for the missing library libtermcap.so.2 using
locate libtermcap

A google search led me to http://forums.nvidia.com/index.php?showtopic=96987
and I installed libncurses and linked it correctly.
sudo yum install ncurses.x86_64
sudo ln -s /usr/lib64/libncurses.so /usr/local/cuda/lib/libtermcap.so.2

That seemed to do the trick !!!
$ cuda-gdb
NVIDIA (R) CUDA Debugger
BETA release
Portions Copyright (C) 2008,2009 NVIDIA Corporation
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
(cuda-gdb)

For more info on cuda-gdb refer to: http://developer.download.nvidia.com/compute/cuda/2_2/toolkit/docs/CUDA_GDB_User_Manual_2.2beta.pdf

Tuesday, May 12, 2009

Installing CUDA 2.2 on MacPro running CentOS 64-bit

My test machine is an early 200 Mac Pro with a NVIDIA Tesla C1060. Upgrading to CUDA 2.2 on this Mac was relatively easy. Please read my previous post for installing CUDA 2.1 before attempting to install CUDA 2.2 on a CentOS 64-bit distro.

Step 1: Download packages:
wget http://developer.download.nvidia.com/compute/cuda/2_2/drivers/cudadriver_2.2_linux_64_185.18.08-beta.run
wget http://developer.download.nvidia.com/compute/cuda/2_2/toolkit/cudatoolkit_2.2_linux_64_rhel5.3.run
wget http://developer.download.nvidia.com/compute/cuda/2_2/sdk/cudasdk_2.2_linux.run
wget http://developer.download.nvidia.com/compute/cuda/2_2/toolkit/cudagdb_2.2_linux_64_rhel5.3.run
Change permissions
chmod +x cudadriver_2.2_linux_64_185.18.08-beta.run
chmod +x cudatoolkit_2.2_linux_64_rhel5.3.run
chmod +x cudagdb_2.2_linux_64_rhel5.3.run
chmod +x cudasdk_2.2_linux.run
Step 2: Find your kernel source and install the corresponding kernel-devel and kernel-headers:
uname -r
2.6.27.21-170.2.56.fc10.x86_64

sudo yum install kernel-devel
sudo yum install kernel-headers
Step 3: Install the CUDA driver first, followed by the toolkit, gdb and finally the SDK.
sudo ./cudadriver_2.2_linux_64_185.18.08-beta.run --kernel-source-path /usr/src/kernels/2.6.27.21-170.2.56.fc10.x86_64
sudo ./cudatoolkit_2.2_linux_64_rhel5.3.run
sudo ./cudagdb_2.2_linux_64_rhel5.3.run
./cudasdk_2.2_linux.run
Make sure that your path is configured correctly. (Refer to previous post)

Step 4: Enable the cuda script mentioned in the previous post.
sudo service cuda start
check the nvidia driver status and you should see this:
ls /dev/nv*
/dev/nvidia0 /dev/nvidiactl /dev/nvram
Step 5: Make sure you do a fresh install of the SDK if you are upgrading.
cd NVIDIA_CUDA_SDK/
make
This should make all your projects in the following directory:
$HOME/NVIDIA_CUDA_SDK/bin/linux/release
Executing the deviceQuery executable shows me this:
./deviceQuery
CUDA Device Query (Runtime API) version (CUDART static linking)
There is 1 device supporting CUDA

Device 0: "Tesla C1060"
CUDA Capability Major revision number: 1
CUDA Capability Minor revision number: 3
Total amount of global memory: 4294705152 bytes
Number of multiprocessors: 30
Number of cores: 240
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 16384 bytes
Total number of registers available per block: 16384
Warp size: 32
Maximum number of threads per block: 512
Maximum sizes of each dimension of a block: 512 x 512 x 64
Maximum sizes of each dimension of a grid: 65535 x 65535 x 1
Maximum memory pitch: 262144 bytes
Texture alignment: 256 bytes
Clock rate: 1.30 GHz
Concurrent copy and execution: Yes
Run time limit on kernels: No
Integrated: No
Support host page-locked memory mapping: Yes
Compute mode: Default (multiple host threads can use this device simultaneously)

Test PASSED

Press ENTER to exit...
Congrats !!! CUDA 2.2 is configured on your 64-bit CentOS Mac Pro and also recognizes the NVIDIA Tesla C1060. Looking forward to post some examples with the zero copy feature :)