29 June 2011

Installing PyDev plugin for Eclipse IDE

PyDev is a Python IDE for Eclipse, which may be used in PythonJython and IronPython development.
It comes with many goodies such as:
  • Django integration
  • Code completion
  • Code completion with auto import
  • Syntax highlighting
  • Code analysis
  • Go to definition
  • Refactoring
  • Mark occurrences
  • Debugger
  • Remote debugger
  • Tokens browser
  • Interactive console
  • Unittest integration
  • Code coverage
  • and many others
To install the plugin into already installed Eclipse IDE -
1. Start the Eclipse IDE, you will see a welcome screen like this -

2. Go to Help -> Install new Software
    This will look like this -

3. Type the following url resource into the text box so that it will download the required plugins from there and install something like this. It will look something like this after typing everything -

4. Click "Next" and "OK" to continue installing PyDev.
5. Select "I accept the terms of the license agreement", then click "Finish". The installer will begin to download the plug-in.
6. A following window will appear after download is complete. Check the box and click on OK.

7. When the installation is complete, you will be asked if you want to restart Eclipse. Select "Yes". You may see a Subclipse Usage  dialog, just uncheck the box and continue.

26 June 2011

Installing PVM on Ubuntu 10.10 64 bit

PVM is a software system that allows you to combine a number of computers which are connected over a network into a Parallel Virtual Machine. This machine can consist of computers with different architectures, running different flavors of the Unix/Linux operating systems, and can still be treated as if it were a single parallel machine.

The simpler way to install PVM is
1. Go to the synaptic package manager and install pvm, libpvm3, xpvm.
2. Or type in terminal $sudo apt-get install pvm

Check if the PVM libraries in /usr/lib/pvm3  or in /usr/local/lib/pvm3 and include files in /usr/include directory.

Configuring PVM to work on different machines -
1. Find out which computers are available. You can use any computer on which you have an account,    and on which PVM is installed.

2. Edit or create the file .rhosts in your home directory. This file must have an entry for every computer you want to use. The entry is in the form of the name of the computer and your login name on that machine:
 ucs.orst.edu  kowallih
dogby.physics.edu hans

If your login name is the same on all machines, then you can leave the field with the login name blank, but it doesn’t hurt to put it in.

3. Set the environment variables in the .bashrc file.
export PVM_ROOT="/usr/lib/pvm3"
export PVM_ARCH=`$PVM_ROOT/lib/pvmgetarch`
export XPVM_ROOT=/usr/bin/xpvm
export PVM_RSH=`which ssh`

4. Create directories for your executables:
    $mkdir $HOME/pvm3/bin/PVM ARCH
where PVM ARCH is the PVM code for the architecture. Although this step is not necessary for PVM to work, it will make your life much easier if you are going to use PVM on computers with different architectures. You can find the code for each computer’s via the PVM function pvmgetarch.

The PVM console
The PVM console is the interface between the parallel virtual machine and the user. You use it to start and stop processes, to display information about the state of the virtual machine, and most importantly, to start and stop PVM on local and remote machines.

Step 1: Starting PVM Log into one of the computers you want to include in
PVM and enter:

Step 2: Adding hosts This is done from the PVM prompt:
pvm> add <hostname>
where hostname is the name of the computer you want to add. This will start PVM
on the specified hosts and, if successful, will produce a message such as:
1 successful
banana 140000
You can continue to add additional hosts as desired.

Step 3: Checking your configuration You display the configuration of your
parallel virtual machine from the PVM prompt:
pvm> conf
This will give you information about the hosts configured, their PVM identification
number and their architecture.

Step 4: Deleting hosts Sometimes it is necessary to remove hosts from the virtual
machine to test or debug a program:
pvm> delete <hostname>

Step 5: Leaving the console If you are done with setting up your virtual machine,
and if you don’t need any of the other functions of the console, you close the
console but keep PVM running:
pvm> quit

Step 6: Stopping PVM To stop PVM after your parallel program has finished,
enter the PVM console, and then from the PVM prompt:
> pvm From Unix shell
pvm> halt From PVM prompt
This stops PVM on all the machines and kills all programs running under PVM.
This is the best and easiest way to stop PVM.

A simple hello.c code to check the library.

#include <stdio.h>
#include <pvm3.h>

int main()
  int mytid;

  mytid = pvm_mytid();
  printf("My TID is %d\n", mytid);
  return 0;

Compiling the code - 
$gcc hello.c -o hello -lpvm3
A simple master program master.c

#include <stdio.h>
#include <stdlib.h>
#include <pvm3.h>

int main()
  int myTID;
  int x = 12;
  int children[10];
  int res;

  myTID = pvm_mytid();
  printf("Master: TID is %d\n", myTID);

  res = pvm_spawn("slave", NULL, PvmTaskDefault, "", 1, children);
  if (res<1) {
    printf("Master: pvm_spawn error\n");

  pvm_pkint(&x, 1, 1);

  pvm_send(children[0], 1);

  pvm_recv(-1, -1);
  pvm_upkint(&x, 1, 1);

  printf("Master has received x=%d\n", x);


  return 0;

A simple client program slave.c

#include <stdio.h>
#include <pvm3.h>

int main()
  int myTID, masterTID;
  int x = 12;

  myTID = pvm_mytid();
  printf("Slave: TID is %d\n", myTID);

  pvm_recv(-1, -1);
  pvm_upkint(&x, 1, 1);
  printf("Slave has received x=%d\n", x);

  x = x + 5;

  pvm_pkint(&x, 1, 1);

  pvm_send(pvm_parent(), 1);


  return 0;

Compiling the above code - 
$gcc -o master master.c -lpvm3
$gcc -o slave slave.c -lpvm3
Now copy the slave binary to the standard pvm folder so that master may know where to get the binary to spawn it.

25 June 2011

Installing CUDA 4.0 on Windows 7 64bit

Download and Install  -
1. Install CUDA developer driver.
    You can get cuda developer driver for notebooks from here.
    You can get cuda developer driver general from here.
    Double click “devdriver_3.2_winvista-win7_32_263.06_general” to install.
2. Install CUDA Toolkit. You can download cuda toolkit from here.
    Double click “cudatoolkit_3.2.16_win_32” to install.
3. Install CUDA Sdk from here.
    Double click “gpucomputingsdk_3.2.16_win_32” to install.
4. Install Visual Studio 2008 from Microsoft.

      All CUDA downloads can be done directly from its site.

After installation of all these drivers and SDKs, run the examples in the CUDA SDK to make sure everything works. If they work, you have successfully installed the correct CUDA driver.

Visual Studio Settings
Copy all files in -
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\extras\visual_studio_integration\rules
to directory -
C:\Program Files\Microsoft Visual Studio 9.0\VC\VCProjectDefaults

Now start Visual Studio 2008 and go to -
Tools -> Option -> Project and Solution -> VC++ Directory
1. To the Executable files drop down add -
    C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\bin
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin

2. To the Include files drop down add -
    C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include

3. To the Library files drop down add -
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include
    C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\lib\x64

Now your visual studio environment is ready to build cuda projects.