emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vectorization, SIMD


From: Gerd Möllmann
Subject: Re: Vectorization, SIMD
Date: Wed, 23 Apr 2025 15:50:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> Cc: Emacs Devel <emacs-devel@gnu.org>
>> Date: Wed, 23 Apr 2025 11:00:23 +0200
>> 
>> I've played with this a bit and made notes, which I'd like to share.
>> Please find attached.
>> 
>> My summary so far: Can be done and it's not that difficult. There is
>> even some degree of "portability" achievable when writing SIMD code by
>> hand. What's will be really no fun, from my POV, is configuration stuff,
>> making it work on N platforms with M compilers and so on.
>> 
>> Don't know, maybe it's best to wait for compilers to get better at
>> auto-vectorization. Or maybe GCC is better than LLVM in this regard. I
>> haven't checked that because I can't really use GCC here on macOS.
>
> I'm probably missing something, but isn't this already supported if
> you take care of specifying the right compiler switches via CFLAGS at
> configure time?
>
> IOW, does this require any changes in Emacs, and if so, why?

Disclaimer: I can only talk about LLVM/Clang here.

With current Clang, auto-vectorization is on with -O2 or better, and
when -march=native or something similar is specified which ensures that
SIMD instructions are supported. Without the -march=xxx it doesn't seem
to happen.

The "problem" with auto-vectorization is that it fails to optimize loops
in many cases. (The .org file contains a compiler option with which one
can see why it fails. By default, clang says nothing.) For example, it
looks like a break or return in a loop makes it fail. Also a switch,
and I don't know what else.

IOW, it's doesn't feel like something that can be relied on, if one
really wants SIMD, especially if some code is compiled by different
compilers or different versions of the same compiler.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]