mixpanel: report cpu_supports_avx2 on startup (#2299)

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel
2024-05-02 16:09:41 -04:00
committed by GitHub
parent 855fd22417
commit 577ebd4826
3 changed files with 11 additions and 4 deletions

View File

@@ -33,13 +33,13 @@ std::string s_implementations_search_path = ".";
} }
// AVX via EAX=1: Processor Info and Feature Bits, bit 28 of ECX // AVX via EAX=1: Processor Info and Feature Bits, bit 28 of ECX
#define cpu_supports_avx() (get_cpu_info(1, 2) & (1 << 28)) #define cpu_supports_avx() !!(get_cpu_info(1, 2) & (1 << 28))
// AVX2 via EAX=7, ECX=0: Extended Features, bit 5 of EBX // AVX2 via EAX=7, ECX=0: Extended Features, bit 5 of EBX
#define cpu_supports_avx2() (get_cpu_info(7, 1) & (1 << 5)) #define cpu_supports_avx2() !!(get_cpu_info(7, 1) & (1 << 5))
#else #else
// gcc/clang // gcc/clang
#define cpu_supports_avx() __builtin_cpu_supports("avx") #define cpu_supports_avx() !!__builtin_cpu_supports("avx")
#define cpu_supports_avx2() __builtin_cpu_supports("avx2") #define cpu_supports_avx2() !!__builtin_cpu_supports("avx2")
#endif #endif
LLModel::Implementation::Implementation(Dlhandle &&dlhandle_) LLModel::Implementation::Implementation(Dlhandle &&dlhandle_)
@@ -260,3 +260,7 @@ const std::string& LLModel::Implementation::implementationsSearchPath() {
bool LLModel::Implementation::hasSupportedCPU() { bool LLModel::Implementation::hasSupportedCPU() {
return cpu_supports_avx() != 0; return cpu_supports_avx() != 0;
} }
int LLModel::Implementation::cpuSupportsAVX2() {
return cpu_supports_avx2();
}

View File

@@ -68,6 +68,8 @@ public:
static void setImplementationsSearchPath(const std::string &path); static void setImplementationsSearchPath(const std::string &path);
static const std::string &implementationsSearchPath(); static const std::string &implementationsSearchPath();
static bool hasSupportedCPU(); static bool hasSupportedCPU();
// 0 for no, 1 for yes, -1 for non-x86_64
static int cpuSupportsAVX2();
private: private:
Implementation(Dlhandle &&); Implementation(Dlhandle &&);

View File

@@ -259,6 +259,7 @@ void Network::sendStartup()
{"display", QString("%1x%2").arg(display->size().width()).arg(display->size().height())}, {"display", QString("%1x%2").arg(display->size().width()).arg(display->size().height())},
{"ram", LLM::globalInstance()->systemTotalRAMInGB()}, {"ram", LLM::globalInstance()->systemTotalRAMInGB()},
{"cpu", getCPUModel()}, {"cpu", getCPUModel()},
{"cpu_supports_avx2", LLModel::Implementation::cpuSupportsAVX2()},
{"datalake_active", mySettings->networkIsActive()}, {"datalake_active", mySettings->networkIsActive()},
}); });
sendIpify(); sendIpify();