2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-01-05 22:24:16 +08:00
|
|
|
* Copyright (C) 2018-2022 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"
|
2022-01-05 22:24:16 +08:00
|
|
|
#include "shared/source/helpers/driver_model_type.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
2021-05-26 00:42:36 +08:00
|
|
|
#include "shared/source/os_interface/driver_info.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
|
2019-12-11 18:38:44 +08:00
|
|
|
#include <cstdint>
|
2021-06-22 22:38:37 +08:00
|
|
|
#include <limits>
|
2020-02-13 20:26:40 +08:00
|
|
|
#include <memory>
|
2020-02-17 23:14:22 +08:00
|
|
|
#include <vector>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
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
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
DriverModelType getDriverModelType() const {
|
|
|
|
return driverModelType;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-05-26 00:42:36 +08:00
|
|
|
virtual PhysicalDevicePciBusInfo getPciBusInfo() const = 0;
|
|
|
|
|
2021-06-22 22:38:37 +08:00
|
|
|
virtual size_t getMaxMemAllocSize() const {
|
|
|
|
return std::numeric_limits<size_t>::max();
|
|
|
|
}
|
|
|
|
|
2021-11-20 05:58:46 +08:00
|
|
|
virtual bool skipResourceCleanup() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-05 00:03:36 +08:00
|
|
|
virtual bool isGpuHangDetected(OsContext &osContext) = 0;
|
2022-01-21 00:56:19 +08:00
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
protected:
|
|
|
|
DriverModelType driverModelType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OSInterface : public NonCopyableClass {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2021-05-21 07:17:57 +08:00
|
|
|
virtual ~OSInterface() = default;
|
|
|
|
DriverModel *getDriverModel() const {
|
|
|
|
return driverModel.get();
|
|
|
|
};
|
|
|
|
|
|
|
|
void setDriverModel(std::unique_ptr<DriverModel> driverModel) {
|
|
|
|
this->driverModel = std::move(driverModel);
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2021-02-24 01:57:27 +08:00
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL bool isDebugAttachAvailable() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
static bool osEnabled64kbPages;
|
2018-10-12 21:20:02 +08:00
|
|
|
static bool osEnableLocalMemory;
|
2021-05-21 07:17:57 +08:00
|
|
|
static bool are64kbPagesEnabled() {
|
|
|
|
return osEnabled64kbPages;
|
|
|
|
}
|
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
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|