You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-slowIssue: Problems and improvements with respect to performance of generated code.
use core::float::sqrt;fnmain(){letmut sum:float = 0.0;for core::uint::range(0,100000000) |i| {
sum += sqrt(i asfloat);}
io::println(fmt!("%f", sum));}
# using cmath
$ rustc --opt-level=3 intrinsics-bench.rs && time ./intrinsics-bench
666666661666.567017
real 0m2.729s
user 0m2.712s
sys 0m0.008s
# using intrinsics
$ x86_64-unknown-linux-gnu/stage2/bin/rustc --opt-level=3 intrinsics-bench.rs && time ./intrinsics-bench
666666661666.567017
real 0m0.513s
user 0m0.500s
sys 0m0.008s
@dbaupp mentioned on reddit that using some of these clobbers the stack canary. I hadn't considered that before and we need to think about how these are implemented. How many of the intrinsics that we are already using are just trotting all over the stack red zone? Perhaps LLVM's intrinsics don't emit the proper stack growth prologues.
However, I didn't realize that intrinsics can clobber the stack. I guess we need to write wrappers with the fixedstacksegment attribute for the problematic intrinsics (sin, cos) as well! This can be done entirely in the Rust compiler now, no need to patch LLVM.
@huonw Extern functions automatically require fixed stack segments, if the #[fast_ffi] attribute is used. (Eventually this attribute will no longer be necessary.) However, I don't think that it will work for functions with the rust-intrinsic ABI, because I didn't realize that some intrinsic functions would need it.
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-slowIssue: Problems and improvements with respect to performance of generated code.
Activity
huonw commentedon Apr 3, 2013
I'm running tests on a patch that uses intrinsics for
sqrt,sin,cos,exp, etc.thestinger commentedon Apr 3, 2013
@dbaupp: Nice! It would be awesome to have all of the useful LLVM intrinsics for integers/floats exposed.
huonw commentedon Apr 3, 2013
Yay! 5x faster:
brson commentedon Apr 3, 2013
@dbaupp mentioned on reddit that using some of these clobbers the stack canary. I hadn't considered that before and we need to think about how these are implemented. How many of the intrinsics that we are already using are just trotting all over the stack red zone? Perhaps LLVM's intrinsics don't emit the proper stack growth prologues.
huonw commentedon Apr 3, 2013
(The very brief reddit thread, for future reference.)
Do I continue working on this? (i.e. open a pull request, since I've got the code basically organised.)
The (most) dangerous intrinsics seem to be
sin,cosandexp, so I've leftsinas libc and addedsin_intrfor the intrinsic etc.brson commentedon Apr 3, 2013
@dbaupp I'd like to know what assembly they generate. Do you have a test case that demonstrates all of them?
librustc: use LLVM intrinsics for several floating point operations.
huonw commentedon Apr 3, 2013
@brson: #5697
pcwalton commentedon Apr 20, 2013
@huonw The necessary LLVM changes have been made.
However, I didn't realize that intrinsics can clobber the stack. I guess we need to write wrappers with the
fixedstacksegmentattribute for the problematic intrinsics (sin, cos) as well! This can be done entirely in the Rust compiler now, no need to patch LLVM.huonw commentedon Apr 20, 2013
@pcwalton Does
fixed_stack_segmentwork on extern/intrinsic functions? i.e.pcwalton commentedon Apr 20, 2013
@huonw Extern functions automatically require fixed stack segments, if the
#[fast_ffi]attribute is used. (Eventually this attribute will no longer be necessary.) However, I don't think that it will work for functions with therust-intrinsicABI, because I didn't realize that some intrinsic functions would need it.auto merge of #5975 : huonw/rust/rustc-intrinsics-fixed-stack, r=pcwa…
huonw commentedon Apr 21, 2013
@brson #5975 fixed this.
brson commentedon Apr 21, 2013
Thanks @huonw!
Auto merge of rust-lang#5686 - flip1995:release_doc, r=phansch
Auto merge of rust-lang#5687 - flip1995:release_doc, r=phansch
Merge rust-lang#5686