fjarri/reikna

gpuarray.copy() returns array of all zeros

mountaindust opened this issue · 1 comments

The following results in unexpected behavior:

import numpy as np
import reikna.cluda as cluda  
api = cluda.cuda_api()  
thr = api.Thread.create()  
A = np.random.rand(10,10)  
A_gpu = thr.to_device(A.astype('float32'))  
B_gpu = A_gpu.copy()

We would expect B_gpu to be a copy of A_gpu, but in fact it is a float32 array of all zeros!
This is not a PyCUDA issue either... the following works as expected:

import numpy as np
import pycuda.driver as cuda
import pycuda.autoinit
import pycuda.gpuarray as gpuarray
A = np.random.rand(10,10)
A_gpu = gpuarray.to_gpu(A.astype('float32'))
B_gpu = A_gpu.copy()

That's pretty embarrassing, to be honest, I tested the thread.copy_array(), but the test for copy() only checked the returned type, not the array contents.