<br>&gt;version :MPICH2 1.3.1<br>&gt;uname -mo<br>            ia64 GNU/Linux <br>&gt;Yah dear 100 is the output. which is the size of array I have I entered.<br>&gt;Yah Friend it is working correctly with out profiling on single and multiple      processes. and also after profiling when it run on a single process.  <br>

<br>#include &lt;mpi.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#define  TRUE 1<br>#include &quot;math.h&quot;<br>#include &lt;time.h&gt;<br>int compare(const void *e1, const void *e2 ) <br>    {<br>

          return (*((int *)e1) - *((int *)e2));<br>    }<br>DisplayError(char *str)<br>{<br>    printf(&quot;Error: %s \n&quot;,str);<br>} <br><br>int Partition(int *Array,int start,int end)<br>{<br>    int pivo;<br>    int i, j;<br>

    int tmp;<br><br>    pivo=Array[end];            <br>    i=start-1;                <br><br>    for(j=start;j&lt;end;j++)<br>        if(Array[j]&lt;=pivo)<br>        {<br>            i++;            <br>            tmp=Array[i];<br>

            Array[i]=Array[j];<br>            Array[j]=tmp;<br>        }<br>    <br>    tmp=Array[i+1];<br>    Array[i+1]=Array[end];<br>    Array[end]=tmp;            <br><br>    return i+1;<br>}<br><br>QuickSort(int *Array,int start,int end)<br>

{<br>    int r;<br>    int i;<br><br>    if(start&lt;end)<br>    {<br>        r=Partition(Array,start,end);<br>        QuickSort(Array,start,r-1);<br>        QuickSort(Array,r+1,end);<br>    }<br>}<br><br>int PowerOf2(int num)<br>

{<br>    int i;<br><br>    i=1;<br><br>    while(num&gt;0)<br>    {<br>        num--;<br>        i=i*2;<br>    }<br>    <br>    return i;<br>}<br><br><br>PQuickSort(int *Array,int start,int end,int m,int id,int MyRank)<br>

{<br>    int i, j;<br>    int r;<br>    int LocalLength;<br>    int *tmp;<br>    //int newsize;<br>    MPI_Status status;<br>    LocalLength=-1;<br>    double t3,t4,t5;<br><br>    if(m==0)<br>    {<br>        if(MyRank==id)<br>

        <br>        t3=MPI_Wtime();<br>        qsort(Array, end-start, sizeof(int), compare);    <br>        t4=MPI_Wtime();<br>        t5=t4-t3;<br>        printf(&quot;Process with ID %d and time %6.3f  \n&quot;,MyRank,t5); <br>

        <br>        return 0;<br>    }    <br><br>    if(MyRank==id)<br>    {<br>        r=Partition(Array,start,end);    <br>        LocalLength=end-r;    <br>        MPI_Send(&amp;LocalLength,1,MPI_INT,id+PowerOf2(m-1),MyRank,MPI_COMM_WORLD);<br>

        if(LocalLength!=0)<br>        MPI_Send(Array+r+1,LocalLength,MPI_INT,id+PowerOf2(m-1),MyRank,MPI_COMM_WORLD);<br>    }<br><br>    if(MyRank==id+PowerOf2(m-1))<br>    {<br>        MPI_Recv(&amp;LocalLength,1,MPI_INT,id,id,MPI_COMM_WORLD,&amp;status);<br>

        <br>       if(LocalLength!=0)<br>        {<br>            tmp=(int *)malloc(LocalLength*sizeof(int));<br>            if(tmp==0) DisplayError(&quot;Malloc memory error!&quot;);<br>            MPI_Recv(tmp,LocalLength,MPI_INT,id,id,MPI_COMM_WORLD,&amp;status);<br>

        }<br>    }<br><br>    <br>        <br>    if(id&lt;=MyRank &amp;&amp; MyRank&lt;id+PowerOf2(m-1))<br>    {<br>        PQuickSort(Array,start,r-1,m-1,id,MyRank);<br>    }<br><br>    if(MyRank&gt;=id+PowerOf2(m-1))<br>

    {<br>        PQuickSort(tmp,0,LocalLength-1,m-1,id+PowerOf2(m-1),MyRank);<br>    }<br><br>    <br>    if((MyRank==id+PowerOf2(m-1)) &amp;&amp; (LocalLength!=0))<br>        MPI_Send(tmp,LocalLength,MPI_INT,id,id+PowerOf2(m-1),MPI_COMM_WORLD);<br>

<br>    if((MyRank==id) &amp;&amp; (LocalLength!=0))<br>        MPI_Recv(Array+r+1,LocalLength,MPI_INT,id+PowerOf2(m-1),id+PowerOf2(m-1),MPI_COMM_WORLD,&amp;status);<br><br>}<br><br>int LogBase2(int num)<br>{<br>    int i, j;<br>

<br>    i=1;    <br>    j=2;<br><br>    while(j&lt;num)<br>    {<br>        j=j*2;<br>        i++;<br>    }<br><br>    if(j&gt;num)<br>        i--;<br><br>    return i;<br>}<br><br><br>main(int argc,char *argv[])<br>{<br>

    int ArraySize;<br>    int *Array;<br>    int    MyRank, npes;<br>    int i, j;<br>    int m, r;<br>    double t1,t2,t3;<br><br><br>    MPI_Status status;<br>    MPI_Init(&amp;argc,&amp;argv);<br>        <br>    MPI_Comm_rank(MPI_COMM_WORLD,&amp;MyRank);    <br>

<br>    MPI_Comm_size(MPI_COMM_WORLD,&amp;npes);    <br>    <br>    if(MyRank==0)<br>    {<br>        ArraySize=1000000;<br>        printf(&quot;%d\n&quot;,ArraySize);<br>        Array=(int *)malloc(ArraySize*sizeof(int));<br>

<br>        if(Array==0) <br>            printf(&quot;Malloc memory error!&quot;);<br><br>        srand(396);<br>        for(i=0;i&lt;ArraySize;i++)<br>        {<br>            Array[i]=(int)rand()%1000;<br>            //printf(&quot;%10d&quot;,Array[i]);<br>

            //    printf(&quot;\t&quot;);<br>        }<br>        printf(&quot;\n&quot;);<br>    }<br>    <br>    m=LogBase2(npes);<br><br>    MPI_Bcast(&amp;ArraySize,1,MPI_INT,0,MPI_COMM_WORLD);<br>        t1=MPI_Wtime();<br>

    PQuickSort(Array,0,ArraySize-1,m,0,MyRank);<br>        t2=MPI_Wtime();<br>        t3=t2-t1;<br>    <br>    if(MyRank==0)<br>    {<br>        //for(i=0;i&lt;ArraySize;i++)<br>        //{<br>        //    printf(&quot;%10d&quot;,Array[i]);<br>

        //        printf(&quot;\t&quot;);<br>        //}<br>        printf(&quot;\n&quot;);<br>    printf(&quot;MPI_time :%6.3f\n&quot;,t3);<br>        <br>    }<br><br>    MPI_Finalize();        <br>    return 0;<br>}<br>

<br>&gt; the above code is without profiling and work well<br>Thanks Friend :)<br>