mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
GTPinFree to check for buffer in shared memory
Related-To: NEO-5667 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
52308244a6
commit
2f4f5a22ae
@@ -2525,6 +2525,46 @@ TEST_F(GTPinTestsWithLocalMemory, whenPlatformHasNoSvmSupportThenGtPinBufferCant
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(GTPinTestsWithLocalMemory, givenGtPinWithSupportForSharedAllocationWhenGtPinHelperFunctionsAreCalledThenCheckIfSharedAllocationCabBeUsed) {
|
||||
GTPinHwHelper >pinHelper = GTPinHwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
|
||||
if (!gtpinHelper.canUseSharedAllocation(pDevice->getHardwareInfo())) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
class MockGTPinHwHelperHw : public GTPinHwHelperHw<FamilyType> {
|
||||
public:
|
||||
bool canUseSharedAllocation(const HardwareInfo &hwInfo) const override {
|
||||
canUseSharedAllocationCalled = true;
|
||||
return true;
|
||||
}
|
||||
mutable bool canUseSharedAllocationCalled = false;
|
||||
};
|
||||
|
||||
const auto family = pDevice->getHardwareInfo().platform.eRenderCoreFamily;
|
||||
MockGTPinHwHelperHw mockGTPinHwHelperHw;
|
||||
VariableBackup<GTPinHwHelper *> gtpinHwHelperBackup{>pinHwHelperFactory[family], &mockGTPinHwHelperHw};
|
||||
|
||||
resource_handle_t resource = nullptr;
|
||||
cl_context ctxt = (cl_context)((Context *)pContext);
|
||||
|
||||
mockGTPinHwHelperHw.canUseSharedAllocationCalled = false;
|
||||
gtpinCreateBuffer((gtpin::context_handle_t)ctxt, 256, &resource);
|
||||
EXPECT_TRUE(mockGTPinHwHelperHw.canUseSharedAllocationCalled);
|
||||
|
||||
mockGTPinHwHelperHw.canUseSharedAllocationCalled = false;
|
||||
uint8_t *address = nullptr;
|
||||
gtpinMapBuffer((gtpin::context_handle_t)ctxt, resource, &address);
|
||||
EXPECT_TRUE(mockGTPinHwHelperHw.canUseSharedAllocationCalled);
|
||||
|
||||
mockGTPinHwHelperHw.canUseSharedAllocationCalled = false;
|
||||
gtpinUnmapBuffer((gtpin::context_handle_t)ctxt, resource);
|
||||
EXPECT_TRUE(mockGTPinHwHelperHw.canUseSharedAllocationCalled);
|
||||
|
||||
mockGTPinHwHelperHw.canUseSharedAllocationCalled = false;
|
||||
gtpinFreeBuffer((gtpin::context_handle_t)ctxt, resource);
|
||||
EXPECT_TRUE(mockGTPinHwHelperHw.canUseSharedAllocationCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(GTPinTestsWithLocalMemory, givenGtPinCanUseSharedAllocationWhenGtPinBufferIsCreatedThenAllocateBufferInSharedMemory) {
|
||||
GTPinHwHelper >pinHelper = GTPinHwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
|
||||
if (!gtpinHelper.canUseSharedAllocation(pDevice->getHardwareInfo())) {
|
||||
|
||||
Reference in New Issue
Block a user