Skip to content

Commit 78f828f

Browse files
Make residency in graphics allocation OsContext dependent.
- Graphics Allocation now holds residency control per OsContext. Change-Id: Ie0a0d3aa9fdaf542fdd42dee3aba236a5af635c7
1 parent c39f9c0 commit 78f828f

21 files changed

+181
-366
lines changed

runtime/command_stream/aub_command_stream_receiver_hw.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
304304
}
305305
} else {
306306
allocationsForResidency->push_back(batchBuffer.commandBufferAllocation);
307-
batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount;
307+
batchBuffer.commandBufferAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount;
308308
}
309309
UNRECOVERABLE_IF(allocationsForResidency == nullptr);
310310
processResidency(*allocationsForResidency, osContext);
@@ -598,17 +598,17 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
598598
if (!writeMemory(*gfxAllocation)) {
599599
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable()));
600600
}
601-
gfxAllocation->residencyTaskCount = this->taskCount + 1;
601+
gfxAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount + 1;
602602
}
603603

604604
dumpAubNonWritable = false;
605605
}
606606

607607
template <typename GfxFamily>
608608
void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
609-
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
609+
if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) {
610610
this->pushAllocationForEviction(&gfxAllocation);
611-
gfxAllocation.residencyTaskCount = ObjectNotResident;
611+
gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident;
612612
}
613613
}
614614

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
/*
2-
* Copyright (c) 2018, Intel Corporation
2+
* Copyright (C) 2018 Intel Corporation
33
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a
5-
* copy of this software and associated documentation files (the "Software"),
6-
* to deal in the Software without restriction, including without limitation
7-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8-
* and/or sell copies of the Software, and to permit persons to whom the
9-
* Software is furnished to do so, subject to the following conditions:
4+
* SPDX-License-Identifier: MIT
105
*
11-
* The above copyright notice and this permission notice shall be included
12-
* in all copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15-
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18-
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19-
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20-
* OTHER DEALINGS IN THE SOFTWARE.
216
*/
227

