Re: [mpich-discuss] the function MPI_Scatterv
Try init tab_indice and tab_taille to NULL (it does not matter that it is initialized for non-root, but the compiler likely isn't smart enough to tell) 2014-11-15 12:38 GMT-08:00 Chafik sanaa <[email protected]>:
when i running the following program, i have this error (error C4703: variable de pointeur locale potentiellement non initialisée 'tab_indice' utilisée and error C4703: variable de pointeur locale potentiellement non initialisée 'tab_taille' utilisée ): program: ///////////////////////////////////////////// // MPI_Scatterv.c // test de la fonction MPI_Scatterv /////////////////////////////////////////////
#include <stdio.h> #include <stdlib.h> #include <mpi.h>
#define DIMENSION 10
int main(int argc, char** argv) { int myrank, i, n_procs; int * sendbuf; //buffer à disperser int * tab_indice; //indice de début de chaque subdivision int * tab_taille; //nombre d'éléments à envoyer // pour chaque processus int * rbuf; //buffer de reception int taille; //taille de la partie reçue
//Initialisation de MPI MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &n_procs); MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0) { //allocation mémoire sendbuf = (int *)malloc(n_procs*DIMENSION*sizeof(int)); tab_indice = (int *)malloc(n_procs*sizeof(int)); tab_taille = (int *)malloc(n_procs*sizeof(int)); //remplissage du buffer à disperser for (i = 0; i<n_procs*DIMENSION; i++) sendbuf[i] = i; //initialisation des subdivisions for (i = 0; i<n_procs; i++){ //nombre d'éléments à envoyer tab_taille[i] = DIMENSION - i; //indice de début du processus i // = celui de i-1 + nombre d'éléments // envoyés par i-1 if (i != 0) tab_indice[i] = tab_indice[i - 1] + tab_taille[i - 1]; else tab_indice[i] = 0; } }
//communication de la taille de la partie reçue à chaque processus MPI_Scatter(tab_taille, 1, MPI_INT, &taille, 1, MPI_INT, 0, MPI_COMM_WORLD); //allocation du buffer de reception rbuf = (int *)malloc(taille*sizeof(int));
//dispersion MPI_Scatterv(&sendbuf, tab_taille, tab_indice, MPI_INT, rbuf, DIMENSION, MPI_INT, 0, MPI_COMM_WORLD);
//affichage printf("processus %d : [ ", myrank); for (i = 0; i<taille; i++) printf("%d ", rbuf[i]); printf("]\n");
//desallocation mémoire free(rbuf); if (myrank == 0) { free(sendbuf); free(tab_indice); free(tab_taille); }
MPI_Finalize(); exit(EXIT_SUCCESS); }
_______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
_______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
participants (1)
-
Anh Vo