Skip to content

Commit 1db6d28

Browse files
Add MultiGraphicsAllocation to MemObj class
use it to get allocation type and coherency status Related-To: NEO-4672 Change-Id: Id1fdc358f7e2038e78c1225ebc986b2a7775c665 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent aa0388e commit 1db6d28

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

opencl/source/kernel/kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ bool Kernel::requiresCoherency() {
12051205
if (Kernel::isMemObj(kernelArguments[argIndex].type)) {
12061206
auto clMem = const_cast<cl_mem>(static_cast<const _cl_mem *>(kernelArguments[argIndex].object));
12071207
auto memObj = castToObjectOrAbort<MemObj>(clMem);
1208-
if (memObj->getGraphicsAllocation()->isCoherent()) {
1208+
if (memObj->getMultiGraphicsAllocation().isCoherent()) {
12091209
return true;
12101210
}
12111211
}
@@ -1303,7 +1303,7 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex,
13031303
forceNonAuxMode = true;
13041304
}
13051305
disableL3 = (argIndex == 0);
1306-
} else if (buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED &&
1306+
} else if (buffer->getMultiGraphicsAllocation().getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED &&
13071307
!kernelArgInfo.pureStatefulBufferAccess) {
13081308
forceNonAuxMode = true;
13091309
}
@@ -2350,7 +2350,7 @@ void Kernel::fillWithBuffersForAuxTranslation(MemObjsForAuxTranslation &memObjsF
23502350
for (uint32_t i = 0; i < getKernelArgsNumber(); i++) {
23512351
if (BUFFER_OBJ == kernelArguments.at(i).type && !kernelInfo.kernelArgInfo.at(i).pureStatefulBufferAccess) {
23522352
auto buffer = castToObject<Buffer>(getKernelArg(i));
2353-
if (buffer && buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
2353+
if (buffer && buffer->getMultiGraphicsAllocation().getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
23542354
memObjsForAuxTranslation.insert(buffer);
23552355

23562356
auto &context = this->program->getContext();

opencl/source/mem_obj/buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool Buffer::isSubBuffer() {
7676
}
7777

7878
bool Buffer::isValidSubBufferOffset(size_t offset) {
79-
if (this->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
79+
if (multiGraphicsAllocation.getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
8080
// From spec: "origin value is aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value"
8181
if (!isAligned(offset, this->getContext()->getDevice(0)->getDeviceInfo().memBaseAddressAlign / 8u)) {
8282
return false;
@@ -650,7 +650,7 @@ bool Buffer::isCompressed() const {
650650
if (this->getGraphicsAllocation()->getDefaultGmm()) {
651651
return this->getGraphicsAllocation()->getDefaultGmm()->isRenderCompressed;
652652
}
653-
if (this->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
653+
if (multiGraphicsAllocation.getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
654654
return true;
655655
}
656656

opencl/source/mem_obj/mem_obj.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ MemObj::MemObj(Context *context,
4242
: context(context), memObjectType(memObjectType), memoryProperties(memoryProperties), flags(flags), flagsIntel(flagsIntel), size(size),
4343
memoryStorage(memoryStorage), hostPtr(hostPtr),
4444
isZeroCopy(zeroCopy), isHostPtrSVM(isHostPtrSVM), isObjectRedescribed(isObjectRedescribed),
45-
graphicsAllocation(gfxAllocation) {
45+
graphicsAllocation(gfxAllocation), multiGraphicsAllocation(graphicsAllocation ? graphicsAllocation->getRootDeviceIndex() : 0) {
4646

4747
if (context) {
4848
context->incRefInternal();
@@ -51,6 +51,9 @@ MemObj::MemObj(Context *context,
5151
executionEnvironment = device->getExecutionEnvironment();
5252
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get();
5353
}
54+
if (graphicsAllocation) {
55+
multiGraphicsAllocation.addAllocation(graphicsAllocation);
56+
}
5457
}
5558

5659
MemObj::~MemObj() {

opencl/source/mem_obj/mem_obj.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#pragma once
99
#include "shared/source/debug_settings/debug_settings_manager.h"
10+
#include "shared/source/memory_manager/multi_graphics_allocation.h"
1011

1112
#include "opencl/extensions/public/cl_ext_private.h"
1213
#include "opencl/source/api/cl_types.h"
@@ -127,6 +128,7 @@ class MemObj : public BaseObject<_cl_mem> {
127128

128129
const cl_mem_flags &getFlags() const { return flags; }
129130
const cl_mem_flags &getFlagsIntel() const { return flagsIntel; }
131+
const MultiGraphicsAllocation &getMultiGraphicsAllocation() const { return multiGraphicsAllocation; }
130132

131133
protected:
132134
void getOsSpecificMemObjectInfo(const cl_mem_info &paramName, size_t *srcParamSize, void **srcParam);
@@ -153,6 +155,7 @@ class MemObj : public BaseObject<_cl_mem> {
153155
bool isObjectRedescribed;
154156
MemoryManager *memoryManager = nullptr;
155157
GraphicsAllocation *graphicsAllocation;
158+
MultiGraphicsAllocation multiGraphicsAllocation;
156159
GraphicsAllocation *mcsAllocation = nullptr;
157160
GraphicsAllocation *mapAllocation = nullptr;
158161
std::shared_ptr<SharingHandler> sharingHandler;

opencl/source/memory_manager/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(RUNTIME_SRCS_MEMORY_MANAGER
99
${CMAKE_CURRENT_SOURCE_DIR}/address_mapper.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/address_mapper.h
1111
${CMAKE_CURRENT_SOURCE_DIR}/cpu_page_fault_manager_memory_sync.cpp
12+
${CMAKE_CURRENT_SOURCE_DIR}/mem_obj_surface.h
1213
${CMAKE_CURRENT_SOURCE_DIR}/memory_banks.h
1314
${CMAKE_CURRENT_SOURCE_DIR}/os_agnostic_memory_manager.cpp
1415
${CMAKE_CURRENT_SOURCE_DIR}/os_agnostic_memory_manager.h

opencl/source/memory_manager/mem_obj_surface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NEO {
1414

1515
class MemObjSurface : public Surface {
1616
public:
17-
MemObjSurface(MemObj *memObj) : Surface(memObj->getGraphicsAllocation()->isCoherent()), memObj(memObj) {
17+
MemObjSurface(MemObj *memObj) : Surface(memObj->getMultiGraphicsAllocation().isCoherent()), memObj(memObj) {
1818
memObj->incRefInternal();
1919
}
2020
~MemObjSurface() override {

0 commit comments

Comments
 (0)