The behavior observed in OP is correct.
array_view<int> av(big)
creates an array_view without data source, while av.synchronize_async()
synchronizes modifications to the data source. Therefore for array_view without data source it is by definition no-op. By extension it is also not forcing the execution of the preceding parallel_for_each
.
If the intention is to synchronize the data to the CPU memory, in this case it needs to be requested explicitly with av.synchronize_to_async(accelerator(accelerator::cpu_accelerator).default_view)
. Of course the returned completion_future
becomes ready only when the preceding parallel_for_each
and (optional) copy operation finish.
Replacing the former synchronization call with the latter makes the assertion successful, keeping in mind it may still fail (by design) on systems with CPU shared memory, or in some rare timings.