1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-08 08:23:34 -05:00

Compare commits

...

41 Commits

Author SHA1 Message Date
XMRig
5e13d78315 Merge remote-tracking branch 'remotes/origin/dev' into evo 2022-09-25 09:49:01 +07:00
xmrig
bc4dd11761 Merge pull request #3129 from SChernykh/dev
Fix: protectRX flushed CPU cache only on MacOS/iOS
2022-09-22 07:02:28 +07:00
SChernykh
7b52a41459 Fix: protectRX flushed CPU cache only on MacOS/iOS 2022-09-21 15:18:06 +02:00
XMRig
b8191cef2b Merge remote-tracking branch 'remotes/origin/dev' into evo 2022-09-21 06:17:57 +07:00
xmrig
b5de214ff9 Merge pull request #3126 from SChernykh/dev
Don't reset when pool sends the same job blob
2022-09-19 19:03:17 +07:00
SChernykh
8bd3b393ef Update m_size only if blob was set successfully 2022-09-19 10:42:08 +02:00
SChernykh
9223c2f027 Don't reset when pool sends the same job blob 2022-09-19 10:35:36 +02:00
XMRig
6f0291bfde Fixed build. 2022-09-19 05:45:16 +07:00
XMRig
6f3187049a Merge remote-tracking branch 'remotes/origin/dev' into evo 2022-09-19 05:14:21 +07:00
xmrig
6346d36d1b Merge pull request #3120 from SChernykh/dev
RandomX: optimized CFROUND elimination more
2022-09-16 22:50:51 +07:00
SChernykh
93c07e1d34 RandomX: optimized CFROUND elimination more 2022-09-16 14:11:27 +02:00
xmrig
0ba3000982 Merge pull request #3119 from SChernykh/dev
RandomX: optimized CFROUND elimination
2022-09-16 01:04:32 +07:00
SChernykh
f0e7de8c71 RandomX: optimized CFROUND elimination 2022-09-15 19:57:34 +02:00
xmrig
1c4eb6c5fe Merge pull request #3109 from SChernykh/dev
RandomX: added Blake2 AVX2 version
2022-08-26 01:52:22 +07:00
SChernykh
63e21dfe63 RandomX: added Blake2 AVX2 version
+0.1% speedup on AMD Zen2/Zen3 and Intel CPUs which support AVX2.
2022-08-25 20:39:54 +02:00
xmrig
b2d9dab2e3 Merge pull request #3075 from dev-0x7C6/master
Recognize armv7ve as valid ARMv7 target.
2022-08-19 02:30:27 +07:00
XMRig
4fec1b0aed Taskbar class cleanup. 2022-08-16 17:54:33 +07:00
XMRig
d862ba853f Revert Taskbar class. 2022-08-16 17:31:39 +07:00
XMRig
9a4558561f Fixed MSVC build. 2022-08-07 22:19:54 +07:00
XMRig
f99554858b Fixed GhostRider build. 2022-08-07 21:21:36 +07:00
XMRig
571bc798f4 Fixed typo. 2022-08-07 17:31:13 +07:00
XMRig
8d043dadec Fixed build (GhostRider temporarily disabled) 2022-08-07 17:25:32 +07:00
XMRig
1438672fe5 Fixed kawpow build. 2022-08-06 15:25:40 +07:00
XMRig
f6dbe32c86 Merge remote-tracking branch 'remotes/origin/sync-base' into evo 2022-08-06 10:22:49 +07:00
XMRig
ce0b879542 Update base. 2022-08-05 11:00:18 +07:00
Bartłomiej Burdukiewicz
7e49fc828d Recognize armv7ve as valid ARMv7 target.
Docs: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

'armv7ve' - The extended version of the ARMv7-A architecture with support for virtualization.

Signed-off-by: Bartłomiej Burdukiewicz <bartlomiej.burdukiewicz@gmail.com>
2022-06-21 18:31:24 +02:00
XMRig
3ab07fe8c1 Rename App to MinerApp. 2021-09-04 21:10:28 +07:00
XMRig
824ba24134 Removed config option background. 2021-09-04 04:59:00 +07:00
XMRig
d7a6aaadea Update for new Entry class. 2021-09-03 23:34:53 +07:00
XMRig
26819f01e1 Fixed Linux build. 2021-09-02 20:22:27 +07:00
XMRig
d94f6e9c3a Fixed build. 2021-09-02 20:16:14 +07:00
XMRig
28312236fd Update base. 2021-09-02 20:02:42 +07:00
XMRig
dbc53c5d46 Add submodule. 2021-08-31 21:28:57 +07:00
XMRig
a7e20ea5de Remove base. 2021-08-31 21:22:44 +07:00
XMRig
bb9e35f5d2 Merge branch 'dev' into evo 2021-08-31 03:33:24 +07:00
XMRig
cb2ec2316a Fixed build. 2021-08-31 00:02:55 +07:00
XMRig
e3b5bfeb36 Build fixes. 2021-08-30 23:41:53 +07:00
XMRig
cac1e4aa5e Build "src/base" as static library. 2021-08-30 23:06:16 +07:00
XMRig
e1f0737a59 Update base. 2021-08-30 19:44:19 +07:00
XMRig
5c6c1299c8 Update base, fmt and llhttp. 2021-08-29 21:18:00 +07:00
XMRig
4f90075ea0 Merge branch 'dev' into evo 2021-08-29 20:45:37 +07:00
56 changed files with 1063 additions and 766 deletions

6
CHANGELOG_NEXT.md Normal file
View File

