Added hwloc stub.

This commit is contained in:
XMRig 2019-07-23 01:18:55 +07:00
parent b02e596853
commit 42460b8805
6 changed files with 145 additions and 5 deletions

View file

@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(xmrig)
option(WITH_LIBCPUID "Use Libcpuid" ON)
option(WITH_HWLOC "Use hwloc" OFF)
option(WITH_CN_LITE "CryptoNight-Lite support" ON)
option(WITH_CN_HEAVY "CryptoNight-Heavy support" ON)
option(WITH_CN_PICO "CryptoNight-Pico support" ON)
@ -146,6 +147,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
find_package(UV REQUIRED)
if (WITH_HWLOC)
find_package(HWLOC REQUIRED)
endif()
if (WITH_RANDOMX)
include_directories(src/crypto/randomx)
add_definitions(/DXMRIG_ALGO_RANDOMX)

25
cmake/FindHWLOC.cmake Normal file
View file

@ -0,0 +1,25 @@
find_path(
HWLOC_INCLUDE_DIR
NAMES hwloc.h
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
find_path(HWLOC_INCLUDE_DIR NAMES hwloc.h)
find_library(
HWLOC_LIBRARY
NAMES hwloc.a hwloc libhwloc
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
find_library(HWLOC_LIBRARY NAMES hwloc.a hwloc libhwloc)
set(HWLOC_LIBRARIES ${HWLOC_LIBRARY})
set(HWLOC_INCLUDE_DIRS ${HWLOC_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HWLOC DEFAULT_MSG HWLOC_LIBRARY HWLOC_INCLUDE_DIR)

View file

@ -29,7 +29,9 @@
#include "backend/cpu/Cpu.h"
#ifdef XMRIG_FEATURE_LIBCPUID
#if defined(XMRIG_FEATURE_HWLOC)
# include "backend/cpu/platform/HwlocCpuInfo.h"
#elif defined(XMRIG_FEATURE_LIBCPUID)
# include "backend/cpu/platform/AdvancedCpuInfo.h"
#else
# include "backend/cpu/platform/BasicCpuInfo.h"
@ -51,7 +53,9 @@ void xmrig::Cpu::init()
{
assert(cpuInfo == nullptr);
# ifdef XMRIG_FEATURE_LIBCPUID
# if defined(XMRIG_FEATURE_HWLOC)
cpuInfo = new HwlocCpuInfo();
# elif defined(XMRIG_FEATURE_LIBCPUID)
cpuInfo = new AdvancedCpuInfo();
# else
cpuInfo = new BasicCpuInfo();

View file

@ -18,16 +18,43 @@ set(SOURCES_BACKEND_CPU
)
if (WITH_LIBCPUID)
if (WITH_HWLOC)
set(WITH_LIBCPUID OFF)
include_directories(${HWLOC_INCLUDE_DIR})
set(CPUID_LIB ${HWLOC_LIBRARY})
remove_definitions(/DXMRIG_FEATURE_LIBCPUID)
add_definitions(/DXMRIG_FEATURE_HWLOC)
set(SOURCES_CPUID
src/backend/cpu/platform/BasicCpuInfo.cpp
src/backend/cpu/platform/BasicCpuInfo.h
src/backend/cpu/platform/HwlocCpuInfo.cpp
src/backend/cpu/platform/HwlocCpuInfo.h
)
elseif (WITH_LIBCPUID)
set(WITH_HWLOC OFF)
add_subdirectory(src/3rdparty/libcpuid)
include_directories(src/3rdparty/libcpuid)
add_definitions(/DXMRIG_FEATURE_LIBCPUID)
remove_definitions(/DXMRIG_FEATURE_HWLOC)
set(CPUID_LIB cpuid)
set(SOURCES_CPUID src/backend/cpu/platform/AdvancedCpuInfo.h src/backend/cpu/platform/AdvancedCpuInfo.cpp src/backend/cpu/Cpu.cpp)
set(SOURCES_CPUID
src/backend/cpu/platform/AdvancedCpuInfo.cpp
src/backend/cpu/platform/AdvancedCpuInfo.h
)
else()
remove_definitions(/DXMRIG_FEATURE_LIBCPUID)
set(SOURCES_CPUID src/backend/cpu/platform/BasicCpuInfo.h src/backend/cpu/Cpu.cpp)
remove_definitions(/DXMRIG_FEATURE_HWLOC)
set(CPUID_LIB "")
set(SOURCES_CPUID
src/backend/cpu/platform/BasicCpuInfo.h
)
if (XMRIG_ARM)
set(SOURCES_CPUID ${SOURCES_CPUID} src/backend/cpu/platform/BasicCpuInfo_arm.cpp)

View file

@ -0,0 +1,34 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <hwloc.h>
#include "backend/cpu/platform/HwlocCpuInfo.h"
xmrig::HwlocCpuInfo::HwlocCpuInfo() : BasicCpuInfo()
{
}

View file

@ -0,0 +1,45 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_HWLOCCPUINFO_H
#define XMRIG_HWLOCCPUINFO_H
#include "backend/cpu/platform/BasicCpuInfo.h"
namespace xmrig {
class HwlocCpuInfo : public BasicCpuInfo
{
public:
HwlocCpuInfo();
};
} /* namespace xmrig */
#endif /* XMRIG_HWLOCCPUINFO_H */