On Tue, 17 Feb 2015, Sven Schreiber wrote:
 Am 17.02.2015 um 14:23 schrieb Allin Cottrell:
> On Tue, 17 Feb 2015, Sven Schreiber wrote:
> 
>> 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.
 This is something I wasn't yet fully aware of I guess... 
A little more info on MPI, in case it's helpful. MPI provides an 
infrastructure that lets you launch n copies of a program on 
different cores or different machines, and a mechanism whereby these 
processes can communicate with each other (broadcast, scatter and 
friends). MPI is not a programming language as such, but it provides 
APIs in both C and Fortran. Gretl's implementation rests on the C 
API.
 Ok, so if I understand correctly, without pre-declaration it's
not 
 possible for the rank-0-interpreter to tell the other interpreters 
 "watch out there's a 'b' coming your way" because there's 
 currently no mechanism that allows the rank-0-interpreter to 
 enclose the necessary information "hey guys, 'b' is a matrix (with 
 dimensions such-and-such)"? 
In principle, rank 0 can send any information you want to the other 
processes, but only via broadcast/scatter.
When you do mpibcast() on a matrix in gretl, libgretl first 
broadcasts the dimensions, "in the background", so that each process 
can allocate space for the content. If that goes OK then the actual 
content is broadcast and copied into the memory of each process.
We don't currently support broadcast of string variables but we 
could if that seemed useful. In that case rank 0 could send out the 
name of a matrix to be received. However, this would generate a 
regress, in that you'd then need a pre-existing string variable at 
each rank to receive the name (plus string substitution to make use 
of it), as in
string mname
if $mpirank == 0
   mname = "b"
   matrix b = {whatever}
endif
mpibcast(&mname)
if $mpirank > 0
   matrix @mname
endif
mpibcast(&@mname)
This would be more cumbersome that just declaring b in all 
processes.
Allin