Update getGraphicsAllocationType

Change-Id: I7613d0d5550d8032b960f86aa117b4baf6b9216f
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski 2019-01-28 15:27:15 +01:00 committed by sys_ocldev
parent 783f408f9f
commit 3fe78d263b
11 changed files with 153 additions and 107 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2018 Intel Corporation
# Copyright (C) 2018-2019 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -10,6 +10,7 @@ set(RUNTIME_SRCS_CONTEXT
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/context_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/context.h
${CMAKE_CURRENT_SOURCE_DIR}/context.inl
${CMAKE_CURRENT_SOURCE_DIR}/context_type.h
${CMAKE_CURRENT_SOURCE_DIR}/driver_diagnostics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_diagnostics.h
)

View File

@ -1,11 +1,12 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/context/context_type.h"
#include "runtime/device/device_vector.h"
#include "runtime/context/driver_diagnostics.h"
#include "runtime/helpers/base_object.h"
@ -26,12 +27,6 @@ struct OpenCLObjectMapper<_cl_context> {
typedef class Context DerivedType;
};
enum class ContextType {
CONTEXT_TYPE_DEFAULT,
CONTEXT_TYPE_SPECIALIZED,
CONTEXT_TYPE_UNRESTRICTIVE
};
class Context : public BaseObject<_cl_context> {
public:
static const cl_ulong objectMagic = 0xA4234321DC002130LL;

View File

@ -0,0 +1,18 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
namespace OCLRT {
enum class ContextType {
CONTEXT_TYPE_DEFAULT,
CONTEXT_TYPE_SPECIALIZED,
CONTEXT_TYPE_UNRESTRICTIVE
};
} // namespace OCLRT

View File

@ -132,8 +132,9 @@ Buffer *Buffer::create(Context *context,
UNRECOVERABLE_IF(!memoryManager);
GraphicsAllocation::AllocationType allocationType = getGraphicsAllocationType(
properties.flags,
properties,
context->isSharedContext,
context->peekContextType(),
HwHelper::renderCompressedBuffersSupported(context->getDevice(0)->getHardwareInfo()),
memoryManager->isLocalMemorySupported());
@ -333,26 +334,24 @@ void Buffer::checkMemory(cl_mem_flags flags,
return;
}
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers, bool isLocalMemoryEnabled) {
if (is32bit) {
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(const MemoryProperties &properties, bool sharedContext,
ContextType contextType, bool renderCompressedBuffers,
bool isLocalMemoryEnabled) {
if (is32bit || sharedContext) {
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
}
if (sharedContext) {
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
}
GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::BUFFER;
if (isValueSet(flags, CL_MEM_USE_HOST_PTR)) {
if (isValueSet(flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL) || !isLocalMemoryEnabled) {
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) {
if (isValueSet(properties.flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL) || !isLocalMemoryEnabled) {
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
}
} else if (renderCompressedBuffers) {
type = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
return GraphicsAllocation::AllocationType::BUFFER;
}
return type;
if (MemObjHelper::isSuitableForRenderCompression(renderCompressedBuffers, properties, contextType)) {
return GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
}
return GraphicsAllocation::AllocationType::BUFFER;
}
bool Buffer::isReadOnlyMemoryPermittedByFlags(cl_mem_flags flags) {

View File

@ -6,6 +6,7 @@
*/
#pragma once
#include "runtime/context/context_type.h"
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/helpers/basic_math.h"
@ -138,7 +139,9 @@ class Buffer : public MemObj {
bool &isZeroCopy,
bool &copyMemoryFromHostPtr,
MemoryManager *memMngr);
static GraphicsAllocation::AllocationType getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers, bool localMemoryEnabled);
static GraphicsAllocation::AllocationType getGraphicsAllocationType(const MemoryProperties &properties, bool sharedContext,
ContextType contextType, bool renderCompressedBuffers,
bool localMemoryEnabled);
static bool isReadOnlyMemoryPermittedByFlags(cl_mem_flags flags);
void transferData(void *dst, void *src, size_t copySize, size_t copyOffset);

View File

@ -30,7 +30,8 @@ bool MemObjHelper::parseMemoryProperties(const cl_mem_properties_intel *properti
return true;
}
AllocationProperties MemObjHelper::getAllocationProperties(cl_mem_flags_intel flags, bool allocateMemory, size_t size, GraphicsAllocation::AllocationType type) {
AllocationProperties MemObjHelper::getAllocationProperties(cl_mem_flags_intel flags, bool allocateMemory,
size_t size, GraphicsAllocation::AllocationType type) {
AllocationProperties allocationProperties(allocateMemory, size, type);
allocationProperties.flags.uncacheable = isValueSet(flags, CL_MEM_LOCALLY_UNCACHED_RESOURCE);
return allocationProperties;
@ -44,6 +45,10 @@ DevicesBitfield MemObjHelper::getDevicesBitfield(const MemoryProperties &propert
return DevicesBitfield(0);
}
bool MemObjHelper::isSuitableForRenderCompression(bool renderCompressedBuffers, const MemoryProperties &properties, ContextType contextType) {
return renderCompressedBuffers;
}
bool MemObjHelper::validateExtraMemoryProperties(const MemoryProperties &properties) {
return true;
}

View File

@ -10,6 +10,7 @@
#include "common/helpers/bit_helpers.h"
#include "mem_obj_types.h"
#include "public/cl_ext_private.h"
#include "runtime/context/context_type.h"
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/memory_manager/memory_manager.h"
@ -41,7 +42,8 @@ class MemObjHelper {
return validateExtraMemoryProperties(properties);
}
static AllocationProperties getAllocationProperties(cl_mem_flags_intel flags, bool allocateMemory, size_t size, GraphicsAllocation::AllocationType type);
static AllocationProperties getAllocationProperties(cl_mem_flags_intel flags, bool allocateMemory,
size_t size, GraphicsAllocation::AllocationType type);
static AllocationProperties getAllocationProperties(ImageInfo *imgInfo, bool allocateMemory);
static DevicesBitfield getDevicesBitfield(const MemoryProperties &properties);
@ -54,6 +56,8 @@ class MemObjHelper {
return isFieldValid(flags, allValidFlags);
}
static bool isSuitableForRenderCompression(bool renderCompressedBuffers, const MemoryProperties &properties, ContextType contextType);
protected:
static bool checkMemFlagsForBuffer(const MemoryProperties &properties) {
MemoryProperties additionalAcceptedProperties;

View File

@ -16,18 +16,19 @@
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_context.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/execution_model_fixture.h"
#include "unit_tests/fixtures/memory_management_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/mocks/mock_program.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/program/program_from_binary.h"
#include "unit_tests/program/program_tests.h"
#include "unit_tests/utilities/base_object_utils.h"
#include <memory>
@ -1684,46 +1685,46 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenKernelIsaIs
}
TEST(KernelImageDetectionTests, givenKernelWithImagesOnlyWhenItIsAskedIfItHasImagesOnlyThenTrueIsReturned) {
auto device = std::make_unique<MockDevice>(*platformDevices[0]);
auto pKernelInfo = std::make_unique<KernelInfo>();
pKernelInfo->kernelArgInfo.resize(3);
pKernelInfo->kernelArgInfo[2].isImage = true;
pKernelInfo->kernelArgInfo[1].isMediaBlockImage = true;
pKernelInfo->kernelArgInfo[0].isMediaImage = true;
MockProgram program(*device->getExecutionEnvironment());
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *device));
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *pKernelInfo, *device));
EXPECT_FALSE(kernel->usesOnlyImages());
kernel->initialize();
EXPECT_TRUE(kernel->usesOnlyImages());
}
TEST(KernelImageDetectionTests, givenKernelWithImagesAndBuffersWhenItIsAskedIfItHasImagesOnlyThenFalseIsReturned) {
auto device = std::make_unique<MockDevice>(*platformDevices[0]);
auto pKernelInfo = std::make_unique<KernelInfo>();
pKernelInfo->kernelArgInfo.resize(3);
pKernelInfo->kernelArgInfo[2].isImage = true;
pKernelInfo->kernelArgInfo[1].isBuffer = true;
pKernelInfo->kernelArgInfo[0].isMediaImage = true;
MockProgram program(*device->getExecutionEnvironment());
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *device));
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *pKernelInfo, *device));
EXPECT_FALSE(kernel->usesOnlyImages());
kernel->initialize();
EXPECT_FALSE(kernel->usesOnlyImages());
}
TEST(KernelImageDetectionTests, givenKernelWithNoImagesWhenItIsAskedIfItHasImagesOnlyThenFalseIsReturned) {
auto device = std::make_unique<MockDevice>(*platformDevices[0]);
auto pKernelInfo = std::make_unique<KernelInfo>();
pKernelInfo->kernelArgInfo.resize(1);
pKernelInfo->kernelArgInfo[0].isBuffer = true;
MockProgram program(*device->getExecutionEnvironment());
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *pKernelInfo, *device));
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *pKernelInfo, *device));
EXPECT_FALSE(kernel->usesOnlyImages());
kernel->initialize();
EXPECT_FALSE(kernel->usesOnlyImages());
@ -2319,8 +2320,10 @@ TEST(KernelTest, givenKernelWithKernelInfoWith64bitPointerSizeThenReport64bit) {
TEST(KernelTest, givenFtrRenderCompressedBuffersWhenInitializingArgsWithNonStatefulAccessThenMarkKernelForAuxTranslation) {
HardwareInfo localHwInfo = *platformDevices[0];
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
MockKernelWithInternals kernel(*device);
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
auto context = clUniquePtr(new MockContext(device.get()));
context->setContextType(ContextType::CONTEXT_TYPE_UNRESTRICTIVE);
MockKernelWithInternals kernel(*device, context.get());
kernel.kernelInfo.kernelArgInfo.resize(1);
kernel.kernelInfo.kernelArgInfo.at(0).typeStr = "char *";
@ -2340,12 +2343,13 @@ TEST(KernelTest, givenFtrRenderCompressedBuffersWhenInitializingArgsWithNonState
TEST(KernelTest, givenDebugVariableSetWhenKernelHasStatefulBufferAccessThenMarkKernelForAuxTranslation) {
DebugManagerStateRestore restore;
HardwareInfo localHwInfo = *platformDevices[0];
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
MockKernelWithInternals kernel(*device);
HardwareInfo localHwInfo = *platformDevices[0];
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
auto context = clUniquePtr(new MockContext(device.get()));
MockKernelWithInternals kernel(*device, context.get());
kernel.kernelInfo.kernelArgInfo.resize(1);
kernel.kernelInfo.kernelArgInfo.at(0).typeStr = "char *";

View File

@ -289,8 +289,8 @@ TEST(Buffer, givenAllocHostPtrFlagPassedToBufferCreateWhenNoSharedContextOrRende
}
TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturnedIn64Bit) {
cl_mem_flags flags = 0;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, false);
MemoryProperties properties;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, false);
if (is32bit) {
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
} else {
@ -299,26 +299,28 @@ TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenB
}
TEST(Buffer, givenSharedContextWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
cl_mem_flags flags = 0;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, true, false, false);
MemoryProperties properties;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, true, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, false);
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenSharedContextAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
cl_mem_flags flags = 0;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, true, true, false);
MemoryProperties properties;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, true, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, false);
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, false);
MemoryProperties properties;
properties.flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, false);
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, true);
MemoryProperties properties;
properties.flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, true);
if (is64bit) {
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
} else {
@ -327,8 +329,9 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledWhenAllocationTypeIsQueried
}
TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) {
cl_mem_flags flags = CL_MEM_ALLOC_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, false);
MemoryProperties properties;
properties.flags = CL_MEM_ALLOC_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, false);
if (is64bit) {
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
} else {
@ -337,14 +340,16 @@ TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferTypeIsRet
}
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, false);
MemoryProperties properties;
properties.flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, false);
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, true);
MemoryProperties properties;
properties.flags = CL_MEM_USE_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, true);
if (is64bit) {
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
} else {
@ -353,14 +358,16 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndRenderCompressedBuffersE
}
TEST(Buffer, givenUseHostPointerFlagAndForceSharedPhysicalStorageWhenLocalMemoryIsEnabledThenBufferHostMemoryTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, true);
MemoryProperties properties;
properties.flags = CL_MEM_USE_HOST_PTR | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, true);
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenAllocHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) {
cl_mem_flags flags = CL_MEM_ALLOC_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, false);
MemoryProperties properties;
properties.flags = CL_MEM_ALLOC_HOST_PTR;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, false);
if (is64bit) {
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type);
} else {
@ -369,8 +376,8 @@ TEST(Buffer, givenAllocHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocatio
}
TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) {
cl_mem_flags flags = 0;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, false);
MemoryProperties properties;
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, false);
if (is32bit) {
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
} else {
@ -409,6 +416,7 @@ struct RenderCompressedBuffersTests : public ::testing::Test {
localHwInfo = *platformDevices[0];
device.reset(Device::create<MockDevice>(&localHwInfo, new ExecutionEnvironment(), 0u));
context = std::make_unique<MockContext>(device.get(), true);
context->setContextType(ContextType::CONTEXT_TYPE_UNRESTRICTIVE);
}
cl_int retVal = CL_SUCCESS;

View File

@ -15,6 +15,7 @@
#include "unit_tests/mocks/mock_mdi.h"
#include "unit_tests/mocks/mock_program.h"
#include "unit_tests/os_interface/debug_settings_manager_fixture.h"
#include "unit_tests/utilities/base_object_utils.h"
#include <memory>
#include <string>
@ -451,11 +452,11 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsLocalBuffer) {
}
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBufferNotSet) {
auto kernelInfo = std::make_unique<KernelInfo>();
auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo;
@ -479,14 +480,14 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBufferNotSet) {
}
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) {
MockContext context;
auto buffer = BufferHelper<>::create(&context);
unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto buffer = BufferHelper<>::create(context.get());
cl_mem clObj = buffer;
auto kernelInfo = std::make_unique<KernelInfo>();
auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
MockProgram program(*device->getExecutionEnvironment(), &context, false);
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo;
@ -517,11 +518,11 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) {
}
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) {
auto kernelInfo = std::make_unique<KernelInfo>();
auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo;
@ -543,9 +544,10 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) {
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImageNotSet) {
auto kernelInfo = std::make_unique<KernelInfo>();
auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
auto kernel = clUniquePtr(new MockKernel(program.get(), *kernelInfo, *device));
SKernelBinaryHeaderCommon kernelHeader;
char surfaceStateHeap[0x80];

View File

@ -1,21 +1,23 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include <cstdint>
#include "runtime/helpers/options.h"
#include "runtime/scheduler/scheduler_kernel.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_program.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
#include "unit_tests/mocks/mock_ostime.h"
#include "runtime/helpers/options.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "gtest/gtest.h"
#include "test.h"
#include <cstdint>
#include <memory>
using namespace OCLRT;
@ -116,12 +118,13 @@ TEST(SchedulerKernelTest, getCurbeSize) {
}
TEST(SchedulerKernelTest, setArgsForSchedulerKernel) {
auto device = unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
program.setDevice(device.get());
unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
program->setDevice(device.get());
unique_ptr<KernelInfo> info(nullptr);
KernelInfo *infoPtr = nullptr;
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(program, *device.get(), infoPtr));
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(*program, *device, infoPtr));
info.reset(infoPtr);
unique_ptr<MockGraphicsAllocation> allocs[9];
@ -145,13 +148,14 @@ TEST(SchedulerKernelTest, setArgsForSchedulerKernel) {
}
TEST(SchedulerKernelTest, setArgsForSchedulerKernelWithNullDebugQueue) {
auto device = unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
program.setDevice(device.get());
unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
program->setDevice(device.get());
unique_ptr<KernelInfo> info(nullptr);
KernelInfo *infoPtr = nullptr;
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(program, *device.get(), infoPtr));
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(*program, *device, infoPtr));
info.reset(infoPtr);
unique_ptr<MockGraphicsAllocation> allocs[9];
@ -178,13 +182,14 @@ TEST(SchedulerKernelTest, createKernelReflectionForForcedSchedulerDispatch) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceDispatchScheduler.set(true);
auto device = unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
program.setDevice(device.get());
unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
program->setDevice(device.get());
unique_ptr<KernelInfo> info(nullptr);
KernelInfo *infoPtr = nullptr;
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(program, *device.get(), infoPtr));
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(*program, *device, infoPtr));
info.reset(infoPtr);
scheduler->createReflectionSurface();
@ -196,13 +201,14 @@ TEST(SchedulerKernelTest, createKernelReflectionSecondTimeForForcedSchedulerDisp
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceDispatchScheduler.set(true);
auto device = unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
program.setDevice(device.get());
unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
program->setDevice(device.get());
unique_ptr<KernelInfo> info(nullptr);
KernelInfo *infoPtr = nullptr;
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(program, *device.get(), infoPtr));
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(*program, *device, infoPtr));
info.reset(infoPtr);
scheduler->createReflectionSurface();
@ -218,13 +224,14 @@ TEST(SchedulerKernelTest, createKernelReflectionForSchedulerDoesNothing) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceDispatchScheduler.set(false);
auto device = unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockProgram program(*device->getExecutionEnvironment());
program.setDevice(device.get());
unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto context = clUniquePtr(new MockContext(device.get()));
auto program = clUniquePtr(new MockProgram(*device->getExecutionEnvironment(), context.get(), false));
program->setDevice(device.get());
unique_ptr<KernelInfo> info(nullptr);
KernelInfo *infoPtr = nullptr;
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(program, *device.get(), infoPtr));
unique_ptr<MockSchedulerKernel> scheduler = unique_ptr<MockSchedulerKernel>(MockSchedulerKernel::create(*program, *device, infoPtr));
info.reset(infoPtr);
scheduler->createReflectionSurface();