@@ -0,0 +1,6 @@
# v7.0.0
- `src/base` is now a git submodule for the [base](https://github.com/xmrig/base) project, build instructions require slight update.
- Removed config option `background` (only command line available). Switching to background now happens on a very early stage before any I/O.
# Previous versions
[doc/CHANGELOG_OLD.md](doc/CHANGELOG_OLD.md)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.1)
project(xmrig)
option(WITH_HWLOC "Enable hwloc support" ON)
@@ -27,6 +27,7 @@ option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
option(WITH_PROFILING "Enable profiling for developers" OFF)
option(WITH_SSE4_1 "Enable SSE 4.1 for Blake2" ON)
option(WITH_AVX2 "Enable AVX2 for Blake2" ON)
option(WITH_VAES "Enable VAES instructions for Cryptonight" ON)
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF)
@@ -36,22 +37,26 @@ option(BUILD_STATIC "Build static binary" OFF)
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
option(HWLOC_DEBUG "Enable hwloc debug helpers and log" OFF)
add_definitions(-DXMRIG_MINER_PROJECT)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(WITH_SODIUM OFF)
set(WITH_CRYPTONOTE ON)
set(WITH_CRYPTO_OPS ON)
set(WITH_COM OFF)
set(WITH_EVENTS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/base/cmake" "${CMAKE_SOURCE_DIR}/cmake")
set(LIBS base)
include (CheckIncludeFile)
include (cmake/cpu.cmake)
include (cmake/os.cmake)
include (src/base/base.cmake)
include (src/backend/backend.cmake)
include(base)
add_subdirectory(src/base)
include(src/backend/backend.cmake)
set(HEADERS
"${HEADERS_BASE}"
"${HEADERS_BASE_HTTP}"
"${HEADERS_BACKEND}"
src/App.h
src/backend/common/interfaces/IMemoryPool.h
src/core/config/Config_default.h
src/core/config/Config_platform.h
src/core/config/Config.h
@@ -60,17 +65,6 @@ set(HEADERS
src/core/Controller.h
src/core/Miner.h
src/core/Taskbar.h
src/net/interfaces/IJobResultListener.h
src/net/JobResult.h
src/net/JobResults.h
src/net/Network.h
src/net/strategies/DonateStrategy.h
src/Summary.h
src/version.h
)
set(HEADERS_CRYPTO
src/backend/common/interfaces/IMemoryPool.h
src/crypto/cn/asm/CryptonightR_template.h
src/crypto/cn/c_blake256.h
src/crypto/cn/c_groestl.h
@@ -91,32 +85,29 @@ set(HEADERS_CRYPTO
src/crypto/common/Nonce.h
src/crypto/common/portable/mm_malloc.h
src/crypto/common/VirtualMemory.h
src/MinerApp.h
src/net/interfaces/IJobResultListener.h
src/net/JobResult.h
src/net/JobResults.h
src/net/Network.h
src/net/strategies/DonateStrategy.h
src/Summary.h
src/version.h
)
if (XMRIG_ARM)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_arm.h)
list(APPEND HEADERS src/crypto/cn/CryptoNight_arm.h)
else()
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86.h)
list(APPEND HEADERS src/crypto/cn/CryptoNight_x86.h)
endif()
set(SOURCES
"${SOURCES_BASE}"
"${SOURCES_BASE_HTTP}"
"${SOURCES_BACKEND}"
src/App.cpp
src/core/config/Config.cpp
src/core/config/ConfigTransform.cpp
src/core/Controller.cpp
src/core/Miner.cpp
src/core/Taskbar.cpp
src/net/JobResults.cpp
src/net/Network.cpp
src/net/strategies/DonateStrategy.cpp
src/Summary.cpp
src/xmrig.cpp
)
set(SOURCES_CRYPTO
src/crypto/cn/c_blake256.c
src/crypto/cn/c_groestl.c
src/crypto/cn/c_jh.c
@@ -127,6 +118,12 @@ set(SOURCES_CRYPTO
src/crypto/common/MemoryPool.cpp
src/crypto/common/Nonce.cpp
src/crypto/common/VirtualMemory.cpp
src/MinerApp.cpp
src/net/JobResults.cpp
src/net/Network.cpp
src/net/strategies/DonateStrategy.cpp
src/Summary.cpp
src/xmrig.cpp
)
if (CMAKE_C_COMPILER_ID MATCHES GNU)
@@ -135,105 +132,58 @@ endif()
if (WITH_VAES)
add_definitions(-DXMRIG_VAES)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h)
set(SOURCES_CRYPTO "${SOURCES_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.cpp)
list(APPEND HEADERS src/crypto/cn/CryptoNight_x86_vaes.h)
list(APPEND SOURCES src/crypto/cn/CryptoNight_x86_vaes.cpp)
if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
set_source_files_properties(src/crypto/cn/CryptoNight_x86_vaes.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize -mavx2 -mvaes")
endif()
endif()
if (WITH_HWLOC)
list(APPEND HEADERS_CRYPTO
list(APPEND HEADERS
src/crypto/common/NUMAMemoryPool.h
)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/common/NUMAMemoryPool.cpp
src/crypto/common/VirtualMemory_hwloc.cpp
)
endif()
if (XMRIG_OS_WIN)
list(APPEND SOURCES_OS
list(APPEND SOURCES
res/app.rc
src/crypto/common/VirtualMemory_win.cpp
)
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv)
elseif (XMRIG_OS_APPLE)
list(APPEND SOURCES_OS
src/crypto/common/VirtualMemory_unix.cpp
)
find_library(IOKIT_LIBRARY IOKit)
find_library(CORESERVICES_LIBRARY CoreServices)
set(EXTRA_LIBS ${IOKIT_LIBRARY} ${CORESERVICES_LIBRARY})
else()
list(APPEND SOURCES_OS
src/crypto/common/VirtualMemory_unix.cpp
)
list(APPEND SOURCES src/crypto/common/VirtualMemory_unix.cpp)
if (XMRIG_OS_ANDROID)
set(EXTRA_LIBS pthread rt dl log)
elseif (XMRIG_OS_LINUX)
list(APPEND SOURCES_OS
if (XMRIG_OS_LINUX AND NOT XMRIG_OS_ANDROID)
list(APPEND SOURCES
src/crypto/common/LinuxMemory.h
src/crypto/common/LinuxMemory.cpp
)
set(EXTRA_LIBS pthread rt dl)
elseif (XMRIG_OS_FREEBSD)
set(EXTRA_LIBS kvm pthread)
endif()
endif()
add_definitions(-DXMRIG_MINER_PROJECT -DXMRIG_LEGACY -DXMRIG_JSON_SINGLE_LINE_ARRAY)
add_definitions(-D__STDC_FORMAT_MACROS -DUNICODE -D_FILE_OFFSET_BITS=64)
find_package(UV REQUIRED)
include_directories(src)
include_directories(src/3rdparty)
include_directories(src/base)
include_directories(${UV_INCLUDE_DIR})
include(cmake/flags.cmake)
include(cmake/randomx.cmake)
include(cmake/argon2.cmake)
include(cmake/kawpow.cmake)
include(cmake/ghostrider.cmake)
include(cmake/OpenSSL.cmake)
include(cmake/asm.cmake)
if (WITH_CN_LITE)
add_definitions(/DXMRIG_ALGO_CN_LITE)
endif()
if (WITH_CN_HEAVY)
add_definitions(/DXMRIG_ALGO_CN_HEAVY)
endif()
if (WITH_CN_PICO)
add_definitions(/DXMRIG_ALGO_CN_PICO)
endif()
if (WITH_CN_FEMTO)
add_definitions(/DXMRIG_ALGO_CN_FEMTO)
endif()
include(randomx)
include(argon2)
include(kawpow)
include(ghostrider)
include(asm)
if (WITH_EMBEDDED_CONFIG)
add_definitions(/DXMRIG_FEATURE_EMBEDDED_CONFIG)
add_definitions(-DXMRIG_FEATURE_EMBEDDED_CONFIG)
endif()
include(src/hw/api/api.cmake)
include(src/hw/dmi/dmi.cmake)
if (WITH_DEBUG_LOG)
add_definitions(/DAPP_DEBUG)
endif()
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB} ${ARGON2_LIBRARY} ${ETHASH_LIBRARY} ${GHOSTRIDER_LIBRARY})
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${LIBS})
if (WIN32)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/bin/WinRing0/WinRing0x64.sys" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)

View File

@@ -1,25 +0,0 @@
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

@@ -1,25 +0,0 @@
find_path(
UV_INCLUDE_DIR
NAMES uv.h
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
find_path(UV_INCLUDE_DIR NAMES uv.h)
find_library(
UV_LIBRARY
NAMES libuv.a uv libuv
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
find_library(UV_LIBRARY NAMES libuv.a uv libuv)
set(UV_LIBRARIES ${UV_LIBRARY})
set(UV_INCLUDE_DIRS ${UV_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UV DEFAULT_MSG UV_LIBRARY UV_INCLUDE_DIR)

View File

@@ -1,64 +0,0 @@
if (WITH_TLS)
set(OPENSSL_ROOT_DIR ${XMRIG_DEPS})
if (WIN32)
set(OPENSSL_USE_STATIC_LIBS TRUE)
set(OPENSSL_MSVC_STATIC_RT TRUE)
set(EXTRA_LIBS ${EXTRA_LIBS} crypt32)
elseif (APPLE)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()
if (BUILD_STATIC)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()
find_package(OpenSSL)
if (OPENSSL_FOUND)
set(TLS_SOURCES
src/base/net/stratum/Tls.cpp
src/base/net/stratum/Tls.h
src/base/net/tls/ServerTls.cpp
src/base/net/tls/ServerTls.h
src/base/net/tls/TlsConfig.cpp
src/base/net/tls/TlsConfig.h
src/base/net/tls/TlsContext.cpp
src/base/net/tls/TlsContext.h
src/base/net/tls/TlsGen.cpp
src/base/net/tls/TlsGen.h
)
include_directories(${OPENSSL_INCLUDE_DIR})
if (WITH_HTTP)
set(TLS_SOURCES ${TLS_SOURCES}
src/base/net/https/HttpsClient.cpp
src/base/net/https/HttpsClient.h
src/base/net/https/HttpsContext.cpp
src/base/net/https/HttpsContext.h
src/base/net/https/HttpsServer.cpp
src/base/net/https/HttpsServer.h
)
endif()
else()
message(FATAL_ERROR "OpenSSL NOT found: use `-DWITH_TLS=OFF` to build without TLS support")
endif()
add_definitions(/DXMRIG_FEATURE_TLS)
else()
set(TLS_SOURCES "")
set(OPENSSL_LIBRARIES "")
remove_definitions(/DXMRIG_FEATURE_TLS)
if (WITH_HTTP)
set(TLS_SOURCES ${TLS_SOURCES}
src/base/net/http/HttpServer.cpp
src/base/net/http/HttpServer.h
)
endif()
set(CMAKE_PROJECT_NAME "${CMAKE_PROJECT_NAME}-notls")
endif()

View File

@@ -1,18 +1,13 @@
if (WITH_ARGON2)
add_definitions(/DXMRIG_ALGO_ARGON2)
list(APPEND HEADERS_CRYPTO
list(APPEND HEADERS
src/crypto/argon2/Hash.h
src/crypto/argon2/Impl.h
)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/argon2/Impl.cpp
)
add_subdirectory(src/3rdparty/argon2)
set(ARGON2_LIBRARY argon2)
else()
remove_definitions(/DXMRIG_ALGO_ARGON2)
set(ARGON2_LIBRARY "")
list(APPEND LIBS argon2)
endif()

View File

@@ -36,17 +36,16 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
endif()
add_library(${XMRIG_ASM_LIBRARY} STATIC ${XMRIG_ASM_FILES})
set(XMRIG_ASM_SOURCES
src/crypto/common/Assembly.h
list(APPEND HEADERS src/crypto/common/Assembly.h)
list(APPEND SOURCES
src/crypto/common/Assembly.cpp
src/crypto/cn/r/CryptonightR_gen.cpp
)
set_property(TARGET ${XMRIG_ASM_LIBRARY} PROPERTY LINKER_LANGUAGE C)
add_definitions(/DXMRIG_FEATURE_ASM)
list(APPEND LIBS ${XMRIG_ASM_LIBRARY})
add_definitions(-DXMRIG_FEATURE_ASM)
else()
set(XMRIG_ASM_SOURCES "")
set(XMRIG_ASM_LIBRARY "")
remove_definitions(/DXMRIG_FEATURE_ASM)
set(WITH_ASM OFF)
endif()

View File

@@ -1,59 +0,0 @@
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(XMRIG_64_BIT ON)
add_definitions(-DXMRIG_64_BIT)
else()
set(XMRIG_64_BIT OFF)
endif()
if (NOT CMAKE_SYSTEM_PROCESSOR)
message(WARNING "CMAKE_SYSTEM_PROCESSOR not defined")
endif()
include(CheckCXXCompilerFlag)
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
set(VAES_SUPPORTED ON)
else()
CHECK_CXX_COMPILER_FLAG("-mavx2 -mvaes" VAES_SUPPORTED)
endif()
if (NOT VAES_SUPPORTED)
set(WITH_VAES OFF)
endif()
if (XMRIG_64_BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
add_definitions(-DRAPIDJSON_SSE2)
else()
set(WITH_SSE4_1 OFF)
set(WITH_VAES OFF)
endif()
if (NOT ARM_TARGET)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv8-a)$")
set(ARM_TARGET 8)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7|armv7f|armv7s|armv7k|armv7-a|armv7l)$")
set(ARM_TARGET 7)
endif()
endif()
if (ARM_TARGET AND ARM_TARGET GREATER 6)
set(XMRIG_ARM ON)
add_definitions(-DXMRIG_ARM=${ARM_TARGET})
message(STATUS "Use ARM_TARGET=${ARM_TARGET} (${CMAKE_SYSTEM_PROCESSOR})")
if (ARM_TARGET EQUAL 8)
CHECK_CXX_COMPILER_FLAG(-march=armv8-a+crypto XMRIG_ARM_CRYPTO)
if (XMRIG_ARM_CRYPTO)
add_definitions(-DXMRIG_ARM_CRYPTO)
set(ARM8_CXX_FLAGS "-march=armv8-a+crypto")
else()
set(ARM8_CXX_FLAGS "-march=armv8-a")
endif()
endif()
endif()
if (WITH_SSE4_1)
add_definitions(-DXMRIG_FEATURE_SSE4_1)
endif()

View File

@@ -1,110 +0,0 @@
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(/DNDEBUG)
endif()
include(CheckSymbolExists)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-aliasing")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions -fno-rtti -Wno-strict-aliasing -Wno-class-memaccess")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -s")
if (ARM_TARGET EQUAL 8)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM8_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM8_CXX_FLAGS} -flax-vector-conversions")
elseif (ARM_TARGET EQUAL 7)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon -flax-vector-conversions")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
add_definitions(/DHAVE_ROTR)
endif()
if (WIN32)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,--large-address-aware")
endif()
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
add_definitions(/D_GNU_SOURCE)
if (${CMAKE_VERSION} VERSION_LESS "3.1.0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-2")
add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE)
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Oi /DNDEBUG /GL")
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Oi /DNDEBUG /GL")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Ob1 /Zi /DRELWITHDEBINFO")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Ob1 /Zi /DRELWITHDEBINFO")
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
add_definitions(/D_CRT_NONSTDC_NO_WARNINGS)
add_definitions(/DNOMINMAX)
add_definitions(/DHAVE_ROTR)
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast -funroll-loops -fmerge-all-constants")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions -fno-rtti -Wno-missing-braces")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -funroll-loops -fmerge-all-constants")
if (ARM_TARGET EQUAL 8)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM8_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM8_CXX_FLAGS}")
elseif (ARM_TARGET EQUAL 7)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -march=${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=${CMAKE_SYSTEM_PROCESSOR}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR)
if (HAVE_ROTR)
add_definitions(/DHAVE_ROTR)
endif()
endif()
if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
endif()
if (NOT WIN32)
check_symbol_exists("__builtin___clear_cache" "stdlib.h" HAVE_BUILTIN_CLEAR_CACHE)
if (HAVE_BUILTIN_CLEAR_CACHE)
add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE)
endif()
endif()

