4 ms·
What do you think of Julia's macro-based approach? That is, there are `@inbounds` and `@fastmath` macros that turn off bounds checking/enable fast-math flags in
by celrod 7y ago
What do you think of Julia's macro-based approach?
That is, there are `@inbounds` and `@fastmath` macros that turn off bounds checking/enable fast-math flags in the following expression.
`@fastmath` works simply by swapping functions (eg `+`) with versions (eg, `Base.FastMath.add_fast`) that have the appropriate llvm flags.
When testing Julia libraries, all `@inbounds` are ignored (ie, it'll emit bounds checks anyway).
I assume it's already possible for a user to similarly implement `inbounds!` and `fastmath!` macros in Rust to substitute `[]` for `.get_unchecked()`, etc. (I haven't checked if there are already crates.) But it sounds like it should be easy enough for folks to check performance sensitive regions this way (in particular, loops that may need these flags to vectorize).
- steveklabnik 7y agoPeople have already implemented them, yeah. Dropbox did for some of their code, IIRC. I think having the speedbump is worth it.