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:
Mateusz Jablonski
2018-10-29 10:38:53 +01:00
committed by sys_ocldev
parent 1dc3a94ac8
commit ead2e2ea6d
50 changed files with 184 additions and 289 deletions

View File

@@ -17,6 +17,7 @@
#include "runtime/context/driver_diagnostics.h"
#include "runtime/device/device.h"
#include "runtime/device_queue/device_queue.h"
#include "runtime/event/user_event.h"
#include "runtime/gtpin/gtpin_notify.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/get_info.h"

View File

@@ -7,12 +7,11 @@
#include "runtime/built_ins/builtins_dispatch_builder.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/command_queue/command_queue_hw.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/device_queue/device_queue.h"
#include "runtime/event/event.h"
#include "runtime/event/user_event.h"
#include "runtime/event/event_builder.h"
#include "runtime/gtpin/gtpin_notify.h"
#include "runtime/helpers/aligned_memory.h"
@@ -586,4 +585,4 @@ void CommandQueue::obtainNewTimestampPacketNodes(size_t numberOfNodes, Timestamp
timestampPacketContainer->add(allocator->getTag());
}
}
} // namespace OCLRT
} // namespace OCLRT

View File

@@ -6,13 +6,9 @@
*/
#pragma once
#include "runtime/api/cl_types.h"
#include "runtime/indirect_heap/indirect_heap.h"
#include "runtime/helpers/base_object.h"
#include "runtime/helpers/properties_helper.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/event/user_event.h"
#include "runtime/os_interface/performance_counters.h"
#include "runtime/helpers/task_information.h"
#include "instrumentation.h"
#include <atomic>
#include <cstdint>
@@ -21,11 +17,14 @@ class Buffer;
class LinearStream;
class Context;
class Device;
class Event;
class EventBuilder;
class FlushStampTracker;
class Image;
class IndirectHeap;
class Kernel;
class MemObj;
class PerformanceCounters;
struct CompletionStamp;
enum class QueuePriority {

View File

@@ -331,7 +331,6 @@ class CommandQueueHw : public CommandQueue {
protected:
MOCKABLE_VIRTUAL void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo){};
MOCKABLE_VIRTUAL bool createAllocationForHostSurface(HostPtrSurface &surface);
size_t calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image);
private:

View File

@@ -9,6 +9,7 @@
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/event/event.h"
#include "runtime/event/event_builder.h"
#include "runtime/helpers/get_info.h"
#include "runtime/helpers/mipmap.h"

View File

