def test_gpu_array_interleaved(self): @cuda.jit('void(double[:], double[:])') def copykernel(x, y): i = cuda.grid(1) if i < x.shape[0]: x[i] = i y[i] = i x = np.arange(10, dtype=np.double) y = x[:-1:2] # z = x[1::2] # n = y.size try: cuda.devicearray.auto_device(y) except ValueError: pass else: raise AssertionError("Should raise exception complaining the " "contiguous-ness of the array.") # Should we handle this use case? # assert z.size == y.size # copykernel[1, n](y, x) # print(y, z) # assert np.all(y == z) # assert np.all(y == list(range(n))) if __name__ == '__main__': unittest.main()
return_value=None) as mock_sync: f[1, 1](f_arr1, f_arr2) # Ensure that synchronize was called twice mock_sync.assert_has_calls([call(), call()]) def test_launch_sync_disabled(self): # Create two foreign arrays with streams s1 = cuda.stream() s2 = cuda.stream() f_arr1 = ForeignArray(cuda.device_array(10, stream=s1)) f_arr2 = ForeignArray(cuda.device_array(10, stream=s2)) with override_config('CUDA_ARRAY_INTERFACE_SYNC', False): @cuda.jit def f(x, y): pass with patch.object(cuda.cudadrv.driver.Stream, 'synchronize', return_value=None) as mock_sync: f[1, 1](f_arr1, f_arr2) # Ensure that synchronize was not called mock_sync.assert_not_called() if __name__ == "__main__": unittest.main()