Hi Andy and Dmitriy,

apologies for the late reply and thanks for narrowing down the problem.
I could reproduce the problem on my machine and can confirm that the 
issue is due to the order of include files. Specifically, Andy's code 
compiles if
  #include "viennacl/compressed_matrix.hpp"
is included *after*
  #include "viennacl/matrix.hpp"

I still need to figure out how to fix this (the order of includes should 
never matter!) and will let you know as soon as a fix is pushed to the 
repository.

>
> Karl, what is recommended set of hpp files to be included?

This question has - unfortunately - not a simple answer. I recommend to 
start with the includes in the respective examples and go from there. 
More specifically, consider the following basic set of includes:

Types:
  viennacl/range.hpp - index ranges
  viennacl/slice.hpp - index slices
  viennacl/vector.hpp - vectors
  viennacl/vector_proxy.hpp - subvector support
  viennacl/matrix.hpp - dense matrices
  viennacl/matrix_proxy.hpp - submatrices of dense matrices
  viennacl/compressed_matrix.hpp - CSR sparse matrices (CSR recommended)

Operations:
  viennacl/linalg/prod.hpp - Matrix-vector and matrix-matrix products
  viennacl/linalg/inner_prod.hpp - Inner products (vectors)
  viennacl/linalg/norm_X.hpp - vector and matrix norms (X in "1", "2", 
"inf", or "frobenius")

Algorithms (solvers, factorizations, etc.)
  Pick the correspondingly named header file in viennacl/linalg

These headers should almost always suffice.


> and more specifically, what is already included transitively, so we
> don't include it again? Is there any general rule/convention about it?

Ideally, all you should ever have to worry about is a single header 
file, e.g. something like
  #include "viennacl/viennacl.hpp"

We could (and probably should?) add such a convenience header file at 
the expense of increased compilation times (and reduced encapsulation of 
source code against compiler issues). Ultimately, this all boils down to 
fighting limitations of the current header-only source code distribution 
model.

Best regards,
Karli



>
>
> On Tue, Aug 16, 2016 at 11:16 AM, Dmitriy Lyubimov <dlie...@gmail.com
> <mailto:dlie...@gmail.com>> wrote:
>
>     Karl,
>
>     i can independently confirm the problem with prod_impl instantiation
>     over expression of compressed times base_matrix into matrix type.
>
>     I understand there are tests examples but something goes wrong with
>     the straightforward code.
>
>     We are compiling for open cl and open mp at the same time.
>
>
>     On Mon, Aug 8, 2016 at 11:03 AM, Andrew Palumbo <ap....@outlook.com
>     <mailto:ap....@outlook.com>> wrote:
>
>         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 <r...@iue.tuwien.ac.at
>         <mailto:r...@iue.tuwien.ac.at>>
>         *Sent:* Sunday, August 7, 2016 2:20:26 PM
>         *To:* Andrew Palumbo; viennacl-devel@lists.sourceforge.net
>         <mailto:viennacl-devel@lists.sourceforge.net>
>         *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
>         >
>
>
>         
> ------------------------------------------------------------------------------
>         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
>         <mailto:ViennaCL-devel@lists.sourceforge.net>
>         https://lists.sourceforge.net/lists/listinfo/viennacl-devel
>         <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