@@ -14,6 +14,7 @@
#include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/command_queue/hardware_interface.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/event/user_event.h"
#include "runtime/event/event_builder.h"
#include "runtime/gtpin/gtpin_notify.h"
#include "runtime/helpers/array_count.h"
@@ -30,7 +31,6 @@
#include "runtime/program/block_kernel_manager.h"
#include "runtime/utilities/range.h"
#include "runtime/utilities/tag_allocator.h"
#include <memory>
#include <new>
namespace OCLRT {
@@ -722,30 +722,6 @@ void CommandQueueHw<GfxFamily>::computeOffsetsValueForRectCommands(size_t *buffe
*hostOffset = hostOrigin[2] * computedHostSlicePitch + hostOrigin[1] * computedHostRowPitch + hostOrigin[0];
}
template <typename GfxFamily>
bool CommandQueueHw<GfxFamily>::createAllocationForHostSurface(HostPtrSurface &surface) {
auto memoryManager = device->getCommandStreamReceiver().getMemoryManager();
GraphicsAllocation *allocation = nullptr;
allocation = memoryManager->allocateGraphicsMemoryForHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), device->isFullRangeSvm());
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
// Try with no host pointer allocation and copy
allocation = memoryManager->allocateGraphicsMemory(surface.getSurfaceSize(), MemoryConstants::pageSize, false, false);
if (allocation) {
memcpy_s(allocation->getUnderlyingBuffer(), allocation->getUnderlyingBufferSize(), surface.getMemoryPointer(), surface.getSurfaceSize());
}
}
if (allocation == nullptr) {
return false;
}
allocation->taskCount = Event::eventNotReady;
surface.setAllocation(allocation);
auto storageForAllocation = device->getCommandStreamReceiver().getInternalAllocationStorage();
storageForAllocation->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
return true;
}
template <typename GfxFamily>
size_t CommandQueueHw<GfxFamily>::calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image) {
auto bytesPerPixel = image->getSurfaceFormatInfo().ImageElementSizeInBytes;

View File

@@ -90,7 +90,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
Surface *surfaces[] = {&bufferSurf, &hostPtrSurf};
if (size != 0) {
bool status = createAllocationForHostSurface(hostPtrSurf);
bool status = getDevice().getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, getDevice());
if (!status) {
return CL_OUT_OF_RESOURCES;
}

View File

@@ -76,7 +76,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBufferRect(
if (region[0] != 0 &&
region[1] != 0 &&
region[2] != 0) {
bool status = createAllocationForHostSurface(hostPtrSurf);
bool status = getDevice().getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, getDevice());
if (!status) {
return CL_OUT_OF_RESOURCES;
}

View File

@@ -10,6 +10,7 @@
#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/helpers/surface_formats.h"
#include "runtime/helpers/cache_policy.h"
#include "runtime/helpers/kernel_commands.h"
@@ -81,7 +82,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
if (region[0] != 0 &&
region[1] != 0 &&
region[2] != 0) {
bool status = createAllocationForHostSurface(hostPtrSurf);
bool status = getDevice().getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, getDevice());
if (!status) {
return CL_OUT_OF_RESOURCES;
}

View File

@@ -89,7 +89,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
Surface *surfaces[] = {&bufferSurf, &hostPtrSurf};
if (size != 0) {
bool status = createAllocationForHostSurface(hostPtrSurf);
bool status = getDevice().getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, getDevice());
if (!status) {
return CL_OUT_OF_RESOURCES;
}

View File

@@ -75,7 +75,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
if (region[0] != 0 &&
region[1] != 0 &&
region[2] != 0) {
bool status = createAllocationForHostSurface(hostPtrSurf);
bool status = getDevice().getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, getDevice());
if (!status) {
return CL_OUT_OF_RESOURCES;
}

View File

@@ -76,7 +76,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
if (region[0] != 0 &&
region[1] != 0 &&
region[2] != 0) {
bool status = createAllocationForHostSurface(hostPtrSurf);
bool status = getDevice().getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, getDevice());
if (!status) {
return CL_OUT_OF_RESOURCES;
}

View File

@@ -5,17 +5,20 @@
*
*/
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/command_stream/experimental_command_buffer.h"
#include "runtime/command_stream/preemption.h"
#include "runtime/device/device.h"
#include "runtime/event/event.h"
#include "runtime/gtpin/gtpin_notify.h"
#include "runtime/helpers/array_count.h"
#include "runtime/helpers/cache_policy.h"
#include "runtime/helpers/flush_stamp.h"
#include "runtime/helpers/string.h"
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/memory_manager/surface.h"
#include "runtime/os_interface/os_interface.h"
namespace OCLRT {
@@ -341,4 +344,25 @@ std::unique_lock<CommandStreamReceiver::MutexType> CommandStreamReceiver::obtain
AllocationsList &CommandStreamReceiver::getTemporaryAllocations() { return internalAllocationStorage->getTemporaryAllocations(); }
AllocationsList &CommandStreamReceiver::getAllocationsForReuse() { return internalAllocationStorage->getAllocationsForReuse(); }
bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surface, Device &device) {
auto memoryManager = getMemoryManager();
GraphicsAllocation *allocation = nullptr;
allocation = memoryManager->allocateGraphicsMemoryForHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), device.isFullRangeSvm());
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
// Try with no host pointer allocation and copy
allocation = memoryManager->allocateGraphicsMemory(surface.getSurfaceSize(), MemoryConstants::pageSize, false, false);
if (allocation) {
memcpy_s(allocation->getUnderlyingBuffer(), allocation->getUnderlyingBufferSize(), surface.getMemoryPointer(), surface.getSurfaceSize());
}
}
if (allocation == nullptr) {
return false;
}
allocation->taskCount = Event::eventNotReady;
surface.setAllocation(allocation);
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
return true;
}
} // namespace OCLRT

View File

