summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <[email protected]>2024-06-11 16:27:12 +0200
committerEdward Welbourne <[email protected]>2024-07-17 12:32:46 +0200
commit6e7c158152cef6a1ae6a628f08661fcc4b27de90 (patch)
tree870f55fb5bfa4bc4fd2a755587c7e393cb24914d
parentd8bd4c2306f2acfefc75f8163b58f2037596dc65 (diff)
Update benchlib's 3rdparty cycle counter to FFTW v3.3.10
Document cycle_p.h's provenance - thanks to Morten Sørvig for digging that up - and update to its version in the most recent release of FFTW. Include patches to apply (after purging dangling hspace) for future updates. [ChangeLog][Third-Party Code] QtTest's benchlib now uses FFTW v3.3.10's version of the clock-cycle counter, Cycle. Pick-to: 6.8 Task-number: QTBUG-126080 Change-Id: Ib59bc53e5d74cfdc889c03e78f9dd72100168f64 Reviewed-by: Jason McDonald <[email protected]>
-rw-r--r--src/testlib/3rdparty/cycle/00-include-guard.patch20
-rw-r--r--src/testlib/3rdparty/cycle/01-rename-ticks.patch18
-rw-r--r--src/testlib/3rdparty/cycle/02-preprocesor-checks.patch36
-rw-r--r--src/testlib/3rdparty/cycle/03-parisc-compile.patch28
-rw-r--r--src/testlib/3rdparty/cycle/cycle_p.h165
-rw-r--r--src/testlib/3rdparty/cycle/qt_attribution.json18
6 files changed, 239 insertions, 46 deletions
diff --git a/src/testlib/3rdparty/cycle/00-include-guard.patch b/src/testlib/3rdparty/cycle/00-include-guard.patch
new file mode 100644
index 00000000000..61339433faf
--- /dev/null
+++ b/src/testlib/3rdparty/cycle/00-include-guard.patch
@@ -0,0 +1,20 @@
+diff --git a/src/testlib/3rdparty/cycle/cycle_p.h b/src/testlib/3rdparty/cycle/cycle_p.h
+index 6750b25d42..52d80d4b97 100644
+--- a/src/testlib/3rdparty/cycle/cycle_p.h
++++ b/src/testlib/3rdparty/cycle/cycle_p.h
+@@ -76,6 +76,9 @@
+ dnl ---------------------------------------------------------------------
+ */
+
++#ifndef QBENCHLIB_CYCLE_H
++#define QBENCHLIB_CYCLE_H
++
+ /***************************************************************************/
+
+ #if TIME_WITH_SYS_TIME
+@@ -562,3 +565,5 @@ static inline ticks getticks(void)
+ INLINE_ELAPSED(inline)
+ #define HAVE_TICK_COUNTER
+ #endif
++
++#endif // QBENCHLIB_CYCLE_H
diff --git a/src/testlib/3rdparty/cycle/01-rename-ticks.patch b/src/testlib/3rdparty/cycle/01-rename-ticks.patch
new file mode 100644
index 00000000000..ac76d5de9b7
--- /dev/null
+++ b/src/testlib/3rdparty/cycle/01-rename-ticks.patch
@@ -0,0 +1,18 @@
+diff --git a/src/testlib/3rdparty/cycle/cycle_p.h b/src/testlib/3rdparty/cycle/cycle_p.h
+index 363e91843a..430f1be446 100644
+--- a/src/testlib/3rdparty/cycle/cycle_p.h
++++ b/src/testlib/3rdparty/cycle/cycle_p.h
+@@ -78,6 +78,7 @@
+
+ #ifndef QBENCHLIB_CYCLE_H
+ #define QBENCHLIB_CYCLE_H
++#define ticks CycleCounterTicks
+
+ /***************************************************************************/
+
+@@ -570,4 +571,5 @@ INLINE_ELAPSED(inline)
+ #define HAVE_TICK_COUNTER
+ #endif
+
++#undef ticks
+ #endif // QBENCHLIB_CYCLE_H
diff --git a/src/testlib/3rdparty/cycle/02-preprocesor-checks.patch b/src/testlib/3rdparty/cycle/02-preprocesor-checks.patch
new file mode 100644
index 00000000000..6916c507c00
--- /dev/null
+++ b/src/testlib/3rdparty/cycle/02-preprocesor-checks.patch
@@ -0,0 +1,36 @@
+diff --git a/src/testlib/3rdparty/cycle/cycle_p.h b/src/testlib/3rdparty/cycle/cycle_p.h
+index eb81ca1444..617ac107b6 100644
+--- a/src/testlib/3rdparty/cycle/cycle_p.h
++++ b/src/testlib/3rdparty/cycle/cycle_p.h
+@@ -190,6 +190,7 @@ INLINE_ELAPSED(__inline__)
+ #endif
+
+ /* Visual C++ -- thanks to Morten Nissov for his help with this */
++#ifdef _MSC_VER
+ #if _MSC_VER >= 1200 && _M_IX86 >= 500 && !defined(HAVE_TICK_COUNTER)
+ #include <windows.h>
+ typedef LARGE_INTEGER CycleCounterTicks;
+@@ -215,6 +216,7 @@ static __inline double elapsed(CycleCounterTicks t1, CycleCounterTicks t0)
+ #define HAVE_TICK_COUNTER
+ #define TIME_MIN 5000.0 /* unreliable pentium IV cycle counter */
+ #endif
++#endif // _MSC_VER
+
+ /*----------------------------------------------------------------*/
+ /*
+@@ -251,6 +253,7 @@ INLINE_ELAPSED(__inline__)
+ #endif
+
+ /* Visual C++, courtesy of Dirk Michaelis */
++#ifdef _MSC_VER
+ #if _MSC_VER >= 1400 && (defined(_M_AMD64) || defined(_M_X64)) && !defined(HAVE_TICK_COUNTER)
+
+ #include <intrin.h>
+@@ -262,6 +265,7 @@ INLINE_ELAPSED(__inline)
+ #define HAVE_TICK_COUNTER
+ #define TIME_MIN 5000.0
+ #endif
++#endif // _MSC_VER
+
+ /*----------------------------------------------------------------*/
+ /*
diff --git a/src/testlib/3rdparty/cycle/03-parisc-compile.patch b/src/testlib/3rdparty/cycle/03-parisc-compile.patch
new file mode 100644
index 00000000000..3e6c5a2d4a7
--- /dev/null
+++ b/src/testlib/3rdparty/cycle/03-parisc-compile.patch
@@ -0,0 +1,28 @@
+diff --git a/src/testlib/3rdparty/cycle/cycle_p.h b/src/testlib/3rdparty/cycle/cycle_p.h
+index 430f1be446..f281c55d48 100644
+--- a/src/testlib/3rdparty/cycle/cycle_p.h
++++ b/src/testlib/3rdparty/cycle/cycle_p.h
+@@ -361,7 +361,11 @@ static __inline__ ticks getticks(void)
+ /* no input, nothing else clobbered */
+ return ret;
+ }
+-# else
++
++INLINE_ELAPSED(inline)
++
++#define HAVE_TICK_COUNTER
++# elif 0 // Doesn't compile
+ # include <machine/inline.h>
+ static inline unsigned long getticks(void)
+ {
+@@ -370,10 +374,6 @@ static inline unsigned long getticks(void)
+ return ret;
+ }
+ # endif
+-
+-INLINE_ELAPSED(inline)
+-
+-#define HAVE_TICK_COUNTER
+ #endif
+
+ /*----------------------------------------------------------------*/
diff --git a/src/testlib/3rdparty/cycle/cycle_p.h b/src/testlib/3rdparty/cycle/cycle_p.h
index 44d7b704368..f281c55d48f 100644
--- a/src/testlib/3rdparty/cycle/cycle_p.h
+++ b/src/testlib/3rdparty/cycle/cycle_p.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2003, 2006 Matteo Frigo
- * Copyright (c) 2003, 2006 Massachusetts Institute of Technology
+ * Copyright (c) 2003, 2007-14 Matteo Frigo
+ * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -23,7 +23,6 @@
*
*/
-/* $Id: cycle.h,v 1.52 2006-02-08 02:36:47 athena Exp $ */
/* machine-dependent cycle counters code. Needs to be inlined. */
@@ -96,7 +95,7 @@
#define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \
{ \
- return (double)(t1 - t0); \
+ return (double)t1 - (double)t0; \
}
/*----------------------------------------------------------------*/
@@ -116,18 +115,19 @@ INLINE_ELAPSED(inline)
#if defined(HAVE_READ_REAL_TIME) && defined(HAVE_TIME_BASE_TO_TIME) && !defined(HAVE_TICK_COUNTER)
typedef timebasestruct_t ticks;
-static inline ticks getticks(void)
+static __inline ticks getticks(void)
{
ticks t;
read_real_time(&t, TIMEBASE_SZ);
return t;
}
-static inline double elapsed(ticks t1, ticks t0) /* time in nanoseconds */
+static __inline double elapsed(ticks t1, ticks t0) /* time in nanoseconds */
{
time_base_to_time(&t1, TIMEBASE_SZ);
time_base_to_time(&t0, TIMEBASE_SZ);
- return ((t1.tb_high - t0.tb_high) * 1e9 + (t1.tb_low - t0.tb_low));
+ return (((double)t1.tb_high - (double)t0.tb_high) * 1.0e9 +
+ ((double)t1.tb_low - (double)t0.tb_low));
}
#define HAVE_TICK_COUNTER
@@ -137,7 +137,7 @@ static inline double elapsed(ticks t1, ticks t0) /* time in nanoseconds */
/*
* PowerPC ``cycle'' counter using the time base register.
*/
-#if ((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || (defined(__MWERKS__) && defined(macintosh))) && !defined(HAVE_TICK_COUNTER)
+#if ((((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || (defined(__MWERKS__) && defined(macintosh)))) || (defined(__IBM_GCC_ASM) && (defined(__powerpc__) || defined(__ppc__)))) && !defined(HAVE_TICK_COUNTER)
typedef unsigned long long ticks;
static __inline__ ticks getticks(void)
@@ -191,8 +191,8 @@ INLINE_ELAPSED(__inline__)
#endif
/* Visual C++ -- thanks to Morten Nissov for his help with this */
-#if defined(_MSC_VER)
-#if _MSC_VER >= 1200 && (_M_IX86 >= 500 || (defined(_WIN32_WCE) && defined(_X86_))) && !defined(HAVE_TICK_COUNTER)
+#ifdef _MSC_VER
+#if _MSC_VER >= 1200 && _M_IX86 >= 500 && !defined(HAVE_TICK_COUNTER)
#include <windows.h>
typedef LARGE_INTEGER ticks;
#define RDTSC __asm __emit 0fh __asm __emit 031h /* hack for VC++ 5.0 */
@@ -202,58 +202,41 @@ static __inline ticks getticks(void)
ticks retval;
__asm {
- RDTSC
- mov retval.HighPart, edx
- mov retval.LowPart, eax
+ RDTSC
+ mov retval.HighPart, edx
+ mov retval.LowPart, eax
}
return retval;
}
static __inline double elapsed(ticks t1, ticks t0)
{
- return (double)(t1.QuadPart - t0.QuadPart);
+ return (double)t1.QuadPart - (double)t0.QuadPart;
}
#define HAVE_TICK_COUNTER
#define TIME_MIN 5000.0 /* unreliable pentium IV cycle counter */
#endif
-#endif
-
-#if _MSC_VER >= 1400 && defined(_WIN32_WCE) && !defined(HAVE_TICK_COUNTER)
-#include <windows.h>
-typedef DWORD ticks;
-
-static __inline ticks getticks(void)
-{
- return GetTickCount();
-}
-
-static __inline double elapsed(ticks t1, ticks t0)
-{
- return (double)(t1 - t0);
-}
-
-#define HAVE_TICK_COUNTER
-#define TIME_MIN 5000.0
-#endif
+#endif // _MSC_VER
/*----------------------------------------------------------------*/
/*
* X86-64 cycle counter
*/
-#if (defined(__GNUC__) || defined(__ICC)) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER)
+#if (defined(__GNUC__) || defined(__ICC) || defined(__SUNPRO_C)) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER)
typedef unsigned long long ticks;
static __inline__ ticks getticks(void)
{
unsigned a, d;
- asm volatile("rdtsc" : "=a" (a), "=d" (d));
+ __asm__ __volatile__ ("rdtsc" : "=a" (a), "=d" (d));
return ((ticks)a) | (((ticks)d) << 32);
}
INLINE_ELAPSED(__inline__)
#define HAVE_TICK_COUNTER
+#define TIME_MIN 5000.0
#endif
/* PGI compiler, courtesy Cristiano Calonaci, Andrea Tarsi, & Roberto Gori.
@@ -267,20 +250,23 @@ static ticks getticks(void)
}
INLINE_ELAPSED(__inline__)
#define HAVE_TICK_COUNTER
+#define TIME_MIN 5000.0
#endif
-/* Visual C++ */
+/* Visual C++, courtesy of Dirk Michaelis */
+#ifdef _MSC_VER
#if _MSC_VER >= 1400 && (defined(_M_AMD64) || defined(_M_X64)) && !defined(HAVE_TICK_COUNTER)
-#include <intrin.h>
+#include <intrin.h>
+#pragma intrinsic(__rdtsc)
typedef unsigned __int64 ticks;
-
#define getticks __rdtsc
-
INLINE_ELAPSED(__inline)
#define HAVE_TICK_COUNTER
+#define TIME_MIN 5000.0
#endif
+#endif // _MSC_VER
/*----------------------------------------------------------------*/
/*
@@ -354,6 +340,8 @@ static __inline ticks getticks(void)
return temp;
}
+INLINE_ELAPSED(inline)
+
#define HAVE_TICK_COUNTER
#endif
@@ -377,7 +365,6 @@ static __inline__ ticks getticks(void)
INLINE_ELAPSED(inline)
#define HAVE_TICK_COUNTER
-
# elif 0 // Doesn't compile
# include <machine/inline.h>
static inline unsigned long getticks(void)
@@ -387,7 +374,6 @@ static inline unsigned long getticks(void)
return ret;
}
# endif
-
#endif
/*----------------------------------------------------------------*/
@@ -460,7 +446,7 @@ INLINE_ELAPSED(__inline)
#endif
/*----------------------------------------------------------------*/
/* SGI/Irix */
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER)
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER) && !defined(__ANDROID__)
typedef struct timespec ticks;
static inline ticks getticks(void)
@@ -472,8 +458,8 @@ static inline ticks getticks(void)
static inline double elapsed(ticks t1, ticks t0)
{
- return (double)(t1.tv_sec - t0.tv_sec) * 1.0E9 +
- (double)(t1.tv_nsec - t0.tv_nsec);
+ return ((double)t1.tv_sec - (double)t0.tv_sec) * 1.0E9 +
+ ((double)t1.tv_nsec - (double)t0.tv_nsec);
}
#define HAVE_TICK_COUNTER
#endif
@@ -494,5 +480,96 @@ INLINE_ELAPSED(inline)
#define HAVE_TICK_COUNTER
#endif
+/*----------------------------------------------------------------*/
+/* MIPS ZBus */
+#if HAVE_MIPS_ZBUS_TIMER
+#if defined(__mips__) && !defined(HAVE_TICK_COUNTER)
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+typedef uint64_t ticks;
+
+static inline ticks getticks(void)
+{
+ static uint64_t* addr = 0;
+
+ if (addr == 0)
+ {
+ uint32_t rq_addr = 0x10030000;
+ int fd;
+ int pgsize;
+
+ pgsize = getpagesize();
+ fd = open ("/dev/mem", O_RDONLY | O_SYNC, 0);
+ if (fd < 0) {
+ perror("open");
+ return NULL;
+ }
+ addr = mmap(0, pgsize, PROT_READ, MAP_SHARED, fd, rq_addr);
+ close(fd);
+ if (addr == (uint64_t *)-1) {
+ perror("mmap");
+ return NULL;
+ }
+ }
+
+ return *addr;
+}
+
+INLINE_ELAPSED(inline)
+
+#define HAVE_TICK_COUNTER
+#endif
+#endif /* HAVE_MIPS_ZBUS_TIMER */
+
+#if defined(HAVE_ARMV7A_CNTVCT)
+typedef uint64_t ticks;
+static inline ticks getticks(void)
+{
+ uint32_t Rt, Rt2 = 0;
+ asm volatile("mrrc p15, 1, %0, %1, c14" : "=r"(Rt), "=r"(Rt2));
+ return ((uint64_t)Rt) | (((uint64_t)Rt2) << 32);
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif
+
+#if defined(HAVE_ARMV7A_PMCCNTR)
+typedef uint64_t ticks;
+static inline ticks getticks(void)
+{
+ uint32_t r;
+ asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) );
+ return r;
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif
+
+#if defined(__aarch64__) && defined(HAVE_ARMV8_CNTVCT_EL0) && !defined(HAVE_ARMV8_PMCCNTR_EL0)
+typedef uint64_t ticks;
+static inline ticks getticks(void)
+{
+ uint64_t Rt;
+ asm volatile("mrs %0, CNTVCT_EL0" : "=r" (Rt));
+ return Rt;
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif
+
+#if defined(__aarch64__) && defined(HAVE_ARMV8_PMCCNTR_EL0)
+typedef uint64_t ticks;
+static inline ticks getticks(void)
+{
+ uint64_t cc = 0;
+ asm volatile("mrs %0, PMCCNTR_EL0" : "=r"(cc));
+ return cc;
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif
+
#undef ticks
#endif // QBENCHLIB_CYCLE_H
diff --git a/src/testlib/3rdparty/cycle/qt_attribution.json b/src/testlib/3rdparty/cycle/qt_attribution.json
index 1eb932b42f7..89773e39c7e 100644
--- a/src/testlib/3rdparty/cycle/qt_attribution.json
+++ b/src/testlib/3rdparty/cycle/qt_attribution.json
@@ -4,13 +4,27 @@
"Name": "Cycle",
"QDocModule": "qttestlib",
"QtUsage": "Used in the Qt Test module.",
+ "Comment": { "Upstream": "https://github.com/FFTW/fftw3",
+ "File": "kernel/cycle.h",
+ "Prepare": "Purge dangling hspace on ends of lines",
+ "Patches": [
+ "00-include-guard.patch",
+ "01-rename-ticks.patch",
+ "02-preprocesor-checks.patch",
+ "03-parisc-compile.patch"
+ ]
+ },
"Files": "cycle_p.h",
"Description": "Allows to access the CPU's cycle counters.",
+ "Homepage": "http://fftw.org/",
+ "Version": "3.3.10",
"License": "MIT License",
"LicenseId": "MIT",
"LicenseFile": "LICENSE.txt",
- "Copyright": ["Copyright (c) 2003, 2006 Matteo Frigo",
- "Copyright (c) 2003, 2006 Massachusetts Institute of Technology"]
+ "Copyright": [
+ "Copyright (c) 2003, 2007-14 Matteo Frigo",
+ "Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology"
+ ]
}
]