viennacl / viennacl-dev

Developer repository for ViennaCL. Visit http://viennacl.sourceforge.net/ for the latest releases.
Other
281 stars 89 forks source link

Double precision error with sparse matrix product #266

Open cdeterman opened 6 years ago

cdeterman commented 6 years ago

I have the following code,

viennacl::compressed_matrix<T> Am;
viennacl::compressed_matrix<T> Bm;

// the matrices are filled

viennacl::compressed_matrix<T> Cm = viennacl::linalg::prod(Am, Bm);

This compiles without an issue, however when I run it with double as opposed to float I get the error

ViennaCL: FATAL ERROR: You requested to create a ViennaCL type using double precision. However, double precision is not supported by your device.

This makes no sense as it is only thrown at the prod call. I am able to initialize the first two matrices without an issue. Why would this be happening?

Another point, I tried addition in viennacl::ocl::switch_context(1); to make sure the correct context was in use with the device that has double (in this case a simple Intel CPU). I'm currently at a loss as to why this isn't working.

karlrupp commented 6 years ago

OpenCL kernels are compiled when needed. Thus, it indeed takes all the way until prod() to compile compute kernels. All the data-setup can proceed without checking for double precision capabilities.

Regarding the error message itself: Is it incorrect (i.e. your device does support double precision)?

cdeterman commented 6 years ago

The device does, it just appears that the previously initialized contexts from a separate .so file, that I load, are not shared with my new code. Something I didn't realize in that it appears with C++ the variables between libraries can't be shared. I will need to re-evaluate how I am approaching my current problem. Thanks.

cdeterman commented 6 years ago

@karlrupp I don't suppose you have come across that situation (contexts between two .so files). I am trying to avoid rewriting all the same functions but I'm not sure if it will be feasible. Any thoughts would be appreciated.

karlrupp commented 6 years ago

It's possible that you are encountering the same issue as discussed here: https://sourceforge.net/p/viennacl/discussion/1143678/thread/81ef1cff/

(It's interesting to notice that this issue hasn't bubbled up for several years, and now it shows up twice within a few weeks)