2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-08 00:00:20 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-09-18 03:26:09 +08:00
|
|
|
#include "graphics_allocation.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/utilities/logger.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-12-21 00:38:38 +08:00
|
|
|
void GraphicsAllocation::setAllocationType(AllocationType allocationType) {
|
|
|
|
this->allocationType = allocationType;
|
2019-12-10 23:26:35 +08:00
|
|
|
FileLoggerInstance().logAllocation(this);
|
2018-12-21 00:38:38 +08:00
|
|
|
}
|
|
|
|
|
2020-04-21 19:16:45 +08:00
|
|
|
GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress,
|
2020-08-20 19:48:47 +08:00
|
|
|
uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, size_t maxOsContextCount)
|
2019-11-04 23:03:30 +08:00
|
|
|
: rootDeviceIndex(rootDeviceIndex),
|
|
|
|
gpuBaseAddress(baseAddress),
|
2019-02-11 17:02:27 +08:00
|
|
|
gpuAddress(gpuAddress),
|
2019-03-13 22:31:46 +08:00
|
|
|
size(sizeIn),
|
|
|
|
cpuPtr(cpuPtrIn),
|
2019-02-26 18:37:51 +08:00
|
|
|
memoryPool(pool),
|
2019-12-17 15:11:16 +08:00
|
|
|
allocationType(allocationType),
|
2020-08-20 19:48:47 +08:00
|
|
|
usageInfos(maxOsContextCount) {
|
2020-04-21 19:16:45 +08:00
|
|
|
gmms.resize(numGmms);
|
2019-02-27 21:59:46 +08:00
|
|
|
}
|
2019-02-11 17:02:27 +08:00
|
|
|
|
2020-04-21 19:16:45 +08:00
|
|
|
GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn,
|
2020-08-20 19:48:47 +08:00
|
|
|
osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount)
|
2019-11-04 23:03:30 +08:00
|
|
|
: rootDeviceIndex(rootDeviceIndex),
|
|
|
|
gpuAddress(castToUint64(cpuPtrIn)),
|
2019-03-13 22:31:46 +08:00
|
|
|
size(sizeIn),
|
2019-02-11 17:02:27 +08:00
|
|
|
cpuPtr(cpuPtrIn),
|
2019-02-26 18:37:51 +08:00
|
|
|
memoryPool(pool),
|
2019-12-17 15:11:16 +08:00
|
|
|
allocationType(allocationType),
|
2020-08-20 19:48:47 +08:00
|
|
|
usageInfos(maxOsContextCount) {
|
2019-02-27 21:59:46 +08:00
|
|
|
sharingInfo.sharedHandle = sharedHandleIn;
|
2020-04-21 19:16:45 +08:00
|
|
|
gmms.resize(numGmms);
|
2019-02-27 21:59:46 +08:00
|
|
|
}
|
2018-11-02 17:01:56 +08:00
|
|
|
|
|
|
|
GraphicsAllocation::~GraphicsAllocation() = default;
|
|
|
|
|
|
|
|
void GraphicsAllocation::updateTaskCount(uint32_t newTaskCount, uint32_t contextId) {
|
2018-11-07 16:33:55 +08:00
|
|
|
if (usageInfos[contextId].taskCount == objectNotUsed) {
|
2018-11-02 17:01:56 +08:00
|
|
|
registeredContextsNum++;
|
|
|
|
}
|
2018-11-07 16:33:55 +08:00
|
|
|
if (newTaskCount == objectNotUsed) {
|
2018-11-02 17:01:56 +08:00
|
|
|
registeredContextsNum--;
|
|
|
|
}
|
2018-11-06 18:38:49 +08:00
|
|
|
usageInfos[contextId].taskCount = newTaskCount;
|
2018-11-02 17:01:56 +08:00
|
|
|
}
|
2018-12-21 00:38:38 +08:00
|
|
|
|
|
|
|
std::string GraphicsAllocation::getAllocationInfoString() const {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-06-13 18:29:21 +08:00
|
|
|
uint32_t GraphicsAllocation::getUsedPageSize() const {
|
|
|
|
switch (this->memoryPool) {
|
|
|
|
case MemoryPool::System64KBPages:
|
|
|
|
case MemoryPool::System64KBPagesWith32BitGpuAddressing:
|
|
|
|
case MemoryPool::LocalMemory:
|
|
|
|
return MemoryConstants::pageSize64k;
|
|
|
|
default:
|
|
|
|
return MemoryConstants::pageSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-07 16:33:55 +08:00
|
|
|
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
|
|
|
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
2020-07-02 17:49:46 +08:00
|
|
|
constexpr uint32_t GraphicsAllocation::objectAlwaysResident;
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|