Skip to content

Commit

Permalink
Version 1.5.3 - MacOS support and binaries, Reduced duplicate shares …
Browse files Browse the repository at this point in the history
…to zero, Cpu throttling option and remote api fixes

* Added MacOS support and binaries. (Tested on High Sierra and El Capitan)
* Added internal cpu throttling option to slow down mining.
* Fixed: Duplicate shares when pool mining.
* Fixed: EthMan API : sent config.txt was ignored when restarting miner on Linux.
  • Loading branch information
polyminer1 committed Jul 8, 2019
1 parent cbd0290 commit da6a2da
Show file tree
Hide file tree
Showing 48 changed files with 1,400 additions and 585 deletions.
2 changes: 1 addition & 1 deletion BuildInfo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define RH_PROJECT_NAME "rhminer"
#define RH_PROJECT_VERSION "1.5.2"
#define RH_PROJECT_VERSION "1.5.3"


6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# rhminer update and bugfix history

Version 1.5.3 - 8 Jul 2019
* Added MacOS support and binaries. (Tested on High Sierra and El Capitan)
* Added internal cpu throttling option to slow down mining.
* Fixed: No more dulicate shares
* Fixed: EthMan API : sent config.txt was ignored when restarting miner on Linux.

Version 1.5.2 - 16 May 2019
* Fixed Xml parsing of config file. Some options where skipped.

Expand Down
2 changes: 1 addition & 1 deletion MinersLib/CPUMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct CPUKernelData
RH_ALIGN(64) U64 m_requestPause;
RH_ALIGN(64) U8 m_workID[64];
RH_ALIGN(64) U64 m_nonce2;
RH_ALIGN(64) U64 m_startNonce;
RH_ALIGN(64) U64 m_rndVal;
RH_ALIGN(64) U64 m_headerSize;
RH_ALIGN(64) U8 m_work1[256]; //return state for RandomHash
RH_ALIGN(64) U8 m_work2[256];
Expand Down
4 changes: 2 additions & 2 deletions MinersLib/Farm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ WorkingProgress const& Farm::miningProgress(bool reset)
Guard l2(m_minerWorkMutex);
if (!m_lastProgressTime)
m_lastProgressTime = TimeGetMilliSec();
U32 dt = TimeGetMilliSec() - m_lastProgressTime;
U32 dt = (U32)(TimeGetMilliSec() - m_lastProgressTime);
if (dt < 100)
dt = 100;
m_lastProgressTime = TimeGetMilliSec();
Expand Down Expand Up @@ -261,7 +261,7 @@ WorkingProgress const& Farm::miningProgress(bool reset)
{
auto rate = p.minersHasheRate[i];
if (rate > m_farmData.m_minersHasheRatePeak[i])
m_farmData.m_minersHasheRatePeak[i] = rate;
m_farmData.m_minersHasheRatePeak[i] = (float)rate;
}
m_farmData.m_progress = p;
m_farmData.m_progress.minersHasheRatePeak = m_farmData.m_minersHasheRatePeak;
Expand Down
12 changes: 10 additions & 2 deletions MinersLib/GenericCLMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void GenericCLMiner::EvalKernelResult()
for (U32 i = 0; i < count; i++)
nonces.push_back((U64)m_results[i + 1]);

SolutionSptr solPtr = MakeSubmitSolution(nonces, false);
SolutionSptr solPtr = MakeSubmitSolution(nonces, m_currentWp->m_nonce2, false);

m_farm.submitProof(solPtr);
}
Expand All @@ -339,13 +339,21 @@ KernelCodeAndFuctions GenericCLMiner::GetKernelsCodeAndFunctions()
};


