New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alignement fault for graphene_vec3_dot with neon #215
Comments
Fedora on ARMv7 distro flags don't enable NEON by default, it should really be a runtime detected optimization as not all arm platforms are guaranteed to have NEON available. |
Run time detection does not work with all the inlining going on, so it's a non starter. |
Thanks for your answer. I'm not sure to understand.:
|
If NEON support is compiled in, then yes: it should work. I only test it on an RPi 3b+, though, because it's the only ARM device I have available. The float32x4_t __mul = vmulq_f32 (a, b);
float32x2_t __s1 = vpadd_f32 (vget_low_f32 (__m), vget_low_f32 (__m));
float32x2_t __res = vadd_f32 (__s1, vget_high_f32 (__m));
float res = vget_lane_f32 (__res, 0); |
Just a random idea: Could it be an LTO issue? @kwizart, have you tried disabling LTO for graphene and see if it helps? |
This bug has been playing me for a long time as well, even in Fedora 33 being unable to start gnome-shell due to this. Building without neon fixes it here as well. |
https://bodhi.fedoraproject.org/updates/FEDORA-2021-f000eb2320 (F33) and https://bodhi.fedoraproject.org/updates/FEDORA-2021-cb9771bb01 (F34) disable neon for Fedora (thanks kwizart!) if you want to test and karma the updates. |
Thanks! |
Edit: Removed tests for rpi3/4 as I don't reproduce there on f33 after double checks. @kalev, I confirm that disabling lto is without effect. |
I have encountered a very similar crash, also on an ARMv7l architecture, albeit within Text of alignment trap:
From GDB:
If my read is correct, it looks like the code within Happy to file as a separate issue instead. |
I can also confirm @jeremy-hiatt segfault when the fuction is called from gstreamer. |
Apologies, the error @jeremy-hiatt was referring to, isn't happening when graphene has been built without neon. |
In 1.10.5, released on February 9, I landed a couple of changes to the alignment annotations; looking at the links on Bodhi that @kalev posted, it seems F33 and F34 still use 1.10.4. Would it be possible for people on ARM to test 1.10.5? |
Hm, I only see 1.10.4 on both https://github.com/ebassi/graphene/releases and https://github.com/ebassi/graphene/tags |
@kalev You're absolutely right—I got confused with the post-release version bump. So I'm really confused as to why there are alignment issues, considering that the structures are marked for alignment as required by vectorised types. |
@ebassi One thing I'll admit I don't understand very well is how the alignment annotations are expected to interact with The part I'm really fuzzy on is whether there's supposed to be anything within GStreamer or GLib in general that's smart enough to allocate heap memory with the correct alignment for this type, and if so, why it's not working here. |
I tested with 1.10.4 (was previously using 1.10.2) but no difference. I checked the reported alignment via I posted a pretty minimal example that triggers the alignment fault reliably on my board. Perhaps @ebassi you can try this on your RPi to see if it works for you? |
There are no special alignment guarantees for heap-allocated memory via Structures that may be placed on the heap must be able to manage their own alignment by padding themselves and applying an offset as part of their API according to their given address. This indeed complictes things, like when such structures are manually copied from one heap-allocated address to another where they require a different alignment. It is advised to provide a "copy" API that properly realigns the content of the structure to the destination address. There may be other tricks to deal with this requirement, but I'm personally not familiar with them. |
I run into the same alignment trap like @jeremy-hiatt, tested with graphene 1.9.2 as well as 1.10.6 on an ARM Cortex A9.
Yes, same here. |
After investigating the issue pointed out by @jeremy-hiatt further, I am now of the opinion that gstreamer should pass 16-byte-aligned memory to graphene. To do this, I created this gstreamer merge request gltransformation: pass 16-byte-aligned memory to graphene. Feedback welcome! |
I'm also getting alignment faults in more then one function. I'm trying to get archlinuxarm gnome running on a rk3288 box. If you need more info then tell me what I can send. |
Seems like a related issue is causing problems with GTK4 (upstream issue); there we're getting SIGBUS errors on Alpine Linux on armv7 and armhf, and the exact function that crashes is |
No, we're not going to allocate pointers to graphene structures in GTK. The main problem is alignment of GObject: https://gitlab.gnome.org/GNOME/glib/-/issues/1231 |
With NEON instructions enabled, graphene expects the memory passed to it 16-byte-aligned. Otherwise unaligned memory access faults occur causing SIGBUS signals. graphene has alloc functions for its structures that take care of this, so use them. See also: ebassi/graphene#215 (comment) Suggested-by: Sebastian Dröge <sebastian@centricular.com> Signed-off-by: Bastian Krause <bst@pengutronix.de> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2128>
This disables neon support on arm devices only because it crashes otherwise. Upstream-status: Reported [ebassi/graphene#215] Signed-off-by: Khem Raj <raj.khem@gmail.com>
Not all arm platforms support neon and runtime detection for this feature is currently not reliable. Disable neon support by default on ARM-32 platforms because of the following upstream bug: ebassi/graphene#215 Enable neon for aarch64 by default (From OE-Core rev: c29a1a2442a22f87913fad24f19eaa45ddb13e23) Signed-off-by: Markus Volk <f_l_k@t-online.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Not all arm platforms support neon and runtime detection for this feature is currently not reliable. Disable neon support by default on ARM-32 platforms because of the following upstream bug: ebassi/graphene#215 Enable neon for aarch64 by default (From OE-Core rev: 4225291418142a61d760b7d317eff47752c41328) Signed-off-by: Markus Volk <f_l_k@t-online.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Not all arm platforms support neon and runtime detection for this feature is currently not reliable. Disable neon support by default on ARM-32 platforms because of the following upstream bug: ebassi/graphene#215 Enable neon for aarch64 by default (From OE-Core rev: 4225291418142a61d760b7d317eff47752c41328) Signed-off-by: Markus Volk <f_l_k@t-online.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Not all arm platforms support neon and runtime detection for this feature is currently not reliable. Disable neon support by default on ARM-32 platforms because of the following upstream bug: ebassi/graphene#215 Enable neon for aarch64 by default (From OE-Core rev: 72778f6a647f47926c6ba1b77f0984999a22e44a) Signed-off-by: Markus Volk <f_l_k@t-online.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Not all arm platforms support neon and runtime detection for this feature is currently not reliable. Disable neon support by default on ARM-32 platforms because of the following upstream bug: ebassi/graphene#215 Enable neon for aarch64 by default Signed-off-by: Markus Volk <f_l_k@t-online.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
With NEON instructions enabled, graphene expects the memory passed to it 16-byte-aligned. Otherwise unaligned memory access faults occur causing SIGBUS signals. graphene has alloc functions for its structures that take care of this, so use them. See also: ebassi/graphene#215 (comment) Suggested-by: Sebastian Dröge <sebastian@centricular.com> Signed-off-by: Bastian Krause <bst@pengutronix.de> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1321>
Experienced behavior
Using graphene at runtime has alignment fault on armv7hl with neon.
Tried using Fedora 33/34 workstation on armhfp with a jetson-tk1.
Build is passing with/without neon enabled in theses distros. Also tests seems to pass in all cases...
(so it looks different than #97 that is related to build issues with others functions).
Expected behavior
Fedora workstation should work with wayland at runtime on the device.
Steps to reproduce
install a build of graphene with neon support enabled (current workaround is to disable neon support in graphene).
Operating system in use
Reproduced on Fedora 33/34 armhfp (armv7hl)
SIMD implementation in use
ARM neon
The text was updated successfully, but these errors were encountered: