Am 16.02.2015 um 18:42 schrieb Allin Cottrell:
On Mon, 16 Feb 2015, Sven Schreiber wrote:
> Am 16.02.2015 um 17:58 schrieb Allin Cottrell:
>> The trouble here is that the matrices a and b exist only in the rank 0
>> process; they need to exist everywhere.
>>
>> <hansl>
>> mpi --np=2
>> matrix a
>> matrix b
>> if $mpirank == 0
>> b = ones(1000,1)
>> a = zeros(1000,1)
>> endif
>> mpiscatter(&b, byrows)
>> </hansl>
>>
>
> Hm, ok I understand. My spontaneous reaction would be: "but isn't this
> what mpiscatter (or mpibroadcast) is supposed to achieve as part of
> their job?".
> What's the value added of requiring the pre-existence of the recipient
> objects?
It's not a question of value added, it's just how MPI works! Remember
that each "rank" corresponds to a distinct instance of gretlmpi.
Consider your original code, without the prior declaration of the
matrices, from the point of view of the rank 1 process: the first line
rank 1 sees is:
mpiscatter(&b, byrows)
So it's like, "mpiscatter what?? I don't know anything about this b".
Yeah, I actually understood that :-)
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?
Then you could tell me "but what if there are several b's out there in
different processes, which one should I use for scattering?" And I would
say "isn't this the same problem in the current status quo?".
Look, all this is probably much easier to criticize than to implement, I
know that. But from a user's point of view it's a hansl dialect in that
mpi block, and it should feel as hanslish as possible IMO.
thanks,
sven