Assume run-time NEON support if detected by cmake

This commit is contained in:
Chris Robinson
2020-12-31 11:42:02 -08:00
parent 78f3d8fcd8
commit 9d354f721c
+2 -45
View File
@@ -131,55 +131,12 @@ al::optional<CPUInfo> GetCPUInfo()
#ifdef HAVE_NEON #ifdef HAVE_NEON
#ifdef __ARM_NEON #ifdef __ARM_NEON
ret.mCaps |= CPU_CAP_NEON; ret.mCaps |= CPU_CAP_NEON;
#elif defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64)) #elif defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64))
if(IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)) if(IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
ret.mCaps |= CPU_CAP_NEON; ret.mCaps |= CPU_CAP_NEON;
#else #else
#warning "Assuming NEON run-time support!"
al::ifstream file{"/proc/cpuinfo"}; ret.mCaps |= CPU_CAP_NEON;
if(!file.is_open())
return al::nullopt;
auto getline = [](std::istream &f, std::string &output) -> bool
{
while(f.good() && f.peek() == '\n')
f.ignore();
return std::getline(f, output) && !output.empty();
};
std::string features;
while(getline(file, features))
{
if(features.compare(0, 10, "Features\t:", 10) == 0)
break;
}
file.close();
size_t extpos{9};
while((extpos=features.find("neon", extpos+1)) != std::string::npos)
{
if(std::isspace(features[extpos-1])
&& (extpos+4 == features.length() || std::isspace(features[extpos+4])))
{
ret.mCaps |= CPU_CAP_NEON;
break;
}
}
if(!(ret.mCaps&CPU_CAP_NEON))
{
extpos = 9;
while((extpos=features.find("asimd", extpos+1)) != std::string::npos)
{
if(std::isspace(features[extpos-1])
&& (extpos+5 == features.length() || std::isspace(features[extpos+5])))
{
ret.mCaps |= CPU_CAP_NEON;
break;
}
}
}
#endif #endif
#endif #endif