rust icon indicating copy to clipboard operation
rust copied to clipboard

no_std support

Open mert-kurttutan opened this issue 1 year ago • 7 comments

I know it might be too early. What is current status for no_std support? It will potentially be more important for cpu-based workloads.

mert-kurttutan avatar Nov 29 '24 16:11 mert-kurttutan

I think it should just work, Enzyme works on another level and won't include any std functionality if you don't use it. At least a while ago I also knew another user who verified that, so please let me know if you encounter issues with it.

ZuseZ4 avatar Dec 02 '24 23:12 ZuseZ4

I think it'll be an issue if allocation is needed. We should eventually expose a pre-allocated tape as can be done using C-Enzyme.

jedbrown avatar Dec 03 '24 01:12 jedbrown

https://doc.rust-lang.org/alloc/ Afaik alloc is available through core even when no_std is used?

ZuseZ4 avatar Dec 03 '24 01:12 ZuseZ4

Unless you registered a custom allocator, Enzyme will use malloc and free for things

wsmoses avatar Dec 03 '24 01:12 wsmoses

Yes, but luckily Rust stopped shipping it's own allocator a long time ago, so they should match behaviour. I just wanted to clarify that I think people won't be surprised if allocations happen in no-std code, let it be Enzyme or normal code. I'd be open to accept a PR to have custom-alloc / tape support, but I have more important bugs to fix first (like autodiff sometimes not running), so I don't think I'll have time for this in the near future myself.

ZuseZ4 avatar Dec 03 '24 01:12 ZuseZ4

I can have a look at this, no promise though. Any link to a developer guide would be great

mert-kurttutan avatar Dec 03 '24 04:12 mert-kurttutan

Unfortunately there is no developer guide for Enzyme core, and I don't have the knowledge to write one. The Rust PRs are quite well documented (at least the part which got reviewed during upstreaming) and I'd write more docs once I understand how to register derivatives, but I think just experimenting won't be super efficient for you, unfortunately. I hope to figure out at some point how to solve this issue: https://github.com/EnzymeAD/rust/issues/190 From there on it should hopefully be easier to also support a custom allocator, assuming that is what you are interested in.

ZuseZ4 avatar Dec 05 '24 03:12 ZuseZ4