2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-18 20:59:16 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-20 11:54:29 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-07-31 20:27:26 +08:00
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/device/device.h"
|
2018-07-09 21:03:42 +08:00
|
|
|
#include "runtime/gmm_helper/gmm.h"
|
2019-10-09 23:29:00 +08:00
|
|
|
#include "runtime/helpers/memory_properties_flags_helpers.h"
|
2018-02-13 20:20:34 +08:00
|
|
|
#include "runtime/helpers/properties_helper.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/mem_obj/mem_obj.h"
|
2018-10-29 20:26:58 +08:00
|
|
|
#include "runtime/memory_manager/allocations_list.h"
|
2018-12-03 17:05:36 +08:00
|
|
|
#include "runtime/os_interface/os_context.h"
|
2019-01-23 18:59:54 +08:00
|
|
|
#include "runtime/platform/platform.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_context.h"
|
|
|
|
#include "unit_tests/mocks/mock_deferred_deleter.h"
|
2018-12-03 17:05:36 +08:00
|
|
|
#include "unit_tests/mocks/mock_device.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
|
|
|
#include "unit_tests/mocks/mock_memory_manager.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-04 16:41:58 +08:00
|
|
|
struct MySharingHandler : public SharingHandler {
|
|
|
|
MySharingHandler(MemObj *memObj) : memObj(memObj) {
|
|
|
|
auto alloc = getAllocation();
|
|
|
|
if (alloc) {
|
|
|
|
alloc->incReuseCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MySharingHandler(GraphicsAllocation *allocation) : allocation(allocation) {
|
|
|
|
auto alloc = getAllocation();
|
|
|
|
if (alloc) {
|
|
|
|
alloc->incReuseCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void releaseReusedGraphicsAllocation() override {
|
|
|
|
auto alloc = getAllocation();
|
|
|
|
if (alloc) {
|
|
|
|
alloc->decReuseCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsAllocation *getAllocation() {
|
|
|
|
if (memObj) {
|
|
|
|
return memObj->getGraphicsAllocation();
|
|
|
|
}
|
|
|
|
return allocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemObj *memObj = nullptr;
|
|
|
|
GraphicsAllocation *allocation = nullptr;
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST(MemObj, GivenMemObjWhenInititalizedFromHostPtrThenInitializeFields) {
|
|
|
|
const size_t size = 64;
|
|
|
|
char buffer[size];
|
|
|
|
MockContext context;
|
|
|
|
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer));
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2017-12-21 07:45:38 +08:00
|
|
|
sizeof(buffer), buffer, buffer, mockAllocation, true, false, false);
|
|
|
|
|
|
|
|
EXPECT_EQ(&buffer, memObj.getCpuAddress());
|
|
|
|
EXPECT_EQ(&buffer, memObj.getHostPtr());
|
|
|
|
EXPECT_EQ(size, memObj.getSize());
|
2019-09-24 22:05:17 +08:00
|
|
|
EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), memObj.getMemoryPropertiesFlags());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-02-09 03:55:31 +08:00
|
|
|
TEST(MemObj, givenMemObjectWhenAskedForTransferToHostPtrThenDoNothing) {
|
|
|
|
const size_t size = 64;
|
|
|
|
uint8_t hostPtr[size] = {};
|
|
|
|
uint8_t expectedHostPtr[size] = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
MockContext context;
|
2018-02-09 03:55:31 +08:00
|
|
|
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr));
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-02-09 03:55:31 +08:00
|
|
|
size, hostPtr, hostPtr, mockAllocation, true, false, false);
|
|
|
|
|
|
|
|
memset(memObj.getCpuAddress(), 123, size);
|
|
|
|
memset(hostPtr, 0, size);
|
|
|
|
|
2018-02-18 05:26:28 +08:00
|
|
|
MemObjOffsetArray copyOffset = {{0, 0, 0}};
|
|
|
|
MemObjSizeArray copySize = {{size, 0, 0}};
|
|
|
|
EXPECT_THROW(memObj.transferDataToHostPtr(copySize, copyOffset), std::exception);
|
2018-02-09 03:55:31 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(memcmp(hostPtr, expectedHostPtr, size) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenMemObjectWhenAskedForTransferFromHostPtrThenDoNothing) {
|
|
|
|
const size_t size = 64;
|
|
|
|
uint8_t hostPtr[size] = {};
|
|
|
|
uint8_t expectedBufferPtr[size] = {};
|
|
|
|
MockContext context;
|
|
|
|
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr));
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_PIPE, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-02-09 03:55:31 +08:00
|
|
|
size, hostPtr, hostPtr, mockAllocation, true, false, false);
|
|
|
|
|
|
|
|
memset(memObj.getCpuAddress(), 123, size);
|
|
|
|
memset(expectedBufferPtr, 123, size);
|
|
|
|
|
2018-02-18 05:26:28 +08:00
|
|
|
MemObjOffsetArray copyOffset = {{0, 0, 0}};
|
|
|
|
MemObjSizeArray copySize = {{size, 0, 0}};
|
|
|
|
EXPECT_THROW(memObj.transferDataFromHostPtr(copySize, copyOffset), std::exception);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-09 03:55:31 +08:00
|
|
|
EXPECT_TRUE(memcmp(memObj.getCpuAddress(), expectedBufferPtr, size) == 0);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-02-13 20:20:34 +08:00
|
|
|
TEST(MemObj, givenHostPtrAndUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnHostPtr) {
|
|
|
|
uint8_t hostPtr = 0;
|
|
|
|
MockContext context;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-02-13 20:20:34 +08:00
|
|
|
1, nullptr, &hostPtr, nullptr, true, false, false);
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
EXPECT_EQ(&hostPtr, memObj.getBasePtrForMap(context.getDevice(0)->getRootDeviceIndex()));
|
2018-02-13 20:20:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenHostPtrWithoutUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnAllocatedPtr) {
|
|
|
|
uint8_t hostPtr = 0;
|
|
|
|
MockContext context;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2018-02-13 20:20:34 +08:00
|
|
|
1, nullptr, &hostPtr, nullptr, true, false, false);
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
EXPECT_NE(&hostPtr, memObj.getBasePtrForMap(context.getDevice(0)->getRootDeviceIndex()));
|
|
|
|
EXPECT_EQ(memObj.getAllocatedMapPtr(), memObj.getBasePtrForMap(context.getDevice(0)->getRootDeviceIndex()));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenMemObjWhenReleaseAllocatedPtrIsCalledTwiceThenItDoesntCrash) {
|
|
|
|
void *allocatedPtr = alignedMalloc(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
|
|
|
|
|
|
|
|
MockContext context;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2017-12-21 07:45:38 +08:00
|
|
|
1, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
|
2018-02-13 20:20:34 +08:00
|
|
|
memObj.setAllocatedMapPtr(allocatedPtr);
|
|
|
|
memObj.releaseAllocatedMapPtr();
|
|
|
|
EXPECT_EQ(nullptr, memObj.getAllocatedMapPtr());
|
|
|
|
memObj.releaseAllocatedMapPtr();
|
|
|
|
EXPECT_EQ(nullptr, memObj.getAllocatedMapPtr());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAllocationIsAddedToMemoryManagerAllocationList) {
|
|
|
|
MockContext context;
|
|
|
|
|
2019-02-18 20:59:16 +08:00
|
|
|
auto memoryManager = context.getDevice(0)->getExecutionEnvironment()->memoryManager.get();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-02-18 20:59:16 +08:00
|
|
|
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-10-22 19:29:39 +08:00
|
|
|
auto defaultEngine = context.getDevice(0)->getDefaultEngine();
|
|
|
|
allocation->updateTaskCount(2, defaultEngine.osContext->getContextId());
|
|
|
|
*(defaultEngine.commandStreamReceiver->getTagAddress()) = 1;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2017-12-21 07:45:38 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
2019-10-22 19:29:39 +08:00
|
|
|
auto &allocationList = defaultEngine.commandStreamReceiver->getTemporaryAllocations();
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
memObj.destroyGraphicsAllocation(allocation, true);
|
|
|
|
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_FALSE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAllocationIsNotAddedToMemoryManagerAllocationList) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-05-06 18:33:44 +08:00
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
2018-12-03 17:05:36 +08:00
|
|
|
MockContext context(device.get());
|
2019-01-23 18:59:54 +08:00
|
|
|
auto memoryManager = executionEnvironment->memoryManager.get();
|
2018-12-03 17:05:36 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2018-12-03 17:05:36 +08:00
|
|
|
allocation->updateTaskCount(1, device->getDefaultEngine().osContext->getContextId());
|
|
|
|
*device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 1;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2017-12-21 07:45:38 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
|
2018-12-03 17:05:36 +08:00
|
|
|
auto &allocationList = device->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations();
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
memObj.destroyGraphicsAllocation(allocation, true);
|
|
|
|
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenNotUsedGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAllocationIsNotAddedToMemoryManagerAllocationList) {
|
|
|
|
MockContext context;
|
2018-10-01 22:10:54 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2017-12-21 07:45:38 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
|
2019-10-22 19:29:39 +08:00
|
|
|
auto &allocationList = context.getDevice(0)->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations();
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
memObj.destroyGraphicsAllocation(allocation, true);
|
|
|
|
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenMemoryManagerWithoutDeviceWhenMemObjDestroysAllocationAsyncThenAllocationIsNotAddedToMemoryManagerAllocationList) {
|
|
|
|
MockContext context;
|
2018-10-01 22:10:54 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2017-12-21 07:45:38 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
|
2019-10-22 19:29:39 +08:00
|
|
|
auto &allocationList = context.getDevice(0)->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations();
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
memObj.destroyGraphicsAllocation(allocation, true);
|
|
|
|
|
2018-10-29 20:26:58 +08:00
|
|
|
EXPECT_TRUE(allocationList.peekIsEmpty());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-01-24 16:57:20 +08:00
|
|
|
TEST(MemObj, givenMemObjAndPointerToObjStorageWithProperCommandWhenCheckIfMemTransferRequiredThenReturnFalse) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2018-01-24 16:57:20 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2018-01-24 16:57:20 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
void *ptr = memObj.getCpuAddressForMemoryTransfer();
|
|
|
|
bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER);
|
|
|
|
EXPECT_FALSE(isMemTransferNeeded);
|
|
|
|
|
|
|
|
isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_READ_BUFFER);
|
|
|
|
EXPECT_FALSE(isMemTransferNeeded);
|
|
|
|
|
|
|
|
isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER_RECT);
|
|
|
|
EXPECT_FALSE(isMemTransferNeeded);
|
|
|
|
|
|
|
|
isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_READ_BUFFER_RECT);
|
|
|
|
EXPECT_FALSE(isMemTransferNeeded);
|
|
|
|
|
|
|
|
isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_IMAGE);
|
|
|
|
EXPECT_FALSE(isMemTransferNeeded);
|
|
|
|
|
|
|
|
isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_READ_IMAGE);
|
|
|
|
EXPECT_FALSE(isMemTransferNeeded);
|
|
|
|
}
|
|
|
|
TEST(MemObj, givenMemObjAndPointerToObjStorageBadCommandWhenCheckIfMemTransferRequiredThenReturnTrue) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2018-01-24 16:57:20 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2018-01-24 16:57:20 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
void *ptr = memObj.getCpuAddressForMemoryTransfer();
|
|
|
|
bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_FILL_BUFFER);
|
|
|
|
EXPECT_TRUE(isMemTransferNeeded);
|
|
|
|
}
|
|
|
|
TEST(MemObj, givenMemObjAndPointerToDiffrentStorageAndProperCommandWhenCheckIfMemTransferRequiredThenReturnTrue) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2018-01-24 16:57:20 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2018-01-24 16:57:20 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
void *ptr = (void *)0x1234;
|
|
|
|
bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER);
|
|
|
|
EXPECT_TRUE(isMemTransferNeeded);
|
2018-02-09 05:59:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenSharingHandlerWhenAskedForCpuMappingThenReturnFalse) {
|
2019-08-26 15:27:30 +08:00
|
|
|
MockContext context;
|
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2019-08-26 15:27:30 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, allocation, true, false, false);
|
2018-02-09 05:59:03 +08:00
|
|
|
memObj.setSharingHandler(new SharingHandler());
|
|
|
|
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) {
|
|
|
|
struct MyMemObj : public MemObj {
|
|
|
|
using MemObj::MemObj;
|
2019-08-26 15:27:30 +08:00
|
|
|
bool isTiledAllocation() const override { return true; }
|
2018-02-09 05:59:03 +08:00
|
|
|
};
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2018-02-09 05:59:03 +08:00
|
|
|
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
|
|
|
|
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
|
|
|
|
}
|
|
|
|
|
2018-07-09 21:03:42 +08:00
|
|
|
TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2018-07-09 21:03:42 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-09 21:03:42 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-03-12 20:24:58 +08:00
|
|
|
allocation->setDefaultGmm(new Gmm(nullptr, 1, false));
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0,
|
2018-07-09 21:03:42 +08:00
|
|
|
1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false);
|
|
|
|
|
2019-03-12 20:24:58 +08:00
|
|
|
allocation->getDefaultGmm()->isRenderCompressed = false;
|
2018-07-09 21:03:42 +08:00
|
|
|
EXPECT_TRUE(memObj.mappingOnCpuAllowed());
|
2019-03-12 20:24:58 +08:00
|
|
|
allocation->getDefaultGmm()->isRenderCompressed = true;
|
2018-07-09 21:03:42 +08:00
|
|
|
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
|
|
|
|
}
|
|
|
|
|
2018-02-09 05:59:03 +08:00
|
|
|
TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
|
2018-07-09 21:03:42 +08:00
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2018-07-09 21:03:42 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-09 21:03:42 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0,
|
2018-07-09 21:03:42 +08:00
|
|
|
64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false);
|
2018-02-09 05:59:03 +08:00
|
|
|
|
2019-08-26 15:27:30 +08:00
|
|
|
EXPECT_FALSE(memObj.isTiledAllocation());
|
2018-02-09 05:59:03 +08:00
|
|
|
EXPECT_FALSE(memObj.peekSharingHandler());
|
|
|
|
EXPECT_TRUE(memObj.mappingOnCpuAllowed());
|
|
|
|
}
|
2018-03-01 21:58:15 +08:00
|
|
|
|
2018-09-28 13:19:14 +08:00
|
|
|
TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2018-09-28 13:19:14 +08:00
|
|
|
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-09-28 13:19:14 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2019-03-12 20:24:58 +08:00
|
|
|
allocation->setDefaultGmm(new Gmm(nullptr, 1, false));
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0,
|
2018-09-28 13:19:14 +08:00
|
|
|
1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false);
|
|
|
|
|
|
|
|
EXPECT_TRUE(memObj.mappingOnCpuAllowed());
|
|
|
|
reinterpret_cast<MemoryAllocation *>(allocation)->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
|
|
|
|
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
|
|
|
|
}
|
|
|
|
|
2018-03-01 21:58:15 +08:00
|
|
|
TEST(MemObj, givenMultipleMemObjectsWithReusedGraphicsAllocationWhenDestroyedThenFreeAllocationOnce) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-03-01 21:58:15 +08:00
|
|
|
|
2018-12-12 01:56:37 +08:00
|
|
|
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
2018-03-01 21:58:15 +08:00
|
|
|
|
2019-10-09 23:29:00 +08:00
|
|
|
std::unique_ptr<MemObj> memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 1, nullptr, nullptr, allocation, true, false, false));
|
2018-03-01 21:58:15 +08:00
|
|
|
memObj1->setSharingHandler(new MySharingHandler(allocation));
|
|
|
|
|
2019-10-09 23:29:00 +08:00
|
|
|
std::unique_ptr<MemObj> memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 1, nullptr, nullptr, allocation, true, false, false));
|
2018-03-01 21:58:15 +08:00
|
|
|
memObj2->setSharingHandler(new MySharingHandler(allocation));
|
|
|
|
|
2019-10-09 23:29:00 +08:00
|
|
|
std::unique_ptr<MemObj> memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 1, nullptr, nullptr, allocation, true, false, false));
|
2018-03-01 21:58:15 +08:00
|
|
|
memObj3->setSharingHandler(new MySharingHandler(allocation));
|
|
|
|
|
2018-03-05 17:56:34 +08:00
|
|
|
EXPECT_EQ(3u, allocation->peekReuseCount());
|
2018-03-01 21:58:15 +08:00
|
|
|
|
2018-03-05 17:56:34 +08:00
|
|
|
memObj3.reset(nullptr);
|
|
|
|
EXPECT_EQ(2u, allocation->peekReuseCount());
|
|
|
|
memObj1.reset(nullptr);
|
|
|
|
EXPECT_EQ(1u, allocation->peekReuseCount());
|
2018-03-01 21:58:15 +08:00
|
|
|
|
2018-03-05 17:56:34 +08:00
|
|
|
memObj2.reset(nullptr);
|
2018-03-01 21:58:15 +08:00
|
|
|
}
|
2018-04-07 19:11:23 +08:00
|
|
|
|
|
|
|
TEST(MemObj, givenMemObjectWhenContextIsNotNullThenContextOutlivesMemobjects) {
|
|
|
|
MockContext context;
|
|
|
|
EXPECT_EQ(1, context.getRefInternalCount());
|
|
|
|
{
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, 0, {}, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false);
|
2018-04-07 19:11:23 +08:00
|
|
|
EXPECT_EQ(2, context.getRefInternalCount());
|
|
|
|
}
|
|
|
|
EXPECT_EQ(1, context.getRefInternalCount());
|
|
|
|
}
|
2018-07-04 16:41:58 +08:00
|
|
|
|
|
|
|
TEST(MemObj, givenSharedMemObjectWithNullGfxAllocationWhenSettingGfxAllocationThenSucceed) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-04 16:41:58 +08:00
|
|
|
MockGraphicsAllocation *gfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-07-04 16:41:58 +08:00
|
|
|
1, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
memObj.setSharingHandler(new MySharingHandler(&memObj));
|
|
|
|
|
|
|
|
memObj.resetGraphicsAllocation(gfxAllocation);
|
|
|
|
gfxAllocation->incReuseCount();
|
|
|
|
|
|
|
|
ASSERT_EQ(1u, gfxAllocation->peekReuseCount());
|
|
|
|
EXPECT_EQ(gfxAllocation, memObj.getGraphicsAllocation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenSharedMemObjectAndNullGfxAllocationProvidedWhenSettingGfxAllocationThenSucceed) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-04 16:41:58 +08:00
|
|
|
MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0);
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-07-04 16:41:58 +08:00
|
|
|
1, nullptr, nullptr, graphicsAllocation, true, false, false);
|
|
|
|
memObj.setSharingHandler(new MySharingHandler(&memObj));
|
|
|
|
|
|
|
|
graphicsAllocation->decReuseCount();
|
|
|
|
memObj.resetGraphicsAllocation(nullptr);
|
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, memObj.getGraphicsAllocation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenSharedMemObjectAndZeroReuseCountWhenChangingGfxAllocationThenOldAllocationIsDestroyed) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-04 16:41:58 +08:00
|
|
|
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
|
|
|
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-07-04 16:41:58 +08:00
|
|
|
1, nullptr, nullptr, oldGfxAllocation, true, false, false);
|
|
|
|
memObj.setSharingHandler(new MySharingHandler(&memObj));
|
|
|
|
|
|
|
|
oldGfxAllocation->decReuseCount();
|
|
|
|
memObj.resetGraphicsAllocation(newGfxAllocation);
|
|
|
|
newGfxAllocation->incReuseCount();
|
|
|
|
|
|
|
|
ASSERT_EQ(1u, newGfxAllocation->peekReuseCount());
|
|
|
|
EXPECT_EQ(newGfxAllocation, memObj.getGraphicsAllocation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenSharedMemObjectAndNonZeroReuseCountWhenChangingGfxAllocationThenOldAllocationIsNotDestroyed) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-04 16:41:58 +08:00
|
|
|
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
|
|
|
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-07-04 16:41:58 +08:00
|
|
|
1, nullptr, nullptr, oldGfxAllocation, true, false, false);
|
|
|
|
memObj.setSharingHandler(new MySharingHandler(&memObj));
|
|
|
|
|
|
|
|
memObj.resetGraphicsAllocation(newGfxAllocation);
|
|
|
|
newGfxAllocation->incReuseCount();
|
|
|
|
|
|
|
|
ASSERT_EQ(1u, newGfxAllocation->peekReuseCount());
|
|
|
|
EXPECT_EQ(newGfxAllocation, memObj.getGraphicsAllocation());
|
|
|
|
memoryManager.checkGpuUsageAndDestroyGraphicsAllocations(oldGfxAllocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIsDestroyed) {
|
|
|
|
MockContext context;
|
2019-03-28 22:42:23 +08:00
|
|
|
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
2019-10-16 16:59:10 +08:00
|
|
|
context.memoryManager = &memoryManager;
|
2018-07-04 16:41:58 +08:00
|
|
|
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
|
|
|
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0,
|
2018-07-04 16:41:58 +08:00
|
|
|
1, nullptr, nullptr, oldGfxAllocation, true, false, false);
|
|
|
|
|
|
|
|
memObj.resetGraphicsAllocation(newGfxAllocation);
|
|
|
|
|
|
|
|
EXPECT_EQ(newGfxAllocation, memObj.getGraphicsAllocation());
|
|
|
|
}
|
2018-08-23 00:41:52 +08:00
|
|
|
|
|
|
|
TEST(MemObj, givenGraphicsAllocationWhenCallingIsAllocDumpableThenItReturnsTheCorrectValue) {
|
2018-10-30 22:24:15 +08:00
|
|
|
MockGraphicsAllocation gfxAllocation(nullptr, 0);
|
2018-08-23 00:41:52 +08:00
|
|
|
EXPECT_FALSE(gfxAllocation.isAllocDumpable());
|
|
|
|
gfxAllocation.setAllocDumpable(true);
|
|
|
|
EXPECT_TRUE(gfxAllocation.isAllocDumpable());
|
|
|
|
}
|
2019-04-08 20:49:35 +08:00
|
|
|
|
|
|
|
TEST(MemObj, givenMemObjNotUsingHostPtrWhenGettingBasePtrTwiceReturnSameMapPtr) {
|
|
|
|
MockContext context;
|
2019-12-05 17:32:42 +08:00
|
|
|
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0);
|
2019-10-09 23:29:00 +08:00
|
|
|
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0,
|
2019-04-08 20:49:35 +08:00
|
|
|
1, nullptr, nullptr, nullptr, true, false, false);
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
void *mapPtr = memObj.getBasePtrForMap(context.getDevice(0)->getRootDeviceIndex());
|
2019-04-08 20:49:35 +08:00
|
|
|
EXPECT_NE(nullptr, mapPtr);
|
|
|
|
auto mapAllocation = memObj.getMapAllocation();
|
|
|
|
ASSERT_NE(nullptr, mapAllocation);
|
|
|
|
EXPECT_EQ(mapPtr, mapAllocation->getUnderlyingBuffer());
|
|
|
|
EXPECT_EQ(mapPtr, memObj.getAllocatedMapPtr());
|
|
|
|
}
|