The AVX + JIT bug is hitting more frequently now. On a AVX machine the
loop vectorizer goes for a vector length of 8 for some of my functions
which in turn causes a SEGFAULT.
Is there a way to limit the loop vectorizer to a certain vector length,
say 4, such that I can work around the bug?
I was about to say that, and you saved us both one cycle.
What you could do is to force an architecture that doesn't have AVX, only
SSE. I'm not sure how to do that on the JIT, I suppose setting the Target
attributes would be enough. Nor I know what CPU string limits support to
SSE, but that should do it.
So, there are ways of disabling stuf in Clang, for instance "-mattr=-avx"
or "-target-feature -avx", but I'm not sure how you're doing it in the JIT.
I'm also not sure how to set target parameters in JIT, you'll have to do
that by hand.
I don’t know that either. I set the CPU via engineBuilder.setMCPU(llvm::sys::getHostCPUName()); and that figures out all target parameters, I assume. I would need to still use this, and then disable just the AVX feature.
Porting my project from JIT to MCJIT did not fix the code generation bug
Frank is also experiencing. However, Renato's "-avx" suggestion did resolve
the issue for me. Hopefully we can get some traction on this bug, happy to
help where possible!
v/r,
Josh
Glad to see you can continue with your work, regardless of the AVX bug. It
would be great if you guys could reduce the IR and report the AVX bug in
bugzilla, I'm hoping you both found the same error (fingers crossed), but
feel free to open separate bugs, and we'll join later if they are the same.
In my case the segfault happens when calling the JIT'ed function. Thus some sort of 'payload' has to be created. Not sure if it's the same what Josh is hitting.
I'm embarrassed to say my bug ended up being a user error. I was passing in
pointers that were 16-byte aligned instead of 32. Explains why they worked
fine for SSE but not AVX Sorry for the noise!
Hmm.. I don't quite understand. How can a module validator
catch this, when it's the pointers, i.e. the payload, you pass
as function arguments that need to be aligned.. ?!
Frank
Agreed, is there a pass that will insert a runtime alignment check? Also, what’s the easiest way to get at TargetTransformInfo::getRegisterBitWidth() so I don’t have to hard code 32? Thanks!
-Josh
I think that's a fair question, and it's about safety. If you're getting
this on the JIT, means we may be generating unsafe transformations on the
vectorizer.
Arnold, Nadav, I don't remember seeing code to generate any run-time
alignment checks on the incoming pointer, is there such a thing? If not,
shouldn't we add one?