older CPUs (experimental): STRATA_ISA_FLOOR=avx|none, and setup compiles it instead of stopping (#394 #595 #623)
- CMake: STRATA_ISA_FLOOR (empty by default) builds ggml-cpu for AVX (Sandy/Ivy Bridge) or SSE4.2
(Nehalem/Westmere) instead of the build host or AVX2; every other ggml ISA option off. Strata's own
AVX2/AVX-512 kernels stay in the binary behind their CPU checks. Excludes STRATA_PORTABLE. The ggml
block follows the Strata_Dirigo fork's (rwkeyes).
- STRATA_FORCE_ISA=avx2|avx|sse caps the engine's CPU probes, so the older-CPU paths run on any PC
(how this was tested here: no old CPU). cpu_sse42_ok(), isa_floor_build().
- The engine: a normal build still refuses a CPU without AVX2, now pointing at the experimental build;
a floor build checks its own floor (AVX, or SSE4.2 + POPCNT) and warns that it is experimental and
slow (or, on an AVX2 CPU, that the normal build is faster).
- setup: a CPU without AVX2 warns ("experimental, slow") and compiles the engine on the PC with the
floor it has, instead of failing (#595's idea); the prebuilt AVX2 engine is not used there. Recorded
in BUILD.json; a build folder for another floor is configured afresh. STRATA_ISA_FLOOR=avx|none asks
for it on any PC. Windows + AMD has no source build: a clear stop. The MCP server's recommendation
notes it instead of refusing.
- tools/test_setup_oldcpu.py.
Default build: nothing changes (no new CMake definitions, the probes answer as before without the env).
This commit is contained in:
1 parent
51a60af92a
commit
b8dbdfe12a
7 files changed
+286
-14
No files matched your search
@@ -21,9 +21,26 @@ ExpertLayout g_layout;
|
||||
|
||||
const ExpertLayout& expert_layout() { return g_layout; }
|
||||
|
||||
int cpu_isa_cap() {
|
||||
// STRATA_FORCE_ISA (tests, the experimental older-CPU builds): the engine's own dispatch acts as if this CPU
|
||||
// stopped at that level. ggml-cpu is not affected: it runs what the build compiled it for.
|
||||
static const int cap = [] {
|
||||
const char* f = std::getenv("STRATA_FORCE_ISA");
|
||||
if (f == nullptr || f[0] == '\0') return 3;
|
||||
const std::string v(f);
|
||||
if (v == "avx2") return 2;
|
||||
if (v == "avx") return 1;
|
||||
if (v == "sse" || v == "sse4.2" || v == "none") return 0;
|
||||
std::fprintf(stderr, "strata: STRATA_FORCE_ISA=%s is not avx2, avx or sse; ignored\n", f);
|
||||
return 3;
|
||||
}();
|
||||
return cap;
|
||||
}
|
||||
|
||||
bool cpu_avx512_ok() {
|
||||
static const bool ok = [] {
|
||||
if (const char* f = std::getenv("STRATA_FORCE_AVX2"); f != nullptr && f[0] == '1') return false;
|
||||
if (cpu_isa_cap() < 3) return false;
|
||||
unsigned r[4] = {0, 0, 0, 0};
|
||||
auto cpuid = [&](unsigned leaf, unsigned sub) {
|
||||
#if defined(_MSC_VER)
|
||||
@@ -55,6 +72,7 @@ bool cpu_avx512_ok() {
|
||||
|
||||
bool cpu_avx2_ok() {
|
||||
static const bool ok = [] {
|
||||
if (cpu_isa_cap() < 2) return false;
|
||||
unsigned r[4] = {0, 0, 0, 0};
|
||||
auto cpuid = [&](unsigned leaf, unsigned sub) {
|
||||
#if defined(_MSC_VER)
|
||||
@@ -89,6 +107,7 @@ bool cpu_avx1_ok() {
|
||||
// AVX (Sandy Bridge, 2011): AVX + OSXSAVE with the OS saving the YMM state; FMA, F16C and AVX2 not needed.
|
||||
// From the Strata_Dirigo fork (rwkeyes).
|
||||
static const bool ok = [] {
|
||||
if (cpu_isa_cap() < 1) return false;
|
||||
unsigned r[4] = {0, 0, 0, 0};
|
||||
#if defined(_MSC_VER)
|
||||
int x[4];
|
||||
@@ -110,6 +129,31 @@ bool cpu_avx1_ok() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool cpu_sse42_ok() {
|
||||
static const bool ok = [] {
|
||||
unsigned r[4] = {0, 0, 0, 0};
|
||||
#if defined(_MSC_VER)
|
||||
int x[4];
|
||||
__cpuidex(x, 1, 0);
|
||||
for (int i = 0; i < 4; ++i) r[i] = (unsigned) x[i];
|
||||
#else
|
||||
__cpuid_count(1, 0, r[0], r[1], r[2], r[3]);
|
||||
#endif
|
||||
return ((r[2] >> 20) & 1u) && ((r[2] >> 23) & 1u); // SSE4.2, POPCNT
|
||||
}();
|
||||
return ok;
|
||||
}
|
||||
|
||||
const char* isa_floor_build() {
|
||||
#if defined(STRATA_ISA_FLOOR_AVX)
|
||||
return "avx";
|
||||
#elif defined(STRATA_ISA_FLOOR_NONE)
|
||||
return "sse4.2";
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string cpu_name() {
|
||||
unsigned r[12] = {};
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
Reference in new issue
Block a user