# Help me!  simple kernel for product matrix and vector!

**URL:** <https://forums.developer.nvidia.com/t/help-me-simple-kernel-for-product-matrix-and-vector/39621>\
**Category:** CUDA Programming and Performance\
**Created:** [September 23, 2015, 8:36am UTC](https://forums.developer.nvidia.com/t/help-me-simple-kernel-for-product-matrix-and-vector/39621 "2015-09-23T08:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joy4162](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@joy4162](https://forums.developer.nvidia.com/u/joy4162)\
**Post date:** [September 23, 2015, 8:36am UTC](https://forums.developer.nvidia.com/t/help-me-simple-kernel-for-product-matrix-and-vector/39621/1 "2015-09-23T08:36:32Z")

</div>

Hi,  
I’m now implement a kernel function for simply 1 matrix \* 1 vector.  
However, I’m just confusing how I can be implement a good way.

I would like to product 1 row by the vector respectively.

if  
matrix →   
a b c d  
e f g h

vector →   
1 2 3 4

result  
a_1 b_2 c_3 d_4  
e_1 f_2 g_3 h_4

I always confuse how I choose grid and block dimension well…

if I use  
width = 1024  
height = 2400  
vector size = 1024 ,  
then how I can set up the grid and block size?  
(I’m using titan X)

Could anyone can explain for my question?  
Thank you!

---

<div class="post-metadata">

**Author:** ![HannesF99](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@HannesF99](https://forums.developer.nvidia.com/u/HannesF99)\
**Post date:** [September 23, 2015, 11:48am UTC](https://forums.developer.nvidia.com/t/help-me-simple-kernel-for-product-matrix-and-vector/39621/2 "2015-09-23T11:48:46Z")

</div>

Regarding blocks, grids, see e.g [nvidia - Understanding CUDA grid dimensions, block dimensions and threads organization (simple explanation) - Stack Overflow](http://stackoverflow.com/questions/2392250/understanding-cuda-grid-dimensions-block-dimensions-and-threads-organization-s)

For matrix-vector multiplication, i would use the cublas library.  
See [c++ - CUDA/CUBLAS Matrix-Vector Multiplication - Stack Overflow](http://stackoverflow.com/questions/18516373/cuda-cublas-matrix-vector-multiplication)

---

<div class="post-metadata">

**Author:** ![joy4162](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@joy4162](https://forums.developer.nvidia.com/u/joy4162)\
**Post date:** [September 24, 2015, 1:23am UTC](https://forums.developer.nvidia.com/t/help-me-simple-kernel-for-product-matrix-and-vector/39621/3 "2015-09-24T01:23:11Z")

</div>

> > HannesF99

Thank you for your reply!
