Files
xmrig/src/backend/cpu/interfaces/ICpuInfo.h

108 lines
3.9 KiB
C
Raw Normal View History

/* XMRig
2020-12-03 19:45:16 +07:00
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 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_CPUINFO_H
#define XMRIG_CPUINFO_H
2019-08-07 16:13:23 +07:00
#include "backend/cpu/CpuThreads.h"
2020-03-09 01:22:34 +07:00
#include "base/crypto/Algorithm.h"
2020-07-22 21:27:40 +07:00
#include "base/tools/Object.h"
2019-06-28 13:08:08 +07:00
#include "crypto/common/Assembly.h"
namespace xmrig {
class ICpuInfo
{
public:
2020-07-22 21:27:40 +07:00
XMRIG_DISABLE_COPY_MOVE(ICpuInfo)
2019-12-17 02:27:07 +07:00
enum Vendor : uint32_t {
2019-12-10 12:49:42 +07:00
VENDOR_UNKNOWN,
VENDOR_INTEL,
VENDOR_AMD
};
2019-12-17 02:27:07 +07:00
enum MsrMod : uint32_t {
MSR_MOD_NONE,
MSR_MOD_RYZEN_17H,
MSR_MOD_RYZEN_19H,
2019-12-17 02:27:07 +07:00
MSR_MOD_INTEL,
MSR_MOD_CUSTOM,
MSR_MOD_MAX
};
2020-11-14 19:55:43 +01:00
# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "intel", "custom"
2020-05-08 22:25:13 +07:00
enum Flag : uint32_t {
FLAG_AES,
FLAG_AVX2,
FLAG_AVX512F,
FLAG_BMI2,
FLAG_OSXSAVE,
FLAG_PDPE1GB,
FLAG_SSE2,
FLAG_SSSE3,
FLAG_SSE41,
2020-05-08 22:25:13 +07:00
FLAG_XOP,
FLAG_POPCNT,
FLAG_CAT_L3,
2020-12-06 17:34:01 +01:00
FLAG_VM,
2020-05-08 22:25:13 +07:00
FLAG_MAX
};
2020-07-22 21:27:40 +07:00
ICpuInfo() = default;
2019-06-28 13:08:08 +07:00
virtual ~ICpuInfo() = default;
# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__)
2019-06-29 10:25:06 +07:00
inline constexpr static bool isX64() { return true; }
# else
2019-06-29 10:25:06 +07:00
inline constexpr static bool isX64() { return false; }
# endif
virtual Assembly::Id assembly() const = 0;
2020-05-08 22:25:13 +07:00
virtual bool has(Flag feature) const = 0;
virtual bool hasAES() const = 0;
virtual bool hasAVX2() const = 0;
2020-01-21 19:44:56 +01:00
virtual bool hasBMI2() const = 0;
2019-12-05 19:39:47 +01:00
virtual bool hasOneGbPages() const = 0;
virtual bool hasCatL3() const = 0;
2020-12-06 17:34:01 +01:00
virtual bool isVM() const = 0;
virtual const char *backend() const = 0;
virtual const char *brand() const = 0;
virtual CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const = 0;
2019-12-17 02:27:07 +07:00
virtual MsrMod msrMod() const = 0;
2020-05-08 22:25:13 +07:00
virtual rapidjson::Value toJSON(rapidjson::Document &doc) const = 0;
virtual size_t cores() const = 0;
virtual size_t L2() const = 0;
virtual size_t L3() const = 0;
virtual size_t nodes() const = 0;
virtual size_t packages() const = 0;
virtual size_t threads() const = 0;
2019-12-10 12:49:42 +07:00
virtual Vendor vendor() const = 0;
virtual bool jccErratum() const = 0;
};
} /* namespace xmrig */
#endif // XMRIG_CPUINFO_H