mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
feature: force stateless svm api calls
Related-to: NEO-6075 Signed-off-by: Damian Tomczak <damian.tomczak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c2f3007140
commit
82bc5256e7
@@ -101,6 +101,7 @@ set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_zebin_wrapper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_align_malloc_memory_manager.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
58
shared/test/common/mocks/mock_align_malloc_memory_manager.h
Normal file
58
shared/test/common/mocks/mock_align_malloc_memory_manager.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockAlignMallocMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
MockAlignMallocMemoryManager(ExecutionEnvironment &executionEnvironment, bool enableLocalMemory = false) : MockMemoryManager(enableLocalMemory, executionEnvironment) {
|
||||
testMallocRestrictions.minAddress = 0;
|
||||
alignMallocRestrictions = nullptr;
|
||||
alignMallocCount = 0;
|
||||
alignMallocMaxIter = 3;
|
||||
returnNullBad = false;
|
||||
returnNullGood = false;
|
||||
}
|
||||
|
||||
AlignedMallocRestrictions testMallocRestrictions;
|
||||
AlignedMallocRestrictions *alignMallocRestrictions;
|
||||
|
||||
static const uintptr_t alignMallocMinAddress = 0x100000;
|
||||
static const uintptr_t alignMallocStep = 10;
|
||||
int alignMallocMaxIter;
|
||||
int alignMallocCount;
|
||||
bool returnNullBad;
|
||||
bool returnNullGood;
|
||||
|
||||
void *alignedMallocWrapper(size_t size, size_t align) override {
|
||||
if (alignMallocCount < alignMallocMaxIter) {
|
||||
alignMallocCount++;
|
||||
if (!returnNullBad) {
|
||||
return reinterpret_cast<void *>(alignMallocMinAddress - alignMallocStep);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
alignMallocCount = 0;
|
||||
if (!returnNullGood) {
|
||||
return reinterpret_cast<void *>(alignMallocMinAddress + alignMallocStep);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
void alignedFreeWrapper(void *) override {
|
||||
alignMallocCount = 0;
|
||||
}
|
||||
|
||||
AlignedMallocRestrictions *getAlignedMallocRestrictions() override {
|
||||
return alignMallocRestrictions;
|
||||
}
|
||||
};
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/raii_gfx_core_helper.h"
|
||||
#include "shared/test/common/mocks/mock_align_malloc_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_allocation_properties.h"
|
||||
#include "shared/test/common/mocks/mock_aub_center.h"
|
||||
#include "shared/test/common/mocks/mock_aub_manager.h"
|
||||
@@ -2176,53 +2177,6 @@ TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhen
|
||||
usedAllocationAndNotGpuCompleted->updateTaskCount(csr->peekLatestFlushedTaskCount(), csr->getOsContext().getContextId());
|
||||
}
|
||||
|
||||
class MockAlignMallocMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
MockAlignMallocMemoryManager(ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) {
|
||||
testMallocRestrictions.minAddress = 0;
|
||||
alignMallocRestrictions = nullptr;
|
||||
alignMallocCount = 0;
|
||||
alignMallocMaxIter = 3;
|
||||
returnNullBad = false;
|
||||
returnNullGood = false;
|
||||
}
|
||||
|
||||
AlignedMallocRestrictions testMallocRestrictions;
|
||||
AlignedMallocRestrictions *alignMallocRestrictions;
|
||||
|
||||
static const uintptr_t alignMallocMinAddress = 0x100000;
|
||||
static const uintptr_t alignMallocStep = 10;
|
||||
int alignMallocMaxIter;
|
||||
int alignMallocCount;
|
||||
bool returnNullBad;
|
||||
bool returnNullGood;
|
||||
|
||||
void *alignedMallocWrapper(size_t size, size_t align) override {
|
||||
if (alignMallocCount < alignMallocMaxIter) {
|
||||
alignMallocCount++;
|
||||
if (!returnNullBad) {
|
||||
return reinterpret_cast<void *>(alignMallocMinAddress - alignMallocStep);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
alignMallocCount = 0;
|
||||
if (!returnNullGood) {
|
||||
return reinterpret_cast<void *>(alignMallocMinAddress + alignMallocStep);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
void alignedFreeWrapper(void *) override {
|
||||
alignMallocCount = 0;
|
||||
}
|
||||
|
||||
AlignedMallocRestrictions *getAlignedMallocRestrictions() override {
|
||||
return alignMallocRestrictions;
|
||||
}
|
||||
};
|
||||
|
||||
struct MockAlignMallocMemoryManagerTest : public MemoryAllocatorTest {
|
||||
void SetUp() override {
|
||||
MemoryAllocatorTest::SetUp();
|
||||
|
||||
Reference in New Issue
Block a user