#include <stdio.h>
#include <mpi.h>
#include
#include <time.h>
#include <math.h>
#define size 1000
float a[size][size];
float sum[size];
void norm(int istart, int iend)
{
int i,j;
for ( i = istart; i <= iend; ++i) {
for (j = 0; j < size; ++j) {
sum[i]=sum[i]+a[i][j];
}
}
}
int main(int argc, char* argv[])
{
int rank, nproc,i,j;
int istart, iend;
float t_1;
clock_t c_1,c_2;
c_1=time(NULL); MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
for ( i = 0; i < size; ++i) {
for (j = 0; j < size; ++j) {
a[i][j] = (float)i + j;
}
sum[i]=0;
}
}
MPI_Bcast(a, size*size, MPI_FLOAT, 0,MPI_COMM_WORLD);
istart = (size / nproc) * rank;
iend = (size / nproc) * (rank + 1) - 1;
norm(istart, iend);
MPI_Gather(sum+ (size/nproc*rank),
size*size/nproc,
MPI_FLOAT,
sum + (size/nproc*rank),
size*size/nproc,
MPI_FLOAT,
0,
MPI_COMM_WORLD);
if (rank == 0) {
if (size % nproc > 0) {
norm((size/nproc)*nproc, size-1);
}
}
MPI_Finalize();
c_2=time(NULL);
t_1 = (float)(c_2-c_1);
printf("Execution time: %f \n",t_1);
return 0;
}
What I have tried:
Fatal error in PMPI_Gather: Invalid buffer pointer, error stack:
PMPI_Gather(856): MPI_Gather(sbuf=0x6010a0, scount=1000000, MPI_FLOAT, rbuf=0x6010a0, rcount=1000000, MPI_FLOAT, root=0, MPI_COMM_WORLD) failed
PMPI_Gather(797): Buffers must not be aliased
it program to compute norm1 and infinite norm in mathmatical
it run ....
but when it get run show me this error
what means of this error
please help