I would like to use Thrust to evaluate expressions consisting of elementwise matrix operations. To make it clear, let us consider an expression like:
D=A*B+3*sin(C)
where A
, B
, C
and D
are matrices, of course of the same size.
The Thrust Quick Start Guide provides the saxpy
example for which y
is used both as input and as output, while in my case the output argument is different from the input ones which, by the way, are more than two. At Element-by-element vector multiplication with CUDA, the case of output different than the input, but of only two inputs, is considered.
Could anyone provide some suggestions (and possibly the rationale behind) on how using Thrust to implement the expression above (output matrix different from the inputs and more than two inputs)? Thanks.
Here's how to implement that computation with Newton, which is the library mentioned in talonmies' comment:
The library is built using
thrust::zip_iterator
andthrust::transform_iterator
to implement expressions with an arbitrary number of inputs. You can refer to the implementation for the details.