Make the env var controlling which SIMD level to use more capable

This commit is contained in:
Kovid Goyal 2024-01-24 22:10:55 +05:30
parent 73342411bc
commit 66341aa28e
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 5 deletions

View file

@ -231,7 +231,10 @@ Variables that kitty sets when running child programs
Set to ``1`` when kitty is running a shell because of the ``--hold`` flag. Can
be used to specialize shell behavior in the shell rc files as desired.
.. envvar:: KITTY_NO_SIMD
.. envvar:: KITTY_SIMD
Set it to any value to prevent kitty from using SIMD CPU vector
instructions.
Set it to ``128`` to use 128 bit vector registers, ``256`` to use 256 bit
vector registers or any other value to prevent kitty from using SIMD CPU
vector instructions. Warning, this overrides CPU capability detection so
will cause kitty to crash with SIGILL if your CPU does not support the
necessary SIMD extensions.

View file

@ -139,8 +139,10 @@ init_simd(void *x) {
do_check();
#endif
#endif
if (getenv("KITTY_NO_SIMD")) {
has_avx2 = false; has_sse4_2 = false;
const char *simd_env = getenv("KITTY_SIMD");
if (simd_env) {
has_sse4_2 = strcmp(simd_env, "128") == 0;
has_avx2 = strcmp(simd_env, "256") == 0;
}
#undef do_check