Simple Matrix-Vector Multiplication
Hello all,

I am sure this is a very simple problem but my brain does not want to work properly today. Given a square matrix and vector I would like to perform matrix-vector operation using CUDA. I found some examples in CUDA SDK for Matrix multiplication where the dimensions of matrices are multiples of defined block size, I would like a more generalized operation if possible. Are there any examples/tutorials for the multiplication of [M-by-N] matrix by a [N-by-P] vector?

Thank you.
Hello all,



I am sure this is a very simple problem but my brain does not want to work properly today. Given a square matrix and vector I would like to perform matrix-vector operation using CUDA. I found some examples in CUDA SDK for Matrix multiplication where the dimensions of matrices are multiples of defined block size, I would like a more generalized operation if possible. Are there any examples/tutorials for the multiplication of [M-by-N] matrix by a [N-by-P] vector?



Thank you.

#1
Posted 04/05/2010 04:49 PM   
If you want to know matrix multiplication on general dimension, you can check this thread
[url="http://forums.nvidia.com/index.php?showtopic=159033&hl=Hand-Tuned+SGEMM"]http://forums.nvidia.com/index.php?showtop...and-Tuned+SGEMM[/url]

I write a report on SGEMM and discuss how to extend SGEMM to arbitrary dimension in section 8
If you want to know matrix multiplication on general dimension, you can check this thread

http://forums.nvidia.com/index.php?showtop...and-Tuned+SGEMM



I write a report on SGEMM and discuss how to extend SGEMM to arbitrary dimension in section 8

Department of Mathematics, Tsing Hua university, R.O.C.
Lung Sheng Chien

#2
Posted 04/06/2010 03:06 PM   
[quote name='LSChien' post='1034861' date='Apr 6 2010, 11:06 AM']If you want to know matrix multiplication on general dimension, you can check this thread
[url="http://forums.nvidia.com/index.php?showtopic=159033&hl=Hand-Tuned+SGEMM"]http://forums.nvidia.com/index.php?showtop...and-Tuned+SGEMM[/url]

I write a report on SGEMM and discuss how to extend SGEMM to arbitrary dimension in section 8[/quote]

Wow, great work.

Thank you
[quote name='LSChien' post='1034861' date='Apr 6 2010, 11:06 AM']If you want to know matrix multiplication on general dimension, you can check this thread

http://forums.nvidia.com/index.php?showtop...and-Tuned+SGEMM



I write a report on SGEMM and discuss how to extend SGEMM to arbitrary dimension in section 8



Wow, great work.



Thank you

#3
Posted 04/06/2010 07:22 PM   
[quote name='LSChien' post='1034861' date='Apr 6 2010, 11:06 AM']If you want to know matrix multiplication on general dimension, you can check this thread
[url="http://forums.nvidia.com/index.php?showtopic=159033&hl=Hand-Tuned+SGEMM"]http://forums.nvidia.com/index.php?showtop...and-Tuned+SGEMM[/url]

I write a report on SGEMM and discuss how to extend SGEMM to arbitrary dimension in section 8[/quote]

Another quick question. Given that I am just trying to really learn CUDA with regards to matrix-vector operation(s) is there a simple CUDA code for matrix-vector multiplication (does not have to be all that efficient)? I like the code you built but it seems like a bit much for what I need - I just want to learn the basics of a matrix-vector multiplication on GPU.

Thanks again.
[quote name='LSChien' post='1034861' date='Apr 6 2010, 11:06 AM']If you want to know matrix multiplication on general dimension, you can check this thread

http://forums.nvidia.com/index.php?showtop...and-Tuned+SGEMM



I write a report on SGEMM and discuss how to extend SGEMM to arbitrary dimension in section 8



Another quick question. Given that I am just trying to really learn CUDA with regards to matrix-vector operation(s) is there a simple CUDA code for matrix-vector multiplication (does not have to be all that efficient)? I like the code you built but it seems like a bit much for what I need - I just want to learn the basics of a matrix-vector multiplication on GPU.



Thanks again.

#4
Posted 04/06/2010 07:55 PM   
[quote name='dinaharchery' post='1035030' date='Apr 6 2010, 11:55 AM']Another quick question. Given that I am just trying to really learn CUDA with regards to matrix-vector operation(s) is there a simple CUDA code for matrix-vector multiplication (does not have to be all that efficient)? I like the code you built but it seems like a bit much for what I need - I just want to learn the basics of a matrix-vector multiplication on GPU.

