fix: set proper allocation in MemObj::getMemObjectInfo
Related-To: NEO-12585 Signed-off-by: Jaroslaw Warchulski <jaroslaw.warchulski@intel.com>
This commit is contained in:
parent
0ef02062c0
commit
0650b96999
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -134,7 +134,8 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName,
|
|||
cl_mem clAssociatedMemObject = static_cast<cl_mem>(this->associatedMemObject);
|
||||
cl_context ctx = nullptr;
|
||||
uint64_t internalHandle = 0llu;
|
||||
auto allocation = getMultiGraphicsAllocation().getDefaultGraphicsAllocation();
|
||||
auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex();
|
||||
auto allocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
|
||||
cl_bool usesCompression;
|
||||
|
||||
switch (paramName) {
|
||||
|
@ -204,7 +205,7 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName,
|
|||
break;
|
||||
|
||||
case CL_MEM_ALLOCATION_HANDLE_INTEL: {
|
||||
auto retVal = multiGraphicsAllocation.getDefaultGraphicsAllocation()->peekInternalHandle(this->memoryManager, internalHandle);
|
||||
auto retVal = allocation->peekInternalHandle(this->memoryManager, internalHandle);
|
||||
if (retVal != 0) {
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -479,3 +479,37 @@ TEST_F(GetMemObjectInfo, GivenFailureOnGettingInternalHandleWhenGettingMemObject
|
|||
&sizeReturned);
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
}
|
||||
|
||||
TEST_F(GetMemObjectInfo, GivenTwoRootDevicesInReverseOrderWhenGettingMemObjectInfoThenCorrectHandleIsReturned) {
|
||||
auto device1 = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr, 1));
|
||||
auto device2 = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr, 0));
|
||||
|
||||
ClDeviceVector devices;
|
||||
devices.push_back(device1.get());
|
||||
devices.push_back(device2.get());
|
||||
auto context = MockContext(devices);
|
||||
|
||||
auto graphicsAllocation1 = new MockGraphicsAllocation();
|
||||
auto graphicsAllocation2 = new MockGraphicsAllocation(1, nullptr, 0);
|
||||
graphicsAllocation2->internalHandle = 0xf00d;
|
||||
graphicsAllocation2->peekInternalHandleResult = 0;
|
||||
|
||||
MultiGraphicsAllocation multiGraphicsAllocation(1);
|
||||
multiGraphicsAllocation.addAllocation(graphicsAllocation1);
|
||||
multiGraphicsAllocation.addAllocation(graphicsAllocation2);
|
||||
|
||||
MemObj buffer(&context, CL_MEM_OBJECT_BUFFER, {}, CL_MEM_COPY_HOST_PTR, 0, 64, nullptr, nullptr, std::move(multiGraphicsAllocation), true, false, false);
|
||||
|
||||
size_t sizeReturned = 0;
|
||||
uint64_t internalHandle = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
auto retVal = buffer.getMemObjectInfo(
|
||||
CL_MEM_ALLOCATION_HANDLE_INTEL,
|
||||
sizeof(internalHandle),
|
||||
&internalHandle,
|
||||
&sizeReturned);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(sizeof(internalHandle), sizeReturned);
|
||||
EXPECT_EQ(internalHandle, graphicsAllocation2->internalHandle);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -69,7 +69,7 @@ TEST(DeviceOsTest, WhenDeviceIsCreatedThenSimultaneousInteropsIsSupported) {
|
|||
EXPECT_TRUE(pDevice->simultaneousInterops == expected);
|
||||
}
|
||||
|
||||
TEST(ApiOsTest, GivenUnupportedApiTokensWhenGettingInfoThenInvalidValueErrorIsReturned) {
|
||||
TEST(ApiOsTest, GivenUnsupportedApiTokensWhenGettingInfoThenInvalidValueErrorIsReturned) {
|
||||
MockContext context;
|
||||
MockBuffer buffer;
|
||||
|
||||
|
@ -79,8 +79,11 @@ TEST(ApiOsTest, GivenUnupportedApiTokensWhenGettingInfoThenInvalidValueErrorIsRe
|
|||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
void *paramVal = nullptr;
|
||||
buffer.context = &context;
|
||||
retVal = buffer.getMemObjectInfo(CL_MEM_D3D10_RESOURCE_KHR, sizeof(void *), paramVal, &size);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
buffer.context = nullptr;
|
||||
}
|
||||
|
||||
TEST(ApiOsTest, GivenUnsupportedApiWhenGettingDispatchThenNullIsReturned) {
|
||||
|
|
Loading…
Reference in New Issue