]> git.pld-linux.org Git - packages/highway.git/commitdiff
- added rdtscp patch from git (disable nanobenchmark on CPUs without rdtscp instruction)
authorJakub Bogusz <qboosh@pld-linux.org>
Tue, 5 Oct 2021 20:19:43 +0000 (22:19 +0200)
committerJakub Bogusz <qboosh@pld-linux.org>
Tue, 5 Oct 2021 20:19:43 +0000 (22:19 +0200)
highway-rdtscp.patch [new file with mode: 0644]
highway.spec

diff --git a/highway-rdtscp.patch b/highway-rdtscp.patch
new file mode 100644 (file)
index 0000000..edf2e73
--- /dev/null
@@ -0,0 +1,44 @@
+From 4a57d62e1d87d8c80bbea34fa0e2d27bc8f6b885 Mon Sep 17 00:00:00 2001
+From: Jan Wassenberg <janwas@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
index cdf65265ae4bc344409c84208e6881382292f717..f8b4f6142deabb620f47dc5a9cc1640a0e19d0ad 100644 (file)
@@ -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
This page took 0.154879 seconds and 4 git commands to generate.