[Openmp-commits] [PATCH] D119988: [OpenMP][Offloading] Fix test case issues in bug49334.cpp
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Feb 16 15:56:59 PST 2022
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, Meinersbur.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.
`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 `+=`).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119988
Files:
openmp/libomptarget/test/offloading/bug49334.cpp
Index: openmp/libomptarget/test/offloading/bug49334.cpp
===================================================================
--- openmp/libomptarget/test/offloading/bug49334.cpp
+++ openmp/libomptarget/test/offloading/bug49334.cpp
@@ -50,8 +50,7 @@
}
}
- 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 @@
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 @@
};
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 @@
}
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";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119988.409441.patch
Type: text/x-patch
Size: 1903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220216/bfaf9638/attachment.bin>
More information about the Openmp-commits
mailing list