I have following code:
double * myX;
double * myY;
double * myZ;
int amount;
int count; // number of process
void SomeClass::someMethod(double *x, double *y, double *z, int amount) {
if (myId == 0) {
myX = x;
myY = y;
myZ = z;
amount = amount;
for(int i = 1; i < count; ++i) {
MPI_Send(&amount, 1, MPI_INT, i, 0, MPI_COMM_WORLD);
MPI_Send(myX, amount, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
MPI_Send(myY, amount, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
MPI_Send(myX, amount, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
}
}
}
void SomeClass::anotherMethod(void) {
if(myId != 0) {
MPI_Recv(&amount, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(myX, amount, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(myY, amount, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(myZ, amount, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
// rest of code
MPI_Reduce(args);
}
But I have problem because I get Null buffer pointer when I run this code or Segmentation fault when I change something, for example set & before var name and then run.
MPI_init and other required function are called in other class, where I also create this class objects.
Can someone help me?
Null buffer pointer? What line is theSegmentation faultthrown from?