Closed dionhaefner closed 5 years ago
It is because you need to save a reference to the returned Bohrium array of a.sum()
.
Currently, at line np.interop_numpy.get_array(a.sum())
the Bohrium arrays get out of scope and its data freed by Bohrium.
Since global_sum
is empty, it is first allocated when you ask for its data at np.interop_numpy.get_array(global_sum)
.
The memory allocation cache will then give it the newly freed data segment.
I'm thinking of a solution where we attach a reference to the Bohrium array on to the NumPy array returned by np.interop_numpy.get_array()
I see. So this is only an issue if the bh array goes out of scope during the call to get_array
, which is probably fine (but should be documented).
When passing Bohrium arrays to be communicated via MPI, I get a pointer to the data through
bh.interop_numpy.get_array
. While debugging something else I found this strange behavior:Script:
Output:
Notice how the send and receive buffers point to the same memory location?
If I change
I get the expected result: