From 9c87d134aeb4c682e6b160ec16a8addc0ee569d6 Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Thu, 5 Jan 2017 01:11:49 -0500 Subject: [PATCH 1/4] checks the cpuid to see if AES-NI instructions are supported --- minethd.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/minethd.cpp b/minethd.cpp index 7399d6f..bc82a8d 100644 --- a/minethd.cpp +++ b/minethd.cpp @@ -21,7 +21,7 @@ #ifdef _WIN32 #include - +#include void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) { SetThreadAffinityMask(h, 1 << cpu_id); @@ -29,7 +29,7 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) #else #include - +#include void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) { cpu_set_t mn; @@ -172,8 +172,26 @@ cryptonight_ctx* minethd_alloc_ctx() return nullptr; //Should never happen } +static bool check_for_aesni() +{ + constexpr int AESNI_BIT = 1 << 25; + int cpu_info[4]; +#ifdef _WIN32 + __cpuid(cpu_info, 1); +#else + __cpuid(1, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]); +#endif + return (cpu_info[2] & AESNI_BIT) != 0; +} + bool minethd::self_test() { + if (!check_for_aesni()) + { + printer::inst()->print_msg(L0, "Your CPU does not support the AES-NI instruction set"); + return false; + } + alloc_msg msg = { 0 }; size_t res; bool fatal = false; From 273f0b8dd8e73c208f58f0035182c2eff0b708fc Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Thu, 5 Jan 2017 01:39:29 -0500 Subject: [PATCH 2/4] use tabs instead of spaces --- minethd.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/minethd.cpp b/minethd.cpp index bc82a8d..2b0e665 100644 --- a/minethd.cpp +++ b/minethd.cpp @@ -1,4 +1,4 @@ -/* +aub/* * 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 @@ -174,23 +174,23 @@ cryptonight_ctx* minethd_alloc_ctx() static bool check_for_aesni() { - constexpr int AESNI_BIT = 1 << 25; - int cpu_info[4]; + constexpr int AESNI_BIT = 1 << 25; + int cpu_info[4]; #ifdef _WIN32 - __cpuid(cpu_info, 1); + __cpuid(cpu_info, 1); #else - __cpuid(1, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]); + __cpuid(1, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]); #endif - return (cpu_info[2] & AESNI_BIT) != 0; + return (cpu_info[2] & AESNI_BIT) != 0; } bool minethd::self_test() { - if (!check_for_aesni()) - { - printer::inst()->print_msg(L0, "Your CPU does not support the AES-NI instruction set"); - return false; - } + if (!check_for_aesni()) + { + printer::inst()->print_msg(L0, "Your CPU does not support the AES-NI instruction set"); + return false; + } alloc_msg msg = { 0 }; size_t res; @@ -330,8 +330,8 @@ void minethd::work_main() if (oWork.bStall) { /* We are stalled here because the executor didn't find a job for us yet, - either because of network latency, or a socket problem. Since we are - raison d'etre of this software it us sensible to just wait until we have something*/ + either because of network latency, or a socket problem. Since we are + raison d'etre of this software it us sensible to just wait until we have something*/ while (iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); From f9b9c0c09d7c727ef4ce57e85d8f256daff75f0c Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Thu, 5 Jan 2017 01:40:43 -0500 Subject: [PATCH 3/4] whoops editor caught some keystrokes --- minethd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minethd.cpp b/minethd.cpp index 2b0e665..b63035d 100644 --- a/minethd.cpp +++ b/minethd.cpp @@ -1,4 +1,4 @@ -aub/* +/* * 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 From 51c4956110171c43fd77a997c20dc2bc52aad6e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Thu, 5 Jan 2017 01:48:28 -0500 Subject: [PATCH 4/4] more whitespace fuss --- minethd.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/minethd.cpp b/minethd.cpp index b63035d..e636d4b 100644 --- a/minethd.cpp +++ b/minethd.cpp @@ -22,6 +22,7 @@ #ifdef _WIN32 #include #include + void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) { SetThreadAffinityMask(h, 1 << cpu_id); @@ -30,6 +31,7 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) #else #include #include + void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) { cpu_set_t mn; @@ -330,8 +332,8 @@ void minethd::work_main() if (oWork.bStall) { /* We are stalled here because the executor didn't find a job for us yet, - either because of network latency, or a socket problem. Since we are - raison d'etre of this software it us sensible to just wait until we have something*/ + either because of network latency, or a socket problem. Since we are + raison d'etre of this software it us sensible to just wait until we have something*/ while (iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100));