View File

@@ -1,8 +1,4 @@
if (WITH_GHOSTRIDER)
add_definitions(/DXMRIG_ALGO_GHOSTRIDER)
add_subdirectory(src/crypto/ghostrider)
set(GHOSTRIDER_LIBRARY ghostrider)
else()
remove_definitions(/DXMRIG_ALGO_GHOSTRIDER)
set(GHOSTRIDER_LIBRARY "")
list(APPEND LIBS ghostrider)
endif()

View File

@@ -1,19 +1,14 @@
if (WITH_KAWPOW)
add_definitions(/DXMRIG_ALGO_KAWPOW)
list(APPEND HEADERS_CRYPTO
list(APPEND HEADERS
src/crypto/kawpow/KPCache.h
src/crypto/kawpow/KPHash.h
)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/kawpow/KPCache.cpp
src/crypto/kawpow/KPHash.cpp
)
add_subdirectory(src/base/3rdparty/libethash)
set(ETHASH_LIBRARY ethash)
else()
remove_definitions(/DXMRIG_ALGO_KAWPOW)
set(ETHASH_LIBRARY "")
list(INSERT LIBS 0 ethash)
endif()

View File

@@ -1,52 +0,0 @@
if (WIN32)
set(XMRIG_OS_WIN ON)
elseif (APPLE)
set(XMRIG_OS_APPLE ON)
if (IOS OR CMAKE_SYSTEM_NAME STREQUAL iOS)
set(XMRIG_OS_IOS ON)
else()
set(XMRIG_OS_MACOS ON)
endif()
else()
set(XMRIG_OS_UNIX ON)
if (ANDROID OR CMAKE_SYSTEM_NAME MATCHES "Android")
set(XMRIG_OS_ANDROID ON)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(XMRIG_OS_LINUX ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(XMRIG_OS_FREEBSD ON)
endif()
endif()
if (XMRIG_OS_WIN)
add_definitions(-DWIN32 -DXMRIG_OS_WIN)
elseif(XMRIG_OS_APPLE)
add_definitions(-DXMRIG_OS_APPLE)
if (XMRIG_OS_IOS)
add_definitions(-DXMRIG_OS_IOS)
else()
add_definitions(-DXMRIG_OS_MACOS)
endif()
if (XMRIG_ARM)
set(WITH_SECURE_JIT ON)
endif()
elseif(XMRIG_OS_UNIX)
add_definitions(-DXMRIG_OS_UNIX)
if (XMRIG_OS_ANDROID)
add_definitions(-DXMRIG_OS_ANDROID)
elseif (XMRIG_OS_LINUX)
add_definitions(-DXMRIG_OS_LINUX)
elseif (XMRIG_OS_FREEBSD)
add_definitions(-DXMRIG_OS_FREEBSD)
endif()
endif()
if (WITH_SECURE_JIT)
add_definitions(-DXMRIG_SECURE_JIT)
endif()

View File

@@ -1,8 +1,5 @@
if (WITH_RANDOMX)
add_definitions(/DXMRIG_ALGO_RANDOMX)
set(WITH_ARGON2 ON)
list(APPEND HEADERS_CRYPTO
list(APPEND HEADERS
src/crypto/rx/Rx.h
src/crypto/rx/RxAlgo.h
src/crypto/rx/RxBasicStorage.h
@@ -14,7 +11,7 @@ if (WITH_RANDOMX)
src/crypto/rx/RxVm.h
)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/randomx/aes_hash.cpp
src/crypto/randomx/allocator.cpp
src/crypto/randomx/blake2_generator.cpp
@@ -44,19 +41,19 @@ if (WITH_RANDOMX)
if (WITH_ASM AND CMAKE_C_COMPILER_ID MATCHES MSVC)
enable_language(ASM_MASM)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/randomx/jit_compiler_x86_static.asm
src/crypto/randomx/jit_compiler_x86.cpp
)
elseif (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/randomx/jit_compiler_x86_static.S
src/crypto/randomx/jit_compiler_x86.cpp
)
# cheat because cmake and ccache hate each other
set_property(SOURCE src/crypto/randomx/jit_compiler_x86_static.S PROPERTY LANGUAGE C)
elseif (XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/randomx/jit_compiler_a64_static.S
src/crypto/randomx/jit_compiler_a64.cpp
)
@@ -67,16 +64,22 @@ if (WITH_RANDOMX)
set_property(SOURCE src/crypto/randomx/jit_compiler_a64_static.S PROPERTY LANGUAGE C)
endif()
else()
list(APPEND SOURCES_CRYPTO
src/crypto/randomx/jit_compiler_fallback.cpp
)
list(APPEND SOURCES src/crypto/randomx/jit_compiler_fallback.cpp)
endif()
if (WITH_SSE4_1)
list(APPEND SOURCES_CRYPTO src/crypto/randomx/blake2/blake2b_sse41.c)
list(APPEND SOURCES src/crypto/randomx/blake2/blake2b_sse41.c)
if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
set_source_files_properties(src/crypto/randomx/blake2/blake2b_sse41.c PROPERTIES COMPILE_FLAGS -msse4.1)
set_source_files_properties(src/crypto/randomx/blake2/blake2b_sse41.c PROPERTIES COMPILE_FLAGS "-Ofast -msse4.1")
endif()
endif()
if (WITH_AVX2)
list(APPEND SOURCES src/crypto/randomx/blake2/avx2/blake2b_avx2.c)
if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
set_source_files_properties(src/crypto/randomx/blake2/avx2/blake2b_avx2.c PROPERTIES COMPILE_FLAGS "-Ofast -mavx2")
endif()
endif()
@@ -85,56 +88,49 @@ if (WITH_RANDOMX)
endif()
if (WITH_HWLOC)
list(APPEND HEADERS_CRYPTO
src/crypto/rx/RxNUMAStorage.h
)
list(APPEND SOURCES_CRYPTO
src/crypto/rx/RxNUMAStorage.cpp
)
list(APPEND HEADERS src/crypto/rx/RxNUMAStorage.h)
list(APPEND SOURCES src/crypto/rx/RxNUMAStorage.cpp)
endif()
if (WITH_MSR AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND (XMRIG_OS_WIN OR XMRIG_OS_LINUX))
add_definitions(/DXMRIG_FEATURE_MSR)
add_definitions(/DXMRIG_FIX_RYZEN)
message("-- WITH_MSR=ON")
add_definitions(-DXMRIG_FEATURE_MSR -DXMRIG_FIX_RYZEN)
if (XMRIG_OS_WIN)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/rx/RxFix_win.cpp
src/hw/msr/Msr_win.cpp
)
elseif (XMRIG_OS_LINUX)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/rx/RxFix_linux.cpp
src/hw/msr/Msr_linux.cpp
)
endif()
list(APPEND HEADERS_CRYPTO
list(APPEND HEADERS
src/crypto/rx/RxFix.h
src/crypto/rx/RxMsr.h
src/hw/msr/Msr.h
src/hw/msr/MsrItem.h
)
list(APPEND SOURCES_CRYPTO
list(APPEND SOURCES
src/crypto/rx/RxMsr.cpp
src/hw/msr/Msr.cpp
src/hw/msr/MsrItem.cpp
)
else()
remove_definitions(/DXMRIG_FEATURE_MSR)
remove_definitions(/DXMRIG_FIX_RYZEN)
message("-- WITH_MSR=OFF")
set(WITH_MSR OFF)
endif()
if (WITH_PROFILING)
add_definitions(/DXMRIG_FEATURE_PROFILING)
add_definitions(-DXMRIG_FEATURE_PROFILING)
list(APPEND HEADERS_CRYPTO src/crypto/rx/Profiler.h)
list(APPEND SOURCES_CRYPTO src/crypto/rx/Profiler.cpp)
list(APPEND HEADERS src/crypto/rx/Profiler.h)
list(APPEND SOURCES src/crypto/rx/Profiler.cpp)
endif()
else()
remove_definitions(/DXMRIG_ALGO_RANDOMX)
endif()
message(STATUS "WITH_MSR \t= ${WITH_MSR}")
message(STATUS "WITH_PROFILING \t= ${WITH_PROFILING}")

View File

@@ -27,7 +27,7 @@
#include <uv.h>
#include "App.h"
#include "MinerApp.h"
#include "backend/cpu/Cpu.h"
#include "base/io/Console.h"
#include "base/io/log/Log.h"
@@ -39,19 +39,19 @@
#include "version.h"
xmrig::App::App(Process *process)
xmrig::MinerApp::MinerApp()
{
m_controller = std::make_shared<Controller>(process);
m_controller = std::make_shared<Controller>();
}
xmrig::App::~App()
xmrig::MinerApp::~MinerApp()
{
Cpu::release();
}
int xmrig::App::exec()
int xmrig::MinerApp::exec()
{
if (!m_controller->isReady()) {
LOG_EMERG("no valid configuration found, try https://xmrig.com/wizard");
@@ -66,7 +66,7 @@ int xmrig::App::exec()
return rc;
}
if (!m_controller->isBackground()) {
if (!Log::isBackground()) {
m_console = std::make_shared<Console>(this);
}
@@ -87,7 +87,7 @@ int xmrig::App::exec()
}
void xmrig::App::onConsoleCommand(char command)
void xmrig::MinerApp::onConsoleCommand(char command)
{
if (command == 3) {
LOG_WARN("%s " YELLOW("Ctrl+C received, exiting"), Tags::signal());
@@ -99,7 +99,7 @@ void xmrig::App::onConsoleCommand(char command)
}
void xmrig::App::onSignal(int signum)
void xmrig::MinerApp::onSignal(int signum)
{
switch (signum)
{
@@ -114,7 +114,7 @@ void xmrig::App::onSignal(int signum)
}
void xmrig::App::close()
void xmrig::MinerApp::close()
{
m_signals.reset();
m_console.reset();

View File

@@ -23,8 +23,8 @@
* of this Program grant you additional permission to convey the resulting work.
*/
#ifndef XMRIG_APP_H
#define XMRIG_APP_H
#ifndef XMRIG_MINERAPP_H
#define XMRIG_MINERAPP_H
#include "base/kernel/interfaces/IConsoleListener.h"
@@ -45,13 +45,13 @@ class Process;
class Signals;
class App : public IConsoleListener, public ISignalListener
class MinerApp : public IConsoleListener, public ISignalListener
{
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(App)
XMRIG_DISABLE_COPY_MOVE(MinerApp)
App(Process *process);
~App() override;
MinerApp();
~MinerApp() override;
int exec();
@@ -71,4 +71,4 @@ private:
} /* namespace xmrig */
#endif /* XMRIG_APP_H */
#endif /* XMRIG_MINERAPP_H */

View File

@@ -18,17 +18,17 @@
#include <cinttypes>
#include <cstdio>
#include <uv.h>
#include "Summary.h"
#include "backend/cpu/Cpu.h"
#include "base/io/log/Log.h"
#include "base/kernel/OS.h"
#include "base/net/stratum/Pool.h"
#include "core/config/Config.h"
#include "core/Controller.h"
#include "crypto/common/Assembly.h"
#include "crypto/common/VirtualMemory.h"
#include "Summary.h"
#include "version.h"
@@ -117,8 +117,8 @@ static void print_cpu(const Config *)
static void print_memory(const Config *config)
{
constexpr size_t oneGiB = 1024U * 1024U * 1024U;
const auto freeMem = static_cast<double>(uv_get_free_memory());
const auto totalMem = static_cast<double>(uv_get_total_memory());
const auto freeMem = static_cast<double>(OS::freemem());
const auto totalMem = static_cast<double>(OS::totalmem());
const double percent = freeMem > 0 ? ((totalMem - freeMem) / totalMem * 100.0) : 100.0;

View File

@@ -27,7 +27,6 @@
#include "backend/common/Workers.h"
#include "backend/cpu/Cpu.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Chrono.h"
#include "base/tools/String.h"
@@ -106,13 +105,13 @@ public:
inline void print() const
{
if (m_started == 0) {
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), Tags::cpu());
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), cpu_tag());
return;
}
LOG_INFO("%s" GREEN_BOLD(" READY") " threads %s%zu/%zu (%zu)" CLEAR " huge pages %s%1.0f%% %zu/%zu" CLEAR " memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"),
Tags::cpu(),
cpu_tag(),
m_errors == 0 ? CYAN_BOLD_S : YELLOW_BOLD_S,
m_totalStarted, std::max(m_totalStarted, m_threads), m_ways,
(m_hugePages.isFullyAllocated() ? GREEN_BOLD_S : (m_hugePages.allocated == 0 ? RED_BOLD_S : YELLOW_BOLD_S)),
@@ -145,7 +144,7 @@ public:
inline void start()
{
LOG_INFO("%s use profile " BLUE_BG(WHITE_BOLD_S " %s ") WHITE_BOLD_S " (" CYAN_BOLD("%zu") WHITE_BOLD(" thread%s)") " scratchpad " CYAN_BOLD("%zu KB"),
Tags::cpu(),
cpu_tag(),
profileName.data(),
threads.size(),
threads.size() > 1 ? "s" : "",
@@ -231,13 +230,15 @@ const char *xmrig::backend_tag(uint32_t backend)
}
# endif
return Tags::cpu();
return cpu_tag();
}
const char *xmrig::cpu_tag()
{
return Tags::cpu();
static const char *tag = CYAN_BG_BOLD(WHITE_BOLD_S " cpu ");
return tag;
}
@@ -297,7 +298,7 @@ void xmrig::CpuBackend::prepare(const Job &nextJob)
if ((f == Algorithm::ARGON2) || (f == Algorithm::RANDOM_X)) {
if (argon2::Impl::select(d_ptr->controller->config()->cpu().argon2Impl())) {
LOG_INFO("%s use " WHITE_BOLD("argon2") " implementation " CSI "1;%dm" "%s",
Tags::cpu(),
cpu_tag(),
argon2::Impl::name() == "default" ? 33 : 32,
argon2::Impl::name().data()
);
@@ -360,7 +361,7 @@ void xmrig::CpuBackend::setJob(const Job &job)
d_ptr->profileName = cpu.threads().profileName(job.algorithm());
if (d_ptr->profileName.isNull() || threads.empty()) {
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), Tags::cpu());
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), cpu_tag());
return stop();
}
@@ -405,7 +406,7 @@ void xmrig::CpuBackend::stop()
d_ptr->workers.stop();
d_ptr->threads.clear();
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::cpu(), Chrono::steadyMSecs() - ts);
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), cpu_tag(), Chrono::steadyMSecs() - ts);
}

