Skip to content

Commit

Permalink
Autoconf fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
o2genum committed May 3, 2019
1 parent cf1be39 commit 3c9c904
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 7 additions & 8 deletions xmrstak/backend/cpu/autoAdjustHwloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ namespace xmrstak
namespace cpu
{

class autoAdjust
class autoAdjustHwloc
{
public:
autoAdjust()
public:
autoAdjustHwloc()
{
auto neededAlgorithms = ::jconf::inst()->GetCurrentCoinSelection().GetAllAlgorithms();

Expand Down Expand Up @@ -60,6 +60,7 @@ class autoAdjust
conf += "/*\n//CPU config is disabled by default because cryptonight_gpu is not suitable for CPU mining.\n";
}

bool is_successful = true;
try
{
std::vector<hwloc_obj_t> tlcs;
Expand All @@ -86,10 +87,8 @@ class autoAdjust
}
catch(const std::runtime_error& err)
{
// \todo add fallback to default auto adjust
conf += std::string(" { \"low_power_mode\" : false");
conf += std::string(", \"no_prefetch\" : true, \"asm\" : \"off\", \"affine_to_cpu\" : false },\n");
printer::inst()->print_msg(L0, "Autoconf FAILED: %s. Create config for a single thread.", err.what());
is_successful = false;
printer::inst()->print_msg(L0, "Autoconf with hwloc FAILED: %s. Trying basic autoconf.", err.what());
}

if(useCryptonight_gpu)
Expand All @@ -101,7 +100,7 @@ class autoAdjust
/* Destroy topology object. */
hwloc_topology_destroy(topology);

return true;
return is_successful;
}

private:
Expand Down
15 changes: 15 additions & 0 deletions xmrstak/backend/cpu/minethd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#ifndef CONF_NO_HWLOC
#include "autoAdjustHwloc.hpp"
#include "autoAdjust.hpp"
#else
#include "autoAdjust.hpp"
#endif
Expand Down Expand Up @@ -515,9 +516,23 @@ std::vector<iBackend*> minethd::thread_starter(uint32_t threadOffset, miner_work

if(!configEditor::file_exist(params::inst().configFileCPU))
{
#ifndef CONF_NO_HWLOC
autoAdjustHwloc adjustHwloc;
if(!adjustHwloc.printConfig())
{
autoAdjust adjust;
if(!adjust.printConfig())
{
return pvThreads;
}
}
#else
autoAdjust adjust;
if(!adjust.printConfig())
{
return pvThreads;
}
#endif
}

if(!jconf::inst()->parse_config())
Expand Down

0 comments on commit 3c9c904

Please sign in to comment.