SolutionSptr GenericCLMiner::MakeSubmitSolution(const std::vector<U64>& nonces, bool isFromCpuMiner)
SolutionSptr GenericCLMiner::MakeSubmitSolution(const std::vector<U64>& nonces, U64 nonce2, bool isFromCpuMiner)
{
PascalSolution* sol = new PascalSolution();
sol->m_results = nonces;
sol->m_gpuIndex = m_globalIndex;
sol->m_work = PascalWorkSptr(m_currentWp->Clone());
sol->m_isFromCpuMiner = isFromCpuMiner;

#ifdef RH_RANDOMIZE_NONCE2
if (!sol->m_work->m_isSolo)
{
sol->m_work->m_nonce2 = (U32)nonce2;
sol->m_work->m_nonce2_64 = PascalWorkPackage::ComputeNonce2((U32)nonce2);
}
#endif

return SolutionSptr(sol);
}
2 changes: 1 addition & 1 deletion MinersLib/GenericCLMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GenericCLMiner: public CLMinerBase
virtual void QueueKernel();
virtual PrepareWorkStatus PrepareWork(const PascalWorkSptr& workTempl, bool reuseCurrentWP = false);
virtual void EvalKernelResult();
virtual SolutionSptr MakeSubmitSolution(const std::vector<U64>& nonces, bool isFromCpuMiner);
virtual SolutionSptr MakeSubmitSolution(const std::vector<U64>& nonces, U64 nonce2, bool isFromCpuMiner);
virtual void SetSearchKernelCurrentTarget(U32 paramIndex, cl::Kernel& searchKernel);
virtual void ClearKernelOutputBuffer();
virtual KernelCodeAndFuctions GetKernelsCodeAndFunctions();
Expand Down
2 changes: 1 addition & 1 deletion MinersLib/GenericMinerClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void GenericMinerClient::doStratum()
}
CpuSleep(1000);

if (GlobalMiningPreset::I().RestartRequested() == GlobalMiningPreset::eInteralRestart && m_farm.isMining())
if (GlobalMiningPreset::I().RestartRequested() == GlobalMiningPreset::eInteralRestart /*&& m_farm.isMining()*/)
{
PrintOutCritical("Restarging rhminer...\n");
//once every 1 sec
Expand Down
48 changes: 28 additions & 20 deletions MinersLib/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
#include "MinersLib/Pascal/RandomHashCLMiner.h"
#include "MinersLib/Pascal/RandomHashCPUMiner.h"

#ifndef _WIN32_WINNT
#include <unistd.h>
#include <spawn.h>
#include <linux/limits.h>
#define __getcwd getcwd
#else
#include <direct.h>
#define __getcwd _getcwd
#endif

#ifndef RH_COMPILE_CPU_ONLY
#include "MinersLib/Pascal/RandomHashHostCudaMiner.h"
#endif
Expand Down Expand Up @@ -115,6 +105,7 @@ GlobalMiningPreset::GlobalMiningPreset()
}
});
#endif //RH_COMPILE_CPU_ONLY

CmdLineManager::GlobalOptions().RegisterValue("devfee", "General", "Set devfee raward percentage. To disable devfee, simply put 0 here. But, before disabling developer fees, consider that it takes time and energy to maintain, develop and optimize this software. Your help is very appreciated.", [&](const string& val)
{
if (val == "0" || val == "0.0")
Expand Down Expand Up @@ -421,7 +412,10 @@ void GlobalMiningPreset::SetRestart(ERestartMode val)
_splitpath(exeFN, dir, f, fn, ex);
strncat(dir, f, sizeof(dir));

string cmd = " -restarted ";
string cmd;
if (GlobalMiningPreset::I().GetPendingConfigFile().length())
cmd += " -restarted ";

cmd += CmdLineManager::GlobalOptions().GetArgsList();
PrintOutSilent("Restarting to %s\n", cmd.c_str());

Expand All @@ -437,7 +431,6 @@ void GlobalMiningPreset::SetRestart(ERestartMode val)
}
else
{
printf("Restarting rhminer\n");
exit(0);
}
}
Expand All @@ -464,11 +457,26 @@ void GlobalMiningPreset::SetRestart(ERestartMode val)
agvI++;
agvI2++;
}

if (GlobalMiningPreset::I().GetPendingConfigFile().length())
{
const char* restart = "-restarted";
*agvI2 = (char*)malloc(strlen(restart) + 1);
strcpy(*agvI2, restart);
agvI2++;
}
*agvI2 = 0;

char *envp[] = { NULL };
execve(exec_path_name, argv2, envp);
exit(-1);
pid_t pid;
pid = fork();
if (pid == 0)
{
char *envp[] = { NULL };
int err = execve(exec_path_name, argv2, envp);
if (err != 0)
printf("exec error %d\n", errno);
}
exit(0);
#endif
}
}
Expand All @@ -483,11 +491,11 @@ void GlobalMiningPreset::RequestReboot()
__getcwd(basePath, sizeof(basePath));

