From 0aedea1ae2803f197ecf98b4464a3e4c05cbcd33 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Wed, 19 Feb 2020 16:32:40 +0100 Subject: [PATCH] Move GTPin notifications out from CSR Change-Id: I4209fc18017c694d71848c3fecd8c3d7440f151b Signed-off-by: Mateusz Hoppe --- core/command_stream/CMakeLists.txt | 3 ++ .../experimental_command_buffer.cpp | 2 +- .../experimental_command_buffer.h | 2 +- .../experimental_command_buffer.inl | 2 +- core/device/device.cpp | 2 +- runtime/command_queue/command_queue.cpp | 4 ++ runtime/command_queue/enqueue_common.h | 4 ++ runtime/command_stream/CMakeLists.txt | 3 -- .../command_stream_receiver.cpp | 8 +--- .../command_stream_receiver_hw_base.inl | 7 +-- .../experimental_command_buffer_gen11.cpp | 6 +-- .../experimental_command_buffer_gen12lp.cpp | 6 +-- .../gen8/experimental_command_buffer_gen8.cpp | 6 +-- .../gen9/experimental_command_buffer_gen9.cpp | 6 +-- runtime/helpers/task_information.cpp | 4 ++ unit_tests/gtpin/gtpin_tests.cpp | 44 +++++++++++++++++++ .../mocks/mock_experimental_command_buffer.h | 4 +- 17 files changed, 80 insertions(+), 33 deletions(-) rename {runtime => core}/command_stream/experimental_command_buffer.cpp (98%) rename {runtime => core}/command_stream/experimental_command_buffer.h (97%) rename {runtime => core}/command_stream/experimental_command_buffer.inl (98%) diff --git a/core/command_stream/CMakeLists.txt b/core/command_stream/CMakeLists.txt index e79c7fb517..308859fdd4 100644 --- a/core/command_stream/CMakeLists.txt +++ b/core/command_stream/CMakeLists.txt @@ -10,6 +10,9 @@ set(NEO_CORE_COMMAND_STREAM ${CMAKE_CURRENT_SOURCE_DIR}/csr_definitions.h ${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.cpp ${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.h + ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.h + ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.inl ${CMAKE_CURRENT_SOURCE_DIR}/linear_stream.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linear_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/preemption_mode.h diff --git a/runtime/command_stream/experimental_command_buffer.cpp b/core/command_stream/experimental_command_buffer.cpp similarity index 98% rename from runtime/command_stream/experimental_command_buffer.cpp rename to core/command_stream/experimental_command_buffer.cpp index c6a70d7fc6..2fba58439e 100644 --- a/runtime/command_stream/experimental_command_buffer.cpp +++ b/core/command_stream/experimental_command_buffer.cpp @@ -5,7 +5,7 @@ * */ -#include "runtime/command_stream/experimental_command_buffer.h" +#include "core/command_stream/experimental_command_buffer.h" #include "core/command_stream/linear_stream.h" #include "core/memory_manager/internal_allocation_storage.h" diff --git a/runtime/command_stream/experimental_command_buffer.h b/core/command_stream/experimental_command_buffer.h similarity index 97% rename from runtime/command_stream/experimental_command_buffer.h rename to core/command_stream/experimental_command_buffer.h index bc661587c6..9246c8dd96 100644 --- a/runtime/command_stream/experimental_command_buffer.h +++ b/core/command_stream/experimental_command_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * diff --git a/runtime/command_stream/experimental_command_buffer.inl b/core/command_stream/experimental_command_buffer.inl similarity index 98% rename from runtime/command_stream/experimental_command_buffer.inl rename to core/command_stream/experimental_command_buffer.inl index f5135cefe0..b95256a694 100644 --- a/runtime/command_stream/experimental_command_buffer.inl +++ b/core/command_stream/experimental_command_buffer.inl @@ -5,12 +5,12 @@ * */ +#include "core/command_stream/experimental_command_buffer.h" #include "core/command_stream/linear_stream.h" #include "core/execution_environment/root_device_environment.h" #include "core/helpers/hw_helper.h" #include "core/memory_manager/graphics_allocation.h" #include "runtime/command_stream/command_stream_receiver_hw.h" -#include "runtime/command_stream/experimental_command_buffer.h" namespace NEO { diff --git a/core/device/device.cpp b/core/device/device.cpp index 647a074972..c95e2e0066 100644 --- a/core/device/device.cpp +++ b/core/device/device.cpp @@ -7,6 +7,7 @@ #include "core/device/device.h" +#include "core/command_stream/experimental_command_buffer.h" #include "core/command_stream/preemption.h" #include "core/execution_environment/root_device_environment.h" #include "core/helpers/hw_helper.h" @@ -15,7 +16,6 @@ #include "core/os_interface/os_interface.h" #include "core/os_interface/os_time.h" #include "runtime/command_stream/command_stream_receiver.h" -#include "runtime/command_stream/experimental_command_buffer.h" #include "runtime/device/driver_info.h" #include "runtime/source_level_debugger/source_level_debugger.h" diff --git a/runtime/command_queue/command_queue.cpp b/runtime/command_queue/command_queue.cpp index aef15bf1cb..caf55fcca7 100644 --- a/runtime/command_queue/command_queue.cpp +++ b/runtime/command_queue/command_queue.cpp @@ -150,6 +150,10 @@ void CommandQueue::waitUntilComplete(uint32_t taskCountToWait, FlushStamp flushS useQuickKmdSleep, forcePowerSavingMode); DEBUG_BREAK_IF(getHwTag() < taskCountToWait); + if (gtpinIsGTPinInitialized()) { + gtpinNotifyTaskCompletion(taskCountToWait); + } + if (auto bcsCsr = getBcsCommandStreamReceiver()) { bcsCsr->waitForTaskCountWithKmdNotifyFallback(bcsTaskCount, 0, false, false); bcsCsr->waitForTaskCountAndCleanTemporaryAllocationList(bcsTaskCount); diff --git a/runtime/command_queue/enqueue_common.h b/runtime/command_queue/enqueue_common.h index 8838e76375..965823d82b 100644 --- a/runtime/command_queue/enqueue_common.h +++ b/runtime/command_queue/enqueue_common.h @@ -794,6 +794,10 @@ CompletionStamp CommandQueueHw::enqueueNonBlocked( dispatchFlags, getDevice()); + if (gtpinIsGTPinInitialized()) { + gtpinNotifyFlushTask(completionStamp.taskCount); + } + return completionStamp; } diff --git a/runtime/command_stream/CMakeLists.txt b/runtime/command_stream/CMakeLists.txt index 3bfc658d8d..b6bad6f9de 100644 --- a/runtime/command_stream/CMakeLists.txt +++ b/runtime/command_stream/CMakeLists.txt @@ -29,9 +29,6 @@ set(RUNTIME_SRCS_COMMAND_STREAM ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_simulated_common_hw_base.inl ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_simulated_common_hw_bdw_plus.inl ${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.inl ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/per_dss_backed_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tbx_command_stream_receiver.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tbx_command_stream_receiver.h diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 74b99e872f..f207655c25 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -7,6 +7,7 @@ #include "runtime/command_stream/command_stream_receiver.h" +#include "core/command_stream/experimental_command_buffer.h" #include "core/command_stream/preemption.h" #include "core/command_stream/scratch_space_controller.h" #include "core/device/device.h" @@ -25,11 +26,9 @@ #include "core/utilities/cpuintrinsics.h" #include "core/utilities/tag_allocator.h" #include "runtime/built_ins/built_ins.h" -#include "runtime/command_stream/experimental_command_buffer.h" -#include "runtime/gtpin/gtpin_notify.h" -#include "runtime/platform/platform.h" namespace NEO { + // Global table of CommandStreamReceiver factories for HW and tests CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE] = {}; @@ -226,9 +225,6 @@ bool CommandStreamReceiver::waitForCompletionWithTimeout(bool enableTimeout, int } } if (*getTagAddress() >= taskCountToWait) { - if (gtpinIsGTPinInitialized()) { - gtpinNotifyTaskCompletion(taskCountToWait); - } return true; } return false; diff --git a/runtime/command_stream/command_stream_receiver_hw_base.inl b/runtime/command_stream/command_stream_receiver_hw_base.inl index ebfc44c3dd..3f9dd41b2a 100644 --- a/runtime/command_stream/command_stream_receiver_hw_base.inl +++ b/runtime/command_stream/command_stream_receiver_hw_base.inl @@ -5,6 +5,7 @@ * */ +#include "core/command_stream/experimental_command_buffer.h" #include "core/command_stream/linear_stream.h" #include "core/command_stream/preemption.h" #include "core/command_stream/scratch_space_controller_base.h" @@ -28,8 +29,6 @@ #include "core/os_interface/os_context.h" #include "core/utilities/tag_allocator.h" #include "runtime/command_stream/command_stream_receiver_hw.h" -#include "runtime/command_stream/experimental_command_buffer.h" -#include "runtime/gtpin/gtpin_notify.h" #include "runtime/helpers/hardware_commands_helper.h" #include "command_stream_receiver_hw_ext.inl" @@ -515,10 +514,6 @@ CompletionStamp CommandStreamReceiverHw::flushTask( this->taskLevel += levelClosed ? 1 : 0; - if (gtpinIsGTPinInitialized()) { - gtpinNotifyFlushTask(completionStamp.taskCount); - } - return completionStamp; } diff --git a/runtime/gen11/experimental_command_buffer_gen11.cpp b/runtime/gen11/experimental_command_buffer_gen11.cpp index ea5ca38541..b8ff110d66 100644 --- a/runtime/gen11/experimental_command_buffer_gen11.cpp +++ b/runtime/gen11/experimental_command_buffer_gen11.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "core/command_stream/experimental_command_buffer.h" +#include "core/command_stream/experimental_command_buffer.inl" #include "core/helpers/hw_helper.h" -#include "runtime/command_stream/experimental_command_buffer.h" -#include "runtime/command_stream/experimental_command_buffer.inl" namespace NEO { typedef ICLFamily GfxFamily; diff --git a/runtime/gen12lp/experimental_command_buffer_gen12lp.cpp b/runtime/gen12lp/experimental_command_buffer_gen12lp.cpp index ae8a58483e..ea9ef24a07 100644 --- a/runtime/gen12lp/experimental_command_buffer_gen12lp.cpp +++ b/runtime/gen12lp/experimental_command_buffer_gen12lp.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "core/command_stream/experimental_command_buffer.h" +#include "core/command_stream/experimental_command_buffer.inl" #include "core/helpers/hw_helper.h" -#include "runtime/command_stream/experimental_command_buffer.h" -#include "runtime/command_stream/experimental_command_buffer.inl" namespace NEO { typedef TGLLPFamily GfxFamily; diff --git a/runtime/gen8/experimental_command_buffer_gen8.cpp b/runtime/gen8/experimental_command_buffer_gen8.cpp index 1f219cf9d7..e486d7ceb4 100644 --- a/runtime/gen8/experimental_command_buffer_gen8.cpp +++ b/runtime/gen8/experimental_command_buffer_gen8.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "core/command_stream/experimental_command_buffer.h" +#include "core/command_stream/experimental_command_buffer.inl" #include "core/helpers/hw_helper.h" -#include "runtime/command_stream/experimental_command_buffer.h" -#include "runtime/command_stream/experimental_command_buffer.inl" namespace NEO { typedef BDWFamily GfxFamily; diff --git a/runtime/gen9/experimental_command_buffer_gen9.cpp b/runtime/gen9/experimental_command_buffer_gen9.cpp index bf323421c1..0f043ce6f3 100644 --- a/runtime/gen9/experimental_command_buffer_gen9.cpp +++ b/runtime/gen9/experimental_command_buffer_gen9.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "core/command_stream/experimental_command_buffer.h" +#include "core/command_stream/experimental_command_buffer.inl" #include "core/helpers/hw_helper.h" -#include "runtime/command_stream/experimental_command_buffer.h" -#include "runtime/command_stream/experimental_command_buffer.inl" namespace NEO { typedef SKLFamily GfxFamily; diff --git a/runtime/helpers/task_information.cpp b/runtime/helpers/task_information.cpp index 6b187e4411..4f80eaffbe 100644 --- a/runtime/helpers/task_information.cpp +++ b/runtime/helpers/task_information.cpp @@ -260,6 +260,10 @@ CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminate dispatchFlags, commandQueue.getDevice()); + if (gtpinIsGTPinInitialized()) { + gtpinNotifyFlushTask(completionStamp.taskCount); + } + if (printfHandler) { commandQueue.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); printfHandler.get()->printEnqueueOutput(); diff --git a/unit_tests/gtpin/gtpin_tests.cpp b/unit_tests/gtpin/gtpin_tests.cpp index a39b2557fc..adb9f382f0 100644 --- a/unit_tests/gtpin/gtpin_tests.cpp +++ b/unit_tests/gtpin/gtpin_tests.cpp @@ -30,6 +30,7 @@ #include "unit_tests/helpers/kernel_binary_helper.h" #include "unit_tests/helpers/test_files.h" #include "unit_tests/helpers/variable_backup.h" +#include "unit_tests/mocks/mock_buffer.h" #include "unit_tests/mocks/mock_command_queue.h" #include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_device.h" @@ -2349,4 +2350,47 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenOnKernelCreateIsCalledWithN EXPECT_EQ(prevCreateCount, KernelCreateCallbackCount); } +HWTEST_F(GTPinTests, givenGtPinInitializedWhenSubmittingKernelCommandThenFlushedTaskCountIsNotified) { + auto mockCmdQ = std::make_unique>(pContext, pDevice, nullptr); + + auto onKernelSubmitFnc = [](command_buffer_handle_t cb, uint64_t kernelId, uint32_t *entryOffset, resource_handle_t *resource) { return; }; + + gtpinCallbacks.onContextCreate = OnContextCreate; + gtpinCallbacks.onContextDestroy = OnContextDestroy; + gtpinCallbacks.onKernelCreate = OnKernelCreate; + gtpinCallbacks.onKernelSubmit = onKernelSubmitFnc; + gtpinCallbacks.onCommandBufferCreate = OnCommandBufferCreate; + gtpinCallbacks.onCommandBufferComplete = OnCommandBufferComplete; + retFromGtPin = GTPin_Init(>pinCallbacks, &driverServices, nullptr); + EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin); + + IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr; + mockCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 128, ih1); + mockCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 128, ih2); + mockCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 128, ih3); + + PreemptionMode preemptionMode = pDevice->getPreemptionMode(); + auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 128, GraphicsAllocation::AllocationType::COMMAND_BUFFER})); + + std::vector surfaces; + auto kernelOperation = std::make_unique(cmdStream, *mockCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage()); + MockKernelWithInternals kernel(*pDevice); + kernel.kernelInfo.usesSsh = true; + kernelOperation->setHeaps(ih1, ih2, ih3); + + bool flushDC = false; + bool slmUsed = false; + bool ndRangeKernel = false; + + gtpinNotifyKernelSubmit(kernel, mockCmdQ.get()); + + std::unique_ptr command(new CommandComputeKernel(*mockCmdQ, kernelOperation, surfaces, flushDC, slmUsed, ndRangeKernel, nullptr, preemptionMode, kernel, 1)); + CompletionStamp stamp = command->submit(20, false); + + ASSERT_EQ(1u, kernelExecQueue.size()); + + EXPECT_TRUE(kernelExecQueue[0].isTaskCountValid); + EXPECT_EQ(kernelExecQueue[0].taskCount, stamp.taskCount); +} + } // namespace ULT diff --git a/unit_tests/mocks/mock_experimental_command_buffer.h b/unit_tests/mocks/mock_experimental_command_buffer.h index 1b8808b460..88dc166b81 100644 --- a/unit_tests/mocks/mock_experimental_command_buffer.h +++ b/unit_tests/mocks/mock_experimental_command_buffer.h @@ -1,12 +1,12 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once -#include "runtime/command_stream/experimental_command_buffer.h" +#include "core/command_stream/experimental_command_buffer.h" namespace NEO {