Closed dionhaefner closed 5 years ago
It is because a, b, c, and d
points to the same base array when using:
a, b, c, d = bh.random.rand(4, 360 * 180, 120)
You have to add either an offset in the kernel or use something like this instead:
a, b, c, d = (bh.random.rand(360 * 180, 120) for k in range(4))
Having said that, it might be a good idea to have an optional argument only_contiguous_operands=True
so that execute()
raise an error when it is set?
I should have been clearer, sorry. The surprising behavior here is that
a, b, c, d = (bh.array(k, order='C') for k in (a, b, c, d))
is not sufficient to ensure data integrity (contrary to what is shown in the examples). A fix would either be the flag you suggest, better documentation, or making Bohrium add the correct offset automatically when passing a contiguous view into a base array to bh.user_kernel.execute
.
My first though was also to let bh.user_kernel.execute()
correct the offset, but that will not work in OpenCL and CUDA easily.
I think I will update the doc and add the only_contiguous_operands
for now.
Thanks
Following the examples, my initial version of the TDMA extmethod as a user kernel was something like this:
(the important line being
a, b, c, d = (bh.array(k, order='C') for k in (a, b, c, d))
)This formulation returns an array full of
NaN
. Looking at the flags of e.g. the arraya
I gotNote how everything is as expected, except
OWNDATA: False
, because ofa, b, c, d = bh.random.rand(4, 360 * 180, 120)
. The problem was fixed by replacingI don't quite understand why it wouldn't work when passing a view of a contiguous array. So this is either a bug, or we should adapt the examples in the docs to include a similar check.