mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
fix: l0, disable device usm pooling on multidevice
Related-To: NEO-6893, GSD-11432 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
930cb2f25a
commit
6ec9ebd7a6
@@ -321,7 +321,9 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
|
||||
}
|
||||
}
|
||||
|
||||
if (this->devices.size() == 0) {
|
||||
this->numDevices = static_cast<uint32_t>(this->devices.size());
|
||||
|
||||
if (this->numDevices == 0) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
@@ -329,17 +331,16 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
|
||||
if (this->svmAllocsManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
if (this->devices.size() == 1) {
|
||||
if (this->numDevices == 1) {
|
||||
this->svmAllocsManager->initUsmAllocationsCaches(*this->devices[0]->getNEODevice());
|
||||
}
|
||||
this->initHostUsmAllocPool();
|
||||
for (auto &device : this->devices) {
|
||||
this->initDeviceUsmAllocPool(*device->getNEODevice());
|
||||
this->initDeviceUsmAllocPool(*device->getNEODevice(), this->numDevices > 1);
|
||||
if (auto deviceUsmAllocPoolsManager = device->getNEODevice()->getUsmMemAllocPoolsManager()) {
|
||||
deviceUsmAllocPoolsManager->ensureInitialized(this->svmAllocsManager);
|
||||
}
|
||||
}
|
||||
this->numDevices = static_cast<uint32_t>(this->devices.size());
|
||||
|
||||
uuidTimestamp = static_cast<uint64_t>(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
|
||||
@@ -402,11 +403,12 @@ void DriverHandleImp::initHostUsmAllocPool() {
|
||||
}
|
||||
}
|
||||
|
||||
void DriverHandleImp::initDeviceUsmAllocPool(NEO::Device &device) {
|
||||
void DriverHandleImp::initDeviceUsmAllocPool(NEO::Device &device, bool multiDevice) {
|
||||
bool enabled = NEO::ApiSpecificConfig::isDeviceUsmPoolingEnabled() &&
|
||||
device.getProductHelper().isDeviceUsmPoolAllocatorSupported() &&
|
||||
nullptr == device.getL0Debugger() &&
|
||||
NEO::DeviceFactory::isHwModeSelected();
|
||||
NEO::DeviceFactory::isHwModeSelected() &&
|
||||
!multiDevice;
|
||||
auto poolParams = NEO::UsmPoolParams::getUsmPoolParams();
|
||||
if (NEO::debugManager.flags.EnableDeviceUsmAllocationPool.get() != -1) {
|
||||
enabled = NEO::debugManager.flags.EnableDeviceUsmAllocationPool.get() > 0;
|
||||
|
||||
@@ -109,7 +109,7 @@ struct DriverHandleImp : public DriverHandle {
|
||||
std::map<uint64_t, IpcHandleTracking *> &getIPCHandleMap() { return this->ipcHandles; };
|
||||
[[nodiscard]] std::unique_lock<std::mutex> lockIPCHandleMap() { return std::unique_lock<std::mutex>(this->ipcHandleMapMutex); };
|
||||
void initHostUsmAllocPool();
|
||||
void initDeviceUsmAllocPool(NEO::Device &device);
|
||||
void initDeviceUsmAllocPool(NEO::Device &device, bool multiDevice);
|
||||
|
||||
std::unique_ptr<HostPointerManager> hostPointerManager;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ struct L0UltHelper {
|
||||
static void initUsmAllocPools(DriverHandleImp *driverHandle) {
|
||||
driverHandle->initHostUsmAllocPool();
|
||||
for (auto device : driverHandle->devices) {
|
||||
driverHandle->initDeviceUsmAllocPool(*device->getNEODevice());
|
||||
driverHandle->initDeviceUsmAllocPool(*device->getNEODevice(), driverHandle->numDevices > 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
template <int hostUsmPoolFlag = -1, int deviceUsmPoolFlag = -1, int poolingVersionFlag = -1>
|
||||
template <int hostUsmPoolFlag = -1, int deviceUsmPoolFlag = -1, int poolingVersionFlag = -1, bool multiDevice = false, bool initDriver = true>
|
||||
struct AllocUsmPoolMemoryTest : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
NEO::debugManager.flags.EnableHostUsmAllocationPool.set(hostUsmPoolFlag);
|
||||
@@ -42,7 +42,7 @@ struct AllocUsmPoolMemoryTest : public ::testing::Test {
|
||||
mockProductHelpers[i]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
}
|
||||
}
|
||||
std::vector<std::unique_ptr<NEO::Device>> devices;
|
||||
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
auto device = std::unique_ptr<NEO::MockDevice>(NEO::MockDevice::createWithExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(),
|
||||
executionEnvironment, i));
|
||||
@@ -51,10 +51,15 @@ struct AllocUsmPoolMemoryTest : public ::testing::Test {
|
||||
devices.push_back(std::move(device));
|
||||
}
|
||||
|
||||
if constexpr (initDriver) {
|
||||
initDriverImp();
|
||||
}
|
||||
}
|
||||
|
||||
void initDriverImp() {
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
l0Devices[0] = driverHandle->devices[0];
|
||||
l0Devices[1] = driverHandle->devices[1];
|
||||
std::copy(driverHandle->devices.begin(), driverHandle->devices.end(), l0Devices);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0};
|
||||
@@ -64,7 +69,9 @@ struct AllocUsmPoolMemoryTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
if constexpr (initDriver) {
|
||||
context->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void setMaxMemoryUsed(NEO::Device &device) {
|
||||
@@ -76,15 +83,16 @@ struct AllocUsmPoolMemoryTest : public ::testing::Test {
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
const uint32_t numRootDevices = 2u;
|
||||
constexpr static uint32_t numRootDevices = multiDevice ? 2u : 1u;
|
||||
L0::ContextImp *context = nullptr;
|
||||
std::vector<MockProductHelper *> mockProductHelpers;
|
||||
NEO::ExecutionEnvironment *executionEnvironment;
|
||||
L0::Device *l0Devices[2];
|
||||
std::vector<std::unique_ptr<NEO::Device>> devices;
|
||||
L0::Device *l0Devices[numRootDevices];
|
||||
constexpr static auto poolAllocationThreshold = 1 * MemoryConstants::megaByte;
|
||||
};
|
||||
|
||||
using AllocUsmHostDefaultMemoryTest = AllocUsmPoolMemoryTest<-1, -1>;
|
||||
using AllocUsmHostDefaultMemoryTest = AllocUsmPoolMemoryTest<-1, -1, -1, true>;
|
||||
TEST_F(AllocUsmHostDefaultMemoryTest, givenDriverHandleWhenCallinginitHostUsmAllocPoolThenInitIfEnabledForAllDevicesAndNoDebugger) {
|
||||
driverHandle->usmHostMemAllocPool.cleanup();
|
||||
mockProductHelpers[0]->isHostUsmPoolAllocatorSupportedResult = false;
|
||||
@@ -285,7 +293,7 @@ TEST_F(AllocUsmDeviceDefaultMemoryTest, givenDeviceWhenCallingInitDeviceUsmAlloc
|
||||
neoDevice->resetUsmAllocationPool(nullptr);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(nullptr);
|
||||
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice);
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice, numRootDevices > 1);
|
||||
EXPECT_NE(nullptr, neoDevice->getUsmMemAllocPool());
|
||||
}
|
||||
for (int32_t csrType = 0; csrType < static_cast<int32_t>(CommandStreamReceiverType::typesNum); ++csrType) {
|
||||
@@ -295,7 +303,7 @@ TEST_F(AllocUsmDeviceDefaultMemoryTest, givenDeviceWhenCallingInitDeviceUsmAlloc
|
||||
neoDevice->resetUsmAllocationPool(nullptr);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(nullptr);
|
||||
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice);
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice, numRootDevices > 1);
|
||||
EXPECT_EQ(NEO::DeviceFactory::isHwModeSelected(), nullptr != neoDevice->getUsmMemAllocPool());
|
||||
}
|
||||
{
|
||||
@@ -303,7 +311,7 @@ TEST_F(AllocUsmDeviceDefaultMemoryTest, givenDeviceWhenCallingInitDeviceUsmAlloc
|
||||
neoDevice->resetUsmAllocationPool(nullptr);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(nullptr);
|
||||
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = false;
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice);
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice, numRootDevices > 1);
|
||||
EXPECT_EQ(nullptr, neoDevice->getUsmMemAllocPool());
|
||||
}
|
||||
{
|
||||
@@ -312,11 +320,35 @@ TEST_F(AllocUsmDeviceDefaultMemoryTest, givenDeviceWhenCallingInitDeviceUsmAlloc
|
||||
neoDevice->resetUsmAllocationPool(nullptr);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(debuggerL0.release());
|
||||
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice);
|
||||
driverHandle->initDeviceUsmAllocPool(*neoDevice, numRootDevices > 1);
|
||||
EXPECT_EQ(nullptr, neoDevice->getUsmMemAllocPool());
|
||||
}
|
||||
}
|
||||
|
||||
using AllocUsmMultiDeviceDefaultMemoryTest = AllocUsmPoolMemoryTest<-1, -1, -1, true, false>;
|
||||
TEST_F(AllocUsmMultiDeviceDefaultMemoryTest, givenMultiDeviceWhenInitializingDriverHandleThenDeviceUsmPoolNotInitialized) {
|
||||
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
mockProductHelpers[1]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
initDriverImp();
|
||||
{
|
||||
EXPECT_EQ(nullptr, l0Devices[0]->getNEODevice()->getUsmMemAllocPool());
|
||||
EXPECT_EQ(nullptr, l0Devices[1]->getNEODevice()->getUsmMemAllocPool());
|
||||
}
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
using AllocUsmMultiDeviceEnabledMemoryTest = AllocUsmPoolMemoryTest<0, 1, -1, true, false>;
|
||||
TEST_F(AllocUsmMultiDeviceEnabledMemoryTest, givenMultiDeviceWhenInitializingDriverHandleThenDeviceUsmPoolInitialized) {
|
||||
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
mockProductHelpers[1]->isDeviceUsmPoolAllocatorSupportedResult = true;
|
||||
initDriverImp();
|
||||
{
|
||||
EXPECT_NE(nullptr, l0Devices[0]->getNEODevice()->getUsmMemAllocPool());
|
||||
EXPECT_NE(nullptr, l0Devices[1]->getNEODevice()->getUsmMemAllocPool());
|
||||
}
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
using AllocUsmDeviceDisabledMemoryTest = AllocUsmPoolMemoryTest<-1, 0>;
|
||||
|
||||
TEST_F(AllocUsmDeviceDisabledMemoryTest, givenDeviceWhenCallingAllocDeviceMemThenDoNotUsePool) {
|
||||
|
||||
Reference in New Issue
Block a user