Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdc2e2ffd5 | ||
|
|
40373c8734 |
4 changed files with 10 additions and 151 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -16,3 +16,4 @@
|
|||
/test-suite-10.0.0rc6.src.fedora.tar.xz
|
||||
/test-suite-10.0.0.src.fedora.tar.xz
|
||||
/test-suite-11.0.0rc1.src.fedora.tar.xz
|
||||
/test-suite-11.0.0.src.fedora.tar.xz
|
||||
|
|
|
|||
|
|
@ -1,147 +0,0 @@
|
|||
From fdab65939511f946f457471100df4aac9257f677 Mon Sep 17 00:00:00 2001
|
||||
From: Jinsong Ji <jji@us.ibm.com>
|
||||
Date: Thu, 16 Jul 2020 16:02:33 +0000
|
||||
Subject: [PATCH] Fix random number generation and floating point comparison in
|
||||
matrix-types-spec.cpp
|
||||
|
||||
The testsuite is failing on PowerPC buildbots due to https://reviews.llvm.org/D72770.
|
||||
Looks like we are using wrong type generator for double.
|
||||
|
||||
We are also using EXPECT_MATRIX_EQ to do binary comparision of
|
||||
floating point values before and afer multiplication. And there might be
|
||||
small differences but within tolerance allowance.
|
||||
|
||||
Reviewed By: fhahn
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D83910
|
||||
|
||||
(cherry picked from commit 4bdbe4ad9dd25b432d405d8a6ac6b7410da9b7a2)
|
||||
---
|
||||
SingleSource/UnitTests/matrix-types-spec.cpp | 87 ++++++++++++++++----
|
||||
1 file changed, 69 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/SingleSource/UnitTests/matrix-types-spec.cpp b/SingleSource/UnitTests/matrix-types-spec.cpp
|
||||
index 0bd5f9e3..549930df 100644
|
||||
--- a/SingleSource/UnitTests/matrix-types-spec.cpp
|
||||
+++ b/SingleSource/UnitTests/matrix-types-spec.cpp
|
||||
@@ -8,15 +8,54 @@
|
||||
#include <random>
|
||||
#include <stdlib.h>
|
||||
|
||||
-#define EXPECT_MATRIX_EQ(A, B, R, C) \
|
||||
- do { \
|
||||
- for (unsigned r = 0; r < R; r++) \
|
||||
- for (unsigned c = 0; c < C; c++) \
|
||||
- if (A[r + c * R] != B[r + c * R]) { \
|
||||
- std::cerr << "mismatch at " << r << ":" << c << "\n"; \
|
||||
- exit(1); \
|
||||
- } \
|
||||
- } while (false)
|
||||
+#define ABSTOL 0.000001
|
||||
+#define RELTOL 0.00001
|
||||
+bool fpcmp(double V1, double V2, double AbsTolerance, double RelTolerance) {
|
||||
+ // Check to see if these are inside the absolute tolerance
|
||||
+ if (AbsTolerance < fabs(V1 - V2)) {
|
||||
+ // Nope, check the relative tolerance...
|
||||
+ double Diff;
|
||||
+ if (V2)
|
||||
+ Diff = fabs(V1 / V2 - 1.0);
|
||||
+ else if (V1)
|
||||
+ Diff = fabs(V2 / V1 - 1.0);
|
||||
+ else
|
||||
+ Diff = 0; // Both zero.
|
||||
+ if (Diff > RelTolerance) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+template <typename ElementTy, typename std::enable_if_t<
|
||||
+ std::is_integral<ElementTy>::value, int> = 0>
|
||||
+void expectMatrixEQ(ElementTy *A, ElementTy *B, unsigned R, unsigned C) {
|
||||
+ do {
|
||||
+ for (unsigned r = 0; r < R; r++)
|
||||
+ for (unsigned c = 0; c < C; c++)
|
||||
+ if (A[r + c * R] != B[r + c * R]) {
|
||||
+ std::cerr << "mismatch at " << r << ":" << c << "\n";
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ } while (false);
|
||||
+}
|
||||
+
|
||||
+template <typename ElementTy,
|
||||
+ typename std::enable_if_t<std::is_floating_point<ElementTy>::value,
|
||||
+ int> = 0>
|
||||
+void expectMatrixEQ(ElementTy *A, ElementTy *B, unsigned R,
|
||||
+ unsigned C) {
|
||||
+ do {
|
||||
+ for (unsigned r = 0; r < R; r++)
|
||||
+ for (unsigned c = 0; c < C; c++)
|
||||
+ if (fpcmp(A[r + c * R], B[r + c * R], ABSTOL, RELTOL)) {
|
||||
+ std::cerr << "mismatch at " << r << ":" << c << "\n";
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ } while (false);
|
||||
+}
|
||||
+
|
||||
|
||||
template <typename EltTy>
|
||||
void zeroMatrix(EltTy *M, unsigned Rows, unsigned Cols) {
|
||||
@@ -33,13 +72,25 @@ template <typename EltTy> void print(EltTy *X, unsigned Rows, unsigned Cols) {
|
||||
}
|
||||
}
|
||||
|
||||
-template <typename Ty> void initRandom(Ty *A, unsigned Rows, unsigned Cols) {
|
||||
+template <typename ElementTy,
|
||||
+ typename std::enable_if_t<std::is_floating_point<ElementTy>::value,
|
||||
+ int> = 0>
|
||||
+void initRandom(ElementTy *A, unsigned Rows, unsigned Cols) {
|
||||
+ std::default_random_engine generator;
|
||||
+ std::uniform_real_distribution<ElementTy> distribution(-10.0, 10.0);
|
||||
+
|
||||
+ for (unsigned i = 0; i < Rows * Cols; i++)
|
||||
+ A[i] = distribution(generator);
|
||||
+}
|
||||
+
|
||||
+template <typename ElementTy, typename std::enable_if_t<
|
||||
+ std::is_integral<ElementTy>::value, int> = 0>
|
||||
+void initRandom(ElementTy *A, unsigned Rows, unsigned Cols) {
|
||||
std::default_random_engine generator;
|
||||
- std::uniform_int_distribution<double> distribution(-10.0, 10.0);
|
||||
- auto random_double = std::bind(distribution, generator);
|
||||
+ std::uniform_int_distribution<ElementTy> distribution(-10, 10);
|
||||
|
||||
for (unsigned i = 0; i < Rows * Cols; i++)
|
||||
- A[i] = random_double();
|
||||
+ A[i] = distribution(generator);
|
||||
}
|
||||
|
||||
template <typename EltTy, unsigned R, unsigned C>
|
||||
@@ -82,8 +133,8 @@ template <typename EltTy, unsigned R0, unsigned C0> void testTranspose() {
|
||||
transposeSpec<EltTy, R0, C0>(ResSpec, X);
|
||||
transposeBuiltin<EltTy, R0, C0>(ResBuiltin, X);
|
||||
|
||||
- EXPECT_MATRIX_EQ(ResBase, ResBuiltin, R0, C0);
|
||||
- EXPECT_MATRIX_EQ(ResBase, ResSpec, C0, R0);
|
||||
+ expectMatrixEQ(ResBase, ResBuiltin, R0, C0);
|
||||
+ expectMatrixEQ(ResBase, ResSpec, C0, R0);
|
||||
}
|
||||
|
||||
template <typename EltTy, unsigned R0, unsigned C0, unsigned C1>
|
||||
@@ -150,9 +201,9 @@ void testMultiply() {
|
||||
multiplySpec<EltTy, R0, C0, C1>(ResSpec, X, Y);
|
||||
multiplyBuiltin<EltTy, R0, C0, C1>(ResBuiltin, X, Y);
|
||||
|
||||
- EXPECT_MATRIX_EQ(ResSpec, ResBuiltin, R0, C1);
|
||||
- EXPECT_MATRIX_EQ(ResBase, ResBuiltin, R0, C1);
|
||||
- EXPECT_MATRIX_EQ(ResBase, ResSpec, R0, C1);
|
||||
+ expectMatrixEQ(ResSpec, ResBuiltin, R0, C1);
|
||||
+ expectMatrixEQ(ResBase, ResBuiltin, R0, C1);
|
||||
+ expectMatrixEQ(ResBase, ResSpec, R0, C1);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
--
|
||||
2.18.1
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
%global _binaries_in_noarch_packages_terminate_build %{nil}
|
||||
|
||||
%global rc_ver 1
|
||||
%global baserelease 0.2
|
||||
#%%global rc_ver 1
|
||||
%global baserelease 1
|
||||
%global test_suite_srcdir test-suite-%{version}%{?rc_ver:rc%{rc_ver}}.src.fedora
|
||||
|
||||
Name: llvm-test-suite
|
||||
|
|
@ -24,7 +24,6 @@ BuildArch: noarch
|
|||
|
||||
Patch0: 0001-Fix-extra-Python3-print-statements.patch
|
||||
Patch1: 0001-CLAMR-Fix-build-with-newer-glibc.patch
|
||||
Patch2: 0001-Fix-random-number-generation-and-floating-point-comp.patch
|
||||
|
||||
# We need python3-devel for pathfix.py.
|
||||
BuildRequires: python3-devel
|
||||
|
|
@ -76,6 +75,12 @@ cp -R %{_builddir}/%{test_suite_srcdir}/* %{buildroot}%{_datadir}/llvm-test-suit
|
|||
|
||||
|
||||
%changelog
|
||||
* Thu Oct 15 2020 sguelton@redhat.com - 11.0.0-1
|
||||
- Fix NVR
|
||||
|
||||
* Tue Oct 13 2020 sguelton@redhat.com - 11.0.0-0.3
|
||||
- llvm 11.0.0 - final release
|
||||
|
||||
* Wed Aug 19 2020 Tom Stellard <tstellar@redhat.com> - 11.0.0-0.2.rc1
|
||||
- Fix build failure with clang 11
|
||||
|
||||
|
|
|
|||
2
sources
2
sources
|
|
@ -1 +1 @@
|
|||
SHA512 (test-suite-11.0.0rc1.src.fedora.tar.xz) = 140460237e670dd8f1776ce1d278f40c5241b5fdaec0d753df8edd31d1f20b583baf43ec1bfbbcb8311620d1c8247ec07ad13dc338fab8b193771ae060ed1bc3
|
||||
SHA512 (test-suite-11.0.0.src.fedora.tar.xz) = fb53afd9b1fcae97f66611ec82ee9f6033494cf4965165d7a3b403f5301c62b8d32f7c289efc35526505bbfa209d1aafa1c59381766f5cf717e194cdaa452d81
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue