}
}
- long Compare(const std::vector<float> &matrix) const {
- long fail = 0;
+ void Compare(const std::vector<float> &matrix) const {
for (int i = 0; i < nBlocksPerCol; i++)
for (int j = 0; j < nBlocksPerRow; j++) {
float *CurrBlock = GetBlock(i, j);
int currj = j * rowsPerBlock + jj;
float m_value = matrix[curri + currj * nCols];
float bm_value = CurrBlock[ii + jj * colsPerBlock];
- if (std::fabs(bm_value - m_value) >
- std::numeric_limits<float>::epsilon()) {
- fail++;
- }
+ assert(std::fabs(bm_value - m_value) <
+ std::numeric_limits<float>::epsilon());
}
}
- return fail;
}
float *GetBlock(int i, int j) const {
};
constexpr const int BS = 16;
-constexpr const int N = 256;
+constexpr const int N = 16;
int BlockMatMul_TargetNowait(BlockMatrix &A, BlockMatrix &B, BlockMatrix &C) {
#pragma omp parallel
}
auto BlockedA = BlockMatrix(BS, BS, N, N);
- BlockedA.Initialize(a);
- BlockedA.Compare(a);
auto BlockedB = BlockMatrix(BS, BS, N, N);
+ auto BlockedC = BlockMatrix(BS, BS, N, N);
+ BlockedA.Initialize(a);
BlockedB.Initialize(b);
+ BlockedC.Initialize(c);
+ BlockedA.Compare(a);
BlockedB.Compare(b);
+ BlockedC.Compare(c);
Matmul(a, b, c);
-
- auto BlockedC = BlockMatrix(BS, BS, N, N);
BlockMatMul_TargetNowait(BlockedA, BlockedB, BlockedC);
- if (BlockedC.Compare(c) > 0) {
- return 1;
- }
+ BlockedC.Compare(c);
std::cout << "PASS\n";