something I periodically want is timeouts that -- for a particular version of a piece of software -- are deterministic across platforms. this would be accomplished with a simple compiler pass that increments and checks a counter at every back edge and function return. anyone know if this exists for LLVM, or do I need to write it?
@regehr
Polish Olympiad in Informatics used to do something like this for already-compiled programs using Intel's pintools. Sadly, I can't find sources for the thing (for some reason there was a separate repository with binaries and all the scripts given to contestants, which I did find at https://github.com/olimpiada/oitimetool-bin).
Ah, it seems that the new version also has some such functionality, but seemingly using perf counters: https://github.com/sio2project/sio2jail/tree/master/src/perf
@robryk it it's actually counting user-mode instructions it'll work! I'll investigate
@robryk oh wow, so there is an instruction count limit! that might solve my problem right there, thanks!
Yeah, both of these versions implemented an instrument count limit in some form. The pintool-based one had pin rewrite (valgrind-style) the program so that each basic block incremented some counter. The new one seemingly uses performance counters to count (which is probably not exact in some silly way -- e.g. I would expect there to be some slop around context switching).
(I'm somewhat surprised they still use instruction counting, given that it caused very unrealistic handling of any cache effects.)
@robryk for sure. performance portability is super hard on modern platforms!
@regehr
But that's probably not actually deterministic enough for you~