On Wed, 11 Jan 2017, Sven Schreiber wrote:
Am 11.01.2017 um 07:51 schrieb Sven Schreiber:
> Am 10.01.2017 um 21:27 schrieb Allin Cottrell:
>> I'm attaching a variant of your script which permits comparison with
>> MPI.
>
> Thanks, I will take a look.
Here's an update, now that bundles can be passed via MPI. See what
you think.
Reminder: this is (one version of) an apparatus which allows several
gretl processes to work on a common problem but with different
parameters, the parameters to be contained in bundles.
<hansl name="mpibuns.inp">
# Everybody needs to know about b
bundle b = null
if $mpirank == 0
# Rank 0 does the parameter setup, and sends
# param bundles out to the other workers
scalar N = $mpisize
bundles B = array(N)
loop i=1..N -q
b = null
b.int = i
b.mat = I(i+1)
B[i] = b
if i > 1
mpisend(b, i-1)
endif
endloop
b = B[1]
else
# The other workers collect their bundles
# from rank 0
b = mpirecv(0)
endif
# Common code block goes here: trivial in this case,
# but can be as complex as you like
b.mat = b.mat * b.int
b.str = "done!"
if $mpirank > 0
# Other workers send their results back
mpisend(b, 0)
else
# Rank 0 collects them...
B[1] = b
loop i=2..N -q
B[i] = mpirecv(i-1)
endloop
# and displays the results
loop i=1..N -q
printf "matrix %d\n%5g\n", i, B[i].mat
printf "string %d: %s\n\n", i, B[i].str
endloop
endif
</hansl>
Execute with
mpiexec -n <whatever> gretlmpi mpibuns.inp
Allin