mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-24 11:36:20 +00:00
Merge branch 'dev'
This commit is contained in:
commit
a1f19305f4
67 changed files with 1540 additions and 380 deletions
|
@ -1,3 +1,9 @@
|
|||
# v2.9.0
|
||||
- [#899](https://github.com/xmrig/xmrig/issues/899) Added support for new algorithm `cn/half` for Masari and Stellite forks.
|
||||
- [#834](https://github.com/xmrig/xmrig/pull/834) Added ASM optimized code for AMD Bulldozer.
|
||||
- [#839](https://github.com/xmrig/xmrig/issues/839) Fixed FreeBSD compile.
|
||||
- [#857](https://github.com/xmrig/xmrig/pull/857) Fixed impossible to build for macOS without clang.
|
||||
|
||||
# v2.8.3
|
||||
- [#813](https://github.com/xmrig/xmrig/issues/813) Fixed critical bug with Minergate pool and variant 2.
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ include (cmake/cpu.cmake)
|
|||
set(HEADERS
|
||||
src/api/NetworkState.h
|
||||
src/App.h
|
||||
src/base/tools/String.h
|
||||
src/common/config/CommonConfig.h
|
||||
src/common/config/ConfigLoader.h
|
||||
src/common/config/ConfigWatcher.h
|
||||
|
@ -93,6 +94,7 @@ endif()
|
|||
set(SOURCES
|
||||
src/api/NetworkState.cpp
|
||||
src/App.cpp
|
||||
src/base/tools/String.cpp
|
||||
src/common/config/CommonConfig.cpp
|
||||
src/common/config/ConfigLoader.cpp
|
||||
src/common/config/ConfigWatcher.cpp
|
||||
|
@ -155,11 +157,11 @@ else()
|
|||
src/Mem_unix.cpp
|
||||
)
|
||||
|
||||
set(EXTRA_LIBS pthread rt dl)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
set(EXTRA_LIBS ${EXTRA_LIBS} kvm)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
set(EXTRA_LIBS kvm)
|
||||
else()
|
||||
set(EXTRA_LIBS pthread rt dl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
@ -255,5 +257,5 @@ if (WITH_DEBUG_LOG)
|
|||
add_definitions(/DAPP_DEBUG)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||
|
|
|
@ -20,4 +20,6 @@ else()
|
|||
set(TLS_SOURCES "")
|
||||
set(OPENSSL_LIBRARIES "")
|
||||
add_definitions(/DXMRIG_NO_TLS)
|
||||
|
||||
set(CMAKE_PROJECT_NAME "${CMAKE_PROJECT_NAME}-notls")
|
||||
endif()
|
||||
|
|
|
@ -5,9 +5,9 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||
enable_language(ASM_MASM)
|
||||
|
||||
if (MSVC_TOOLSET_VERSION GREATER_EQUAL 141)
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cnv2_main_loop.asm")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cn_main_loop.asm")
|
||||
else()
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cnv2_main_loop.asm")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cn_main_loop.asm")
|
||||
endif()
|
||||
|
||||
set_property(SOURCE ${XMRIG_ASM_FILE} PROPERTY ASM_MASM)
|
||||
|
@ -15,9 +15,9 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||
enable_language(ASM)
|
||||
|
||||
if (WIN32 AND CMAKE_C_COMPILER_ID MATCHES GNU)
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cnv2_main_loop.S")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cn_main_loop.S")
|
||||
else()
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cnv2_main_loop.S")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cn_main_loop.S")
|
||||
endif()
|
||||
|
||||
set_property(SOURCE ${XMRIG_ASM_FILE} PROPERTY C)
|
||||
|
|
|
@ -87,6 +87,10 @@ App::~App()
|
|||
|
||||
int App::exec()
|
||||
{
|
||||
if (m_controller->isDone()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!m_controller->isReady()) {
|
||||
return 2;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
|
12
src/Mem.h
12
src/Mem.h
|
@ -6,7 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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,8 +23,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_H__
|
||||
#define __MEM_H__
|
||||
#ifndef XMRIG_MEM_H
|
||||
#define XMRIG_MEM_H
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
@ -59,6 +60,9 @@ public:
|
|||
static void init(bool enabled);
|
||||
static void release(cryptonight_ctx **ctx, size_t count, MemInfo &info);
|
||||
|
||||
static void *allocateExecutableMemory(size_t size);
|
||||
static void flushInstructionCache(void *p, size_t size);
|
||||
|
||||
static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; }
|
||||
|
||||
private:
|
||||
|
@ -70,4 +74,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif /* __MEM_H__ */
|
||||
#endif /* XMRIG_MEM_H */
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -87,3 +88,19 @@ void Mem::release(MemInfo &info)
|
|||
_mm_free(info.memory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *Mem::allocateExecutableMemory(size_t size)
|
||||
{
|
||||
# if defined(__APPLE__)
|
||||
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
# else
|
||||
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Mem::flushInstructionCache(void *p, size_t size)
|
||||
{
|
||||
__builtin___clear_cache(reinterpret_cast<char*>(p), reinterpret_cast<char*>(p) + size);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -182,3 +183,15 @@ void Mem::release(MemInfo &info)
|
|||
_mm_free(info.memory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *Mem::allocateExecutableMemory(size_t size)
|
||||
{
|
||||
return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
}
|
||||
|
||||
|
||||
void Mem::flushInstructionCache(void *p, size_t size)
|
||||
{
|
||||
::FlushInstructionCache(GetCurrentProcess(), p, size);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 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 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -43,7 +44,8 @@ static const char *coloredAsmNames[] = {
|
|||
"\x1B[1;31mnone\x1B[0m",
|
||||
"auto",
|
||||
"\x1B[1;32mintel\x1B[0m",
|
||||
"\x1B[1;32mryzen\x1B[0m"
|
||||
"\x1B[1;32mryzen\x1B[0m",
|
||||
"\x1B[1;32mbulldozer\x1B[0m"
|
||||
};
|
||||
|
||||
|
||||
|
|
225
src/base/tools/String.cpp
Normal file
225
src/base/tools/String.cpp
Normal file
|
@ -0,0 +1,225 @@
|
|||
/* 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 2016-2019 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
|
||||
* 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 "base/tools/String.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
xmrig::String::String(const char *str) :
|
||||
m_data(nullptr),
|
||||
m_size(str == nullptr ? 0 : strlen(str))
|
||||
{
|
||||
if (m_size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, str, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
xmrig::String::String(const char *str, size_t size) :
|
||||
m_data(nullptr),
|
||||
m_size(size)
|
||||
{
|
||||
if (str == nullptr) {
|
||||
m_size = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, str, m_size);
|
||||
m_data[m_size] = '\0';
|
||||
}
|
||||
|
||||
|
||||
xmrig::String::String(const String &other) :
|
||||
m_data(nullptr),
|
||||
m_size(other.m_size)
|
||||
{
|
||||
if (other.m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, other.m_data, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::String::isEqual(const char *str) const
|
||||
{
|
||||
return (m_data != nullptr && str != nullptr && strcmp(m_data, str) == 0) || (m_data == nullptr && str == nullptr);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::String::isEqual(const String &other) const
|
||||
{
|
||||
if (m_size != other.m_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (m_data != nullptr && other.m_data != nullptr && memcmp(m_data, other.m_data, m_size) == 0) || (m_data == nullptr && other.m_data == nullptr);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::String::toJSON() const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
return isNull() ? Value(kNullType) : Value(StringRef(m_data));
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::String::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
return isNull() ? Value(kNullType) : Value(m_data, doc.GetAllocator());
|
||||
}
|
||||
|
||||
|
||||
std::vector<xmrig::String> xmrig::String::split(char sep) const
|
||||
{
|
||||
std::vector<xmrig::String> out;
|
||||
if (m_size == 0) {
|
||||
return out;
|
||||
}
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
for (pos = 0; pos < m_size; ++pos) {
|
||||
if (m_data[pos] == sep) {
|
||||
if ((pos - start) > 0) {
|
||||
out.push_back(String(m_data + start, pos - start));
|
||||
}
|
||||
|
||||
start = pos + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pos - start) > 0) {
|
||||
out.push_back(String(m_data + start, pos - start));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::String::join(const std::vector<xmrig::String> &vec, char sep)
|
||||
{
|
||||
if (vec.empty()) {
|
||||
return String();
|
||||
}
|
||||
|
||||
size_t size = vec.size();
|
||||
for (const String &str : vec) {
|
||||
size += str.size();
|
||||
}
|
||||
|
||||
size_t offset = 0;
|
||||
char *buf = new char[size];
|
||||
|
||||
for (const String &str : vec) {
|
||||
memcpy(buf + offset, str.data(), str.size());
|
||||
|
||||
offset += str.size() + 1;
|
||||
|
||||
if (offset < size) {
|
||||
buf[offset - 1] = sep;
|
||||
}
|
||||
}
|
||||
|
||||
buf[size - 1] = '\0';
|
||||
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::copy(const char *str)
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
if (str == nullptr) {
|
||||
m_size = 0;
|
||||
m_data = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_size = strlen(str);
|
||||
m_data = new char[m_size + 1];
|
||||
|
||||
memcpy(m_data, str, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::copy(const String &other)
|
||||
{
|
||||
if (m_size > 0) {
|
||||
if (m_size == other.m_size) {
|
||||
memcpy(m_data, other.m_data, m_size + 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
delete [] m_data;
|
||||
|
||||
if (other.m_data == nullptr) {
|
||||
m_size = 0;
|
||||
m_data = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_size = other.m_size;
|
||||
m_data = new char[m_size + 1];
|
||||
|
||||
memcpy(m_data, other.m_data, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::move(char *str)
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
m_size = str == nullptr ? 0 : strlen(str);
|
||||
m_data = str;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::move(String &&other)
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
m_data = other.m_data;
|
||||
m_size = other.m_size;
|
||||
|
||||
other.m_data = nullptr;
|
||||
other.m_size = 0;
|
||||
}
|
104
src/base/tools/String.h
Normal file
104
src/base/tools/String.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/* 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 2016-2018 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
|
||||
* 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_STRING_H
|
||||
#define XMRIG_STRING_H
|
||||
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Simple C string wrapper.
|
||||
*
|
||||
* 1. I know about std:string.
|
||||
* 2. For some reason I prefer don't use std:string in miner, eg because of file size of MSYS2 builds.
|
||||
* 3. nullptr and JSON conversion supported.
|
||||
*/
|
||||
class String
|
||||
{
|
||||
public:
|
||||
inline String() : m_data(nullptr), m_size(0) {}
|
||||
inline String(char *str) : m_data(str), m_size(str == nullptr ? 0 : strlen(str)) {}
|
||||
inline String(String &&other) : m_data(other.m_data), m_size(other.m_size) { other.m_data = nullptr; other.m_size = 0; }
|
||||
|
||||
String(const char *str);
|
||||
String(const char *str, size_t size);
|
||||
String(const String &other);
|
||||
|
||||
inline ~String() { delete [] m_data; }
|
||||
|
||||
|
||||
bool isEqual(const char *str) const;
|
||||
bool isEqual(const String &other) const;
|
||||
|
||||
|
||||
inline bool contains(const char *str) const { return isNull() ? false : strstr(m_data, str) != nullptr; }
|
||||
|
||||
|
||||
inline bool isEmpty() const { return size() == 0; }
|
||||
inline bool isNull() const { return m_data == nullptr; }
|
||||
inline char *data() { return m_data; }
|
||||
inline const char *data() const { return m_data; }
|
||||
inline size_t size() const { return m_size; }
|
||||
|
||||
|
||||
inline bool operator!=(const char *str) const { return !isEqual(str); }
|
||||
inline bool operator!=(const String &other) const { return !isEqual(other); }
|
||||
inline bool operator<(const String &str) const { return strcmp(data(), str.data()) < 0; }
|
||||
inline bool operator==(const char *str) const { return isEqual(str); }
|
||||
inline bool operator==(const String &other) const { return isEqual(other); }
|
||||
inline operator const char*() const { return m_data; }
|
||||
inline String &operator=(char *str) { move(str); return *this; }
|
||||
inline String &operator=(const char *str) { copy(str); return *this; }
|
||||
inline String &operator=(const String &str) { copy(str); return *this; }
|
||||
inline String &operator=(String &&other) { move(std::move(other)); return *this; }
|
||||
|
||||
rapidjson::Value toJSON() const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
std::vector<xmrig::String> split(char sep) const;
|
||||
|
||||
static String join(const std::vector<xmrig::String> &vec, char sep);
|
||||
|
||||
private:
|
||||
void copy(const char *str);
|
||||
void copy(const String &other);
|
||||
void move(char *str);
|
||||
void move(String &&other);
|
||||
|
||||
char *m_data;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_STRING_H */
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -36,7 +37,7 @@
|
|||
|
||||
|
||||
char Platform::m_defaultConfigName[520] = { 0 };
|
||||
xmrig::c_str Platform::m_userAgent;
|
||||
xmrig::String Platform::m_userAgent;
|
||||
|
||||
|
||||
const char *Platform::defaultConfigName()
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 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,7 +29,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "common/utils/c_str.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
class Platform
|
||||
|
@ -36,7 +37,9 @@ class Platform
|
|||
public:
|
||||
static bool setThreadAffinity(uint64_t cpu_id);
|
||||
static const char *defaultConfigName();
|
||||
static uint32_t setTimerResolution(uint32_t resolution);
|
||||
static void init(const char *userAgent);
|
||||
static void restoreTimerResolution();
|
||||
static void setProcessPriority(int priority);
|
||||
static void setThreadPriority(int priority);
|
||||
|
||||
|
@ -46,7 +49,7 @@ private:
|
|||
static char *createUserAgent();
|
||||
|
||||
static char m_defaultConfigName[520];
|
||||
static xmrig::c_str m_userAgent;
|
||||
static xmrig::String m_userAgent;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,15 +40,20 @@
|
|||
|
||||
char *Platform::createUserAgent()
|
||||
{
|
||||
const size_t max = 160;
|
||||
constexpr const size_t max = 256;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = new char[max]();
|
||||
int length = snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s", APP_NAME, APP_VERSION, uv_version_string());
|
||||
|
||||
# ifdef XMRIG_NVIDIA_PROJECT
|
||||
const int cudaVersion = cuda_get_runtime_version();
|
||||
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# else
|
||||
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
|
||||
# endif
|
||||
|
||||
# ifdef __clang__
|
||||
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# elif defined(__GNUC__)
|
||||
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# endif
|
||||
|
||||
return buf;
|
||||
|
@ -65,9 +70,19 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
|
|||
}
|
||||
|
||||
|
||||
uint32_t Platform::setTimerResolution(uint32_t resolution)
|
||||
{
|
||||
return resolution;
|
||||
}
|
||||
|
||||
|
||||
void Platform::restoreTimerResolution()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Platform::setProcessPriority(int priority)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ typedef cpuset_t cpu_set_t;
|
|||
|
||||
char *Platform::createUserAgent()
|
||||
{
|
||||
const size_t max = 160;
|
||||
constexpr const size_t max = 256;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = new char[max]();
|
||||
int length = snprintf(buf, max, "%s/%s (Linux ", APP_NAME, APP_VERSION);
|
||||
|
||||
# if defined(__x86_64__)
|
||||
|
@ -70,7 +70,9 @@ char *Platform::createUserAgent()
|
|||
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
|
||||
# endif
|
||||
|
||||
# ifdef __GNUC__
|
||||
# ifdef __clang__
|
||||
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# elif defined(__GNUC__)
|
||||
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# endif
|
||||
|
||||
|
@ -92,6 +94,17 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
|
|||
}
|
||||
|
||||
|
||||
uint32_t Platform::setTimerResolution(uint32_t resolution)
|
||||
{
|
||||
return resolution;
|
||||
}
|
||||
|
||||
|
||||
void Platform::restoreTimerResolution()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Platform::setProcessPriority(int priority)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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,6 +23,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <uv.h>
|
||||
|
@ -37,6 +39,11 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_AMD_PROJECT
|
||||
static uint32_t timerResolution = 0;
|
||||
#endif
|
||||
|
||||
|
||||
static inline OSVERSIONINFOEX winOsVersion()
|
||||
{
|
||||
typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO);
|
||||
|
@ -58,9 +65,9 @@ static inline OSVERSIONINFOEX winOsVersion()
|
|||
char *Platform::createUserAgent()
|
||||
{
|
||||
const auto osver = winOsVersion();
|
||||
const size_t max = 160;
|
||||
constexpr const size_t max = 256;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = new char[max]();
|
||||
int length = snprintf(buf, max, "%s/%s (Windows NT %lu.%lu", APP_NAME, APP_VERSION, osver.dwMajorVersion, osver.dwMinorVersion);
|
||||
|
||||
# if defined(__x86_64__) || defined(_M_AMD64)
|
||||
|
@ -94,6 +101,34 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
|
|||
}
|
||||
|
||||
|
||||
uint32_t Platform::setTimerResolution(uint32_t resolution)
|
||||
{
|
||||
# ifdef XMRIG_AMD_PROJECT
|
||||
TIMECAPS tc;
|
||||
|
||||
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
timerResolution = std::min<uint32_t>(std::max<uint32_t>(tc.wPeriodMin, resolution), tc.wPeriodMax);
|
||||
|
||||
return timeBeginPeriod(timerResolution) == TIMERR_NOERROR ? timerResolution : 0;
|
||||
# else
|
||||
return resolution;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Platform::restoreTimerResolution()
|
||||
{
|
||||
# ifdef XMRIG_AMD_PROJECT
|
||||
if (timerResolution) {
|
||||
timeEndPeriod(timerResolution);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Platform::setProcessPriority(int priority)
|
||||
{
|
||||
if (priority == -1) {
|
||||
|
@ -121,6 +156,7 @@ void Platform::setProcessPriority(int priority)
|
|||
|
||||
case 5:
|
||||
prio = REALTIME_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -174,8 +174,11 @@ void xmrig::CommonConfig::printVersions()
|
|||
int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100);
|
||||
# else
|
||||
memset(buf, 0, 16);
|
||||
|
||||
# if !defined(XMRIG_NO_HTTPD) || !defined(XMRIG_NO_TLS)
|
||||
int length = 0;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||
{
|
||||
|
@ -280,16 +283,16 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
|
|||
break;
|
||||
|
||||
case KeepAliveKey: /* --keepalive */
|
||||
m_pools.back().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
|
||||
currentPool().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
|
||||
break;
|
||||
|
||||
case TlsKey: /* --tls */
|
||||
m_pools.back().setTLS(enable);
|
||||
currentPool().setTLS(enable);
|
||||
break;
|
||||
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
case NicehashKey: /* --nicehash */
|
||||
m_pools.back().setNicehash(enable);
|
||||
currentPool().setNicehash(enable);
|
||||
break;
|
||||
# endif
|
||||
|
||||
|
@ -333,13 +336,15 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
|
|||
break;
|
||||
|
||||
case UserpassKey: /* --userpass */
|
||||
if (!m_pools.back().setUserpass(arg)) {
|
||||
if (!currentPool().setUserpass(arg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UrlKey: /* --url */
|
||||
fixup();
|
||||
|
||||
if (m_pools.size() > 1 || m_pools[0].isValid()) {
|
||||
Pool pool(arg);
|
||||
|
||||
|
@ -358,23 +363,23 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
|
|||
break;
|
||||
|
||||
case UserKey: /* --user */
|
||||
m_pools.back().setUser(arg);
|
||||
currentPool().setUser(arg);
|
||||
break;
|
||||
|
||||
case PasswordKey: /* --pass */
|
||||
m_pools.back().setPassword(arg);
|
||||
currentPool().setPassword(arg);
|
||||
break;
|
||||
|
||||
case RigIdKey: /* --rig-id */
|
||||
m_pools.back().setRigId(arg);
|
||||
currentPool().setRigId(arg);
|
||||
break;
|
||||
|
||||
case FingerprintKey: /* --tls-fingerprint */
|
||||
m_pools.back().setFingerprint(arg);
|
||||
currentPool().setFingerprint(arg);
|
||||
break;
|
||||
|
||||
case VariantKey: /* --variant */
|
||||
m_pools.back().algorithm().parseVariant(arg);
|
||||
currentPool().algorithm().parseVariant(arg);
|
||||
break;
|
||||
|
||||
case LogFileKey: /* --log-file */
|
||||
|
@ -400,7 +405,7 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
|
|||
case RetriesKey: /* --retries */
|
||||
case RetryPauseKey: /* --retry-pause */
|
||||
case ApiPort: /* --api-port */
|
||||
case PrintTimeKey: /* --cpu-priority */
|
||||
case PrintTimeKey: /* --print-time */
|
||||
return parseUint64(key, strtol(arg, nullptr, 10));
|
||||
|
||||
case BackgroundKey: /* --background */
|
||||
|
@ -462,11 +467,11 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
|
|||
break;
|
||||
|
||||
case KeepAliveKey: /* --keepalive */
|
||||
m_pools.back().setKeepAlive(arg);
|
||||
currentPool().setKeepAlive(arg);
|
||||
break;
|
||||
|
||||
case VariantKey: /* --variant */
|
||||
m_pools.back().algorithm().parseVariant(arg);
|
||||
currentPool().algorithm().parseVariant(arg);
|
||||
break;
|
||||
|
||||
case DonateLevelKey: /* --donate-level */
|
||||
|
@ -493,3 +498,30 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Pool &xmrig::CommonConfig::currentPool()
|
||||
{
|
||||
fixup();
|
||||
|
||||
return m_pools.back();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::CommonConfig::fixup()
|
||||
{
|
||||
if (m_state == NoneState) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pools.empty()) {
|
||||
if (!m_activePools.empty()) {
|
||||
std::swap(m_pools, m_activePools);
|
||||
}
|
||||
else {
|
||||
m_pools.push_back(Pool());
|
||||
}
|
||||
|
||||
m_state = NoneState;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,9 +112,11 @@ protected:
|
|||
|
||||
private:
|
||||
bool parseInt(int key, int arg);
|
||||
Pool ¤tPool();
|
||||
void fixup();
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* __COMMONCONFIG_H__ */
|
||||
#endif /* XMRIG_COMMONCONFIG_H */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -50,6 +50,7 @@
|
|||
#include "rapidjson/filereadstream.h"
|
||||
|
||||
|
||||
bool xmrig::ConfigLoader::m_done = false;
|
||||
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
|
||||
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
|
||||
xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr;
|
||||
|
@ -283,12 +284,16 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option
|
|||
|
||||
void xmrig::ConfigLoader::showUsage()
|
||||
{
|
||||
m_done = true;
|
||||
|
||||
printf(usage);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigLoader::showVersion()
|
||||
{
|
||||
m_done = true;
|
||||
|
||||
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
|
||||
|
||||
# if defined(__clang__)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIGLOADER_H__
|
||||
#define __CONFIGLOADER_H__
|
||||
#ifndef XMRIG_CONFIGLOADER_H
|
||||
#define XMRIG_CONFIGLOADER_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
@ -53,6 +53,8 @@ public:
|
|||
static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener);
|
||||
static void release();
|
||||
|
||||
static inline bool isDone() { return m_done; }
|
||||
|
||||
private:
|
||||
static bool getJSON(const char *fileName, rapidjson::Document &doc);
|
||||
static bool parseArg(IConfig *config, int key, const char *arg);
|
||||
|
@ -60,6 +62,7 @@ private:
|
|||
static void showUsage();
|
||||
static void showVersion();
|
||||
|
||||
static bool m_done;
|
||||
static ConfigWatcher *m_watcher;
|
||||
static IConfigCreator *m_creator;
|
||||
static IWatcherListener *m_listener;
|
||||
|
@ -68,4 +71,4 @@ private:
|
|||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* __CONFIGLOADER_H__ */
|
||||
#endif /* XMRIG_CONFIGLOADER_H */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -62,6 +62,8 @@ static AlgoData const algorithms[] = {
|
|||
{ "cryptonight/xao", "cn/xao", xmrig::CRYPTONIGHT, xmrig::VARIANT_XAO },
|
||||
{ "cryptonight/rto", "cn/rto", xmrig::CRYPTONIGHT, xmrig::VARIANT_RTO },
|
||||
{ "cryptonight/2", "cn/2", xmrig::CRYPTONIGHT, xmrig::VARIANT_2 },
|
||||
{ "cryptonight/half", "cn/half", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
|
||||
{ "cryptonight/xtlv9", "cn/xtlv9", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
|
||||
|
@ -109,9 +111,13 @@ static const char *variants[] = {
|
|||
"xao",
|
||||
"rto",
|
||||
"2",
|
||||
"half"
|
||||
};
|
||||
|
||||
|
||||
static_assert(xmrig::VARIANT_MAX == ARRAY_SIZE(variants), "variants size mismatch");
|
||||
|
||||
|
||||
bool xmrig::Algorithm::isValid() const
|
||||
{
|
||||
if (m_algo == INVALID_ALGO) {
|
||||
|
@ -144,10 +150,16 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo)
|
|||
m_variant = VARIANT_AUTO;
|
||||
|
||||
assert(algo != nullptr);
|
||||
if (algo == nullptr) {
|
||||
if (algo == nullptr || strlen(algo) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (*algo == '!') {
|
||||
m_flags |= Forced;
|
||||
|
||||
return parseAlgorithm(algo + 1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) {
|
||||
if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) {
|
||||
m_algo = algorithms[i].algo;
|
||||
|
@ -166,12 +178,26 @@ void xmrig::Algorithm::parseVariant(const char *variant)
|
|||
{
|
||||
m_variant = VARIANT_AUTO;
|
||||
|
||||
if (variant == nullptr || strlen(variant) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (*variant == '!') {
|
||||
m_flags |= Forced;
|
||||
|
||||
return parseVariant(variant + 1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
|
||||
if (strcasecmp(variant, variants[i]) == 0) {
|
||||
m_variant = static_cast<Variant>(i);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasecmp(variant, "xtlv9") == 0) {
|
||||
m_variant = VARIANT_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -39,28 +39,38 @@ namespace xmrig {
|
|||
class Algorithm
|
||||
{
|
||||
public:
|
||||
enum Flags {
|
||||
None = 0,
|
||||
Forced = 1
|
||||
};
|
||||
|
||||
inline Algorithm() :
|
||||
m_algo(INVALID_ALGO),
|
||||
m_flags(0),
|
||||
m_variant(VARIANT_AUTO)
|
||||
{}
|
||||
|
||||
inline Algorithm(Algo algo, Variant variant) :
|
||||
m_flags(0),
|
||||
m_variant(variant)
|
||||
{
|
||||
setAlgo(algo);
|
||||
}
|
||||
|
||||
inline Algorithm(const char *algo)
|
||||
inline Algorithm(const char *algo) :
|
||||
m_flags(0)
|
||||
{
|
||||
parseAlgorithm(algo);
|
||||
}
|
||||
|
||||
bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
|
||||
inline Algo algo() const { return m_algo; }
|
||||
inline const char *name() const { return name(false); }
|
||||
inline const char *shortName() const { return name(true); }
|
||||
inline Variant variant() const { return m_variant; }
|
||||
inline void setVariant(Variant variant) { m_variant = variant; }
|
||||
inline Algo algo() const { return m_algo; }
|
||||
inline bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
|
||||
inline bool isForced() const { return m_flags & Forced; }
|
||||
inline const char *name() const { return name(false); }
|
||||
inline const char *shortName() const { return name(true); }
|
||||
inline int flags() const { return m_flags; }
|
||||
inline Variant variant() const { return m_variant; }
|
||||
inline void setVariant(Variant variant) { m_variant = variant; }
|
||||
|
||||
inline bool operator!=(const Algorithm &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const Algorithm &other) const { return isEqual(other); }
|
||||
|
@ -80,6 +90,7 @@ private:
|
|||
const char *name(bool shortName) const;
|
||||
|
||||
Algo m_algo;
|
||||
int m_flags;
|
||||
Variant m_variant;
|
||||
};
|
||||
|
||||
|
|
|
@ -97,16 +97,23 @@ public:
|
|||
OclCompModeKey = 1410,
|
||||
|
||||
// xmrig-proxy
|
||||
AccessLogFileKey = 'A',
|
||||
BindKey = 'b',
|
||||
CoinKey = 1104,
|
||||
CustomDiffKey = 1102,
|
||||
DebugKey = 1101,
|
||||
ModeKey = 'm',
|
||||
PoolCoinKey = 'C',
|
||||
ReuseTimeoutKey = 1106,
|
||||
WorkersKey = 1103,
|
||||
WorkersAdvKey = 1107,
|
||||
AccessLogFileKey = 'A',
|
||||
BindKey = 'b',
|
||||
CoinKey = 1104,
|
||||
CustomDiffKey = 1102,
|
||||
DebugKey = 1101,
|
||||
ModeKey = 'm',
|
||||
PoolCoinKey = 'C',
|
||||
ReuseTimeoutKey = 1106,
|
||||
WorkersKey = 1103,
|
||||
WorkersAdvKey = 1107,
|
||||
TlsBindKey = 1108,
|
||||
TlsCertKey = 1109,
|
||||
TlsCertKeyKey = 1110,
|
||||
TlsDHparamKey = 1111,
|
||||
TlsCiphersKey = 1112,
|
||||
TlsCipherSuitesKey = 1113,
|
||||
TlsProtocolsKey = 1114,
|
||||
|
||||
// xmrig nvidia
|
||||
CudaMaxThreadsKey = 1200,
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
#ifndef XMRIG_LOG_H
|
||||
#define XMRIG_LOG_H
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
static inline Log* i() { if (!m_self) { defaultInit(); } return m_self; }
|
||||
static inline void add(ILogBackend *backend) { i()->m_backends.push_back(backend); }
|
||||
static inline void init() { if (!m_self) { new Log(); } }
|
||||
static inline void release() { assert(m_self != nullptr); delete m_self; }
|
||||
static inline void release() { delete m_self; }
|
||||
|
||||
void message(ILogBackend::Level level, const char* fmt, ...);
|
||||
void text(const char* fmt, ...);
|
||||
|
@ -98,4 +98,4 @@ private:
|
|||
# define LOG_DEBUG_WARN(x, ...)
|
||||
#endif
|
||||
|
||||
#endif /* __LOG_H__ */
|
||||
#endif /* XMRIG_LOG_H */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -212,6 +212,12 @@ const char *Client::tlsVersion() const
|
|||
|
||||
int64_t Client::submit(const JobResult &result)
|
||||
{
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
if (result.clientId != m_rpcId) {
|
||||
return -1;
|
||||
}
|
||||
# endif
|
||||
|
||||
using namespace rapidjson;
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
|
@ -336,8 +342,7 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
if (params.HasMember("algo")) {
|
||||
job.setAlgorithm(params["algo"].GetString());
|
||||
}
|
||||
|
||||
if (params.HasMember("variant")) {
|
||||
else if (params.HasMember("variant")) {
|
||||
const rapidjson::Value &variant = params["variant"];
|
||||
|
||||
if (variant.IsInt()) {
|
||||
|
@ -355,6 +360,8 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
return false;
|
||||
}
|
||||
|
||||
m_job.setClientId(m_rpcId);
|
||||
|
||||
if (m_job != job) {
|
||||
m_jobs++;
|
||||
m_job = std::move(job);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ID_H__
|
||||
#define __ID_H__
|
||||
#ifndef XMRIG_ID_H
|
||||
#define XMRIG_ID_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
@ -95,4 +95,4 @@ private:
|
|||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* __ID_H__ */
|
||||
#endif /* XMRIG_ID_H */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -91,6 +91,12 @@ Job::~Job()
|
|||
}
|
||||
|
||||
|
||||
bool Job::isEqual(const Job &other) const
|
||||
{
|
||||
return m_id == other.m_id && m_clientId == other.m_clientId && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool Job::setBlob(const char *blob)
|
||||
{
|
||||
if (!blob) {
|
||||
|
@ -119,6 +125,15 @@ bool Job::setBlob(const char *blob)
|
|||
m_algorithm.setVariant(variant());
|
||||
}
|
||||
|
||||
if (!m_algorithm.isForced()) {
|
||||
if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_HALF);
|
||||
}
|
||||
else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_HALF);
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
memset(m_rawBlob, 0, sizeof(m_rawBlob));
|
||||
memcpy(m_rawBlob, blob, m_size * 2);
|
||||
|
@ -214,18 +229,6 @@ char *Job::toHex(const unsigned char* in, unsigned int len)
|
|||
#endif
|
||||
|
||||
|
||||
bool Job::operator==(const Job &other) const
|
||||
{
|
||||
return m_id == other.m_id && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool Job::operator!=(const Job &other) const
|
||||
{
|
||||
return m_id != other.m_id || memcmp(m_blob, other.m_blob, sizeof(m_blob)) != 0;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Variant Job::variant() const
|
||||
{
|
||||
using namespace xmrig;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -42,6 +42,7 @@ public:
|
|||
Job(int poolId, bool nicehash, const xmrig::Algorithm &algorithm, const xmrig::Id &clientId);
|
||||
~Job();
|
||||
|
||||
bool isEqual(const Job &other) const;
|
||||
bool setBlob(const char *blob);
|
||||
bool setTarget(const char *target);
|
||||
void setAlgorithm(const char *algo);
|
||||
|
@ -81,8 +82,8 @@ public:
|
|||
static char *toHex(const unsigned char* in, unsigned int len);
|
||||
# endif
|
||||
|
||||
bool operator==(const Job &other) const;
|
||||
bool operator!=(const Job &other) const;
|
||||
inline bool operator==(const Job &other) const { return isEqual(other); }
|
||||
inline bool operator!=(const Job &other) const { return !isEqual(other); }
|
||||
|
||||
private:
|
||||
xmrig::Variant variant() const;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -322,23 +322,39 @@ void Pool::adjustVariant(const xmrig::Variant variantHint)
|
|||
m_nicehash = true;
|
||||
bool valid = true;
|
||||
|
||||
if (m_host.contains("cryptonight.") && m_port == 3355) {
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT;
|
||||
switch (m_port) {
|
||||
case 3355:
|
||||
case 33355:
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonight.");
|
||||
m_algorithm.setVariant(VARIANT_0);
|
||||
}
|
||||
else if (m_host.contains("cryptonightv7.") && m_port == 3363) {
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT;
|
||||
break;
|
||||
|
||||
case 3363:
|
||||
case 33363:
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonightv7.");
|
||||
m_algorithm.setVariant(VARIANT_1);
|
||||
}
|
||||
else if (m_host.contains("cryptonightheavy.") && m_port == 3364) {
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT_HEAVY;
|
||||
break;
|
||||
|
||||
case 3364:
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT_HEAVY && m_host.contains("cryptonightheavy.");
|
||||
m_algorithm.setVariant(VARIANT_0);
|
||||
break;
|
||||
|
||||
case 3367:
|
||||
case 33367:
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonightv8.");
|
||||
m_algorithm.setVariant(VARIANT_2);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
m_algorithm.setAlgo(INVALID_ALGO);
|
||||
}
|
||||
|
||||
m_tls = m_port > 33000;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -349,7 +365,7 @@ void Pool::adjustVariant(const xmrig::Variant variantHint)
|
|||
|
||||
if (m_host.contains("xmr.pool.")) {
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT;
|
||||
m_algorithm.setVariant(m_port == 45700 ? VARIANT_2 : VARIANT_0);
|
||||
m_algorithm.setVariant(m_port == 45700 ? VARIANT_AUTO : VARIANT_0);
|
||||
}
|
||||
else if (m_host.contains("aeon.pool.") && m_port == 45690) {
|
||||
valid = m_algorithm.algo() == CRYPTONIGHT_LITE;
|
||||
|
@ -396,6 +412,7 @@ void Pool::rebuild()
|
|||
addVariant(xmrig::VARIANT_2);
|
||||
addVariant(xmrig::VARIANT_1);
|
||||
addVariant(xmrig::VARIANT_0);
|
||||
addVariant(xmrig::VARIANT_HALF);
|
||||
addVariant(xmrig::VARIANT_XTL);
|
||||
addVariant(xmrig::VARIANT_TUBE);
|
||||
addVariant(xmrig::VARIANT_MSR);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_TLS_H
|
||||
#define XMRIG_TLS_H
|
||||
#ifndef XMRIG_CLIENT_TLS_H
|
||||
#define XMRIG_CLIENT_TLS_H
|
||||
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
@ -59,4 +59,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif /* XMRIG_TLS_H */
|
||||
#endif /* XMRIG_CLIENT_TLS_H */
|
||||
|
|
|
@ -21,82 +21,19 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __C_STR_H__
|
||||
#define __C_STR_H__
|
||||
#ifndef XMRIG_C_STR_H
|
||||
#define XMRIG_C_STR_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Simple C string wrapper.
|
||||
*
|
||||
* 1. I know about std:string.
|
||||
* 2. For some reason I prefer don't use std:string in miner, eg because of file size of MSYS2 builds.
|
||||
*/
|
||||
class c_str
|
||||
{
|
||||
public:
|
||||
inline c_str() : m_data(nullptr) {}
|
||||
inline c_str(c_str &&other) { m_data = other.m_data; other.m_data = nullptr; }
|
||||
inline c_str(const c_str &other) : m_data(nullptr) { set(other.data()); }
|
||||
inline c_str(const char *str) : m_data(nullptr) { set(str); }
|
||||
inline ~c_str() { free(m_data); }
|
||||
|
||||
|
||||
inline void set(const char *str)
|
||||
{
|
||||
free(m_data);
|
||||
|
||||
m_data = str != nullptr ? strdup(str) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
inline void set(char *str)
|
||||
{
|
||||
free(m_data);
|
||||
|
||||
m_data = str;
|
||||
}
|
||||
|
||||
|
||||
inline bool isEqual(const char *str) const
|
||||
{
|
||||
return (m_data != nullptr && str != nullptr && strcmp(m_data, str) == 0) || (m_data == nullptr && m_data == nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline bool contains(const char *str) const
|
||||
{
|
||||
return strstr(m_data, str) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
inline bool isNull() const { return m_data == nullptr; }
|
||||
inline const char *data() const { return m_data; }
|
||||
inline size_t size() const { return m_data == nullptr ? 0 : strlen(m_data); }
|
||||
|
||||
|
||||
inline bool operator!=(const c_str &str) const { return !isEqual(str.data()); }
|
||||
inline bool operator!=(const char *str) const { return !isEqual(str); }
|
||||
inline bool operator==(const c_str &str) const { return isEqual(str.data()); }
|
||||
inline bool operator==(const char *str) const { return isEqual(str); }
|
||||
inline c_str &operator=(char *str) { set(str); return *this; }
|
||||
inline c_str &operator=(const c_str &str) { set(str.data()); return *this; }
|
||||
inline c_str &operator=(const char *str) { set(str); return *this; }
|
||||
|
||||
|
||||
private:
|
||||
char *m_data;
|
||||
};
|
||||
typedef String c_str;
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* __C_STR_H__ */
|
||||
#endif /* XMRIG_C_STR_H */
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
static inline int64_t currentMSecsSinceEpoch()
|
||||
static inline int64_t steadyTimestamp()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
if (high_resolution_clock::is_steady) {
|
||||
|
@ -42,6 +42,14 @@ static inline int64_t currentMSecsSinceEpoch()
|
|||
}
|
||||
|
||||
|
||||
static inline int64_t currentMSecsSinceEpoch()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
return time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
}
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* XMRIG_TIMESTAMP_H */
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -68,6 +69,7 @@ enum Variant {
|
|||
VARIANT_XAO = 6, // Modified CryptoNight variant 0 (Alloy only)
|
||||
VARIANT_RTO = 7, // Modified CryptoNight variant 1 (Arto only)
|
||||
VARIANT_2 = 8, // CryptoNight variant 2
|
||||
VARIANT_HALF = 9, // CryptoNight variant 2 with half iterations (Masari/Stellite)
|
||||
VARIANT_MAX
|
||||
};
|
||||
|
||||
|
@ -99,6 +101,7 @@ enum Assembly {
|
|||
ASM_AUTO,
|
||||
ASM_INTEL,
|
||||
ASM_RYZEN,
|
||||
ASM_BULLDOZER,
|
||||
ASM_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ Options:\n\
|
|||
"\
|
||||
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
|
||||
--safe safe adjust threads and av settings for current CPU\n\
|
||||
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen.\n\
|
||||
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen, bulldozer.\n\
|
||||
--print-time=N print hashrate report every N seconds\n\
|
||||
--api-port=N port for the miner API\n\
|
||||
--api-access-token=T access token for API\n\
|
||||
|
|
|
@ -78,6 +78,12 @@ xmrig::Controller::~Controller()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Controller::isDone() const
|
||||
{
|
||||
return ConfigLoader::isDone();
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Controller::isReady() const
|
||||
{
|
||||
return d_ptr->config && d_ptr->network;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CONTROLLER_H__
|
||||
#define __CONTROLLER_H__
|
||||
#ifndef XMRIG_CONTROLLER_H
|
||||
#define XMRIG_CONTROLLER_H
|
||||
|
||||
|
||||
#include "common/interfaces/IWatcherListener.h"
|
||||
|
@ -46,6 +46,7 @@ public:
|
|||
Controller();
|
||||
~Controller();
|
||||
|
||||
bool isDone() const;
|
||||
bool isReady() const;
|
||||
Config *config() const;
|
||||
int init(int argc, char **argv);
|
||||
|
@ -61,4 +62,4 @@ private:
|
|||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* __CONTROLLER_H__ */
|
||||
#endif /* XMRIG_CONTROLLER_H */
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 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 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -24,7 +25,6 @@
|
|||
#include <libcpuid.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <thread>
|
||||
|
||||
|
||||
#include "core/cpu/AdvancedCpuInfo.h"
|
||||
|
@ -39,7 +39,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
|||
m_L2(0),
|
||||
m_L3(0),
|
||||
m_sockets(1),
|
||||
m_threads(std::thread::hardware_concurrency())
|
||||
m_threads(0)
|
||||
{
|
||||
struct cpu_raw_data_t raw = { 0 };
|
||||
struct cpu_id_t data = { 0 };
|
||||
|
@ -49,6 +49,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
|||
|
||||
strncpy(m_brand, data.brand_str, sizeof(m_brand));
|
||||
|
||||
m_threads = data.total_logical_cpus;
|
||||
m_sockets = threads() / data.num_logical_cpus;
|
||||
if (m_sockets == 0) {
|
||||
m_sockets = 1;
|
||||
|
@ -76,7 +77,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
|||
m_aes = true;
|
||||
|
||||
if (data.vendor == VENDOR_AMD) {
|
||||
m_assembly = ASM_RYZEN;
|
||||
m_assembly = (data.ext_family >= 23) ? ASM_RYZEN : ASM_BULLDOZER;
|
||||
}
|
||||
else if (data.vendor == VENDOR_INTEL) {
|
||||
m_assembly = ASM_INTEL;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 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 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -40,7 +41,8 @@ static const char *asmNames[] = {
|
|||
"none",
|
||||
"auto",
|
||||
"intel",
|
||||
"ryzen"
|
||||
"ryzen",
|
||||
"bulldozer"
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -402,12 +402,12 @@ static inline __m128i aes_round_tweak_div(const __m128i &in, const __m128i &key)
|
|||
}
|
||||
|
||||
|
||||
template<xmrig::Variant VARIANT>
|
||||
template<xmrig::Variant VARIANT, xmrig::Variant BASE>
|
||||
static inline void cryptonight_monero_tweak(const uint8_t* l, uint64_t idx, __m128i ax0, __m128i bx0, __m128i bx1, __m128i cx)
|
||||
{
|
||||
uint64_t* mem_out = (uint64_t*)&l[idx];
|
||||
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1);
|
||||
_mm_store_si128((__m128i *)mem_out, _mm_xor_si128(bx0, cx));
|
||||
} else {
|
||||
|
@ -429,12 +429,12 @@ static inline void cryptonight_monero_tweak(const uint8_t* l, uint64_t idx, __m1
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 32);
|
||||
return;
|
||||
}
|
||||
|
@ -473,8 +473,8 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
cx = _mm_aesenc_si128(cx, ax0);
|
||||
}
|
||||
|
||||
if (IS_V1 || VARIANT == xmrig::VARIANT_2) {
|
||||
cryptonight_monero_tweak<VARIANT>(l0, idx0 & MASK, ax0, bx0, bx1, cx);
|
||||
if (BASE == xmrig::VARIANT_1 || BASE == xmrig::VARIANT_2) {
|
||||
cryptonight_monero_tweak<VARIANT, BASE>(l0, idx0 & MASK, ax0, bx0, bx1, cx);
|
||||
} else {
|
||||
_mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx));
|
||||
}
|
||||
|
@ -484,7 +484,8 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
uint64_t hi, lo, cl, ch;
|
||||
cl = ((uint64_t*) &l0[idx0 & MASK])[0];
|
||||
ch = ((uint64_t*) &l0[idx0 & MASK])[1];
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_INTEGER_MATH(0, cl, cx);
|
||||
lo = __umul128(idx0, cl, &hi);
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo);
|
||||
|
@ -498,9 +499,9 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||
|
||||
if (IS_V1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
||||
} else if (IS_V1) {
|
||||
} else if (BASE == xmrig::VARIANT_1) {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0;
|
||||
} else {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0;
|
||||
|
@ -525,9 +526,11 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
idx0 = d ^ q;
|
||||
}
|
||||
}
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
bx1 = bx0;
|
||||
}
|
||||
|
||||
bx0 = cx;
|
||||
}
|
||||
|
||||
|
@ -541,12 +544,12 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 64);
|
||||
return;
|
||||
}
|
||||
|
@ -602,9 +605,9 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
cx1 = _mm_aesenc_si128(cx1, ax1);
|
||||
}
|
||||
|
||||
if (IS_V1 || (VARIANT == xmrig::VARIANT_2)) {
|
||||
cryptonight_monero_tweak<VARIANT>(l0, idx0 & MASK, ax0, bx00, bx01, cx0);
|
||||
cryptonight_monero_tweak<VARIANT>(l1, idx1 & MASK, ax1, bx10, bx11, cx1);
|
||||
if (BASE == xmrig::VARIANT_1 || (BASE == xmrig::VARIANT_2)) {
|
||||
cryptonight_monero_tweak<VARIANT, BASE>(l0, idx0 & MASK, ax0, bx00, bx01, cx0);
|
||||
cryptonight_monero_tweak<VARIANT, BASE>(l1, idx1 & MASK, ax1, bx10, bx11, cx1);
|
||||
} else {
|
||||
_mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx00, cx0));
|
||||
_mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx10, cx1));
|
||||
|
@ -616,7 +619,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
uint64_t hi, lo, cl, ch;
|
||||
cl = ((uint64_t*) &l0[idx0 & MASK])[0];
|
||||
ch = ((uint64_t*) &l0[idx0 & MASK])[1];
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_INTEGER_MATH(0, cl, cx0);
|
||||
lo = __umul128(idx0, cl, &hi);
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo);
|
||||
|
@ -629,9 +633,9 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||
|
||||
if (IS_V1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
||||
} else if (IS_V1) {
|
||||
} else if (BASE == xmrig::VARIANT_1) {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0;
|
||||
} else {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0;
|
||||
|
@ -659,7 +663,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
cl = ((uint64_t*) &l1[idx1 & MASK])[0];
|
||||
ch = ((uint64_t*) &l1[idx1 & MASK])[1];
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_INTEGER_MATH(1, cl, cx1);
|
||||
lo = __umul128(idx1, cl, &hi);
|
||||
VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo);
|
||||
|
@ -672,9 +677,9 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
((uint64_t*)&l1[idx1 & MASK])[0] = al1;
|
||||
|
||||
if (IS_V1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1;
|
||||
} else if (IS_V1) {
|
||||
} else if (BASE == xmrig::VARIANT_1) {
|
||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1;
|
||||
} else {
|
||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -38,7 +38,7 @@ namespace xmrig
|
|||
constexpr const size_t CRYPTONIGHT_MEMORY = 2 * 1024 * 1024;
|
||||
constexpr const uint32_t CRYPTONIGHT_MASK = 0x1FFFF0;
|
||||
constexpr const uint32_t CRYPTONIGHT_ITER = 0x80000;
|
||||
constexpr const uint32_t CRYPTONIGHT_MSR_ITER = 0x40000;
|
||||
constexpr const uint32_t CRYPTONIGHT_HALF_ITER = 0x40000;
|
||||
constexpr const uint32_t CRYPTONIGHT_XAO_ITER = 0x100000;
|
||||
|
||||
constexpr const size_t CRYPTONIGHT_LITE_MEMORY = 1 * 1024 * 1024;
|
||||
|
@ -109,7 +109,8 @@ template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_0>()
|
|||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_1>() { return CRYPTONIGHT_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_2>() { return CRYPTONIGHT_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_XTL>() { return CRYPTONIGHT_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_MSR>() { return CRYPTONIGHT_MSR_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_HALF>() { return CRYPTONIGHT_HALF_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_MSR>() { return CRYPTONIGHT_HALF_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_XAO>() { return CRYPTONIGHT_XAO_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_RTO>() { return CRYPTONIGHT_ITER; }
|
||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE, VARIANT_0>() { return CRYPTONIGHT_LITE_ITER; }
|
||||
|
@ -123,7 +124,8 @@ inline uint32_t cn_select_iter(Algo algorithm, Variant variant)
|
|||
{
|
||||
switch (variant) {
|
||||
case VARIANT_MSR:
|
||||
return CRYPTONIGHT_MSR_ITER;
|
||||
case VARIANT_HALF:
|
||||
return CRYPTONIGHT_HALF_ITER;
|
||||
|
||||
case VARIANT_RTO:
|
||||
return CRYPTONIGHT_XAO_ITER;
|
||||
|
@ -161,6 +163,7 @@ template<> inline constexpr Variant cn_base_variant<VARIANT_XHV>() { return VA
|
|||
template<> inline constexpr Variant cn_base_variant<VARIANT_XAO>() { return VARIANT_0; }
|
||||
template<> inline constexpr Variant cn_base_variant<VARIANT_RTO>() { return VARIANT_1; }
|
||||
template<> inline constexpr Variant cn_base_variant<VARIANT_2>() { return VARIANT_2; }
|
||||
template<> inline constexpr Variant cn_base_variant<VARIANT_HALF>() { return VARIANT_2; }
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -33,21 +33,21 @@
|
|||
#ifndef XMRIG_ARM
|
||||
# define VARIANT1_INIT(part) \
|
||||
uint64_t tweak1_2_##part = 0; \
|
||||
if (IS_V1) { \
|
||||
if (BASE == xmrig::VARIANT_1) { \
|
||||
tweak1_2_##part = (*reinterpret_cast<const uint64_t*>(input + 35 + part * size) ^ \
|
||||
*(reinterpret_cast<const uint64_t*>(ctx[part]->state) + 24)); \
|
||||
}
|
||||
#else
|
||||
# define VARIANT1_INIT(part) \
|
||||
uint64_t tweak1_2_##part = 0; \
|
||||
if (IS_V1) { \
|
||||
if (BASE == xmrig::VARIANT_1) { \
|
||||
memcpy(&tweak1_2_##part, input + 35 + part * size, sizeof tweak1_2_##part); \
|
||||
tweak1_2_##part ^= *(reinterpret_cast<const uint64_t*>(ctx[part]->state) + 24); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define VARIANT1_1(p) \
|
||||
if (IS_V1) { \
|
||||
if (BASE == xmrig::VARIANT_1) { \
|
||||
const uint8_t tmp = reinterpret_cast<const uint8_t*>(p)[11]; \
|
||||
static const uint32_t table = 0x75310; \
|
||||
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \
|
||||
|
@ -55,7 +55,7 @@
|
|||
}
|
||||
|
||||
#define VARIANT1_2(p, part) \
|
||||
if (IS_V1) { \
|
||||
if (BASE == xmrig::VARIANT_1) { \
|
||||
(p) ^= tweak1_2_##part; \
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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,8 +22,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CRYPTONIGHT_TEST_H__
|
||||
#define __CRYPTONIGHT_TEST_H__
|
||||
#ifndef XMRIG_CRYPTONIGHT_TEST_H
|
||||
#define XMRIG_CRYPTONIGHT_TEST_H
|
||||
|
||||
|
||||
const static uint8_t test_input[380] = {
|
||||
|
@ -55,6 +55,7 @@ const static uint8_t test_input[380] = {
|
|||
};
|
||||
|
||||
|
||||
// "cn/0"
|
||||
const static uint8_t test_output_v0[160] = {
|
||||
0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7,
|
||||
0x1B, 0x31, 0x10, 0xD8, 0x86, 0x01, 0x1E, 0x87, 0x7E, 0xE5, 0x78, 0x6A, 0xFD, 0x08, 0x01, 0x00,
|
||||
|
@ -69,7 +70,7 @@ const static uint8_t test_output_v0[160] = {
|
|||
};
|
||||
|
||||
|
||||
// Cryptonight variant 1 (Monero v7)
|
||||
// "cn/1" Cryptonight variant 1 (Monero v7)
|
||||
const static uint8_t test_output_v1[160] = {
|
||||
0xF2, 0x2D, 0x3D, 0x62, 0x03, 0xD2, 0xA0, 0x8B, 0x41, 0xD9, 0x02, 0x72, 0x78, 0xD8, 0xBC, 0xC9,
|
||||
0x83, 0xAC, 0xAD, 0xA9, 0xB6, 0x8E, 0x52, 0xE3, 0xC6, 0x89, 0x69, 0x2A, 0x50, 0xE9, 0x21, 0xD9,
|
||||
|
@ -84,7 +85,7 @@ const static uint8_t test_output_v1[160] = {
|
|||
};
|
||||
|
||||
|
||||
// Cryptonight variant 2 (Monero v8)
|
||||
// "cn/2" Cryptonight variant 2 (Monero v8)
|
||||
const static uint8_t test_output_v2[160] = {
|
||||
0x97, 0x37, 0x82, 0x82, 0xCF, 0x10, 0xE7, 0xAD, 0x03, 0x3F, 0x7B, 0x80, 0x74, 0xC4, 0x0E, 0x14,
|
||||
0xD0, 0x6E, 0x7F, 0x60, 0x9D, 0xDD, 0xDA, 0x78, 0x76, 0x80, 0xB5, 0x8C, 0x05, 0xF4, 0x3D, 0x21,
|
||||
|
@ -99,7 +100,7 @@ const static uint8_t test_output_v2[160] = {
|
|||
};
|
||||
|
||||
|
||||
// Stellite (XTL)
|
||||
// "cn/xtl" Stellite (XTL)
|
||||
const static uint8_t test_output_xtl[160] = {
|
||||
0x8F, 0xE5, 0xF0, 0x5F, 0x02, 0x2A, 0x61, 0x7D, 0xE5, 0x3F, 0x79, 0x36, 0x4B, 0x25, 0xCB, 0xC3,
|
||||
0xC0, 0x8E, 0x0E, 0x1F, 0xE3, 0xBE, 0x48, 0x57, 0x07, 0x03, 0xFE, 0xE1, 0xEC, 0x0E, 0xB0, 0xB1,
|
||||
|
@ -114,7 +115,22 @@ const static uint8_t test_output_xtl[160] = {
|
|||
};
|
||||
|
||||
|
||||
// Masari (MSR)
|
||||
// "cn/half"
|
||||
const static uint8_t test_output_half[160] = {
|
||||
0x5D, 0x4F, 0xBC, 0x35, 0x60, 0x97, 0xEA, 0x64, 0x40, 0xB0, 0x88, 0x8E, 0xDE, 0xB6, 0x35, 0xDD,
|
||||
0xC8, 0x4A, 0x0E, 0x39, 0x7C, 0x86, 0x84, 0x56, 0x89, 0x5C, 0x3F, 0x29, 0xBE, 0x73, 0x12, 0xA7,
|
||||
0x02, 0xE6, 0x1D, 0x2B, 0xBC, 0x84, 0xB6, 0x71, 0x96, 0x71, 0xD5, 0x0C, 0xAC, 0x76, 0x0E, 0x6B,
|
||||
0xF1, 0xF0, 0x55, 0x34, 0x15, 0x29, 0x93, 0x04, 0x2D, 0xED, 0xD2, 0x33, 0x50, 0x6E, 0xBE, 0x25,
|
||||
0xD0, 0xFD, 0x8E, 0xC6, 0x15, 0xD5, 0x12, 0x53, 0x7B, 0x26, 0xF6, 0x01, 0xA5, 0xA8, 0xBE, 0x7C,
|
||||
0xCF, 0x5E, 0x19, 0xB7, 0x63, 0x0D, 0x0F, 0x02, 0x2B, 0xD7, 0xC4, 0x8C, 0x12, 0x24, 0x80, 0x02,
|
||||
0xE7, 0xB7, 0xA0, 0x4F, 0x94, 0xF9, 0x46, 0xB5, 0x18, 0x64, 0x7E, 0x4E, 0x9C, 0x81, 0x6C, 0x60,
|
||||
0x7D, 0x2E, 0xEA, 0xCF, 0x90, 0xCB, 0x68, 0x09, 0xC9, 0x53, 0xF6, 0xA9, 0xCA, 0x0C, 0xAC, 0xDC,
|
||||
0xFD, 0x07, 0xDA, 0x24, 0x1D, 0xD1, 0x35, 0x32, 0x3C, 0xE8, 0x64, 0x44, 0x5E, 0xCB, 0xB5, 0x00,
|
||||
0x69, 0xF4, 0x6F, 0xBB, 0x62, 0x0D, 0x25, 0xD8, 0xAC, 0x20, 0x90, 0xC5, 0x1B, 0xD3, 0x5F, 0xCA
|
||||
};
|
||||
|
||||
|
||||
// "cn/msr" Masari (MSR)
|
||||
const static uint8_t test_output_msr[160] = {
|
||||
0x3C, 0x7A, 0x61, 0x08, 0x4C, 0x5E, 0xB8, 0x65, 0xB4, 0x98, 0xAB, 0x2F, 0x5A, 0x1A, 0xC5, 0x2C,
|
||||
0x49, 0xC1, 0x77, 0xC2, 0xD0, 0x13, 0x34, 0x42, 0xD6, 0x5E, 0xD5, 0x14, 0x33, 0x5C, 0x82, 0xC5,
|
||||
|
@ -129,7 +145,7 @@ const static uint8_t test_output_msr[160] = {
|
|||
};
|
||||
|
||||
|
||||
// Alloy (XAO)
|
||||
// "cn/xao" Alloy (XAO)
|
||||
const static uint8_t test_output_xao[160] = {
|
||||
0x9A, 0x29, 0xD0, 0xC4, 0xAF, 0xDC, 0x63, 0x9B, 0x65, 0x53, 0xB1, 0xC8, 0x37, 0x35, 0x11, 0x4C,
|
||||
0x5D, 0x77, 0x16, 0x21, 0x42, 0x97, 0x5C, 0xB8, 0x50, 0xC0, 0xA5, 0x1F, 0x64, 0x07, 0xBD, 0x33,
|
||||
|
@ -144,7 +160,7 @@ const static uint8_t test_output_xao[160] = {
|
|||
};
|
||||
|
||||
|
||||
// Arto (RTO)
|
||||
// "cn/rto" Arto (RTO)
|
||||
const static uint8_t test_output_rto[160] = {
|
||||
0x82, 0x66, 0x1E, 0x1C, 0x6E, 0x64, 0x36, 0x66, 0x84, 0x06, 0x32, 0x7A, 0x9B, 0xB1, 0x13, 0x19,
|
||||
0xA5, 0x56, 0x16, 0x15, 0xDF, 0xEC, 0x1C, 0x9E, 0xE3, 0x88, 0x4A, 0x6C, 0x1C, 0xEB, 0x76, 0xA5,
|
||||
|
@ -160,6 +176,7 @@ const static uint8_t test_output_rto[160] = {
|
|||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
// "cn-lite/0"
|
||||
const static uint8_t test_output_v0_lite[160] = {
|
||||
0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
|
||||
0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88,
|
||||
|
@ -174,7 +191,7 @@ const static uint8_t test_output_v0_lite[160] = {
|
|||
};
|
||||
|
||||
|
||||
// AEON v7
|
||||
// "cn-lite/1" AEON v7
|
||||
const static uint8_t test_output_v1_lite[160] = {
|
||||
0x6D, 0x8C, 0xDC, 0x44, 0x4E, 0x9B, 0xBB, 0xFD, 0x68, 0xFC, 0x43, 0xFC, 0xD4, 0x85, 0x5B, 0x22,
|
||||
0x8C, 0x8A, 0x1B, 0xD9, 0x1D, 0x9D, 0x00, 0x28, 0x5B, 0xEC, 0x02, 0xB7, 0xCA, 0x2D, 0x67, 0x41,
|
||||
|
@ -191,6 +208,7 @@ const static uint8_t test_output_v1_lite[160] = {
|
|||
|
||||
|
||||
#ifndef XMRIG_NO_SUMO
|
||||
// "cn-heavy/0"
|
||||
const static uint8_t test_output_v0_heavy[160] = {
|
||||
0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64,
|
||||
0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2,
|
||||
|
@ -204,6 +222,8 @@ const static uint8_t test_output_v0_heavy[160] = {
|
|||
0xAD, 0xB1, 0xFD, 0x89, 0xFB, 0x5C, 0xB4, 0x25, 0x6A, 0xDD, 0xB0, 0x09, 0xC5, 0x72, 0x87, 0xEB
|
||||
};
|
||||
|
||||
|
||||
// "cn-heavy/xhv"
|
||||
const static uint8_t test_output_xhv_heavy[160] = {
|
||||
0x5A, 0xC3, 0xF7, 0x85, 0xC4, 0x90, 0xC5, 0x85, 0x50, 0xEC, 0x95, 0xD2, 0x72, 0x65, 0x63, 0x57,
|
||||
0x7E, 0x7C, 0x1C, 0x21, 0x2D, 0x0C, 0xDE, 0x59, 0x12, 0x73, 0x20, 0x1E, 0x44, 0xFD, 0xD5, 0xB6,
|
||||
|
@ -218,7 +238,7 @@ const static uint8_t test_output_xhv_heavy[160] = {
|
|||
};
|
||||
|
||||
|
||||
// TUBE
|
||||
// "cn-heavy/tube"
|
||||
const static uint8_t test_output_tube_heavy[160] = {
|
||||
0xFE, 0x53, 0x35, 0x20, 0x76, 0xEA, 0xE6, 0x89, 0xFA, 0x3B, 0x4F, 0xDA, 0x61, 0x46, 0x34, 0xCF,
|
||||
0xC3, 0x12, 0xEE, 0x0C, 0x38, 0x7D, 0xF2, 0xB8, 0xB7, 0x4D, 0xA2, 0xA1, 0x59, 0x74, 0x12, 0x35,
|
||||
|
@ -234,4 +254,4 @@ const static uint8_t test_output_tube_heavy[160] = {
|
|||
#endif
|
||||
|
||||
|
||||
#endif /* __CRYPTONIGHT_TEST_H__ */
|
||||
#endif /* XMRIG_CRYPTONIGHT_TEST_H */
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -427,10 +427,10 @@ static inline __m128i int_sqrt_v2(const uint64_t n0)
|
|||
}
|
||||
|
||||
|
||||
template<xmrig::Variant VARIANT>
|
||||
template<xmrig::Variant VARIANT, xmrig::Variant BASE>
|
||||
static inline void cryptonight_monero_tweak(uint64_t* mem_out, const uint8_t* l, uint64_t idx, __m128i ax0, __m128i bx0, __m128i bx1, __m128i cx)
|
||||
{
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1);
|
||||
_mm_store_si128((__m128i *)mem_out, _mm_xor_si128(bx0, cx));
|
||||
} else {
|
||||
|
@ -453,12 +453,12 @@ static inline void cryptonight_monero_tweak(uint64_t* mem_out, const uint8_t* l,
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 32);
|
||||
return;
|
||||
}
|
||||
|
@ -498,8 +498,8 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
cx = _mm_aesenc_si128(cx, ax0);
|
||||
}
|
||||
|
||||
if (IS_V1 || VARIANT == xmrig::VARIANT_2) {
|
||||
cryptonight_monero_tweak<VARIANT>((uint64_t*)&l0[idx0 & MASK], l0, idx0 & MASK, ax0, bx0, bx1, cx);
|
||||
if (BASE == xmrig::VARIANT_1 || BASE == xmrig::VARIANT_2) {
|
||||
cryptonight_monero_tweak<VARIANT, BASE>((uint64_t*)&l0[idx0 & MASK], l0, idx0 & MASK, ax0, bx0, bx1, cx);
|
||||
} else {
|
||||
_mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx));
|
||||
}
|
||||
|
@ -509,7 +509,8 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
uint64_t hi, lo, cl, ch;
|
||||
cl = ((uint64_t*) &l0[idx0 & MASK])[0];
|
||||
ch = ((uint64_t*) &l0[idx0 & MASK])[1];
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_INTEGER_MATH(0, cl, cx);
|
||||
lo = __umul128(idx0, cl, &hi);
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo);
|
||||
|
@ -523,9 +524,9 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||
|
||||
if (IS_V1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
||||
} else if (IS_V1) {
|
||||
} else if (BASE == xmrig::VARIANT_1) {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0;
|
||||
} else {
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0;
|
||||
|
@ -548,9 +549,11 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
idx0 = d ^ q;
|
||||
}
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
bx1 = bx0;
|
||||
}
|
||||
|
||||
bx0 = cx;
|
||||
}
|
||||
|
||||
|
@ -564,7 +567,13 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
#ifndef XMRIG_NO_ASM
|
||||
extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx *ctx);
|
||||
extern "C" void cnv2_mainloop_ryzen_asm(cryptonight_ctx *ctx);
|
||||
extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx* ctx0, cryptonight_ctx* ctx1);
|
||||
extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx *ctx);
|
||||
extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx *ctx0, cryptonight_ctx *ctx1);
|
||||
|
||||
extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm;
|
||||
extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm;
|
||||
extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm;
|
||||
extern xmrig::CpuThread::cn_mainloop_double_fun cn_half_double_mainloop_sandybridge_asm;
|
||||
|
||||
|
||||
template<xmrig::Algo ALGO, xmrig::Variant VARIANT, xmrig::Assembly ASM>
|
||||
|
@ -575,11 +584,27 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
xmrig::keccak(input, size, ctx[0]->state);
|
||||
cn_explode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[0]->state), reinterpret_cast<__m128i*>(ctx[0]->memory));
|
||||
|
||||
if (ASM == xmrig::ASM_INTEL) {
|
||||
cnv2_mainloop_ivybridge_asm(ctx[0]);
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
if (ASM == xmrig::ASM_INTEL) {
|
||||
cnv2_mainloop_ivybridge_asm(ctx[0]);
|
||||
}
|
||||
else if (ASM == xmrig::ASM_RYZEN) {
|
||||
cnv2_mainloop_ryzen_asm(ctx[0]);
|
||||
}
|
||||
else {
|
||||
cnv2_mainloop_bulldozer_asm(ctx[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cnv2_mainloop_ryzen_asm(ctx[0]);
|
||||
else if (VARIANT == xmrig::VARIANT_HALF) {
|
||||
if (ASM == xmrig::ASM_INTEL) {
|
||||
cn_half_mainloop_ivybridge_asm(ctx[0]);
|
||||
}
|
||||
else if (ASM == xmrig::ASM_RYZEN) {
|
||||
cn_half_mainloop_ryzen_asm(ctx[0]);
|
||||
}
|
||||
else {
|
||||
cn_half_mainloop_bulldozer_asm(ctx[0]);
|
||||
}
|
||||
}
|
||||
|
||||
cn_implode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state));
|
||||
|
@ -599,7 +624,12 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
cn_explode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[0]->state), reinterpret_cast<__m128i*>(ctx[0]->memory));
|
||||
cn_explode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[1]->state), reinterpret_cast<__m128i*>(ctx[1]->memory));
|
||||
|
||||
cnv2_double_mainloop_sandybridge_asm(ctx[0], ctx[1]);
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
cnv2_double_mainloop_sandybridge_asm(ctx[0], ctx[1]);
|
||||
}
|
||||
else if (VARIANT == xmrig::VARIANT_HALF) {
|
||||
cn_half_double_mainloop_sandybridge_asm(ctx[0], ctx[1]);
|
||||
}
|
||||
|
||||
cn_implode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state));
|
||||
cn_implode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[1]->memory), reinterpret_cast<__m128i*>(ctx[1]->state));
|
||||
|
@ -616,12 +646,12 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 64);
|
||||
return;
|
||||
}
|
||||
|
@ -678,9 +708,9 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
cx1 = _mm_aesenc_si128(cx1, ax1);
|
||||
}
|
||||
|
||||
if (IS_V1 || (VARIANT == xmrig::VARIANT_2)) {
|
||||
cryptonight_monero_tweak<VARIANT>((uint64_t*)&l0[idx0 & MASK], l0, idx0 & MASK, ax0, bx00, bx01, cx0);
|
||||
cryptonight_monero_tweak<VARIANT>((uint64_t*)&l1[idx1 & MASK], l1, idx1 & MASK, ax1, bx10, bx11, cx1);
|
||||
if (BASE == xmrig::VARIANT_1 || (BASE == xmrig::VARIANT_2)) {
|
||||
cryptonight_monero_tweak<VARIANT, BASE>((uint64_t*)&l0[idx0 & MASK], l0, idx0 & MASK, ax0, bx00, bx01, cx0);
|
||||
cryptonight_monero_tweak<VARIANT, BASE>((uint64_t*)&l1[idx1 & MASK], l1, idx1 & MASK, ax1, bx10, bx11, cx1);
|
||||
} else {
|
||||
_mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx00, cx0));
|
||||
_mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx10, cx1));
|
||||
|
@ -692,7 +722,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
uint64_t hi, lo, cl, ch;
|
||||
cl = ((uint64_t*) &l0[idx0 & MASK])[0];
|
||||
ch = ((uint64_t*) &l0[idx0 & MASK])[1];
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_INTEGER_MATH(0, cl, cx0);
|
||||
lo = __umul128(idx0, cl, &hi);
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo);
|
||||
|
@ -705,9 +736,9 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||
|
||||
if (IS_V1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
((uint64_t*) &l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
||||
} else if (IS_V1) {
|
||||
} else if (BASE == xmrig::VARIANT_1) {
|
||||
((uint64_t*) &l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0;
|
||||
} else {
|
||||
((uint64_t*) &l0[idx0 & MASK])[1] = ah0;
|
||||
|
@ -733,7 +764,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
cl = ((uint64_t*) &l1[idx1 & MASK])[0];
|
||||
ch = ((uint64_t*) &l1[idx1 & MASK])[1];
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
VARIANT2_INTEGER_MATH(1, cl, cx1);
|
||||
lo = __umul128(idx1, cl, &hi);
|
||||
VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo);
|
||||
|
@ -746,9 +778,9 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
((uint64_t*)&l1[idx1 & MASK])[0] = al1;
|
||||
|
||||
if (IS_V1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) {
|
||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1;
|
||||
} else if (IS_V1) {
|
||||
} else if (BASE == xmrig::VARIANT_1) {
|
||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1;
|
||||
} else {
|
||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1;
|
||||
|
@ -772,10 +804,11 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
idx1 = d ^ q;
|
||||
}
|
||||
|
||||
if (VARIANT == xmrig::VARIANT_2) {
|
||||
if (BASE == xmrig::VARIANT_2) {
|
||||
bx01 = bx00;
|
||||
bx11 = bx10;
|
||||
}
|
||||
|
||||
bx00 = cx0;
|
||||
bx10 = cx1;
|
||||
}
|
||||
|
@ -806,8 +839,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
c = _mm_aesenc_si128(c, a); \
|
||||
} \
|
||||
\
|
||||
if (IS_V1 || (VARIANT == xmrig::VARIANT_2)) { \
|
||||
cryptonight_monero_tweak<VARIANT>((uint64_t*)ptr, l, idx & MASK, a, b0, b1, c); \
|
||||
if (BASE == xmrig::VARIANT_1 || BASE == xmrig::VARIANT_2) { \
|
||||
cryptonight_monero_tweak<VARIANT, BASE>((uint64_t*)ptr, l, idx & MASK, a, b0, b1, c); \
|
||||
} else { \
|
||||
_mm_store_si128(ptr, _mm_xor_si128(b0, c)); \
|
||||
}
|
||||
|
@ -821,7 +854,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
|
||||
|
||||
#define CN_STEP4(part, a, b0, b1, c, l, mc, ptr, idx) \
|
||||
if (VARIANT == xmrig::VARIANT_2) { \
|
||||
if (BASE == xmrig::VARIANT_2) { \
|
||||
VARIANT2_INTEGER_MATH(part, cl##part, c); \
|
||||
lo = __umul128(idx, cl##part, &hi); \
|
||||
VARIANT2_SHUFFLE2(l, idx & MASK, a, b0, b1, hi, lo); \
|
||||
|
@ -830,7 +863,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
} \
|
||||
a = _mm_add_epi64(a, _mm_set_epi64x(lo, hi)); \
|
||||
\
|
||||
if (IS_V1) { \
|
||||
if (BASE == xmrig::VARIANT_1) { \
|
||||
_mm_store_si128(ptr, _mm_xor_si128(a, mc)); \
|
||||
\
|
||||
if (VARIANT == xmrig::VARIANT_TUBE || \
|
||||
|
@ -855,7 +888,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
\
|
||||
idx = d ^ q; \
|
||||
} \
|
||||
if (VARIANT == xmrig::VARIANT_2) { \
|
||||
if (BASE == xmrig::VARIANT_2) { \
|
||||
b1 = b0; \
|
||||
} \
|
||||
b0 = c;
|
||||
|
@ -865,11 +898,11 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
__m128i mc##n; \
|
||||
__m128i division_result_xmm_##n; \
|
||||
__m128i sqrt_result_xmm_##n; \
|
||||
if (IS_V1) { \
|
||||
if (BASE == xmrig::VARIANT_1) { \
|
||||
mc##n = _mm_set_epi64x(*reinterpret_cast<const uint64_t*>(input + n * size + 35) ^ \
|
||||
*(reinterpret_cast<const uint64_t*>((ctx)->state) + 24), 0); \
|
||||
} \
|
||||
if (VARIANT == xmrig::VARIANT_2) { \
|
||||
if (BASE == xmrig::VARIANT_2) { \
|
||||
division_result_xmm_##n = _mm_cvtsi64_si128(h##n[12]); \
|
||||
sqrt_result_xmm_##n = _mm_cvtsi64_si128(h##n[13]); \
|
||||
} \
|
||||
|
@ -882,12 +915,12 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 32 * 3);
|
||||
return;
|
||||
}
|
||||
|
@ -946,12 +979,12 @@ inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t si
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 32 * 4);
|
||||
return;
|
||||
}
|
||||
|
@ -1019,12 +1052,12 @@ inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size
|
|||
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||
inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||
{
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr bool IS_V1 = xmrig::cn_base_variant<VARIANT>() == xmrig::VARIANT_1;
|
||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||
constexpr xmrig::Variant BASE = xmrig::cn_base_variant<VARIANT>();
|
||||
|
||||
if (IS_V1 && size < 43) {
|
||||
if (BASE == xmrig::VARIANT_1 && size < 43) {
|
||||
memset(output, 0, 32 * 5);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
lea r9, QWORD PTR [rdx+r13]
|
||||
movdqu xmm15, XMMWORD PTR [r9]
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
main_loop_double_sandybridge:
|
||||
movdqu xmm9, xmm15
|
||||
mov eax, edx
|
180
src/crypto/asm/cn2/cnv2_main_loop_bulldozer.inc
Normal file
180
src/crypto/asm/cn2/cnv2_main_loop_bulldozer.inc
Normal file
|
@ -0,0 +1,180 @@
|
|||
mov QWORD PTR [rsp+16], rbx
|
||||
mov QWORD PTR [rsp+24], rbp
|
||||
mov QWORD PTR [rsp+32], rsi
|
||||
push rdi
|
||||
push r12
|
||||
push r13
|
||||
push r14
|
||||
push r15
|
||||
sub rsp, 64
|
||||
|
||||
stmxcsr DWORD PTR [rsp]
|
||||
mov DWORD PTR [rsp+4], 24448
|
||||
ldmxcsr DWORD PTR [rsp+4]
|
||||
|
||||
mov rax, QWORD PTR [rcx+48]
|
||||
mov r9, rcx
|
||||
xor rax, QWORD PTR [rcx+16]
|
||||
mov ebp, 524288
|
||||
mov r8, QWORD PTR [rcx+32]
|
||||
xor r8, QWORD PTR [rcx]
|
||||
mov r11, QWORD PTR [rcx+40]
|
||||
mov r10, r8
|
||||
mov rdx, QWORD PTR [rcx+56]
|
||||
movq xmm3, rax
|
||||
xor rdx, QWORD PTR [rcx+24]
|
||||
xor r11, QWORD PTR [rcx+8]
|
||||
mov rbx, QWORD PTR [rcx+224]
|
||||
mov rax, QWORD PTR [r9+80]
|
||||
xor rax, QWORD PTR [r9+64]
|
||||
movq xmm0, rdx
|
||||
mov rcx, QWORD PTR [rcx+88]
|
||||
xor rcx, QWORD PTR [r9+72]
|
||||
mov rdi, QWORD PTR [r9+104]
|
||||
and r10d, 2097136
|
||||
movaps XMMWORD PTR [rsp+48], xmm6
|
||||
movq xmm4, rax
|
||||
movaps XMMWORD PTR [rsp+32], xmm7
|
||||
movaps XMMWORD PTR [rsp+16], xmm8
|
||||
xorps xmm8, xmm8
|
||||
mov ax, 1023
|
||||
shl rax, 52
|
||||
movq xmm7, rax
|
||||
mov r15, QWORD PTR [r9+96]
|
||||
punpcklqdq xmm3, xmm0
|
||||
movq xmm0, rcx
|
||||
punpcklqdq xmm4, xmm0
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_main_loop_bulldozer:
|
||||
movdqa xmm5, XMMWORD PTR [r10+rbx]
|
||||
movq xmm6, r8
|
||||
pinsrq xmm6, r11, 1
|
||||
lea rdx, QWORD PTR [r10+rbx]
|
||||
lea r9, QWORD PTR [rdi+rdi]
|
||||
shl rdi, 32
|
||||
|
||||
mov ecx, r10d
|
||||
mov eax, r10d
|
||||
xor ecx, 16
|
||||
xor eax, 32
|
||||
xor r10d, 48
|
||||
aesenc xmm5, xmm6
|
||||
movdqa xmm2, XMMWORD PTR [rcx+rbx]
|
||||
movdqa xmm1, XMMWORD PTR [rax+rbx]
|
||||
movdqa xmm0, XMMWORD PTR [r10+rbx]
|
||||
paddq xmm2, xmm3
|
||||
paddq xmm1, xmm6
|
||||
paddq xmm0, xmm4
|
||||
movdqa XMMWORD PTR [rcx+rbx], xmm0
|
||||
movdqa XMMWORD PTR [rax+rbx], xmm2
|
||||
movdqa XMMWORD PTR [r10+rbx], xmm1
|
||||
|
||||
movaps xmm1, xmm8
|
||||
mov rsi, r15
|
||||
xor rsi, rdi
|
||||
|
||||
mov edi, 1023
|
||||
shl rdi, 52
|
||||
|
||||
movq r14, xmm5
|
||||
pextrq rax, xmm5, 1
|
||||
|
||||
movdqa xmm0, xmm5
|
||||
pxor xmm0, xmm3
|
||||
mov r10, r14
|
||||
and r10d, 2097136
|
||||
movdqa XMMWORD PTR [rdx], xmm0
|
||||
xor rsi, QWORD PTR [r10+rbx]
|
||||
lea r12, QWORD PTR [r10+rbx]
|
||||
mov r13, QWORD PTR [r10+rbx+8]
|
||||
|
||||
add r9d, r14d
|
||||
or r9d, -2147483647
|
||||
xor edx, edx
|
||||
div r9
|
||||
mov eax, eax
|
||||
shl rdx, 32
|
||||
lea r15, [rax+rdx]
|
||||
lea rax, [r14+r15]
|
||||
shr rax, 12
|
||||
add rax, rdi
|
||||
movq xmm0, rax
|
||||
sqrtsd xmm1, xmm0
|
||||
movq rdi, xmm1
|
||||
test rdi, 524287
|
||||
je sqrt_fixup_bulldozer
|
||||
shr rdi, 19
|
||||
|
||||
sqrt_fixup_bulldozer_ret:
|
||||
mov rax, rsi
|
||||
mul r14
|
||||
movq xmm1, rax
|
||||
movq xmm0, rdx
|
||||
punpcklqdq xmm0, xmm1
|
||||
|
||||
mov r9d, r10d
|
||||
mov ecx, r10d
|
||||
xor r9d, 16
|
||||
xor ecx, 32
|
||||
xor r10d, 48
|
||||
movdqa xmm1, XMMWORD PTR [rcx+rbx]
|
||||
xor rdx, [rcx+rbx]
|
||||
xor rax, [rcx+rbx+8]
|
||||
movdqa xmm2, XMMWORD PTR [r9+rbx]
|
||||
pxor xmm2, xmm0
|
||||
paddq xmm4, XMMWORD PTR [r10+rbx]
|
||||
paddq xmm2, xmm3
|
||||
paddq xmm1, xmm6
|
||||
movdqa XMMWORD PTR [r9+rbx], xmm4
|
||||
movdqa XMMWORD PTR [rcx+rbx], xmm2
|
||||
movdqa XMMWORD PTR [r10+rbx], xmm1
|
||||
|
||||
movdqa xmm4, xmm3
|
||||
add r8, rdx
|
||||
add r11, rax
|
||||
mov QWORD PTR [r12], r8
|
||||
xor r8, rsi
|
||||
mov QWORD PTR [r12+8], r11
|
||||
mov r10, r8
|
||||
xor r11, r13
|
||||
and r10d, 2097136
|
||||
movdqa xmm3, xmm5
|
||||
dec ebp
|
||||
jne cnv2_main_loop_bulldozer
|
||||
|
||||
ldmxcsr DWORD PTR [rsp]
|
||||
movaps xmm6, XMMWORD PTR [rsp+48]
|
||||
lea r11, QWORD PTR [rsp+64]
|
||||
mov rbx, QWORD PTR [r11+56]
|
||||
mov rbp, QWORD PTR [r11+64]
|
||||
mov rsi, QWORD PTR [r11+72]
|
||||
movaps xmm8, XMMWORD PTR [r11-48]
|
||||
movaps xmm7, XMMWORD PTR [rsp+32]
|
||||
mov rsp, r11
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
pop r12
|
||||
pop rdi
|
||||
jmp cnv2_main_loop_bulldozer_endp
|
||||
|
||||
sqrt_fixup_bulldozer:
|
||||
movq r9, xmm5
|
||||
add r9, r15
|
||||
dec rdi
|
||||
mov edx, -1022
|
||||
shl rdx, 32
|
||||
mov rax, rdi
|
||||
shr rdi, 19
|
||||
shr rax, 20
|
||||
mov rcx, rdi
|
||||
sub rcx, rax
|
||||
lea rcx, [rcx+rdx+1]
|
||||
add rax, rdx
|
||||
imul rcx, rax
|
||||
sub rcx, r9
|
||||
adc rdi, 0
|
||||
jmp sqrt_fixup_bulldozer_ret
|
||||
|
||||
cnv2_main_loop_bulldozer_endp:
|
|
@ -50,7 +50,7 @@
|
|||
punpcklqdq xmm5, xmm0
|
||||
movdqu xmm6, XMMWORD PTR [r10+rbx]
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
main_loop_ivybridge:
|
||||
lea rdx, QWORD PTR [r10+rbx]
|
||||
mov ecx, r10d
|
|
@ -45,7 +45,7 @@
|
|||
movq xmm0, rcx
|
||||
punpcklqdq xmm4, xmm0
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
main_loop_ryzen:
|
||||
movdqa xmm5, XMMWORD PTR [r10+rbx]
|
||||
movq xmm0, r11
|
|
@ -1,4 +1,8 @@
|
|||
#define ALIGN .align
|
||||
#ifdef __APPLE__
|
||||
# define ALIGN(x) .align 6
|
||||
#else
|
||||
# define ALIGN(x) .align 64
|
||||
#endif
|
||||
.intel_syntax noprefix
|
||||
#ifdef __APPLE__
|
||||
# define FN_PREFIX(fn) _ ## fn
|
||||
|
@ -9,29 +13,54 @@
|
|||
#endif
|
||||
.global FN_PREFIX(cnv2_mainloop_ivybridge_asm)
|
||||
.global FN_PREFIX(cnv2_mainloop_ryzen_asm)
|
||||
.global FN_PREFIX(cnv2_mainloop_bulldozer_asm)
|
||||
.global FN_PREFIX(cnv2_double_mainloop_sandybridge_asm)
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
FN_PREFIX(cnv2_mainloop_ivybridge_asm):
|
||||
sub rsp, 48
|
||||
mov rcx, rdi
|
||||
#include "cnv2_main_loop_ivybridge.inc"
|
||||
#include "cn2/cnv2_main_loop_ivybridge.inc"
|
||||
add rsp, 48
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
FN_PREFIX(cnv2_mainloop_ryzen_asm):
|
||||
sub rsp, 48
|
||||
mov rcx, rdi
|
||||
#include "cnv2_main_loop_ryzen.inc"
|
||||
#include "cn2/cnv2_main_loop_ryzen.inc"
|
||||
add rsp, 48
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
FN_PREFIX(cnv2_mainloop_bulldozer_asm):
|
||||
sub rsp, 48
|
||||
mov rcx, rdi
|
||||
#include "cn2/cnv2_main_loop_bulldozer.inc"
|
||||
add rsp, 48
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ALIGN(64)
|
||||
FN_PREFIX(cnv2_double_mainloop_sandybridge_asm):
|
||||
sub rsp, 48
|
||||
mov rcx, rdi
|
||||
mov rdx, rsi
|
||||
#include "cnv2_double_main_loop_sandybridge.inc"
|
||||
#include "cn2/cnv2_double_main_loop_sandybridge.inc"
|
||||
add rsp, 48
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
|
@ -1,24 +1,47 @@
|
|||
_TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE
|
||||
PUBLIC cnv2_mainloop_ivybridge_asm
|
||||
PUBLIC cnv2_mainloop_ryzen_asm
|
||||
PUBLIC cnv2_mainloop_bulldozer_asm
|
||||
PUBLIC cnv2_double_mainloop_sandybridge_asm
|
||||
|
||||
ALIGN 64
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_ivybridge_asm PROC
|
||||
INCLUDE cnv2_main_loop_ivybridge.inc
|
||||
INCLUDE cn2/cnv2_main_loop_ivybridge.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_mainloop_ivybridge_asm ENDP
|
||||
|
||||
ALIGN 64
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_ryzen_asm PROC
|
||||
INCLUDE cnv2_main_loop_ryzen.inc
|
||||
INCLUDE cn2/cnv2_main_loop_ryzen.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_mainloop_ryzen_asm ENDP
|
||||
|
||||
ALIGN 64
|
||||
cnv2_double_mainloop_sandybridge_asm PROC
|
||||
INCLUDE cnv2_double_main_loop_sandybridge.inc
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_bulldozer_asm PROC
|
||||
INCLUDE cn2/cnv2_main_loop_bulldozer.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_mainloop_bulldozer_asm ENDP
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_double_mainloop_sandybridge_asm PROC
|
||||
INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_double_mainloop_sandybridge_asm ENDP
|
||||
|
||||
_TEXT_CNV2_MAINLOOP ENDS
|
|
@ -94,7 +94,7 @@
|
|||
lea r9, QWORD PTR [rdx+r13]
|
||||
movdqu xmm15, XMMWORD PTR [r9]
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
main_loop_double_sandybridge:
|
||||
movdqu xmm9, xmm15
|
||||
mov eax, edx
|
180
src/crypto/asm/win64/cn2/cnv2_main_loop_bulldozer.inc
Normal file
180
src/crypto/asm/win64/cn2/cnv2_main_loop_bulldozer.inc
Normal file
|
@ -0,0 +1,180 @@
|
|||
mov QWORD PTR [rsp+16], rbx
|
||||
mov QWORD PTR [rsp+24], rbp
|
||||
mov QWORD PTR [rsp+32], rsi
|
||||
push rdi
|
||||
push r12
|
||||
push r13
|
||||
push r14
|
||||
push r15
|
||||
sub rsp, 64
|
||||
|
||||
stmxcsr DWORD PTR [rsp]
|
||||
mov DWORD PTR [rsp+4], 24448
|
||||
ldmxcsr DWORD PTR [rsp+4]
|
||||
|
||||
mov rax, QWORD PTR [rcx+48]
|
||||
mov r9, rcx
|
||||
xor rax, QWORD PTR [rcx+16]
|
||||
mov ebp, 524288
|
||||
mov r8, QWORD PTR [rcx+32]
|
||||
xor r8, QWORD PTR [rcx]
|
||||
mov r11, QWORD PTR [rcx+40]
|
||||
mov r10, r8
|
||||
mov rdx, QWORD PTR [rcx+56]
|
||||
movd xmm3, rax
|
||||
xor rdx, QWORD PTR [rcx+24]
|
||||
xor r11, QWORD PTR [rcx+8]
|
||||
mov rbx, QWORD PTR [rcx+224]
|
||||
mov rax, QWORD PTR [r9+80]
|
||||
xor rax, QWORD PTR [r9+64]
|
||||
movd xmm0, rdx
|
||||
mov rcx, QWORD PTR [rcx+88]
|
||||
xor rcx, QWORD PTR [r9+72]
|
||||
mov rdi, QWORD PTR [r9+104]
|
||||
and r10d, 2097136
|
||||
movaps XMMWORD PTR [rsp+48], xmm6
|
||||
movd xmm4, rax
|
||||
movaps XMMWORD PTR [rsp+32], xmm7
|
||||
movaps XMMWORD PTR [rsp+16], xmm8
|
||||
xorps xmm8, xmm8
|
||||
mov ax, 1023
|
||||
shl rax, 52
|
||||
movd xmm7, rax
|
||||
mov r15, QWORD PTR [r9+96]
|
||||
punpcklqdq xmm3, xmm0
|
||||
movd xmm0, rcx
|
||||
punpcklqdq xmm4, xmm0
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_main_loop_bulldozer:
|
||||
movdqa xmm5, XMMWORD PTR [r10+rbx]
|
||||
movd xmm6, r8
|
||||
pinsrq xmm6, r11, 1
|
||||
lea rdx, QWORD PTR [r10+rbx]
|
||||
lea r9, QWORD PTR [rdi+rdi]
|
||||
shl rdi, 32
|
||||
|
||||
mov ecx, r10d
|
||||
mov eax, r10d
|
||||
xor ecx, 16
|
||||
xor eax, 32
|
||||
xor r10d, 48
|
||||
aesenc xmm5, xmm6
|
||||
movdqa xmm2, XMMWORD PTR [rcx+rbx]
|
||||
movdqa xmm1, XMMWORD PTR [rax+rbx]
|
||||
movdqa xmm0, XMMWORD PTR [r10+rbx]
|
||||
paddq xmm2, xmm3
|
||||
paddq xmm1, xmm6
|
||||
paddq xmm0, xmm4
|
||||
movdqa XMMWORD PTR [rcx+rbx], xmm0
|
||||
movdqa XMMWORD PTR [rax+rbx], xmm2
|
||||
movdqa XMMWORD PTR [r10+rbx], xmm1
|
||||
|
||||
movaps xmm1, xmm8
|
||||
mov rsi, r15
|
||||
xor rsi, rdi
|
||||
|
||||
mov edi, 1023
|
||||
shl rdi, 52
|
||||
|
||||
movd r14, xmm5
|
||||
pextrq rax, xmm5, 1
|
||||
|
||||
movdqa xmm0, xmm5
|
||||
pxor xmm0, xmm3
|
||||
mov r10, r14
|
||||
and r10d, 2097136
|
||||
movdqa XMMWORD PTR [rdx], xmm0
|
||||
xor rsi, QWORD PTR [r10+rbx]
|
||||
lea r12, QWORD PTR [r10+rbx]
|
||||
mov r13, QWORD PTR [r10+rbx+8]
|
||||
|
||||
add r9d, r14d
|
||||
or r9d, -2147483647
|
||||
xor edx, edx
|
||||
div r9
|
||||
mov eax, eax
|
||||
shl rdx, 32
|
||||
lea r15, [rax+rdx]
|
||||
lea rax, [r14+r15]
|
||||
shr rax, 12
|
||||
add rax, rdi
|
||||
movd xmm0, rax
|
||||
sqrtsd xmm1, xmm0
|
||||
movd rdi, xmm1
|
||||
test rdi, 524287
|
||||
je sqrt_fixup_bulldozer
|
||||
shr rdi, 19
|
||||
|
||||
sqrt_fixup_bulldozer_ret:
|
||||
mov rax, rsi
|
||||
mul r14
|
||||
movd xmm1, rax
|
||||
movd xmm0, rdx
|
||||
punpcklqdq xmm0, xmm1
|
||||
|
||||
mov r9d, r10d
|
||||
mov ecx, r10d
|
||||
xor r9d, 16
|
||||
xor ecx, 32
|
||||
xor r10d, 48
|
||||
movdqa xmm1, XMMWORD PTR [rcx+rbx]
|
||||
xor rdx, [rcx+rbx]
|
||||
xor rax, [rcx+rbx+8]
|
||||
movdqa xmm2, XMMWORD PTR [r9+rbx]
|
||||
pxor xmm2, xmm0
|
||||
paddq xmm4, XMMWORD PTR [r10+rbx]
|
||||
paddq xmm2, xmm3
|
||||
paddq xmm1, xmm6
|
||||
movdqa XMMWORD PTR [r9+rbx], xmm4
|
||||
movdqa XMMWORD PTR [rcx+rbx], xmm2
|
||||
movdqa XMMWORD PTR [r10+rbx], xmm1
|
||||
|
||||
movdqa xmm4, xmm3
|
||||
add r8, rdx
|
||||
add r11, rax
|
||||
mov QWORD PTR [r12], r8
|
||||
xor r8, rsi
|
||||
mov QWORD PTR [r12+8], r11
|
||||
mov r10, r8
|
||||
xor r11, r13
|
||||
and r10d, 2097136
|
||||
movdqa xmm3, xmm5
|
||||
dec ebp
|
||||
jne cnv2_main_loop_bulldozer
|
||||
|
||||
ldmxcsr DWORD PTR [rsp]
|
||||
movaps xmm6, XMMWORD PTR [rsp+48]
|
||||
lea r11, QWORD PTR [rsp+64]
|
||||
mov rbx, QWORD PTR [r11+56]
|
||||
mov rbp, QWORD PTR [r11+64]
|
||||
mov rsi, QWORD PTR [r11+72]
|
||||
movaps xmm8, XMMWORD PTR [r11-48]
|
||||
movaps xmm7, XMMWORD PTR [rsp+32]
|
||||
mov rsp, r11
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
pop r12
|
||||
pop rdi
|
||||
jmp cnv2_main_loop_bulldozer_endp
|
||||
|
||||
sqrt_fixup_bulldozer:
|
||||
movd r9, xmm5
|
||||
add r9, r15
|
||||
dec rdi
|
||||
mov edx, -1022
|
||||
shl rdx, 32
|
||||
mov rax, rdi
|
||||
shr rdi, 19
|
||||
shr rax, 20
|
||||
mov rcx, rdi
|
||||
sub rcx, rax
|
||||
lea rcx, [rcx+rdx+1]
|
||||
add rax, rdx
|
||||
imul rcx, rax
|
||||
sub rcx, r9
|
||||
adc rdi, 0
|
||||
jmp sqrt_fixup_bulldozer_ret
|
||||
|
||||
cnv2_main_loop_bulldozer_endp:
|
|
@ -50,7 +50,7 @@
|
|||
punpcklqdq xmm5, xmm0
|
||||
movdqu xmm6, XMMWORD PTR [r10+rbx]
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
main_loop_ivybridge:
|
||||
lea rdx, QWORD PTR [r10+rbx]
|
||||
mov ecx, r10d
|
|
@ -45,7 +45,7 @@
|
|||
movd xmm0, rcx
|
||||
punpcklqdq xmm4, xmm0
|
||||
|
||||
ALIGN 16
|
||||
ALIGN(64)
|
||||
main_loop_ryzen:
|
||||
movdqa xmm5, XMMWORD PTR [r10+rbx]
|
||||
movd xmm0, r11
|
43
src/crypto/asm/win64/cn_main_loop.S
Normal file
43
src/crypto/asm/win64/cn_main_loop.S
Normal file
|
@ -0,0 +1,43 @@
|
|||
#define ALIGN(x) .align 64
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
.global cnv2_mainloop_ivybridge_asm
|
||||
.global cnv2_mainloop_ryzen_asm
|
||||
.global cnv2_mainloop_bulldozer_asm
|
||||
.global cnv2_double_mainloop_sandybridge_asm
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_ivybridge_asm:
|
||||
#include "../cn2/cnv2_main_loop_ivybridge.inc"
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_ryzen_asm:
|
||||
#include "../cn2/cnv2_main_loop_ryzen.inc"
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_bulldozer_asm:
|
||||
#include "../cn2/cnv2_main_loop_bulldozer.inc"
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_double_mainloop_sandybridge_asm:
|
||||
#include "../cn2/cnv2_double_main_loop_sandybridge.inc"
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
|
@ -1,24 +1,47 @@
|
|||
_TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE
|
||||
PUBLIC cnv2_mainloop_ivybridge_asm
|
||||
PUBLIC cnv2_mainloop_ryzen_asm
|
||||
PUBLIC cnv2_mainloop_bulldozer_asm
|
||||
PUBLIC cnv2_double_mainloop_sandybridge_asm
|
||||
|
||||
ALIGN 64
|
||||
cnv2_mainloop_ivybridge_asm PROC
|
||||
INCLUDE cnv2_main_loop_ivybridge.inc
|
||||
INCLUDE cn2/cnv2_main_loop_ivybridge.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_mainloop_ivybridge_asm ENDP
|
||||
|
||||
ALIGN 64
|
||||
cnv2_mainloop_ryzen_asm PROC
|
||||
INCLUDE cnv2_main_loop_ryzen.inc
|
||||
INCLUDE cn2/cnv2_main_loop_ryzen.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_mainloop_ryzen_asm ENDP
|
||||
|
||||
ALIGN 64
|
||||
cnv2_double_mainloop_sandybridge_asm PROC
|
||||
INCLUDE cnv2_double_main_loop_sandybridge.inc
|
||||
cnv2_mainloop_bulldozer_asm PROC
|
||||
INCLUDE cn2/cnv2_main_loop_bulldozer.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_mainloop_bulldozer_asm ENDP
|
||||
|
||||
ALIGN 64
|
||||
cnv2_double_mainloop_sandybridge_asm PROC
|
||||
INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc
|
||||
ret 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
cnv2_double_mainloop_sandybridge_asm ENDP
|
||||
|
||||
_TEXT_CNV2_MAINLOOP ENDS
|
|
@ -1,21 +0,0 @@
|
|||
#define ALIGN .align
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
.global cnv2_mainloop_ivybridge_asm
|
||||
.global cnv2_mainloop_ryzen_asm
|
||||
.global cnv2_double_mainloop_sandybridge_asm
|
||||
|
||||
ALIGN 16
|
||||
cnv2_mainloop_ivybridge_asm:
|
||||
#include "../cnv2_main_loop_ivybridge.inc"
|
||||
ret 0
|
||||
|
||||
ALIGN 16
|
||||
cnv2_mainloop_ryzen_asm:
|
||||
#include "../cnv2_main_loop_ryzen.inc"
|
||||
ret 0
|
||||
|
||||
ALIGN 16
|
||||
cnv2_double_mainloop_sandybridge_asm:
|
||||
#include "../cnv2_double_main_loop_sandybridge.inc"
|
||||
ret 0
|
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __JOBRESULT_H__
|
||||
#define __JOBRESULT_H__
|
||||
#ifndef XMRIG_JOBRESULT_H
|
||||
#define XMRIG_JOBRESULT_H
|
||||
|
||||
|
||||
#include <memory.h>
|
||||
|
@ -36,17 +36,29 @@ class JobResult
|
|||
{
|
||||
public:
|
||||
inline JobResult() : poolId(0), diff(0), nonce(0) {}
|
||||
inline JobResult(int poolId, const xmrig::Id &jobId, uint32_t nonce, const uint8_t *result, uint32_t diff, const xmrig::Algorithm &algorithm) :
|
||||
inline JobResult(int poolId, const xmrig::Id &jobId, const xmrig::Id &clientId, uint32_t nonce, const uint8_t *result, uint32_t diff, const xmrig::Algorithm &algorithm) :
|
||||
poolId(poolId),
|
||||
diff(diff),
|
||||
nonce(nonce),
|
||||
algorithm(algorithm),
|
||||
clientId(clientId),
|
||||
jobId(jobId)
|
||||
{
|
||||
memcpy(this->result, result, sizeof(this->result));
|
||||
}
|
||||
|
||||
|
||||
inline JobResult(const Job &job) : poolId(0), diff(0), nonce(0)
|
||||
{
|
||||
jobId = job.id();
|
||||
clientId = job.clientId();
|
||||
poolId = job.poolId();
|
||||
diff = job.diff();
|
||||
nonce = *job.nonce();
|
||||
algorithm = job.algorithm();
|
||||
}
|
||||
|
||||
|
||||
inline uint64_t actualDiff() const
|
||||
{
|
||||
return Job::toDiff(reinterpret_cast<const uint64_t*>(result)[3]);
|
||||
|
@ -58,7 +70,8 @@ public:
|
|||
uint32_t nonce;
|
||||
uint8_t result[32];
|
||||
xmrig::Algorithm algorithm;
|
||||
xmrig::Id clientId;
|
||||
xmrig::Id jobId;
|
||||
};
|
||||
|
||||
#endif /* __JOBRESULT_H__ */
|
||||
#endif /* XMRIG_JOBRESULT_H */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -27,15 +27,15 @@
|
|||
#define APP_ID "xmrig"
|
||||
#define APP_NAME "XMRig"
|
||||
#define APP_DESC "XMRig CPU miner"
|
||||
#define APP_VERSION "2.8.3"
|
||||
#define APP_VERSION "2.8.5-dev"
|
||||
#define APP_DOMAIN "xmrig.com"
|
||||
#define APP_SITE "www.xmrig.com"
|
||||
#define APP_COPYRIGHT "Copyright (C) 2016-2018 xmrig.com"
|
||||
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
|
||||
#define APP_KIND "cpu"
|
||||
|
||||
#define APP_VER_MAJOR 2
|
||||
#define APP_VER_MINOR 8
|
||||
#define APP_VER_PATCH 3
|
||||
#define APP_VER_PATCH 5
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if (_MSC_VER >= 1910)
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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,6 +29,7 @@
|
|||
#include "common/log/Log.h"
|
||||
#include "common/net/Pool.h"
|
||||
#include "crypto/Asm.h"
|
||||
#include "Mem.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "workers/CpuThread.h"
|
||||
|
||||
|
@ -53,6 +55,73 @@ xmrig::CpuThread::CpuThread(size_t index, Algo algorithm, AlgoVariant av, Multiw
|
|||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_ASM
|
||||
template<typename T, typename U>
|
||||
static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t mask)
|
||||
{
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(src);
|
||||
|
||||
// Workaround for Visual Studio placing trampoline in debug builds.
|
||||
# if defined(_MSC_VER)
|
||||
if (p[0] == 0xE9) {
|
||||
p += *(int32_t*)(p + 1) + 5;
|
||||
}
|
||||
# endif
|
||||
|
||||
size_t size = 0;
|
||||
while (*(uint32_t*)(p + size) != 0x90909090) {
|
||||
++size;
|
||||
}
|
||||
|
||||
memcpy((void*) dst, (const void*) src, size);
|
||||
|
||||
uint8_t* patched_data = reinterpret_cast<uint8_t*>(dst);
|
||||
for (size_t i = 0; i + sizeof(uint32_t) <= size; ++i) {
|
||||
switch (*(uint32_t*)(patched_data + i)) {
|
||||
case xmrig::CRYPTONIGHT_ITER:
|
||||
*(uint32_t*)(patched_data + i) = iterations;
|
||||
break;
|
||||
|
||||
case xmrig::CRYPTONIGHT_MASK:
|
||||
*(uint32_t*)(patched_data + i) = mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx *ctx);
|
||||
extern "C" void cnv2_mainloop_ryzen_asm(cryptonight_ctx *ctx);
|
||||
extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx *ctx);
|
||||
extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx *ctx0, cryptonight_ctx *ctx1);
|
||||
|
||||
|
||||
xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm = nullptr;
|
||||
xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm = nullptr;
|
||||
xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm = nullptr;
|
||||
xmrig::CpuThread::cn_mainloop_double_fun cn_half_double_mainloop_sandybridge_asm = nullptr;
|
||||
|
||||
|
||||
void xmrig::CpuThread::patchAsmVariants()
|
||||
{
|
||||
const int allocation_size = 65536;
|
||||
uint8_t *base = static_cast<uint8_t *>(Mem::allocateExecutableMemory(allocation_size));
|
||||
|
||||
cn_half_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0000);
|
||||
cn_half_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x1000);
|
||||
cn_half_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x2000);
|
||||
cn_half_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_double_fun> (base + 0x3000);
|
||||
|
||||
patchCode(cn_half_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK);
|
||||
patchCode(cn_half_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK);
|
||||
patchCode(cn_half_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK);
|
||||
patchCode(cn_half_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK);
|
||||
|
||||
Mem::flushInstructionCache(base, allocation_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool xmrig::CpuThread::isSoftAES(AlgoVariant av)
|
||||
{
|
||||
return av == AV_SINGLE_SOFT || av == AV_DOUBLE_SOFT || av > AV_PENTA;
|
||||
|
@ -64,7 +133,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
|||
assert(variant >= VARIANT_0 && variant < VARIANT_MAX);
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
constexpr const size_t count = VARIANT_MAX * 10 * 3 + 3;
|
||||
constexpr const size_t count = VARIANT_MAX * 10 * 3 + 8;
|
||||
# else
|
||||
constexpr const size_t count = VARIANT_MAX * 10 * 3;
|
||||
# endif
|
||||
|
@ -151,6 +220,17 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
|||
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_2>,
|
||||
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_2>,
|
||||
|
||||
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_HALF>,
|
||||
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_HALF>,
|
||||
cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_HALF>,
|
||||
cryptonight_double_hash<CRYPTONIGHT, true, VARIANT_HALF>,
|
||||
cryptonight_triple_hash<CRYPTONIGHT, false, VARIANT_HALF>,
|
||||
cryptonight_quad_hash<CRYPTONIGHT, false, VARIANT_HALF>,
|
||||
cryptonight_penta_hash<CRYPTONIGHT, false, VARIANT_HALF>,
|
||||
cryptonight_triple_hash<CRYPTONIGHT, true, VARIANT_HALF>,
|
||||
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_HALF>,
|
||||
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_HALF>,
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
|
||||
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
|
||||
|
@ -181,6 +261,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
|||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL2
|
||||
# else
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
|
@ -191,6 +272,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
|||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
# endif
|
||||
|
||||
# ifndef XMRIG_NO_SUMO
|
||||
|
@ -235,6 +317,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
|||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL2
|
||||
# else
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
|
@ -245,11 +328,18 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
|||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
# endif
|
||||
# ifndef XMRIG_NO_ASM
|
||||
cryptonight_single_hash_asm<CRYPTONIGHT, VARIANT_2, ASM_INTEL>,
|
||||
cryptonight_single_hash_asm<CRYPTONIGHT, VARIANT_2, ASM_RYZEN>,
|
||||
cryptonight_double_hash_asm<CRYPTONIGHT, VARIANT_2, ASM_INTEL>
|
||||
cryptonight_single_hash_asm<CRYPTONIGHT, VARIANT_2, ASM_BULLDOZER>,
|
||||
cryptonight_double_hash_asm<CRYPTONIGHT, VARIANT_2, ASM_INTEL>,
|
||||
|
||||
cryptonight_single_hash_asm<CRYPTONIGHT, VARIANT_HALF, ASM_INTEL>,
|
||||
cryptonight_single_hash_asm<CRYPTONIGHT, VARIANT_HALF, ASM_RYZEN>,
|
||||
cryptonight_single_hash_asm<CRYPTONIGHT, VARIANT_HALF, ASM_BULLDOZER>,
|
||||
cryptonight_double_hash_asm<CRYPTONIGHT, VARIANT_HALF, ASM_INTEL>
|
||||
# endif
|
||||
};
|
||||
|
||||
|
@ -440,14 +530,19 @@ size_t xmrig::CpuThread::fnIndex(Algo algorithm, AlgoVariant av, Variant variant
|
|||
}
|
||||
|
||||
constexpr const size_t offset = VARIANT_MAX * 10 * 3;
|
||||
size_t extra_offset = 0;
|
||||
|
||||
if (algorithm == CRYPTONIGHT && (variant == VARIANT_2 || variant == VARIANT_HALF)) {
|
||||
if (variant == VARIANT_HALF) {
|
||||
extra_offset += 4;
|
||||
}
|
||||
|
||||
if (algorithm == CRYPTONIGHT && variant == VARIANT_2) {
|
||||
if (av == AV_SINGLE) {
|
||||
return offset + assembly - 2;
|
||||
return offset + extra_offset + assembly - 2;
|
||||
}
|
||||
|
||||
if (av == AV_DOUBLE) {
|
||||
return offset + 2;
|
||||
return offset + 3 + extra_offset;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -60,6 +61,12 @@ public:
|
|||
CpuThread(size_t index, Algo algorithm, AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch, Assembly assembly);
|
||||
|
||||
typedef void (*cn_hash_fun)(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx **ctx);
|
||||
typedef void (*cn_mainloop_fun)(cryptonight_ctx *ctx);
|
||||
typedef void (*cn_mainloop_double_fun)(cryptonight_ctx *ctx1, cryptonight_ctx *ctx2);
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
static void patchAsmVariants();
|
||||
# endif
|
||||
|
||||
static bool isSoftAES(AlgoVariant av);
|
||||
static cn_hash_fun fn(Algo algorithm, AlgoVariant av, Variant variant, Assembly assembly);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -54,13 +54,14 @@ bool MultiWorker<N>::selfTest()
|
|||
using namespace xmrig;
|
||||
|
||||
if (m_thread->algorithm() == CRYPTONIGHT) {
|
||||
return verify(VARIANT_0, test_output_v0) &&
|
||||
verify(VARIANT_1, test_output_v1) &&
|
||||
verify(VARIANT_2, test_output_v2) &&
|
||||
verify(VARIANT_XTL, test_output_xtl) &&
|
||||
verify(VARIANT_MSR, test_output_msr) &&
|
||||
verify(VARIANT_XAO, test_output_xao) &&
|
||||
verify(VARIANT_RTO, test_output_rto);
|
||||
return verify(VARIANT_0, test_output_v0) &&
|
||||
verify(VARIANT_1, test_output_v1) &&
|
||||
verify(VARIANT_2, test_output_v2) &&
|
||||
verify(VARIANT_XTL, test_output_xtl) &&
|
||||
verify(VARIANT_MSR, test_output_msr) &&
|
||||
verify(VARIANT_XAO, test_output_xao) &&
|
||||
verify(VARIANT_RTO, test_output_rto) &&
|
||||
verify(VARIANT_HALF, test_output_half);
|
||||
}
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
|
@ -108,7 +109,7 @@ void MultiWorker<N>::start()
|
|||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
if (*reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24) < m_state.job.target()) {
|
||||
Workers::submit(JobResult(m_state.job.poolId(), m_state.job.id(), *nonce(i), m_hash + (i * 32), m_state.job.diff(), m_state.job.algorithm()));
|
||||
Workers::submit(JobResult(m_state.job.poolId(), m_state.job.id(), m_state.job.clientId(), *nonce(i), m_hash + (i * 32), m_state.job.diff(), m_state.job.algorithm()));
|
||||
}
|
||||
|
||||
*nonce(i) += 1;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 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
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -168,6 +169,10 @@ void Workers::start(xmrig::Controller *controller)
|
|||
LOG_NOTICE("--------------------------------------------------------------------------");
|
||||
# endif
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
xmrig::CpuThread::patchAsmVariants();
|
||||
# endif
|
||||
|
||||
m_controller = controller;
|
||||
|
||||
const std::vector<xmrig::IThread *> &threads = controller->config()->threads();
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 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
|
||||
|
@ -21,8 +22,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __WORKERS_H__
|
||||
#define __WORKERS_H__
|
||||
#ifndef XMRIG_WORKERS_H
|
||||
#define XMRIG_WORKERS_H
|
||||
|
||||
|
||||
#include <atomic>
|
||||
|
@ -118,4 +119,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif /* __WORKERS_H__ */
|
||||
#endif /* XMRIG_WORKERS_H */
|
||||
|
|
Loading…
Reference in a new issue