2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-01-07 09:29:49 +01:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "runtime/helpers/aligned_memory.h"
|
2018-11-02 10:01:56 +01:00
|
|
|
#include "runtime/memory_manager/graphics_allocation.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-11-02 10:01:56 +01:00
|
|
|
namespace OCLRT {
|
|
|
|
|
bool GraphicsAllocation::isL3Capable() {
|
2018-08-24 15:23:45 +02:00
|
|
|
auto ptr = ptrOffset(cpuPtr, static_cast<size_t>(this->allocationOffset));
|
|
|
|
|
if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr && alignUp(this->size, MemoryConstants::cacheLineSize) == this->size) {
|
2017-12-21 00:45:38 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-01-07 09:29:49 +01:00
|
|
|
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, uint32_t osContextCount, bool multiOsContextCapable) : gpuBaseAddress(baseAddress),
|
|
|
|
|
size(sizeIn),
|
|
|
|
|
cpuPtr(cpuPtrIn),
|
|
|
|
|
gpuAddress(gpuAddress),
|
|
|
|
|
multiOsContextCapable(multiOsContextCapable) {
|
2018-11-21 09:57:51 +01:00
|
|
|
usageInfos.resize(maxOsContextCount);
|
2018-11-02 10:01:56 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-07 09:29:49 +01:00
|
|
|
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, uint32_t osContextCount, bool multiOsContextCapable) : size(sizeIn),
|
|
|
|
|
cpuPtr(cpuPtrIn),
|
|
|
|
|
gpuAddress(castToUint64(cpuPtrIn)),
|
|
|
|
|
sharedHandle(sharedHandleIn),
|
|
|
|
|
multiOsContextCapable(multiOsContextCapable) {
|
2018-11-21 09:57:51 +01:00
|
|
|
usageInfos.resize(maxOsContextCount);
|
2018-11-02 10:01:56 +01:00
|
|
|
}
|
|
|
|
|
GraphicsAllocation::~GraphicsAllocation() = default;
|
|
|
|
|
|
|
|
|
|
void GraphicsAllocation::updateTaskCount(uint32_t newTaskCount, uint32_t contextId) {
|
2018-11-07 08:33:55 +00:00
|
|
|
if (usageInfos[contextId].taskCount == objectNotUsed) {
|
2018-11-02 10:01:56 +01:00
|
|
|
registeredContextsNum++;
|
|
|
|
|
}
|
2018-11-07 08:33:55 +00:00
|
|
|
if (newTaskCount == objectNotUsed) {
|
2018-11-02 10:01:56 +01:00
|
|
|
registeredContextsNum--;
|
|
|
|
|
}
|
2018-11-06 11:38:49 +01:00
|
|
|
usageInfos[contextId].taskCount = newTaskCount;
|
2018-11-02 10:01:56 +01:00
|
|
|
}
|
2018-11-07 08:33:55 +00:00
|
|
|
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
|
|
|
|
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
2018-11-02 10:01:56 +01:00
|
|
|
} // namespace OCLRT
|