Eliminate race in thrust::system::cuda::detail::merge_n

Fixes #329