mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 01:48:50 +08:00
Create new OsContext per CSR Change-Id: I8dad7fc1ab450e560f78eba3152b5913791e59a3 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
48 lines
2.8 KiB
C++
48 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/helpers/aligned_memory.h"
|
|
#include "runtime/memory_manager/graphics_allocation.h"
|
|
|
|
namespace OCLRT {
|
|
bool GraphicsAllocation::isL3Capable() {
|
|
auto ptr = ptrOffset(cpuPtr, static_cast<size_t>(this->allocationOffset));
|
|
if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr && alignUp(this->size, MemoryConstants::cacheLineSize) == this->size) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, uint32_t osContextCount, bool isShareable) : gpuBaseAddress(baseAddress),
|
|
size(sizeIn),
|
|
cpuPtr(cpuPtrIn),
|
|
gpuAddress(gpuAddress),
|
|
isShareable(isShareable) {
|
|
usageInfos.resize(maxOsContextCount);
|
|
}
|
|
|
|
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, uint32_t osContextCount, bool isShareable) : size(sizeIn),
|
|
cpuPtr(cpuPtrIn),
|
|
gpuAddress(castToUint64(cpuPtrIn)),
|
|
sharedHandle(sharedHandleIn),
|
|
isShareable(isShareable) {
|
|
usageInfos.resize(maxOsContextCount);
|
|
}
|
|
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;
|
|
}
|
|
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
|
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
|
} // namespace OCLRT
|