From 78f828fcd1c04d49a944a7479a67a966c8364dea Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Wed, 19 Sep 2018 20:54:29 -0700 Subject: [PATCH] Make residency in graphics allocation OsContext dependent. - Graphics Allocation now holds residency control per OsContext. Change-Id: Ie0a0d3aa9fdaf542fdd42dee3aba236a5af635c7 --- .../aub_command_stream_receiver_hw.inl | 8 +-- .../command_stream_receiver.cpp | 29 ++------- .../command_stream/command_stream_receiver.h | 22 ++----- .../tbx_command_stream_receiver_hw.inl | 2 +- .../execution_environment.cpp | 26 ++------ runtime/memory_manager/graphics_allocation.h | 24 ++----- .../os_interface/linux/drm_command_stream.inl | 23 ++----- .../windows/wddm_device_command_stream.inl | 21 +----- .../aub_command_stream_receiver_tests.cpp | 64 +++++++++---------- ...mmand_stream_receiver_flush_task_tests.cpp | 25 ++------ .../command_stream_receiver_tests.cpp | 55 ++++++++++------ .../tbx_command_stream_tests.cpp | 18 +++--- unit_tests/event/event_tests.cpp | 23 ++----- .../enqueue_execution_model_kernel_tests.cpp | 21 +----- unit_tests/gtpin/gtpin_tests.cpp | 36 +++++------ unit_tests/mem_obj/buffer_tests.cpp | 10 +-- unit_tests/mem_obj/image_tests.cpp | 29 ++------- unit_tests/mem_obj/mem_obj_tests.cpp | 29 ++------- unit_tests/mocks/mock_csr.h | 21 +----- unit_tests/mocks/mock_program.cpp | 24 ++----- .../linux/drm_command_stream_tests.cpp | 37 ++++------- 21 files changed, 181 insertions(+), 366 deletions(-) diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 682b1fbc4b..5b017ab0c8 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -304,7 +304,7 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer } } else { allocationsForResidency->push_back(batchBuffer.commandBufferAllocation); - batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount; + batchBuffer.commandBufferAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount; } UNRECOVERABLE_IF(allocationsForResidency == nullptr); processResidency(*allocationsForResidency, osContext); @@ -598,7 +598,7 @@ void AUBCommandStreamReceiverHw::processResidency(ResidencyContainer if (!writeMemory(*gfxAllocation)) { DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable())); } - gfxAllocation->residencyTaskCount = this->taskCount + 1; + gfxAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount + 1; } dumpAubNonWritable = false; @@ -606,9 +606,9 @@ void AUBCommandStreamReceiverHw::processResidency(ResidencyContainer template void AUBCommandStreamReceiverHw::makeNonResident(GraphicsAllocation &gfxAllocation) { - if (gfxAllocation.residencyTaskCount != ObjectNotResident) { + if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) { this->pushAllocationForEviction(&gfxAllocation); - gfxAllocation.residencyTaskCount = ObjectNotResident; + gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident; } } diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 969ed847ec..00c032152c 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (C) 2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "runtime/command_stream/command_stream_receiver.h" @@ -69,14 +54,14 @@ CommandStreamReceiver::~CommandStreamReceiver() { void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { auto submissionTaskCount = this->taskCount + 1; - if (gfxAllocation.residencyTaskCount < (int)submissionTaskCount) { + if (gfxAllocation.residencyTaskCount[deviceIndex] < (int)submissionTaskCount) { this->pushAllocationForResidency(&gfxAllocation); gfxAllocation.taskCount = submissionTaskCount; - if (gfxAllocation.residencyTaskCount == ObjectNotResident) { + if (gfxAllocation.residencyTaskCount[deviceIndex] == ObjectNotResident) { this->totalMemoryUsed += gfxAllocation.getUnderlyingBufferSize(); } } - gfxAllocation.residencyTaskCount = submissionTaskCount; + gfxAllocation.residencyTaskCount[deviceIndex] = submissionTaskCount; } void CommandStreamReceiver::processEviction() { @@ -84,7 +69,7 @@ void CommandStreamReceiver::processEviction() { } void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) { - if (gfxAllocation.residencyTaskCount != ObjectNotResident) { + if (gfxAllocation.residencyTaskCount[deviceIndex] != ObjectNotResident) { makeCoherent(gfxAllocation); if (gfxAllocation.peekEvictable()) { this->pushAllocationForEviction(&gfxAllocation); @@ -93,7 +78,7 @@ void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) { } } - gfxAllocation.residencyTaskCount = ObjectNotResident; + gfxAllocation.residencyTaskCount[deviceIndex] = ObjectNotResident; } void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer *allocationsForResidency) { diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index 50158e5aca..a10f00240b 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -1,23 +1,8 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (C) 2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #pragma once @@ -167,6 +152,8 @@ class CommandStreamReceiver { size_t defaultSshSize; + void setDeviceIndex(uint32_t deviceIndex) { this->deviceIndex = deviceIndex; } + protected: void setDisableL3Cache(bool val) { disableL3Cache = val; @@ -226,6 +213,7 @@ class CommandStreamReceiver { MutexType ownershipMutex; std::unique_ptr kmdNotifyHelper; ExecutionEnvironment &executionEnvironment; + uint32_t deviceIndex = 0u; }; typedef CommandStreamReceiver *(*CommandStreamReceiverCreateFunc)(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment); diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index 6c31deeb87..e3b8d6f734 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -369,7 +369,7 @@ void TbxCommandStreamReceiverHw::processResidency(ResidencyContainer if (!writeMemory(*gfxAllocation)) { DEBUG_BREAK_IF(!(gfxAllocation->getUnderlyingBufferSize() == 0)); } - gfxAllocation->residencyTaskCount = this->taskCount + 1; + gfxAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount + 1; } } diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index 29a77632bd..9c7a2617da 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -1,24 +1,9 @@ /* -* Copyright (c) 2018, Intel Corporation -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ #include "runtime/execution_environment/execution_environment.h" #include "runtime/command_stream/command_stream_receiver.h" @@ -56,6 +41,7 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p if (pHwInfo->capabilityTable.ftrRenderCompressedBuffers || pHwInfo->capabilityTable.ftrRenderCompressedImages) { commandStreamReceiver->createPageTableManager(); } + commandStreamReceiver->setDeviceIndex(deviceIndex); this->commandStreamReceivers[deviceIndex] = std::move(commandStreamReceiver); return true; } diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 03ceec0314..9f0e058d37 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #pragma once @@ -39,6 +24,7 @@ namespace Sharing { constexpr auto nonSharedResource = 0u; } +constexpr uint32_t maxOsContextCount = 4u; const int ObjectNotResident = -1; const uint32_t ObjectNotUsed = (uint32_t)-1; @@ -63,7 +49,7 @@ class GraphicsAllocation : public IDNode { uint64_t gpuBaseAddress = 0; Gmm *gmm = nullptr; uint64_t allocationOffset = 0u; - int residencyTaskCount = ObjectNotResident; + int residencyTaskCount[maxOsContextCount] = {ObjectNotResident}; bool cpuPtrAllocated = false; // flag indicating if cpuPtr is driver-allocated enum class AllocationType { @@ -145,7 +131,7 @@ class GraphicsAllocation : public IDNode { void setEvictable(bool evictable) { this->evictable = evictable; } bool peekEvictable() const { return evictable; } - bool isResident() const { return residencyTaskCount != ObjectNotResident; } + bool isResident(uint32_t contextId) const { return residencyTaskCount[contextId] != ObjectNotResident; } void setLocked(bool locked) { this->locked = locked; } bool isLocked() const { return locked; } diff --git a/runtime/os_interface/linux/drm_command_stream.inl b/runtime/os_interface/linux/drm_command_stream.inl index b279ccaf56..fd82c472f0 100644 --- a/runtime/os_interface/linux/drm_command_stream.inl +++ b/runtime/os_interface/linux/drm_command_stream.inl @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "runtime/command_stream/linear_stream.h" @@ -144,7 +129,7 @@ void DrmCommandStreamReceiver::makeNonResident(GraphicsAllocation &gf // Vector is moved to command buffer inside flush. // If flush wasn't called we need to make all objects non-resident. // If makeNonResident is called before flush, vector will be cleared. - if (gfxAllocation.residencyTaskCount != ObjectNotResident) { + if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) { for (auto &surface : residency) { surface->setIsResident(false); } @@ -158,7 +143,7 @@ void DrmCommandStreamReceiver::makeNonResident(GraphicsAllocation &gf } } } - gfxAllocation.residencyTaskCount = ObjectNotResident; + gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident; } template diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index ead4647ac7..576ddf59a4 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ // Need to suppress warining 4005 caused by hw_cmds.h and wddm.h order. @@ -103,7 +88,7 @@ FlushStamp WddmCommandStreamReceiver::flush(BatchBuffer &batchBuffer, makeResident(*batchBuffer.commandBufferAllocation); } else { allocationsForResidency->push_back(batchBuffer.commandBufferAllocation); - batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount; + batchBuffer.commandBufferAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount; } UNRECOVERABLE_IF(allocationsForResidency == nullptr); diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index 3df9765b61..edd1baa4a5 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -259,26 +259,26 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC // First makeResident marks the allocation resident aubCsr->makeResident(*gfxAllocation); - EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->taskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]); EXPECT_EQ(1u, aubCsr->getResidencyAllocations().size()); // Second makeResident should have no impact aubCsr->makeResident(*gfxAllocation); - EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->taskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]); EXPECT_EQ(1u, aubCsr->getResidencyAllocations().size()); // First makeNonResident marks the allocation as nonresident aubCsr->makeNonResident(*gfxAllocation); - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size()); // Second makeNonResident should have no impact aubCsr->makeNonResident(*gfxAllocation); - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size()); memoryManager->freeGraphicsMemoryImpl(gfxAllocation); @@ -470,17 +470,17 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; auto engineType = OCLRT::ENGINE_RCS; - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); aubCsr->flush(batchBuffer, engineType, &allocationsForResidency, *pDevice->getOsContext()); - EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount); + EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount[0u]); aubCsr->makeSurfacePackNonResident(nullptr); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); } HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) { @@ -492,11 +492,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; auto engineType = OCLRT::ENGINE_RCS; - EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->residencyTaskCount[0u]); aubCsr->flush(batchBuffer, engineType, &allocationsForResidency, *pDevice->getOsContext()); - EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, aubExecutionEnvironment->commandBuffer->residencyTaskCount[0u]); } HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) { @@ -513,22 +513,22 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon auto engineType = OCLRT::ENGINE_RCS; ResidencyContainer allocationsForResidency = {gfxAllocation}; - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); aubCsr->flush(batchBuffer, engineType, &allocationsForResidency, *pDevice->getOsContext()); - EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]); - EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount); + EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount[0u]); aubCsr->makeSurfacePackNonResident(&allocationsForResidency); - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -546,13 +546,13 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand auto engineType = OCLRT::ENGINE_RCS; ResidencyContainer allocationsForResidency = {gfxAllocation}; - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); aubCsr->flush(batchBuffer, engineType, &allocationsForResidency, *pDevice->getOsContext()); - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); memoryManager->freeGraphicsMemoryImpl(gfxAllocation); } @@ -582,22 +582,22 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon auto engineType = OCLRT::ENGINE_RCS; ResidencyContainer allocationsForResidency = {gfxAllocation}; - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); aubCsr->flush(batchBuffer, engineType, &allocationsForResidency, *pDevice->getOsContext()); - EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]); - EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount); - EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount); + EXPECT_NE(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, commandBuffer->residencyTaskCount[0u]); aubCsr->makeSurfacePackNonResident(&allocationsForResidency); - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); memoryManager->freeGraphicsMemory(gfxAllocation); } diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp index 82d60d6ee4..8e33cd4615 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (C) 2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "reg_configs_common.h" @@ -2326,8 +2311,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenRecorded std::vector residentSurfaces = cmdBuffer->surfaces; for (auto &graphicsAllocation : residentSurfaces) { - EXPECT_TRUE(graphicsAllocation->isResident()); - EXPECT_EQ(1, graphicsAllocation->residencyTaskCount); + EXPECT_TRUE(graphicsAllocation->isResident(0u)); + EXPECT_EQ(1, graphicsAllocation->residencyTaskCount[0u]); } mockCsr->flushBatchedSubmissions(); @@ -2343,7 +2328,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenRecorded EXPECT_EQ(0u, surfacesForResidency.size()); for (auto &graphicsAllocation : residentSurfaces) { - EXPECT_FALSE(graphicsAllocation->isResident()); + EXPECT_FALSE(graphicsAllocation->isResident(0u)); } } diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index e17e44948b..8d2f38f73b 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (C) 2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "runtime/command_stream/command_stream_receiver.h" @@ -127,11 +112,11 @@ TEST_F(CommandStreamReceiverTest, makeResident_setsBufferResidencyFlag) { srcMemory, retVal); ASSERT_NE(nullptr, buffer); - EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident()); + EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u)); commandStreamReceiver->makeResident(*buffer->getGraphicsAllocation()); - EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident()); + EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u)); delete buffer; } @@ -415,3 +400,35 @@ TEST(CommandStreamReceiverSimpleTest, givenCSRWhenWaitBeforeMakingNonResidentWhe EXPECT_EQ(0u, tag); } + +TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesAreUsedThenResidencyIsProperlyHandled) { + auto executionEnvironment = new ExecutionEnvironment; + + std::unique_ptr device0(Device::create(nullptr, executionEnvironment, 0u)); + std::unique_ptr device1(Device::create(nullptr, executionEnvironment, 1u)); + + auto &commandStreamReceiver0 = device0->getCommandStreamReceiver(); + auto &commandStreamReceiver1 = device1->getCommandStreamReceiver(); + + auto graphicsAllocation = executionEnvironment->memoryManager->allocateGraphicsMemory(4096u); + + commandStreamReceiver0.makeResident(*graphicsAllocation); + commandStreamReceiver1.makeResident(*graphicsAllocation); + + EXPECT_EQ(1u, commandStreamReceiver0.getResidencyAllocations().size()); + EXPECT_EQ(1u, commandStreamReceiver1.getResidencyAllocations().size()); + + EXPECT_EQ(1, graphicsAllocation->residencyTaskCount[0u]); + EXPECT_EQ(1, graphicsAllocation->residencyTaskCount[1u]); + + commandStreamReceiver0.makeNonResident(*graphicsAllocation); + commandStreamReceiver1.makeNonResident(*graphicsAllocation); + + EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[1u]); + + EXPECT_EQ(1u, commandStreamReceiver0.getEvictionAllocations().size()); + EXPECT_EQ(1u, commandStreamReceiver1.getEvictionAllocations().size()); + + executionEnvironment->memoryManager->freeGraphicsMemory(graphicsAllocation); +} diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index 58ba21d649..d66de33a1c 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -225,13 +225,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); tbxCsr->pushAllocationForResidency(graphicsAllocation); tbxCsr->processResidency(tbxCsr->getResidencyAllocations(), *pDevice->getOsContext()); - EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount); - EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); + EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]); memoryManager->freeGraphicsMemory(graphicsAllocation); } @@ -244,13 +244,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); ResidencyContainer allocationsForResidency = {graphicsAllocation}; tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); - EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount); - EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); + EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]); memoryManager->freeGraphicsMemory(graphicsAllocation); } @@ -271,12 +271,12 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh auto engineType = OCLRT::ENGINE_RCS; ResidencyContainer allocationsForResidency = {graphicsAllocation}; - EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); tbxCsr->flush(batchBuffer, engineType, &allocationsForResidency, *pDevice->getOsContext()); - EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount); - EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount); + EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); + EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]); memoryManager->freeGraphicsMemory(commandBuffer); memoryManager->freeGraphicsMemory(graphicsAllocation); diff --git a/unit_tests/event/event_tests.cpp b/unit_tests/event/event_tests.cpp index 7e8d4c1c7c..ae5b2226c8 100644 --- a/unit_tests/event/event_tests.cpp +++ b/unit_tests/event/event_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "event_fixture.h" @@ -476,7 +461,7 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) { delete pCmdQ; EXPECT_EQ(surface->resident, 1u); - EXPECT_FALSE(surface->graphicsAllocation->isResident()); + EXPECT_FALSE(surface->graphicsAllocation->isResident(0u)); delete surface->graphicsAllocation; } @@ -567,7 +552,7 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut std::string output = testing::internal::GetCapturedStdout(); EXPECT_STREQ("test", output.c_str()); - EXPECT_FALSE(surface->isResident()); + EXPECT_FALSE(surface->isResident(0u)); delete pPrintfSurface; delete pCmdQ; diff --git a/unit_tests/execution_model/enqueue_execution_model_kernel_tests.cpp b/unit_tests/execution_model/enqueue_execution_model_kernel_tests.cpp index a22f69cfbf..0a132e63be 100644 --- a/unit_tests/execution_model/enqueue_execution_model_kernel_tests.cpp +++ b/unit_tests/execution_model/enqueue_execution_model_kernel_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "runtime/command_queue/gpgpu_walker.h" @@ -129,7 +114,7 @@ HWTEST_P(ParentKernelEnqueueTest, GivenParentKernelWithPrivateSurfaceWhenEnqueue pKernel->getProgram()->getBlockKernelManager()->pushPrivateSurface(privateSurface, 0); pCmdQ->enqueueKernel(pKernel, 1, offset, gws, gws, 0, nullptr, nullptr); - EXPECT_NE(ObjectNotResident, privateSurface->residencyTaskCount); + EXPECT_NE(ObjectNotResident, privateSurface->residencyTaskCount[0u]); } } diff --git a/unit_tests/gtpin/gtpin_tests.cpp b/unit_tests/gtpin/gtpin_tests.cpp index 6cdbad375e..28004c1636 100644 --- a/unit_tests/gtpin/gtpin_tests.cpp +++ b/unit_tests/gtpin/gtpin_tests.cpp @@ -1669,11 +1669,11 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelIsCreatedThenAllKerne auto pBuffer1 = castToObject(gtpinBuffer1); GraphicsAllocation *pGfxAlloc1 = pBuffer1->getGraphicsAllocation(); CommandStreamReceiver &csr = pCmdQueue->getDevice().getCommandStreamReceiver(); - EXPECT_FALSE(pGfxAlloc0->isResident()); - EXPECT_FALSE(pGfxAlloc1->isResident()); + EXPECT_FALSE(pGfxAlloc0->isResident(0u)); + EXPECT_FALSE(pGfxAlloc1->isResident(0u)); gtpinNotifyMakeResident(pKernel, &csr); - EXPECT_TRUE(pGfxAlloc0->isResident()); - EXPECT_FALSE(pGfxAlloc1->isResident()); + EXPECT_TRUE(pGfxAlloc0->isResident(0u)); + EXPECT_FALSE(pGfxAlloc1->isResident(0u)); // Cancel information about second submitted kernel kernelExecQueue.pop_back(); @@ -1840,24 +1840,24 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenOneKernelIsSubmittedSeveral GraphicsAllocation *pGfxAlloc1 = pBuffer1->getGraphicsAllocation(); CommandStreamReceiver &csr = pCmdQueue->getDevice().getCommandStreamReceiver(); // Make resident resource of first submitted kernel - EXPECT_FALSE(pGfxAlloc0->isResident()); - EXPECT_FALSE(pGfxAlloc1->isResident()); + EXPECT_FALSE(pGfxAlloc0->isResident(0u)); + EXPECT_FALSE(pGfxAlloc1->isResident(0u)); gtpinNotifyMakeResident(pKernel, &csr); - EXPECT_TRUE(pGfxAlloc0->isResident()); - EXPECT_FALSE(pGfxAlloc1->isResident()); + EXPECT_TRUE(pGfxAlloc0->isResident(0u)); + EXPECT_FALSE(pGfxAlloc1->isResident(0u)); // Make resident resource of second submitted kernel gtpinNotifyMakeResident(pKernel, &csr); - EXPECT_TRUE(pGfxAlloc0->isResident()); - EXPECT_TRUE(pGfxAlloc1->isResident()); + EXPECT_TRUE(pGfxAlloc0->isResident(0u)); + EXPECT_TRUE(pGfxAlloc1->isResident(0u)); // Verify that correct GT-Pin resource is added to residency list. // This simulates enqueuing blocked kernels kernelExecQueue[0].isResourceResident = false; kernelExecQueue[1].isResourceResident = false; - pGfxAlloc0->residencyTaskCount = ObjectNotResident; - pGfxAlloc1->residencyTaskCount = ObjectNotResident; - EXPECT_FALSE(pGfxAlloc0->isResident()); - EXPECT_FALSE(pGfxAlloc1->isResident()); + pGfxAlloc0->residencyTaskCount[0u] = ObjectNotResident; + pGfxAlloc1->residencyTaskCount[0u] = ObjectNotResident; + EXPECT_FALSE(pGfxAlloc0->isResident(0u)); + EXPECT_FALSE(pGfxAlloc1->isResident(0u)); std::vector residencyVector; EXPECT_EQ(0u, residencyVector.size()); // Add to residency list resource of first submitted kernel @@ -1866,16 +1866,16 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenOneKernelIsSubmittedSeveral // Make resident first resource on residency list GeneralSurface *pSurf1 = (GeneralSurface *)residencyVector[0]; pSurf1->makeResident(csr); - EXPECT_TRUE(pGfxAlloc0->isResident()); - EXPECT_FALSE(pGfxAlloc1->isResident()); + EXPECT_TRUE(pGfxAlloc0->isResident(0u)); + EXPECT_FALSE(pGfxAlloc1->isResident(0u)); // Add to residency list resource of second submitted kernel gtpinNotifyUpdateResidencyList(pKernel, &residencyVector); EXPECT_EQ(2u, residencyVector.size()); // Make resident second resource on residency list GeneralSurface *pSurf2 = (GeneralSurface *)residencyVector[1]; pSurf2->makeResident(csr); - EXPECT_TRUE(pGfxAlloc0->isResident()); - EXPECT_TRUE(pGfxAlloc1->isResident()); + EXPECT_TRUE(pGfxAlloc0->isResident(0u)); + EXPECT_TRUE(pGfxAlloc1->isResident(0u)); // Cleanup delete pSurf1; diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index 8d950c5d40..ed7051afef 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -636,18 +636,18 @@ TEST_P(ValidHostPtr, isResident_defaultsToFalseAfterCreate) { buffer = createBuffer(); ASSERT_NE(nullptr, buffer); - EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident()); + EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u)); } TEST_P(ValidHostPtr, isResident_returnsValueFromSetResident) { buffer = createBuffer(); ASSERT_NE(nullptr, buffer); - buffer->getGraphicsAllocation()->residencyTaskCount = 1; - EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident()); + buffer->getGraphicsAllocation()->residencyTaskCount[0u] = 1; + EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u)); - buffer->getGraphicsAllocation()->residencyTaskCount = ObjectNotResident; - EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident()); + buffer->getGraphicsAllocation()->residencyTaskCount[0u] = ObjectNotResident; + EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u)); } TEST_P(ValidHostPtr, getAddress) { diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index 0a21cd491f..3574053301 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "runtime/built_ins/built_ins.h" @@ -515,18 +500,18 @@ TEST_P(CreateImageHostPtr, isResidentDefaultsToFalseAfterCreate) { image = createImage(retVal); ASSERT_NE(nullptr, image); - EXPECT_FALSE(image->getGraphicsAllocation()->isResident()); + EXPECT_FALSE(image->getGraphicsAllocation()->isResident(0u)); } TEST_P(CreateImageHostPtr, isResidentReturnsValueFromSetResident) { image = createImage(retVal); ASSERT_NE(nullptr, image); - image->getGraphicsAllocation()->residencyTaskCount = 1; - EXPECT_TRUE(image->getGraphicsAllocation()->isResident()); + image->getGraphicsAllocation()->residencyTaskCount[0u] = 1; + EXPECT_TRUE(image->getGraphicsAllocation()->isResident(0u)); - image->getGraphicsAllocation()->residencyTaskCount = ObjectNotResident; - EXPECT_FALSE(image->getGraphicsAllocation()->isResident()); + image->getGraphicsAllocation()->residencyTaskCount[0u] = ObjectNotResident; + EXPECT_FALSE(image->getGraphicsAllocation()->isResident(0u)); } TEST_P(CreateImageHostPtr, getAddress) { diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index f36593760f..37819716c7 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "runtime/command_stream/command_stream_receiver.h" @@ -73,11 +58,11 @@ TEST(MemObj, useCount) { MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false); - EXPECT_EQ(ObjectNotResident, memObj.getGraphicsAllocation()->residencyTaskCount); - memObj.getGraphicsAllocation()->residencyTaskCount = 1; - EXPECT_EQ(1, memObj.getGraphicsAllocation()->residencyTaskCount); - memObj.getGraphicsAllocation()->residencyTaskCount--; - EXPECT_EQ(0, memObj.getGraphicsAllocation()->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, memObj.getGraphicsAllocation()->residencyTaskCount[0u]); + memObj.getGraphicsAllocation()->residencyTaskCount[0u] = 1; + EXPECT_EQ(1, memObj.getGraphicsAllocation()->residencyTaskCount[0u]); + memObj.getGraphicsAllocation()->residencyTaskCount[0u]--; + EXPECT_EQ(0, memObj.getGraphicsAllocation()->residencyTaskCount[0u]); } TEST(MemObj, GivenMemObjWhenInititalizedFromHostPtrThenInitializeFields) { diff --git a/unit_tests/mocks/mock_csr.h b/unit_tests/mocks/mock_csr.h index d120b7f978..bf9f61a7c4 100644 --- a/unit_tests/mocks/mock_csr.h +++ b/unit_tests/mocks/mock_csr.h @@ -1,23 +1,8 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (C) 2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #pragma once @@ -59,7 +44,7 @@ class MockCsrBase : public UltCommandStreamReceiver { if (this->getMemoryManager()) { this->getResidencyAllocations().push_back(&gfxAllocation); } - gfxAllocation.residencyTaskCount = this->taskCount; + gfxAllocation.residencyTaskCount[this->deviceIndex] = this->taskCount; } void makeNonResident(GraphicsAllocation &gfxAllocation) override { madeNonResidentGfxAllocations.push_back(&gfxAllocation); diff --git a/unit_tests/mocks/mock_program.cpp b/unit_tests/mocks/mock_program.cpp index becf11b9a5..8a8f545acc 100644 --- a/unit_tests/mocks/mock_program.cpp +++ b/unit_tests/mocks/mock_program.cpp @@ -1,24 +1,10 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ + #include "runtime/context/context.h" #include "runtime/helpers/hash.h" #include "runtime/program/create.inl" @@ -47,7 +33,9 @@ cl_int GlobalMockSipProgram::processGenBinaryOnce() { return ret; } void GlobalMockSipProgram::resetAllocationState() { - this->kernelInfoArray[0]->kernelAllocation->residencyTaskCount = 0xffffffff; + for (uint32_t index = 0u; index < maxOsContextCount; index++) { + this->kernelInfoArray[0]->kernelAllocation->residencyTaskCount[index] = 0xffffffff; + } static_cast(this->kernelInfoArray[0]->kernelAllocation)->resetInspectionId(); } void GlobalMockSipProgram::initSipProgram() { diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index 5434651adf..198352b72d 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -1,23 +1,8 @@ /* - * Copyright (c) 2017 - 2018, Intel Corporation + * Copyright (C) 2017-2018 Intel Corporation * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. */ #include "hw_cmds.h" @@ -1091,7 +1076,7 @@ TEST_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhenItIsSubmitte EXPECT_TRUE(cmdBuffers.peekIsEmpty()); auto commandBufferGraphicsAllocation = submittedCommandBuffer.getGraphicsAllocation(); - EXPECT_FALSE(commandBufferGraphicsAllocation->isResident()); + EXPECT_FALSE(commandBufferGraphicsAllocation->isResident(0u)); //preemption allocation size_t csrSurfaceCount = (device->getPreemptionMode() == PreemptionMode::MidThread) ? 2 : 0; @@ -1664,7 +1649,7 @@ TEST_F(DrmCommandStreamLeaksTest, givenMultipleMakeResidentWhenMakeNonResidentIs csr->makeSurfacePackNonResident(nullptr); EXPECT_EQ(0u, csr->getResidencyAllocations().size()); - EXPECT_FALSE(allocation1->isResident()); + EXPECT_FALSE(allocation1->isResident(0u)); mm->freeGraphicsMemory(allocation1); } @@ -1715,24 +1700,24 @@ class DrmMockBuffer : public Buffer { TEST_F(DrmCommandStreamLeaksTest, BufferResidency) { std::unique_ptr buffer(DrmMockBuffer::create()); - ASSERT_FALSE(buffer->getGraphicsAllocation()->isResident()); - ASSERT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->residencyTaskCount); + ASSERT_FALSE(buffer->getGraphicsAllocation()->isResident(0u)); + ASSERT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->residencyTaskCount[0u]); ASSERT_GT(buffer->getSize(), 0u); //make it resident 8 times for (int c = 0; c < 8; c++) { csr->makeResident(*buffer->getGraphicsAllocation()); csr->processResidency(csr->getResidencyAllocations(), *osContext); - EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident()); - EXPECT_EQ(buffer->getGraphicsAllocation()->residencyTaskCount, (int)csr->peekTaskCount() + 1); + EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u)); + EXPECT_EQ(buffer->getGraphicsAllocation()->residencyTaskCount[0u], (int)csr->peekTaskCount() + 1); } csr->makeNonResident(*buffer->getGraphicsAllocation()); - EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident()); + EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u)); csr->makeNonResident(*buffer->getGraphicsAllocation()); - EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident()); - EXPECT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->residencyTaskCount); + EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident(0u)); + EXPECT_EQ(ObjectNotResident, buffer->getGraphicsAllocation()->residencyTaskCount[0u]); } typedef Test DrmCommandStreamMemoryManagerTest;