Hi Karli,
I've mocked up in C++ the method that I'm trying to use from java. Aside from
adding some values, it looks very similar to the code that you have below.
I'm getting the same compiler error hat I was getting through javacpp/JNI:
sparseDenseMmul.cpp:85:103: required from here
/usr/include/viennacl/matrix.hpp:2247:36: error: no matching function for
call to
‘prod_impl(const viennacl::compressed_matrix<double>&, const
viennacl::matrix_base<double, long unsigned int, long int>&,
viennacl::matrix_base<double, long unsigned int, long int>&)’
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:438:10: note: candidate:
template<class NumericT> void viennacl::linalg::prod_impl(const
viennacl::matrix_base<T>&, const viennacl::vector_base<T>&,
viennacl::vector_base<T>&)
void prod_impl(const matrix_base<NumericT> & mat,
The code is below, and I've attached both the "sparseDenseMmul.cpp" file and
the full compilation error output (very long, probably not useful)
Thanks very much,
Andy
Attached as "sparseDenseMmul.cpp":
#include <iostream>
// not using openMP for this mockup
// #define VIENNACL_WITH_OPENMP 1
// ViennaCL includes
#include "viennacl/forwards.h"
#include "viennacl/compressed_matrix.hpp"
#include "viennacl/linalg/prod.hpp"
#include "viennacl/backend/memory.hpp"
#include "viennacl/matrix.hpp"
#include "viennacl/detail/matrix_def.hpp"
#include "viennacl/tools/random.hpp"
#include "viennacl/context.hpp"
#include "viennacl/linalg/host_based/sparse_matrix_operations.hpp"
// C_dense_matrix = A_compressed_matrix %*% B_dense_matrix.
// compile line w/o OpenMP: g++ sparseDenseMmul.cpp -I/usr/include/viennacl/
-o sparseDenseMmul
int main()
{
// trying to recreate javacpp wrapper functionalliy as closely as possible
// so not using typedef, unsigned ints, etc, and defining templates as doubles
// creating buffers as int/double arrays and then setting pointers to them.
// (not 100% sure that this is how javacpp passes pointers but should be
close.)
//typedef double ScalarType;
// in acuallity, we cast `int`s from jni/javacpp.
unsigned int m = 10;
unsigned int n = 10;
unsigned long s = 5;
unsigned int NNz_A = 12;
// allocate buffers and set pointers (similarly to javacpp)
// using ints (not unsigned ints) here from jni/javacpp.
int A_row_jumpers[m + 1] = {0, 0, 1, 2, 4, 5, 6, 7, 9, 11, 12};
int *A_row_ptr = A_row_jumpers;
// using ints (not unsigned ints) here from jni/javacpp.
int A_col_idxs[NNz_A] = {4, 0, 2, 3, 2, 4, 0, 4, 3, 0, 3, 0};
int *A_col_ptr = A_col_idxs;
double A_values[NNz_A] = {0.4065367203992265, 0.04957158909682802,
0.3708618354358446,
0.5205586068847993, 0.6963900565931678, 0.8330915529787706,
0.32839112750638844,
0.4265801782090245, 0.7856168903297948, 0.14733066454561583,
0.9501663495824946,
0.9710498974366047};
double* A_values_ptr = A_values;
// using double values in Mahout setting template directlyfor our
compressed_matrix, A
viennacl::compressed_matrix<double> A_compressed_matrix(m, s);
// set the ptrs for A
A_compressed_matrix.set(A_row_ptr, A_col_ptr, A_values_ptr, m, s, NNz_A);
// B is dense s so we only need s x n values.
double B_values[s * n] = {0};
// add some random data to B:
viennacl::tools::uniform_random_numbers<double> randomNumber;
for (int i = 0; i< s * n; i++) {
B_values[i] = randomNumber();
}
double* B_values_ptr = B_values;
// for our row_major dense_matrix, B can set the double values in the
construcor
// this is currently the constructor that we're using through scala/javacpp.
const viennacl::matrix<double,viennacl::row_major>
B_dense_matrix(B_values_ptr, viennacl::MAIN_MEMORY, s,
n);
// perform multiplication and inside of a compressed_matrix constructor
viennacl::matrix<double>
C_dense_matrix(viennacl::linalg::prod(A_compressed_matrix , B_dense_matrix));
// print out matrix
std::cout << "ViennaCL: " << C_dense_matrix << std::endl;
// just exit with success for now if there are no runtime errors.
return EXIT_SUCCESS;
}
________________________________
From: Karl Rupp <[email protected]>
Sent: Sunday, August 7, 2016 2:20:26 PM
To: Andrew Palumbo; [email protected]
Subject: Re: [ViennaCL-devel] compressed_matrix %*% matrix_Base
Hi Andy,
the relevant tests for sparse matrices times dense matrices are in
tests/spmdm.cpp. In particular, I recreated a test case based on your
description and couldn't find any issues:
viennacl::compressed_matrix<NumericT> compressed_A;
viennacl::matrix<NumericT, FactorLayoutT> B1(std_A.size(), cols_rhs);
viennacl::matrix_base<NumericT> B1_ref(B1);
viennacl::matrix_base<NumericT>
C2(viennacl::linalg::prod(compressed_A, B1_ref));
compiles cleanly. Could you please provide a code snippet demonstrating
the problem you are encountering?
Thanks and best regards,
Karli
On 08/05/2016 09:04 PM, Andrew Palumbo wrote:
> Hi Karl,
>
>
> I've been trying to implement tests for:
>
>
> matrix_base<double> C = compressed_matrix<double> A %*%
>
> matrix_base<double,row_major> B.
>
>
> I cant find in the code or the documentation any constructor for
> matrix_base<T>(
>
> matrix_expression<const viennacl::compressed_matrix<T>, const
> viennacl::matrix_base<T>, viennacl::op_prod>)
>
> ie. a mixed expression of compressed_matrix and matrix_base
>
> and get a compilation error when I try to instantiate a:
>
> matrix_base<double>(matrix_expression<const
> viennacl::compressed_matrix<double>, const
> viennacl::matrix_base<double>,
> viennacl::op_prod>)
>
> Is there a transformation that I need to do from this
>
> matrix_expression<compressed_matrix<double>, matrix_base<double>,
> op_prod>
>
> to something else so that I may be able to initialize a matrix_base (or
> possibly even a compressed_matrix) from it?
>
> The compilation error that i get is below.
>
> Thanks,
>
> Andy
>
#include <iostream>
// not using openMP for this mockup
// #define VIENNACL_WITH_OPENMP 1
// ViennaCL includes
#include "viennacl/forwards.h"
#include "viennacl/compressed_matrix.hpp"
#include "viennacl/linalg/prod.hpp"
#include "viennacl/backend/memory.hpp"
#include "viennacl/matrix.hpp"
#include "viennacl/detail/matrix_def.hpp"
#include "viennacl/tools/random.hpp"
#include "viennacl/context.hpp"
#include "viennacl/linalg/host_based/sparse_matrix_operations.hpp"
// C_dense_matrix = A_compressed_matrix %*% B_dense_matrix.
// compile line w/o OpenMP: g++ sparseDenseMmul.cpp -I/usr/include/viennacl/ -o sparseDenseMmul
int main()
{
// trying to reCuce javacpp wrapper functionalliy as closely as possible
// so not using typedef, unsigned ints, etc, and defining templates as doubles
// creating buffers as int/double arrays and then setting pointers to them.
// (not 100% sure that this is how javacpp passes pointers but should be close.)
//typedef double ScalarType;
// using unsigned ints here to suppress warnings/errors w/o using -fpermissive`
// in acuallity, we cast `int`s from jni/javacpp.
unsigned int m = 10;
unsigned int n = 10;
unsigned long s = 5;
unsigned int NNz_A = 12;
// allocate buffers and set pointers (similarly to javacpp)
// using ints (not unsigned ints) here from jni/javacpp.
int A_row_jumpers[m + 1] = {0, 0, 1, 2, 4, 5, 6, 7, 9, 11, 12};
int *A_row_ptr = A_row_jumpers;
// using ints (not unsigned ints) here from jni/javacpp.
int A_col_idxs[NNz_A] = {4, 0, 2, 3, 2, 4, 0, 4, 3, 0, 3, 0};
int *A_col_ptr = A_col_idxs;
double A_values[NNz_A] = {0.4065367203992265, 0.04957158909682802, 0.3708618354358446,
0.5205586068847993, 0.6963900565931678, 0.8330915529787706, 0.32839112750638844,
0.4265801782090245, 0.7856168903297948, 0.14733066454561583, 0.9501663495824946,
0.9710498974366047};
double* A_values_ptr = A_values;
// using double values in Mahout setting template directlyfor our compressed_matrix, A
viennacl::compressed_matrix<double> A_compressed_matrix(m, s);
// set the ptrs for A
A_compressed_matrix.set(A_row_ptr, A_col_ptr, A_values_ptr, m, s, NNz_A);
// B is dense s so we only need s x n values.
double B_values[s * n] = {0};
// add some random data to B:
viennacl::tools::uniform_random_numbers<double> randomNumber;
for (int i = 0; i< s * n; i++) {
B_values[i] = randomNumber();
}
double* B_values_ptr = B_values;
// for our row_major dense_matrix, B can set the double values in the construcor
// this is currently the constructor that we're using through scala/javacpp.
const viennacl::matrix<double,viennacl::row_major>
B_dense_matrix(B_values_ptr, viennacl::MAIN_MEMORY, s, n);
// perform multiplication and inside of a compressed_matrix constructor
viennacl::matrix<double> C_dense_matrix(viennacl::linalg::prod(A_compressed_matrix , B_dense_matrix));
// print out matrix
std::cout << "ViennaCL: " << C_dense_matrix << std::endl;
// just exit with success for now if there are no runtime errors.
return EXIT_SUCCESS;
}
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp: In instantiation of âstatic void
viennacl::linalg::detail::op_executor<viennacl::matrix_base<T>,
viennacl::op_assign, viennacl::matrix_expression<const LHS, const RHS,
viennacl::op_prod> >::apply(viennacl::matrix_base<T>&, const
viennacl::matrix_expression<const SparseMatrixType, const
viennacl::matrix_base<T>, viennacl::op_prod>&) [with SparseMatrixType =
viennacl::compressed_matrix<double>; T = double; LHS =
viennacl::compressed_matrix<double>; RHS = viennacl::matrix_base<double, long
unsigned int, long int>]â:
/usr/include/viennacl/matrix.hpp:324:107: required from
âviennacl::matrix_base<NumericT, SizeT, DistanceT>&
viennacl::matrix_base<SCALARTYPE, SizeType, DistanceType>::operator=(const
viennacl::matrix_expression<const LHS, const RHS, OP>&) [with LHS =
viennacl::compressed_matrix<double>; RHS = viennacl::matrix_base<double, long
unsigned int, long int>; OP = viennacl::op_prod; NumericT = double; SizeT =
long unsigned int; DistanceT = long int]â
/usr/include/viennacl/matrix.hpp:155:25: required from
âviennacl::matrix_base<SCALARTYPE, SizeType, DistanceType>::matrix_base(const
viennacl::matrix_expression<const LHS, const RHS, OP>&) [with LHS =
viennacl::compressed_matrix<double>; RHS = viennacl::matrix_base<double, long
unsigned int, long int>; OP = viennacl::op_prod; NumericT = double; SizeT =
long unsigned int; DistanceT = long int]â
/usr/include/viennacl/matrix.hpp:750:75: required from
âviennacl::matrix<SCALARTYPE, F, ALIGNMENT>::matrix(const
viennacl::matrix_expression<LHS, RHS, OP>&) [with LHS = const
viennacl::compressed_matrix<double>; RHS = const viennacl::matrix_base<double,
long unsigned int, long int>; OP = viennacl::op_prod; NumericT = double; F =
viennacl::row_major; unsigned int AlignmentV = 1u]â
sparseDenseMmul.cpp:83:103: required from here
/usr/include/viennacl/matrix.hpp:2247:36: error: no matching function for call
to âprod_impl(const viennacl::compressed_matrix<double>&, const
viennacl::matrix_base<double, long unsigned int, long int>&,
viennacl::matrix_base<double, long unsigned int, long int>&)â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:438:10: note: candidate:
template<class NumericT> void viennacl::linalg::prod_impl(const
viennacl::matrix_base<T>&, const viennacl::vector_base<T>&,
viennacl::vector_base<T>&)
void prod_impl(const matrix_base<NumericT> & mat,
^
/usr/include/viennacl/linalg/matrix_operations.hpp:438:10: note: template
argument deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::compressed_matrix<double>â is not derived from âconst
viennacl::matrix_base<T>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:479:10: note: candidate:
template<class NumericT> void viennacl::linalg::prod_impl(const
viennacl::matrix_expression<const viennacl::matrix_base<T>, const
viennacl::matrix_base<T>, viennacl::op_trans>&, const
viennacl::vector_base<T>&, viennacl::vector_base<T>&)
void prod_impl(const matrix_expression< const matrix_base<NumericT>, const
matrix_base<NumericT>, op_trans> & mat_trans,
^
/usr/include/viennacl/linalg/matrix_operations.hpp:479:10: note: template
argument deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::compressed_matrix<double>â is not derived from âconst
viennacl::matrix_expression<const viennacl::matrix_base<T>, const
viennacl::matrix_base<T>, viennacl::op_trans>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from sparseDenseMmul.cpp:6:0:
/usr/include/viennacl/forwards.h:820:5: note: candidate: template<class
SparseMatrixType, class SCALARTYPE, unsigned int ALIGNMENT> typename
viennacl::enable_if<viennacl::is_any_sparse_matrix<T>::value,
viennacl::vector_expression<const SparseMatrixType, const
viennacl::vector<SCALARTYPE, ALIGNMENT>, viennacl::op_prod> >::type
viennacl::linalg::prod_impl(const SparseMatrixType&, const
viennacl::vector<SCALARTYPE, ALIGNMENT>&)
prod_impl(const SparseMatrixType & mat,
^
/usr/include/viennacl/forwards.h:820:5: note: template argument
deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::matrix_base<double, long unsigned int, long int>â is not derived
from âconst viennacl::vector<SCALARTYPE, ALIGNMENT>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:519:10: note: candidate:
template<class NumericT, class ScalarType> void
viennacl::linalg::prod_impl(const viennacl::matrix_base<T>&, const
viennacl::matrix_base<T>&, viennacl::matrix_base<T>&, ScalarType, ScalarType)
void prod_impl(const matrix_base<NumericT> & A,
^
/usr/include/viennacl/linalg/matrix_operations.hpp:519:10: note: template
argument deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::compressed_matrix<double>â is not derived from âconst
viennacl::matrix_base<T>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:560:10: note: candidate:
template<class NumericT, class ScalarType> void
viennacl::linalg::prod_impl(const viennacl::matrix_expression<const
viennacl::matrix_base<T>, const viennacl::matrix_base<T>, viennacl::op_trans>&,
const viennacl::matrix_base<T>&, viennacl::matrix_base<T>&, ScalarType,
ScalarType)
void prod_impl(const viennacl::matrix_expression< const
matrix_base<NumericT>,
^
/usr/include/viennacl/linalg/matrix_operations.hpp:560:10: note: template
argument deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::compressed_matrix<double>â is not derived from âconst
viennacl::matrix_expression<const viennacl::matrix_base<T>, const
viennacl::matrix_base<T>, viennacl::op_trans>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:603:10: note: candidate:
template<class NumericT, class ScalarType> void
viennacl::linalg::prod_impl(const viennacl::matrix_base<T>&, const
viennacl::matrix_expression<const viennacl::matrix_base<T>, const
viennacl::matrix_base<T>, viennacl::op_trans>&, viennacl::matrix_base<T>&,
ScalarType, ScalarType)
void prod_impl(const matrix_base<NumericT> & A,
^
/usr/include/viennacl/linalg/matrix_operations.hpp:603:10: note: template
argument deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::compressed_matrix<double>â is not derived from âconst
viennacl::matrix_base<T>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
In file included from /usr/include/viennacl/matrix.hpp:28:0,
from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/linalg/matrix_operations.hpp:643:10: note: candidate:
template<class NumericT, class ScalarType> void
viennacl::linalg::prod_impl(const viennacl::matrix_expression<const
viennacl::matrix_base<T>, const viennacl::matrix_base<T>, viennacl::op_trans>&,
const viennacl::matrix_expression<const viennacl::matrix_base<T>, const
viennacl::matrix_base<T>, viennacl::op_trans>&, viennacl::matrix_base<T>&,
ScalarType, ScalarType)
void prod_impl(const viennacl::matrix_expression< const
matrix_base<NumericT>, const matrix_base<NumericT>, op_trans> & A,
^
/usr/include/viennacl/linalg/matrix_operations.hpp:643:10: note: template
argument deduction/substitution failed:
In file included from
/usr/include/viennacl/linalg/sparse_matrix_operations.hpp:28:0,
from /usr/include/viennacl/compressed_matrix.hpp:31,
from sparseDenseMmul.cpp:7:
/usr/include/viennacl/matrix.hpp:2247:36: note: âconst
viennacl::compressed_matrix<double>â is not derived from âconst
viennacl::matrix_expression<const viennacl::matrix_base<T>, const
viennacl::matrix_base<T>, viennacl::op_trans>â
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), lhs);
^
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/viennacl-devel