mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
Add CpuInfo::isCpuFlagPresent() method
Related-To: NEO-5276 Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
efcd05d7bd
commit
92f067b9aa
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,7 +7,12 @@
|
||||
|
||||
#include "shared/source/utilities/cpu_info.h"
|
||||
|
||||
#include "shared/source/os_interface/linux/os_inc.h"
|
||||
|
||||
#include <cpuid.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -37,4 +42,22 @@ void CpuInfo::cpuidex(
|
||||
cpuidexFunc(reinterpret_cast<int *>(cpuInfo), functionId, subfunctionId);
|
||||
}
|
||||
|
||||
bool CpuInfo::isCpuFlagPresent(const char *cpuFlag) {
|
||||
std::ifstream ifs(std::string(Os::sysFsProcPathPrefix) + "/cpuinfo");
|
||||
std::string line;
|
||||
while (std::getline(ifs, line)) {
|
||||
if (line.substr(0, 5) == "flags") {
|
||||
std::stringstream ss(line);
|
||||
std::string flag;
|
||||
while (ss >> flag) {
|
||||
if (flag == cpuFlag) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user