feature: add support for zeMemGet/SetAtomicAccessAttributeExp

Resolves: NEO-8219

Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
John Falkowski
2023-09-20 22:34:19 +00:00
committed by Compute-Runtime-Automation
parent 1ac37d4a49
commit 56f05303c9
24 changed files with 735 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
#include "shared/source/built_ins/sip.h"
#include "shared/source/command_stream/tag_allocation_layout.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/common_types.h"
#include "shared/source/helpers/surface_format_info.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/memory_manager/memory_banks.h"
@@ -4841,6 +4842,27 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetMemAdviseIsCalledThenUp
}
}
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetAtomicAccessIsCalledThenTrueReturned) {
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
BufferObject bo(rootDeviceIndex, mock, 3, 1, 1024, 0);
DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::UNIFIED_SHARED_MEMORY, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
EXPECT_EQ(&bo, drmAllocation.getBO());
size_t size = 16;
AtomicAccessMode mode = AtomicAccessMode::None;
EXPECT_TRUE(memoryManager.setAtomicAccess(&drmAllocation, size, mode, rootDeviceIndex));
mode = AtomicAccessMode::Device;
EXPECT_TRUE(memoryManager.setAtomicAccess(&drmAllocation, size, mode, rootDeviceIndex));
mode = AtomicAccessMode::System;
EXPECT_TRUE(memoryManager.setAtomicAccess(&drmAllocation, size, mode, rootDeviceIndex));
mode = AtomicAccessMode::Host;
EXPECT_TRUE(memoryManager.setAtomicAccess(&drmAllocation, size, mode, rootDeviceIndex));
}
TEST_F(DrmMemoryManagerTest, givenKmdMigratedSharedAllocationWithMultipleBOsWhenSetMemPrefetchIsCalledWithSubDevicesThenPrefetchBOsToTheseSubDevices) {
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
SubDeviceIdsVec subDeviceIds{0, 1};

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/helpers/common_types.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/os_interface/linux/engine_info.h"
#include "shared/source/os_interface/linux/i915_prelim.h"
@@ -143,6 +144,12 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtThenReturnSuccess)
EXPECT_EQ(1u, drm->ioctlCallsCount);
}
TEST_F(IoctlHelperPrelimFixture, givenAtomicAccessModeHostWhenCallGetAtomicAccessReturnZero) {
auto ioctlHelper = drm->getIoctlHelper();
uint32_t ret = ioctlHelper->getAtomicAccess(AtomicAccessMode::Host);
EXPECT_EQ(0u, ret);
}
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithChunkingThenGetNumOfChunks) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.PrintBOChunkingLogs.set(true);
@@ -457,6 +464,46 @@ TEST_F(IoctlHelperPrelimFixture,
EXPECT_EQ(allocation.storageInfo.numOfChunks, drm->ioctlCallsCount);
}
TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetAtomicAccessWithModeCalledThenIoctlCalled) {
drm->ioctlCallsCount = 0;
MockBufferObject bo(0u, drm.get(), 3, 0, 0, 1);
MockDrmAllocation allocation(0u, AllocationType::BUFFER, MemoryPool::LocalMemory);
allocation.bufferObjects[0] = &bo;
allocation.storageInfo.memoryBanks = 0x1;
allocation.setNumHandles(1);
size_t size = 16;
AtomicAccessMode mode = AtomicAccessMode::None;
EXPECT_TRUE(allocation.setAtomicAccess(drm.get(), size, mode));
EXPECT_EQ(1u, drm->ioctlCallsCount);
mode = AtomicAccessMode::Device;
EXPECT_TRUE(allocation.setAtomicAccess(drm.get(), size, mode));
EXPECT_EQ(2u, drm->ioctlCallsCount);
mode = AtomicAccessMode::System;
EXPECT_TRUE(allocation.setAtomicAccess(drm.get(), size, mode));
EXPECT_EQ(3u, drm->ioctlCallsCount);
mode = AtomicAccessMode::Host;
// No IOCTL call for Host mode
EXPECT_TRUE(allocation.setAtomicAccess(drm.get(), size, mode));
EXPECT_EQ(3u, drm->ioctlCallsCount);
}
TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetAtomicAccessWithNullBufferObjectThenIoctlNotCalled) {
drm->ioctlCallsCount = 0;
MockDrmAllocation allocation(0u, AllocationType::BUFFER, MemoryPool::LocalMemory);
allocation.bufferObjects[0] = nullptr;
allocation.storageInfo.memoryBanks = 0x1;
allocation.setNumHandles(1);
size_t size = 16;
AtomicAccessMode mode = AtomicAccessMode::None;
EXPECT_TRUE(allocation.setAtomicAccess(drm.get(), size, mode));
EXPECT_EQ(0u, drm->ioctlCallsCount);
}
TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetMemPrefetchSucceedsThenReturnTrue) {
SubDeviceIdsVec subDeviceIds{0};
MockBufferObject bo(0u, drm.get(), 3, 0, 0, 1);

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/helpers/common_types.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/register_offsets.h"
#include "shared/source/os_interface/linux/engine_info.h"
@@ -477,6 +478,8 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe
EXPECT_EQ(0u, xeIoctlHelper->getAtomicAdvise(false));
EXPECT_EQ(0u, xeIoctlHelper->getAtomicAccess(AtomicAccessMode::None));
EXPECT_EQ(0u, xeIoctlHelper->getPreferredLocationAdvise());
EXPECT_EQ(std::nullopt, xeIoctlHelper->getPreferredLocationRegion(PreferredLocation::None, 0));