opencl backend: separate copying of memory to device from buffer allocation
There does not appear to be any particular reason why this copying
was combined together with the buffer allocation in
2b8a598 (Add OpenCL
backend, Fri Jun 21 11:57:05 2013 +0200).
However, ever since
fd0e714 (opencl backend: avoid uninitialized
cl_mem objects, Wed May 7 12:56:20 2014 +0100), we allocate a buffer
that contains at least one element, even if the original host array
contains no elements. In principle, C99 does not allow arrays with
zero elements, but most compilers do and so do we. In this cases
we would therefore be copying data from memory beyond the host array.
This copying does not seem to have caused any problems in practice so far,
but we should still fix it.
An added advantage of separating the copying from the allocation
is that the cuda backend does the same, such that the difference
between the two backends is reduced by this commit.
Tested-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>