On Tue, 17 Feb 2015, Sven Schreiber wrote:
Am 16.02.2015 um 23:29 schrieb Cottrell, Allin:
> On Mon, Feb 16, 2015 at 2:43 PM, Sven Schreiber <svetosch(a)gmx.net> wrote:
>>
>> Yes -- but that's where the literal meaning of "broadcast" or
"scatter"
>> comes in IMO: The whole purpose of these functions is to take something
>> that doesn't exist in other processes yet and copy it over there. So
>> it's a function that creates something in the subprocesses. In principle
>> that could also be written as (with non-existing syntax):
>>
>> matrix b = mpibroadcast(b[$mpirank==0])
>>
>> and this would make it completely clear that this creates b in all
>> "ranks". (I'm not suggesting this syntax change, it's just for
the sake
>> of the argument.) From this point of view I think the empty
>> pre-declaration could be redundant.
>
> Sorry, but this doesn't really make sense to me. We would have to
> institute something complicated that we don't do at present, namely
> parsing (but not executing) lines of hansl that are blocked by a false
> "if" condition. We'd have to keep a stack of names and types of
objects
> that don't exist but that might exist in future (if they're subsequently
> broadcast or scattered). IMO it's much cleaner just to go with the MPI
> paradigm, according to which objects that are to be shared have to be
> declared at all ranks.
>
Maybe I have a misunderstanding here -- how many data copies are there if you
do:
matrix b
if $mpirank == 0
matrix b = {1}
endif
So a bunch of "b" exist in all ranks.
I would say, a matrix named "b" exists at each rank. The b at rank 0
contains 1 while the b's at other ranks are empty.
If that's right, then what mpiscatter or mpibroadcast effectively
do is to
_create_ (conceptually) an array of matrices with the same name. ("Array"
again in a conceptual sense, don't known what's the internal structure.)
I would say, the scatter or broadcast transmits the content of a
matrix at the root node, such that the like-named matrices at all
nodes acquire the same content (broadcast) or a portion thereof
(scatter).
There would be no need to keep track of non-existing objects even
without
pre-declaration:
if $mpirank == 0
# creation in rank 0 only:
matrix b = {1}
endif
# creation for all ranks:
# (non-existing syntax to be more explicit,
# but the same goes for just mpibroadcast(&b))
matrix b = mpibroadcast(&b)
The problem is that, in either form, this contravenes existing hansl
semantics. Conceptually, "&b" means the address of b, and if b
doesn't already exist it doesn't have an address. All our functions
that take a matrix pointer argument require that the "pointed to"
matrix has already been declared.
In the last line the gretl interpreter would just have to know
that the "b" to be broadcast lives in rank 0. I don't see why it
would have to know about non-existing b's in other ranks.
You have n copies of the gretl interpreter running. The n - 1 copies
that are not at rank 0 would have to parse the hansl code "hidden
behind" the condition $mpirank == 0 and record the names and types
of all variables declared therein, so that if any of these names
later appeared in broadcast or scatter calls they would be
recognized.
If we allow (as we presently do) that the root node doesn't have to
be rank 0 (or not all the time), then each rank would have to peek
at the code specific to all other ranks in case anything that's not
globally declared features in a broadcast or scatter.
This is all just about idiomatic syntax I think: C and (I guess)
Mpi do pre-declaration all the time. Hansl doesn't. I'm not saying
one is always better than the other, but I would like Hansl to
stay Hansl as much as possible.
I take your point and thank you for getting a discussion going on
this. My feeling is that there's a definite programming paradigm
associated with MPI -- which seems strange and confusing at first
but has a clear logic that becomes apparent after you've worked with
it for a little -- and that gretl users who want to use MPI are best
advised to master this logic. So I'm skeptical about trying to
"sweeten the pill".
Allin