238
#include "runtime/command_stream/command_stream_receiver.h"
@@ -69,22 +54,22 @@ CommandStreamReceiver::~CommandStreamReceiver() {
6954

7055
void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
7156
auto submissionTaskCount = this->taskCount + 1;
72-
if (gfxAllocation.residencyTaskCount < (int)submissionTaskCount) {
57+
if (gfxAllocation.residencyTaskCount[deviceIndex] < (int)submissionTaskCount) {
7358
this->pushAllocationForResidency(&gfxAllocation);
7459
gfxAllocation.taskCount = submissionTaskCount;
75-
if (gfxAllocation.residencyTaskCount == ObjectNotResident) {
60+
if (gfxAllocation.residencyTaskCount[deviceIndex] == ObjectNotResident) {
7661
this->totalMemoryUsed += gfxAllocation.getUnderlyingBufferSize();
7762
}
7863
}
79-
gfxAllocation.residencyTaskCount = submissionTaskCount;
64+
gfxAllocation.residencyTaskCount[deviceIndex] = submissionTaskCount;
8065
}
8166

8267
void CommandStreamReceiver::processEviction() {
8368
this->clearEvictionAllocations();
8469
}
8570

8671
void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
87-
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
72+
if (gfxAllocation.residencyTaskCount[deviceIndex] != ObjectNotResident) {
8873
makeCoherent(gfxAllocation);
8974
if (gfxAllocation.peekEvictable()) {
9075
this->pushAllocationForEviction(&gfxAllocation);
@@ -93,7 +78,7 @@ void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
9378
}
9479
}
9580

96-
gfxAllocation.residencyTaskCount = ObjectNotResident;
81+
gfxAllocation.residencyTaskCount[deviceIndex] = ObjectNotResident;
9782
}
9883

9984
void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer *allocationsForResidency) {

runtime/command_stream/command_stream_receiver.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
/*
2-
* Copyright (c) 2018, Intel Corporation
2+
* Copyright (C) 2018 Intel Corporation
33
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a
5-
* copy of this software and associated documentation files (the "Software"),
6-
* to deal in the Software without restriction, including without limitation
7-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8-
* and/or sell copies of the Software, and to permit persons to whom the
9-
* Software is furnished to do so, subject to the following conditions:
4+
* SPDX-License-Identifier: MIT
105
*
11-
* The above copyright notice and this permission notice shall be included
12-
* in all copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15-
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18-
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19-
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20-
* OTHER DEALINGS IN THE SOFTWARE.
216
*/
227

238
#pragma once
@@ -167,6 +152,8 @@ class CommandStreamReceiver {
167152

168153
size_t defaultSshSize;
169154

155+
void setDeviceIndex(uint32_t deviceIndex) { this->deviceIndex = deviceIndex; }
156+
170157
protected:
171158
void setDisableL3Cache(bool val) {
172159
disableL3Cache = val;
@@ -226,6 +213,7 @@ class CommandStreamReceiver {
226213
MutexType ownershipMutex;
227214
std::unique_ptr<KmdNotifyHelper> kmdNotifyHelper;
228215
ExecutionEnvironment &executionEnvironment;
216+
uint32_t deviceIndex = 0u;
229217
};
230218

231219
typedef CommandStreamReceiver *(*CommandStreamReceiverCreateFunc)(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment);

runtime/command_stream/tbx_command_stream_receiver_hw.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
369369
if (!writeMemory(*gfxAllocation)) {
370370
DEBUG_BREAK_IF(!(gfxAllocation->getUnderlyingBufferSize() == 0));
371371
}
372-
gfxAllocation->residencyTaskCount = this->taskCount + 1;
372+
gfxAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount + 1;
373373
}
374374
}
375375

runtime/execution_environment/execution_environment.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
/*
2-
* Copyright (c) 2018, Intel Corporation
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a
5-
* copy of this software and associated documentation files (the "Software"),
6-
* to deal in the Software without restriction, including without limitation
7-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8-
* and/or sell copies of the Software, and to permit persons to whom the
9-
* Software is furnished to do so, subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included
12-
* in all copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15-
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18-
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19-
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20-
* OTHER DEALINGS IN THE SOFTWARE.
21-
*/
2+
* Copyright (C) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
227

238
#include "runtime/execution_environment/execution_environment.h"
249
#include "runtime/command_stream/command_stream_receiver.h"
@@ -56,6 +41,7 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p
5641
if (pHwInfo->capabilityTable.ftrRenderCompressedBuffers || pHwInfo->capabilityTable.ftrRenderCompressedImages) {
5742
commandStreamReceiver->createPageTableManager();
5843
}
44+
commandStreamReceiver->setDeviceIndex(deviceIndex);
5945
this->commandStreamReceivers[deviceIndex] = std::move(commandStreamReceiver);
6046
return true;
6147
}

runtime/memory_manager/graphics_allocation.h

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
/*
2-
* Copyright (c) 2017 - 2018, Intel Corporation
2+
* Copyright (C) 2017-2018 Intel Corporation
33
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a
5-
* copy of this software and associated documentation files (the "Software"),
6-
* to deal in the Software without restriction, including without limitation
7-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8-
* and/or sell copies of the Software, and to permit persons to whom the
9-
* Software is furnished to do so, subject to the following conditions:
4+
* SPDX-License-Identifier: MIT
105
*
11-
* The above copyright notice and this permission notice shall be included
12-
* in all copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15-
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18-
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19-
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20-
* OTHER DEALINGS IN THE SOFTWARE.
216
*/
227

238
#pragma once
@@ -39,6 +24,7 @@ namespace Sharing {
3924
constexpr auto nonSharedResource = 0u;
4025
}
4126

