Refactor graphics memory allocation scheme

- replace createGraphicsAllocationWithRequiredBitness with more general
methodallocateGraphicsMemoryInPreferredPool based on passed
 AllocationData
- proper flags for allocation selected based on AllocationType

- remove allocateGraphicsMemory(size_t size, size_t alignment)
and use allocateGraphicsMemory(size_t size) instead where default
alignment is sufficient, otherwise use full options version:
allocateGraphicsMemory(size_t size, size_t alignment,
 bool forcePin, bool uncacheable)

Change-Id: I2da891f372ee181253cb840568a61b33c0d71fc9
This commit is contained in:
Hoppe, Mateusz
2018-07-09 14:12:32 +02:00
committed by sys_ocldev
parent 4993a94b5b
commit 55a045ebe1
44 changed files with 609 additions and 291 deletions

View File

@@ -123,8 +123,12 @@ Buffer *Buffer::create(Context *context,
allocateMemory = false;
}
}
if (!memory) {
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(zeroCopy, allocateMemory, true, false, hostPtr, static_cast<size_t>(size), GraphicsAllocation::AllocationType::BUFFER);
}
if (allocateMemory) {
memory = memoryManager->createGraphicsAllocationWithRequiredBitness(size, nullptr, true);
if (memory) {
memoryManager->addAllocationToHostPtrManager(memory);
}
@@ -132,15 +136,11 @@ Buffer *Buffer::create(Context *context,
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_BUFFER_NEEDS_ALLOCATE_MEMORY);
}
} else {
if (!memory) {
//Host ptr was not created with clSVMAlloc - create graphic allocation
memory = memoryManager->createGraphicsAllocationWithRequiredBitness(size, hostPtr, true);
}
if (!memory && Buffer::isReadOnlyMemoryPermittedByFlags(flags)) {
memory = memoryManager->createGraphicsAllocationWithRequiredBitness(size, nullptr, true);
zeroCopy = false;
copyMemoryFromHostPtr = true;
allocateMemory = true;
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(zeroCopy, allocateMemory, true, false, nullptr, static_cast<size_t>(size), GraphicsAllocation::AllocationType::BUFFER);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -62,7 +62,8 @@ Pipe *Pipe::create(Context *context,
DEBUG_BREAK_IF(!memoryManager);
while (true) {
GraphicsAllocation *memory = memoryManager->createGraphicsAllocationWithRequiredBitness(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace, nullptr);
auto size = static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace);
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, size, GraphicsAllocation::AllocationType::PIPE);
if (!memory) {
errcodeRet = CL_OUT_OF_HOST_MEMORY;
break;