1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "graphics_allocation.h"
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/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, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress,
uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, size_t maxOsContextCount)
: rootDeviceIndex(rootDeviceIndex),
gpuBaseAddress(baseAddress),
gpuAddress(gpuAddress),
size(sizeIn),
cpuPtr(cpuPtrIn),
memoryPool(pool),
allocationType(allocationType),
usageInfos(maxOsContextCount) {
gmms.resize(numGmms);
}
GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn,
osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount)
: rootDeviceIndex(rootDeviceIndex),
gpuAddress(castToUint64(cpuPtrIn)),
size(sizeIn),
cpuPtr(cpuPtrIn),
memoryPool(pool),
allocationType(allocationType),
usageInfos(maxOsContextCount) {
sharingInfo.sharedHandle = sharedHandleIn;
gmms.resize(numGmms);
}
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;
constexpr uint32_t GraphicsAllocation::objectAlwaysResident;
} // namespace NEO
|