Removing std dependencies from num-traits and num-complex#3
Removing std dependencies from num-traits and num-complex#3michaelciraci merged 4 commits intomainfrom
Conversation
|
Trying to look at this in Rust-Analyzer isn't working well: I get "macro invocation exceeds token limit: produced 4744974 tokens, limit is 2097152" on lib.rs line 64. Also my computer is too old for it to really agree with this project I think (I have a Skylake era mobile i7). Building takes minutes. I was wondering to what extent you could use FloatCore instead of Float. That way you wouldn't even need the libm feature. I do believe your current approach would work but there are two possible caveats I would see with it:
I don't know that there is a fix for issue 1, but for issue 2 you could do this by forwarding the features: [features]
default = ["std"]
std = ["num-complex/std", "num-traits/std"]
libm = ["num-complex/libm", "num-traits/libm"]
[dependencies]
monarch-derive = { path = "crates/monarch-derive" }
num-complex = { version = "0.4", default-features = false }
num-traits = { version = "0.2", default-features = false }Then your user gets to decide if they use std or libm. I don't think there is an automatic way to say "enable libm if std is disabled". I believe there is an open RFC about exclusive features for Cargo, but this is not even implemented for nightly yet. You could add an assert near the top (above the #[cfg(not(any(feature = "std", feature = "libm")))]
compile_error!("At least one of std and libm must be enabled");The downside of this is now you have two different configurations to test. I don't know that is something you want to do. Two configs isn't too bad, but features risk being a combinatorial explosion if you get too many of them. Also testing this properly gets complicated due to issue 1 (feature unification with rustfft) that I mentioned above. Some thought is needed for how to properly set up the CI. You would need to cargo build and cargo test separately. |
|
Looks like your benchmarks also pull in rustfft & fftw, so you would get feature unification there. You could test libm vs std by patching out those temporarily to check what numbers you get. |
|
Yes, right now the macros build for FFT sizes 1-200 but I'd like a more elegant solution to just build the FFT sizes you need, and then rust-analyzer would have a way easier time. I don't think I could use FloatCore, because I need |
Closes #1