Please only use this list for MPICH-related questions, not general programming questions. — Pavan
On Nov 11, 2014, at 9:42 AM, Chafik sanaa <[email protected]> wrote:
Hi, What should I do? i have the folowing error (error C4703: variable de pointeur locale potentiellement non initialisée 'sendbuf' utilisée and error C4703: variable de pointeur locale potentiellement non initialisée 'tab_indice' utilisée ) when I execute this program: #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 printf("la taille de la boucle %d \n", n_procs*DIMENSION); 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; printf("tab_taille[%d]=%d \n", i, tab_taille[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; printf("tab_indice[%d]=%d \n", i, tab_indice[i]); } } //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
-- Pavan Balaji ✉️ http://www.mcs.anl.gov/~balaji _______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
participants (1)
-
Balaji, Pavan