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. And the value of "b" in rank 0
should be one. But what's the value of all those "b"s in the other
ranks, before you do a broadcast or scatter? I would guess they're still
empty because otherwise there wouldn't be a point to do the assignment
only in rank 0. Right?
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.) 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)
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.
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.
thanks,
sven