Files
compute-runtime/shared/source/memory_manager/graphics_allocation.cpp
kamdiedrich e072275ae6 Reorganization directory structure [3/n]
Change-Id: If3dfa3f6007f8810a6a1ae1a4f0c7da38544648d
2020-02-23 23:48:28 +01:00

74 lines
2.3 KiB
C++

/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "graphics_allocation.h"
#include "helpers/aligned_memory.h"
#include "memory_manager/memory_manager.h"
#include "opencl/source/utilities/logger.h"
namespace NEO {
void GraphicsAllocation::setAllocationType(AllocationType allocationType) {
this->allocationType = allocationType;
FileLoggerInstance().logAllocation(this);
}
GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress,
size_t sizeIn, MemoryPool::Type pool)
: rootDeviceIndex(rootDeviceIndex),
gpuBaseAddress(baseAddress),
gpuAddress(gpuAddress),
size(sizeIn),
cpuPtr(cpuPtrIn),
memoryPool(pool),
allocationType(allocationType),
usageInfos(MemoryManager::maxOsContextCount) {
}
GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn,
MemoryPool::Type pool)
: rootDeviceIndex(rootDeviceIndex),
gpuAddress(castToUint64(cpuPtrIn)),
size(sizeIn),
cpuPtr(cpuPtrIn),
memoryPool(pool),
allocationType(allocationType),
usageInfos(MemoryManager::maxOsContextCount) {
sharingInfo.sharedHandle = sharedHandleIn;
}
GraphicsAllocation::~GraphicsAllocation() = default;
void GraphicsAllocation::updateTaskCount(uint32_t newTaskCount, uint32_t contextId) {
if (usageInfos[contextId].taskCount == objectNotUsed) {
registeredContextsNum++;
}
if (newTaskCount == objectNotUsed) {
registeredContextsNum--;
}
usageInfos[contextId].taskCount = newTaskCount;
}
std::string GraphicsAllocation::getAllocationInfoString() const {
return "";
}
uint32_t GraphicsAllocation::getUsedPageSize() const {
switch (this->memoryPool) {
case MemoryPool::System64KBPages:
case MemoryPool::System64KBPagesWith32BitGpuAddressing:
case MemoryPool::LocalMemory:
return MemoryConstants::pageSize64k;
default:
return MemoryConstants::pageSize;
}
}
constexpr uint32_t GraphicsAllocation::objectNotUsed;
constexpr uint32_t GraphicsAllocation::objectNotResident;
} // namespace NEO