From 108d950874e457ced4d5d1f0569dfb43bbd25734 Mon Sep 17 00:00:00 2001 From: Cosmic Snow Date: Tue, 8 Aug 2023 00:17:41 +0200 Subject: [PATCH] Fix Windows unable to load models on older Windows builds - Replace high-level IsProcessorFeaturePresent - Reintroduce low-level compiler intrinsics implementation --- gpt4all-backend/llmodel.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gpt4all-backend/llmodel.cpp b/gpt4all-backend/llmodel.cpp index d3ac6c96..40276865 100644 --- a/gpt4all-backend/llmodel.cpp +++ b/gpt4all-backend/llmodel.cpp @@ -11,8 +11,7 @@ #include #include #ifdef _MSC_VER -#include -#include +#include #endif std::string s_implementations_search_path = "."; @@ -22,7 +21,9 @@ static bool has_at_least_minimal_hardware() { #ifndef _MSC_VER return __builtin_cpu_supports("avx"); #else - return IsProcessorFeaturePresent(PF_AVX_INSTRUCTIONS_AVAILABLE); + int cpuInfo[4]; + __cpuid(cpuInfo, 1); + return cpuInfo[2] & (1 << 28); #endif #else return true; // Don't know how to handle non-x86_64 @@ -34,7 +35,9 @@ static bool requires_avxonly() { #ifndef _MSC_VER return !__builtin_cpu_supports("avx2"); #else - return !IsProcessorFeaturePresent(PF_AVX2_INSTRUCTIONS_AVAILABLE); + int cpuInfo[4]; + __cpuidex(cpuInfo, 7, 0); + return !(cpuInfo[1] & (1 << 5)); #endif #else return false; // Don't know how to handle non-x86_64