mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 15:53:13 +08:00
Move createAllocationForHostPtr method to command stream receiver
Remove not needed includes from command_queue.h Change-Id: I45963bf005471bd7716d55471474299a15e27b62 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
1dc3a94ac8
commit
ead2e2ea6d
@@ -5,35 +5,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "runtime/command_queue/enqueue_kernel.h"
|
||||
#include "runtime/command_queue/enqueue_marker.h"
|
||||
#include "runtime/command_queue/enqueue_common.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/event_builder.h"
|
||||
#include "runtime/helpers/queue_helpers.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/helpers/dispatch_info_builder.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
#include "unit_tests/fixtures/buffer_fixture.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/gen_common/matchers.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/memory_management.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_csr.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_event.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "test.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
@@ -1016,123 +1000,3 @@ HWTEST_F(CommandQueueHwTest, givenKernelSplitEnqueueReadBufferWhenBlockedThenEnq
|
||||
EXPECT_EQ(expected, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(CommandQueueHwTest, givenReadOnlyHostPointerWhenAllocationForHostSurfaceWithPtrCopyAllowedIsCreatedThenCopyAllocationIsCreatedAndMemoryCopied) {
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
ASSERT_NE(nullptr, device.get());
|
||||
::testing::NiceMock<GMockMemoryManager> *gmockMemoryManager = new ::testing::NiceMock<GMockMemoryManager>(*device->getExecutionEnvironment());
|
||||
ASSERT_NE(nullptr, gmockMemoryManager);
|
||||
|
||||
device->injectMemoryManager(gmockMemoryManager);
|
||||
MockContext *mockContext = new MockContext(device.get());
|
||||
ASSERT_NE(nullptr, mockContext);
|
||||
|
||||
auto mockCmdQ = new MockCommandQueueHw<FamilyType>(mockContext, device.get(), 0);
|
||||
ASSERT_NE(nullptr, mockCmdQ);
|
||||
|
||||
const char memory[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
size_t size = sizeof(memory);
|
||||
HostPtrSurface surface(const_cast<char *>(memory), size, true);
|
||||
|
||||
if (device->isFullRangeSvm()) {
|
||||
EXPECT_CALL(*gmockMemoryManager, populateOsHandles(::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(MemoryManager::AllocationStatus::InvalidHostPointer));
|
||||
} else {
|
||||
EXPECT_CALL(*gmockMemoryManager, allocateGraphicsMemoryForNonSvmHostPtr(::testing::_, ::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
}
|
||||
|
||||
bool result = mockCmdQ->createAllocationForHostSurface(surface);
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
auto allocation = surface.getAllocation();
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
EXPECT_NE(memory, allocation->getUnderlyingBuffer());
|
||||
EXPECT_THAT(allocation->getUnderlyingBuffer(), MemCompare(memory, size));
|
||||
|
||||
allocation->taskCount = device->getCommandStreamReceiver().peekLatestFlushedTaskCount();
|
||||
mockCmdQ->release();
|
||||
mockContext->release();
|
||||
}
|
||||
|
||||
HWTEST_F(CommandQueueHwTest, givenReadOnlyHostPointerWhenAllocationForHostSurfaceWithPtrCopyNotAllowedIsCreatedThenCopyAllocationIsNotCreated) {
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
ASSERT_NE(nullptr, device.get());
|
||||
::testing::NiceMock<GMockMemoryManager> *gmockMemoryManager = new ::testing::NiceMock<GMockMemoryManager>(*device->getExecutionEnvironment());
|
||||
ASSERT_NE(nullptr, gmockMemoryManager);
|
||||
|
||||
device->injectMemoryManager(gmockMemoryManager);
|
||||
MockContext *mockContext = new MockContext(device.get());
|
||||
ASSERT_NE(nullptr, mockContext);
|
||||
|
||||
auto mockCmdQ = new MockCommandQueueHw<FamilyType>(mockContext, device.get(), 0);
|
||||
ASSERT_NE(nullptr, mockCmdQ);
|
||||
|
||||
const char memory[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
size_t size = sizeof(memory);
|
||||
HostPtrSurface surface(const_cast<char *>(memory), size, false);
|
||||
|
||||
if (device->isFullRangeSvm()) {
|
||||
EXPECT_CALL(*gmockMemoryManager, populateOsHandles(::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(MemoryManager::AllocationStatus::InvalidHostPointer));
|
||||
} else {
|
||||
EXPECT_CALL(*gmockMemoryManager, allocateGraphicsMemoryForNonSvmHostPtr(::testing::_, ::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
}
|
||||
|
||||
bool result = mockCmdQ->createAllocationForHostSurface(surface);
|
||||
EXPECT_FALSE(result);
|
||||
|
||||
auto allocation = surface.getAllocation();
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
|
||||
mockCmdQ->release();
|
||||
mockContext->release();
|
||||
}
|
||||
|
||||
struct ReducedAddrSpaceCommandQueueHwTest : public CommandQueueHwTest {
|
||||
HardwareInfo hwInfoToModify;
|
||||
std::unique_ptr<MockDevice> device;
|
||||
MockContext *mockContext = nullptr;
|
||||
::testing::NiceMock<GMockMemoryManager> *gmockMemoryManager = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
CommandQueueHwTest::SetUp();
|
||||
hwInfoToModify = *platformDevices[0];
|
||||
hwInfoToModify.capabilityTable.gpuAddressSpace = MemoryConstants::max32BitAddress;
|
||||
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfoToModify));
|
||||
ASSERT_NE(nullptr, device.get());
|
||||
gmockMemoryManager = new ::testing::NiceMock<GMockMemoryManager>(*device->getExecutionEnvironment());
|
||||
ASSERT_NE(nullptr, gmockMemoryManager);
|
||||
device->injectMemoryManager(gmockMemoryManager);
|
||||
mockContext = new MockContext(device.get());
|
||||
ASSERT_NE(nullptr, mockContext);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
CommandQueueHwTest::TearDown();
|
||||
mockContext->release();
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST_F(ReducedAddrSpaceCommandQueueHwTest,
|
||||
givenReducedGpuAddressSpaceWhenAllocationForHostSurfaceIsCreatedThenAllocateGraphicsMemoryForNonSvmHostPtrIsCalled) {
|
||||
|
||||
std::unique_ptr<MockCommandQueueHw<FamilyType>, std::function<void(MockCommandQueueHw<FamilyType> *)>> mockCmdQ(
|
||||
new MockCommandQueueHw<FamilyType>(mockContext, device.get(), 0), [](MockCommandQueueHw<FamilyType> *ptr) { ptr->release(); });
|
||||
|
||||
char memory[8] = {};
|
||||
HostPtrSurface surface(const_cast<char *>(memory), sizeof(memory), false);
|
||||
|
||||
EXPECT_CALL(*gmockMemoryManager, allocateGraphicsMemoryForNonSvmHostPtr(::testing::_, ::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
|
||||
bool result = mockCmdQ->createAllocationForHostSurface(surface);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hw_cmds.h"
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/command_queue/gpgpu_walker.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "unit_tests/command_queue/command_enqueue_fixture.h"
|
||||
#include "gen_cmd_parse.h"
|
||||
#include "test.h"
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
/*
|
||||
* 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"),
|
||||
* 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_queue/command_queue.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "unit_tests/fixtures/buffer_fixture.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/command_stream/aub_subcapture.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
#include "unit_tests/fixtures/enqueue_handler_fixture.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "reg_configs_common.h"
|
||||
#include "runtime/helpers/preamble.h"
|
||||
#include "runtime/memory_manager/allocations_list.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/command_queue/command_enqueue_fixture.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "unit_tests/command_queue/command_enqueue_fixture.h"
|
||||
#include "gen_cmd_parse.h"
|
||||
#include "test.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
#include "unit_tests/command_stream/command_stream_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "reg_configs_common.h"
|
||||
#include "runtime/helpers/dispatch_info.h"
|
||||
#include "runtime/memory_manager/memory_constants.h"
|
||||
|
||||
@@ -5,19 +5,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/memory_manager/allocations_list.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
#include "unit_tests/command_queue/enqueue_map_buffer_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/buffer_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "runtime/memory_manager/allocations_list.h"
|
||||
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "reg_configs_common.h"
|
||||
#include "runtime/helpers/dispatch_info.h"
|
||||
#include "unit_tests/command_queue/enqueue_write_buffer_rect_fixture.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
/*
|
||||
* 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"),
|
||||
* 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/event/event.h"
|
||||
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
|
||||
Reference in New Issue
Block a user