Saturday, January 15, 2011

Threads and Parallel programming model



what is a thread?
  • Informally said, a thread consists of a series of instructions with its own program counter(PC) and state
  • A multi-threaded program executes multiple threads in parallel
  • This is the core concept to increase the utilization of CPU, therefore performance of system is increased.(if you are not convinced with this statement, have a glance at this page  click here)
Multiple Threads
 
Parallel programming models : 

There are various programming models present, some of the well-known are listed below. They can be categorized into two types,
  1. Distributed Memory
  2. Shared Memory
Some models which come under Distributed Memory are : Sockets, PVM(Parallel Virtual Machine), MPI(Message Passing Interface), etc..

Some models which come under Shared Memory are : OpenMP, posix thread, Automatic parallelization, etc,..

I will discuss in one or two sentence about one each from above two categories,

MPI (Message Passing Interface) : 
  • Is an example for Distributed memory model
  • All data is private
  • All threads have access to their own private memory
  • Data is shared explicitly by exchanging buffers
  • Data transfer has to be programmed explicitly
  • An overview is given below in the figure,
Distributed Memory Model - MPI(Message passing Interface)

OpenMP :  (Open Multi-Processing)
  • Is an example for Shared Memory Model
  • Data can be shared or private
  • All threads can have access to the same or globally shared memory
  • private data can be accessed only by the thread that owns it
  • Easy to learn and implement
  • it is as shown below

Shared Memory Model - Open MP

Note : In this blog i will only be discussing about OpenMP and other models on shared memory models, sorry to say no to MPI. So once you are through with this post you can get on to next post which discusses more about OpenMP.

No comments:

Post a Comment