2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2025-01-28 20:37:29 +08:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
2022-10-05 03:26:23 +08:00
|
|
|
#include "shared/source/helpers/topology_map.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
|
2023-01-10 01:14:18 +08:00
|
|
|
#include <limits>
|
2020-02-13 20:26:40 +08:00
|
|
|
#include <memory>
|
2023-01-12 00:58:04 +08:00
|
|
|
#include <string>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2023-01-10 01:14:18 +08:00
|
|
|
struct PhysicalDevicePciBusInfo;
|
|
|
|
struct PhysicalDevicePciSpeedInfo;
|
2023-10-18 16:00:43 +08:00
|
|
|
struct HardwareInfo;
|
2023-01-10 01:14:18 +08:00
|
|
|
enum class DriverModelType;
|
2020-03-17 14:26:46 +08:00
|
|
|
class ExecutionEnvironment;
|
2021-05-21 07:17:57 +08:00
|
|
|
class MemoryManager;
|
2022-02-05 00:03:36 +08:00
|
|
|
class OsContext;
|
2021-05-21 07:17:57 +08:00
|
|
|
|
2021-05-25 01:34:55 +08:00
|
|
|
class HwDeviceId : public NonCopyableClass {
|
|
|
|
public:
|
|
|
|
HwDeviceId(DriverModelType driverModel) : driverModelType(driverModel) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~HwDeviceId() = default;
|
|
|
|
|
|
|
|
DriverModelType getDriverModelType() const {
|
|
|
|
return driverModelType;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() const {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<const DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DriverModelType driverModelType;
|
|
|
|
};
|
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
class DriverModel : public NonCopyableClass {
|
|
|
|
public:
|
|
|
|
DriverModel(DriverModelType driverModelType)
|
|
|
|
: driverModelType(driverModelType) {
|
|
|
|
}
|
|
|
|
|
2021-05-25 01:34:55 +08:00
|
|
|
virtual ~DriverModel() = default;
|
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() const {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<const DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setGmmInputArgs(void *args) = 0;
|
|
|
|
|
|
|
|
virtual uint32_t getDeviceHandle() const = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2024-07-18 20:08:59 +08:00
|
|
|
MOCKABLE_VIRTUAL DriverModelType getDriverModelType() const {
|
2021-05-21 07:17:57 +08:00
|
|
|
return driverModelType;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-05-26 00:42:36 +08:00
|
|
|
virtual PhysicalDevicePciBusInfo getPciBusInfo() const = 0;
|
2022-10-14 21:02:37 +08:00
|
|
|
virtual PhysicalDevicePciSpeedInfo getPciSpeedInfo() const = 0;
|
2021-05-26 00:42:36 +08:00
|
|
|
|
2021-06-22 22:38:37 +08:00
|
|
|
virtual size_t getMaxMemAllocSize() const {
|
|
|
|
return std::numeric_limits<size_t>::max();
|
|
|
|
}
|
|
|
|
|
2022-10-20 17:51:13 +08:00
|
|
|
virtual bool isDriverAvailable() {
|
2022-05-17 23:23:15 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool skipResourceCleanup() const {
|
|
|
|
return skipResourceCleanupVar;
|
2021-11-20 05:58:46 +08:00
|
|
|
}
|
|
|
|
|
2022-07-20 01:13:51 +08:00
|
|
|
virtual void cleanup() {}
|
|
|
|
|
2022-02-05 00:03:36 +08:00
|
|
|
virtual bool isGpuHangDetected(OsContext &osContext) = 0;
|
2023-10-18 16:00:43 +08:00
|
|
|
virtual const HardwareInfo *getHardwareInfo() const = 0;
|
|
|
|
|
2022-10-05 03:26:23 +08:00
|
|
|
const TopologyMap &getTopologyMap() {
|
|
|
|
return topologyMap;
|
|
|
|
};
|
2022-01-21 00:56:19 +08:00
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
protected:
|
|
|
|
DriverModelType driverModelType;
|
2022-10-05 03:26:23 +08:00
|
|
|
TopologyMap topologyMap;
|
2022-05-17 23:23:15 +08:00
|
|
|
bool skipResourceCleanupVar = false;
|
2021-05-21 07:17:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class OSInterface : public NonCopyableClass {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2022-07-20 01:13:51 +08:00
|
|
|
virtual ~OSInterface();
|
|
|
|
DriverModel *getDriverModel() const;
|
2021-05-21 07:17:57 +08:00
|
|
|
|
2022-07-20 01:13:51 +08:00
|
|
|
void setDriverModel(std::unique_ptr<DriverModel> driverModel);
|
2021-02-24 01:57:27 +08:00
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL bool isDebugAttachAvailable() const;
|
2022-12-14 19:27:22 +08:00
|
|
|
MOCKABLE_VIRTUAL bool isLockablePointer(bool isLockable) const;
|
2025-02-04 18:24:31 +08:00
|
|
|
MOCKABLE_VIRTUAL bool isSizeWithinThresholdForStaging(size_t size, bool isIGPU) const;
|
2025-01-31 23:26:12 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getAggregatedProcessCount() const;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
static bool osEnabled64kbPages;
|
2018-10-12 21:20:02 +08:00
|
|
|
static bool osEnableLocalMemory;
|
2022-07-20 01:13:51 +08:00
|
|
|
static bool are64kbPagesEnabled();
|
2020-09-22 22:29:34 +08:00
|
|
|
static bool newResourceImplicitFlush;
|
|
|
|
static bool gpuIdleImplicitFlush;
|
2021-05-20 04:12:09 +08:00
|
|
|
static bool requiresSupportForWddmTrimNotification;
|
2020-03-17 14:26:46 +08:00
|
|
|
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
|
2021-10-11 23:34:03 +08:00
|
|
|
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevice(ExecutionEnvironment &executionEnvironment, std::string &osPciPath);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
2021-05-21 07:17:57 +08:00
|
|
|
std::unique_ptr<DriverModel> driverModel = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2022-06-15 02:22:28 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|