Added command line option --export-topology.

This commit is contained in:
XMRig 2019-07-30 09:06:50 +07:00
parent 6b3b1c3fc4
commit bd739d217b
3 changed files with 51 additions and 2 deletions

View file

@ -41,6 +41,9 @@
#include "version.h"
namespace xmrig {
static int showVersion()
{
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
@ -92,6 +95,36 @@ static int showVersion()
}
#ifdef XMRIG_FEATURE_HWLOC
static int exportTopology(const Process &process)
{
const String path = process.location(Process::ExeLocation, "topology.xml");
hwloc_topology_t topology;
hwloc_topology_init(&topology);
hwloc_topology_load(topology);
# if HWLOC_API_VERSION >= 0x20000
if (hwloc_topology_export_xml(topology, path, 0) == -1) {
# else
if (hwloc_topology_export_xml(topology, path) == -1) {
# endif
printf("failed to export hwloc topology.\n");
}
else {
printf("hwloc topology successfully exported to \"%s\"\n", path.data());
}
hwloc_topology_destroy(topology);
return 0;
}
#endif
} // namespace xmrig
xmrig::Entry::Id xmrig::Entry::get(const Process &process)
{
const Arguments &args = process.arguments();
@ -103,11 +136,17 @@ xmrig::Entry::Id xmrig::Entry::get(const Process &process)
return Version;
}
# ifdef XMRIG_FEATURE_HWLOC
if (args.hasArg("--export-topology")) {
return Topo;
}
# endif
return Default;
}
int xmrig::Entry::exec(const Process &, Id id)
int xmrig::Entry::exec(const Process &process, Id id)
{
switch (id) {
case Usage:
@ -117,6 +156,11 @@ int xmrig::Entry::exec(const Process &, Id id)
case Version:
return showVersion();
# ifdef XMRIG_FEATURE_HWLOC
case Topo:
return exportTopology(process);
# endif
default:
break;
}

View file

@ -38,7 +38,8 @@ public:
enum Id {
Default,
Usage,
Version
Version,
Topo
};
static Id get(const Process &process);

View file

@ -113,6 +113,10 @@ Options:\n\
--randomx-init=N threads count to initialize RandomX dataset\n\
--randomx-no-numa disable NUMA support for RandomX\n"
#endif
#ifdef XMRIG_FEATURE_HWLOC
"\
--export-topology export hwloc topology to a XML file and exit\n"
#endif
"\
--dry-run test configuration and exit\n\
-h, --help display this help and exit\n\