diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
| commit | bdaedce69b17b654bd0060579dd9b9ff120009b5 (patch) | |
| tree | 0e9cd8597652263a96c48ba678fb0b66e1fc131b /src/isa.c | |
| parent | ba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff) | |
| parent | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff) | |
Merge branch 'wt/rename' into api-hardening
# Conflicts:
# README.md
Diffstat (limited to 'src/isa.c')
| -rw-r--r-- | src/isa.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -3,19 +3,19 @@ * the first terminal exists, so every call in a process uses the same * kernels. */ -#include "term.h" +#include "wsap_vtcore.h" #include "simd.h" #include <stdatomic.h> #include <stdlib.h> #include <string.h> -int term_isa_level; +int wsap_vtcore_isa_level; static atomic_int isa_state; static const char *const level_names[] = { "base", "avx2", "avx512" }; -#if defined(TERM_ISA_RUNTIME) +#if defined(WSAP_VTCORE_ISA_RUNTIME) /* The AVX-512 kernels also need VBMI and VBMI2. Every CPU with VBMI except * Cannon Lake has VBMI2. */ static int cpu_level(void) @@ -23,56 +23,56 @@ static int cpu_level(void) __builtin_cpu_init(); if (__builtin_cpu_supports("x86-64-v4") && __builtin_cpu_supports("avx512vbmi") && __builtin_cpu_supports("avx512vbmi2")) - return TERM_ISA_AVX512; + return WSAP_VTCORE_ISA_AVX512; if (__builtin_cpu_supports("x86-64-v3")) - return TERM_ISA_AVX2; - return TERM_ISA_BASE; + return WSAP_VTCORE_ISA_AVX2; + return WSAP_VTCORE_ISA_BASE; } #else static int cpu_level(void) { - return TERM_ISA_FLOOR; + return WSAP_VTCORE_ISA_FLOOR; } #endif static int pick_level(void) { int level = cpu_level(); - /* TERM_HEADLESS_ISA can only lower the level, never below the floor the + /* WSAP_VTCORE_ISA can only lower the level, never below the floor the * compiler flags fix. */ - const char *want = getenv("TERM_HEADLESS_ISA"); - for (int i = TERM_ISA_FLOOR; want && i < level; i++) + const char *want = getenv("WSAP_VTCORE_ISA"); + for (int i = WSAP_VTCORE_ISA_FLOOR; want && i < level; i++) if (!strcmp(want, level_names[i])) level = i; return level; } /* The first caller picks the level. A second caller waits until it is set. */ -void term_isa_init(void) +void wsap_vtcore_isa_init(void) { if (atomic_load_explicit(&isa_state, memory_order_acquire) == 2) return; int expected = 0; if (atomic_compare_exchange_strong(&isa_state, &expected, 1)) { - term_isa_level = pick_level(); + wsap_vtcore_isa_level = pick_level(); atomic_store_explicit(&isa_state, 2, memory_order_release); return; } while (atomic_load_explicit(&isa_state, memory_order_acquire) != 2) - term_cpu_relax(); + wsap_vtcore_cpu_relax(); } -const char *term_isa(void) +const char *wsap_vtcore_isa(void) { - term_isa_init(); + wsap_vtcore_isa_init(); #if defined(__aarch64__) return "neon"; #else - int level = TERM_ISA_FLOOR; - if (term_use_avx2()) - level = TERM_ISA_AVX2; - if (term_use_avx512()) - level = TERM_ISA_AVX512; + int level = WSAP_VTCORE_ISA_FLOOR; + if (wsap_vtcore_use_avx2()) + level = WSAP_VTCORE_ISA_AVX2; + if (wsap_vtcore_use_avx512()) + level = WSAP_VTCORE_ISA_AVX512; return level_names[level]; #endif } |
