[packages/highway] - added rdtscp patch from git (disable nanobenchmark on CPUs without rdtscp instruction)

qboosh qboosh at pld-linux.org
Tue Oct 5 22:14:51 CEST 2021


commit 72d60b3872a1c08cb02d51f5078ffdff4d7bf08f
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Tue Oct 5 22:19:43 2021 +0200

    - added rdtscp patch from git (disable nanobenchmark on CPUs without rdtscp instruction)

 highway-rdtscp.patch | 44 ++++++++++++++++++++++++++++++++++++++++++++
 highway.spec         |  3 +++
 2 files changed, 47 insertions(+)
---
diff --git a/highway.spec b/highway.spec
index cdf6526..f8b4f61 100644
--- a/highway.spec
+++ b/highway.spec
@@ -12,6 +12,8 @@ Group:		Libraries
 #Source0Download: https://github.com/google/highway/releases
 Source0:	https://github.com/google/highway/archive/%{version}/%{name}-%{version}.tar.gz
 # Source0-md5:	4821b1064a35baa24ea36994c0d58c41
+# https://github.com/google/highway/commit/4a57d62e1d87d8c80bbea34fa0e2d27bc8f6b885.patch
+Patch0:		%{name}-rdtscp.patch
 URL:		https://github.com/google/highway
 BuildRequires:	cmake >= 3.10
 BuildRequires:	gtest-devel
@@ -58,6 +60,7 @@ Dokumentacja API biblioteki Highway.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 install -d build
diff --git a/highway-rdtscp.patch b/highway-rdtscp.patch
new file mode 100644
index 0000000..edf2e73
--- /dev/null
+++ b/highway-rdtscp.patch
@@ -0,0 +1,44 @@
+From 4a57d62e1d87d8c80bbea34fa0e2d27bc8f6b885 Mon Sep 17 00:00:00 2001
+From: Jan Wassenberg <janwas at google.com>
+Date: Wed, 1 Sep 2021 02:49:11 -0700
+Subject: [PATCH] skip nanobenchmarks if rdtscp is not supported. Refs
+ https://github.com/libjxl/libjxl/issues/408, thanks @error256
+
+PiperOrigin-RevId: 394187316
+---
+ hwy/nanobenchmark.cc | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/hwy/nanobenchmark.cc b/hwy/nanobenchmark.cc
+index 8e00cca..91c5713 100644
+--- a/hwy/nanobenchmark.cc
++++ b/hwy/nanobenchmark.cc
+@@ -353,6 +353,12 @@ void Cpuid(const uint32_t level, const uint32_t count,
+ #endif
+ }
+ 
++bool HasRDTSCP() {
++  uint32_t abcd[4];
++  Cpuid(0x80000001U, 0, abcd);         // Extended feature flags
++  return (abcd[3] & (1u << 27)) != 0;  // RDTSCP
++}
++
+ std::string BrandString() {
+   char brand_string[49];
+   std::array<uint32_t, 4> abcd;
+@@ -647,6 +653,15 @@ int Unpredictable1() { return timer::Start() != ~0ULL; }
+ size_t Measure(const Func func, const uint8_t* arg, const FuncInput* inputs,
+                const size_t num_inputs, Result* results, const Params& p) {
+   NANOBENCHMARK_CHECK(num_inputs != 0);
++
++#if HWY_ARCH_X86
++  if (!platform::HasRDTSCP()) {
++    fprintf(stderr, "CPU '%s' does not support RDTSCP, skipping benchmark.\n",
++            platform::BrandString().c_str());
++    return 0;
++  }
++#endif
++
+   const InputVec& unique = UniqueInputs(inputs, num_inputs);
+ 
+   const size_t num_skip = NumSkip(func, arg, unique, p);  // never 0
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/highway.git/commitdiff/72d60b3872a1c08cb02d51f5078ffdff4d7bf08f



More information about the pld-cvs-commit mailing list