0

I would like to build a big array of dimensions (nx, ny, nz) starting from more smaller arrays of dimensions (nx, ny, nz/np), where np is the number of processors.

As I am new to MPI, I don't exactly know the best procedure. What I tried for now is this (fortran):

call mpi_sendrecv(u_small(nx, ny, nz/np), nx*ny*nz/np, rp, up, 1, u_tot(nx, ny,nz),nx*ny*nz, rp, down, 1, comm, status, ierr)

in which rp, comm and status are already properly defined and they're correct.

Thanks for the help

1 Answer 1

2

You seem vague on how MPI works. "build a big array" where? On one of the processes? Then you need to use MPI_Gather.

But I have to ask: why? MPI is partly motivated by the need for oodles of memory. (In a pre-multicore world, a process was a processor, so the more processes, the more processors, and the more memory.) So a good MPI program keeps all its data distributed, and you "big array" is something that exists only in your mind. Besides: if you have enough processes, that "big array" may not even fit the memory of a single process. So: why do you want to construct it explicitly to being with?

Sign up to request clarification or add additional context in comments.

1 Comment

Or possibly MPI_Gatherv. But I agree, keep things distributed - use of mpi_gather(v) usually indicates things are not being done in a good way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.