<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>I was able to correct, thanks<br></div><div>#include <malloc.h></div><div>#include <stdlib.h></div><div>#include <stdio.h></div><div>#include <time.h></div><div>#include "math.h"</div><div>#include "mpi.h"</div><div><br></div><div>int main(int argc, char** argv)</div><div>{</div><div><span class="" style="white-space:pre">   </span>int          taskid, ntasks;</div><div><span class="" style="white-space:pre">      </span>int          ierr, i, itask;</div><div><span class="" style="white-space:pre">      </span>int<span class="" style="white-space:pre">       </span>         sendcounts[2048], displs[2048], recvcount;</div><div><span class="" style="white-space:pre">       </span>double       **sendbuff, *recvbuff, buffsum, buffsums[2048];</div><div><span class="" style="white-space:pre">        </span>double       inittime, totaltime;</div><div><span class="" style="white-space:pre">   </span>const int nbr_etat = 10;</div><div><span class="" style="white-space:pre">   </span>double tab[nbr_etat];</div><div><br></div><div><span class="" style="white-space:pre">     </span>for (int i = 0; i < nbr_etat; i++)</div><div><span class="" style="white-space:pre">              </span>tab[i] = i;</div><div><br></div><div><span class="" style="white-space:pre">       </span>for (int i = 0; i < nbr_etat; i++)</div><div><span class="" style="white-space:pre">              </span>printf("%0.0f<span class="" style="white-space:pre">        </span>", tab[i]);</div><div><span class="" style="white-space:pre">   </span>printf("\n");</div><div><span class="" style="white-space:pre">    </span>int nbr_elm[2] = { 4, 6 };</div><div><span class="" style="white-space:pre"> </span>int dpl[2] = { 0, 4 };</div><div><br></div><div><span class="" style="white-space:pre">    </span>MPI_Init(&argc, &argv);</div><div><span class="" style="white-space:pre">    </span>MPI_Comm_rank(MPI_COMM_WORLD, &taskid);</div><div><span class="" style="white-space:pre">        </span>MPI_Comm_size(MPI_COMM_WORLD, &ntasks);</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">      </span>recvbuff = (double *)malloc(sizeof(double)*nbr_etat);</div><div><span class="" style="white-space:pre">      </span>if (taskid == 0)</div><div><span class="" style="white-space:pre">   </span>{</div><div><span class="" style="white-space:pre">          </span>sendbuff = (double **)malloc(sizeof(double *)*ntasks);// on execute pour deux proc</div><div><span class="" style="white-space:pre">         </span>sendbuff[0] = (double *)malloc(sizeof(double)*ntasks*nbr_etat);</div><div><span class="" style="white-space:pre">            </span>for (i = 1; i < ntasks; i++)</div><div><span class="" style="white-space:pre">            </span>{</div><div><span class="" style="white-space:pre">                  </span>sendbuff[i] = sendbuff[i - 1] + nbr_etat;</div><div><span class="" style="white-space:pre">              </span>}</div><div><span class="" style="white-space:pre">  </span>}</div><div><span class="" style="white-space:pre">  </span>else</div><div><span class="" style="white-space:pre">       </span>{</div><div><span class="" style="white-space:pre">          </span>sendbuff = (double **)malloc(sizeof(double *)* 1);</div><div><span class="" style="white-space:pre">         </span>sendbuff[0] = (double *)malloc(sizeof(double)* 1);</div><div><span class="" style="white-space:pre"> </span>}</div><div><br></div><div><span class="" style="white-space:pre"> </span>if (taskid == 0){</div><div><br></div><div><br></div><div><br></div><div><br></div><div><span class="" style="white-space:pre">              </span>srand((unsigned)time(NULL) + taskid);</div><div><span class="" style="white-space:pre">          </span>for (itask = 0; itask<ntasks; itask++)</div><div><span class="" style="white-space:pre">          </span>{</div><div><span class="" style="white-space:pre">                  </span>int k;</div><div><span class="" style="white-space:pre">                     </span>displs[itask] = itask*nbr_etat;</div><div><span class="" style="white-space:pre">                    </span>int s = dpl[itask];</div><div><span class="" style="white-space:pre">                        </span>sendcounts[itask] = nbr_elm[itask];</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">                      </span>for (i = 0; i<sendcounts[itask]; i++)</div><div><span class="" style="white-space:pre">                   </span>{</div><div><span class="" style="white-space:pre">                          </span>k = i + s;</div><div><span class="" style="white-space:pre">                             </span>sendbuff[itask][i] = tab[k];</div><div><span class="" style="white-space:pre">                               </span>printf("+ %0.0f  ", sendbuff[itask][i]);</div><div><span class="" style="white-space:pre">                        </span>}</div><div><span class="" style="white-space:pre">                  </span>printf("\n");</div><div><span class="" style="white-space:pre">            </span>}</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">        </span>}</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">        </span>recvcount = nbr_elm[taskid];</div><div><br></div><div><span class="" style="white-space:pre">      </span>inittime = MPI_Wtime();</div><div><br></div><div><span class="" style="white-space:pre">   </span>ierr = MPI_Scatterv(sendbuff[0], sendcounts, displs, MPI_DOUBLE,</div><div><span class="" style="white-space:pre">           </span>recvbuff, recvcount, MPI_DOUBLE,</div><div><span class="" style="white-space:pre">           </span>0, MPI_COMM_WORLD);</div><div><br></div><div><span class="" style="white-space:pre">       </span>totaltime = MPI_Wtime() - inittime;</div><div><br></div><div><span class="" style="white-space:pre">       </span>printf("\n<span class="" style="white-space:pre">   </span>>>>><span class="" style="white-space:pre">  </span>\n");</div><div><span class="" style="white-space:pre"> </span>buffsum = 0.0;</div><div><span class="" style="white-space:pre">     </span>printf("\n<span class="" style="white-space:pre">   </span>> %d <<span class="" style="white-space:pre">      </span>\n", taskid);</div><div><span class="" style="white-space:pre"> </span>for (i = 0; i<recvcount; i++)</div><div><span class="" style="white-space:pre">   </span>{</div><div><span class="" style="white-space:pre">          </span>printf("* %0.0f<span class="" style="white-space:pre">      </span>", recvbuff[i]);</div><div><span class="" style="white-space:pre">      </span>}</div><div><br></div><div><span class="" style="white-space:pre"> </span>printf("\n");</div><div><span class="" style="white-space:pre">    </span>if (taskid == 0){</div><div><span class="" style="white-space:pre">          </span>free(sendbuff[0]);</div><div><span class="" style="white-space:pre">         </span>free(sendbuff);</div><div><span class="" style="white-space:pre">    </span>}</div><div><span class="" style="white-space:pre">  </span>else{</div><div><span class="" style="white-space:pre">              </span>free(sendbuff[0]);</div><div><span class="" style="white-space:pre">         </span>free(sendbuff);</div><div><span class="" style="white-space:pre">            </span>free(recvbuff);</div><div><span class="" style="white-space:pre">    </span>}</div><div><br></div><div><span class="" style="white-space:pre"> </span>/*===============================================================*/</div><div><span class="" style="white-space:pre">        </span>/* Finalisation de MPI                                           */</div><div><span class="" style="white-space:pre">       </span>MPI_Finalize();</div><div><br></div><div>}</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-28 20:52 GMT+01:00 Chafik sanaa <span dir="ltr"><<a href="mailto:san.chafik@gmail.com" target="_blank">san.chafik@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi<div>when i execute this program (I use two processes) i have a error in the display part :</div><div>* RESULT OF EXECUTION:</div><div><div>0<span style="white-space:pre-wrap"> </span>1<span style="white-space:pre-wrap">       </span>2<span style="white-space:pre-wrap">       </span>3<span style="white-space:pre-wrap">       </span>4<span style="white-space:pre-wrap">       </span>5<span style="white-space:pre-wrap">       </span>6<span style="white-space:pre-wrap">       </span>7<span style="white-space:pre-wrap">       </span>8<span style="white-space:pre-wrap">       </span>9<span style="white-space:pre-wrap">       </span></div><div>>> (1,6) << </div><div><br></div><div><span style="white-space:pre-wrap">    </span>>>>><span style="white-space:pre-wrap">        </span></div><div><br></div><div><span style="white-space:pre-wrap">        </span>> 1 <<span style="white-space:pre-wrap">     </span></div><div>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">   </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span></div><div>0<span style="white-space:pre-wrap">        </span>1<span style="white-space:pre-wrap">       </span>2<span style="white-space:pre-wrap">       </span>3<span style="white-space:pre-wrap">       </span>4<span style="white-space:pre-wrap">       </span>5<span style="white-space:pre-wrap">       </span>6<span style="white-space:pre-wrap">       </span>7<span style="white-space:pre-wrap">       </span>8<span style="white-space:pre-wrap">       </span>9<span style="white-space:pre-wrap">       </span></div><div>0  1  2  3  </div><div>4  5  6  7  8  9  </div><div>>> (0,4) << </div><div><br></div><div><span style="white-space:pre-wrap">      </span>>>>><span style="white-space:pre-wrap">        </span></div><div><br></div><div><span style="white-space:pre-wrap">        </span>> 0 <<span style="white-space:pre-wrap">     </span></div><div>* 0<span style="white-space:pre-wrap">      </span>* 1<span style="white-space:pre-wrap">     </span>* 2<span style="white-space:pre-wrap">     </span>* 3 </div></div><div>* PROGRAM</div><div><div>#include <malloc.h></div><div>#include <stdlib.h></div><div>#include <stdio.h></div><div>#include <time.h></div><div>#include "math.h"</div><div>#include "mpi.h"</div><div><br></div><div>int main(int argc, char** argv)</div><div>{</div><div><span style="white-space:pre-wrap">  </span>int          taskid, ntasks;</div><div><span style="white-space:pre-wrap">    </span>int          ierr, i, itask;</div><div><span style="white-space:pre-wrap">    </span>int<span style="white-space:pre-wrap">     </span>         sendcounts[2048], displs[2048], recvcount;</div><div><span style="white-space:pre-wrap">     </span>double       **sendbuff, *recvbuff, buffsum, buffsums[2048];</div><div><span style="white-space:pre-wrap">      </span>double       inittime, totaltime;</div><div><span style="white-space:pre-wrap"> </span>const int nbr_etat = 10;</div><div><span style="white-space:pre-wrap"> </span>double tab[nbr_etat];</div><div><br></div><div><span style="white-space:pre-wrap">   </span>for (int i = 0; i < nbr_etat; i++)</div><div><span style="white-space:pre-wrap">            </span>tab[i] = i;</div><div><br></div><div><span style="white-space:pre-wrap">     </span>for (int i = 0; i < nbr_etat; i++)</div><div><span style="white-space:pre-wrap">            </span>printf("%0.0f<span style="white-space:pre-wrap">      </span>", tab[i]);</div><div><span style="white-space:pre-wrap"> </span>printf("\n");</div><div><span style="white-space:pre-wrap">  </span>int nbr_elm[2] = { 4, 6 };</div><div><span style="white-space:pre-wrap">       </span>int dpl[2] = { 0, 4 };</div><div><br></div><div><span style="white-space:pre-wrap">  </span>MPI_Init(&argc, &argv);</div><div><span style="white-space:pre-wrap">  </span>MPI_Comm_rank(MPI_COMM_WORLD, &taskid);</div><div><span style="white-space:pre-wrap">      </span>MPI_Comm_size(MPI_COMM_WORLD, &ntasks);</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">    </span>recvbuff = (double *)malloc(sizeof(double)*nbr_etat);</div><div><span style="white-space:pre-wrap">    </span>if (taskid == 0)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap">                </span>sendbuff = (double **)malloc(sizeof(double *)*ntasks);// on execute pour deux proc</div><div><span style="white-space:pre-wrap">               </span>sendbuff[0] = (double *)malloc(sizeof(double)*ntasks*nbr_etat);</div><div><span style="white-space:pre-wrap">          </span>for (i = 1; i < ntasks; i++)</div><div><span style="white-space:pre-wrap">          </span>{</div><div><span style="white-space:pre-wrap">                        </span>sendbuff[i] = sendbuff[i - 1] + nbr_etat;</div><div><span style="white-space:pre-wrap">            </span>}</div><div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span>else</div><div><span style="white-space:pre-wrap">     </span>{</div><div><span style="white-space:pre-wrap">                </span>sendbuff = (double **)malloc(sizeof(double *)* 1);</div><div><span style="white-space:pre-wrap">               </span>sendbuff[0] = (double *)malloc(sizeof(double)* 1);</div><div><span style="white-space:pre-wrap">       </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>if (taskid == 0){</div><div><br></div><div><br></div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">            </span>srand((unsigned)time(NULL) + taskid);</div><div><span style="white-space:pre-wrap">                </span>for (itask = 0; itask<ntasks; itask++)</div><div><span style="white-space:pre-wrap">                </span>{</div><div><span style="white-space:pre-wrap">                        </span>int k;</div><div><span style="white-space:pre-wrap">                   </span>displs[itask] = dpl[itask];</div><div><span style="white-space:pre-wrap">                      </span>int s = displs[itask];</div><div><span style="white-space:pre-wrap">                   </span>sendcounts[itask] = nbr_elm[itask];</div><div><span style="white-space:pre-wrap">              </span></div><div><br></div><div><span style="white-space:pre-wrap">                        </span>for (i = 0; i<sendcounts[itask]; i++)</div><div><span style="white-space:pre-wrap">                 </span>{</div><div><span style="white-space:pre-wrap">                                </span>k = i + s;</div><div><span style="white-space:pre-wrap">                           </span>sendbuff[itask][i] = tab[k];</div><div><span style="white-space:pre-wrap">                             </span>printf("%0.0f  ", sendbuff[itask][i]);</div><div><span style="white-space:pre-wrap">                    </span>}</div><div><span style="white-space:pre-wrap">                        </span>printf("\n");</div><div><span style="white-space:pre-wrap">          </span>}</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">      </span>}</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">      </span>recvcount = nbr_elm[taskid];</div><div><br></div><div><span style="white-space:pre-wrap">    </span>inittime = MPI_Wtime();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>ierr = MPI_Scatterv(sendbuff[0], sendcounts, displs, MPI_DOUBLE,</div><div><span style="white-space:pre-wrap">         </span>recvbuff, recvcount, MPI_DOUBLE,</div><div><span style="white-space:pre-wrap">         </span>0, MPI_COMM_WORLD);</div><div><br></div><div><span style="white-space:pre-wrap">     </span>totaltime = MPI_Wtime() - inittime;</div><div>                            </div><div><span style="white-space:pre-wrap">        </span>printf("\n<span style="white-space:pre-wrap"> </span>>>>><span style="white-space:pre-wrap">        </span>\n");</div><div><span style="white-space:pre-wrap">       </span>buffsum = 0.0;</div><div><span style="white-space:pre-wrap">   </span>printf("\n<span style="white-space:pre-wrap"> </span>> %d <<span style="white-space:pre-wrap">    </span>\n",taskid);</div><div><span style="white-space:pre-wrap">        </span>for (i = 0; i<recvcount; i++)</div><div><span style="white-space:pre-wrap"> </span>{<span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap"> </span>printf("* %0.0f<span style="white-space:pre-wrap">    </span>", recvbuff[i]);</div><div><span style="white-space:pre-wrap">    </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>printf("\n");                                  </div><div><span style="white-space:pre-wrap">   </span>if (taskid == 0){</div><div><span style="white-space:pre-wrap">                </span>free(sendbuff[0]);</div><div><span style="white-space:pre-wrap">               </span>free(sendbuff);</div><div><span style="white-space:pre-wrap">  </span>}</div><div><span style="white-space:pre-wrap">        </span>else{</div><div><span style="white-space:pre-wrap">            </span>free(sendbuff[0]);</div><div><span style="white-space:pre-wrap">               </span>free(sendbuff);</div><div><span style="white-space:pre-wrap">          </span>free(recvbuff);</div><div><span style="white-space:pre-wrap">  </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>/*===============================================================*/</div><div><span style="white-space:pre-wrap">      </span>/* Finalisation de MPI                                           */</div><div><span style="white-space:pre-wrap">     </span>MPI_Finalize();</div><div><br></div><div>}</div></div><div><br></div><div><br></div></div></blockquote></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-28 20:53 GMT+01:00 Chafik sanaa <span dir="ltr"><<a href="mailto:san.chafik@gmail.com" target="_blank">san.chafik@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi<div>when i execute this program (I use two processes) i have a error in the display part :</div><div>* RESULT OF EXECUTION:</div><div><div>0<span style="white-space:pre-wrap">   </span>1<span style="white-space:pre-wrap">       </span>2<span style="white-space:pre-wrap">       </span>3<span style="white-space:pre-wrap">       </span>4<span style="white-space:pre-wrap">       </span>5<span style="white-space:pre-wrap">       </span>6<span style="white-space:pre-wrap">       </span>7<span style="white-space:pre-wrap">       </span>8<span style="white-space:pre-wrap">       </span>9<span style="white-space:pre-wrap">       </span></div><div>>> (1,6) << </div><div><br></div><div><span style="white-space:pre-wrap">    </span>>>>><span style="white-space:pre-wrap">        </span></div><div><br></div><div><span style="white-space:pre-wrap">        </span>> 1 <<span style="white-space:pre-wrap">     </span></div><div>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">   </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span>* -6277438562204192500000000000000000000000000000000000000000000000000<span style="white-space:pre-wrap">  </span></div><div>0<span style="white-space:pre-wrap">        </span>1<span style="white-space:pre-wrap">       </span>2<span style="white-space:pre-wrap">       </span>3<span style="white-space:pre-wrap">       </span>4<span style="white-space:pre-wrap">       </span>5<span style="white-space:pre-wrap">       </span>6<span style="white-space:pre-wrap">       </span>7<span style="white-space:pre-wrap">       </span>8<span style="white-space:pre-wrap">       </span>9<span style="white-space:pre-wrap">       </span></div><div>0  1  2  3  </div><div>4  5  6  7  8  9  </div><div>>> (0,4) << </div><div><br></div><div><span style="white-space:pre-wrap">      </span>>>>><span style="white-space:pre-wrap">        </span></div><div><br></div><div><span style="white-space:pre-wrap">        </span>> 0 <<span style="white-space:pre-wrap">     </span></div><div>* 0<span style="white-space:pre-wrap">      </span>* 1<span style="white-space:pre-wrap">     </span>* 2<span style="white-space:pre-wrap">     </span>* 3 </div></div><div>* PROGRAM</div><div><div>#include <malloc.h></div><div>#include <stdlib.h></div><div>#include <stdio.h></div><div>#include <time.h></div><div>#include "math.h"</div><div>#include "mpi.h"</div><div><br></div><div>int main(int argc, char** argv)</div><div>{</div><div><span style="white-space:pre-wrap">  </span>int          taskid, ntasks;</div><div><span style="white-space:pre-wrap">    </span>int          ierr, i, itask;</div><div><span style="white-space:pre-wrap">    </span>int<span style="white-space:pre-wrap">     </span>         sendcounts[2048], displs[2048], recvcount;</div><div><span style="white-space:pre-wrap">     </span>double       **sendbuff, *recvbuff, buffsum, buffsums[2048];</div><div><span style="white-space:pre-wrap">      </span>double       inittime, totaltime;</div><div><span style="white-space:pre-wrap"> </span>const int nbr_etat = 10;</div><div><span style="white-space:pre-wrap"> </span>double tab[nbr_etat];</div><div><br></div><div><span style="white-space:pre-wrap">   </span>for (int i = 0; i < nbr_etat; i++)</div><div><span style="white-space:pre-wrap">            </span>tab[i] = i;</div><div><br></div><div><span style="white-space:pre-wrap">     </span>for (int i = 0; i < nbr_etat; i++)</div><div><span style="white-space:pre-wrap">            </span>printf("%0.0f<span style="white-space:pre-wrap">      </span>", tab[i]);</div><div><span style="white-space:pre-wrap"> </span>printf("\n");</div><div><span style="white-space:pre-wrap">  </span>int nbr_elm[2] = { 4, 6 };</div><div><span style="white-space:pre-wrap">       </span>int dpl[2] = { 0, 4 };</div><div><br></div><div><span style="white-space:pre-wrap">  </span>MPI_Init(&argc, &argv);</div><div><span style="white-space:pre-wrap">  </span>MPI_Comm_rank(MPI_COMM_WORLD, &taskid);</div><div><span style="white-space:pre-wrap">      </span>MPI_Comm_size(MPI_COMM_WORLD, &ntasks);</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">    </span>recvbuff = (double *)malloc(sizeof(double)*nbr_etat);</div><div><span style="white-space:pre-wrap">    </span>if (taskid == 0)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap">                </span>sendbuff = (double **)malloc(sizeof(double *)*ntasks);// on execute pour deux proc</div><div><span style="white-space:pre-wrap">               </span>sendbuff[0] = (double *)malloc(sizeof(double)*ntasks*nbr_etat);</div><div><span style="white-space:pre-wrap">          </span>for (i = 1; i < ntasks; i++)</div><div><span style="white-space:pre-wrap">          </span>{</div><div><span style="white-space:pre-wrap">                        </span>sendbuff[i] = sendbuff[i - 1] + nbr_etat;</div><div><span style="white-space:pre-wrap">            </span>}</div><div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span>else</div><div><span style="white-space:pre-wrap">     </span>{</div><div><span style="white-space:pre-wrap">                </span>sendbuff = (double **)malloc(sizeof(double *)* 1);</div><div><span style="white-space:pre-wrap">               </span>sendbuff[0] = (double *)malloc(sizeof(double)* 1);</div><div><span style="white-space:pre-wrap">       </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>if (taskid == 0){</div><div><br></div><div><br></div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">            </span>srand((unsigned)time(NULL) + taskid);</div><div><span style="white-space:pre-wrap">                </span>for (itask = 0; itask<ntasks; itask++)</div><div><span style="white-space:pre-wrap">                </span>{</div><div><span style="white-space:pre-wrap">                        </span>int k;</div><div><span style="white-space:pre-wrap">                   </span>displs[itask] = dpl[itask];</div><div><span style="white-space:pre-wrap">                      </span>int s = displs[itask];</div><div><span style="white-space:pre-wrap">                   </span>sendcounts[itask] = nbr_elm[itask];</div><div><span style="white-space:pre-wrap">              </span></div><div><br></div><div><span style="white-space:pre-wrap">                        </span>for (i = 0; i<sendcounts[itask]; i++)</div><div><span style="white-space:pre-wrap">                 </span>{</div><div><span style="white-space:pre-wrap">                                </span>k = i + s;</div><div><span style="white-space:pre-wrap">                           </span>sendbuff[itask][i] = tab[k];</div><div><span style="white-space:pre-wrap">                             </span>printf("%0.0f  ", sendbuff[itask][i]);</div><div><span style="white-space:pre-wrap">                    </span>}</div><div><span style="white-space:pre-wrap">                        </span>printf("\n");</div><div><span style="white-space:pre-wrap">          </span>}</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">      </span>}</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">      </span>recvcount = nbr_elm[taskid];</div><div><br></div><div><span style="white-space:pre-wrap">    </span>inittime = MPI_Wtime();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>ierr = MPI_Scatterv(sendbuff[0], sendcounts, displs, MPI_DOUBLE,</div><div><span style="white-space:pre-wrap">         </span>recvbuff, recvcount, MPI_DOUBLE,</div><div><span style="white-space:pre-wrap">         </span>0, MPI_COMM_WORLD);</div><div><br></div><div><span style="white-space:pre-wrap">     </span>totaltime = MPI_Wtime() - inittime;</div><div>                            </div><div><span style="white-space:pre-wrap">        </span>printf("\n<span style="white-space:pre-wrap"> </span>>>>><span style="white-space:pre-wrap">        </span>\n");</div><div><span style="white-space:pre-wrap">       </span>buffsum = 0.0;</div><div><span style="white-space:pre-wrap">   </span>printf("\n<span style="white-space:pre-wrap"> </span>> %d <<span style="white-space:pre-wrap">    </span>\n",taskid);</div><div><span style="white-space:pre-wrap">        </span>for (i = 0; i<recvcount; i++)</div><div><span style="white-space:pre-wrap"> </span>{<span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap"> </span>printf("* %0.0f<span style="white-space:pre-wrap">    </span>", recvbuff[i]);</div><div><span style="white-space:pre-wrap">    </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>printf("\n");                                  </div><div><span style="white-space:pre-wrap">   </span>if (taskid == 0){</div><div><span style="white-space:pre-wrap">                </span>free(sendbuff[0]);</div><div><span style="white-space:pre-wrap">               </span>free(sendbuff);</div><div><span style="white-space:pre-wrap">  </span>}</div><div><span style="white-space:pre-wrap">        </span>else{</div><div><span style="white-space:pre-wrap">            </span>free(sendbuff[0]);</div><div><span style="white-space:pre-wrap">               </span>free(sendbuff);</div><div><span style="white-space:pre-wrap">          </span>free(recvbuff);</div><div><span style="white-space:pre-wrap">  </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>/*===============================================================*/</div><div><span style="white-space:pre-wrap">      </span>/* Finalisation de MPI                                           */</div><div><span style="white-space:pre-wrap">     </span>MPI_Finalize();</div><div><br></div><div>}</div></div><div><br></div></div>
</blockquote></div><br></div>