This subroutine calculates C = alpha*op1(A)*op2(B) +beta*C where: * C is MxN general matrix * op1(A) is MxK matrix * op2(B) is KxN matrix * "op" may be identity transformation, transposition, conjugate transposition Additional info: * cache-oblivious algorithm is used. * multiplication result replaces C. If Beta=0, C elements are not used in calculations (not multiplied by zero - just not refer
| 1415 | Bochkanov Sergey |
| 1416 | *************************************************************************/ |
| 1417 | void cmatrixgemm(int m, |
| 1418 | int n, |
| 1419 | int k, |
| 1420 | ap::complex alpha, |
| 1421 | const ap::complex_2d_array& a, |
| 1422 | int ia, |
| 1423 | int ja, |
| 1424 | int optypea, |
| 1425 | const ap::complex_2d_array& b, |
| 1426 | int ib, |
| 1427 | int jb, |
| 1428 | int optypeb, |
| 1429 | ap::complex beta, |
| 1430 | ap::complex_2d_array& c, |
| 1431 | int ic, |
| 1432 | int jc) |
| 1433 | { |
| 1434 | int s1; |
| 1435 | int s2; |
| 1436 | int bs; |
| 1437 | |
| 1438 | bs = ablascomplexblocksize(a); |
| 1439 | if( m<=bs&&n<=bs&&k<=bs ) |
| 1440 | { |
| 1441 | cmatrixgemmk(m, n, k, alpha, a, ia, ja, optypea, b, ib, jb, optypeb, beta, c, ic, jc); |
| 1442 | return; |
| 1443 | } |
| 1444 | if( m>=n&&m>=k ) |
| 1445 | { |
| 1446 | |
| 1447 | // |
| 1448 | // A*B = (A1 A2)^T*B |
| 1449 | // |
| 1450 | ablascomplexsplitlength(a, m, s1, s2); |
| 1451 | cmatrixgemm(s1, n, k, alpha, a, ia, ja, optypea, b, ib, jb, optypeb, beta, c, ic, jc); |
| 1452 | if( optypea==0 ) |
| 1453 | { |
| 1454 | cmatrixgemm(s2, n, k, alpha, a, ia+s1, ja, optypea, b, ib, jb, optypeb, beta, c, ic+s1, jc); |
| 1455 | } |
| 1456 | else |
| 1457 | { |
| 1458 | cmatrixgemm(s2, n, k, alpha, a, ia, ja+s1, optypea, b, ib, jb, optypeb, beta, c, ic+s1, jc); |
| 1459 | } |
| 1460 | return; |
| 1461 | } |
| 1462 | if( n>=m&&n>=k ) |
| 1463 | { |
| 1464 | |
| 1465 | // |
| 1466 | // A*B = A*(B1 B2) |
| 1467 | // |
| 1468 | ablascomplexsplitlength(a, n, s1, s2); |
| 1469 | if( optypeb==0 ) |
| 1470 | { |
| 1471 | cmatrixgemm(m, s1, k, alpha, a, ia, ja, optypea, b, ib, jb, optypeb, beta, c, ic, jc); |
| 1472 | cmatrixgemm(m, s2, k, alpha, a, ia, ja, optypea, b, ib, jb+s1, optypeb, beta, c, ic, jc+s1); |
| 1473 | } |
| 1474 | else |
no test coverage detected