[Openmp-commits] [openmp] 092a5bb - [OpenMP][Offloading] Fix test case issues in bug49334.cpp
Shilei Tian via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 17 07:22:52 PST 2022
Author: Shilei Tian
Date: 2022-02-17T10:22:48-05:00
New Revision: 092a5bb72ba8cc5a6cec02cfe61f70130a2c1282
URL: https://github.com/llvm/llvm-project/commit/092a5bb72ba8cc5a6cec02cfe61f70130a2c1282
DIFF: https://github.com/llvm/llvm-project/commit/092a5bb72ba8cc5a6cec02cfe61f70130a2c1282.diff
LOG: [OpenMP][Offloading] Fix test case issues in bug49334.cpp
`bug49334.cpp` has one issue that causes flaky result reported in #53730.
The root cause is `BlockedC` is never initialized but in `BlockMatMul_TargetNowait`
it is directly read and written (via `+=`). Fixes #53730.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D119988
Added:
Modified:
openmp/libomptarget/test/offloading/bug49334.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/test/offloading/bug49334.cpp b/openmp/libomptarget/test/offloading/bug49334.cpp
index cd0b185219940..047a78c11ac8b 100644
--- a/openmp/libomptarget/test/offloading/bug49334.cpp
+++ b/openmp/libomptarget/test/offloading/bug49334.cpp
@@ -50,8 +50,7 @@ class BlockMatrix {
}
}
- 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);
@@ -61,13 +60,10 @@ class BlockMatrix {
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 {
@@ -77,7 +73,7 @@ class BlockMatrix {
};
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
@@ -130,20 +126,19 @@ int main(int argc, char *argv[]) {
}
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";
More information about the Openmp-commits
mailing list