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 Jun 1, 2024
1 parent b6b3abe commit 729dfbd
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 60 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ 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_AVX2 "Enable AVX2 for Blake2" ON)
option(WITH_VAES "Enable VAES instructions for Cryptonight" ON)
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF)
option(WITH_DMI "Enable DMI/SMBIOS reader" ON)
option(WITH_MO_BENCHMARK "Enable Benchmark module and algo-perf feature (for MoneroOcean)" ON)

option(BUILD_STATIC "Build static binary" OFF)
option(ARM_V8 "Force ARMv8 (64 bit) architecture, use with caution if automatic detection fails, but you sure it may work" OFF)
Expand Down Expand Up @@ -135,13 +135,6 @@ set(SOURCES_CRYPTO
src/crypto/flex/flex_keccak.c
)

if (WITH_MO_BENCHMARK)
list(APPEND SOURCES
src/core/MoBenchmark.cpp
)
add_definitions(/DXMRIG_FEATURE_MO_BENCHMARK)
endif()

if (CMAKE_C_COMPILER_ID MATCHES GNU)
set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize")
endif()
Expand Down Expand Up @@ -248,6 +241,13 @@ if (WITH_DEBUG_LOG)
add_definitions(/DAPP_DEBUG)
endif()

if (WITH_MO_BENCHMARK)
list(APPEND SOURCES
src/core/MoBenchmark.cpp
)
add_definitions(/DXMRIG_FEATURE_MO_BENCHMARK)
endif()

add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB} ${ARGON2_LIBRARY} ${ETHASH_LIBRARY} ${GHOSTRIDER_LIBRARY})

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
4 changes: 3 additions & 1 deletion src/backend/common/Threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ xmrig::String xmrig::Threads<T>::profileName(const Algorithm &algorithm, bool st
}
}

if (std::is_same<T, CpuThreads>::value && (name == "panthera") && has("rx")) return "rx";
if (std::is_same<T, CpuThreads>::value && (name == Algorithm::kRX_XLA) && has(Algorithm::kRX)) {
return Algorithm::kRX;
}

if (has(kAsterisk)) {
return kAsterisk;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cpu/platform/BasicCpuInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3

# ifdef XMRIG_ALGO_CN_FEMTO
if (f == Algorithm::CN_FEMTO) {
return CpuThreads(count, 2);
return CpuThreads(count_limit, 2);
}
# endif

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 @@ -58,13 +58,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
7 changes: 3 additions & 4 deletions src/base/kernel/config/BaseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ 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_syslog = reader.getBool(kSyslog, m_syslog);
m_watch = reader.getBool(kWatch, m_watch);
m_logFile = reader.getString(kLogFile);
Expand All @@ -107,11 +104,13 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
m_tls = reader.getValue(kTls);
# endif

Log::setColors(reader.getBool(kColors, Log::isColors()));
# ifdef XMRIG_FEATURE_MO_BENCHMARK
m_rebenchAlgo = reader.getBool(kRebenchAlgo, m_rebenchAlgo);
m_benchAlgoTime = reader.getInt(kBenchAlgoTime, m_benchAlgoTime);
m_algoMinTime = reader.getInt(kAlgoMinTime, m_algoMinTime);
# endif

Log::setColors(reader.getBool(kColors, Log::isColors()));
setVerbose(reader.getValue(kVerbose));

const auto &api = reader.getObject(kApi);
Expand Down
27 changes: 14 additions & 13 deletions src/base/kernel/config/BaseTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,20 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
# endif

case IConfig::RetriesKey: /* --retries */
# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
case IConfig::AlgoMinTimeKey: /* --algo-min-time */
# endif
case IConfig::RetryPauseKey: /* --retry-pause */
case IConfig::PrintTimeKey: /* --print-time */
# ifdef XMRIG_FEATURE_HTTP
case IConfig::HttpPort: /* --http-port */
case IConfig::DonateLevelKey: /* --donate-level */
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
case IConfig::DaemonJobTimeoutKey: /* --daemon-job-timeout */
case IConfig::DnsTtlKey: /* --dns-ttl */
case IConfig::DaemonZMQPortKey: /* --daemon-zmq-port */
# endif
case IConfig::DnsTtlKey: /* --dns-ttl */
case IConfig::DonateLevelKey: /* --donate-level */
# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
case IConfig::AlgoMinTimeKey: /* --algo-min-time */
# endif
return transformUint64(doc, key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));

case IConfig::BackgroundKey: /* --background */
Expand All @@ -268,13 +270,12 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
case IConfig::HttpEnabledKey: /* --http-enabled */
case IConfig::DaemonKey: /* --daemon */
# endif
# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::RebenchAlgoKey: /* --rebench-algo */
# endif
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
case IConfig::SubmitToOriginKey: /* --submit-to-origin */
case IConfig::VerboseKey: /* --verbose */
case IConfig::DnsIPv6Key: /* --dns-ipv6 */
# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::RebenchAlgoKey: /* --rebench-algo */
# endif
return transformBoolean(doc, key, true);

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

case IConfig::DnsIPv6Key: /* --dns-ipv6 */
return set(doc, DnsConfig::kField, DnsConfig::kIPv6, enable);

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

case IConfig::DnsIPv6Key: /* --dns-ipv6 */
return set(doc, DnsConfig::kField, DnsConfig::kIPv6, enable);

