MPI_Scatter根进程出口,信号为(6),

问题描述 投票:0回答:1

我正在尝试读取图像(.ras),并将图像的一部分发送给每个进程。但是每次我得到

主作业正常终止,但是1个进程返回了非零的退出代码。按照用户方向,作业已中止。mpirun注意到在节点eskandarany上具有PID 0的进程等级0在信号6(异常终止)上退出。

这是我的代码:


typedef struct {
  struct rasterfile file;  ///< Entête image Sun Raster
  unsigned char rouge[256],vert[256],bleu[256];  ///< Palette de couleur
  unsigned char *data;    ///< Pointeur vers l'image
} Raster;

int main(int argc, char *argv[]) {
  Raster r;
  int    w, h, lh;  /* nombre de lignes et de colonnes de l'image */
  /* Variables liees au traitement de l'image */
  int    filtre;        /* numero du filtre */
  int    nbiter;        /* nombre d'iterations */
  /* Variables liees au chronometrage */
  double debut, fin;
  /* Variables de boucle */
  int   i,j;
  /* Nombres de processus */
  int p, my_rank, tag = 0, root = 0;
  MPI_Status status;
  if (argc != 4) {
    fprintf( stderr, usage, argv[0]);
    return 1;
  }      
  /* Saisie des paramètres */
  filtre = atoi(argv[2]);
  nbiter = atoi(argv[3]);

  /* Initialisation */
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &p);

  /* Lecture du fichier Raster */
  if (my_rank == root) {
    lire_rasterfile( argv[1], &r);
    h = r.file.ras_height;
    w = r.file.ras_width;
    lh = (h/p) + 2;
  }
  MPI_Bcast(&w, 1, MPI_INT, root, MPI_COMM_WORLD);
  MPI_Bcast(&lh, 1, MPI_INT, root, MPI_COMM_WORLD);
  int shift = 0;
  if (my_rank == 0 || my_rank == p-1) {
    lh--;
    shift = w;
  }
  unsigned char *bandlette = (unsigned char *) malloc(w * lh * sizeof(unsigned char));
  MPI_Scatter(r.data, w*h, MPI_UNSIGNED_CHAR, bandlette + shift, w*lh, MPI_UNSIGNED_CHAR, root, MPI_COMM_WORLD);

  printf("my rank is %i\n", my_rank);

  free(bandlette);
  free(r.data);
  MPI_Finalize();

  return 0;
} ```
c++ c mpi openmpi mpir
1个回答
1
投票

问题在于,MPI_Scatter的第二个参数是要发送给每个进程的数据大小,而不是send_buffer的总大小。因此,在这种情况下它将为w * h / p

© www.soinside.com 2019 - 2024. All rights reserved.