Hi Pushkar,

you are right, the CUDA-related initializer is accidentally missing in 
the matrix<> class. I created an issue here:
  https://github.com/viennacl/viennacl-dev/issues/69
to ensure this gets fixed with the next release.

As a fully operational alternative, please use the constructor provided 
through matrix_base<> instead:
 
https://github.com/viennacl/viennacl-dev/blob/master/viennacl/matrix.hpp#L306
An example usage is in the libviennacl sources, where this is used to 
wrap the user-provided CUDA handle, e.g.
 
https://github.com/viennacl/viennacl-dev/blob/master/libviennacl/src/blas3_cuda.cu#L66

Basically you have to provide four arguments for each matrix dimension:
  - the number of logical elements ("size")
  - the row/column offset from the beginning of the buffer ("0" for a 
full matrix)
  - the increment ("1" for a full matrix)
  - the internal length of the buffer for the dimension (same as "size" 
if you don't pad your matrix to e.g. multiples of 128).

For the code snippet you presented below, just use
viennacl::matrix<ScalarType> vcl_A(cuda_x, viennacl::CUDA_MEMORY,
                                    3, 0, 1, 3
                                    3, 0, 1, 3);

Keep in mind, though, that you need much larger matrix sizes to get good 
performance on GPUs.

Best regards,
Karli



On 03/27/2014 08:39 AM, Pushkar Ratnalikar wrote:
> Hello All,
>
> I am getting started with ViennaCL. The PDF reference manual has an
> example in section 10.2, where, a dense-matrix is initialized with a
> data pointer. I was just trying it out with GPU memory. I get a
> compilation error. The following is the snippet.
>
>
> ScalarType* cuda_x;
> cudaMalloc(&cuda_x, 3*3*sizeof(ScalarType));
> viennacl::matrix<ScalarType> vcl_A(cuda_x, viennacl::CUDA_MEMORY, 3, 3);
>
>
> While there is a constructor for vector object in the vector.hpp file,
> there is none in the matrix.hpp file. Am I missing something?  Is there
> another class that I need to look at?
>
>
> Thanks for the help,
> Pushkar
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> ViennaCL-devel mailing list
> ViennaCL-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/viennacl-devel
>


------------------------------------------------------------------------------
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to