#ifdef _WIN32_WINNT
strncat(basePath, "\\", sizeof(basePath));
strncat(basePath, "reboot.bat", sizeof(basePath));
strncat(basePath, "\\", sizeof(basePath)-1);
strncat(basePath, "reboot.bat", sizeof(basePath) - 1);
#else
strncat(basePath, "/", sizeof(basePath));
strncat(basePath, "reboot.sh", sizeof(basePath));
strncat(basePath, "/", sizeof(basePath) - 1);
strncat(basePath, "reboot.sh", sizeof(basePath) - 1);
#endif
if (GetFileSize(basePath) == U64_Max)
PrintOut("Launch Error. file. %s does not exists\n", basePath);
Expand Down Expand Up @@ -523,7 +531,7 @@ void GlobalMiningPreset::DoPerformanceTest()
PrintOut("CPU: %s\n", GpuManager::CpuInfos.cpuBrandName.c_str());
PrintOut("Testing raw cpu performance for %d sec on %d threads\n", g_testPerformance, ThreadCount);

U64 timeout[] = { 10 * 1000, g_testPerformance * 1000 };
U64 timeout[] = { 10 * 1000, (U64)g_testPerformance * 1000 };
std::vector<U64> hashes;
hashes.resize(ThreadCount);

Expand Down
61 changes: 53 additions & 8 deletions MinersLib/GpuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "precomp.h"
#include "MinersLib/GpuManager.h"
#include "MinersLib/Global.h"
#include "MinersLib/Global.h"
#include "BuildInfo.h"

#ifndef RH_COMPILE_CPU_ONLY
Expand All @@ -36,7 +35,12 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <sys/sysinfo.h>
#if defined(MACOS_X) || (defined(__APPLE__) & defined(__MACH__))
#include <sys/syslimits.h>
#include <sys/sysctl.h>
#else
#include <linux/limits.h>
#endif
#endif

#define RHMINER_MAKE_ARCH_NAME(devname, gpuToken, archname, var) if (stristr(devname.c_str(), gpuToken)) {var = string(gpuToken) + "_" + archname;}
Expand All @@ -45,6 +49,8 @@ std::vector<GpuManager::GPUInfos> GpuManager::Gpus;
CPUInfo GpuManager::CpuInfos;
bool g_isSSE3Supported = false;
bool g_isSSE4Supported = false;
bool g_isAVX2Supported = false;


GpuManager::GpuManager()
{
Expand Down Expand Up @@ -293,23 +299,44 @@ void GpuManager::SetPostCommandLineOptions()
if (g_memoryBoostLevel == RH_OPT_UNSET)
{
g_memoryBoostLevel = CpuInfos.numberOfCores == CpuInfos.numberOfProcessors ? 0 : 1; //enable boost on hyperthreads cpu
#if defined(MACOS_X) || (defined(__APPLE__) & defined(__MACH__))
if (stristr(CpuInfos.cpuBrandName.c_str(), "xeon"))
g_memoryBoostLevel = 0;
#endif
}

#ifdef RHMINER_ENABLE_SSE4
if (g_sseOptimization > 2)
g_sseOptimization = 2;

#if defined(RHMINER_COND_SSE4)
#if defined(RHMINER_COND_SSE4)
g_sseOptimization = 0;
#endif
#endif


if (g_sseOptimization == 2)
{
#if defined(RH_ENABLE_AVX)
bool avxDisabled = false;
#else
bool avxDisabled = true;
#endif

if (avxDisabled || g_isAVX2Supported == false)
{
g_sseOptimization = 0;
PrintOut("WARNING. AVX not supported. Selecting default optimization level.\n");
}
}

#else //#ifdef RHMINER_ENABLE_SSE4

if (g_sseOptimization)
PrintOut("SSE4 not available in this binary. -sseboost option ignored. \n");
g_sseOptimization = 0;
PrintOut("Detecting old-gen cpu.\n");
#endif

#endif //#ifdef RHMINER_ENABLE_SSE4
}

void GpuManager::LoadGPUMap()
Expand Down Expand Up @@ -601,9 +628,10 @@ bool GpuManager::SetupGPU()
exit(-1);
}

