mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
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:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -193,4 +193,4 @@ void FlatBatchBufferHelperHw<GfxFamily>::removePipeControlData(size_t pipeContro
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace OCLRT
|
||||
}; // namespace OCLRT
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user