Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.fortran

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-29-2006, 06:29 AM
Fabian Braennstroem
Guest
 
Posts: n/a
Default send array using MPI

Hi,

I try to write a small fortran/mpi program to solve the
poisson eqn. To accomplish that, I have to send a part of
the calculated 2D array to the other processors.

The array is defined in a COMMON file: f(i,j) with i=100 and
j=100.

I want to send the values for j=10 and i=1 to 100; so I
actually send 100 values to the other processors.

My problem is, that I do not know, how I declare the range
of the sending array to the MPI_SEND routine.


CALL MPI_Send(f(1,100),count,MPI_FLOAT,1, 0,MPI_COMM_WORLD, ierr)

'count' should be set to 100, but how can I declare the
range!?

Would be nice, if you have an idea, how I can do that in
fortran77!

Greetings!
Fabian
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 03-29-2006, 08:00 AM
Michael Wild
Guest
 
Posts: n/a
Default Re: send array using MPI

Fabian Braennstroem wrote:
> Hi,
>
> I try to write a small fortran/mpi program to solve the
> poisson eqn. To accomplish that, I have to send a part of
> the calculated 2D array to the other processors.
>
> The array is defined in a COMMON file: f(i,j) with i=100 and
> j=100.
>
> I want to send the values for j=10 and i=1 to 100; so I
> actually send 100 values to the other processors.
>
> My problem is, that I do not know, how I declare the range
> of the sending array to the MPI_SEND routine.
>
>
> CALL MPI_Send(f(1,100),count,MPI_FLOAT,1, 0,MPI_COMM_WORLD, ierr)
>
> 'count' should be set to 100, but how can I declare the
> range!?
>
> Would be nice, if you have an idea, how I can do that in
> fortran77!
>
> Greetings!
> Fabian



why do you pass f(1,100)? pass it f(1,10) and count=100. as fortran
stores column major, there's no problem. it will start in column 10, row
1 and send off until column 10, row 100.


michael
Reply With Quote
  #3 (permalink)  
Old 03-29-2006, 11:13 AM
Fabian Braennstroem
Guest
 
Posts: n/a
Default Re: send array using MPI

Hi Michael,

* Michael Wild <themiwi@student.ethz.ch> wrote:
> Fabian Braennstroem wrote:
>> Hi,
>>
>> I try to write a small fortran/mpi program to solve the
>> poisson eqn. To accomplish that, I have to send a part of
>> the calculated 2D array to the other processors.
>>
>> The array is defined in a COMMON file: f(i,j) with i=100 and
>> j=100.
>>
>> I want to send the values for j=10 and i=1 to 100; so I
>> actually send 100 values to the other processors.
>>
>> My problem is, that I do not know, how I declare the range
>> of the sending array to the MPI_SEND routine.
>>
>>
>> CALL MPI_Send(f(1,100),count,MPI_FLOAT,1, 0,MPI_COMM_WORLD, ierr)
>>
>> 'count' should be set to 100, but how can I declare the
>> range!?
>>
>> Would be nice, if you have an idea, how I can do that in
>> fortran77!
>>
>> Greetings!
>> Fabian

>
>
> why do you pass f(1,100)? pass it f(1,10) and count=100. as fortran
> stores column major, there's no problem. it will start in column 10, row
> 1 and send off until column 10, row 100.


Thanks for your hint, I forgot that! It works now, but how would I do it
the other way: i=10 and j=1 to 100?

Greetings!
Fabian
Reply With Quote
  #4 (permalink)  
Old 03-29-2006, 12:24 PM
Michael Wild
Guest
 
Posts: n/a
Default Re: send array using MPI

