V
V
vkopeluk2016-09-25 00:53:08
Multithreading
vkopeluk, 2016-09-25 00:53:08

Can't loop 1 step when transferring data?

Each process is given an integer. Using the MPI_Send and MPI_Recv functions, perform a cyclic data shift with step 1 for all processes, sending the number from process 0 to process 1, from process 1 to process 2, ..., from the last process to process 0. In each process, output the resulting number.

#include <windows.h>
#pragma hdrstop
#include "mpi.h"
#include "pt4.h"
void Solve()
{
  Task("MPIBegin18");
  int flag;
  MPI_Initialized(&flag);
  if (flag == 0)
    return;
  int rank, size;
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Status s;
  int n;

  pt >> n;
  //Show(n);

  for (int i = 0; i < size; ++i)
  {

    MPI_Send(&n, 1, MPI_INT, i, 0, MPI_COMM_WORLD);
  }

  
}

that's what it is, whether it would have done an array without problems, but here something has no ideas. Help if not difficult

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question