4 ms·
> Considering each BrainFuck command on average takes 5 or more assembly instructions to implement, even assuming a perfect 1 instructions per s
by zokier 9y ago
> Considering each BrainFuck command
on average takes 5 or more assembly instructions to implement,
even assuming a perfect 1 instructions per second on a 3GHz
processor, it would require almost one hundred cores to compete
with this performance
I assume the authors intended to mean "1 instructions per cycle" here, but even with that amendment isn't that pretty poor performance for modern CPU? I was under the impression that modern CPUs have peak performance way above 1 IPC, although if that is realizable with BF interpreter is another question. It would have been nice to see comparison to some reasonably high-performance BF compiler.
- DSingularity 9y agoNot way above, but yes. We use simultaneous multi threading and out of order execution to enable superscalar execution I.e >1 instruction per cycle. But it’s not likely to be more than 2-3 for a variety of reasons.
- monocasa 9y agoJust adding that you can be superscalar, while not being out of order or multithreaded. The Xbox 360's cores fit that model, as well as the original Pentium. They'll execute multiple instructions, but will serialize if there are dependencies (or other constraints that are uarch specific).
- deepnotderp 9y agoBecause of a number of factors, mostly to do with memory latency, modern superscalar OoOs achieve ~2, sometimes 3 IPC, so not "way above".
- cornholio 9y agoRegardless of the IPC level, 5 CISC instructions for 1 BF instruction sounds exceptional low, it's something that an 200 bytes naive compiler would produce. An optimizing compiler capable of generating the full gamut of x86 instructions would increase the IPC by at least one order of magnitude, the majority of BF code are boilerplate structures that set up loops, move data around, repeated increments to generate constants etc. Being a very simple language with limited and well defined side effects, it lends itself exceptionally well to reordering.