mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
L0Debug - account for device bitfield
- converting physical/api thread ids should account for devicebitfield - debug events for ISA filtered - skip events for not relevant tiles Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1f6c09ba1d
commit
dd7967a05d
@@ -1380,17 +1380,19 @@ bool DeviceImp::toPhysicalSliceId(const NEO::TopologyMap &topologyMap, uint32_t
|
||||
if (topologyMap.size() == subDeviceCount && !isSubdevice) {
|
||||
uint32_t sliceId = slice;
|
||||
for (uint32_t i = 0; i < topologyMap.size(); i++) {
|
||||
if (sliceId < topologyMap.at(i).sliceIndices.size()) {
|
||||
slice = topologyMap.at(i).sliceIndices[sliceId];
|
||||
if (deviceBitfield.test(i)) {
|
||||
if (sliceId < topologyMap.at(i).sliceIndices.size()) {
|
||||
slice = topologyMap.at(i).sliceIndices[sliceId];
|
||||
|
||||
if (topologyMap.at(i).sliceIndices.size() == 1) {
|
||||
uint32_t subsliceId = subslice;
|
||||
subslice = topologyMap.at(i).subsliceIndices[subsliceId];
|
||||
if (topologyMap.at(i).sliceIndices.size() == 1) {
|
||||
uint32_t subsliceId = subslice;
|
||||
subslice = topologyMap.at(i).subsliceIndices[subsliceId];
|
||||
}
|
||||
deviceIndex = i;
|
||||
return true;
|
||||
}
|
||||
deviceIndex = i;
|
||||
return true;
|
||||
sliceId = sliceId - static_cast<uint32_t>(topologyMap.at(i).sliceIndices.size());
|
||||
}
|
||||
sliceId = sliceId - static_cast<uint32_t>(topologyMap.at(i).sliceIndices.size());
|
||||
}
|
||||
} else if (isSubdevice) {
|
||||
UNRECOVERABLE_IF(!deviceBitfield.any());
|
||||
@@ -1425,7 +1427,9 @@ bool DeviceImp::toApiSliceId(const NEO::TopologyMap &topologyMap, uint32_t &slic
|
||||
uint32_t apiSliceId = 0;
|
||||
if (!isSubdevice) {
|
||||
for (uint32_t devId = 0; devId < deviceIndex; devId++) {
|
||||
apiSliceId += static_cast<uint32_t>(topologyMap.at(devId).sliceIndices.size());
|
||||
if (deviceBitfield.test(devId)) {
|
||||
apiSliceId += static_cast<uint32_t>(topologyMap.at(devId).sliceIndices.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,11 +117,15 @@ void MultipleDevicesWithCustomHwInfo::setUp() {
|
||||
hwInfo.gtSystemInfo.MaxSubSlicesSupported = sliceCount * subsliceCount;
|
||||
hwInfo.gtSystemInfo.MaxDualSubSlicesSupported = sliceCount * subsliceCount;
|
||||
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = 1;
|
||||
ASSERT_FALSE(numSubDevices == 0 || numSubDevices > 4);
|
||||
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = numSubDevices > 0;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = numSubDevices;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile0 = 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile1 = 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileMask = 3;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile0 = numSubDevices >= 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile1 = numSubDevices >= 2;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile2 = numSubDevices >= 3;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile3 = numSubDevices == 4;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileMask = static_cast<uint8_t>(maxNBitValue(numSubDevices));
|
||||
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo);
|
||||
|
||||
@@ -134,7 +134,7 @@ struct MultipleDevicesWithCustomHwInfo {
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory;
|
||||
|
||||
const uint32_t numRootDevices = 1u;
|
||||
const uint32_t numSubDevices = 2u;
|
||||
uint32_t numSubDevices = 2u;
|
||||
};
|
||||
|
||||
struct SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl : public MultiDeviceFixture {
|
||||
|
||||
@@ -2634,6 +2634,214 @@ TEST_F(MultipleDevicesTest, givenTopologyForTwoSubdevicesWhenGettingPhysicalSlic
|
||||
EXPECT_EQ(1u, deviceIndex);
|
||||
}
|
||||
|
||||
struct MultipleDevicesAffinityTest : MultipleDevicesFixture<-1> {
|
||||
void SetUp() override {
|
||||
DebugManager.flags.ZE_AFFINITY_MASK.set("0.1,1.0");
|
||||
MultipleDevicesFixture<-1>::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
MultipleDevicesFixture<-1>::TearDown();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
};
|
||||
TEST_F(MultipleDevicesAffinityTest, givenAffinityMaskRootDeviceCorrespondingToTileWhenGettingPhysicalSliceIdThenCorrectSliceIdAndDeviceIndexIsReturned) {
|
||||
ASSERT_EQ(2u, driverHandle->devices.size());
|
||||
|
||||
L0::Device *device0 = driverHandle->devices[0];
|
||||
L0::Device *device1 = driverHandle->devices[1];
|
||||
auto hwInfo = device0->getHwInfo();
|
||||
|
||||
uint32_t subDeviceCount = numSubDevices;
|
||||
std::vector<ze_device_handle_t> subDevices0(subDeviceCount);
|
||||
auto res = device0->getSubDevices(&subDeviceCount, subDevices0.data());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_EQ(0u, subDeviceCount);
|
||||
|
||||
L0::DeviceImp *deviceImp0 = static_cast<DeviceImp *>(device0);
|
||||
L0::DeviceImp *deviceImp1 = static_cast<DeviceImp *>(device1);
|
||||
|
||||
NEO::TopologyMap map;
|
||||
TopologyMapping mapping;
|
||||
|
||||
mapping.sliceIndices.resize(hwInfo.gtSystemInfo.SliceCount);
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.sliceIndices[i] = i + 5;
|
||||
}
|
||||
|
||||
mapping.subsliceIndices.resize(hwInfo.gtSystemInfo.SubSliceCount / hwInfo.gtSystemInfo.SliceCount);
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SubSliceCount / hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.subsliceIndices[i] = i;
|
||||
}
|
||||
|
||||
map[0] = mapping;
|
||||
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.sliceIndices[i] = i + 10;
|
||||
}
|
||||
map[1] = mapping;
|
||||
|
||||
uint32_t sliceId = 0;
|
||||
uint32_t subsliceId = 1;
|
||||
uint32_t deviceIndex = 0;
|
||||
auto ret = deviceImp0->toPhysicalSliceId(map, sliceId, subsliceId, deviceIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(10u, sliceId);
|
||||
EXPECT_EQ(1u, subsliceId);
|
||||
EXPECT_EQ(1u, deviceIndex);
|
||||
|
||||
sliceId = 0;
|
||||
subsliceId = 1;
|
||||
deviceIndex = 100;
|
||||
ret = deviceImp1->toPhysicalSliceId(map, sliceId, subsliceId, deviceIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(5u, sliceId);
|
||||
EXPECT_EQ(1u, subsliceId);
|
||||
EXPECT_EQ(0u, deviceIndex);
|
||||
}
|
||||
|
||||
TEST_F(MultipleDevicesAffinityTest, givenAffinityMaskRootDeviceCorrespondingToTileWhenGettingApiSliceIdThenCorrectSliceIdsReturned) {
|
||||
ASSERT_EQ(2u, driverHandle->devices.size());
|
||||
|
||||
L0::Device *device0 = driverHandle->devices[0];
|
||||
L0::Device *device1 = driverHandle->devices[1];
|
||||
auto hwInfo = device0->getHwInfo();
|
||||
|
||||
uint32_t subDeviceCount = numSubDevices;
|
||||
std::vector<ze_device_handle_t> subDevices0(subDeviceCount);
|
||||
auto res = device0->getSubDevices(&subDeviceCount, subDevices0.data());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_EQ(0u, subDeviceCount);
|
||||
|
||||
L0::DeviceImp *deviceImp0 = static_cast<DeviceImp *>(device0);
|
||||
L0::DeviceImp *deviceImp1 = static_cast<DeviceImp *>(device1);
|
||||
|
||||
NEO::TopologyMap map;
|
||||
TopologyMapping mapping;
|
||||
|
||||
mapping.sliceIndices.resize(hwInfo.gtSystemInfo.SliceCount);
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.sliceIndices[i] = i;
|
||||
}
|
||||
|
||||
mapping.subsliceIndices.resize(hwInfo.gtSystemInfo.SubSliceCount / hwInfo.gtSystemInfo.SliceCount);
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SubSliceCount / hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.subsliceIndices[i] = i;
|
||||
}
|
||||
|
||||
map[0] = mapping;
|
||||
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.sliceIndices[i] = i + 10;
|
||||
}
|
||||
map[1] = mapping;
|
||||
|
||||
uint32_t sliceId = 10;
|
||||
uint32_t subsliceId = 0;
|
||||
uint32_t tileIndex = 1;
|
||||
auto ret = deviceImp0->toApiSliceId(map, sliceId, subsliceId, tileIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(0u, sliceId);
|
||||
|
||||
sliceId = 0;
|
||||
tileIndex = 0;
|
||||
ret = deviceImp1->toApiSliceId(map, sliceId, subsliceId, tileIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(0u, sliceId);
|
||||
}
|
||||
|
||||
TEST_F(MultipleDevicesAffinityTest, givenAffinityMaskRootDeviceCorrespondingToTileWhenMappingToAndFromApiAndPhysicalSliceIdThenIdsAreMatching) {
|
||||
ASSERT_EQ(2u, driverHandle->devices.size());
|
||||
|
||||
L0::Device *device0 = driverHandle->devices[0];
|
||||
L0::Device *device1 = driverHandle->devices[1];
|
||||
auto hwInfo = device0->getHwInfo();
|
||||
|
||||
uint32_t subDeviceCount = numSubDevices;
|
||||
std::vector<ze_device_handle_t> subDevices0(subDeviceCount);
|
||||
auto res = device0->getSubDevices(&subDeviceCount, subDevices0.data());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_EQ(0u, subDeviceCount);
|
||||
|
||||
L0::DeviceImp *deviceImp0 = static_cast<DeviceImp *>(device0);
|
||||
L0::DeviceImp *deviceImp1 = static_cast<DeviceImp *>(device1);
|
||||
|
||||
NEO::TopologyMap map;
|
||||
TopologyMapping mapping;
|
||||
|
||||
mapping.sliceIndices.resize(hwInfo.gtSystemInfo.SliceCount);
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.sliceIndices[i] = i;
|
||||
}
|
||||
|
||||
mapping.subsliceIndices.resize(hwInfo.gtSystemInfo.SubSliceCount / hwInfo.gtSystemInfo.SliceCount);
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SubSliceCount / hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.subsliceIndices[i] = i + 10;
|
||||
}
|
||||
map[0] = mapping;
|
||||
|
||||
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.SliceCount; i++) {
|
||||
mapping.sliceIndices[i] = i + 1;
|
||||
}
|
||||
map[1] = mapping;
|
||||
|
||||
uint32_t tileIndex = 1;
|
||||
|
||||
ze_device_properties_t deviceProperties = {};
|
||||
deviceImp0->getProperties(&deviceProperties);
|
||||
|
||||
for (uint32_t i = 0; i < deviceProperties.numSlices; i++) {
|
||||
uint32_t sliceId = i;
|
||||
uint32_t subsliceId = deviceProperties.numSubslicesPerSlice / 2;
|
||||
auto ret = deviceImp0->toPhysicalSliceId(map, sliceId, subsliceId, tileIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(i + 1, sliceId);
|
||||
EXPECT_EQ(1u, tileIndex);
|
||||
if (mapping.sliceIndices.size() == 1) {
|
||||
EXPECT_EQ(deviceProperties.numSubslicesPerSlice / 2 + 10u, subsliceId);
|
||||
} else {
|
||||
EXPECT_EQ(deviceProperties.numSubslicesPerSlice / 2, subsliceId);
|
||||
}
|
||||
|
||||
ret = deviceImp0->toApiSliceId(map, sliceId, subsliceId, tileIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(i, sliceId);
|
||||
EXPECT_EQ(deviceProperties.numSubslicesPerSlice / 2, subsliceId);
|
||||
}
|
||||
|
||||
deviceImp1->getProperties(&deviceProperties);
|
||||
|
||||
tileIndex = 0;
|
||||
for (uint32_t i = 0; i < deviceProperties.numSlices; i++) {
|
||||
uint32_t sliceId = i;
|
||||
uint32_t subsliceId = deviceProperties.numSubslicesPerSlice - 1;
|
||||
auto ret = deviceImp1->toPhysicalSliceId(map, sliceId, subsliceId, tileIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
EXPECT_EQ(i, sliceId);
|
||||
EXPECT_EQ(0u, tileIndex);
|
||||
if (mapping.sliceIndices.size() == 1) {
|
||||
EXPECT_EQ(deviceProperties.numSubslicesPerSlice - 1 + 10u, subsliceId);
|
||||
} else {
|
||||
EXPECT_EQ(deviceProperties.numSubslicesPerSlice - 1, subsliceId);
|
||||
}
|
||||
|
||||
ret = deviceImp1->toApiSliceId(map, sliceId, subsliceId, tileIndex);
|
||||
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(i, sliceId);
|
||||
EXPECT_EQ(deviceProperties.numSubslicesPerSlice - 1, subsliceId);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MultipleDevicesTest, givenInvalidApiSliceIdWhenGettingPhysicalSliceIdThenFalseIsReturned) {
|
||||
L0::Device *device0 = driverHandle->devices[0];
|
||||
auto hwInfo = device0->getHwInfo();
|
||||
|
||||
@@ -41,9 +41,10 @@ void DebugSession::createEuThreads() {
|
||||
|
||||
for (uint32_t tileIndex = 0; tileIndex < subDeviceCount; tileIndex++) {
|
||||
|
||||
if (isSubDevice) {
|
||||
if (isSubDevice || subDeviceCount == 1) {
|
||||
tileIndex = Math::log2(static_cast<uint32_t>(connectedDevice->getNEODevice()->getDeviceBitfield().to_ulong()));
|
||||
}
|
||||
|
||||
for (uint32_t sliceID = 0; sliceID < hwInfo.gtSystemInfo.MaxSlicesSupported; sliceID++) {
|
||||
for (uint32_t subsliceID = 0; subsliceID < numSubslicesPerSlice; subsliceID++) {
|
||||
for (uint32_t euID = 0; euID < numEuPerSubslice; euID++) {
|
||||
@@ -57,17 +58,22 @@ void DebugSession::createEuThreads() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isSubDevice || subDeviceCount == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DebugSession::getDeviceIndexFromApiThread(ze_device_thread_t thread) {
|
||||
uint32_t deviceIndex = 0;
|
||||
auto &hwInfo = connectedDevice->getHwInfo();
|
||||
auto deviceCount = std::max(1u, connectedDevice->getNEODevice()->getNumSubDevices());
|
||||
auto deviceBitfield = connectedDevice->getNEODevice()->getDeviceBitfield();
|
||||
|
||||
uint32_t deviceIndex = Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()));
|
||||
|
||||
if (connectedDevice->getNEODevice()->isSubDevice()) {
|
||||
deviceIndex = Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()));
|
||||
} else {
|
||||
@@ -502,7 +508,7 @@ ze_result_t DebugSessionImp::resume(ze_device_thread_t thread) {
|
||||
ze_result_t retVal = ZE_RESULT_SUCCESS;
|
||||
|
||||
if (singleDevice) {
|
||||
uint32_t deviceIndex = 0;
|
||||
uint32_t deviceIndex = Math::log2(static_cast<uint32_t>(connectedDevice->getNEODevice()->getDeviceBitfield().to_ulong()));
|
||||
|
||||
if (connectedDevice->getNEODevice()->isSubDevice()) {
|
||||
deviceIndex = Math::log2(static_cast<uint32_t>(connectedDevice->getNEODevice()->getDeviceBitfield().to_ulong()));
|
||||
|
||||
@@ -761,8 +761,8 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
|
||||
if (vmBind->num_uuids > 0 && vmBind->base.size > sizeof(prelim_drm_i915_debug_event_vm_bind)) {
|
||||
auto vmHandle = vmBind->vm_handle;
|
||||
uint32_t index = 0;
|
||||
auto connection = clientHandleToConnection[vmBind->client_handle].get();
|
||||
uint32_t index = 0;
|
||||
const auto uuid = vmBind->uuids[index];
|
||||
const auto tileIndex = tileSessionsEnabled ? connection->vmToTile[vmHandle] : 0;
|
||||
|
||||
@@ -794,7 +794,9 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
}
|
||||
}
|
||||
|
||||
if (connection->uuidMap[uuid].classIndex == NEO::DrmResourceClass::Isa) {
|
||||
bool handleEvent = isTileWithinDeviceBitfield(connection->vmToTile[vmBind->vm_handle]);
|
||||
|
||||
if (handleEvent && connection->uuidMap[uuid].classIndex == NEO::DrmResourceClass::Isa) {
|
||||
PRINT_DEBUGGER_INFO_LOG("ISA vm_handle = %llu, tileIndex = %lu", (uint64_t)vmHandle, tileIndex);
|
||||
|
||||
const auto isaUuidHandle = connection->uuidMap[uuid].handle;
|
||||
@@ -1099,6 +1101,10 @@ void DebugSessionLinux::handleAttentionEvent(prelim_drm_i915_debug_event_eu_atte
|
||||
return;
|
||||
}
|
||||
|
||||
if (!connectedDevice->getNEODevice()->getDeviceBitfield().test(tileIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
@@ -1617,13 +1623,13 @@ uint64_t DebugSessionLinux::getContextStateSaveAreaGpuVa(uint64_t memoryHandle)
|
||||
}
|
||||
|
||||
uint32_t DebugSessionLinux::getDeviceIndexFromApiThread(ze_device_thread_t thread) {
|
||||
uint32_t deviceIndex = 0;
|
||||
auto deviceBitfield = connectedDevice->getNEODevice()->getDeviceBitfield();
|
||||
uint32_t deviceIndex = Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()));
|
||||
auto deviceCount = std::max(1u, connectedDevice->getNEODevice()->getNumSubDevices());
|
||||
const auto &topologyMap = DrmHelper::getTopologyMap(connectedDevice);
|
||||
|
||||
if (connectedDevice->getNEODevice()->isSubDevice()) {
|
||||
auto deviceBitfield = connectedDevice->getNEODevice()->getDeviceBitfield();
|
||||
return Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()));
|
||||
return deviceIndex;
|
||||
}
|
||||
|
||||
if (deviceCount > 1) {
|
||||
@@ -1633,10 +1639,12 @@ uint32_t DebugSessionLinux::getDeviceIndexFromApiThread(ze_device_thread_t threa
|
||||
} else {
|
||||
uint32_t sliceId = thread.slice;
|
||||
for (uint32_t i = 0; i < topologyMap.size(); i++) {
|
||||
if (sliceId < topologyMap.at(i).sliceIndices.size()) {
|
||||
deviceIndex = i;
|
||||
if (deviceBitfield.test(i)) {
|
||||
if (sliceId < topologyMap.at(i).sliceIndices.size()) {
|
||||
deviceIndex = i;
|
||||
}
|
||||
sliceId = sliceId - static_cast<uint32_t>(topologyMap.at(i).sliceIndices.size());
|
||||
}
|
||||
sliceId = sliceId - static_cast<uint32_t>(topologyMap.at(i).sliceIndices.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +267,10 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
virtual uint64_t getSbaBufferGpuVa(uint64_t memoryHandle);
|
||||
void printContextVms();
|
||||
|
||||
bool isTileWithinDeviceBitfield(uint32_t tileIndex) {
|
||||
return connectedDevice->getNEODevice()->getDeviceBitfield().test(tileIndex);
|
||||
}
|
||||
|
||||
ThreadHelper internalEventThread;
|
||||
std::mutex internalEventThreadMutex;
|
||||
std::condition_variable internalEventCondition;
|
||||
|
||||
@@ -6289,5 +6289,135 @@ TEST_F(DebugApiLinuxMultitileTest, givenApiThreadAndMultipleTilesWhenGettingDevi
|
||||
EXPECT_EQ(1u, deviceIndex);
|
||||
}
|
||||
|
||||
struct AffinityMaskMultipleSubdevices : DebugApiLinuxMultiDeviceFixture {
|
||||
void setUp() {
|
||||
DebugManager.flags.ZE_AFFINITY_MASK.set("0.0,0.1,0.3");
|
||||
MultipleDevicesWithCustomHwInfo::numSubDevices = 4;
|
||||
DebugApiLinuxMultiDeviceFixture::setUp();
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
MultipleDevicesWithCustomHwInfo::tearDown();
|
||||
}
|
||||
DebugManagerStateRestore restorer;
|
||||
};
|
||||
|
||||
using AffinityMaskMultipleSubdevicesTest = Test<AffinityMaskMultipleSubdevices>;
|
||||
|
||||
TEST_F(AffinityMaskMultipleSubdevicesTest, givenApiThreadAndMultipleTilesWhenConvertingToPhysicalThenCorrectValuesReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto debugSession = std::make_unique<MockDebugSessionLinux>(config, deviceImp, 10);
|
||||
|
||||
ze_device_thread_t thread = {2 * sliceCount - 1, 0, 0, 0};
|
||||
|
||||
uint32_t deviceIndex = debugSession->getDeviceIndexFromApiThread(thread);
|
||||
EXPECT_EQ(1u, deviceIndex);
|
||||
|
||||
auto convertedThread = debugSession->convertToPhysicalWithinDevice(thread, deviceIndex);
|
||||
|
||||
EXPECT_EQ(1u, deviceIndex);
|
||||
EXPECT_EQ(sliceCount - 1, convertedThread.slice);
|
||||
EXPECT_EQ(thread.subslice, convertedThread.subslice);
|
||||
EXPECT_EQ(thread.eu, convertedThread.eu);
|
||||
EXPECT_EQ(thread.thread, convertedThread.thread);
|
||||
|
||||
thread = {3 * sliceCount - 1, 0, 0, 0};
|
||||
|
||||
deviceIndex = debugSession->getDeviceIndexFromApiThread(thread);
|
||||
EXPECT_EQ(3u, deviceIndex);
|
||||
|
||||
convertedThread = debugSession->convertToPhysicalWithinDevice(thread, deviceIndex);
|
||||
|
||||
EXPECT_EQ(3u, deviceIndex);
|
||||
EXPECT_EQ(sliceCount - 1, convertedThread.slice);
|
||||
EXPECT_EQ(thread.subslice, convertedThread.subslice);
|
||||
EXPECT_EQ(thread.eu, convertedThread.eu);
|
||||
EXPECT_EQ(thread.thread, convertedThread.thread);
|
||||
|
||||
thread = {sliceCount - 1, 0, 0, 0};
|
||||
|
||||
deviceIndex = debugSession->getDeviceIndexFromApiThread(thread);
|
||||
EXPECT_EQ(0u, deviceIndex);
|
||||
|
||||
convertedThread = debugSession->convertToPhysicalWithinDevice(thread, deviceIndex);
|
||||
|
||||
EXPECT_EQ(0u, deviceIndex);
|
||||
EXPECT_EQ(sliceCount - 1, convertedThread.slice);
|
||||
EXPECT_EQ(thread.subslice, convertedThread.subslice);
|
||||
EXPECT_EQ(thread.eu, convertedThread.eu);
|
||||
EXPECT_EQ(thread.thread, convertedThread.thread);
|
||||
|
||||
thread.slice = UINT32_MAX;
|
||||
deviceIndex = debugSession->getDeviceIndexFromApiThread(thread);
|
||||
EXPECT_EQ(UINT32_MAX, deviceIndex);
|
||||
}
|
||||
|
||||
TEST_F(AffinityMaskMultipleSubdevicesTest, GivenEventWithAckFlagAndTileNotWithinBitfieldWhenHandlingEventForISAThenIsaIsNotStoredInMapAndEventIsAcked) {
|
||||
uint64_t isaGpuVa = 0x345000;
|
||||
uint64_t isaSize = 0x2000;
|
||||
uint64_t vmBindIsaData[sizeof(prelim_drm_i915_debug_event_vm_bind) / sizeof(uint64_t) + 3 * sizeof(typeOfUUID)];
|
||||
prelim_drm_i915_debug_event_vm_bind *vmBindIsa = reinterpret_cast<prelim_drm_i915_debug_event_vm_bind *>(&vmBindIsaData);
|
||||
|
||||
auto debugSession = std::make_unique<MockDebugSessionLinux>(zet_debug_config_t{1234}, deviceImp, 10);
|
||||
auto handler = new MockIoctlHandler;
|
||||
debugSession->ioctlHandler.reset(handler);
|
||||
|
||||
vmBindIsa->base.type = PRELIM_DRM_I915_DEBUG_EVENT_VM_BIND;
|
||||
vmBindIsa->base.flags = PRELIM_DRM_I915_DEBUG_EVENT_CREATE | PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK;
|
||||
vmBindIsa->base.size = sizeof(prelim_drm_i915_debug_event_vm_bind) + 3 * sizeof(typeOfUUID);
|
||||
vmBindIsa->base.seqno = 20u;
|
||||
vmBindIsa->client_handle = MockDebugSessionLinux::mockClientHandle;
|
||||
vmBindIsa->va_start = isaGpuVa;
|
||||
vmBindIsa->va_length = isaSize;
|
||||
vmBindIsa->vm_handle = 5;
|
||||
vmBindIsa->num_uuids = 1;
|
||||
|
||||
auto *uuids = reinterpret_cast<typeOfUUID *>(ptrOffset(vmBindIsaData, sizeof(prelim_drm_i915_debug_event_vm_bind)));
|
||||
|
||||
typeOfUUID uuidsTemp[1];
|
||||
uuidsTemp[0] = static_cast<typeOfUUID>(6);
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->uuidMap[6].classIndex = NEO::DrmResourceClass::Isa;
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->vmToTile[vmBindIsa->vm_handle] = 2;
|
||||
memcpy(uuids, uuidsTemp, sizeof(uuidsTemp));
|
||||
|
||||
debugSession->handleEvent(&vmBindIsa->base);
|
||||
EXPECT_EQ(0u, debugSession->clientHandleToConnection[debugSession->clientHandle]->isaMap[0].size());
|
||||
EXPECT_EQ(0u, debugSession->clientHandleToConnection[debugSession->clientHandle]->isaMap[2].size());
|
||||
EXPECT_EQ(vmBindIsa->base.seqno, handler->debugEventAcked.seqno);
|
||||
}
|
||||
|
||||
TEST_F(AffinityMaskMultipleSubdevicesTest, GivenAttEventForTileNotWithinBitfieldWhenHandlingEventThenEventIsSkipped) {
|
||||
auto debugSession = std::make_unique<MockDebugSessionLinux>(zet_debug_config_t{1234}, deviceImp, 10);
|
||||
|
||||
uint64_t ctxHandle = 2;
|
||||
uint64_t vmHandle = 7;
|
||||
uint64_t lrcHandle = 8;
|
||||
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->contextsCreated[ctxHandle].vm = vmHandle;
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->lrcToContextHandle[lrcHandle] = ctxHandle;
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->vmToTile[vmHandle] = 2;
|
||||
|
||||
prelim_drm_i915_debug_event_eu_attention attEvent = {};
|
||||
attEvent.base.type = PRELIM_DRM_I915_DEBUG_EVENT_EU_ATTENTION;
|
||||
attEvent.base.flags = PRELIM_DRM_I915_DEBUG_EVENT_STATE_CHANGE;
|
||||
attEvent.base.size = sizeof(prelim_drm_i915_debug_event_eu_attention);
|
||||
attEvent.bitmask_size = 0;
|
||||
attEvent.client_handle = MockDebugSessionLinux::mockClientHandle;
|
||||
attEvent.lrc_handle = lrcHandle;
|
||||
attEvent.flags = 0;
|
||||
|
||||
auto engineInfo = mockDrm->getEngineInfo();
|
||||
auto ci = engineInfo->getEngineInstance(2, hwInfo.capabilityTable.defaultEngineType);
|
||||
attEvent.ci.engine_class = ci->engineClass;
|
||||
attEvent.ci.engine_instance = ci->engineInstance;
|
||||
|
||||
ze_device_thread_t thread = {0, 0, 0, UINT32_MAX};
|
||||
debugSession->pendingInterrupts.push_back(std::pair<ze_device_thread_t, bool>(thread, false));
|
||||
|
||||
debugSession->handleEvent(&attEvent.base);
|
||||
EXPECT_FALSE(debugSession->triggerEvents);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user