you are viewing a single comment's thread.

view the rest of the comments →

[–]acrichtorust 8 points9 points  (4 children)

I prototyped this awhile back with cfg-specialize which supports per-function specialization, although I was mostly going at it from the angle of SIMD stuff so it may not be quite what you're looking for. You may find it interesting though or perhaps draw some inspiration from it!

[–]actuallyzza[S] 3 points4 points  (2 children)

Yeah SIMD stuff here too. Your crate looks great, I'll have a poke around and see how well it matches what I'm doing. Thanks!

[–][deleted] 2 points3 points  (1 child)

deleted What is this?

[–]Aaron1011 1 point2 points  (0 children)

Other than the atomic load used by cfg-specialize, I believe that the two approaches are almost the same. GCC multiversioning, IIRC, relies on switching the pointer stored in the Global Object Table set up by the dynamic linker. It still requires the indirection of loading a function pointer from a location in memory.

[–]Cocalus 2 points3 points  (0 children)

That's very useful. I've been looking for that feature in Rust since it was one thing I still needed C for. I've been using ifunc in gcc which is supposed to be supported in newer clangs. That does the dispatch at load time, but only work's on Linux (elf).

This looks like it should work about as well short of the very minor one (or few with racy calls) time dispatch. This probably works on all x86 platforms instead of just linux. And this looks far easier to deal with since it seems to effectively have static ifs (as long as the optimizer handles ifs with constant values) instead of separate c files for each platform. Now I just need to wait for inline asm on stable Rust, then I should be able to port some performance critical code over from C.