[Openmp-commits] [PATCH] D119485: [OpenMP][Offloading] Change the way to compare floating point values in bug49334.cpp
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 10 14:15:49 PST 2022
tianshilei1992 created this revision.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.
`bug49334.cpp` directly uses `!=` to compare two floating point values,
which is almost wrong.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119485
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
@@ -5,7 +5,9 @@
// UNSUPPORTED: x86_64-pc-linux-gnu
#include <cassert>
+#include <cmath>
#include <iostream>
+#include <limits>
#include <memory>
#include <vector>
@@ -57,7 +59,8 @@
int currj = j * rowsPerBlock + jj;
float m_value = matrix[curri + currj * nCols];
float bm_value = CurrBlock[ii + jj * colsPerBlock];
- if (bm_value != m_value) {
+ if (std::fabs(bm_value - m_value) >
+ std::numeric_limits<float>::epsilon()) {
fail++;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119485.407680.patch
Type: text/x-patch
Size: 792 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220210/338609a1/attachment-0001.bin>
More information about the Openmp-commits
mailing list