default:
break;
}
Expand Down
10 changes: 5 additions & 5 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,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 @@ -102,8 +102,8 @@
"user-agent": null,
"verbose": 0,
"watch": true,
"rebench-algo": false,
"bench-algo-time": 20,
"pause-on-battery": false,
"pause-on-active": false
"pause-on-active": false,
"rebench-algo": false,
"bench-algo-time": 20
}
5 changes: 0 additions & 5 deletions src/core/MoBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,3 @@ uint64_t MoBenchmark::get_now() const { // get current time in ms
}

} // namespace xmrig

const char *xmrig::bm_tag()
{
return Tags::benchmark();
}
13 changes: 6 additions & 7 deletions src/core/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime);
# endif

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

# ifdef XMRIG_FEATURE_DMI
d_ptr->dmi = reader.getBool(kDMI, d_ptr->dmi);
# endif

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

return true;
}

Expand Down Expand Up @@ -313,14 +313,13 @@ 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);
doc.AddMember(StringRef(kPauseOnActive), (d_ptr->idleTime == 0U || d_ptr->idleTime == kIdleTime) ? Value(isPauseOnActive()) : Value(d_ptr->idleTime), allocator);

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

doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator);
doc.AddMember(StringRef(kPauseOnActive), (d_ptr->idleTime == 0U || d_ptr->idleTime == kIdleTime) ? Value(isPauseOnActive()) : Value(d_ptr->idleTime), allocator);
}
2 changes: 1 addition & 1 deletion src/core/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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
2 changes: 1 addition & 1 deletion src/crypto/randomx/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace randomx {
constexpr int SuperscalarMaxSize = 3 * RANDOMX_SUPERSCALAR_MAX_LATENCY + 2;
constexpr size_t CacheLineSize = RANDOMX_DATASET_ITEM_SIZE;
#define ScratchpadSize RandomX_CurrentConfig.ScratchpadL3_Size
#define CacheLineAlignMask RandomX_CurrentConfig.CacheLineAlignMask_Calculated
#define CacheLineAlignMask RandomX_CurrentConfig.CacheLineAlignMask_Calculated
#define DatasetExtraItems RandomX_ConfigurationBase::DatasetExtraItems_Calculated
constexpr int StoreL3Condition = 14;

Expand Down
28 changes: 28 additions & 0 deletions src/crypto/randomx/panthera/sysendian.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#define be64enc libcperciva_be64enc
#define le32dec libcperciva_le32dec
#define le32enc libcperciva_le32enc
#define le64dec libcperciva_le64dec
#define le64enc libcperciva_le64enc

static inline uint32_t
be32dec(const void * pp)
Expand Down Expand Up @@ -91,4 +93,30 @@ le32enc(void * pp, uint32_t x)
p[3] = (x >> 24) & 0xff;
}

static inline uint64_t
le64dec(const void * pp)
{
const uint8_t * p = (uint8_t const *)pp;

return ((uint64_t)(p[0]) + ((uint64_t)(p[1]) << 8) +
((uint64_t)(p[2]) << 16) + ((uint64_t)(p[3]) << 24) +
((uint64_t)(p[4]) << 32) + ((uint64_t)(p[5]) << 40) +
((uint64_t)(p[6]) << 48) + ((uint64_t)(p[7]) << 56));
}

static inline void
le64enc(void * pp, uint64_t x)
{
uint8_t * p = (uint8_t *)pp;

p[0] = x & 0xff;
p[1] = (x >> 8) & 0xff;
p[2] = (x >> 16) & 0xff;
p[3] = (x >> 24) & 0xff;
p[4] = (x >> 32) & 0xff;
p[5] = (x >> 40) & 0xff;
p[6] = (x >> 48) & 0xff;
p[7] = (x >> 56) & 0xff;
}

#endif /* !_SYSENDIAN_H_ */
2 changes: 1 addition & 1 deletion src/crypto/randomx/randomx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void RandomX_ConfigurationBase::Apply()

ScratchpadL3Mask_Calculated = (((ScratchpadL3_Size / sizeof(uint64_t)) - 1) * 8);
ScratchpadL3Mask64_Calculated = ((ScratchpadL3_Size / sizeof(uint64_t)) / 8 - 1) * 64;
CacheLineAlignMask_Calculated = (DatasetBaseSize - 1) & ~(RANDOMX_DATASET_ITEM_SIZE - 1);
CacheLineAlignMask_Calculated = (DatasetBaseSize - 1) & ~(RANDOMX_DATASET_ITEM_SIZE - 1);

#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__))
*(uint32_t*)(codeShhPrefetchTweaked + 3) = ArgonMemory * 16 - 1;
Expand Down
9 changes: 4 additions & 5 deletions src/crypto/randomx/randomx.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ struct RandomX_ConfigurationBase
ConditionMask_Calculated = ((1 << JumpBits) - 1) << JumpOffset,
};

uint32_t ArgonMemory;
uint32_t CacheAccesses;
uint32_t DatasetBaseSize;
uint32_t ArgonMemory;
uint32_t CacheAccesses;
uint32_t DatasetBaseSize;

uint32_t ArgonIterations;
uint32_t ArgonLanes;
Expand Down Expand Up @@ -134,11 +134,10 @@ struct RandomX_ConfigurationBase
uint8_t codePrefetchScratchpadTweaked[28];
uint32_t codePrefetchScratchpadTweakedSize;

uint32_t CacheLineAlignMask_Calculated;

uint32_t AddressMask_Calculated[4];
uint32_t ScratchpadL3Mask_Calculated;
uint32_t ScratchpadL3Mask64_Calculated;
uint32_t CacheLineAlignMask_Calculated;

# if (XMRIG_ARM == 8)
uint32_t Log2_ScratchpadL1;
Expand Down

0 comments on commit 729dfbd

Please sign in to comment.