2018-06-22 18:54:33 +08:00
|
|
|
/*
|
2025-01-13 20:18:55 +08:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-27 17:35:37 +08:00
|
|
|
#pragma once
|
2023-01-18 22:41:50 +08:00
|
|
|
#include "shared/source/debugger/debugger.h"
|
2025-01-15 00:36:45 +08:00
|
|
|
#include "shared/source/helpers/device_hierarchy_mode.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/reference_tracked_object.h"
|
2018-06-22 18:54:33 +08:00
|
|
|
|
2023-07-18 18:48:49 +08:00
|
|
|
#include <mutex>
|
2024-08-20 08:14:56 +08:00
|
|
|
#include <stdarg.h>
|
2024-03-15 21:14:45 +08:00
|
|
|
#include <string>
|
2024-08-20 08:14:56 +08:00
|
|
|
#include <thread>
|
2022-09-22 16:48:55 +08:00
|
|
|
#include <unordered_map>
|
2019-11-05 20:38:20 +08:00
|
|
|
#include <vector>
|
2018-08-01 15:06:46 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2021-07-30 17:56:58 +08:00
|
|
|
class DirectSubmissionController;
|
2025-01-21 19:30:02 +08:00
|
|
|
class UnifiedMemoryReuseCleaner;
|
2023-10-06 07:12:34 +08:00
|
|
|
class GfxCoreHelper;
|
2018-07-11 22:47:49 +08:00
|
|
|
class MemoryManager;
|
2020-03-17 14:26:46 +08:00
|
|
|
struct OsEnvironment;
|
2019-11-15 16:59:48 +08:00
|
|
|
struct RootDeviceEnvironment;
|
2018-08-21 21:47:21 +08:00
|
|
|
|
2018-06-22 18:54:33 +08:00
|
|
|
class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment> {
|
2018-07-12 17:45:02 +08:00
|
|
|
|
2018-06-27 17:35:37 +08:00
|
|
|
public:
|
2018-07-03 16:00:12 +08:00
|
|
|
ExecutionEnvironment();
|
2018-06-27 17:35:37 +08:00
|
|
|
~ExecutionEnvironment() override;
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2020-09-18 22:19:41 +08:00
|
|
|
MOCKABLE_VIRTUAL bool initializeMemoryManager();
|
2019-12-17 15:11:16 +08:00
|
|
|
void calculateMaxOsContextCount();
|
2024-08-20 08:14:56 +08:00
|
|
|
int clearErrorDescription();
|
2021-10-15 20:02:31 +08:00
|
|
|
virtual void prepareRootDeviceEnvironments(uint32_t numRootDevices);
|
2021-10-11 23:34:03 +08:00
|
|
|
void prepareRootDeviceEnvironment(const uint32_t rootDeviceIndexForReInit);
|
2021-01-25 17:24:00 +08:00
|
|
|
void parseAffinityMask();
|
2022-09-22 16:48:55 +08:00
|
|
|
void adjustCcsCount();
|
|
|
|
void adjustCcsCount(const uint32_t rootDeviceIndex) const;
|
2021-07-11 08:12:15 +08:00
|
|
|
void sortNeoDevices();
|
2025-01-15 00:36:45 +08:00
|
|
|
void setDeviceHierarchyMode(const GfxCoreHelper &gfxCoreHelper);
|
|
|
|
void setDeviceHierarchyMode(const DeviceHierarchyMode deviceHierarchyMode) {
|
|
|
|
this->deviceHierarchyMode = deviceHierarchyMode;
|
|
|
|
}
|
|
|
|
DeviceHierarchyMode getDeviceHierarchyMode() const { return deviceHierarchyMode; }
|
2023-07-11 18:55:25 +08:00
|
|
|
void adjustRootDeviceEnvironments();
|
2022-05-17 23:23:15 +08:00
|
|
|
void prepareForCleanup() const;
|
2024-03-15 21:14:45 +08:00
|
|
|
void configureCcsMode();
|
2023-01-18 22:41:50 +08:00
|
|
|
void setDebuggingMode(DebuggingMode debuggingMode) {
|
|
|
|
debuggingEnabledMode = debuggingMode;
|
2020-07-13 21:14:16 +08:00
|
|
|
}
|
2023-03-27 20:03:02 +08:00
|
|
|
DebuggingMode getDebuggingMode() const { return debuggingEnabledMode; }
|
2023-12-12 19:37:31 +08:00
|
|
|
bool isDebuggingEnabled() const { return debuggingEnabledMode != DebuggingMode::disabled; }
|
2023-01-27 20:37:09 +08:00
|
|
|
void setMetricsEnabled(bool value) {
|
|
|
|
this->metricsEnabled = value;
|
|
|
|
}
|
2024-08-20 08:14:56 +08:00
|
|
|
void getErrorDescription(const char **ppString);
|
2023-08-16 11:00:31 +08:00
|
|
|
bool getSubDeviceHierarchy(uint32_t index, std::tuple<uint32_t, uint32_t, uint32_t> *subDeviceMap);
|
2023-01-27 20:37:09 +08:00
|
|
|
bool areMetricsEnabled() { return this->metricsEnabled; }
|
2024-08-20 08:14:56 +08:00
|
|
|
int setErrorDescription(const std::string &str);
|
2023-02-28 00:53:08 +08:00
|
|
|
void setFP64EmulationEnabled() {
|
|
|
|
fp64EmulationEnabled = true;
|
|
|
|
}
|
|
|
|
bool isFP64EmulationEnabled() const { return fp64EmulationEnabled; }
|
2023-01-18 22:41:50 +08:00
|
|
|
|
2021-10-25 23:33:38 +08:00
|
|
|
DirectSubmissionController *initializeDirectSubmissionController();
|
2025-02-26 19:56:03 +08:00
|
|
|
void initializeUnifiedMemoryReuseCleaner(bool enable);
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2018-07-11 22:47:49 +08:00
|
|
|
std::unique_ptr<MemoryManager> memoryManager;
|
2025-01-21 19:30:02 +08:00
|
|
|
std::unique_ptr<UnifiedMemoryReuseCleaner> unifiedMemoryReuseCleaner;
|
2021-10-25 23:33:38 +08:00
|
|
|
std::unique_ptr<DirectSubmissionController> directSubmissionController;
|
2020-03-17 14:26:46 +08:00
|
|
|
std::unique_ptr<OsEnvironment> osEnvironment;
|
2019-11-15 16:59:48 +08:00
|
|
|
std::vector<std::unique_ptr<RootDeviceEnvironment>> rootDeviceEnvironments;
|
2021-10-11 23:34:03 +08:00
|
|
|
void releaseRootDeviceEnvironmentResources(RootDeviceEnvironment *rootDeviceEnvironment);
|
2023-08-16 11:00:31 +08:00
|
|
|
// Map of Sub Device Indicies set during Affinity Mask in the form of:
|
|
|
|
// <RootDeviceIndex, SubDeviceIndex, SubDeviceCount>
|
|
|
|
// Primarily used by the Metrics Library to communicate the actual Sub Device Index being used in queries.
|
|
|
|
std::unordered_map<uint32_t, std::tuple<uint32_t, uint32_t, uint32_t>> mapOfSubDeviceIndices;
|
2024-08-20 08:14:56 +08:00
|
|
|
std::unordered_map<std::thread::id, std::string> errorDescs;
|
|
|
|
std::mutex errorDescsMutex;
|
2020-07-13 21:14:16 +08:00
|
|
|
|
|
|
|
protected:
|
2023-06-13 23:19:02 +08:00
|
|
|
static bool comparePciIdBusNumber(std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnvironment1, std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnvironment2);
|
2022-09-22 16:48:55 +08:00
|
|
|
void parseCcsCountLimitations();
|
|
|
|
void adjustCcsCountImpl(RootDeviceEnvironment *rootDeviceEnvironment) const;
|
2022-10-26 20:41:36 +08:00
|
|
|
void configureNeoEnvironment();
|
2024-03-15 21:14:45 +08:00
|
|
|
void restoreCcsMode();
|
2023-01-27 20:37:09 +08:00
|
|
|
bool metricsEnabled = false;
|
2023-02-28 00:53:08 +08:00
|
|
|
bool fp64EmulationEnabled = false;
|
2023-01-18 22:41:50 +08:00
|
|
|
|
2025-01-16 22:25:29 +08:00
|
|
|
DeviceHierarchyMode deviceHierarchyMode = DeviceHierarchyMode::composite;
|
2023-12-12 19:37:31 +08:00
|
|
|
DebuggingMode debuggingEnabledMode = DebuggingMode::disabled;
|
2022-09-22 16:48:55 +08:00
|
|
|
std::unordered_map<uint32_t, uint32_t> rootDeviceNumCcsMap;
|
2023-07-18 18:48:49 +08:00
|
|
|
std::mutex initializeDirectSubmissionControllerMutex;
|
2025-01-21 19:30:02 +08:00
|
|
|
std::mutex initializeUnifiedMemoryReuseCleanerMutex;
|
2024-03-15 21:14:45 +08:00
|
|
|
std::vector<std::tuple<std::string, uint32_t>> deviceCcsModeVec;
|
2018-06-22 18:54:33 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|