Skip to content

Commit

Permalink
Cleanup useless code, rearrange
Browse files Browse the repository at this point in the history
  • Loading branch information
Spudz76 committed Nov 8, 2020
1 parent 9b3d722 commit 8eb1d9a
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (on
option(WITH_ADL "Enable ADL (AMD Display Library) or sysfs support (only if OpenCL backend enabled)" ON)
option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
option(WITH_MO_BENCHMARK "Enable Benchmark module and algo-perf feature (for MoneroOcean)" ON)
option(WITH_PROFILING "Enable profiling for developers" OFF)
option(WITH_SSE4_1 "Enable SSE 4.1 for Blake2" ON)
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
option(WITH_MO_BENCHMARK "Enable Benchmark module and algo-perf feature (for MoneroOcean)" ON)

option(BUILD_STATIC "Build static binary" OFF)
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
Expand Down
4 changes: 0 additions & 4 deletions src/backend/common/Tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ const char *ocl_tag();
const char *cuda_tag();
#endif

#ifdef XMRIG_FEATURE_MO_BENCHMARK
const char *bm_tag();
#endif


} // namespace xmrig

Expand Down
8 changes: 4 additions & 4 deletions src/base/io/log/Tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class Tags
static const char *opencl();
# endif

# ifdef XMRIG_FEATURE_MO_BENCHMARK
static const char *benchmark();
# endif

# ifdef XMRIG_FEATURE_PROFILING
static const char* profiler();
# endif

# ifdef XMRIG_FEATURE_MO_BENCHMARK
static const char *benchmark();
# endif
};


Expand Down
12 changes: 5 additions & 7 deletions src/base/kernel/config/BaseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
m_autoSave = reader.getBool(kAutosave, m_autoSave);
m_background = reader.getBool(kBackground, m_background);
m_dryRun = reader.getBool(kDryRun, m_dryRun);
# ifdef XMRIG_FEATURE_MO_BENCHMARK
m_rebenchAlgo = reader.getBool(kRebenchAlgo, m_rebenchAlgo);
# endif
m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery);
m_syslog = reader.getBool(kSyslog, m_syslog);
m_watch = reader.getBool(kWatch, m_watch);
m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery);
# ifdef XMRIG_FEATURE_MO_BENCHMARK
m_rebenchAlgo = reader.getBool(kRebenchAlgo, m_rebenchAlgo);
m_benchAlgoTime = reader.getInt(kBenchAlgoTime, m_benchAlgoTime);
# endif
m_logFile = reader.getString(kLogFile);
m_userAgent = reader.getString(kUserAgent);
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
Expand All @@ -114,9 +115,6 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
# endif

Log::setColors(reader.getBool(kColors, Log::isColors()));
# ifdef XMRIG_FEATURE_MO_BENCHMARK
m_benchAlgoTime = reader.getInt(kBenchAlgoTime, m_benchAlgoTime);
# endif
setVerbose(reader.getValue(kVerbose));

const auto &api = reader.getObject(kApi);
Expand Down
8 changes: 4 additions & 4 deletions src/base/kernel/config/BaseTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
case IConfig::DaemonKey: /* --daemon */
# endif
case IConfig::VerboseKey: /* --verbose */
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::RebenchAlgoKey: /* --rebench-algo */
# endif
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
return transformBoolean(doc, key, true);

case IConfig::ColorKey: /* --no-color */
Expand Down Expand Up @@ -332,14 +332,14 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
case IConfig::NoTitleKey: /* --no-title */
return set(doc, BaseConfig::kTitle, enable);

case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
return set(doc, BaseConfig::kPauseOnBattery, enable);

# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::RebenchAlgoKey: /* --rebench-algo */
return set(doc, BaseConfig::kRebenchAlgo, enable);
# endif

case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
return set(doc, BaseConfig::kPauseOnBattery, enable);

default:
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"nvml": true,
"cn/0": false,
"cn-lite/0": false,
"panthera": false,
"astrobwt": false
"astrobwt": false,
"panthera": false
},
"donate-level": 1,
"donate-over-proxy": 1,
Expand Down Expand Up @@ -97,7 +97,7 @@
"user-agent": null,
"verbose": 0,
"watch": true,
"pause-on-battery": false,
"rebench-algo": false,
"bench-algo-time": 20,
"pause-on-battery": false
"bench-algo-time": 20
}
2 changes: 1 addition & 1 deletion src/core/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void xmrig::Controller::pre_start()
void xmrig::Controller::start()
{
Base::start();
#ifndef XMRIG_FEATURE_BENCHMARK
#ifndef XMRIG_FEATURE_MO_BENCHMARK
m_miner = new Miner(this);
#endif
network()->connect();
Expand Down
5 changes: 0 additions & 5 deletions src/core/MoBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,3 @@ uint64_t MoBenchmark::get_now() const { // get current time in ms
}

} // namespace xmrig

