Transfer of arrays with different strides
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 298
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
Hi,
First, thanks for writing this library! It's a very convenient way to do GPU programming.
I found the following unexpected behaviour when debugging one of my programs that uses numpy arrays in different orders:
```python
import pycuda.autoinit
from pycuda.gpuarray import to_gpu
import numpy as np
# Creating a GPU array in fortran layou
cpu_arr_f = np.zeros([3,4], order='F')
gpu_arr = to_gpu(cpu_arr_f)
# Copying an array in C layout to and from GPU changes it
# pycuda apparently assumes that CPU array has same strides as GPU array without checking it
cpu_arr_c = np.zeros([3,4], order='C')
cpu_arr_c[0,:] = 1
gpu_arr.set(cpu_arr_c)
assert(np.allclose(gpu_arr.get(), cpu_arr_c))
```
The last `assert` fails since pycuda apparently assumes that the strides of the source and destination arrays match. Is this the intended behaviour? If yes, I think a warning or a documentation note might be helpful in this case.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.