Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2442 Discussions

Using parallel_reduce inside of a parallel_for

rkyee
Beginner
405 Views

Hi All,

 

I'm wanting to perform a block matrix calculation in the following way:

Matrix A is a (k x n) block matrix, and X is a (n x 1) block vector.  
To compute the product AX, which will be a (k x 1) block vector, I want to parallelize the computation of each entry, which involves summing n matrix products. This can be accomplished using parallel_reduce, which will let individual threads handle the matrix multiplication, and combine results via addition.

 

My question is that since I need to compute k such entries, I wonder whether it makes sense to put the parallel_reduce inside of a parallel_for, or if doing this causes some problems?
Each of the k entries are computed independently, so it seems reasonable from a theoretical standpoint. 
I've implemented it, but performance is not as good as I'd like. I'm not super familiar with parallel computation, so I hoped to double check that I'm not doing something inefficient or dumb here. 

Thanks for your help!
 

0 Kudos
1 Solution
NoorjahanSk_Intel
Moderator
379 Views

Hi,


Thanks for reaching out to us.


>>I've implemented it, but performance is not as good as I'd like


Could you please provide us with a source code(steps if any) that you have implemented?


Could you please let us know how you are measuring the performance?


Also please let us know the environmental details on which you are building your code.



Thanks & Regards,

Noorjahan.


View solution in original post

4 Replies
NoorjahanSk_Intel
Moderator
380 Views

Hi,


Thanks for reaching out to us.


>>I've implemented it, but performance is not as good as I'd like


Could you please provide us with a source code(steps if any) that you have implemented?


Could you please let us know how you are measuring the performance?


Also please let us know the environmental details on which you are building your code.



Thanks & Regards,

Noorjahan.


NoorjahanSk_Intel
Moderator
356 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue?


Thanks & Regards,

Noorjahan.


rkyee
Beginner
348 Views

Hi Noorjahan,  the error ended up being a simple one on my own part due to some inadvertent copying. Thank you for the support!

NoorjahanSk_Intel
Moderator
332 Views

Hi,


Glad to know that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards,

Noorjahan.


Reply