To permit a straightforward wrapper implementation it seems to be
necessary to impose some non-interference rules for concurrent read
and write operations on arrays. When an array is passed to an
MPI member such as a send or receive operation, the wrapper code will
extract a pointer to the contents of the array using a JNI
Get<PrimitiveType>ArrayElements routine. If the garbage collector
does not support ``pinning'' (temporarily disabling run-time relocation of data
for specific arrays), the pointer returned by this Get function
may be to a temporary copy of the elements. The copy will be written
back to the true Java array when a subsequent call to
Release<PrimitiveType>ArrayElements is made.
If two operations involving the same array are active concurrently, this
copy back may result in failure to save modifications made by one or more
of the concurrent calls.
For safety, the rule suggested is that when several MPI send or receive
(etc) operations are active concurrently, if any one of those
operations writes to a particular array, none of the other operations
must read or write any portion of that array.
Operations may occur concurrently through explicit use of threads, or through use of non-blocking communication operations. So far as
use of non-blocking communication operations is concerned, the
restriction could be relaxed at the price of having the wrapper always
explicitly copy buffers using MPI_PACK and MPI_UNPACK. Of course
this is an undesirable overhead. A final decision on whether
this overhead is acceptable will be defered until the implementation
is more complete.