Remove unused cycles/cycle-timer

This commit is contained in:
Robin Gareus 2025-11-14 17:40:07 +01:00
parent fa319ffda2
commit 04b180cc79
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
6 changed files with 1 additions and 400 deletions

View file

@ -1,65 +0,0 @@
/*
* Copyright (C) 2006-2015 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2009 David Robillard <d@drobilla.net>
*
* 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 <string>
#include <iostream>
#include <cstdlib>
#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
}
};

View file

@ -1,253 +0,0 @@
/*
* Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
* Copyright (C) 2007-2008 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
* Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2018-2019 Robin Gareus <robin@gareus.org>
*
* 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 <stdint.h>
#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 <sys/platform/ppc.h>
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 <CoreAudio/HostTime.h>
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 <sys/time.h>
typedef long cycles_t;
static inline cycles_t get_cycles(void)
{
struct timeval tv;
gettimeofday (&tv, NULL);
return tv.tv_usec;
}
#endif

View file

@ -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"

View file

@ -1,79 +0,0 @@
/*
* Copyright (C) 2006-2016 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2009 David Robillard <d@drobilla.net>
* Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
*
* 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 <cstdio>
#include <fstream>
#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;
}

View file

@ -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"

View file

@ -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',