Before I dig too deeply into the code, has anyone done any investigation or work on porting to say CP/M for Z80?
I'd recommend against that; TOPBENCH was deliberately designed for x86 systems only, to create a synthetic score to use as a means to compare different x86 CPUs against each other based only on the time it takes for their instruction opcodes to execute in various situations. It was never meant to be portable to other CPU architectures or environments. If you want something to compare across all systems, a more generic workload-only benchmark would be more appropriate; see below:
But I've wondered about a more universal and non-PC-capable benchmark that could at least make a reasonably-close comparison between architectures (like the Byte Unix benchmarks do for the old-school Unix world).
The "problem" with that is that if you create a portable piece of code, it is possible for that code to be compiled differently depending on what compiler is used (even if all the compilers you try are for the same architecture). That's why the TOPBENCH metric code was written in assembler. With very few and irrelevant exceptions, the code assembles the same no matter the assembler.
And I know the difficulty of cross-arch benchmarking; but, again, the Byte Unixbench suite did that pretty successfully for the very architecture-diverse Unix world (successfully comparing performance between a VAX, a 68K workstation, and SPARC).
I'd say try porting that, except it contains a ton of unix-centric system calls (exec(), pipe-based context switching, etc.), as well as I/O-limited stuff (copying a file), so that won't be portable across all systems. It's portable across all UNIX systems, yes, but not all systems.
If I were you, making a benchmark to compare across all systems, I'd do the following:
- Pick some common benchmark workloads (dhrystone, whetstone, etc.)
- Determine if you are measuring the performance of the hardware only, or the entire system (hardware+OS+I/O)
- ..If hardware only, describe the workload in pseudocode but allow anyone to write an optimized version of it for a CPU (maybe even in assembler) so that the CPU isn't penalized by bad compilers
- ..If entire system, write portable C code
Here is a recent
resurrection of the Byte Unixbench; it contains both a dhrystone and a whetstone, so maybe those could be lifted.
TOPBENCH uses some DMA hack to determine the CPU speed.
It's nothing that heinous; TOPBENCH reprograms the INT 08 PIT interrupt to fire at 20Hz instead of 18.2Hz so that the time measurements are done with integers in milliseconds, then it programs it back so that DOS time doesn't skew too much. In retrospect, this was unnecessary; I could have gotten the same accuracy if I had just monitored the 8253 timer value ports. Oh well, can't change it now without potentially invalidating the numbers in the database.