Merge branch 'master' of https://github.com/xmrig/xmrig into xmrig-master
This commit is contained in:
parent
4276afc4f4
commit
96be9bee18
12 changed files with 116 additions and 60 deletions
|
@ -195,6 +195,7 @@ if (WITH_HTTPD)
|
|||
message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_HTTPD=OFF` to build without http deamon support")
|
||||
endif()
|
||||
else()
|
||||
set(MHD_LIBRARY "")
|
||||
add_definitions(/DXMRIG_NO_HTTPD)
|
||||
add_definitions(/DXMRIG_NO_API)
|
||||
endif()
|
||||
|
|
33
src/App.cpp
33
src/App.cpp
|
@ -118,7 +118,7 @@ int App::exec()
|
|||
{
|
||||
if(!m_options)
|
||||
{
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
uv_signal_start(&m_sigHUP, App::onSignal, SIGHUP);
|
||||
|
@ -129,13 +129,20 @@ int App::exec()
|
|||
|
||||
if(!CryptoNight::init(m_options->algo(), m_options->algoVariant()))
|
||||
{
|
||||
LOG_ERR("\"" << m_options->algoName() << "\" hash self-test failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages());
|
||||
Summary::print();
|
||||
|
||||
if(m_options->dryRun())
|
||||
{
|
||||
LOG_NOTICE("OK");
|
||||
release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifndef XMRIG_NO_API
|
||||
Api::start();
|
||||
# endif
|
||||
|
@ -152,12 +159,7 @@ int App::exec()
|
|||
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
uv_loop_close(uv_default_loop());
|
||||
|
||||
delete m_network;
|
||||
|
||||
Options::release();
|
||||
Mem::release();
|
||||
Platform::release();
|
||||
|
||||
release();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -184,7 +186,7 @@ void App::onConsoleCommand(char command)
|
|||
case 'R':
|
||||
if(!Workers::isEnabled())
|
||||
{
|
||||
LOG_INFO("resumed");
|
||||
LOG_INFO((m_options->colors() ? "\x1B[01;32mresumed" : "resumed"));
|
||||
Workers::setEnabled(true);
|
||||
}
|
||||
break;
|
||||
|
@ -209,6 +211,19 @@ void App::close()
|
|||
}
|
||||
|
||||
|
||||
void App::release()
|
||||
{
|
||||
if(m_network)
|
||||
{
|
||||
delete m_network;
|
||||
}
|
||||
|
||||
Options::release();
|
||||
Mem::release();
|
||||
Platform::release();
|
||||
}
|
||||
|
||||
|
||||
void App::onSignal(uv_signal_t* handle, int signum)
|
||||
{
|
||||
switch(signum)
|
||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
|||
private:
|
||||
void background();
|
||||
void close();
|
||||
void release();
|
||||
|
||||
static void onSignal(uv_signal_t* handle, int signum);
|
||||
|
||||
|
|
|
@ -109,6 +109,14 @@ void Cpu::initCommon()
|
|||
m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets;
|
||||
m_l2_exclusive = true;
|
||||
}
|
||||
// Workaround for Intel Core Solo, Core Duo, Core 2 Duo, Core 2 Quad and their Xeon homologue
|
||||
// These processors have L2 cache shared by 2 cores.
|
||||
else if(data.vendor == VENDOR_INTEL && data.family == 0x06 && (data.model == 0x0E || data.model == 0x0F ||
|
||||
data.model == 0x07))
|
||||
{
|
||||
int l2_count_per_socket = m_totalCores > 1 ? m_totalCores / 2 : 1;
|
||||
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * l2_count_per_socket * m_sockets : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0;
|
||||
|
|
|
@ -102,12 +102,16 @@ static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S";
|
|||
static struct option const options[] =
|
||||
{
|
||||
{ "algo", 1, nullptr, 'a' },
|
||||
{ "api-access-token", 1, nullptr, 4001 },
|
||||
{ "api-port", 1, nullptr, 4000 },
|
||||
{ "api-worker-id", 1, nullptr, 4002 },
|
||||
{ "av", 1, nullptr, 'v' },
|
||||
{ "background", 0, nullptr, 'B' },
|
||||
{ "config", 1, nullptr, 'c' },
|
||||
{ "cpu-affinity", 1, nullptr, 1020 },
|
||||
{ "cpu-priority", 1, nullptr, 1021 },
|
||||
{ "donate-level", 1, nullptr, 1003 },
|
||||
{ "dry-run", 0, nullptr, 5000 },
|
||||
{ "help", 0, nullptr, 'h' },
|
||||
{ "keepalive", 0, nullptr , 'k' },
|
||||
{ "log-file", 1, nullptr, 'l' },
|
||||
|
@ -127,9 +131,6 @@ static struct option const options[] =
|
|||
{ "user-agent", 1, nullptr, 1008 },
|
||||
{ "userpass", 1, nullptr, 'O' },
|
||||
{ "version", 0, nullptr, 'V' },
|
||||
{ "api-port", 1, nullptr, 4000 },
|
||||
{ "api-access-token", 1, nullptr, 4001 },
|
||||
{ "api-worker-id", 1, nullptr, 4002 },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -143,6 +144,7 @@ static struct option const config_options[] =
|
|||
{ "cpu-affinity", 1, nullptr, 1020 },
|
||||
{ "cpu-priority", 1, nullptr, 1021 },
|
||||
{ "donate-level", 1, nullptr, 1003 },
|
||||
{ "dry-run", 0, nullptr, 5000 },
|
||||
{ "huge-pages", 0, nullptr, 1009 },
|
||||
{ "log-file", 1, nullptr, 'l' },
|
||||
{ "max-cpu-usage", 1, nullptr, 1004 },
|
||||
|
@ -211,6 +213,7 @@ Options::Options(int argc, char** argv) :
|
|||
m_background(false),
|
||||
m_colors(true),
|
||||
m_doubleHash(false),
|
||||
m_dryRun(false),
|
||||
m_hugePages(true),
|
||||
m_ready(false),
|
||||
m_safe(false),
|
||||
|
@ -593,6 +596,10 @@ bool Options::parseBoolean(int key, bool enable)
|
|||
m_colors = enable;
|
||||
break;
|
||||
|
||||
case 5000: /* --dry-run */
|
||||
m_dryRun = enable;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,10 @@ public:
|
|||
{
|
||||
return m_doubleHash;
|
||||
}
|
||||
inline bool dryRun() const
|
||||
{
|
||||
return m_dryRun;
|
||||
}
|
||||
inline bool hugePages() const
|
||||
{
|
||||
return m_hugePages;
|
||||
|
@ -184,6 +188,7 @@ private:
|
|||
bool m_background;
|
||||
bool m_colors;
|
||||
bool m_doubleHash;
|
||||
bool m_dryRun;
|
||||
bool m_hugePages;
|
||||
bool m_ready;
|
||||
bool m_safe;
|
||||
|
|
|
@ -48,7 +48,7 @@ NetworkState::NetworkState() :
|
|||
|
||||
int NetworkState::connectionTime() const
|
||||
{
|
||||
return m_active ? ((uv_now(uv_default_loop()) - m_connectionTime) / 1000) : 0;
|
||||
return m_active ? (int)((uv_now(uv_default_loop()) - m_connectionTime) / 1000) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ uint32_t NetworkState::avgTime() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (uint32_t) connectionTime() / m_latency.size();
|
||||
return connectionTime() / (uint32_t)m_latency.size();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -202,14 +202,14 @@ static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2,
|
|||
{
|
||||
if(SOFT_AES)
|
||||
{
|
||||
*x0 = soft_aesenc(*x0, key);
|
||||
*x1 = soft_aesenc(*x1, key);
|
||||
*x2 = soft_aesenc(*x2, key);
|
||||
*x3 = soft_aesenc(*x3, key);
|
||||
*x4 = soft_aesenc(*x4, key);
|
||||
*x5 = soft_aesenc(*x5, key);
|
||||
*x6 = soft_aesenc(*x6, key);
|
||||
*x7 = soft_aesenc(*x7, key);
|
||||
*x0 = soft_aesenc((uint32_t*)x0, key);
|
||||
*x1 = soft_aesenc((uint32_t*)x1, key);
|
||||
*x2 = soft_aesenc((uint32_t*)x2, key);
|
||||
*x3 = soft_aesenc((uint32_t*)x3, key);
|
||||
*x4 = soft_aesenc((uint32_t*)x4, key);
|
||||
*x5 = soft_aesenc((uint32_t*)x5, key);
|
||||
*x6 = soft_aesenc((uint32_t*)x6, key);
|
||||
*x7 = soft_aesenc((uint32_t*)x7, key);
|
||||
}
|
||||
# ifndef XMRIG_ARMv7
|
||||
else
|
||||
|
@ -379,14 +379,15 @@ inline void cryptonight_hash(const void* __restrict__ input, size_t size, void*
|
|||
|
||||
for(size_t i = 0; i < ITERATIONS; i++)
|
||||
{
|
||||
__m128i cx = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
__m128i cx;
|
||||
|
||||
if(SOFT_AES)
|
||||
{
|
||||
cx = soft_aesenc(cx, _mm_set_epi64x(ah0, al0));
|
||||
cx = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
# ifndef XMRIG_ARMv7
|
||||
cx = vreinterpretq_m128i_u8(vaesmcq_u8(vaeseq_u8(cx, vdupq_n_u8(0)))) ^ _mm_set_epi64x(ah0, al0);
|
||||
# endif
|
||||
|
@ -447,16 +448,17 @@ inline void cryptonight_double_hash(const void* __restrict__ input, size_t size,
|
|||
|
||||
for(size_t i = 0; i < ITERATIONS; i++)
|
||||
{
|
||||
__m128i cx0 = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
__m128i cx1 = _mm_load_si128((__m128i*) &l1[idx1 & MASK]);
|
||||
__m128i cx0, cx1;
|
||||
|
||||
if(SOFT_AES)
|
||||
{
|
||||
cx0 = soft_aesenc(cx0, _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc(cx1, _mm_set_epi64x(ah1, al1));
|
||||
cx0 = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc((uint32_t*)&l1[idx1 & MASK], _mm_set_epi64x(ah1, al1));
|
||||
}
|
||||
else
|
||||
{
|
||||
cx0 = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
cx1 = _mm_load_si128((__m128i*) &l1[idx1 & MASK]);
|
||||
# ifndef XMRIG_ARMv7
|
||||
cx0 = vreinterpretq_m128i_u8(vaesmcq_u8(vaeseq_u8(cx0, vdupq_n_u8(0)))) ^ _mm_set_epi64x(ah0, al0);
|
||||
cx1 = vreinterpretq_m128i_u8(vaesmcq_u8(vaeseq_u8(cx1, vdupq_n_u8(0)))) ^ _mm_set_epi64x(ah1, al1);
|
||||
|
|
|
@ -201,14 +201,14 @@ static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2,
|
|||
{
|
||||
if(SOFT_AES)
|
||||
{
|
||||
*x0 = soft_aesenc(*x0, key);
|
||||
*x1 = soft_aesenc(*x1, key);
|
||||
*x2 = soft_aesenc(*x2, key);
|
||||
*x3 = soft_aesenc(*x3, key);
|
||||
*x4 = soft_aesenc(*x4, key);
|
||||
*x5 = soft_aesenc(*x5, key);
|
||||
*x6 = soft_aesenc(*x6, key);
|
||||
*x7 = soft_aesenc(*x7, key);
|
||||
*x0 = soft_aesenc((uint32_t*)x0, key);
|
||||
*x1 = soft_aesenc((uint32_t*)x1, key);
|
||||
*x2 = soft_aesenc((uint32_t*)x2, key);
|
||||
*x3 = soft_aesenc((uint32_t*)x3, key);
|
||||
*x4 = soft_aesenc((uint32_t*)x4, key);
|
||||
*x5 = soft_aesenc((uint32_t*)x5, key);
|
||||
*x6 = soft_aesenc((uint32_t*)x6, key);
|
||||
*x7 = soft_aesenc((uint32_t*)x7, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -337,17 +337,16 @@ inline void cryptonight_hash(const void* __restrict__ input, size_t size, void*
|
|||
for(size_t i = 0; i < ITERATIONS; i++)
|
||||
{
|
||||
__m128i cx;
|
||||
cx = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
|
||||
if(SOFT_AES)
|
||||
{
|
||||
cx = soft_aesenc(cx, _mm_set_epi64x(ah0, al0));
|
||||
cx = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
cx = _mm_aesenc_si128(cx, _mm_set_epi64x(ah0, al0));
|
||||
}
|
||||
|
||||
_mm_store_si128((__m128i*) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx));
|
||||
idx0 = EXTRACT64(cx);
|
||||
bx0 = cx;
|
||||
|
@ -403,16 +402,17 @@ inline void cryptonight_double_hash(const void* __restrict__ input, size_t size,
|
|||
|
||||
for(size_t i = 0; i < ITERATIONS; i++)
|
||||
{
|
||||
__m128i cx0 = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
__m128i cx1 = _mm_load_si128((__m128i*) &l1[idx1 & MASK]);
|
||||
__m128i cx0, cx1;
|
||||
|
||||
if(SOFT_AES)
|
||||
{
|
||||
cx0 = soft_aesenc(cx0, _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc(cx1, _mm_set_epi64x(ah1, al1));
|
||||
cx0 = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc((uint32_t*)&l1[idx1 & MASK], _mm_set_epi64x(ah1, al1));
|
||||
}
|
||||
else
|
||||
{
|
||||
cx0 = _mm_load_si128((__m128i*) &l0[idx0 & MASK]);
|
||||
cx1 = _mm_load_si128((__m128i*) &l1[idx1 & MASK]);
|
||||
cx0 = _mm_aesenc_si128(cx0, _mm_set_epi64x(ah0, al0));
|
||||
cx1 = _mm_aesenc_si128(cx1, _mm_set_epi64x(ah1, al1));
|
||||
}
|
||||
|
|
|
@ -89,19 +89,12 @@
|
|||
const uint32_t saes_table[4][256] = { saes_data(saes_u0), saes_data(saes_u1), saes_data(saes_u2), saes_data(saes_u3) };
|
||||
const uint8_t saes_sbox[256] = saes_data(saes_h0);
|
||||
|
||||
static inline __m128i soft_aesenc(__m128i in, __m128i key)
|
||||
static inline __m128i soft_aesenc(const uint32_t* in, __m128i key)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
const uint32_t x0 = in.m128i_u32[0];
|
||||
const uint32_t x1 = in.m128i_u32[1];
|
||||
const uint32_t x2 = in.m128i_u32[2];
|
||||
const uint32_t x3 = in.m128i_u32[3];
|
||||
#else
|
||||
const uint32_t x0 = _mm_cvtsi128_si32(in);
|
||||
const uint32_t x1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55));
|
||||
const uint32_t x2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA));
|
||||
const uint32_t x3 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF));
|
||||
#endif
|
||||
const uint32_t x0 = in[0];
|
||||
const uint32_t x1 = in[1];
|
||||
const uint32_t x2 = in[2];
|
||||
const uint32_t x3 = in[3];
|
||||
|
||||
__m128i out = _mm_set_epi32(
|
||||
(saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^
|
||||
|
|
|
@ -647,7 +647,7 @@ void Client::onAllocBuffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t*
|
|||
auto client = getClient(handle->data);
|
||||
|
||||
buf->base = &client->m_recvBuf.base[client->m_recvBufPos];
|
||||
buf->len = client->m_recvBuf.len - client->m_recvBufPos;
|
||||
buf->len = client->m_recvBuf.len - (unsigned long)client->m_recvBufPos;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -156,15 +156,39 @@ void Network::onResultAccepted(Client* client, const SubmitResult & result, cons
|
|||
m_state.add(result, error);
|
||||
|
||||
if(0 < error.size())
|
||||
{
|
||||
if(m_options->colors())
|
||||
{
|
||||
/*
|
||||
LOG_INFO("\x1B[01;31mrejected\x1B[0m (%" PRId64 "/%" PRId64
|
||||
") diff \x1B[01;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%" PRIu64 " ms)",
|
||||
m_state.accepted, m_state.rejected, result.diff, error, result.elapsed);
|
||||
*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO("rejected (" << m_state.accepted << "/" << m_state.rejected << ") diff " << result.diff << " \"" <<
|
||||
error << "\" (" << result.elapsed << " ms)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_options->colors())
|
||||
{
|
||||
/*
|
||||
LOG_INFO("\x1B[01;32maccepted\x1B[0m (%" PRId64 "/%" PRId64
|
||||
") diff \x1B[01;37m%u\x1B[0m \x1B[01;30m(%" PRIu64 " ms)",
|
||||
m_state.accepted, m_state.rejected, result.diff, result.elapsed);
|
||||
*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO("accepted (" << m_state.accepted << "/" << m_state.rejected << ") diff " << result.diff << " (" <<
|
||||
result.elapsed << " ms)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue