On Fri, Nov 9, 2012 at 11:41 AM, mohsen jadidi <[email protected]> wrote:
> Hello,
> I am not sure if this problem related to pycuda gpuarray or sickits.cuda
> library so I just posted in both mailing list maybe I can find a solution
> about it.
>
> my problem is that when I am trying to find a matrix transpose of matrix
> which has mad up by concatenation by 2 matrices I'm getting wrong result. To
> be more precises :
>
> a1=np.array([[1,3,4,5],[7,4,8,2],[7,5,0,9]],np.float64)
>
> temp=np.array([[3,4,5],[4,8,2],[5,0,9]],np.float64)
>
> a2=r2=np.c_[np.array([1,7,7],np.float64),temp]
>
> a1_gpu=gpuarray.to_gpu(a1)
> a2_gpu=gpuarray.to_gpu(a2)
>
>
> so far everything works fine and I have same value for all matrices.
> a1=a1=a1_gpu=a2_gpu :
>
> [ 1.,  3.,  4.,  5.]
> [ 7.,  4.,  8.,  2.]
> [ 7.,  5.,  0.,  9.]
>
> but now
>
> import scikits.cuda.linalg as la
>
> np.all(la.transpose(a1_gpu).get())==a1.T)
>
> returns True but but False for
>
> np.all(la.transpose(a2_gpu).get())==a2.T)
>
> my la.transpose(a2_gpu) :
>
> [ 1.,  4.,  0.]
> [ 7.,  5.,  5.]
> [ 7.,  4.,  2.]
> [ 3.,  8.,  9.]
>
> by looking at a1 and la.transpose(a2_gpu) it looks like the problem is
> somehow related to memory storage! I am right?

Thanks for including a minimal example (NB., it had a syntax error in
the np.all() calls :). The problem seems to go away if you do the
following:

a2 = r2 =  np.array(np.c_[np.array([1,7,7],np.float64),temp], order='C')

For some reason, the array concatenation munges the C versus Fortran
ordering, and the call to np.array() with the order='C' keyword tells
Numpy to be explicit about C ordering. It's ugly but it works... if
anybody can explain why Numpy seems to have such crevices of unreason,
we'd be obliged. Hope this helps though,
Ahmed

_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda

Reply via email to