我正在尝试使用 MPI 和 C 将方阵乘以向量。我必须使用 MPI_Allgather 将矩阵的所有部分发送到所有进程。这就是我到目前为止所拥有的
#include "mpi.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#define DIM 500
int main(int argc, char *argv[])
{
int i, j, n;
int nlocal; /* Number of locally stored rows of A */
double *fb;
double a[DIM*DIM], b[DIM], x[DIM]; /* Will point to a buffer that stores the entire vector b */
int npes, myrank;
MPI_Status status;
MPI_Init(&argc,&argv);
/* Get information about the communicator */
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
MPI_Comm_size(MPI_COMM_WORLD, &npes);
/* …Run Code Online (Sandbox Code Playgroud)