I am newbie to MPI programming. While reading some information online, I am unable to understand about ghost rows/columns. Can somebody please explain to me what is it, how it is implemented and why do we use it?
Ghost regions are usually used with stencil applications. What that means is that the processes might be laid out like this (I'm going to answer this question in 2D, but you can extrapolate to however many dimensions is helpful for you):
0 | 1 | 2
---------
3 | 4 | 5
---------
6 | 7 | 8
Each process communicates directly with its neighbors (north, south, east, and west) to exchange data every iteration. Each process has some block of 2D data that is laid out like this:
1 5 9 3 7
2 3 4 8 0
2 5 7 3 9
9 3 8 1 4
8 3 7 3 2
The edges of that data are usually used as "ghost regions":
1 5 9 3 7
---------
2 | 3 4 8 | 0
2 | 5 7 3 | 9
9 | 3 8 1 | 4
---------
8 3 7 3 2
This means that this data is made available to the neighboring processes so they can use it in their own calculation, usually to calculate some sort of interactions between physical objects at the borders of a domain decomposition problem.
As for the implementation, that will depend on the data, but often it can be done using custom MPI datatypes. I won't provide code here since it's so specific to your application, but there are plenty of tutorials out there on the web where you can learn about how to use MPI datatypes.
Here's a tutorial I turned up with a quick Google search. It's not about MPI specifically, but it explains the basic concepts: http://www.hpjava.org/papers/HPJava/HPJava/node28.html