Thanks again.[/quote]



for matrix-vector multiplication, you can look at reduction example in SDK.
for matrix-matrix multiplication, matrixMul in SDK uses shared memory but only works for specific dimension.
You can try to extend matrixMul in SDK to arbitrary dimension.


if you want to know how to use registers instead of shared memory, then
I strongly recommand volkov's paper and his code, you can download them in the thread
[url="http://forums.nvidia.com/index.php?showtopic=89084"]http://forums.nvidia.com/index.php?showtopic=89084[/url]
[quote name='dinaharchery' post='1035030' date='Apr 6 2010, 11:55 AM']Another quick question. Given that I am just trying to really learn CUDA with regards to matrix-vector operation(s) is there a simple CUDA code for matrix-vector multiplication (does not have to be all that efficient)? I like the code you built but it seems like a bit much for what I need - I just want to learn the basics of a matrix-vector multiplication on GPU.



Thanks again.







for matrix-vector multiplication, you can look at reduction example in SDK.

for matrix-matrix multiplication, matrixMul in SDK uses shared memory but only works for specific dimension.

You can try to extend matrixMul in SDK to arbitrary dimension.





if you want to know how to use registers instead of shared memory, then

I strongly recommand volkov's paper and his code, you can download them in the thread

http://forums.nvidia.com/index.php?showtopic=89084

Department of Mathematics, Tsing Hua university, R.O.C.
Lung Sheng Chien

#5
Posted 04/08/2010 04:09 PM   
Here we shared thoughts, ideas, and some code on GEMV: [url="http://forums.nvidia.com/index.php?showtopic=162330&st=20"]http://forums.nvidia.com/index.php?showtop...62330&st=20[/url]
Here we shared thoughts, ideas, and some code on GEMV: http://forums.nvidia.com/index.php?showtop...62330&st=20

#6
Posted 04/09/2010 07:47 PM   
[quote name='Jimmy Pettersson' post='1036999' date='Apr 9 2010, 03:47 PM']Here we shared thoughts, ideas, and some code on GEMV: [url="http://forums.nvidia.com/index.php?showtopic=162330&st=20"]http://forums.nvidia.com/index.php?showtop...62330&st=20[/url][/quote]

Thanks very much for all the great information.

I have another question - I hope it is not too far off topic. Can Gaussian Elimination be implemented on CUDA? I know that it contains a lot of back/forward substitutions which don't seem to leave a lot of room for parallelism via CUDA but it would be interesting to see.
[quote name='Jimmy Pettersson' post='1036999' date='Apr 9 2010, 03:47 PM']Here we shared thoughts, ideas, and some code on GEMV: http://forums.nvidia.com/index.php?showtop...62330&st=20



Thanks very much for all the great information.



I have another question - I hope it is not too far off topic. Can Gaussian Elimination be implemented on CUDA? I know that it contains a lot of back/forward substitutions which don't seem to leave a lot of room for parallelism via CUDA but it would be interesting to see.

#7
Posted 04/16/2010 04:50 PM   
[quote name='Jimmy Pettersson' post='1036999' date='Apr 9 2010, 03:47 PM']Here we shared thoughts, ideas, and some code on GEMV: [url="http://forums.nvidia.com/index.php?showtopic=162330&st=20"]http://forums.nvidia.com/index.php?showtop...62330&st=20[/url][/quote]

Thanks very much for all the great information.

I have another question - I hope it is not too far off topic. Can Gaussian Elimination be implemented on CUDA? I know that it contains a lot of back/forward substitutions which don't seem to leave a lot of room for parallelism via CUDA but it would be interesting to see.
[quote name='Jimmy Pettersson' post='1036999' date='Apr 9 2010, 03:47 PM']Here we shared thoughts, ideas, and some code on GEMV: http://forums.nvidia.com/index.php?showtop...62330&st=20



Thanks very much for all the great information.



I have another question - I hope it is not too far off topic. Can Gaussian Elimination be implemented on CUDA? I know that it contains a lot of back/forward substitutions which don't seem to leave a lot of room for parallelism via CUDA but it would be interesting to see.

#8
Posted 04/16/2010 04:50 PM   
Scroll To Top