android-riscv64 icon indicating copy to clipboard operation
android-riscv64 copied to clipboard

llvm function multi-versioning

Open enh-google opened this issue 2 years ago • 7 comments

related to but distinct from https://github.com/google/android-riscv64/issues/8, we'll want function multi-versioning in llvm.

enh-google avatar Mar 08 '23 00:03 enh-google

Is this issue related to the multi-versioning feature itself or to function optimization that supports different instruction set extensions?

MaoHan001 avatar Mar 22 '23 09:03 MaoHan001

Is this issue related to the multi-versioning feature itself or to function optimization that supports different instruction set extensions?

the former --- we don't expect this to be useful for OS developers, but -- especially because riscv64 might unfortuntely end up more fragmented than other architectures in the long term -- this might be helpful for third-party library/app developers. (our experience with the existing architectures is that ifuncs are too much trouble for all but the absolute most performance-conscious. we hope -- but don't know yet, because llvm's fmv functionality for arm64 is too new, and no developers really care about x86-64 -- that fmv will help.)

enh-google avatar Mar 22 '23 14:03 enh-google

ifuncs are too much trouble [...] fmv will help

To the best of my knowledge, function multiversioning in both LLVM and GCC is implemented using GNU indirect functions. So this ticket could be considered blocked on #8.

nick-knight avatar Mar 22 '23 18:03 nick-knight

This is referring something like this? https://gcc.gnu.org/wiki/FunctionMultiVersioning

kito-cheng avatar Mar 23 '23 00:03 kito-cheng

Yes. As usual, @maskray's blog has useful info: https://maskray.me/blog/2023-02-05-function-multi-versioning

nick-knight avatar Mar 23 '23 00:03 nick-knight

(fwiw, in terms of prioritization -- which i know is on everyone's minds right now -- i think fmv is a thing for after you have an ecosystem, and you're starting to see fragmentation in terms of extension availability, and how you can help bring the cost of dealing with that down for app developers. because otherwise the traditional default is "target the lowest available [since i have to support that anyway], leave any extra performance lying on the table [because i can't afford the extra development or testing costs]". fmv doesn't help with the testing costs -- which are admittedly the dominating factor for all developers -- but it does at least bring the development costs way down relative to ifuncs or messing around with cpu feature detection directly. x86-64 has had this for a long time, but arm64 only just gained it. riscv64 can probably punt this to the late 2020s, but it's on the list for feature parity.)

enh-google avatar Mar 23 '23 15:03 enh-google

Kito filed an issue here https://github.com/riscv-non-isa/riscv-c-api-doc/pull/35

topperc avatar Apr 06 '23 00:04 topperc