| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "chyokotov_a_dense_matrix_mul_foxs_algorithm/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cmath> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "chyokotov_a_dense_matrix_mul_foxs_algorithm/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace chyokotov_a_dense_matrix_mul_foxs_algorithm { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | ChyokotovADenseMatMulFoxAlgorithmSEQ::ChyokotovADenseMatMulFoxAlgorithmSEQ(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 | GetInput() = in; | ||
| 14 | GetOutput().clear(); | ||
| 15 | 32 | } | |
| 16 | |||
| 17 | 32 | bool ChyokotovADenseMatMulFoxAlgorithmSEQ::ValidationImpl() { | |
| 18 | 32 | return (GetInput().first.size() == GetInput().second.size()); | |
| 19 | } | ||
| 20 | |||
| 21 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
|
32 | bool ChyokotovADenseMatMulFoxAlgorithmSEQ::PreProcessingImpl() { |
| 22 | GetOutput().clear(); | ||
| 23 | 32 | GetOutput().resize(GetInput().first.size(), 0.0); | |
| 24 | 32 | return true; | |
| 25 | } | ||
| 26 | |||
| 27 | ✗ | int ChyokotovADenseMatMulFoxAlgorithmSEQ::CalculateBlockSize(int n) { | |
| 28 | 24 | return static_cast<int>(std::sqrt(static_cast<double>(n))); | |
| 29 | } | ||
| 30 | |||
| 31 | ✗ | int ChyokotovADenseMatMulFoxAlgorithmSEQ::CountBlock(int n, int size) { | |
| 32 | 24 | return (n + size - 1) / size; | |
| 33 | } | ||
| 34 | |||
| 35 | 136 | void ChyokotovADenseMatMulFoxAlgorithmSEQ::Matmul(std::vector<double> &a, std::vector<double> &b, int n, int istart, | |
| 36 | int iend, int jstart, int jend, int kstart, int kend) { | ||
| 37 |
2/2✓ Branch 0 taken 200 times.
✓ Branch 1 taken 136 times.
|
336 | for (int i = istart; i < iend; i++) { |
| 38 |
2/2✓ Branch 0 taken 328 times.
✓ Branch 1 taken 200 times.
|
528 | for (int j = jstart; j < jend; j++) { |
| 39 | double sum = 0.0; | ||
| 40 |
2/2✓ Branch 0 taken 584 times.
✓ Branch 1 taken 328 times.
|
912 | for (int k = kstart; k < kend; k++) { |
| 41 | 584 | sum += a[(i * n) + k] * b[(k * n) + j]; | |
| 42 | } | ||
| 43 | 328 | GetOutput()[(i * n) + j] += sum; | |
| 44 | } | ||
| 45 | } | ||
| 46 | 136 | } | |
| 47 | |||
| 48 | 32 | bool ChyokotovADenseMatMulFoxAlgorithmSEQ::RunImpl() { | |
| 49 | 32 | std::vector<double> a = GetInput().first; | |
| 50 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | std::vector<double> b = GetInput().second; |
| 51 | 32 | int n = static_cast<int>(std::sqrt(static_cast<double>(a.size()))); | |
| 52 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
|
32 | if (n == 0) { |
| 53 | return true; | ||
| 54 | } | ||
| 55 | |||
| 56 | int block_size = CalculateBlockSize(n); | ||
| 57 | int count_block = CountBlock(n, block_size); | ||
| 58 | |||
| 59 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
|
64 | for (int ic = 0; ic < count_block; ic++) { |
| 60 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 40 times.
|
112 | for (int jc = 0; jc < count_block; jc++) { |
| 61 |
2/2✓ Branch 0 taken 136 times.
✓ Branch 1 taken 72 times.
|
208 | for (int kc = 0; kc < count_block; kc++) { |
| 62 | 136 | int istart = ic * block_size; | |
| 63 | 136 | int jstart = jc * block_size; | |
| 64 | 136 | int kstart = kc * block_size; | |
| 65 | |||
| 66 | 136 | int iend = std::min(istart + block_size, n); | |
| 67 | 136 | int jend = std::min(jstart + block_size, n); | |
| 68 | 136 | int kend = std::min(kstart + block_size, n); | |
| 69 | |||
| 70 | 136 | Matmul(a, b, n, istart, iend, jstart, jend, kstart, kend); | |
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | return true; | ||
| 76 | } | ||
| 77 | |||
| 78 | 32 | bool ChyokotovADenseMatMulFoxAlgorithmSEQ::PostProcessingImpl() { | |
| 79 | 32 | return true; | |
| 80 | } | ||
| 81 | |||
| 82 | } // namespace chyokotov_a_dense_matrix_mul_foxs_algorithm | ||
| 83 |