On Mon, Feb 16, 2015 at 2:43 PM, Sven Schreiber <svetosch(a)gmx.net> wrote:
Am 16.02.2015 um 19:21 schrieb Allin Cottrell:
> On Mon, 16 Feb 2015, Sven Schreiber wrote:
>
>>
>> But since we're on the gretl list my comment was aimed at the hansl
>> wrapper implementation: Why can't hansl see the &b in mpiscatter(&b,
>> byrows) and shout out: "Hey I've seen this b before, it was created in
>> line xyz, and now everybody's getting it, too." I mean this look-up of
>> existing objects is what the interpreter does all the time, no?
>
> Not really. If you do the following, which seems analogous to me,
>
> <hansl>
> if 0
> matrix b = I(3)
> endif
> print b
> </hansl>
>
> you'll get an error since b was never actually defined. And
>
> if $mpirank == 0
>
> is just like "if 0" from the point of view of all MPI processes other
> than root.
>
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.
Allin