# Matrix vector multiply

## Matrix vector multiply

What would be the recommended ArBB code-outlineto efficientlymultiply a dense f.p.matrix by a dense f.p. vector?
e.g. M x V1 = V2
- paul

4 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Paul - thanks for submitting so many good questions. We will post an answer to this soon.

--Amanda

I was thinking this:

V2 = add_reduce( repeat_row( V1, M.num_rows() ) * M );

...would work, but is it time efficient? Space efficient? What about multicore, as the per-row operations are independent?

As a type-A personailty, I think I might like map() functionality not on each atomic element of a container, but on a "per row" and/or "per page" of a container, todescribe to ArBB how Ialready know thecalculation could be parallelized. . . and these are hierachy-ably call-able e.g. the per-page "map"can make calls tothe per-row "map" which can make calls tothe map()ArBB has.

- paul

Hello Paul,

if you like you can have a look at this webinar, slide #19-21 is covering the matrix-vector multiplication. As you already discovered, the following is expressing the MV-multiplication:

result = add_reduce(matrix * repeat_row(vector, matrix.num_rows()));

Intel ArBB is aiming to make programs efficient which are the most straight-forward implementations of a problem (according to the programming model of Intel ArBB). We definitely want to have code which is approaching this goal in contrast to something which is indirectly hitting the target in a non-obvious manner. The MV-multiplication as presented is efficient.

Another note on the terminology "space efficient" (inside of the context of an Intel ArBB function). Despite of the C++ perspective, a new
dense container inside of an Intel ArBB functions context isn't necessarily representing a
whole copy of a container. It is less about moving whole memory regions
around (like memcopy), instead it is filling the registers with the selected
region as the operation referring the "copy" goes.

Thank you for suggesting the functionality which is scoping the map-operator to something different than each element in an element-by-element manner. We logged a feature request for your suggestion.

Hans

## Leave a Comment

Please sign in to add a comment. Not a member?