Fixed build without hwloc.
This commit is contained in:
parent
e9e747f0d1
commit
8ef3e2ec14
3 changed files with 46 additions and 10 deletions
|
@ -22,6 +22,17 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "backend/cpu/platform/AdvancedCpuInfo.h"
|
||||
#include "3rdparty/libcpuid/libcpuid.h"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <intrin.h>
|
||||
#else
|
||||
# include <cpuid.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
@ -29,10 +40,6 @@
|
|||
#include <cstring>
|
||||
|
||||
|
||||
#include "3rdparty/libcpuid/libcpuid.h"
|
||||
#include "backend/cpu/platform/AdvancedCpuInfo.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -54,11 +61,38 @@ static inline void cpu_brand_string(char out[64], const char *in) {
|
|||
}
|
||||
|
||||
|
||||
static inline void cpuid(uint32_t level, int32_t output[4])
|
||||
{
|
||||
memset(output, 0, sizeof(int32_t) * 4);
|
||||
|
||||
# ifdef _MSC_VER
|
||||
__cpuid(output, static_cast<int>(level));
|
||||
# else
|
||||
__cpuid_count(level, 0, output[0], output[1], output[2], output[3]);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static inline bool has_feature(uint32_t level, uint32_t reg, int32_t bit)
|
||||
{
|
||||
int32_t cpu_info[4] = { 0 };
|
||||
cpuid(level, cpu_info);
|
||||
|
||||
return (cpu_info[reg] & bit) != 0;
|
||||
}
|
||||
|
||||
|
||||
static inline bool has_pdpe1gb()
|
||||
{
|
||||
return has_feature(0x80000001, 3, 1 << 26);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
||||
m_brand()
|
||||
m_pdpe1gb(has_pdpe1gb())
|
||||
{
|
||||
struct cpu_raw_data_t raw = {};
|
||||
struct cpu_id_t data = {};
|
||||
|
@ -74,7 +108,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
|||
m_cores = static_cast<size_t>(data.num_cores) * m_packages;
|
||||
m_L3 = data.l3_cache > 0 ? static_cast<size_t>(data.l3_cache) * m_packages : 0;
|
||||
|
||||
const size_t l2 = static_cast<size_t>(data.l2_cache);
|
||||
const auto l2 = static_cast<size_t>(data.l2_cache);
|
||||
|
||||
// Workaround for AMD CPUs https://github.com/anrieff/libcpuid/issues/97
|
||||
if (data.vendor == VENDOR_AMD && data.ext_family >= 0x15 && data.ext_family < 0x17) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue