Improve AllocationType operations: dont do bit operations on enums

Change-Id: Ie70ca9e2a93ec80b1cd655bad622db9e12abb7f7
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2018-07-19 21:34:45 +02:00
parent f487ce11a2
commit 239ebf9eab
11 changed files with 101 additions and 126 deletions

View File

@ -21,8 +21,8 @@
*/
#include "runtime/command_queue/command_queue.h"
#include "runtime/device/device.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/event/event_builder.h"
#include "runtime/helpers/get_info.h"
#include "runtime/helpers/mipmap.h"
@ -138,7 +138,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
}
if (!unmapInfo.readOnly) {
auto graphicsAllocation = transferProperties.memObj->getGraphicsAllocation();
graphicsAllocation->clearTypeAubNonWritable();
graphicsAllocation->setAubWritable(true);
}
break;
case CL_COMMAND_READ_BUFFER:

View File

@ -22,13 +22,13 @@
#include "hw_cmds.h"
#include "runtime/command_stream/aub_subcapture.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/debug_helpers.h"
#include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/string.h"
#include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/string.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include <cstring>
@ -524,7 +524,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
auto size = gfxAllocation.getUnderlyingBufferSize();
auto allocType = gfxAllocation.getAllocationType();
if ((size == 0) || gfxAllocation.isTypeAubNonWritable())
if ((size == 0) || !gfxAllocation.isAubWritable())
return false;
{
@ -549,10 +549,9 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
gfxAllocation.setLocked(false);
}
if (!!(allocType & GraphicsAllocation::AllocationType::BUFFER) ||
!!(allocType & GraphicsAllocation::AllocationType::IMAGE))
gfxAllocation.setTypeAubNonWritable();
if (allocType == GraphicsAllocation::AllocationType::BUFFER || allocType == GraphicsAllocation::AllocationType::IMAGE) {
gfxAllocation.setAubWritable(false);
}
return true;
}
@ -568,10 +567,10 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
for (auto &gfxAllocation : residencyAllocations) {
if (dumpAubNonWritable) {
gfxAllocation->clearTypeAubNonWritable();
gfxAllocation->setAubWritable(true);
}
if (!writeMemory(*gfxAllocation)) {
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || gfxAllocation->isTypeAubNonWritable()));
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable()));
}
gfxAllocation->residencyTaskCount = this->taskCount + 1;
}

View File

@ -20,10 +20,10 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/helpers/flat_batch_buffer_helper_hw.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/helpers/flat_batch_buffer_helper_hw.h"
#include "runtime/helpers/string.h"
#include "runtime/memory_manager/memory_manager.h"
namespace OCLRT {
@ -41,7 +41,7 @@ void *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(BatchBuffer &batchB
if (dispatchMode == DispatchMode::ImmediateDispatch) {
if (batchBuffer.chainedBatchBuffer) {
batchBuffer.chainedBatchBuffer->setAllocationType(batchBuffer.chainedBatchBuffer->getAllocationType() | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
batchBuffer.chainedBatchBuffer->setAubWritable(false);
auto sizeMainBatchBuffer = batchBuffer.chainedBatchBufferStartOffset - batchBuffer.startOffset;
auto flatBatchBufferSize = alignUp(sizeMainBatchBuffer + indirectPatchCommandsSize + batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), MemoryConstants::pageSize);

View File

@ -20,17 +20,17 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/mem_obj/buffer.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/validators.h"
#include "runtime/helpers/string.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/helpers/validators.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h"
@ -149,10 +149,8 @@ Buffer *Buffer::create(Context *context,
break;
}
auto allocationType = (flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS))
? GraphicsAllocation::AllocationType::BUFFER
: GraphicsAllocation::AllocationType::BUFFER | GraphicsAllocation::AllocationType::WRITABLE;
memory->setAllocationType(allocationType);
memory->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
memory->setMemObjectsAllocationWithWritableFlags(!(flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)));
DBG_LOG(LogMemoryObject, __FUNCTION__, "hostPtr:", hostPtr, "size:", size, "memoryStorage:", memory->getUnderlyingBuffer(), "GPU address:", std::hex, memory->getGpuAddress());

View File

@ -20,11 +20,15 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/mem_obj/image.h"
#include "common/compiler_support.h"
#include "igfxfmid.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/context/context.h"
#include "runtime/helpers/surface_formats.h"
#include "runtime/device/device.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/resource_info.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/basic_math.h"
#include "runtime/helpers/get_info.h"
@ -32,14 +36,10 @@
#include "runtime/helpers/mipmap.h"
#include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/string.h"
#include "runtime/mem_obj/image.h"
#include "runtime/helpers/surface_formats.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/resource_info.h"
#include "igfxfmid.h"
#include <map>
namespace OCLRT {
@ -288,10 +288,8 @@ Image *Image::create(Context *context,
break;
}
auto allocationType = (flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS))
? GraphicsAllocation::AllocationType::IMAGE
: GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::WRITABLE;
memory->setAllocationType(allocationType);
memory->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
memory->setMemObjectsAllocationWithWritableFlags(!(flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)));
DBG_LOG(LogMemoryObject, __FUNCTION__, "hostPtr:", hostPtr, "size:", memory->getUnderlyingBufferSize(), "memoryStorage:", memory->getUnderlyingBuffer(), "GPU address:", std::hex, memory->getGpuAddress());

View File

@ -66,7 +66,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
int residencyTaskCount = ObjectNotResident;
bool cpuPtrAllocated = false; // flag indicating if cpuPtr is driver-allocated
enum AllocationType {
enum class AllocationType {
UNKNOWN = 0,
BUFFER,
IMAGE,
@ -87,8 +87,6 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
SURFACE_STATE_HEAP,
DYNAMIC_STATE_HEAP,
SHARED_RESOURCE,
NON_AUB_WRITABLE = 0x40000000,
WRITABLE = 0x80000000
};
virtual ~GraphicsAllocation() = default;
@ -97,23 +95,18 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
GraphicsAllocation(void *cpuPtrIn, size_t sizeIn) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(castToUint64(cpuPtrIn)),
sharedHandle(Sharing::nonSharedResource),
allocationType(AllocationType::UNKNOWN) {}
sharedHandle(Sharing::nonSharedResource) {}
GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(gpuAddress),
sharedHandle(Sharing::nonSharedResource),
gpuBaseAddress(baseAddress),
allocationType(AllocationType::UNKNOWN) {}
gpuBaseAddress(baseAddress) {}
GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(castToUint64(cpuPtrIn)),
sharedHandle(sharedHandleIn),
allocationType(AllocationType::UNKNOWN) {}
sharedHandle(sharedHandleIn) {}
void *getUnderlyingBuffer() const { return cpuPtr; }
void setCpuPtrAndGpuAddress(void *cpuPtr, uint64_t gpuAddress) {
@ -137,12 +130,13 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
void setSize(size_t size) { this->size = size; }
osHandle peekSharedHandle() { return sharedHandle; }
void setAllocationType(uint32_t allocationType) { this->allocationType = allocationType; }
uint32_t getAllocationType() const { return allocationType; }
void setAllocationType(AllocationType allocationType) { this->allocationType = allocationType; }
AllocationType getAllocationType() const { return allocationType; }
void setTypeAubNonWritable() { this->allocationType |= GraphicsAllocation::AllocationType::NON_AUB_WRITABLE; }
void clearTypeAubNonWritable() { this->allocationType &= ~GraphicsAllocation::AllocationType::NON_AUB_WRITABLE; }
bool isTypeAubNonWritable() const { return !!(this->allocationType & GraphicsAllocation::AllocationType::NON_AUB_WRITABLE); }
void setAubWritable(bool writable) { aubWritable = writable; }
bool isAubWritable() const { return aubWritable; }
bool isMemObjectsAllocationWithWritableFlags() const { return memObjectsAllocationWithWritableFlags; }
void setMemObjectsAllocationWithWritableFlags(bool newValue) { memObjectsAllocationWithWritableFlags = newValue; }
bool isL3Capable();
void setEvictable(bool evictable) { this->evictable = evictable; }
@ -163,8 +157,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
//this variable can only be modified from SubmissionAggregator
friend class SubmissionAggregator;
uint32_t inspectionId = 0;
private:
uint32_t allocationType;
AllocationType allocationType = AllocationType::UNKNOWN;
bool aubWritable = true;
bool memObjectsAllocationWithWritableFlags = false;
};
} // namespace OCLRT

View File

@ -20,12 +20,12 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/event/event.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/buffer_fixture.h"
#include "test.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/event/event.h"
#include "test.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/buffer_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include <algorithm>
using namespace OCLRT;
@ -207,7 +207,7 @@ TEST_F(EnqueueUnmapMemObjTest, UnmapMemObjWaitEvent) {
HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBufferObjectMappedToHostPtrForWritingThenItShouldBeResetToAubWritable) {
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
ASSERT_NE(nullptr, buffer);
buffer->getGraphicsAllocation()->setTypeAubNonWritable();
buffer->getGraphicsAllocation()->setAubWritable(false);
auto mappedForWritingPtr = pCmdQ->enqueueMapBuffer(buffer.get(), CL_TRUE, CL_MAP_WRITE, 0, 8, 0, nullptr, nullptr, retVal);
ASSERT_NE(nullptr, mappedForWritingPtr);
@ -220,5 +220,5 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(buffer->getGraphicsAllocation()->isTypeAubNonWritable());
EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable());
}

View File

@ -677,7 +677,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
EXPECT_FALSE(gfxAllocation->isTypeAubNonWritable());
EXPECT_TRUE(gfxAllocation->isAubWritable());
memoryManager->freeGraphicsMemory(gfxAllocation);
}
@ -692,7 +692,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
ResidencyContainer allocationsForResidency = {gfxDefaultAllocation};
aubCsr->processResidency(&allocationsForResidency);
EXPECT_FALSE(gfxDefaultAllocation->isTypeAubNonWritable());
EXPECT_TRUE(gfxDefaultAllocation->isAubWritable());
memoryManager->freeGraphicsMemory(gfxDefaultAllocation);
}
@ -711,8 +711,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(&allocationsForResidency);
EXPECT_TRUE(gfxBufferAllocation->isTypeAubNonWritable());
EXPECT_TRUE(gfxImageAllocation->isTypeAubNonWritable());
EXPECT_FALSE(gfxBufferAllocation->isAubWritable());
EXPECT_FALSE(gfxImageAllocation->isAubWritable());
memoryManager->freeGraphicsMemory(gfxBufferAllocation);
memoryManager->freeGraphicsMemory(gfxImageAllocation);
@ -725,18 +725,20 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
gfxBufferAllocation->setAubWritable(false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
gfxImageAllocation->setAubWritable(false);
aubCsr->dumpAubNonWritable = true;
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(&allocationsForResidency);
EXPECT_FALSE(gfxBufferAllocation->isTypeAubNonWritable());
EXPECT_FALSE(gfxImageAllocation->isTypeAubNonWritable());
EXPECT_TRUE(gfxBufferAllocation->isAubWritable());
EXPECT_TRUE(gfxImageAllocation->isAubWritable());
memoryManager->freeGraphicsMemory(gfxBufferAllocation);
memoryManager->freeGraphicsMemory(gfxImageAllocation);
@ -749,18 +751,20 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
gfxBufferAllocation->setAubWritable(false);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
gfxImageAllocation->setAubWritable(false);
aubCsr->dumpAubNonWritable = false;
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(&allocationsForResidency);
EXPECT_TRUE(gfxBufferAllocation->isTypeAubNonWritable());
EXPECT_TRUE(gfxImageAllocation->isTypeAubNonWritable());
EXPECT_FALSE(gfxBufferAllocation->isAubWritable());
EXPECT_FALSE(gfxImageAllocation->isAubWritable());
memoryManager->freeGraphicsMemory(gfxBufferAllocation);
memoryManager->freeGraphicsMemory(gfxImageAllocation);
@ -785,7 +789,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxAllocation->setTypeAubNonWritable();
gfxAllocation->setAubWritable(false);
EXPECT_FALSE(aubCsr->writeMemory(*gfxAllocation));
memoryManager->freeGraphicsMemory(gfxAllocation);

View File

@ -20,25 +20,25 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "gmock/gmock.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/resource_info.h"
#include "runtime/helpers/options.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/memory_management_fixture.h"
#include "unit_tests/fixtures/platform_fixture.h"
#include "unit_tests/gen_common/matchers.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/memory_management.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_gmm_resource_info.h"
#include "unit_tests/fixtures/platform_fixture.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "runtime/helpers/options.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_gmm_resource_info.h"
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "test.h"
using namespace OCLRT;
@ -357,14 +357,11 @@ TEST_P(NoHostPtr, withBufferGraphicsAllocationReportsBufferType) {
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, buffer);
auto &allocation = *buffer->getGraphicsAllocation();
auto type = allocation.getAllocationType();
auto isTypeBuffer = !!(type & GraphicsAllocation::AllocationType::BUFFER);
EXPECT_TRUE(isTypeBuffer);
auto allocation = buffer->getGraphicsAllocation();
EXPECT_TRUE(allocation->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER);
auto isTypeWritable = !!(type & GraphicsAllocation::AllocationType::WRITABLE);
auto isBufferWritable = !(flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS));
EXPECT_EQ(isBufferWritable, isTypeWritable);
EXPECT_EQ(isBufferWritable, allocation->isMemObjectsAllocationWithWritableFlags());
delete buffer;
}

View File

@ -20,22 +20,22 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/image_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/compiler_interface/compiler_interface.h"
#include "runtime/mem_obj/image.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/mipmap.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/mem_obj/image.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/image_fixture.h"
#include "unit_tests/fixtures/memory_management_fixture.h"
#include "unit_tests/gen_common/test.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/kernel_binary_helper.h"
#include "unit_tests/helpers/memory_management.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_gmm.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/gen_common/test.h"
using namespace OCLRT;
@ -480,14 +480,11 @@ TEST_P(CreateImageNoHostPtr, withImageGraphicsAllocationReportsImageType) {
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, image);
auto &allocation = *image->getGraphicsAllocation();
auto type = allocation.getAllocationType();
auto isTypeImage = !!(type & GraphicsAllocation::AllocationType::IMAGE);
EXPECT_TRUE(isTypeImage);
auto allocation = image->getGraphicsAllocation();
EXPECT_TRUE(allocation->getAllocationType() == GraphicsAllocation::AllocationType::IMAGE);
auto isTypeWritable = !!(type & GraphicsAllocation::AllocationType::WRITABLE);
auto isImageWritable = !(flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS));
EXPECT_EQ(isImageWritable, isTypeWritable);
EXPECT_EQ(isImageWritable, allocation->isMemObjectsAllocationWithWritableFlags());
delete image;
}

View File

@ -20,24 +20,30 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "gtest/gtest.h"
#include "test.h"
#include "runtime/event/event.h"
#include "runtime/helpers/dispatch_info.h"
#include "runtime/mem_obj/image.h"
#include "runtime/utilities/tag_allocator.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/program/printf_handler.h"
#include "runtime/program/program.h"
#include "runtime/utilities/tag_allocator.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/memory_allocator_fixture.h"
#include "unit_tests/fixtures/memory_manager_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/memory_management.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/utilities/containers_tests_helpers.h"
#include "unit_tests/fixtures/memory_allocator_fixture.h"
#include "unit_tests/fixtures/memory_manager_fixture.h"
#include "unit_tests/mocks/mock_gmm.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_deferred_deleter.h"
#include "unit_tests/mocks/mock_deferrable_deletion.h"
#include "unit_tests/mocks/mock_deferred_deleter.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_gmm.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/mocks/mock_mdi.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/utilities/containers_tests_helpers.h"
#include "test.h"
#include <future>
#include <type_traits>
@ -135,16 +141,6 @@ TEST(GraphicsAllocationTest, GivenGraphicsAllocationWhenLockingThenIsLocked) {
EXPECT_NE(0ULL, gpuAddr);
}
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenChangingTypeAubNonWritableThenItIsSetCorrectly) {
GraphicsAllocation gfxAllocation((void *)0x30000, 0x1000);
gfxAllocation.setTypeAubNonWritable();
EXPECT_TRUE(gfxAllocation.isTypeAubNonWritable());
gfxAllocation.clearTypeAubNonWritable();
EXPECT_FALSE(gfxAllocation.isTypeAubNonWritable());
}
TEST_F(MemoryAllocatorTest, allocateSystem) {
auto ptr = memoryManager->allocateSystemMemory(sizeof(char), 0);
EXPECT_NE(nullptr, ptr);
@ -671,14 +667,6 @@ TEST_F(MemoryAllocatorTest, givenMemoryManagerWhenAskedFor32bitAllocationWithPtr
memoryManager->freeGraphicsMemory(allocation);
}
#include "runtime/program/program.h"
#include "runtime/program/printf_handler.h"
#include "runtime/helpers/dispatch_info.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/mocks/mock_mdi.h"
class MockPrintfHandler : public PrintfHandler {
public:
static MockPrintfHandler *create(const MultiDispatchInfo &multiDispatchInfo, Device &deviceArg) {