From 04b180cc79a7175a8b93bc17e03ed49918cc327a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 14 Nov 2025 17:40:07 +0100 Subject: [PATCH] Remove unused cycles/cycle-timer --- libs/ardour/ardour/cycle_timer.h | 65 -------- libs/ardour/ardour/cycles.h | 253 ------------------------------- libs/ardour/audioengine.cc | 2 +- libs/ardour/cycle_timer.cc | 79 ---------- libs/ardour/session_process.cc | 1 - libs/ardour/wscript | 1 - 6 files changed, 1 insertion(+), 400 deletions(-) delete mode 100644 libs/ardour/ardour/cycle_timer.h delete mode 100644 libs/ardour/ardour/cycles.h delete mode 100644 libs/ardour/cycle_timer.cc diff --git a/libs/ardour/ardour/cycle_timer.h b/libs/ardour/ardour/cycle_timer.h deleted file mode 100644 index 1b980177a3..0000000000 --- a/libs/ardour/ardour/cycle_timer.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2006-2015 Paul Davis - * Copyright (C) 2009-2012 Carl Hetherington - * Copyright (C) 2009 David Robillard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include -#include -#include - -#include "ardour/libardour_visibility.h" -#include "ardour/cycles.h" -#include "ardour/debug.h" - -float get_mhz (); - -class LIBARDOUR_API CycleTimer { - private: - static float cycles_per_usec; -#ifndef NDEBUG - cycles_t _entry; - cycles_t _exit; - std::string _name; -#endif - - public: - CycleTimer(const std::string& name) { -#ifndef NDEBUG - if (DEBUG_ENABLED (PBD::DEBUG::CycleTimers)) { - _name = name; - if (cycles_per_usec == 0) { - cycles_per_usec = get_mhz (); - } - _entry = get_cycles(); - } -#else - (void) name; -#endif - } - - ~CycleTimer() { -#ifndef NDEBUG - if (DEBUG_ENABLED (PBD::DEBUG::CycleTimers)) { - _exit = get_cycles(); - std::cerr << _name << ": " << (float) (_exit - _entry) / cycles_per_usec << " (" << _entry << ", " << _exit << ')' << std::endl; - } -#endif - } -}; diff --git a/libs/ardour/ardour/cycles.h b/libs/ardour/ardour/cycles.h deleted file mode 100644 index 4cfac2367a..0000000000 --- a/libs/ardour/ardour/cycles.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (C) 2005-2006 Taybin Rutkin - * Copyright (C) 2007-2008 Paul Davis - * Copyright (C) 2008-2011 David Robillard - * Copyright (C) 2012 Carl Hetherington - * Copyright (C) 2018-2019 Robin Gareus - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include - -#if defined(__i386__) || defined(__x86_64__) - -/* - * Standard way to access the cycle counter on i586+ CPUs. - * Currently only used on SMP. - * - * If you really have a SMP machine with i486 chips or older, - * compile for that, and this will just always return zero. - * That's ok, it just means that the nicer scheduling heuristics - * won't work for you. - * - * We only use the low 32 bits, and we'd simply better make sure - * that we reschedule before that wraps. Scheduling at least every - * four billion cycles just basically sounds like a good idea, - * regardless of how fast the machine is. - */ -typedef uint64_t cycles_t; - -#if defined(__x86_64__) - -#define rdtscll(lo, hi) \ - __asm__ __volatile__("rdtsc" : "=a" (lo), "=d" (hi)) - -static inline cycles_t get_cycles (void) -{ - cycles_t lo, hi; - - rdtscll(lo, hi); - return lo; -} - -#else - -#define rdtscll(val) \ -__asm__ __volatile__("rdtsc" : "=A" (val)) - -static inline cycles_t get_cycles (void) -{ - cycles_t ret; - - rdtscll(ret); - return ret & 0xffffffff; -} -#endif - -#elif defined(__powerpc64__) - -#ifdef __linux__ -#include -typedef uint64_t cycles_t; -static inline cycles_t get_cycles(void) -{ - return __ppc_get_timebase(); -} -#elif defined(__FreeBSD__) -typedef uint64_t cycles_t; -static inline cycles_t get_cycles(void) -{ - cycles_t tbr; - asm volatile("mfspr %0, 268" : "=r"(tbr)); - return tbr; -} -#endif - -#elif defined(__powerpc__) - -#define CPU_FTR_601 0x00000100 - -typedef uint32_t cycles_t; - -/* - * For the "cycle" counter we use the timebase lower half. - * Currently only used on SMP. - */ - -static inline cycles_t get_cycles(void) -{ - cycles_t ret = 0; - - __asm__ __volatile__( - "98: mftb %0\n" - "99:\n" - ".section __ftr_fixup,\"a\"\n" - " .long %1\n" - " .long 0\n" - " .long 98b\n" - " .long 99b\n" - ".previous" - : "=r" (ret) : "i" (CPU_FTR_601)); - return ret; -} - -#elif defined(__ia64__) -/* ia64 */ - -typedef uint32_t cycles_t; -static inline cycles_t -get_cycles (void) -{ - cycles_t ret; - __asm__ __volatile__ ("mov %0=ar.itc" : "=r"(ret)); - return ret; -} - -#elif defined(__alpha__) -/* alpha */ - -/* - * Standard way to access the cycle counter. - * Currently only used on SMP for scheduling. - * - * Only the low 32 bits are available as a continuously counting entity. - * But this only means we'll force a reschedule every 8 seconds or so, - * which isn't an evil thing. - */ - -typedef uint32_t cycles_t; -static inline cycles_t get_cycles (void) -{ - cycles_t ret; - __asm__ __volatile__ ("rpcc %0" : "=r"(ret)); - return ret; -} - -#elif defined(__s390__) -/* s390 */ - -typedef uint32_t long cycles_t; -static inline cycles_t get_cycles(void) -{ - cycles_t cycles; - __asm__("stck 0(%0)" : : "a" (&(cycles)) : "memory", "cc"); - return cycles >> 2; -} - -#elif defined(__hppa__) -/* hppa/parisc */ - -#define mfctl(reg) ({ \ - uint32_t cr; \ - __asm__ __volatile__( \ - "mfctl " #reg ",%0" : \ - "=r" (cr) \ - ); \ - cr; \ -}) - -typedef uint32_t cycles_t; -static inline cycles_t get_cycles (void) -{ - return mfctl(16); -} - -#elif defined(__mips__) -/* mips/mipsel */ - -/* - * Standard way to access the cycle counter. - * Currently only used on SMP for scheduling. - * - * Only the low 32 bits are available as a continuously counting entity. - * But this only means we'll force a reschedule every 8 seconds or so, - * which isn't an evil thing. - * - * We know that all SMP capable CPUs have cycle counters. - */ - -#define __read_32bit_c0_register(source, sel) \ -({ int __res; \ - if (sel == 0) \ - __asm__ __volatile__( \ - "mfc0\t%0, " #source "\n\t" \ - : "=r" (__res)); \ - else \ - __asm__ __volatile__( \ - ".set\tmips32\n\t" \ - "mfc0\t%0, " #source ", " #sel "\n\t" \ - ".set\tmips0\n\t" \ - : "=r" (__res)); \ - __res; \ -}) - -/* #define CP0_COUNT $9 */ -#define read_c0_count() __read_32bit_c0_register($9, 0) - -typedef uint32_t cycles_t; -static inline cycles_t get_cycles (void) -{ - return read_c0_count(); -} - -/* begin mach */ -#elif defined(__APPLE__) - -#include - -typedef UInt64 cycles_t; -static inline cycles_t get_cycles (void) -{ - UInt64 time = AudioGetCurrentHostTime(); - return AudioConvertHostTimeToNanos(time); -} -/* end mach */ - -#else - -/* debian: sparc, arm, m68k */ - -#ifndef COMPILER_MSVC -/* GRRR... Annoyingly, #warning aborts the compilation for MSVC !! */ -#warning You are compiling libardour on a platform for which ardour/cycles.h needs work -#endif - -#include - -typedef long cycles_t; - -static inline cycles_t get_cycles(void) -{ - struct timeval tv; - gettimeofday (&tv, NULL); - - return tv.tv_usec; -} - -#endif - diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 4032da8e21..bf4ef28765 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -54,7 +54,7 @@ #include "ardour/audioengine.h" #include "ardour/search_paths.h" #include "ardour/buffer.h" -#include "ardour/cycle_timer.h" +#include "ardour/debug.h" #include "ardour/internal_send.h" #include "ardour/meter.h" #include "ardour/midi_port.h" diff --git a/libs/ardour/cycle_timer.cc b/libs/ardour/cycle_timer.cc deleted file mode 100644 index 7d094cddd1..0000000000 --- a/libs/ardour/cycle_timer.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2006-2016 Paul Davis - * Copyright (C) 2009 David Robillard - * Copyright (C) 2014-2015 Robin Gareus - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include "pbd/error.h" -#include "ardour/cycle_timer.h" - -#include "ardour/libardour_visibility.h" - -#include "pbd/i18n.h" - -using namespace std; -using namespace PBD; - -float CycleTimer::cycles_per_usec = 0; - -float -get_mhz() -{ - FILE *f; - - if ((f = fopen("/proc/cpuinfo", "r")) == 0) { - fatal << _("CycleTimer::get_mhz(): can't open /proc/cpuinfo") << endmsg; - abort(); /*NOTREACHED*/ - return 0.0f; - } - - while (true) { - - float mhz; - int ret; - char buf[1000]; - - if (fgets (buf, sizeof(buf), f) == 0) { - fatal << _("CycleTimer::get_mhz(): cannot locate cpu MHz in /proc/cpuinfo") << endmsg; - abort(); /*NOTREACHED*/ - return 0.0f; - } - -#ifdef __powerpc__ - - int imhz; - - /* why can't the PPC crew standardize their /proc/cpuinfo format ? */ - ret = sscanf (buf, "clock\t: %dMHz", &imhz); - mhz = (float) imhz; - -#else /* XXX don't assume its x86 just because its not power pc */ - ret = sscanf (buf, "cpu MHz : %f", &mhz); - -#endif - if (ret == 1) { - fclose(f); - return mhz; - } - } - - fatal << _("cannot locate cpu MHz in /proc/cpuinfo") << endmsg; - abort(); /*NOTREACHED*/ - return 0.0f; -} diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index f9f61b4216..a1983cc76e 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -38,7 +38,6 @@ #include "ardour/audioengine.h" #include "ardour/auditioner.h" #include "ardour/butler.h" -#include "ardour/cycle_timer.h" #include "ardour/debug.h" #include "ardour/disk_reader.h" #include "ardour/graph.h" diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 9d24a5ae78..9efa0b9bbe 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -53,7 +53,6 @@ libardour_sources = [ 'control_group.cc', 'control_protocol_manager.cc', 'convolver.cc', - 'cycle_timer.cc', 'data_type.cc', 'default_click.cc', 'debug.cc',