const char *xmrig::bm_tag()
{
return Tags::benchmark();
}
24 changes: 12 additions & 12 deletions src/core/MoBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ class MoBenchmark : public IJobResultListener {
Job* m_bench_job[BenchAlgo::MAX];
double m_bench_algo_perf[BenchAlgo::MAX];

Controller* m_controller; // to get access to config and network
bool m_isNewBenchRun; // true if benchmark is need to be executed or was executed
MoBenchmark::BenchAlgo m_bench_algo; // current perf algo we benchmark
uint64_t m_hash_count; // number of hashes calculated for current perf algo
uint64_t m_time_start; // time of the first resultt for current perf algo (in ms)
uint64_t m_bench_start; // time of measurements start for current perf algo (in ms) after all backends are started
unsigned m_enabled_backend_count; // number of active miner backends
Controller* m_controller; // to get access to config and network
bool m_isNewBenchRun; // true if benchmark is need to be executed or was executed
MoBenchmark::BenchAlgo m_bench_algo; // current perf algo we benchmark
uint64_t m_hash_count; // number of hashes calculated for current perf algo
uint64_t m_time_start; // time of the first resultt for current perf algo (in ms)
uint64_t m_bench_start; // time of measurements start for current perf algo (in ms) after all backends are started
unsigned m_enabled_backend_count; // number of active miner backends
std::set<uint32_t> m_backends_started; // id of backend started for benchmark

uint64_t get_now() const; // get current time in ms
uint64_t get_now() const; // get current time in ms
double get_algo_perf(Algorithm::Id algo) const; // get algo perf based on m_bench_algo_perf
void start(const MoBenchmark::BenchAlgo); // start benchmark for specified perf algo
void finish(); // end of benchmarks, switch to jobs from the pool (network), fill algo_perf
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
void run_next_bench_algo(BenchAlgo); // run next bench algo or finish benchmark for the last one
void start(const MoBenchmark::BenchAlgo); // start benchmark for specified perf algo
void finish(); // end of benchmarks, switch to jobs from the pool (network), fill algo_perf
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
void run_next_bench_algo(BenchAlgo); // run next bench algo or finish benchmark for the last one

public:
MoBenchmark();
Expand Down
9 changes: 4 additions & 5 deletions src/core/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool xmrig::Config::isShouldSave() const
}
# endif

# ifdef XMRIG_FEATURE_BENCHMARK
# ifdef XMRIG_FEATURE_MO_BENCHMARK
if (m_benchmark.isNewBenchRun()) {
return true;
}
Expand Down Expand Up @@ -197,7 +197,7 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime);
# endif

# ifdef XMRIG_FEATURE_BENCHMARK
# ifdef XMRIG_FEATURE_MO_BENCHMARK
m_benchmark.read(reader.getValue(kAlgoPerf));
# endif

Expand Down Expand Up @@ -257,12 +257,11 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
doc.AddMember(StringRef(kWatch), m_watch, allocator);
doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator);

# ifdef XMRIG_FEATURE_BENCHMARK
# ifdef XMRIG_FEATURE_MO_BENCHMARK
doc.AddMember(StringRef(kRebenchAlgo), isRebenchAlgo(), allocator);
doc.AddMember(StringRef(kBenchAlgoTime), benchAlgoTime(), allocator);
doc.AddMember(StringRef(kAlgoPerf), m_benchmark.toJSON(doc), allocator);
# endif

doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator);
}
2 changes: 1 addition & 1 deletion src/core/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Config : public BaseConfig
void getJSON(rapidjson::Document &doc) const override;

# ifdef XMRIG_FEATURE_MO_BENCHMARK
inline MoBenchmark &benchmark() { return m_benchmark; }
inline MoBenchmark &benchmark() { return m_benchmark; }
# endif

private:
Expand Down

0 comments on commit 8eb1d9a

Please sign in to comment.