From fe912704b8309103157930b9549269a0705d6aa3 Mon Sep 17 00:00:00 2001 From: "Hoppe, Mateusz" Date: Tue, 18 Sep 2018 16:45:45 -0700 Subject: [PATCH] Enhance AubTests with TBX server capability - aub_tests started with "--tbx" option connects to TBX server - CSR is created in dual mode: TBX + AUB to dump aub file - with this enhancement it is possible to debug aub tests live Change-Id: I0302f5f4bac4c293661a149f64888770dd49343c --- runtime/os_interface/DebugVariables_base.inl | 22 ++--------- .../aub_command_stream_fixture.cpp | 34 +++++++---------- .../aub_command_stream_fixture.h | 38 +++++++++---------- unit_tests/libult/create_tbx_sockets.cpp | 24 ++++-------- unit_tests/linux/CMakeLists.txt | 21 ++-------- .../linux/linux_tests_configuration.cpp | 12 ++++++ unit_tests/main.cpp | 23 +++-------- unit_tests/tbx/CMakeLists.txt | 20 ++-------- unit_tests/tbx/tbx_tests_configuration.cpp | 12 ++++++ unit_tests/tests_configuration.h | 27 +++++-------- 10 files changed, 89 insertions(+), 144 deletions(-) create mode 100644 unit_tests/linux/linux_tests_configuration.cpp create mode 100644 unit_tests/tbx/tbx_tests_configuration.cpp diff --git a/runtime/os_interface/DebugVariables_base.inl b/runtime/os_interface/DebugVariables_base.inl index 346d69bb5f..6b777f450f 100644 --- a/runtime/os_interface/DebugVariables_base.inl +++ b/runtime/os_interface/DebugVariables_base.inl @@ -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. */ + // clang-format off /*SIMULATION FLAGS*/ DECLARE_DEBUG_VARIABLE(std::string, TbxServer, std::string("127.0.0.1"), "TCP-IP address of TBX server") @@ -33,7 +19,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpSubCaptureMode, 0, "AUB dump subcapture m DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelStartIdx, 0, "Start index of kernel to AUB capture") DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelEndIdx, -1, "End index of kernel to AUB capture") DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpToggleCaptureOnOff, 0, "Toggle AUB capture on/off") -DECLARE_DEBUG_VARIABLE(int32_t, SetCommandStreamReceiver, 0, "Set command stream receiver") +DECLARE_DEBUG_VARIABLE(int32_t, SetCommandStreamReceiver, 0, "Set command stream receiver to: 0 - HW, 1 - AUB, 2 - TBX, 3 - HW & AUB, 4 - TBX & AUB") DECLARE_DEBUG_VARIABLE(int32_t, TbxPort, 4321, "TCP-IP port of TBX server") DECLARE_DEBUG_VARIABLE(bool, FlattenBatchBufferForAUBDump, false, "Dump multi-level batch buffers to AUB as single, flat batch buffer") DECLARE_DEBUG_VARIABLE(bool, AddPatchInfoCommentsForAUBDump, false, "Dump comments containing allocations and patching information") diff --git a/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.cpp b/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.cpp index 777b1d2de2..98900164ee 100644 --- a/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.cpp +++ b/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.cpp @@ -1,32 +1,22 @@ /* - * 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/command_queue.h" #include "runtime/command_stream/command_stream_receiver.h" +#include "runtime/command_stream/tbx_command_stream_receiver.h" #include "runtime/device/device.h" + +#include "gen_cmd_parse.h" + +#include "unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h" #include "unit_tests/helpers/memory_management.h" #include "unit_tests/mocks/mock_device.h" -#include "gen_cmd_parse.h" -#include "unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h" +#include "unit_tests/tests_configuration.h" + #include "gtest/gtest.h" namespace OCLRT { @@ -40,7 +30,11 @@ void AUBCommandStreamFixture::SetUp(CommandQueue *pCmdQ) { strfilename << testInfo->test_case_name() << "_" << testInfo->name(); const auto &hwInfo = device.getHardwareInfo(); - pCommandStreamReceiver = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment); + if (testMode == TestMode::AubTestsWithTbx) { + pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, true, *device.executionEnvironment); + } else { + pCommandStreamReceiver = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment); + } ASSERT_NE(nullptr, pCommandStreamReceiver); device.resetCommandStreamReceiver(pCommandStreamReceiver); diff --git a/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h b/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h index 166325e757..cd8556f263 100644 --- a/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h +++ b/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h @@ -1,32 +1,20 @@ /* - * 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 #include "runtime/command_stream/aub_command_stream_receiver_hw.h" +#include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" +#include "runtime/command_stream/tbx_command_stream_receiver_hw.h" #include "unit_tests/command_stream/command_stream_fixture.h" +#include "unit_tests/tests_configuration.h" + #include namespace OCLRT { - class CommandStreamReceiver; class AUBCommandStreamFixture : public CommandStreamFixture { @@ -50,14 +38,24 @@ class AUBCommandStreamFixture : public CommandStreamFixture { header.readMaskHigh = 0xffffffff; header.dwordCount = (sizeof(header) / sizeof(uint32_t)) - 1; + CommandStreamReceiver *csr = pCommandStreamReceiver; + if (testMode == TestMode::AubTestsWithTbx) { + csr = reinterpret_cast> *>(pCommandStreamReceiver)->aubCSR; + } + // Write our pseudo-op to the AUB file - auto aubCsr = reinterpret_cast *>(pCommandStreamReceiver); + auto aubCsr = reinterpret_cast *>(csr); aubCsr->stream->fileHandle.write(reinterpret_cast(&header), sizeof(header)); } template void expectMemory(void *gfxAddress, const void *srcAddress, size_t length) { - auto aubCsr = reinterpret_cast *>(pCommandStreamReceiver); + CommandStreamReceiver *csr = pCommandStreamReceiver; + if (testMode == TestMode::AubTestsWithTbx) { + csr = reinterpret_cast> *>(pCommandStreamReceiver)->aubCSR; + } + + auto aubCsr = reinterpret_cast *>(csr); PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) { if (offset > length) abort(); diff --git a/unit_tests/libult/create_tbx_sockets.cpp b/unit_tests/libult/create_tbx_sockets.cpp index 2781eda1c0..386c8d0522 100644 --- a/unit_tests/libult/create_tbx_sockets.cpp +++ b/unit_tests/libult/create_tbx_sockets.cpp @@ -1,29 +1,19 @@ /* - * 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/tbx/tbx_sockets_imp.h" #include "unit_tests/mocks/mock_tbx_sockets.h" +#include "unit_tests/tests_configuration.h" namespace OCLRT { TbxSockets *TbxSockets::create() { + if (testMode == TestMode::AubTestsWithTbx) { + return new TbxSocketsImp; + } return new MockTbxSockets; } } // namespace OCLRT diff --git a/unit_tests/linux/CMakeLists.txt b/unit_tests/linux/CMakeLists.txt index 4602913083..87a7ff8228 100644 --- a/unit_tests/linux/CMakeLists.txt +++ b/unit_tests/linux/CMakeLists.txt @@ -1,31 +1,18 @@ -# 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: +# Copyright (C) 2017-2018 Intel Corporation # -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. +# SPDX-License-Identifier: MIT # -# 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. - set(IGDRCL_SRCS_linux_tests + ${CMAKE_CURRENT_SOURCE_DIR}/linux_tests_configuration.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main_linux.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/allocator_helper.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp ) set(IGDRCL_SRCS_linux_dll_tests + ${CMAKE_CURRENT_SOURCE_DIR}/linux_tests_configuration.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main_linux_dll.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_null_device_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.cpp diff --git a/unit_tests/linux/linux_tests_configuration.cpp b/unit_tests/linux/linux_tests_configuration.cpp new file mode 100644 index 0000000000..9997831299 --- /dev/null +++ b/unit_tests/linux/linux_tests_configuration.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "unit_tests/tests_configuration.h" + +namespace OCLRT { +TestMode testMode = TestMode::NotSpecified; +} // namespace OCLRT diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 967d8d6491..4256b42a33 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.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 "global_environment.h" @@ -222,6 +207,10 @@ int main(int argc, char **argv) { enable_alarm = false; } else if (!strcmp("--print_memory_op_cs", argv[i])) { printMemoryOpCallStack = true; + } else if (!strcmp("--tbx", argv[i])) { + if (testMode == TestMode::AubTests) { + testMode = TestMode::AubTestsWithTbx; + } } else if (!strcmp("--devices", argv[i])) { ++i; if (i < argc) { diff --git a/unit_tests/tbx/CMakeLists.txt b/unit_tests/tbx/CMakeLists.txt index 44c0653bb1..a2ce5e8278 100644 --- a/unit_tests/tbx/CMakeLists.txt +++ b/unit_tests/tbx/CMakeLists.txt @@ -1,26 +1,12 @@ -# 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: +# Copyright (C) 2017-2018 Intel Corporation # -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. +# SPDX-License-Identifier: MIT # -# 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. -project(igdrcl_tbx_tests) add_executable(igdrcl_tbx_tests ${CMAKE_CURRENT_SOURCE_DIR}/main_tbx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tbx_tests_configuration.cpp ${IGDRCL_SOURCE_DIR}/runtime/dll/create_command_stream.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/options.cpp $ diff --git a/unit_tests/tbx/tbx_tests_configuration.cpp b/unit_tests/tbx/tbx_tests_configuration.cpp new file mode 100644 index 0000000000..4a3cb0ad10 --- /dev/null +++ b/unit_tests/tbx/tbx_tests_configuration.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "unit_tests/tests_configuration.h" + +namespace OCLRT { +TestMode testMode = TestMode::TbxTests; +} // namespace OCLRT diff --git a/unit_tests/tests_configuration.h b/unit_tests/tests_configuration.h index c75f388d2f..45ae53e449 100644 --- a/unit_tests/tests_configuration.h +++ b/unit_tests/tests_configuration.h @@ -1,27 +1,18 @@ /* - * 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 namespace OCLRT { -enum class TestMode { NotSpecified, UnitTests, AubTests }; +enum class TestMode { NotSpecified, + UnitTests, + AubTests, + AubTestsWithTbx, + TbxTests }; + +extern TestMode testMode; } // namespace OCLRT