Haha, no worries. :)
To tell you the full story, at some point it was included in the OpenCL
backend only, using the OpenCL code generator. It supported  row/column
reduction for sum, max, min. But we eventually removed it because having
support for HOST and CUDA was too many things to maintain, as Karl pointed
it out. This being said, the OpenCL code generator, deep down, still has
the capability to generate reduction code. Unfortunately, I have forgotten
how to leverage these capabilities. If you need more complex reduction code
(such as max/min), here are a few options you might want to consider:
- If you want to write your own kernel, have a look at this :
http://www.bealto.com/gpu-gemv.html. GEMV is a special case of reduction
[since x = prod(A,y) <=> x = sum( A .* repmat(y, N), 0)]. To come up with a
row-wise reduction, have a look at GEMV code, replace the summation by
whatever operator you need, and don't use the vector values. To come up
with a column-wise reduction kernel, have a look at x = prod(A.T, y),
although it's not shown on this website.
- reset to  2a6cbbb57edf01de5bfa609c9 (1 year ago :D). There should be
reductions for OpenCL there, tested in tests/src/generator_blas2.cpp. Then
perhaps you can find a way to dump the kernel.
- use VexCL. I think the latest version supports it.
- If you just want a single OpenCL reduction kernel to investigate, I am
implementing an improved version of the code-generator. It is closed-source
for now, but I can dump some .cl files for you if you contact me privately.

Philippe

2015-07-27 10:07 GMT-07:00 Charles Determan <cdeterma...@gmail.com>:

> Philippe,
>
> I definitely understand and support such a solution for ViennaCL.  I don't
> mean to say it should be included, I was just curious what the current
> approach was.  However, I am interested in additional OpenCL development
> outside of the framework.  Do you have any recommendations in learning more
> about coding OpenCL reductions?  As I mentioned above, I have only found
> very basic reduction approaches so far, nothing for slightly more complex
> scenarios like the column and row sum examples.
>
> If this is transitioning too far from the mailing list focus I would
> certainly appreciate a reply off list.
>
> Thank you,
> Charles
>
> On Mon, Jul 27, 2015 at 11:46 AM, Philippe Tillet <phil.til...@gmail.com>
> wrote:
>
>> Hi,
>>
>> Such row-rise / column-wise reductions could be generate-able by the
>> OpenCL backend, but this won't work on the Host of CUDA backend. Plus, this
>> is not really maintained at the moment. I would recommend Karl's solution,
>> even though it won't be optimal when the vector does not fit in the L2
>> cache of the OpenCL device (Maxwell for example has 2MB of L2 cache), as
>> the current algorithm for GEMV accesses the entire vector get_num_groups(0)
>> times.
>>
>> Philippe
>>
>> 2015-07-27 9:40 GMT-07:00 Karl Rupp <r...@iue.tuwien.ac.at>:
>>
>>>
>>> > Excellent, thank you.  I thought that would be the way to go initially
>>> > but I hesitated because of concerns about having additional temporary
>>> > objects taking up memory when matrices begin to get larger but it
>>> > certainly is simpler this way.
>>>
>>> Just pushed:
>>>
>>> https://github.com/viennacl/viennacl-dev/commit/4063c941235d46804cd448db7ddecf0c3238548f
>>>
>>> Yeah, it's a bit of a trade-off: Sure, one could optimize the summation
>>> kernel, but this also implies more code to maintain. On the other hand,
>>> I'm not aware (which, of course, does not deny a possible existence) of
>>> a scenario where such summation routines are the performance bottleneck.
>>>
>>> > Glad to hear that 1.7.0 is nearly completed.  Does that mean we should
>>> > expect a formal release soon?
>>>
>>> Yep. Expect the release on Wednesday.
>>>
>>> Best regards,
>>> Karli
>>>
>>>
>>>
>>> > On Mon, Jul 27, 2015 at 9:57 AM, Karl Rupp <r...@iue.tuwien.ac.at
>>> > <mailto:r...@iue.tuwien.ac.at>> wrote:
>>> >
>>> >     Hi Charles,
>>> >
>>> >       > I am working on writing some additional opencl kernels
>>> >     (potentially to
>>> >     > incorporate in to viennacl) which involve column-wise
>>> reductions.  A
>>> >     > simple case would simply be the sum of each column of a matrix.
>>> >     > However, I am having an extremely difficult time getting my
>>> kernel
>>> >     > correct (reductions are tricky to me).  That said, after
>>> searching for
>>> >     > some resources I came across an old post on sourceforge
>>> referring to
>>> >     > column-wise kernels
>>> >      > (http://sourceforge.net/p/viennacl/mailman/message/27542552/)
>>> with
>>> >     > viennacl.  This leads me to my primary question.
>>> >     >
>>> >     > Are there such kernels already in ViennaCL that I have
>>> overlooked?
>>> >
>>> >     Yes ;-) Have a look here at how row-wise sums reduce to a standard
>>> >     matrix-vector product:
>>> >
>>> https://sourceforge.net/p/viennacl/discussion/1143678/thread/38e942a0/
>>> >
>>> >     That is, in order to compute a row-sum and a column-sum you can use
>>> >        row_sum = prod(A, ones);
>>> >        col_sum = prod(trans(A), ones);
>>> >
>>> >     In an hour or two I will push convenience functions for summation
>>> fixing
>>> >     the only remaining issue for the 1.7.0 release:
>>> >     https://github.com/viennacl/viennacl-dev/issues/127
>>> >
>>> >
>>> >     > If not, are there any examples or resources you would recommend
>>> to help
>>> >     > learn this topic?  I have tried searching further but the only
>>> thing I
>>> >     > can really find is a reduction of an entire matrix (which is
>>> relatively
>>> >     > simple) as opposed to by column or row.
>>> >
>>> >     At this point I can only recommend to think about how such
>>> operations
>>> >     can be recast in terms of (standard) linear algebra. For example,
>>> row-
>>> >     and column-wise updates to a matrix are special cases of the more
>>> >     general
>>> >        A += outer_prod(u, v);
>>> >     operation (rank-1 updates). I'll improve the documentation in that
>>> >     direction.
>>> >
>>> >     Best regards,
>>> >     Karli
>>> >
>>> >
>>> >
>>>  
>>> ------------------------------------------------------------------------------
>>> >     _______________________________________________
>>> >     ViennaCL-devel mailing list
>>> >     ViennaCL-devel@lists.sourceforge.net
>>> >     <mailto: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
>>>
>>
>>
>
------------------------------------------------------------------------------
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to