Fabian Braennstroem wrote:
> Hi Michael,
>
> * Michael Wild <themiwi@student.ethz.ch> wrote:
>
>>Fabian Braennstroem wrote:
>>
>>>Hi,
>>>
>>>I try to write a small fortran/mpi program to solve the
>>>poisson eqn. To accomplish that, I have to send a part of
>>>the calculated 2D array to the other processors.
>>>
>>>The array is defined in a COMMON file: f(i,j) with i=100 and
>>>j=100.
>>>
>>>I want to send the values for j=10 and i=1 to 100; so I
>>>actually send 100 values to the other processors.
>>>
>>>My problem is, that I do not know, how I declare the range
>>>of the sending array to the MPI_SEND routine.
>>>
>>>
>>>CALL MPI_Send(f(1,100),count,MPI_FLOAT,1, 0,MPI_COMM_WORLD, ierr)
>>>
>>>'count' should be set to 100, but how can I declare the
>>>range!?
>>>
>>>Would be nice, if you have an idea, how I can do that in
>>>fortran77!
>>>
>>>Greetings!
>>> Fabian

>>
>>
>>why do you pass f(1,100)? pass it f(1,10) and count=100. as fortran
>>stores column major, there's no problem. it will start in column 10, row
>>1 and send off until column 10, row 100.

>
>
> Thanks for your hint, I forgot that! It works now, but how would I do it
> the other way: i=10 and j=1 to 100?
>
> Greetings!
> Fabian


that's a problem. i don't think there's a way to allow for a "stride" in
the mpi calls. either sent the elements individualy (horror) or copy
them to a temporary array. i'm not the mpi guru though, there might be a
much better version...

michael
Reply With Quote
  #5 (permalink)  
Old 03-29-2006, 03:18 PM
Ron Shepard
Guest
 
Posts: n/a
Default Re: send array using MPI

In article <442a7c68$1@news1.ethz.ch>,
Michael Wild <themiwi@student.ethz.ch> wrote:

> > Thanks for your hint, I forgot that! It works now, but how would I do it
> > the other way: i=10 and j=1 to 100?

>
> that's a problem. i don't think there's a way to allow for a "stride" in
> the mpi calls. either sent the elements individualy (horror) or copy
> them to a temporary array. i'm not the mpi guru though, there might be a
> much better version...


I'm not an MPI guru either, but I think you do need to make a copy
of the data in a buffer with contiguous addresses and send that
buffer through the MPI call.

