mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
feature: Support for ccs mode configuration via SysFs
Add support for configuring ccs mode for all applicable devices before KMD is loaded. Use ZEX_NUMBER_OF_CCS to configure ccs mode. Format is as follows: ZEX_NUMBER_OF_CCS=NumberOfCcs i,e Setting ZEX_NUMBER_OF_CCS to 4 sets ccs mode to 4 for all devices for which configuration is supported. Related-To: NEO-10378 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f496233462
commit
9736313d10
@@ -51,6 +51,7 @@ ExecutionEnvironment::~ExecutionEnvironment() {
|
||||
}
|
||||
rootDeviceEnvironments.clear();
|
||||
mapOfSubDeviceIndices.clear();
|
||||
this->restoreCcsMode();
|
||||
}
|
||||
|
||||
bool ExecutionEnvironment::initializeMemoryManager() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/utilities/reference_tracked_object.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -37,6 +38,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
void setDeviceHierarchy(const GfxCoreHelper &gfxCoreHelper);
|
||||
void adjustRootDeviceEnvironments();
|
||||
void prepareForCleanup() const;
|
||||
void configureCcsMode();
|
||||
void setDebuggingMode(DebuggingMode debuggingMode) {
|
||||
debuggingEnabledMode = debuggingMode;
|
||||
}
|
||||
@@ -77,6 +79,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
void parseCcsCountLimitations();
|
||||
void adjustCcsCountImpl(RootDeviceEnvironment *rootDeviceEnvironment) const;
|
||||
void configureNeoEnvironment();
|
||||
void restoreCcsMode();
|
||||
bool metricsEnabled = false;
|
||||
bool fp64EmulationEnabled = false;
|
||||
bool subDevicesAsDevices = false;
|
||||
@@ -85,5 +88,6 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
DebuggingMode debuggingEnabledMode = DebuggingMode::disabled;
|
||||
std::unordered_map<uint32_t, uint32_t> rootDeviceNumCcsMap;
|
||||
std::mutex initializeDirectSubmissionControllerMutex;
|
||||
std::vector<std::tuple<std::string, uint32_t>> deviceCcsModeVec;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/file_descriptor.h"
|
||||
#include "shared/source/utilities/directory.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
namespace NEO {
|
||||
|
||||
void ExecutionEnvironment::adjustRootDeviceEnvironments() {
|
||||
@@ -17,4 +22,76 @@ void ExecutionEnvironment::adjustRootDeviceEnvironments() {
|
||||
drmMemoryOperationsHandler->setRootDeviceIndex(rootDeviceIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::configureCcsMode() {
|
||||
const auto &ccsString = debugManager.flags.ZEX_NUMBER_OF_CCS.get();
|
||||
|
||||
if (ccsString.compare("default") == 0 ||
|
||||
ccsString.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *endPtr = nullptr;
|
||||
uint32_t ccsMode = static_cast<uint32_t>(std::strtoul(ccsString.c_str(), &endPtr, 10));
|
||||
if (endPtr == ccsString.c_str()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string drmPath = "/sys/class/drm";
|
||||
std::string expectedFilePrefix = drmPath + "/card";
|
||||
auto files = Directory::getFiles(drmPath.c_str());
|
||||
for (const auto &file : files) {
|
||||
if (file.find(expectedFilePrefix.c_str()) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string gtPath = file + "/gt";
|
||||
auto gtFiles = Directory::getFiles(gtPath.c_str());
|
||||
expectedFilePrefix = gtPath + "/gt";
|
||||
for (const auto >File : gtFiles) {
|
||||
if (gtFile.find(expectedFilePrefix.c_str()) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
std::string ccsFile = gtFile + "/ccs_mode";
|
||||
auto fd = FileDescriptor(ccsFile.c_str(), O_RDWR);
|
||||
if (fd < 0) {
|
||||
if ((errno == -EACCES) || (errno == -EPERM)) {
|
||||
fprintf(stderr, "No read and write permissions for %s, System administrator needs to grant permissions to allow modification of this file from user space\n", ccsFile.c_str());
|
||||
fprintf(stdout, "No read and write permissions for %s, System administrator needs to grant permissions to allow modification of this file from user space\n", ccsFile.c_str());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t ccsValue = 0;
|
||||
ssize_t ret = SysCalls::read(fd, &ccsValue, sizeof(uint32_t));
|
||||
PRINT_DEBUG_STRING(debugManager.flags.PrintDebugMessages.get() && (ret < 0), stderr, "read() on %s failed errno = %d | ret = %d \n",
|
||||
ccsFile.c_str(), errno, ret);
|
||||
|
||||
if ((ret < 0) || (ccsValue == ccsMode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = SysCalls::write(fd, &ccsMode, sizeof(uint32_t));
|
||||
} while (ret == -1 && errno == -EBUSY);
|
||||
|
||||
if (ret > 0) {
|
||||
deviceCcsModeVec.emplace_back(ccsFile, ccsValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::restoreCcsMode() {
|
||||
for (auto &[ccsFile, ccsMode] : deviceCcsModeVec) {
|
||||
auto fd = FileDescriptor(ccsFile.c_str(), O_WRONLY);
|
||||
DEBUG_BREAK_IF(fd < 0);
|
||||
if (fd > 0) {
|
||||
[[maybe_unused]] auto ret = SysCalls::write(fd, &ccsMode, sizeof(uint32_t));
|
||||
DEBUG_BREAK_IF(ret < 0);
|
||||
}
|
||||
}
|
||||
deviceCcsModeVec.clear();
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/driver_model_type.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/file_descriptor.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/utilities/directory.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -22,4 +28,75 @@ void ExecutionEnvironment::adjustRootDeviceEnvironments() {
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::configureCcsMode() {
|
||||
const auto &ccsString = debugManager.flags.ZEX_NUMBER_OF_CCS.get();
|
||||
|
||||
if (ccsString.compare("default") == 0 ||
|
||||
ccsString.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *endPtr = nullptr;
|
||||
uint32_t ccsMode = static_cast<uint32_t>(std::strtoul(ccsString.c_str(), &endPtr, 10));
|
||||
if (endPtr == ccsString.c_str()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string drmPath = "/sys/class/drm";
|
||||
std::string expectedFilePrefix = drmPath + "/card";
|
||||
auto files = Directory::getFiles(drmPath.c_str());
|
||||
for (const auto &file : files) {
|
||||
if (file.find(expectedFilePrefix.c_str()) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string gtPath = file + "/gt";
|
||||
auto gtFiles = Directory::getFiles(gtPath.c_str());
|
||||
expectedFilePrefix = gtPath + "/gt";
|
||||
for (const auto >File : gtFiles) {
|
||||
if (gtFile.find(expectedFilePrefix.c_str()) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
std::string ccsFile = gtFile + "/ccs_mode";
|
||||
auto fd = FileDescriptor(ccsFile.c_str(), O_RDWR);
|
||||
if (fd < 0) {
|
||||
if ((errno == -EACCES) || (errno == -EPERM)) {
|
||||
fprintf(stderr, "No read and write permissions for %s, System administrator needs to grant permissions to allow modification of this file from user space\n", ccsFile.c_str());
|
||||
fprintf(stdout, "No read and write permissions for %s, System administrator needs to grant permissions to allow modification of this file from user space\n", ccsFile.c_str());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t ccsValue = 0;
|
||||
ssize_t ret = SysCalls::read(fd, &ccsValue, sizeof(uint32_t));
|
||||
PRINT_DEBUG_STRING(debugManager.flags.PrintDebugMessages.get() && (ret < 0), stderr, "read() on %s failed errno = %d | ret = %d \n",
|
||||
ccsFile.c_str(), errno, ret);
|
||||
|
||||
if ((ret < 0) || (ccsValue == ccsMode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = SysCalls::write(fd, &ccsMode, sizeof(uint32_t));
|
||||
} while (ret == -1 && errno == -EBUSY);
|
||||
|
||||
if (ret > 0) {
|
||||
deviceCcsModeVec.emplace_back(ccsFile, ccsValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::restoreCcsMode() {
|
||||
for (auto &[ccsFile, ccsMode] : deviceCcsModeVec) {
|
||||
auto fd = FileDescriptor(ccsFile.c_str(), O_WRONLY);
|
||||
DEBUG_BREAK_IF(fd < 0);
|
||||
if (fd > 0) {
|
||||
[[maybe_unused]] auto ret = SysCalls::write(fd, &ccsMode, sizeof(uint32_t));
|
||||
DEBUG_BREAK_IF(ret < 0);
|
||||
}
|
||||
}
|
||||
deviceCcsModeVec.clear();
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,4 +12,10 @@ namespace NEO {
|
||||
void ExecutionEnvironment::adjustRootDeviceEnvironments() {
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::configureCcsMode() {
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::restoreCcsMode() {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user