if (/*CpuInfos.avxSupportted == false && */g_sseOptimization == 2)
if (CpuInfos.avxSupportted == false && g_sseOptimization == 2)
{
PrintOut("AVX2 not supported yet.\n");
//PrintOut("AVX2 not supported yet.\n");
PrintOut("AVX2 not supported on this platform.\n");
exit(-1);
}
}
Expand Down Expand Up @@ -761,6 +789,7 @@ void GpuManager::TestExtraInstructions()

g_isSSE3Supported = CpuInfos.sse3Supportted;
g_isSSE4Supported = CpuInfos.sse4_1Supportted;
g_isAVX2Supported = CpuInfos.avxSupportted;
PrintOutSilent("SSe3 supported : %s\n", CpuInfos.sse3Supportted ? "Yes" : "No");
PrintOutSilent("SSe4.1 supported : %s\n", CpuInfos.sse4_1Supportted ? "Yes" : "No");
PrintOutSilent("avx supported : %s\n", CpuInfos.avxSupportted ? "Yes" : "No");
Expand Down Expand Up @@ -821,11 +850,27 @@ void GpuManager::LoadCPUInfos()
CpuInfos.numberOfProcessors = sysconf(_SC_NPROCESSORS_ONLN);
CpuInfos.numberOfCores = 0;
CpuInfos.allocationGranularity = 1024*64;
#ifdef _SC_AVPHYS_PAGES
CpuInfos.avaiablelMem = sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
#else
CpuInfos.avaiablelMem = sysconf(_SC_PAGESIZE) * sysconf(_SC_PAGE_SIZE);
#endif

CpuInfos.cpuBrandName = "x64";

string line;
string brand;

#if defined(MACOS_X) || (defined(__APPLE__) & defined(__MACH__))
char buf[100];
size_t buflen = 100;
sysctlbyname("machdep.cpu.brand_string", &buf, &buflen, NULL, 0);
brand = buf;
memset(buf, 0, 100);
sysctlbyname("hw.ncpu", &buf, &buflen, NULL, 0);
CpuInfos.numberOfCores = (U32)*buf;

#else
ifstream finfo("/proc/cpuinfo");
while(getline(finfo,line))
{
Expand All @@ -845,7 +890,7 @@ void GpuManager::LoadCPUInfos()
CpuInfos.numberOfCores = ToUInt(TrimString(info));
}
}

#endif
if (!CpuInfos.numberOfCores)
{
CpuInfos.numberOfCores = sysconf(_SC_NPROCESSORS_ONLN);
Expand Down
3 changes: 1 addition & 2 deletions MinersLib/Pascal/PascalCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ const static U32 PascalHeaderNoncePosV3 = (PascalHeaderSize-4);
#define RH_M_MEM_PER_THREAD_MB 8.8f

#define RH_N 5
#define RH_STRIDE_SIZE_FACTOR 32

// M*=5
#define RH_StrideArrayCount 31
#define RH_StrideSize 208896
#define RH_StrideSize (208896)

#define RH_CheckerSize (sizeof(U64))
#define RH_WorkSize RH_StrideSize
Expand Down
4 changes: 2 additions & 2 deletions MinersLib/Pascal/RandomHashCLMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void RandomHashCLMiner::QueueKernel()
{
GenericCLMiner::QueueKernel();
}

/*
SolutionSptr RandomHashCLMiner::MakeSubmitSolution(const std::vector<U64>& nonces, bool isFromCpuMiner)
{
PascalSolution* sol = new PascalSolution();
Expand All @@ -53,7 +53,7 @@ SolutionSptr RandomHashCLMiner::MakeSubmitSolution(const std::vector<U64>& nonce
return SolutionSptr(sol);
}

*/
bool RandomHashCLMiner::configureGPU()
{
//target a minimum of I=10
Expand Down
2 changes: 1 addition & 1 deletion MinersLib/Pascal/RandomHashCLMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ class RandomHashCLMiner: public GenericCLMiner

protected:
virtual void QueueKernel();
virtual SolutionSptr MakeSubmitSolution(const std::vector<U64>& nonces, bool isFromCpuMiner);
//virtual SolutionSptr MakeSubmitSolution(const std::vector<U64>& nonces, U64 nonce2, bool isFromCpuMiner);
};

Loading

0 comments on commit da6a2da

Please sign in to comment.