- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need to program an operation using MPI which is not something usual nor efficient, but I need to do this and I am asking for suggestions.
This is a simple example that represents what I am going to do, in a nutshell:
I have a 1d array, evenly divided between processes. Process 0 starts operations on the array which are propagating, i.e. operation on array entry i+1 needs the result of the operation on entry i.
This is easily done on a single process with a do loop. now process 1 needs to wait for processes 0 to do all the operations on its portion of the array, since it needs the value of the last entry of the array assigned to process 0. Then communication occurs and process 1 can start.
How can this be achieved? I am only familiar with synchronous operations.
Thank you
I need to program an operation using MPI which is not something usual nor efficient, but I need to do this and I am asking for suggestions.
This is a simple example that represents what I am going to do, in a nutshell:
I have a 1d array, evenly divided between processes. Process 0 starts operations on the array which are propagating, i.e. operation on array entry i+1 needs the result of the operation on entry i.
This is easily done on a single process with a do loop. now process 1 needs to wait for processes 0 to do all the operations on its portion of the array, since it needs the value of the last entry of the array assigned to process 0. Then communication occurs and process 1 can start.
How can this be achieved? I am only familiar with synchronous operations.
Thank you
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simplest way would be:
Tim
[fortran]IF(my_rank == 0) THEN DO I = 1, numPerProcEND DO END IF CALL MPI_BARRIER(MPI_COMM_WORLD) ! Send/recv the results IF(my_rank == 1) THEN DO I = numPerProc, endNum END DO END IF CALL MPI_BARRIER(MPI_COMM_WORLD)[/fortran]
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you talking two processes or n processes?
When using two processes then something like Tim suggests would work out. When using N processes you would expand upon Tim's suggestion (I' worker 0, I'm worker 1, ... I'm worker n-1).
But note that there are two different ways to handle the data flow
a) master thread dispatches work for each worker
b) worker dispatches work for next worker
Method a) will generallyrequire more messaging
Method b) is like pipeline or bucket brigate
has less messaging and can use multiple routes simulteaneously
Jim Dempsey
When using two processes then something like Tim suggests would work out. When using N processes you would expand upon Tim's suggestion (I' worker 0, I'm worker 1, ... I'm worker n-1).
But note that there are two different ways to handle the data flow
a) master thread dispatches work for each worker
b) worker dispatches work for next worker
Method a) will generallyrequire more messaging
Method b) is like pipeline or bucket brigate
has less messaging and can use multiple routes simulteaneously
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I'll try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jim,
I am talking about n processes, so I 'll expand around Tim suggestion, which is on the lines of your case b) I think.
Thank you a lot
Alberto
I am talking about n processes, so I 'll expand around Tim suggestion, which is on the lines of your case b) I think.
Thank you a lot
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would this work for an N number of processes which is not know beforehand:
do process=0,NUMPROCS-1
if(myid .eq. process) then
do i=1:N
....
enddo
end if
call MPI_BARRIER(mpi_comm_world, ier)
! sendrecv communications
....
end do
I am apparently having issues here with these lines of code..
Thanks for any suggestion
do process=0,NUMPROCS-1
if(myid .eq. process) then
do i=1:N
....
enddo
end if
call MPI_BARRIER(mpi_comm_world, ier)
! sendrecv communications
....
end do
I am apparently having issues here with these lines of code..
Thanks for any suggestion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That should work but note that the sections are all serial. So, you get no speedup by making this parallel versus leaving it singular. In fact, this section would be slower in parallel than in serial because of the overhead from barriers and communication. If this is the only thing the code does (which I doubt, but can't rule anything out without asking), then the *only* benefit to doing it in parallel is if the data won't fit on a single machine for memory reasons.
What is this procedure exactly? There may be a way to express it in a more parallel-friendly way than doing it serially and passing along the information. Or, if it's part of a more complicated code, then the other processes might have something else to keep them busy while the other one is in the IF statement.
Tim
What is this procedure exactly? There may be a way to express it in a more parallel-friendly way than doing it serially and passing along the information. Or, if it's part of a more complicated code, then the other processes might have something else to keep them busy while the other one is in the IF statement.
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tim,
I know this is really a waste of computational resources since all the processes have to wait for NUMPROCS serial procedures to end but It is something I do not think I can avoid. It is done only once in the code, which is a much larger code. In fact, I have a 3D data array and there is 1D domain decomposition in J among the processes to run it in parallel. I am passing j=constant planes of data from one process to the other though send recv communications to the left and to the right.
Maybe I can optimize it a little but I want to make it work like this first, which I still cannot achieve..
Thanks
alberto
I know this is really a waste of computational resources since all the processes have to wait for NUMPROCS serial procedures to end but It is something I do not think I can avoid. It is done only once in the code, which is a much larger code. In fact, I have a 3D data array and there is 1D domain decomposition in J among the processes to run it in parallel. I am passing j=constant planes of data from one process to the other though send recv communications to the left and to the right.
Maybe I can optimize it a little but I want to make it work like this first, which I still cannot achieve..
Thanks
alberto

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page