View File

@@ -22,28 +22,8 @@ set(SOURCES_BACKEND_CPU
)
if (WITH_HWLOC)
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
add_subdirectory(src/base/3rdparty/hwloc)
include_directories(src/base/3rdparty/hwloc/include)
set(CPUID_LIB hwloc)
else()
find_package(HWLOC REQUIRED)
include_directories(${HWLOC_INCLUDE_DIR})
set(CPUID_LIB ${HWLOC_LIBRARY})
endif()
add_definitions(/DXMRIG_FEATURE_HWLOC)
if (HWLOC_DEBUG)
add_definitions(/DXMRIG_HWLOC_DEBUG)
endif()
list(APPEND HEADERS_BACKEND_CPU src/backend/cpu/platform/HwlocCpuInfo.h)
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/HwlocCpuInfo.cpp)
else()
remove_definitions(/DXMRIG_FEATURE_HWLOC)
set(CPUID_LIB "")
endif()
if (XMRIG_ARM)

View File

@@ -32,7 +32,6 @@
#include "backend/cuda/wrappers/CudaDevice.h"
#include "backend/cuda/wrappers/CudaLib.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Chrono.h"
#include "base/tools/String.h"
@@ -101,13 +100,13 @@ public:
inline void print() const
{
if (m_started == 0) {
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), Tags::nvidia());
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), cuda_tag());
return;
}
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " "%s%zu/%zu" BLACK_BOLD(" (%" PRIu64 " ms)"),
Tags::nvidia(),
cuda_tag(),
m_errors == 0 ? CYAN_BOLD_S : YELLOW_BOLD_S,
m_started,
m_threads,
@@ -204,7 +203,7 @@ public:
inline void start(const Job &job)
{
LOG_INFO("%s use profile " BLUE_BG(WHITE_BOLD_S " %s ") WHITE_BOLD_S " (" CYAN_BOLD("%zu") WHITE_BOLD(" thread%s)") " scratchpad " CYAN_BOLD("%zu KB"),
Tags::nvidia(),
cuda_tag(),
profileName.data(),
threads.size(),
threads.size() > 1 ? "s" : "",
@@ -267,7 +266,7 @@ public:
}
LOG_INFO("%s" CYAN_BOLD(" #%u") YELLOW(" %s") MAGENTA_BOLD("%4uW") CSI "1;%um %2uC" CLEAR WHITE_BOLD("%s") "%s",
Tags::nvidia(),
cuda_tag(),
device.index(),
device.topology().toString().data(),
health.power,
@@ -298,7 +297,9 @@ public:
const char *xmrig::cuda_tag()
{
return Tags::nvidia();
static const char *tag = GREEN_BG_BOLD(WHITE_BOLD_S " nvidia ");
return tag;
}
@@ -438,7 +439,7 @@ void xmrig::CudaBackend::setJob(const Job &job)
d_ptr->profileName = cuda.threads().profileName(job.algorithm());
if (d_ptr->profileName.isNull() || threads.empty()) {
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), Tags::nvidia());
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), cuda_tag());
return stop();
}
@@ -479,7 +480,7 @@ void xmrig::CudaBackend::stop()
d_ptr->workers.stop();
d_ptr->threads.clear();
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::nvidia(), Chrono::steadyMSecs() - ts);
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), cuda_tag(), Chrono::steadyMSecs() - ts);
}

View File

@@ -18,10 +18,10 @@
#include "backend/cuda/runners/CudaKawPowRunner.h"
#include "3rdparty/libethash/data_sizes.h"
#include "backend/common/Tags.h"
#include "backend/cuda/CudaLaunchData.h"
#include "backend/cuda/wrappers/CudaLib.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Chrono.h"
#include "crypto/kawpow/KPCache.h"
@@ -61,12 +61,12 @@ bool xmrig::CudaKawPowRunner::set(const Job &job, uint8_t *blob)
const bool result = CudaLib::kawPowPrepare(m_ctx, cache.data(), cache.size(), cache.l1_cache(), KPCache::dag_size(epoch), height, dag_sizes);
if (!result) {
LOG_ERR("%s " YELLOW("KawPow") RED(" failed to initialize DAG: ") RED_BOLD("%s"), Tags::nvidia(), CudaLib::lastError(m_ctx));
LOG_ERR("%s " YELLOW("KawPow") RED(" failed to initialize DAG: ") RED_BOLD("%s"), cuda_tag(), CudaLib::lastError(m_ctx));
}
else {
const int64_t dt = Chrono::steadyMSecs() - start_ms;
if (dt > 1000) {
LOG_INFO("%s " YELLOW("KawPow") " DAG for epoch " WHITE_BOLD("%u") " calculated " BLACK_BOLD("(%" PRIu64 "ms)"), Tags::nvidia(), epoch, dt);
LOG_INFO("%s " YELLOW("KawPow") " DAG for epoch " WHITE_BOLD("%u") " calculated " BLACK_BOLD("(%" PRIu64 "ms)"), cuda_tag(), epoch, dt);
}
}

View File

@@ -352,7 +352,7 @@ bool xmrig::CudaLib::open()
# ifdef XMRIG_OS_LINUX
if (m_loader == defaultLoader) {
m_loader = Process::location(Process::ExeLocation, m_loader);
m_loader = Process::locate(Process::ExeLocation, m_loader);
}
else {
return false;

View File

@@ -33,7 +33,6 @@
#include "backend/opencl/wrappers/OclContext.h"
#include "backend/opencl/wrappers/OclLib.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Chrono.h"
#include "base/tools/String.h"
@@ -101,13 +100,13 @@ public:
inline void print() const
{
if (m_started == 0) {
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), Tags::opencl());
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), ocl_tag());
return;
}
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " "%s%zu/%zu" BLACK_BOLD(" (%" PRIu64 " ms)"),
Tags::opencl(),
ocl_tag(),
m_errors == 0 ? CYAN_BOLD_S : YELLOW_BOLD_S,
m_started,
m_threads,
@@ -192,7 +191,7 @@ public:
inline void start(const Job &job)
{
LOG_INFO("%s use profile " BLUE_BG(WHITE_BOLD_S " %s ") WHITE_BOLD_S " (" CYAN_BOLD("%zu") WHITE_BOLD(" thread%s)") " scratchpad " CYAN_BOLD("%zu KB"),
Tags::opencl(),
ocl_tag(),
profileName.data(),
threads.size(),
threads.size() > 1 ? "s" : "",
@@ -246,7 +245,7 @@ public:
const auto health = AdlLib::health(device);
LOG_INFO("%s" CYAN_BOLD(" #%u") YELLOW(" %s") MAGENTA_BOLD("%4uW") CSI "1;%um %2uC" CYAN_BOLD(" %4u") CYAN("RPM") WHITE_BOLD(" %u/%u") "MHz",
Tags::opencl(),
ocl_tag(),
device.index(),
device.topology().toString().data(),
health.power,
@@ -278,7 +277,9 @@ public:
const char *xmrig::ocl_tag()
{
return Tags::opencl();
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " opencl ");
return tag;
}
@@ -418,13 +419,13 @@ void xmrig::OclBackend::setJob(const Job &job)
d_ptr->profileName = cl.threads().profileName(job.algorithm());
if (d_ptr->profileName.isNull() || threads.empty()) {
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), Tags::opencl());
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), ocl_tag());
return stop();
}
if (!d_ptr->context.init(d_ptr->devices, threads)) {
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (OpenCL context unavailable)"), Tags::opencl());
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (OpenCL context unavailable)"), ocl_tag());
return stop();
}
@@ -467,7 +468,7 @@ void xmrig::OclBackend::stop()
OclSharedState::release();
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::opencl(), Chrono::steadyMSecs() - ts);
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), ocl_tag(), Chrono::steadyMSecs() - ts);
}

