OK, I should probably explain what gave rise to the problem noted
by Ignacio in
http://lists.wfu.edu/pipermail/gretl-devel/2017-December/008324.html
It's to do with sending information between gretl and gretlmpi in
connection with an "mpi block" in a hansl script. Say you want to
send a matrix from gretl to gretlmpi, and get a processed matrix
back again. You can of course use mwrite() and mread(), which work
via writing and reading of files. But now, experimentally, you can
use these two functions in a special mode: if you give the matrix
filenames the suffix ".shm" we'll transfer the data via shared
memory rather than regular files. Here's a trivial example:
<hansl>
set verbose off
matrix m = mnormal(500,500)
mwrite(m, "gmat.shm")
mpi
matrix m
if $mpirank == 0
m = mread("gmat.shm")
printf "mpi(root)\n"
m *= 2
mwrite(m, "gmat2.shm")
endif
end mpi --np=4
m2 = mread("gmat2.shm")
printf "Should be zero: %g\n", maxc(maxr(abs(m2 - 2*m)))
</hansl>
Using ".shm" the behavior is a bit different from usual: the shared
memory block is freed on the first read (to avoid leaking memory).
Also you shouldn't give a full path for the "file", it's
automatically created under /dev/shm on Linux (or in "dotdir" on
Windows, which doesn't support POSIX shared memory).
Although this is quite cool, I'm not sure it's really worthwhile. In
my testing I'm seeing only a small speed advantage over writing the
matrix as a regular binary file, as in
mwrite(m, "gmat.bin")
But if anyone would like to test, please go ahead and tell me what
you see.
(The problem Ignacio found was due to the fact that some Linux
variants require explicit linkage to librt when using shared memory
functions while others such as Arch and Fedora do not. I was testing
on Arch and Fedora and so didn't see a problem.)
Allin