Added ADL support for Windows.
This commit is contained in:
@ -19,6 +19,7 @@ option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
||||
option(WITH_OPENCL "Enable OpenCL backend" ON)
|
||||
option(WITH_CUDA "Enable CUDA backend" ON)
|
||||
option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (only if CUDA backend enabled)" ON)
|
||||
option(WITH_ADL "Enable ADL (AMD Display Library) 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)
|
||||
|
||||
|
2342
src/3rdparty/adl/adl_defines.h
vendored
Normal file
2342
src/3rdparty/adl/adl_defines.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
44
src/3rdparty/adl/adl_sdk.h
vendored
Normal file
44
src/3rdparty/adl/adl_sdk.h
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// MIT LICENSE:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
/// \file adl_sdk.h
|
||||
/// \brief Contains the definition of the Memory Allocation Callback.\n <b>Included in ADL SDK</b>
|
||||
///
|
||||
/// \n\n
|
||||
/// This file contains the definition of the Memory Allocation Callback.\n
|
||||
/// It also includes definitions of the respective structures and constants.\n
|
||||
/// <b> This is the only header file to be included in a C/C++ project using ADL </b>
|
||||
|
||||
#ifndef ADL_SDK_H_
|
||||
#define ADL_SDK_H_
|
||||
|
||||
#include "adl_structures.h"
|
||||
|
||||
#if defined (LINUX)
|
||||
#define __stdcall
|
||||
#endif /* (LINUX) */
|
||||
|
||||
/// Memory Allocation Call back
|
||||
typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int );
|
||||
|
||||
|
||||
#endif /* ADL_SDK_H_ */
|
3440
src/3rdparty/adl/adl_structures.h
vendored
Normal file
3440
src/3rdparty/adl/adl_structures.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -27,11 +27,11 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
#include "backend/opencl/OclBackend.h"
|
||||
#include "backend/common/Hashrate.h"
|
||||
#include "backend/common/interfaces/IWorker.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/opencl/OclBackend.h"
|
||||
#include "backend/opencl/OclConfig.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/OclWorker.h"
|
||||
@ -52,6 +52,13 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_ADL
|
||||
#include "backend/opencl/wrappers/AdlLib.h"
|
||||
|
||||
namespace xmrig { static const char *kAdlLabel = "ADL"; }
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@ -59,14 +66,15 @@ extern template class Threads<OclThreads>;
|
||||
|
||||
|
||||
constexpr const size_t oneMiB = 1024U * 1024U;
|
||||
static const char *kLabel = "OPENCL";
|
||||
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ");
|
||||
static const String kType = "opencl";
|
||||
static std::mutex mutex;
|
||||
|
||||
|
||||
static void printDisabled(const char *reason)
|
||||
static void printDisabled(const char *label, const char *reason)
|
||||
{
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", "OPENCL", reason);
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", label, reason);
|
||||
}
|
||||
|
||||
|
||||
@ -129,11 +137,11 @@ public:
|
||||
void init(const OclConfig &cl)
|
||||
{
|
||||
if (!cl.isEnabled()) {
|
||||
return printDisabled("");
|
||||
return printDisabled(kLabel, "");
|
||||
}
|
||||
|
||||
if (!OclLib::init(cl.loader())) {
|
||||
return printDisabled(RED_S " (failed to load OpenCL runtime)");
|
||||
return printDisabled(kLabel, RED_S " (failed to load OpenCL runtime)");
|
||||
}
|
||||
|
||||
if (platform.isValid()) {
|
||||
@ -142,14 +150,30 @@ public:
|
||||
|
||||
platform = cl.platform();
|
||||
if (!platform.isValid()) {
|
||||
return printDisabled(RED_S " (selected OpenCL platform NOT found)");
|
||||
return printDisabled(kLabel, RED_S " (selected OpenCL platform NOT found)");
|
||||
}
|
||||
|
||||
devices = platform.devices();
|
||||
if (devices.empty()) {
|
||||
return printDisabled(RED_S " (no devices)");
|
||||
return printDisabled(kLabel, RED_S " (no devices)");
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (cl.isAdlEnabled()) {
|
||||
if (AdlLib::init()) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "press " MAGENTA_BG(WHITE_BOLD_S "e") " for health report",
|
||||
kAdlLabel
|
||||
);
|
||||
}
|
||||
else {
|
||||
printDisabled(kAdlLabel, RED_S " (failed to load ADL)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printDisabled(kAdlLabel, "");
|
||||
}
|
||||
# endif
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu ") WHITE_BOLD("%s") "/" WHITE_BOLD("%s"), "OPENCL", platform.index(), platform.name().data(), platform.version().data());
|
||||
|
||||
for (const OclDevice &device : devices) {
|
||||
@ -204,6 +228,32 @@ public:
|
||||
}
|
||||
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
void printHealth()
|
||||
{
|
||||
if (!AdlLib::isReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &device : devices) {
|
||||
const auto health = AdlLib::health(device);
|
||||
|
||||
LOG_INFO("%s" CYAN_BOLD(" #%u") YELLOW(" %s") MAGENTA_BOLD("%4uW") CSI "1;%um %2uC" CYAN_BOLD(" %4u") CYAN("RPM") WHITE_BOLD(" %u/%u") "MHz",
|
||||
tag,
|
||||
device.index(),
|
||||
device.topology().toString().data(),
|
||||
health.power,
|
||||
health.temperature < 60 ? 32 : (health.temperature > 85 ? 31 : 33),
|
||||
health.temperature,
|
||||
health.rpm,
|
||||
health.clock,
|
||||
health.memClock
|
||||
);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
Algorithm algo;
|
||||
Controller *controller;
|
||||
OclContext context;
|
||||
@ -237,6 +287,10 @@ xmrig::OclBackend::~OclBackend()
|
||||
delete d_ptr;
|
||||
|
||||
OclLib::close();
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
AdlLib::close();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
@ -270,6 +324,16 @@ const xmrig::String &xmrig::OclBackend::type() const
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclBackend::execCommand(char command)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (command == 'e' || command == 'E') {
|
||||
d_ptr->printHealth();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclBackend::prepare(const Job &)
|
||||
{
|
||||
}
|
||||
@ -385,6 +449,15 @@ void xmrig::OclBackend::stop()
|
||||
void xmrig::OclBackend::tick(uint64_t ticks)
|
||||
{
|
||||
d_ptr->workers.tick(ticks);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (isEnabled()) {
|
||||
auto seconds = d_ptr->controller->config()->healthPrintTime();
|
||||
if (seconds && ticks && (ticks % (seconds * 2)) == 0) {
|
||||
d_ptr->printHealth();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -51,13 +51,12 @@ public:
|
||||
~OclBackend() override;
|
||||
|
||||
protected:
|
||||
inline void execCommand(char) override {}
|
||||
|
||||
bool isEnabled() const override;
|
||||
bool isEnabled(const Algorithm &algorithm) const override;
|
||||
const Hashrate *hashrate() const override;
|
||||
const String &profileName() const override;
|
||||
const String &type() const override;
|
||||
void execCommand(char command) override;
|
||||
void prepare(const Job &nextJob) override;
|
||||
void printHashrate(bool details) override;
|
||||
void setJob(const Job &job) override;
|
||||
|
@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -44,6 +44,10 @@ static const char *kLoader = "loader";
|
||||
static const char *kNVIDIA = "NVIDIA";
|
||||
static const char *kPlatform = "platform";
|
||||
|
||||
#ifdef XMRIG_FEATURE_ADL
|
||||
static const char *kAdl = "adl";
|
||||
#endif
|
||||
|
||||
|
||||
extern template class Threads<OclThreads>;
|
||||
|
||||
@ -108,6 +112,10 @@ rapidjson::Value xmrig::OclConfig::toJSON(rapidjson::Document &doc) const
|
||||
obj.AddMember(StringRef(kLoader), m_loader.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kPlatform), m_platformVendor.isEmpty() ? Value(m_platformIndex) : m_platformVendor.toJSON(), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
obj.AddMember(StringRef(kAdl), m_adl, allocator);
|
||||
# endif
|
||||
|
||||
m_threads.toJSON(obj, doc);
|
||||
|
||||
return obj;
|
||||
@ -155,6 +163,10 @@ void xmrig::OclConfig::read(const rapidjson::Value &value)
|
||||
setPlatform(Json::getValue(value, kPlatform));
|
||||
setDevicesHint(Json::getString(value, kDevicesHint));
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
m_adl = Json::getBool(value, kAdl, m_adl);
|
||||
# endif
|
||||
|
||||
m_threads.read(value);
|
||||
|
||||
generate();
|
||||
|
@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -51,6 +51,10 @@ public:
|
||||
inline const String &loader() const { return m_loader; }
|
||||
inline const Threads<OclThreads> &threads() const { return m_threads; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
inline bool isAdlEnabled() const { return m_adl; }
|
||||
# endif
|
||||
|
||||
private:
|
||||
void generate();
|
||||
void setDevicesHint(const char *devicesHint);
|
||||
@ -64,6 +68,10 @@ private:
|
||||
String m_platformVendor;
|
||||
Threads<OclThreads> m_threads;
|
||||
uint32_t m_platformIndex = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
bool m_adl = true;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ if (WITH_OPENCL)
|
||||
src/backend/opencl/wrappers/OclLib.h
|
||||
src/backend/opencl/wrappers/OclPlatform.h
|
||||
src/backend/opencl/wrappers/OclVendor.h
|
||||
)
|
||||
)
|
||||
|
||||
set(SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/cl/OclSource.cpp
|
||||
@ -59,75 +59,89 @@ if (WITH_OPENCL)
|
||||
src/backend/opencl/wrappers/OclKernel.cpp
|
||||
src/backend/opencl/wrappers/OclLib.cpp
|
||||
src/backend/opencl/wrappers/OclPlatform.cpp
|
||||
)
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_win.cpp)
|
||||
else()
|
||||
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_unix.cpp)
|
||||
endif()
|
||||
if (WIN32)
|
||||
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_win.cpp)
|
||||
else()
|
||||
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_unix.cpp)
|
||||
endif()
|
||||
|
||||
if (WITH_RANDOMX)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h
|
||||
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.h
|
||||
src/backend/opencl/kernels/rx/ExecuteVmKernel.h
|
||||
src/backend/opencl/kernels/rx/FillAesKernel.h
|
||||
src/backend/opencl/kernels/rx/FindSharesKernel.h
|
||||
src/backend/opencl/kernels/rx/HashAesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/InitVmKernel.h
|
||||
src/backend/opencl/kernels/rx/RxJitKernel.h
|
||||
src/backend/opencl/kernels/rx/RxRunKernel.h
|
||||
src/backend/opencl/runners/OclRxBaseRunner.h
|
||||
src/backend/opencl/runners/OclRxJitRunner.h
|
||||
src/backend/opencl/runners/OclRxVmRunner.h
|
||||
)
|
||||
if (WITH_RANDOMX)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h
|
||||
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.h
|
||||
src/backend/opencl/kernels/rx/ExecuteVmKernel.h
|
||||
src/backend/opencl/kernels/rx/FillAesKernel.h
|
||||
src/backend/opencl/kernels/rx/FindSharesKernel.h
|
||||
src/backend/opencl/kernels/rx/HashAesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/InitVmKernel.h
|
||||
src/backend/opencl/kernels/rx/RxJitKernel.h
|
||||
src/backend/opencl/kernels/rx/RxRunKernel.h
|
||||
src/backend/opencl/runners/OclRxBaseRunner.h
|
||||
src/backend/opencl/runners/OclRxJitRunner.h
|
||||
src/backend/opencl/runners/OclRxVmRunner.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/generators/ocl_generic_rx_generator.cpp
|
||||
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
|
||||
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
|
||||
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
|
||||
src/backend/opencl/kernels/rx/FillAesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/FindSharesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/HashAesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/InitVmKernel.cpp
|
||||
src/backend/opencl/kernels/rx/RxJitKernel.cpp
|
||||
src/backend/opencl/kernels/rx/RxRunKernel.cpp
|
||||
src/backend/opencl/runners/OclRxBaseRunner.cpp
|
||||
src/backend/opencl/runners/OclRxJitRunner.cpp
|
||||
src/backend/opencl/runners/OclRxVmRunner.cpp
|
||||
)
|
||||
endif()
|
||||
list(APPEND SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/generators/ocl_generic_rx_generator.cpp
|
||||
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
|
||||
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
|
||||
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
|
||||
src/backend/opencl/kernels/rx/FillAesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/FindSharesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/HashAesKernel.cpp
|
||||
src/backend/opencl/kernels/rx/InitVmKernel.cpp
|
||||
src/backend/opencl/kernels/rx/RxJitKernel.cpp
|
||||
src/backend/opencl/kernels/rx/RxRunKernel.cpp
|
||||
src/backend/opencl/runners/OclRxBaseRunner.cpp
|
||||
src/backend/opencl/runners/OclRxJitRunner.cpp
|
||||
src/backend/opencl/runners/OclRxVmRunner.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.h
|
||||
src/backend/opencl/kernels/Cn1RyoKernel.h
|
||||
src/backend/opencl/kernels/Cn2RyoKernel.h
|
||||
src/backend/opencl/runners/OclRyoRunner.h
|
||||
)
|
||||
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.h
|
||||
src/backend/opencl/kernels/Cn1RyoKernel.h
|
||||
src/backend/opencl/kernels/Cn2RyoKernel.h
|
||||
src/backend/opencl/runners/OclRyoRunner.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/generators/ocl_generic_cn_gpu_generator.cpp
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.cpp
|
||||
src/backend/opencl/kernels/Cn1RyoKernel.cpp
|
||||
src/backend/opencl/kernels/Cn2RyoKernel.cpp
|
||||
src/backend/opencl/runners/OclRyoRunner.cpp
|
||||
)
|
||||
endif()
|
||||
list(APPEND SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/generators/ocl_generic_cn_gpu_generator.cpp
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.cpp
|
||||
src/backend/opencl/kernels/Cn1RyoKernel.cpp
|
||||
src/backend/opencl/kernels/Cn2RyoKernel.cpp
|
||||
src/backend/opencl/runners/OclRyoRunner.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_STRICT_CACHE)
|
||||
add_definitions(/DXMRIG_STRICT_OPENCL_CACHE)
|
||||
else()
|
||||
remove_definitions(/DXMRIG_STRICT_OPENCL_CACHE)
|
||||
endif()
|
||||
if (WITH_STRICT_CACHE)
|
||||
add_definitions(/DXMRIG_STRICT_OPENCL_CACHE)
|
||||
else()
|
||||
remove_definitions(/DXMRIG_STRICT_OPENCL_CACHE)
|
||||
endif()
|
||||
|
||||
if (WITH_INTERLEAVE_DEBUG_LOG)
|
||||
add_definitions(/DXMRIG_INTERLEAVE_DEBUG)
|
||||
endif()
|
||||
if (WITH_INTERLEAVE_DEBUG_LOG)
|
||||
add_definitions(/DXMRIG_INTERLEAVE_DEBUG)
|
||||
endif()
|
||||
|
||||
if (WITH_ADL AND XMRIG_OS_WIN)
|
||||
add_definitions(/DXMRIG_FEATURE_ADL)
|
||||
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/wrappers/AdlHealth.h
|
||||
src/backend/opencl/wrappers/AdlLib.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/wrappers/AdlLib.cpp)
|
||||
else()
|
||||
remove_definitions(/DXMRIG_FEATURE_ADL)
|
||||
endif()
|
||||
else()
|
||||
remove_definitions(/DXMRIG_FEATURE_OPENCL)
|
||||
remove_definitions(/DXMRIG_FEATURE_ADL)
|
||||
|
||||
set(HEADERS_BACKEND_OPENCL "")
|
||||
set(SOURCES_BACKEND_OPENCL "")
|
||||
|
38
src/backend/opencl/wrappers/AdlHealth.h
Normal file
38
src/backend/opencl/wrappers/AdlHealth.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* XMRig
|
||||
* Copyright 2008-2018 Advanced Micro Devices, Inc.
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ADLHEALTH_H
|
||||
#define XMRIG_ADLHEALTH_H
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
|
||||
struct AdlHealth
|
||||
{
|
||||
uint32_t clock = 0;
|
||||
uint32_t memClock = 0;
|
||||
uint32_t power = 0;
|
||||
uint32_t rpm = 0;
|
||||
uint32_t temperature = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* XMRIG_ADLHEALTH_H */
|
266
src/backend/opencl/wrappers/AdlLib.cpp
Normal file
266
src/backend/opencl/wrappers/AdlLib.cpp
Normal file
@ -0,0 +1,266 @@
|
||||
/* XMRig
|
||||
* Copyright 2008-2018 Advanced Micro Devices, Inc.
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/AdlLib.h"
|
||||
#include "3rdparty/adl/adl_sdk.h"
|
||||
#include "3rdparty/adl/adl_structures.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "backend/opencl/wrappers/OclDevice.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static std::vector<AdapterInfo> adapters;
|
||||
static uv_lib_t adlLib;
|
||||
|
||||
|
||||
static const char *kSymbolNotFound = "symbol not found";
|
||||
static const char *kADL_Main_Control_Create = "ADL_Main_Control_Create";
|
||||
static const char *kADL_Main_Control_Destroy = "ADL_Main_Control_Destroy";
|
||||
static const char *kADL_Adapter_NumberOfAdapters_Get = "ADL_Adapter_NumberOfAdapters_Get";
|
||||
static const char *kADL_Adapter_AdapterInfo_Get = "ADL_Adapter_AdapterInfo_Get";
|
||||
static const char *kADL2_Overdrive_Caps = "ADL2_Overdrive_Caps";
|
||||
static const char *kADL2_OverdriveN_FanControl_Get = "ADL2_OverdriveN_FanControl_Get";
|
||||
static const char *kADL2_New_QueryPMLogData_Get = "ADL2_New_QueryPMLogData_Get";
|
||||
static const char *kADL2_OverdriveN_Temperature_Get = "ADL2_OverdriveN_Temperature_Get";
|
||||
static const char *kADL2_OverdriveN_PerformanceStatus_Get = "ADL2_OverdriveN_PerformanceStatus_Get";
|
||||
static const char *kADL2_Overdrive6_CurrentPower_Get = "ADL2_Overdrive6_CurrentPower_Get";
|
||||
|
||||
|
||||
using ADL_MAIN_CONTROL_CREATE = int (*)(ADL_MAIN_MALLOC_CALLBACK, int);
|
||||
using ADL_MAIN_CONTROL_DESTROY = int (*)();
|
||||
using ADL_ADAPTER_NUMBEROFADAPTERS_GET = int (*)(int *);
|
||||
using ADL_ADAPTER_ADAPTERINFO_GET = int (*)(LPAdapterInfo, int);
|
||||
using ADL2_OVERDRIVE_CAPS = int (*)(ADL_CONTEXT_HANDLE, int, int *, int *, int *);
|
||||
using ADL2_OVERDRIVEN_FANCONTROL_GET = int (*)(ADL_CONTEXT_HANDLE, int, ADLODNFanControl *);
|
||||
using ADL2_NEW_QUERYPMLOGDATA_GET = int (*)(ADL_CONTEXT_HANDLE, int, ADLPMLogDataOutput *);
|
||||
using ADL2_OVERDRIVEN_TEMPERATURE_GET = int (*)(ADL_CONTEXT_HANDLE, int, int, int *);
|
||||
using ADL2_OVERDRIVEN_PERFORMANCESTATUS_GET = int (*)(ADL_CONTEXT_HANDLE, int, ADLODNPerformanceStatus *);
|
||||
using ADL2_OVERDRIVE6_CURRENTPOWER_GET = int (*)(ADL_CONTEXT_HANDLE, int, int, int *);
|
||||
|
||||
|
||||
ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create = nullptr;
|
||||
ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy = nullptr;
|
||||
ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get = nullptr;
|
||||
ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get = nullptr;
|
||||
ADL2_OVERDRIVE_CAPS ADL2_Overdrive_Caps = nullptr;
|
||||
ADL2_OVERDRIVEN_FANCONTROL_GET ADL2_OverdriveN_FanControl_Get = nullptr;
|
||||
ADL2_NEW_QUERYPMLOGDATA_GET ADL2_New_QueryPMLogData_Get = nullptr;
|
||||
ADL2_OVERDRIVEN_TEMPERATURE_GET ADL2_OverdriveN_Temperature_Get = nullptr;
|
||||
ADL2_OVERDRIVEN_PERFORMANCESTATUS_GET ADL2_OverdriveN_PerformanceStatus_Get = nullptr;
|
||||
ADL2_OVERDRIVE6_CURRENTPOWER_GET ADL2_Overdrive6_CurrentPower_Get = nullptr;
|
||||
|
||||
|
||||
#define DLSYM(x) if (uv_dlsym(&adlLib, k##x, reinterpret_cast<void**>(&(x))) == -1) { throw std::runtime_error(kSymbolNotFound); }
|
||||
|
||||
|
||||
bool AdlLib::m_initialized = false;
|
||||
bool AdlLib::m_ready = false;
|
||||
|
||||
|
||||
static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
|
||||
{
|
||||
return malloc(iSize);
|
||||
}
|
||||
|
||||
|
||||
static inline bool matchTopology(const PciTopology &topology, const AdapterInfo &adapter)
|
||||
{
|
||||
return adapter.iBusNumber > -1 && topology.bus() == adapter.iBusNumber && topology.device() == adapter.iDeviceNumber && topology.function() == adapter.iFunctionNumber;
|
||||
}
|
||||
|
||||
|
||||
static void getFan_v7(const AdapterInfo &adapter, AdlHealth &health)
|
||||
{
|
||||
ADLODNFanControl data;
|
||||
memset(&data, 0, sizeof(ADLODNFanControl));
|
||||
|
||||
if (ADL2_OverdriveN_FanControl_Get(nullptr, adapter.iAdapterIndex, &data) == ADL_OK) {
|
||||
health.rpm = data.iCurrentFanSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void getTemp_v7(const AdapterInfo &adapter, AdlHealth &health)
|
||||
{
|
||||
int temp = 0;
|
||||
if (ADL2_OverdriveN_Temperature_Get(nullptr, adapter.iAdapterIndex, 1, &temp) == ADL_OK) {
|
||||
health.temperature = temp / 1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void getClocks_v7(const AdapterInfo &adapter, AdlHealth &health)
|
||||
{
|
||||
ADLODNPerformanceStatus data;
|
||||
memset(&data, 0, sizeof(ADLODNPerformanceStatus));
|
||||
|
||||
if (ADL2_OverdriveN_PerformanceStatus_Get(nullptr, adapter.iAdapterIndex, &data) == ADL_OK) {
|
||||
health.clock = data.iCoreClock / 100;
|
||||
health.memClock = data.iMemoryClock / 100;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void getPower_v7(const AdapterInfo &adapter, AdlHealth &health)
|
||||
{
|
||||
int power = 0;
|
||||
if (ADL2_Overdrive6_CurrentPower_Get && ADL2_Overdrive6_CurrentPower_Get(nullptr, adapter.iAdapterIndex, 0, &power) == ADL_OK) {
|
||||
health.power = static_cast<uint32_t>(power / 256.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void getSensorsData_v8(const AdapterInfo &adapter, AdlHealth &health)
|
||||
{
|
||||
if (!ADL2_New_QueryPMLogData_Get) {
|
||||
return;
|
||||
}
|
||||
|
||||
ADLPMLogDataOutput data;
|
||||
memset(&data, 0, sizeof(ADLPMLogDataOutput));
|
||||
|
||||
if (ADL2_New_QueryPMLogData_Get(nullptr, adapter.iAdapterIndex, &data) != ADL_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto sensorValue = [&data](ADLSensorType type) { return data.sensors[type].supported ? data.sensors[type].value : 0; };
|
||||
|
||||
health.clock = sensorValue(PMLOG_CLK_GFXCLK);
|
||||
health.memClock = sensorValue(PMLOG_CLK_MEMCLK);
|
||||
health.power = sensorValue(PMLOG_ASIC_POWER);
|
||||
health.rpm = sensorValue(PMLOG_FAN_RPM);
|
||||
health.temperature = sensorValue(PMLOG_TEMPERATURE_HOTSPOT);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
bool xmrig::AdlLib::init()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
m_ready = dlopen() && load();
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
return m_ready;
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::AdlLib::lastError() noexcept
|
||||
{
|
||||
return uv_dlerror(&adlLib);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AdlLib::close()
|
||||
{
|
||||
if (m_ready) {
|
||||
ADL_Main_Control_Destroy();
|
||||
}
|
||||
|
||||
uv_dlclose(&adlLib);
|
||||
}
|
||||
|
||||
|
||||
AdlHealth xmrig::AdlLib::health(const OclDevice &device)
|
||||
{
|
||||
if (!isReady()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
int supported, enabled, version;
|
||||
AdlHealth health;
|
||||
|
||||
for (const auto &adapter : adapters) {
|
||||
if (matchTopology(device.topology(), adapter)) {
|
||||
if (ADL2_Overdrive_Caps(nullptr, adapter.iAdapterIndex, &supported, &enabled, &version) != ADL_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (version == 7) {
|
||||
getFan_v7(adapter, health);
|
||||
getTemp_v7(adapter, health);
|
||||
getClocks_v7(adapter, health);
|
||||
getPower_v7(adapter, health);
|
||||
}
|
||||
else if (version == 8) {
|
||||
getSensorsData_v8(adapter, health);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return health;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::AdlLib::dlopen()
|
||||
{
|
||||
return uv_dlopen("atiadlxx.dll", &adlLib) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::AdlLib::load()
|
||||
{
|
||||
try {
|
||||
DLSYM(ADL_Main_Control_Create);
|
||||
DLSYM(ADL_Main_Control_Destroy);
|
||||
DLSYM(ADL_Adapter_NumberOfAdapters_Get);
|
||||
DLSYM(ADL_Adapter_AdapterInfo_Get);
|
||||
DLSYM(ADL2_Overdrive_Caps);
|
||||
DLSYM(ADL2_OverdriveN_FanControl_Get);
|
||||
DLSYM(ADL2_OverdriveN_Temperature_Get);
|
||||
DLSYM(ADL2_OverdriveN_PerformanceStatus_Get);
|
||||
} catch (std::exception &ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
DLSYM(ADL2_Overdrive6_CurrentPower_Get);
|
||||
DLSYM(ADL2_New_QueryPMLogData_Get);
|
||||
} catch (std::exception &ex) {}
|
||||
|
||||
if (ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1) != ADL_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
if (ADL_Adapter_NumberOfAdapters_Get(&count) != ADL_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
adapters.resize(count);
|
||||
const size_t size = sizeof(adapters[0]) * adapters.size();
|
||||
memset(adapters.data(), 0, size);
|
||||
|
||||
return ADL_Adapter_AdapterInfo_Get(adapters.data(), size) == ADL_OK;
|
||||
}
|
57
src/backend/opencl/wrappers/AdlLib.h
Normal file
57
src/backend/opencl/wrappers/AdlLib.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* XMRig
|
||||
* Copyright 2008-2018 Advanced Micro Devices, Inc.
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ADLLIB_H
|
||||
#define XMRIG_ADLLIB_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/AdlHealth.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class OclDevice;
|
||||
|
||||
|
||||
class AdlLib
|
||||
{
|
||||
public:
|
||||
static bool init();
|
||||
static const char *lastError() noexcept;
|
||||
static void close();
|
||||
|
||||
static AdlHealth health(const OclDevice &device);
|
||||
|
||||
static inline bool isInitialized() noexcept { return m_initialized; }
|
||||
static inline bool isReady() noexcept { return m_ready; }
|
||||
|
||||
private:
|
||||
static bool dlopen();
|
||||
static bool load();
|
||||
|
||||
static bool m_initialized;
|
||||
static bool m_ready;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ADLLIB_H */
|
@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclDevice.h"
|
||||
|
||||
#include "backend/opencl/OclGenerator.h"
|
||||
#include "backend/opencl/OclThreads.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
@ -33,6 +32,10 @@
|
||||
#include "crypto/common/Algorithm.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
#ifdef XMRIG_FEATURE_ADL
|
||||
# include "backend/opencl/wrappers/AdlLib.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -208,5 +211,20 @@ void xmrig::OclDevice::toJSON(rapidjson::Value &out, rapidjson::Document &doc) c
|
||||
out.AddMember("bus_id", topology().toString().toJSON(doc), allocator);
|
||||
out.AddMember("cu", computeUnits(), allocator);
|
||||
out.AddMember("global_mem", static_cast<uint64_t>(globalMemSize()), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (AdlLib::isReady()) {
|
||||
auto data = AdlLib::health(*this);
|
||||
|
||||
Value health(kObjectType);
|
||||
health.AddMember("temperature", data.temperature, allocator);
|
||||
health.AddMember("power", data.power, allocator);
|
||||
health.AddMember("clock", data.clock, allocator);
|
||||
health.AddMember("mem_clock", data.memClock, allocator);
|
||||
health.AddMember("rpm", data.rpm, allocator);
|
||||
|
||||
out.AddMember("health", health, allocator);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
Reference in New Issue
Block a user