A few weeks ago there was a discussion about using f90 array syntax,
f(1,. The general conclusion seemed to be that this would not
work with many of the MPI calls. The problem is that the MPI_*()
calls do not use assumed shape declarations (or otherwise allow the
equivalent), so the fortran compiler will make a temporary copy, and
the MPI library will attempt to use the address of that copy after
its memory has been deallocated. MPI_SEND() is a blocking call, so
you might be able to use f(1, as an argument in it, but the
nonblocking calls (where the control is returned to the calling
program before the input data is fully processed) will probably not
work.

$.02 -Ron Shepard
Reply With Quote
  #6 (permalink)  
Old 03-29-2006, 03:46 PM
Douglas Sondak
Guest
 
Posts: n/a
Default Re: send array using MPI

In article <slrne2kqv4.6of.f.braennstroem@localhost.localdoma in>,
Fabian Braennstroem wrote:
> Thanks for your hint, I forgot that! It works now, but how would I do it
> the other way: i=10 and j=1 to 100?


An MPI user-defined datatype allows you to specify a stride. Take a look
at MPI_TYPE_VECTOR.

Doug Sondak
Reply With Quote
  #7 (permalink)  
Old 03-29-2006, 03:46 PM
Paul Van Delst
Guest
 
Posts: n/a
Default Re: send array using MPI

Michael Wild wrote:
> Fabian Braennstroem wrote:
>
>> Hi Michael,
>>
>> * Michael Wild <themiwi@student.ethz.ch> wrote:
>>
>>> Fabian Braennstroem wrote:
>>>
>>>> Hi,
>>>>
>>>> I try to write a small fortran/mpi program to solve the
>>>> poisson eqn. To accomplish that, I have to send a part of
>>>> the calculated 2D array to the other processors.
>>>>
>>>> The array is defined in a COMMON file: f(i,j) with i=100 and
>>>> j=100.
>>>>
>>>> I want to send the values for j=10 and i=1 to 100; so I
>>>> actually send 100 values to the other processors.
>>>> My problem is, that I do not know, how I declare the range
>>>> of the sending array to the MPI_SEND routine.
>>>>
>>>>
>>>> CALL MPI_Send(f(1,100),count,MPI_FLOAT,1, 0,MPI_COMM_WORLD, ierr)
>>>>
>>>> 'count' should be set to 100, but how can I declare the
>>>> range!?
>>>>
>>>> Would be nice, if you have an idea, how I can do that in
>>>> fortran77!
>>>>
>>>> Greetings!
>>>> Fabian
>>>
>>>
>>>
>>> why do you pass f(1,100)? pass it f(1,10) and count=100. as fortran
>>> stores column major, there's no problem. it will start in column 10,
>>> row 1 and send off until column 10, row 100.

>>
>>
>>
>> Thanks for your hint, I forgot that! It works now, but how would I do it
>> the other way: i=10 and j=1 to 100?
>>
>> Greetings!
>> Fabian

>
>
> that's a problem. i don't think there's a way to allow for a "stride" in
> the mpi calls. either sent the elements individualy (horror) or copy
> them to a temporary array. i'm not the mpi guru though, there might be a
> much better version...


I've encountered this problem recently - a copy being made to a temporary in an MPI call
and then the copy being destroyed before the results were passed back. The details are
becoming fuzzy, but basically MPI wait statements had to be put in there (or maybe
mpi_isend used instead of mpi_send? Can't remember) to allow the temporary to be "put
back" before proceeding. My quick take on the whole problem was that MPI just isn't
designed (either in general or under-the-covers) for use where pass-by-reference isn't
guaranteed. (Nothing wrong with that, of course, but it means no use of some f95 features).

cheers,

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Reply With Quote
  #8 (permalink)  
Old 03-29-2006, 04:18 PM
Richard E Maine
Guest
 
Posts: n/a
Default Re: send array using MPI

Ron Shepard <ron-shepard@NOSPAM.comcast.net> wrote:

> I'm not an MPI guru either, but I think you do need to make a copy
> of the data in a buffer with contiguous addresses and send that
> buffer through the MPI call.


...which is exactly what the compiler should do for you anyway, as you
describe. But as you also describe, the compiler-made copy is temporary
and will get deallocated too quickly in some cases. So you have to make
the copy yourself for those. I guess I'm just repeating what you said,
adding only the side note about the similarity of what the compiler does
and what you need to do; they are awfully similar, the difference just
being in the lifetime of the copy.

I'm also not an MPI guru (or even novice, because I have not yet once
used it). I think I understand the issue anyway, but it is possible that
my lack of direct experience specifically in MPI is leading me astray.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
Reply With Quote
  #9 (permalink)  
Old 03-29-2006, 04:34 PM
Dan Nagle
Guest
 
Posts: n/a
Default Re: send array using MPI

Ron Shepard wrote:

<snip>

> I'm not an MPI guru either, but I think you do need to make a copy
> of the data in a buffer with contiguous addresses and send that
> buffer through the MPI call.


Actually, you can, see MPI User Defined Datatypes.

However, It's probably not worth the effort, unless performance
is a real bottleneck. It's the kind of low-level rubbish
you'd expect from C. Just make the copy.

<snip>

--
Cheers!

Dan Nagle
Purple Sage Computing Solutions, Inc.
Reply With Quote
  #10 (permalink)  
Old 03-30-2006, 11:53 AM
Fabian Braennstroem
Guest
 
Posts: n/a
Default Re: send array using MPI

Hi to all,

thanks for your help!

[...]

Greetings!
Fabian
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Read/Write Microsoft Word document William W. Viergever Newsgroup comp.soft-sys.sas 0 05-31-2006 08:46 PM
Re: Read/Write Microsoft Word document Joe Whitehurst Newsgroup comp.soft-sys.sas 0 05-31-2006 08:35 PM
Re: MAX of _TEMPORARY_ array? Venky Chakravarthy Newsgroup comp.soft-sys.sas 0 06-27-2005 09:19 PM
Re: MAX of _TEMPORARY_ array? nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 06-27-2005 04:51 PM
Re: find maximum vaule in sas array Paul M. Dorfman Newsgroup comp.soft-sys.sas 0 04-27-2005 05:27 AM



All times are GMT. The time now is 09:00 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.