Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Lars_M_
Beginner
55 Views

Rewrite subroutine to use MKL - matrix multiplication

Hi,

My first post on the forum!

I'm working with an older code written i Fortran at uni. The program consists of several subroutines and I would like to rewrite parts (subroutines) of the code so it runs faster (parallel). My knowledge of Fortran is limited/"ok". The first routine I like to look into is MT:

description:

            “Matrix multiplication

             B = AA*B*A (AA is the transpose of A)

             B = Full, symmetric matrix

             A = Unit matrix with an n by n submatrix (argument A) on the diagonal”


 

For code, please see attachment.

The subroutine is often called like this:

   do J = 1,10,3

      CALL MT(UM,FS,WE,12,3,J,PU,ER)

   continue

Then UM(3,3), FS(12,12) and WE(3)

Is there any way I can use MKL to rewrite the code? Using dgemm? Or maybe use openmp?

 

Any clues?


Thanks,

Lars

0 Kudos
4 Replies
TimP
Black Belt
55 Views

The problem is rather small so I would not expect MKL to be of much help.  As you show the possibility of executing 2 or 4 of them in parallel, there may be some scope for threading.

Inside MT, it may help to give loop count directives or to assure that the compiler can take advantage of such information through interprocedural analysis.  Just in case, you would examine vec-report to assure that the inner loops have vectorized (with the proviso that the loops are rather short and probably do better with minimal unroll).

 

Lars_M_
Beginner
55 Views

Tim Prince wrote:

The problem is rather small so I would not expect MKL to be of much help.  As you show the possibility of executing 2 or 4 of them in parallel, there may be some scope for threading.

Inside MT, it may help to give loop count directives or to assure that the compiler can take advantage of such information through interprocedural analysis.  Just in case, you would examine vec-report to assure that the inner loops have vectorized (with the proviso that the loops are rather short and probably do better with minimal unroll).

 

Thanks for the answer Tim, but as I wrote, my Fortran knowledge is limited. Are you able to make an example?

mecej4
Black Belt
55 Views

I do not understand the problem description. If A is n X n and B is m X m, the matrix pairs (AT, B) and (B, A) are not suitable for multiplication when m is not equal to n. Please explain.

Lars_M_
Beginner
55 Views

mecej4 wrote:

I do not understand the problem description. If A is n X n and B is m X m, the matrix pairs (AT, B) and (B, A) are not suitable for multiplication when m is not equal to n. Please explain.

Mecej4,

For each step J, B is a subset of B : AT(3,3) * B(3,12) and then B(12,3)*A(3,3)

 

Reply