View File

@@ -26,7 +26,6 @@
#include "backend/opencl/wrappers/OclLib.h"
#include "base/io/log/Log.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Chrono.h"
#include "crypto/common/VirtualMemory.h"
@@ -159,7 +158,7 @@ void OclKawPowRunner::set(const Job &job, uint8_t *blob)
OclLib::finish(m_queue);
LOG_INFO("%s " YELLOW("KawPow") " DAG for epoch " WHITE_BOLD("%u") " calculated " BLACK_BOLD("(%" PRIu64 "ms)"), Tags::opencl(), epoch, Chrono::steadyMSecs() - start_ms);
LOG_INFO("%s " YELLOW("KawPow") " DAG for epoch " WHITE_BOLD("%u") " calculated " BLACK_BOLD("(%" PRIu64 "ms)"), ocl_tag(), epoch, Chrono::steadyMSecs() - start_ms);
}
const uint64_t target = job.target();

View File

@@ -19,6 +19,7 @@
#include "backend/opencl/runners/tools/OclKawPow.h"
#include "3rdparty/libethash/data_sizes.h"
#include "3rdparty/libethash/ethash_internal.h"
#include "backend/common/Tags.h"
#include "backend/opencl/cl/kawpow/kawpow_cl.h"
#include "backend/opencl/interfaces/IOclRunner.h"
#include "backend/opencl/OclCache.h"
@@ -27,7 +28,6 @@
#include "backend/opencl/wrappers/OclError.h"
#include "backend/opencl/wrappers/OclLib.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/tools/Baton.h"
#include "base/tools/Chrono.h"
#include "crypto/kawpow/KPHash.h"
@@ -228,7 +228,7 @@ public:
return nullptr;
}
LOG_INFO("%s " YELLOW("KawPow") " program for period " WHITE_BOLD("%" PRIu64) " compiled " BLACK_BOLD("(%" PRIu64 "ms)"), Tags::opencl(), period, Chrono::steadyMSecs() - ts);
LOG_INFO("%s " YELLOW("KawPow") " program for period " WHITE_BOLD("%" PRIu64) " compiled " BLACK_BOLD("(%" PRIu64 "ms)"), ocl_tag(), period, Chrono::steadyMSecs() - ts);
cache.add(runner.algorithm(), period, worksize, runner.deviceIndex(), program, kernel);

View File

@@ -1,12 +1,6 @@
/* 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-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/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
@@ -22,10 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/opencl/wrappers/OclPlatform.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/opencl/wrappers/OclLib.h"
#include "base/kernel/Process.h"
#include "base/tools/Arguments.h"
bool xmrig::OclPlatform::printPlatforms(int &rc)
{
if (Process::arguments().contains("--print-platforms")) {
if (OclLib::init()) {
OclPlatform::print();
}
else {
rc = 1;
}
return true;
}
return false;
}
std::vector<xmrig::OclPlatform> xmrig::OclPlatform::get()

View File

@@ -1,12 +1,6 @@
/* 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-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/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
@@ -45,6 +39,7 @@ public:
OclPlatform() = default;
OclPlatform(size_t index, cl_platform_id id) : m_id(id), m_index(index) {}
static bool printPlatforms(int &rc);
static std::vector<OclPlatform> get();
static void print();

View File

@@ -33,8 +33,8 @@
#include <cassert>
xmrig::Controller::Controller(Process *process) :
Base(process)
xmrig::Controller::Controller() :
Base()
{
}

View File

@@ -38,9 +38,9 @@ class Network;
class Controller : public Base
{
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Controller)
XMRIG_DISABLE_COPY_MOVE(Controller)
Controller(Process *process);
Controller();
~Controller() override;
int init() override;

View File

@@ -358,19 +358,18 @@ public:
Algorithms algorithms;
bool active = false;
bool battery_power = false;
bool user_active = false;
bool enabled = true;
int32_t auto_pause = 0;
bool reset = true;
bool user_active = false;
Controller *controller;
int32_t auto_pause = 0;
Job job;
mutable std::map<Algorithm::Id, double> maxHashrate;
std::vector<IBackend *> backends;
String userJobId;
Taskbar taskbar;
Timer *timer = nullptr;
uint64_t ticks = 0;
Taskbar m_taskbar;
};
@@ -494,7 +493,7 @@ void xmrig::Miner::execCommand(char command)
void xmrig::Miner::pause()
{
d_ptr->active = false;
d_ptr->m_taskbar.setActive(false);
d_ptr->taskbar.setActive(false);
Nonce::pause(true);
Nonce::touch();
@@ -514,7 +513,7 @@ void xmrig::Miner::setEnabled(bool enabled)
}
d_ptr->enabled = enabled;
d_ptr->m_taskbar.setEnabled(enabled);
d_ptr->taskbar.setEnabled(enabled);
if (enabled) {
LOG_INFO("%s " GREEN_BOLD("resumed"), Tags::miner());
@@ -562,6 +561,12 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
const uint8_t index = donate ? 1 : 0;
d_ptr->reset = !(d_ptr->job.index() == 1 && index == 0 && d_ptr->userJobId == job.id());
// Don't reset nonce if pool sends the same hashing blob again, but with different difficulty (for example)
if (d_ptr->job.isEqualBlob(job)) {
d_ptr->reset = false;
}
d_ptr->job = job;
d_ptr->job.setIndex(index);
@@ -584,7 +589,7 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
mutex.unlock();
d_ptr->active = true;
d_ptr->m_taskbar.setActive(true);
d_ptr->taskbar.setActive(true);
if (ready) {
d_ptr->handleJobChange();

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/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
@@ -28,80 +28,80 @@
namespace xmrig {
struct TaskbarPrivate
class Taskbar::Private
{
TaskbarPrivate()
public:
XMRIG_DISABLE_COPY_MOVE(Private)
Private()
{
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if (hr < 0) {
return;
}
hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_taskbar));
hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbar));
if (hr < 0) {
return;
}
hr = m_taskbar->HrInit();
hr = taskbar->HrInit();
if (hr < 0) {
m_taskbar->Release();
m_taskbar = nullptr;
taskbar->Release();
taskbar = nullptr;
return;
}
m_consoleWnd = GetConsoleWindow();
console = GetConsoleWindow();
}
~TaskbarPrivate()
~Private()
{
if (m_taskbar) {
m_taskbar->Release();
if (taskbar) {
taskbar->Release();
}
CoUninitialize();
}
ITaskbarList3* m_taskbar = nullptr;
HWND m_consoleWnd = nullptr;
void update()
{
if (taskbar) {
if (active) {
taskbar->SetProgressState(console, enabled ? TBPF_NOPROGRESS : TBPF_PAUSED);
taskbar->SetProgressValue(console, enabled ? 0 : 1, 1);
}
else {
taskbar->SetProgressState(console, TBPF_ERROR);
taskbar->SetProgressValue(console, 1, 1);
}
}
}
bool active = false;
bool enabled = true;
HWND console = nullptr;
ITaskbarList3 *taskbar = nullptr;
};
Taskbar::Taskbar() : d_ptr(new TaskbarPrivate())
Taskbar::Taskbar() :
d(std::make_shared<Private>())
{
}
Taskbar::~Taskbar()
{
delete d_ptr;
}
void Taskbar::setActive(bool active)
{
m_active = active;
updateTaskbarColor();
d->active = active;
d->update();
}
void Taskbar::setEnabled(bool enabled)
{
m_enabled = enabled;
updateTaskbarColor();
}
void Taskbar::updateTaskbarColor()
{
if (d_ptr->m_taskbar) {
if (m_active) {
d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, m_enabled ? TBPF_NOPROGRESS : TBPF_PAUSED);
d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, m_enabled ? 0 : 1, 1);
}
else {
d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, TBPF_ERROR);
d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, 1, 1);
}
}
d->enabled = enabled;
d->update();
}
@@ -114,8 +114,7 @@ void Taskbar::updateTaskbarColor()
namespace xmrig {
Taskbar::Taskbar() {}
Taskbar::~Taskbar() {}
Taskbar::Taskbar() = default;
void Taskbar::setActive(bool) {}
void Taskbar::setEnabled(bool) {}

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/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
@@ -20,32 +20,31 @@
#define XMRIG_TASKBAR_H
#include "base/tools/Object.h"
namespace xmrig {
struct TaskbarPrivate;
class Taskbar
{
public:
XMRIG_DISABLE_COPY_MOVE(Taskbar)
Taskbar();
~Taskbar();
~Taskbar() = default;
void setActive(bool active);
void setEnabled(bool enabled);
private:
bool m_active = false;
bool m_enabled = true;
TaskbarPrivate* d_ptr = nullptr;
void updateTaskbarColor();
# ifdef _WIN32
XMRIG_DECL_PRIVATE()
# endif
};
} // namespace xmrig
#endif /* XMRIG_TASKBAR_H */
#endif // XMRIG_TASKBAR_H

View File

@@ -19,7 +19,6 @@
#include <algorithm>
#include <cinttypes>
#include <cstring>
#include <uv.h>
#include "core/config/Config.h"
@@ -263,7 +262,6 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember(StringRef(kApi), api, allocator);
doc.AddMember(StringRef(kHttp), m_http.toJSON(doc), allocator);
doc.AddMember(StringRef(kAutosave), isAutoSave(), allocator);
doc.AddMember(StringRef(kBackground), isBackground(), allocator);
doc.AddMember(StringRef(kColors), Log::isColors(), allocator);
doc.AddMember(StringRef(kTitle), title().toJSON(), allocator);

View File

@@ -21,7 +21,7 @@
#ifdef _MSC_VER
# include "getopt/getopt.h"
# include "3rdparty/getopt/getopt.h"
#else
# include <getopt.h>
#endif

View File

