diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 579a1fcb64..ad92a09289 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -26,6 +26,7 @@ #include "runtime/helpers/ptr_math.h" #include "runtime/memory_manager/graphics_allocation.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" +#include "runtime/gmm_helper/gmm_helper.h" #include namespace OCLRT { @@ -405,7 +406,7 @@ void AUBCommandStreamReceiverHw::makeResident(GraphicsAllocation &gfx template bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxAllocation) { auto cpuAddress = gfxAllocation.getUnderlyingBuffer(); - auto gpuAddress = gfxAllocation.getGpuAddress(); + auto gpuAddress = Gmm::decanonize(gfxAllocation.getGpuAddress()); auto size = gfxAllocation.getUnderlyingBufferSize(); auto allocType = gfxAllocation.getAllocationType(); diff --git a/unit_tests/aub_tests/CMakeLists.txt b/unit_tests/aub_tests/CMakeLists.txt index 5e624451ee..a9ef736b32 100644 --- a/unit_tests/aub_tests/CMakeLists.txt +++ b/unit_tests/aub_tests/CMakeLists.txt @@ -90,6 +90,7 @@ else(MSVC) ) endif(MSVC) +add_subdirectory(gen8) add_subdirectory(gen9) target_link_libraries(igdrcl_aub_tests igdrcl_mocks) diff --git a/unit_tests/aub_tests/aub_tests_configuration.h b/unit_tests/aub_tests/aub_tests_configuration.h new file mode 100644 index 0000000000..38577a1f2c --- /dev/null +++ b/unit_tests/aub_tests/aub_tests_configuration.h @@ -0,0 +1,30 @@ +/* + * 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. + */ + +#pragma once + +struct AubTestsConfig { + bool testCanonicalAddress; +}; + +template +AubTestsConfig GetAubTestsConfig(); diff --git a/unit_tests/aub_tests/aub_tests_configuration.inl b/unit_tests/aub_tests/aub_tests_configuration.inl new file mode 100644 index 0000000000..2b8f70b769 --- /dev/null +++ b/unit_tests/aub_tests/aub_tests_configuration.inl @@ -0,0 +1,31 @@ +/* + * 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. + */ + +#pragma once +#include "unit_tests/aub_tests/aub_tests_configuration.h" + +template +AubTestsConfig GetAubTestsConfig() { + AubTestsConfig aubTestsConfig; + aubTestsConfig.testCanonicalAddress = true; + return aubTestsConfig; +} \ No newline at end of file diff --git a/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp b/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp index 36416889bb..ff8640a26c 100644 --- a/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp +++ b/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 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"), @@ -26,6 +26,7 @@ #include "runtime/mem_obj/buffer.h" #include "unit_tests/aub_tests/command_queue/command_enqueue_fixture.h" #include "unit_tests/mocks/mock_context.h" +#include "unit_tests/aub_tests/aub_tests_configuration.h" #include "test.h" using namespace OCLRT; @@ -111,3 +112,42 @@ INSTANTIATE_TEST_CASE_P(AUBReadBuffer_simple, 1 * sizeof(cl_float), 2 * sizeof(cl_float), 3 * sizeof(cl_float))); + +HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) { + if (!GetAubTestsConfig().testCanonicalAddress) { + return; + } + + MockContext context; + + cl_float srcMemory[] = {1.0f, 2.0f, 3.0f, 4.0f}; + cl_float dstMemory[] = {0.0f, 0.0f, 0.0f, 0.0f}; + GraphicsAllocation *srcAlocation = new GraphicsAllocation(srcMemory, 0xFFFF800400001000, 0xFFFF800400001000, sizeof(srcMemory)); + + std::unique_ptr srcBuffer(Buffer::createBufferHw(&context, + CL_MEM_USE_HOST_PTR, + sizeof(srcMemory), + srcAlocation->getUnderlyingBuffer(), + srcMemory, + srcAlocation, + false, + false, + false)); + ASSERT_NE(nullptr, srcBuffer); + + srcBuffer->forceDisallowCPUCopy = true; + auto retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(), + CL_TRUE, + 0, + sizeof(dstMemory), + dstMemory, + 0, + nullptr, + nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + GraphicsAllocation *dstAllocation = pCommandStreamReceiver->createAllocationAndHandleResidency(dstMemory, sizeof(dstMemory)); + cl_float *dstGpuAddress = reinterpret_cast(dstAllocation->getGpuAddress()); + + AUBCommandStreamFixture::expectMemory(dstGpuAddress, srcMemory, sizeof(dstMemory)); +} diff --git a/unit_tests/aub_tests/gen8/CMakeLists.txt b/unit_tests/aub_tests/gen8/CMakeLists.txt new file mode 100644 index 0000000000..ab252277b9 --- /dev/null +++ b/unit_tests/aub_tests/gen8/CMakeLists.txt @@ -0,0 +1,25 @@ +# 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. + +if(TESTS_GEN8) + target_sources(igdrcl_aub_tests PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_configuration.cpp + ) +endif(TESTS_GEN8) diff --git a/unit_tests/aub_tests/gen8/aub_tests_configuration.cpp b/unit_tests/aub_tests/gen8/aub_tests_configuration.cpp new file mode 100644 index 0000000000..8f9374b91e --- /dev/null +++ b/unit_tests/aub_tests/gen8/aub_tests_configuration.cpp @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#include "unit_tests/aub_tests/aub_tests_configuration.inl" +#include "runtime/gen_common/hw_cmds.h" + +using namespace OCLRT; + +template AubTestsConfig GetAubTestsConfig(); diff --git a/unit_tests/aub_tests/gen9/CMakeLists.txt b/unit_tests/aub_tests/gen9/CMakeLists.txt index 1c6316b0f2..e3cf0a965c 100644 --- a/unit_tests/aub_tests/gen9/CMakeLists.txt +++ b/unit_tests/aub_tests/gen9/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, 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"), @@ -18,12 +18,11 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) - -project(igdrcl_aub_tests) - if(TESTS_GEN9) add_subdirectory(batch_buffer) add_subdirectory(execution_model) add_subdirectory(skl) + target_sources(igdrcl_aub_tests PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_configuration.cpp + ) endif(TESTS_GEN9) diff --git a/unit_tests/aub_tests/gen9/aub_tests_configuration.cpp b/unit_tests/aub_tests/gen9/aub_tests_configuration.cpp new file mode 100644 index 0000000000..b4f96eea85 --- /dev/null +++ b/unit_tests/aub_tests/gen9/aub_tests_configuration.cpp @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#include "unit_tests/aub_tests/aub_tests_configuration.inl" +#include "runtime/gen_common/hw_cmds.h" + +using namespace OCLRT; + +template AubTestsConfig GetAubTestsConfig();