On Mon, 16 Feb 2015, Sven Schreiber wrote:
Am 16.02.2015 um 17:58 schrieb Allin Cottrell:
> On Mon, 16 Feb 2015, Sven Schreiber wrote:
>
>> Advancing line-by-line here... Next error below the sample script:
>>
>> <hansl>
>> mpi --np=2
>> if $mpirank == 0 # parent process
>> matrix b = ones(1000,1)
>> matrix a = zeros(1000,1)
>> endif
>> # -- up to here no errors --
>>
>> # divide up the input data
>> mpiscatter(&b, byrows)
>
> 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".
Allin