27+
constexpr uint32_t maxOsContextCount = 4u;
4228
const int ObjectNotResident = -1;
4329
const uint32_t ObjectNotUsed = (uint32_t)-1;
4430

@@ -63,7 +49,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
6349
uint64_t gpuBaseAddress = 0;
6450
Gmm *gmm = nullptr;
6551
uint64_t allocationOffset = 0u;
66-
int residencyTaskCount = ObjectNotResident;
52+
int residencyTaskCount[maxOsContextCount] = {ObjectNotResident};
6753
bool cpuPtrAllocated = false; // flag indicating if cpuPtr is driver-allocated
6854

6955
enum class AllocationType {
@@ -145,7 +131,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
145131
void setEvictable(bool evictable) { this->evictable = evictable; }
146132
bool peekEvictable() const { return evictable; }
147133

148-
bool isResident() const { return residencyTaskCount != ObjectNotResident; }
134+
bool isResident(uint32_t contextId) const { return residencyTaskCount[contextId] != ObjectNotResident; }
149135
void setLocked(bool locked) { this->locked = locked; }
150136
bool isLocked() const { return locked; }
151137

runtime/os_interface/linux/drm_command_stream.inl

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
/*
2-
* Copyright (c) 2017 - 2018, Intel Corporation
2+
* Copyright (C) 2017-2018 Intel Corporation
33
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a
5-
* copy of this software and associated documentation files (the "Software"),
6-
* to deal in the Software without restriction, including without limitation
7-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8-
* and/or sell copies of the Software, and to permit persons to whom the
9-
* Software is furnished to do so, subject to the following conditions:
4+
* SPDX-License-Identifier: MIT
105
*
11-
* The above copyright notice and this permission notice shall be included
12-
* in all copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15-
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18-
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19-
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20-
* OTHER DEALINGS IN THE SOFTWARE.
216
*/
227

238
#include "runtime/command_stream/linear_stream.h"
@@ -144,7 +129,7 @@ void DrmCommandStreamReceiver<GfxFamily>::makeNonResident(GraphicsAllocation &gf
144129
// Vector is moved to command buffer inside flush.
145130
// If flush wasn't called we need to make all objects non-resident.
146131
// If makeNonResident is called before flush, vector will be cleared.
147-
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {
132+
if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) {
148133
for (auto &surface : residency) {
149134
surface->setIsResident(false);
150135
}
@@ -158,7 +143,7 @@ void DrmCommandStreamReceiver<GfxFamily>::makeNonResident(GraphicsAllocation &gf
158143
}
159144
}
160145
}
161-
gfxAllocation.residencyTaskCount = ObjectNotResident;
146+
gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident;
162147
}
163148

164149
template <typename GfxFamily>

runtime/os_interface/windows/wddm_device_command_stream.inl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
/*
2-
* Copyright (c) 2017 - 2018, Intel Corporation
2+
* Copyright (C) 2017-2018 Intel Corporation
33
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a
5-
* copy of this software and associated documentation files (the "Software"),
6-
* to deal in the Software without restriction, including without limitation
7-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8-
* and/or sell copies of the Software, and to permit persons to whom the
9-
* Software is furnished to do so, subject to the following conditions:
4+
* SPDX-License-Identifier: MIT
105
*
11-
* The above copyright notice and this permission notice shall be included
12-
* in all copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15-
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18-
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19-
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20-
* OTHER DEALINGS IN THE SOFTWARE.
216
*/
227

238
// Need to suppress warining 4005 caused by hw_cmds.h and wddm.h order.
@@ -103,7 +88,7 @@ FlushStamp WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer,
10388
makeResident(*batchBuffer.commandBufferAllocation);
10489
} else {
10590
allocationsForResidency->push_back(batchBuffer.commandBufferAllocation);
106-
batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount;
91+
batchBuffer.commandBufferAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount;
10792
}
10893

10994
UNRECOVERABLE_IF(allocationsForResidency == nullptr);

0 commit comments

Comments
 (0)