Hi Dmitriy, On 07/12/2016 07:17 AM, Dmitriy Lyubimov wrote: > Hi, > > I am trying to create some elementary wrappers for VCL in javacpp. > > Everything goes fine, except i really would rather not use those "cpu" > types (std::map, > std::vector) and rather initialize matrices directly by feeding > row-major or CCS formats. > > I see that matrix () constructor accepts this form of initialization; > but it really states that > it does "wrapping" for the device memory.
Yes, the constructors either create their own memory buffer (zero-initialized) or wrap an existing buffer. These are the only reasonable options. > Now, i can create a host matrix() using host memory and row-major > packing. This works ok it seems. > > However, these are still host instances. Can i copy host instances to > instances on opencl context? Did you look at viennacl::copy() or viennacl::fast_copy()? > That might be one way bypassing unnecessary (in my case) complexities of > working with std::vector and std::map classes from java side. > > But it looks like there's no copy() variation that would accept a > matrix-on-host and matrix-on-opencl arguments (or rather, it of course > declares those to be ambiguous since two methods fit). If you want to copy your OpenCL data into a viennacl::matrix, you may wrap the memory handle (obtained with .elements()) into a vector and copy that. If you have plain host data, use viennacl::fast_copy() and mind the data layout (padding of rows/columns!) > For compressed_matrix, there seems to be a set() method, but i guess > this also requires CCS arrays in the device memory if I use it. Same > question, is there a way to send-and-wrap CCS arrays to an opencl device > instance of compressed matrix without using std::map? Currently you have to use .set() if you want to bypass viennacl::copy() and std::map. I acknowledge that the C++ type system is a pain when interfacing from other languages. We will make this much more convenient in ViennaCL 2.0. The existing interface in ViennaCL 1.x is too hard to fix without breaking lots of user code, so we won't invest time in that (contributions welcome, though :-) ) Best regards, Karli ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev _______________________________________________ ViennaCL-devel mailing list ViennaCL-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viennacl-devel