Open ZuseZ4 opened 2 years ago
This is a Type analysis bug, can you post a log, ideally with the EnzymePrintType flag on
Sure, here it goes. The printType flag is on. https://drive.google.com/file/d/1grzI4iio2ts-497rI_ReiaWlEms0VGJN/view?usp=sharing
Can you run with the following flag set to false: https://github.com/wsmoses/Enzyme/blob/f7c9fe57112bba48caee520b0dec28ec55e48285/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp#L68
It appears there is a potential type confusion as to whether something is an integer vs a pointer on std::option::Option<(std::ptr::NonNull<u8>, std::alloc::Layout)>
which makes sense since presumably the ptr is a pointer and the layout is an integer.
Thanks for finding the origin.
Not sure how aware you are about the rust types, so the Option here doesn't read as either ptr or alloc, instead it's either Some((ptr, alloc))
, which contains a tuple or None
, where I'm not sure how it will be represented. Iirc, for cases where the T
in Some
can't be / begin with zero, they try to merge both. But that probably won't affect the TypeAnalysis anymore. Alloc is a struct { usize, NonZeroUsize }
about the memory size and the alignment.
That's with strict-aliasing=true: https://drive.google.com/file/d/1PTqFNkxx7VyZzR9BZwe0nKq7RPJmn9IU/view?usp=sharing That's with strict-aliasing=false: https://drive.google.com/file/d/1aRUcfKlT3TQKdeYdrjXCSwe5y3sj4aUS/view?usp=sharing Unfortunately, I ran out of memory in the second case with 48GB (+50GB Swp). It also looks like it's missing the end. I guess trying to trigger the issue with some simpler allocations in a smaller function, or starting to mark some rust functions as inactive could help here? What do you think?
Using
one the following test function:
will lead to Enzyme failing with the following message:
I'm using an Enzyme fork with the Rust debug parser merged, but the failing code doesn't seem to be affected by that: https://github.com/ZuseZ4/Enzyme/blob/08eb0646ee6f0ae7eca99fcc41f0c54fcc09cbc1/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp#L617
It could be due to the sloppy initialization of some values which (based on my understanding) shouldn't be seriously considered by Enzyme: https://github.com/rust-ml/oxide-enzyme/blob/a1dfbde391b32cde6a594b9fe87f7e8b8940a9e2/src/enzyme/enzyme_wrapper.rs#L77
I guess this issue about allocating is outdated, correct? https://github.com/wsmoses/Enzyme.jl/blob/05c9b84f9051c5bd8863925e54a2fc4eb11fc784/src/Enzyme.jl#L126