@@ -28,6 +28,7 @@ class ExecutionEnvironment;
class ExperimentalCommandBuffer;
class GmmPageTableMngr;
class GraphicsAllocation;
class HostPtrSurface;
class IndirectHeap;
class InternalAllocationStorage;
class LinearStream;
@@ -151,6 +152,7 @@ class CommandStreamReceiver {
AllocationsList &getTemporaryAllocations();
AllocationsList &getAllocationsForReuse();
InternalAllocationStorage *getInternalAllocationStorage() const { return internalAllocationStorage.get(); }
bool createAllocationForHostSurface(HostPtrSurface &surface, Device &device);
protected:
void cleanupResources();

View File

@@ -9,9 +9,11 @@
#include "runtime/command_stream/experimental_command_buffer.h"
#include "runtime/command_stream/linear_stream.h"
#include "runtime/device/device.h"
#include "runtime/event/event.h"
#include "runtime/gtpin/gtpin_notify.h"
#include "runtime/helpers/cache_policy.h"
#include "runtime/helpers/flat_batch_buffer_helper_hw.h"
#include "runtime/helpers/flush_stamp.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/helpers/preamble.h"
#include "runtime/helpers/ptr_math.h"
@@ -24,7 +26,6 @@
#include "runtime/command_stream/preemption.h"
#include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/utilities/tag_allocator.h"
#include "command_stream_receiver_hw.h"
namespace OCLRT {

View File

@@ -8,6 +8,7 @@
#include "cl_api_tests.h"
#include "runtime/context/context.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/event/event.h"
#include "unit_tests/os_interface/mock_performance_counters.h"
using namespace OCLRT;

View File

@@ -8,6 +8,7 @@
#include "cl_api_tests.h"
#include "runtime/context/context.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/event/event.h"
using namespace OCLRT;

View File

@@ -9,6 +9,7 @@
#include "runtime/command_queue/command_queue.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/event/user_event.h"
using namespace OCLRT;

View File

@@ -6,6 +6,8 @@
*/
#include "runtime/command_queue/command_queue.h"
#include "runtime/event/event.h"
#include "runtime/helpers/kernel_commands.h"
#include "runtime/helpers/ptr_math.h"
#include "gen_cmd_parse.h"
#include "unit_tests/aub_tests/fixtures/aub_fixture.h"

View File

@@ -5,6 +5,7 @@
*
*/
#include "runtime/event/event.h"
#include "runtime/helpers/kernel_commands.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/mem_obj/buffer.h"

View File

@@ -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);
}

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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;

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -13,14 +13,17 @@
#include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/memory_manager/surface.h"
#include "test.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/unit_test_helper.h"
#include "unit_tests/mocks/mock_buffer.h"
#include "unit_tests/mocks/mock_builtins.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_csr.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/mocks/mock_program.h"
#include "gmock/gmock.h"
@@ -373,3 +376,88 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA
executionEnvironment->memoryManager->freeGraphicsMemory(graphicsAllocation);
}
struct CreateAllocationForHostSurfaceTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new ExecutionEnvironment;
gmockMemoryManager = new ::testing::NiceMock<GMockMemoryManager>(*executionEnvironment);
executionEnvironment->memoryManager.reset(gmockMemoryManager);
device.reset(Device::create<Device>(&hwInfo, executionEnvironment, 0u));
commandStreamReceiver = &device->getCommandStreamReceiver();
}
HardwareInfo hwInfo = *platformDevices[0];
ExecutionEnvironment *executionEnvironment = nullptr;
GMockMemoryManager *gmockMemoryManager = nullptr;
std::unique_ptr<Device> device;
CommandStreamReceiver *commandStreamReceiver = nullptr;
};
TEST_F(CreateAllocationForHostSurfaceTest, givenReadOnlyHostPointerWhenAllocationForHostSurfaceWithPtrCopyAllowedIsCreatedThenCopyAllocationIsCreatedAndMemoryCopied) {
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 = commandStreamReceiver->createAllocationForHostSurface(surface, *device);
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 = commandStreamReceiver->peekLatestFlushedTaskCount();
}
TEST_F(CreateAllocationForHostSurfaceTest, givenReadOnlyHostPointerWhenAllocationForHostSurfaceWithPtrCopyNotAllowedIsCreatedThenCopyAllocationIsNotCreated) {
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 = commandStreamReceiver->createAllocationForHostSurface(surface, *device);
EXPECT_FALSE(result);
auto allocation = surface.getAllocation();
EXPECT_EQ(nullptr, allocation);
}
struct ReducedAddrSpaceCommandStreamReceiverTest : public CreateAllocationForHostSurfaceTest {
void SetUp() override {
hwInfo.capabilityTable.gpuAddressSpace = MemoryConstants::max32BitAddress;
CreateAllocationForHostSurfaceTest::SetUp();
}
};
TEST_F(ReducedAddrSpaceCommandStreamReceiverTest,
givenReducedGpuAddressSpaceWhenAllocationForHostSurfaceIsCreatedThenAllocateGraphicsMemoryForNonSvmHostPtrIsCalled) {
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 = commandStreamReceiver->createAllocationForHostSurface(surface, *device);
EXPECT_FALSE(result);
}

View File

@@ -7,6 +7,7 @@
#include "test.h"
#include "runtime/command_stream/submissions_aggregator.h"
#include "runtime/event/event.h"
#include "runtime/helpers/flush_stamp.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_device.h"

View File

