After changing device, the assignment with index generates an exception (Invalid Memory Object when calling clSetkernelArg)
const int idx[]{1, 3};
af::setDevice(0);
af::array d0_idx(2, idx, afHost);
af::array d0_in(10, 10);
d0_in(d0_idx) = 1.0; // success
af::setDevice(1);
af::array d1_idx(2, idx, afHost);
af::array d1_in(10, 10);
d1_in(d1_idx) = 2.0; // <- exception
Output:
ArrayFire v3.9.0 (OpenCL, 64-bit Windows, build b184388 )
[0] AMD: Spectre, 6571 MB -- OpenCL 2.0 AMD-APP (3224.5) -- Device driver 3224.5 -- FP64 Support: True
-1- NVIDIA: NVIDIA GeForce GTX 750 Ti, 2047 MB -- OpenCL 3.0 CUDA -- Device driver 531.61 -- FP64 Support: True
OpenCL Error (-38): Invalid Memory Object when calling clSetKernelArg
Cause:
For Assignments on arrays with indexes, empty indexes are internally generated.
For each empty index, an empty device buffer is used as parameter to the assign kernel.
Since the empty device buffer remains unchanged, the resulting buffer of the 1st time is cached.
The cached device buffer is however dependent on the context, explaining why it failed after setdevice(1) (=changed context).
1 bug less.