@@ -25,16 +25,13 @@
#define XMRIG_USAGE_H
#include "version.h"
#include <string>
namespace xmrig {
static inline const std::string &usage()
static const std::string &usage()
{
static std::string u;
@@ -42,7 +39,7 @@ static inline const std::string &usage()
return u;
}
u += "Usage: " APP_ID " [OPTIONS]\n\nNetwork:\n";
u += "\nNetwork:\n";
u += " -o, --url=URL URL of mining server\n";
u += " -a, --algo=ALGO mining algorithm https://xmrig.com/docs/algorithms\n";
u += " --coin=COIN specify coin instead of algorithm\n";
@@ -168,15 +165,8 @@ static inline const std::string &usage()
u += "\nMisc:\n";
u += " -c, --config=FILE load a JSON-format configuration file\n";
u += " -B, --background run the miner in the background\n";
u += " -V, --version output version information and exit\n";
u += " -h, --help display this help and exit\n";
u += " --dry-run test configuration and exit\n";
# ifdef XMRIG_FEATURE_HWLOC
u += " --export-topology export hwloc topology to a XML file and exit\n";
# endif
# ifdef XMRIG_OS_WIN
u += " --title set custom console window title\n";
u += " --no-title disable setting console window title\n";

View File

@@ -485,7 +485,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
}
}
lo = __umul128(idx0, cl, &hi);
lo = xmrig_umul128(idx0, cl, &hi);
if (BASE == Algorithm::CN_2) {
if (ALGO == Algorithm::CN_R) {
@@ -661,7 +661,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
}
}
lo = __umul128(idx0, cl, &hi);
lo = xmrig_umul128(idx0, cl, &hi);
if (BASE == Algorithm::CN_2) {
if (ALGO == Algorithm::CN_R) {
@@ -721,7 +721,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
}
}
lo = __umul128(idx1, cl, &hi);
lo = xmrig_umul128(idx1, cl, &hi);
if (BASE == Algorithm::CN_2) {
if (ALGO == Algorithm::CN_R) {

View File

@@ -774,7 +774,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
}
}
lo = __umul128(idx0, cl, &hi);
lo = xmrig_umul128(idx0, cl, &hi);
if (BASE == Algorithm::CN_2) {
if (ALGO == Algorithm::CN_R) {
@@ -1395,7 +1395,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
}
}
lo = __umul128(idx0, cl, &hi);
lo = xmrig_umul128(idx0, cl, &hi);
if (BASE == Algorithm::CN_2) {
if (ALGO == Algorithm::CN_R) {
@@ -1453,7 +1453,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
}
}
lo = __umul128(idx1, cl, &hi);
lo = xmrig_umul128(idx1, cl, &hi);
if (BASE == Algorithm::CN_2) {
if (ALGO == Algorithm::CN_R) {
@@ -1651,7 +1651,7 @@ static NOINLINE void cryptonight_quad_hash_gr_sse41(const uint8_t* __restrict__
VARIANT2_INTEGER_MATH(part, cl##part, c); \
} \
} \
lo = __umul128(idx, cl##part, &hi); \
lo = xmrig_umul128(idx, cl##part, &hi); \
if (BASE == Algorithm::CN_2) { \
if (ALGO == Algorithm::CN_R) { \
VARIANT2_SHUFFLE(l, idx & MASK, a, b0, b1, c, 0); \

View File

@@ -112,13 +112,19 @@ bool xmrig::VirtualMemory::protectRWX(void *p, size_t size)
bool xmrig::VirtualMemory::protectRX(void *p, size_t size)
{
bool result = true;
# if defined(XMRIG_OS_APPLE) && defined(XMRIG_ARM)
pthread_jit_write_protect_np(true);
flushInstructionCache(p, size);
return true;
# else
return mprotect(p, size, PROT_READ | PROT_EXEC) == 0;
result = (mprotect(p, size, PROT_READ | PROT_EXEC) == 0);
# endif
# if defined(XMRIG_ARM)
flushInstructionCache(p, size);
# endif
return result;
}

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.1)
project(GhostRider)
set(HEADERS
@@ -80,6 +80,8 @@ endif()
include_directories(.)
include_directories(../..)
include_directories(../../base)
include_directories(${UV_INCLUDE_DIR})
include_directories(${HWLOC_INCLUDE_DIR})
add_library(ghostrider STATIC ${HEADERS} ${SOURCES})

View File

@@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

View File

@@ -0,0 +1,38 @@
#ifndef BLAKE2_AVX2_BLAKE2_H
#define BLAKE2_AVX2_BLAKE2_H
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
#if defined(_MSC_VER)
#define INLINE __inline
#elif defined(__GNUC__)
#define INLINE __inline__
#else
#define INLINE
#endif
#else
#define INLINE inline
#endif
#if defined(_MSC_VER)
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif
enum blake2s_constant {
BLAKE2S_BLOCKBYTES = 64,
BLAKE2S_OUTBYTES = 32,
BLAKE2S_KEYBYTES = 32,
BLAKE2S_SALTBYTES = 8,
BLAKE2S_PERSONALBYTES = 8
};
enum blake2b_constant {
BLAKE2B_BLOCKBYTES = 128,
BLAKE2B_OUTBYTES = 64,
BLAKE2B_KEYBYTES = 64,
BLAKE2B_SALTBYTES = 16,
BLAKE2B_PERSONALBYTES = 16
};
#endif

View File

@@ -0,0 +1,48 @@
#ifndef BLAKE2_AVX2_BLAKE2B_COMMON_H
#define BLAKE2_AVX2_BLAKE2B_COMMON_H
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <immintrin.h>
#include "blake2.h"
#define LOAD128(p) _mm_load_si128( (__m128i *)(p) )
#define STORE128(p,r) _mm_store_si128((__m128i *)(p), r)
#define LOADU128(p) _mm_loadu_si128( (__m128i *)(p) )
#define STOREU128(p,r) _mm_storeu_si128((__m128i *)(p), r)
#define LOAD(p) _mm256_load_si256( (__m256i *)(p) )
#define STORE(p,r) _mm256_store_si256((__m256i *)(p), r)
#define LOADU(p) _mm256_loadu_si256( (__m256i *)(p) )
#define STOREU(p,r) _mm256_storeu_si256((__m256i *)(p), r)
static INLINE uint64_t LOADU64(void const * p) {
uint64_t v;
memcpy(&v, p, sizeof v);
return v;
}
#define ROTATE16 _mm256_setr_epi8( 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9, \
2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9 )
#define ROTATE24 _mm256_setr_epi8( 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10, \
3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10 )
#define ADD(a, b) _mm256_add_epi64(a, b)
#define SUB(a, b) _mm256_sub_epi64(a, b)
#define XOR(a, b) _mm256_xor_si256(a, b)
#define AND(a, b) _mm256_and_si256(a, b)
#define OR(a, b) _mm256_or_si256(a, b)
#define ROT32(x) _mm256_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1))
#define ROT24(x) _mm256_shuffle_epi8((x), ROTATE24)
#define ROT16(x) _mm256_shuffle_epi8((x), ROTATE16)
#define ROT63(x) _mm256_or_si256(_mm256_srli_epi64((x), 63), ADD((x), (x)))
#endif

View File

@@ -0,0 +1,340 @@
#ifndef BLAKE2_AVX2_BLAKE2B_LOAD_AVX2_H
#define BLAKE2_AVX2_BLAKE2B_LOAD_AVX2_H
#define BLAKE2B_LOAD_MSG_0_1(b0) do { \
t0 = _mm256_unpacklo_epi64(m0, m1); \
t1 = _mm256_unpacklo_epi64(m2, m3); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while(0)
#define BLAKE2B_LOAD_MSG_0_2(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m0, m1);\
t1 = _mm256_unpackhi_epi64(m2, m3);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_0_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m7, m4);\
t1 = _mm256_unpacklo_epi64(m5, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_0_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m7, m4);\
t1 = _mm256_unpackhi_epi64(m5, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_1_1(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m7, m2);\
t1 = _mm256_unpackhi_epi64(m4, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_1_2(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m5, m4);\
t1 = _mm256_alignr_epi8(m3, m7, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_1_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m2, m0);\
t1 = _mm256_blend_epi32(m5, m0, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_1_4(b0) \
do { \
t0 = _mm256_alignr_epi8(m6, m1, 8);\
t1 = _mm256_blend_epi32(m3, m1, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_2_1(b0) \
do { \
t0 = _mm256_alignr_epi8(m6, m5, 8);\
t1 = _mm256_unpackhi_epi64(m2, m7);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_2_2(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m4, m0);\
t1 = _mm256_blend_epi32(m6, m1, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_2_3(b0) \
do { \
t0 = _mm256_alignr_epi8(m5, m4, 8);\
t1 = _mm256_unpackhi_epi64(m1, m3);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_2_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m2, m7);\
t1 = _mm256_blend_epi32(m0, m3, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_3_1(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m3, m1);\
t1 = _mm256_unpackhi_epi64(m6, m5);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_3_2(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m4, m0);\
t1 = _mm256_unpacklo_epi64(m6, m7);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_3_3(b0) \
do { \
t0 = _mm256_alignr_epi8(m1, m7, 8);\
t1 = _mm256_shuffle_epi32(m2, _MM_SHUFFLE(1,0,3,2));\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_3_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m4, m3);\
t1 = _mm256_unpacklo_epi64(m5, m0);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_4_1(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m4, m2);\
t1 = _mm256_unpacklo_epi64(m1, m5);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_4_2(b0) \
do { \
t0 = _mm256_blend_epi32(m3, m0, 0x33);\
t1 = _mm256_blend_epi32(m7, m2, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_4_3(b0) \
do { \
t0 = _mm256_alignr_epi8(m7, m1, 8);\
t1 = _mm256_alignr_epi8(m3, m5, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_4_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m6, m0);\
t1 = _mm256_unpacklo_epi64(m6, m4);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_5_1(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m1, m3);\
t1 = _mm256_unpacklo_epi64(m0, m4);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_5_2(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m6, m5);\
t1 = _mm256_unpackhi_epi64(m5, m1);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_5_3(b0) \
do { \
t0 = _mm256_alignr_epi8(m2, m0, 8);\
t1 = _mm256_unpackhi_epi64(m3, m7);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_5_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m4, m6);\
t1 = _mm256_alignr_epi8(m7, m2, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_6_1(b0) \
do { \
t0 = _mm256_blend_epi32(m0, m6, 0x33);\
t1 = _mm256_unpacklo_epi64(m7, m2);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_6_2(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m2, m7);\
t1 = _mm256_alignr_epi8(m5, m6, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_6_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m4, m0);\
t1 = _mm256_blend_epi32(m4, m3, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_6_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m5, m3);\
t1 = _mm256_shuffle_epi32(m1, _MM_SHUFFLE(1,0,3,2));\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_7_1(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m6, m3);\
t1 = _mm256_blend_epi32(m1, m6, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_7_2(b0) \
do { \
t0 = _mm256_alignr_epi8(m7, m5, 8);\
t1 = _mm256_unpackhi_epi64(m0, m4);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_7_3(b0) \
do { \
t0 = _mm256_blend_epi32(m2, m1, 0x33);\
t1 = _mm256_alignr_epi8(m4, m7, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_7_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m5, m0);\
t1 = _mm256_unpacklo_epi64(m2, m3);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_8_1(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m3, m7);\
t1 = _mm256_alignr_epi8(m0, m5, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_8_2(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m7, m4);\
t1 = _mm256_alignr_epi8(m4, m1, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_8_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m5, m6);\
t1 = _mm256_unpackhi_epi64(m6, m0);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_8_4(b0) \
do { \
t0 = _mm256_alignr_epi8(m1, m2, 8);\
t1 = _mm256_alignr_epi8(m2, m3, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_9_1(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m5, m4);\
t1 = _mm256_unpackhi_epi64(m3, m0);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_9_2(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m1, m2);\
t1 = _mm256_blend_epi32(m2, m3, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_9_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m6, m7);\
t1 = _mm256_unpackhi_epi64(m4, m1);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_9_4(b0) \
do { \
t0 = _mm256_blend_epi32(m5, m0, 0x33);\
t1 = _mm256_unpacklo_epi64(m7, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_10_1(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m0, m1);\
t1 = _mm256_unpacklo_epi64(m2, m3);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_10_2(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m0, m1);\
t1 = _mm256_unpackhi_epi64(m2, m3);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_10_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m7, m4);\
t1 = _mm256_unpacklo_epi64(m5, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_10_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m7, m4);\
t1 = _mm256_unpackhi_epi64(m5, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_11_1(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m7, m2);\
t1 = _mm256_unpackhi_epi64(m4, m6);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_11_2(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m5, m4);\
t1 = _mm256_alignr_epi8(m3, m7, 8);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_11_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m2, m0);\
t1 = _mm256_blend_epi32(m5, m0, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#define BLAKE2B_LOAD_MSG_11_4(b0) \
do { \
t0 = _mm256_alignr_epi8(m6, m1, 8);\
t1 = _mm256_blend_epi32(m3, m1, 0x33);\
b0 = _mm256_blend_epi32(t0, t1, 0xF0);\
} while(0)
#endif

View File

@@ -0,0 +1,16 @@
#ifndef BLAKE2_AVX2_BLAKE2B_H
#define BLAKE2_AVX2_BLAKE2B_H
#include <stddef.h>
#if defined(__cplusplus)
extern "C" {
#endif
int blake2b_avx2(void* out, size_t outlen, const void* in, size_t inlen);
#if defined(__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,141 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "blake2.h"
#include "blake2b.h"
#include "blake2b-common.h"
ALIGN(64) static const uint64_t blake2b_IV[8] = {
UINT64_C(0x6A09E667F3BCC908), UINT64_C(0xBB67AE8584CAA73B),
UINT64_C(0x3C6EF372FE94F82B), UINT64_C(0xA54FF53A5F1D36F1),
UINT64_C(0x510E527FADE682D1), UINT64_C(0x9B05688C2B3E6C1F),
UINT64_C(0x1F83D9ABFB41BD6B), UINT64_C(0x5BE0CD19137E2179),
};
#define BLAKE2B_G1_V1(a, b, c, d, m) do { \
a = ADD(a, m); \
a = ADD(a, b); d = XOR(d, a); d = ROT32(d); \
c = ADD(c, d); b = XOR(b, c); b = ROT24(b); \
} while(0)
#define BLAKE2B_G2_V1(a, b, c, d, m) do { \
a = ADD(a, m); \
a = ADD(a, b); d = XOR(d, a); d = ROT16(d); \
c = ADD(c, d); b = XOR(b, c); b = ROT63(b); \
} while(0)
#define BLAKE2B_DIAG_V1(a, b, c, d) do { \
a = _mm256_permute4x64_epi64(a, _MM_SHUFFLE(2,1,0,3)); \
d = _mm256_permute4x64_epi64(d, _MM_SHUFFLE(1,0,3,2)); \
c = _mm256_permute4x64_epi64(c, _MM_SHUFFLE(0,3,2,1)); \
} while(0)
#define BLAKE2B_UNDIAG_V1(a, b, c, d) do { \
a = _mm256_permute4x64_epi64(a, _MM_SHUFFLE(0,3,2,1)); \
d = _mm256_permute4x64_epi64(d, _MM_SHUFFLE(1,0,3,2)); \
c = _mm256_permute4x64_epi64(c, _MM_SHUFFLE(2,1,0,3)); \
} while(0)
#include "blake2b-load-avx2.h"
#define BLAKE2B_ROUND_V1(a, b, c, d, r, m) do { \
__m256i b0; \
BLAKE2B_LOAD_MSG_ ##r ##_1(b0); \
BLAKE2B_G1_V1(a, b, c, d, b0); \
BLAKE2B_LOAD_MSG_ ##r ##_2(b0); \
BLAKE2B_G2_V1(a, b, c, d, b0); \
BLAKE2B_DIAG_V1(a, b, c, d); \
BLAKE2B_LOAD_MSG_ ##r ##_3(b0); \
BLAKE2B_G1_V1(a, b, c, d, b0); \
BLAKE2B_LOAD_MSG_ ##r ##_4(b0); \
BLAKE2B_G2_V1(a, b, c, d, b0); \
BLAKE2B_UNDIAG_V1(a, b, c, d); \
} while(0)
#define BLAKE2B_ROUNDS_V1(a, b, c, d, m) do { \
BLAKE2B_ROUND_V1(a, b, c, d, 0, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 1, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 2, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 3, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 4, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 5, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 6, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 7, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 8, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 9, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 10, (m)); \
BLAKE2B_ROUND_V1(a, b, c, d, 11, (m)); \
} while(0)
#define DECLARE_MESSAGE_WORDS(m) \
const __m256i m0 = _mm256_broadcastsi128_si256(LOADU128((m) + 0)); \
const __m256i m1 = _mm256_broadcastsi128_si256(LOADU128((m) + 16)); \
const __m256i m2 = _mm256_broadcastsi128_si256(LOADU128((m) + 32)); \
const __m256i m3 = _mm256_broadcastsi128_si256(LOADU128((m) + 48)); \
const __m256i m4 = _mm256_broadcastsi128_si256(LOADU128((m) + 64)); \
const __m256i m5 = _mm256_broadcastsi128_si256(LOADU128((m) + 80)); \
const __m256i m6 = _mm256_broadcastsi128_si256(LOADU128((m) + 96)); \
const __m256i m7 = _mm256_broadcastsi128_si256(LOADU128((m) + 112)); \
__m256i t0, t1;
#define BLAKE2B_COMPRESS_V1(a, b, m, t0, t1, f0, f1) do { \
DECLARE_MESSAGE_WORDS(m) \
const __m256i iv0 = a; \
const __m256i iv1 = b; \
__m256i c = LOAD(&blake2b_IV[0]); \
__m256i d = XOR( \
LOAD(&blake2b_IV[4]), \
_mm256_set_epi64x(f1, f0, t1, t0) \
); \
BLAKE2B_ROUNDS_V1(a, b, c, d, m); \
a = XOR(a, c); \
b = XOR(b, d); \
a = XOR(a, iv0); \
b = XOR(b, iv1); \
} while(0)
int blake2b_avx2(void* out_ptr, size_t outlen, const void* in_ptr, size_t inlen) {
const __m256i parameter_block = _mm256_set_epi64x(0, 0, 0, 0x01010000UL | (uint32_t)outlen);
ALIGN(64) uint8_t buffer[BLAKE2B_BLOCKBYTES];
__m256i a = XOR(LOAD(&blake2b_IV[0]), parameter_block);
__m256i b = LOAD(&blake2b_IV[4]);
uint64_t counter = 0;
const uint8_t* in = (const uint8_t*)in_ptr;
do {
const uint64_t flag = (inlen <= BLAKE2B_BLOCKBYTES) ? -1 : 0;
size_t block_size = BLAKE2B_BLOCKBYTES;
if(inlen < BLAKE2B_BLOCKBYTES) {
memcpy(buffer, in, inlen);
memset(buffer + inlen, 0, BLAKE2B_BLOCKBYTES - inlen);
block_size = inlen;
in = buffer;
}
counter += block_size;
BLAKE2B_COMPRESS_V1(a, b, in, counter, 0, flag, 0);
inlen -= block_size;
in += block_size;
} while(inlen > 0);
uint8_t* out = (uint8_t*)out_ptr;
switch (outlen) {
case 64:
STOREU(out + 32, b);
// Fall through
case 32:
STOREU(out, a);
break;
default:
STOREU(buffer, a);
STOREU(buffer + 32, b);
memcpy(out, buffer, outlen);
break;
}
_mm256_zeroupper();
return 0;
}

View File

@@ -92,7 +92,12 @@ extern "C" {
int rx_blake2b_final(blake2b_state *S, void *out, size_t outlen);
/* Simple API */
int rx_blake2b(void *out, size_t outlen, const void *in, size_t inlen);
void rx_blake2b_compress_integer(blake2b_state * S, const uint8_t * block);
void rx_blake2b_compress_sse41(blake2b_state * S, const uint8_t * block);
int rx_blake2b_default(void* out, size_t outlen, const void* in, size_t inlen);
extern void (*rx_blake2b_compress)(blake2b_state * S, const uint8_t * block);
extern int (*rx_blake2b)(void* out, size_t outlen, const void* in, size_t inlen);
/* Argon2 Team - Begin Code */
int rxa2_blake2b_long(void *out, size_t outlen, const void *in, size_t inlen);

View File

@@ -179,7 +179,7 @@ int rx_blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, size_t
return 0;
}
static void rx_blake2b_compress_integer(blake2b_state *S, const uint8_t *block) {
void rx_blake2b_compress_integer(blake2b_state *S, const uint8_t *block) {
uint64_t m[16];
uint64_t v[16];
unsigned int i, r;
@@ -237,21 +237,6 @@ static void rx_blake2b_compress_integer(blake2b_state *S, const uint8_t *block)
#undef ROUND
}
#if defined(XMRIG_FEATURE_SSE4_1)
uint32_t rx_blake2b_use_sse41 = 0;
void rx_blake2b_compress_sse41(blake2b_state* S, const uint8_t* block);
#define rx_blake2b_compress(S, block) \
if (rx_blake2b_use_sse41) \
rx_blake2b_compress_sse41(S, block); \
else \
rx_blake2b_compress_integer(S, block);
#else
#define rx_blake2b_compress(S, block) rx_blake2b_compress_integer(S, block);
#endif
int rx_blake2b_update(blake2b_state *S, const void *in, size_t inlen) {
const uint8_t *pin = (const uint8_t *)in;
@@ -322,7 +307,7 @@ int rx_blake2b_final(blake2b_state *S, void *out, size_t outlen) {
return 0;
}
int rx_blake2b(void *out, size_t outlen, const void *in, size_t inlen) {
int rx_blake2b_default(void *out, size_t outlen, const void *in, size_t inlen) {
blake2b_state S;
int ret = -1;

View File

@@ -167,6 +167,11 @@ namespace randomx {
static const uint8_t* NOPX[] = { NOP1, NOP2, NOP3, NOP4, NOP5, NOP6, NOP7, NOP8, NOP9 };
static const uint8_t NOP13[] = { 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x44, 0x00, 0x00 };
static const uint8_t NOP14[] = { 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00 };
static const uint8_t NOP25[] = { 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uint8_t NOP26[] = { 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uint8_t JMP_ALIGN_PREFIX[14][16] = {
{},
{0x2E},
@@ -407,7 +412,7 @@ namespace randomx {
*(uint32_t*)(code + codePos + 14) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
if (hasAVX) {
uint32_t* p = (uint32_t*)(code + codePos + 61);
*p = (*p & 0xFF000000U) | 0x0077F8C5U;
*p = (*p & 0xFF000000U) | 0x0077F8C5U; // vzeroupper
}
# ifdef XMRIG_FIX_RYZEN
@@ -419,7 +424,8 @@ namespace randomx {
memcpy(imul_rcp_storage - 34, &pcfg.eMask, sizeof(pcfg.eMask));
codePos = codePosFirst;
prevCFROUND = 0;
prevCFROUND = -1;
prevFPOperation = -1;
//mark all registers as used
uint64_t* r = (uint64_t*)registerUsage;
@@ -1155,7 +1161,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint64_t dst = instr.dst % RegisterCountFlt;
const uint64_t src = instr.src % RegisterCountFlt;
@@ -1170,7 +1176,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint32_t src = instr.src % RegistersCount;
const uint32_t dst = instr.dst % RegisterCountFlt;
@@ -1187,7 +1193,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint64_t dst = instr.dst % RegisterCountFlt;
const uint64_t src = instr.src % RegisterCountFlt;
@@ -1202,7 +1208,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint32_t src = instr.src % RegistersCount;
const uint32_t dst = instr.dst % RegisterCountFlt;
@@ -1230,7 +1236,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint64_t dst = instr.dst % RegisterCountFlt;
const uint64_t src = instr.src % RegisterCountFlt;
@@ -1245,7 +1251,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint32_t src = instr.src % RegistersCount;
const uint64_t dst = instr.dst % RegisterCountFlt;
@@ -1272,7 +1278,7 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
prevFPOperation = pos;
const uint32_t dst = instr.dst % RegisterCountFlt;
@@ -1283,21 +1289,18 @@ namespace randomx {
void JitCompilerX86::h_CFROUND(const Instruction& instr) {
uint8_t* const p = code;
uint32_t pos = prevCFROUND;
int32_t t = prevCFROUND;
if (pos) {
if (t > prevFPOperation) {
if (vm_flags & RANDOMX_FLAG_AMD) {
memcpy(p + pos + 0, NOP9, 9);
memcpy(p + pos + 9, NOP9, 9);
memcpy(p + pos + 18, NOP8, 8);
memcpy(p + t, NOP26, 26);
}
else {
memcpy(p + pos + 0, NOP8, 8);
memcpy(p + pos + 8, NOP6, 6);
memcpy(p + t, NOP14, 14);
}
}
pos = codePos;
uint32_t pos = codePos;
prevCFROUND = pos;
const uint32_t src = instr.src % RegistersCount;
@@ -1322,21 +1325,18 @@ namespace randomx {
void JitCompilerX86::h_CFROUND_BMI2(const Instruction& instr) {
uint8_t* const p = code;
uint32_t pos = prevCFROUND;
int32_t t = prevCFROUND;
if (pos) {
if (t > prevFPOperation) {
if (vm_flags & RANDOMX_FLAG_AMD) {
memcpy(p + pos + 0, NOP9, 9);
memcpy(p + pos + 9, NOP9, 9);
memcpy(p + pos + 18, NOP7, 7);
memcpy(p + t, NOP25, 25);
}
else {
memcpy(p + pos + 0, NOP8, 8);
memcpy(p + pos + 8, NOP5, 5);
memcpy(p + t, NOP13, 13);
}
}
pos = codePos;
uint32_t pos = codePos;
prevCFROUND = pos;
const uint64_t src = instr.src % RegistersCount;
@@ -1363,10 +1363,15 @@ namespace randomx {
uint8_t* const p = code;
uint32_t pos = codePos;
prevCFROUND = 0;
const int reg = instr.dst % RegistersCount;
int32_t jmp_offset = registerUsage[reg] - (pos + 16);
int32_t jmp_offset = registerUsage[reg];
// if it jumps over the previous FP instruction that uses rounding, treat it as if FP instruction happened now
if (jmp_offset <= prevFPOperation) {
prevFPOperation = pos;
}
jmp_offset -= pos + 16;
if (jccErratum) {
const uint32_t branch_begin = static_cast<uint32_t>(pos + 7);

View File

@@ -89,7 +89,8 @@ namespace randomx {
uint32_t codePos = 0;
uint32_t codePosFirst = 0;
uint32_t vm_flags = 0;
uint32_t prevCFROUND = 0;
int32_t prevCFROUND = -1;
int32_t prevFPOperation = -1;
# ifdef XMRIG_FIX_RYZEN
std::pair<const void*, const void*> mainLoopBounds;

View File

@@ -18,6 +18,7 @@
*/
#include "crypto/rx/Rx.h"
#include "backend/cpu/Cpu.h"
#include "backend/cpu/CpuConfig.h"
#include "backend/cpu/CpuThreads.h"
#include "crypto/rx/RxConfig.h"
@@ -84,6 +85,16 @@ void xmrig::Rx::init(IRxListener *listener)
}
#include "crypto/randomx/blake2/blake2.h"
#if defined(XMRIG_FEATURE_AVX2)
#include "crypto/randomx/blake2/avx2/blake2b.h"
#endif
void (*rx_blake2b_compress)(blake2b_state* S, const uint8_t * block) = rx_blake2b_compress_integer;
int (*rx_blake2b)(void* out, size_t outlen, const void* in, size_t inlen) = rx_blake2b_default;
template<typename T>
bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu)
{
@@ -133,6 +144,19 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
if (!cpu.isHwAES()) {
SelectSoftAESImpl(cpu.threads().get(seed.algorithm()).count());
}
# if defined(XMRIG_FEATURE_SSE4_1)
if (Cpu::info()->has(ICpuInfo::FLAG_SSE41)) {
rx_blake2b_compress = rx_blake2b_compress_sse41;
}
# endif
#if defined(XMRIG_FEATURE_AVX2)
if (Cpu::info()->has(ICpuInfo::FLAG_AVX2)) {
rx_blake2b = blake2b_avx2;
}
# endif
osInitialized = true;
}

View File

@@ -29,7 +29,6 @@
#include <thread>
#include <uv.h>
namespace xmrig {
@@ -203,7 +202,7 @@ void xmrig::RxDataset::allocate(bool hugePages, bool oneGbPages)
return;
}
if (m_mode == RxConfig::AutoMode && uv_get_total_memory() < (maxSize() + RxCache::maxSize())) {
if (m_mode == RxConfig::AutoMode && OS::totalmem() < (maxSize() + RxCache::maxSize())) {
LOG_ERR(CLEAR "%s" RED_BOLD_S "not enough memory for RandomX dataset", Tags::randomx());
return;

View File

@@ -25,11 +25,6 @@
#include "crypto/rx/RxVm.h"
#if defined(XMRIG_FEATURE_SSE4_1)
extern "C" uint32_t rx_blake2b_use_sse41;
#endif
randomx_vm *xmrig::RxVm::create(RxDataset *dataset, uint8_t *scratchpad, bool softAes, const Assembly &assembly, uint32_t node)
{
int flags = 0;
@@ -51,10 +46,6 @@ randomx_vm *xmrig::RxVm::create(RxDataset *dataset, uint8_t *scratchpad, bool so
flags |= RANDOMX_FLAG_AMD;
}
# if defined(XMRIG_FEATURE_SSE4_1)
rx_blake2b_use_sse41 = Cpu::info()->has(ICpuInfo::FLAG_SSE41) ? 1 : 0;
# endif
return randomx_create_vm(static_cast<randomx_flags>(flags), !dataset->get() ? dataset->cache()->get() : nullptr, dataset->get(), scratchpad, node);
}

View File

@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hw/api/HwApi.h"
#include "base/api/interfaces/IApiRequest.h"
#include "base/tools/String.h"

View File

@@ -1,11 +1,4 @@
if (WITH_HTTP)
add_definitions(/DXMRIG_FEATURE_DMI)
list(APPEND HEADERS
src/hw/api/HwApi.h
)
list(APPEND SOURCES
src/hw/api/HwApi.cpp
)
list(APPEND HEADERS src/hw/api/HwApi.h)
list(APPEND SOURCES src/hw/api/HwApi.cpp)
endif()

View File

@@ -5,7 +5,7 @@ else()
endif()
if (WITH_DMI)
add_definitions(/DXMRIG_FEATURE_DMI)
add_definitions(-DXMRIG_FEATURE_DMI)
list(APPEND HEADERS
src/hw/dmi/DmiBoard.h
@@ -28,6 +28,6 @@ if (WITH_DMI)
elseif(XMRIG_OS_MACOS)
list(APPEND SOURCES src/hw/dmi/DmiReader_mac.cpp)
endif()
else()
remove_definitions(/DXMRIG_FEATURE_DMI)
endif()
message(STATUS "WITH_DMI \t= ${WITH_DMI}")

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/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
@@ -14,21 +14,19 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GNU GPL version 3 section 7
*
* If you modify this Program, or any covered work, by linking or combining
* it with OpenSSL (or a modified version of that library), containing parts
* covered by the terms of OpenSSL License and SSLeay License, the licensors
* of this Program grant you additional permission to convey the resulting work.
*/
#include "App.h"
#include "MinerApp.h"
#include "base/kernel/Entry.h"
#include "base/kernel/Process.h"
#include "core/config/usage.h"
#ifdef XMRIG_FEATURE_OPENCL
# include "backend/opencl/wrappers/OclPlatform.h"
#endif
int main(int argc, char **argv)
{
using namespace xmrig;
@@ -37,15 +35,18 @@ int main(int argc, char **argv)
{
int rc = 0;
Entry entry(usage);
auto entry = std::make_unique<Entry>(usage);
if (entry.exec(rc)) {
# ifdef XMRIG_FEATURE_OPENCL
entry->add(OclPlatform::printPlatforms);
# endif
if (entry->exec(rc)) {
return rc;
}
}
App app(&process);
MinerApp app;
return app.exec();
}