@@ -5,8 +5,9 @@
*
*/
#include "runtime/event/user_event.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "driver_diagnostics_tests.h"
#include "unit_tests/context/driver_diagnostics_tests.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/fixtures/buffer_fixture.h"

View File

@@ -8,6 +8,7 @@
#include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/command_queue/local_id_gen.h"
#include "runtime/device_queue/device_queue_hw.h"
#include "runtime/event/user_event.h"
#include "runtime/helpers/per_thread_data.h"
#include "runtime/kernel/kernel.h"
#include "runtime/builtin_kernels_simulation/scheduler_simulation.h"

View File

@@ -10,6 +10,7 @@
#include "runtime/command_queue/command_queue_hw.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/command_stream/linear_stream.h"
#include "runtime/event/user_event.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"

View File

@@ -7,6 +7,7 @@
#include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/command_queue/hardware_interface.h"
#include "runtime/event/user_event.h"
#include "runtime/helpers/options.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/utilities/tag_allocator.h"

View File

@@ -7,6 +7,7 @@
#include "runtime/built_ins/builtins_dispatch_builder.h"
#include "runtime/command_stream/command_stream_receiver_hw.h"
#include "runtime/helpers/flush_stamp.h"
#include "runtime/helpers/options.h"
#include "runtime/helpers/surface_formats.h"
#include "runtime/kernel/kernel.h"

View File

@@ -7,6 +7,7 @@
#include "test.h"
#include "runtime/command_queue/command_queue_hw.h"
#include "runtime/event/user_event.h"
#include "runtime/mem_obj/image.h"
#include "unit_tests/fixtures/image_fixture.h"
#include "unit_tests/mocks/mock_context.h"

View File

@@ -67,7 +67,6 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
public:
using BaseClass::commandStream;
using BaseClass::createAllocationForHostSurface;
using BaseClass::obtainNewTimestampPacketNodes;
using BaseClass::timestampPacketContainer;
@@ -134,16 +133,6 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
return this->commandStream;
}
bool doNotCallCreateAllocationForHostSurface = false;
size_t createAllocationForHostSurfaceCounter = 0;
bool createAllocationForHostSurface(HostPtrSurface &surface) override {
createAllocationForHostSurfaceCounter++;
if (doNotCallCreateAllocationForHostSurface) {
return false;
}
return BaseClass::createAllocationForHostSurface(surface);
}
void updateFromCompletionStamp(const CompletionStamp &completionStamp) override {
BaseClass::updateFromCompletionStamp(completionStamp);
const uint32_t &referenceToCompletionStampTaskCount = completionStamp.taskCount;

View File

@@ -7,7 +7,7 @@
#pragma once
#include "runtime/event/event.h"
#include "runtime/event/user_event.h"
#include "runtime/event/event_builder.h"
namespace OCLRT {

View File

@@ -5,23 +5,16 @@
*
*/
#include "hw_cmds.h"
#include "runtime/command_stream/device_command_stream.h"
#include "runtime/command_stream/linear_stream.h"
#include "runtime/command_stream/preemption.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/options.h"
#include "runtime/helpers/flush_stamp.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/os_interface/linux/drm_allocation.h"
#include "runtime/os_interface/linux/drm_buffer_object.h"
#include "runtime/os_interface/linux/drm_command_stream.h"
#include "runtime/os_interface/linux/drm_memory_manager.h"
#include "runtime/os_interface/linux/os_interface.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/gen_common/gen_cmd_parse.h"
#include "unit_tests/helpers/hw_parse.h"
#include "unit_tests/mocks/mock_program.h"
#include "unit_tests/mocks/mock_host_ptr_manager.h"
@@ -30,9 +23,6 @@
#include "test.h"
#include "drm/i915_drm.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <iostream>
#include <memory>
using namespace OCLRT;

View File

@@ -1,29 +1,14 @@
/*
* 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 "unit_tests/fixtures/scenario_test_fixture.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "runtime/event/event.h"
#include "runtime/event/user_event.h"
#include "runtime/helpers/options.h"
#include "gtest/gtest.h"

View File

@@ -1,29 +1,15 @@
/*
* 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 "unit_tests/fixtures/scenario_test_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "runtime/event/user_event.h"
#include "runtime/helpers/options.h"
#include "runtime/platform/platform.h"
#include "runtime/event/async_events_handler.h"

View File

@@ -6,7 +6,7 @@
*/
#include "runtime/context/context.h"
#include "runtime/event/event.h"
#include "runtime/event/user_event.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/sharings/sharing.h"

View File

@@ -8,7 +8,7 @@
#include "runtime/command_queue/command_queue.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "runtime/device/device.h"
#include "runtime/event/event.h"
#include "runtime/event/user_event.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/mem_obj/image.h"