mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Add OCL xe_hp_core unit tests
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b5d222f6cb
commit
14c93a6432
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_deferred_deleter.h"
|
||||
@@ -14,6 +15,7 @@
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
#include "opencl/source/context/context.inl"
|
||||
#include "opencl/source/device_queue/device_queue.h"
|
||||
#include "opencl/source/mem_obj/buffer.h"
|
||||
#include "opencl/source/sharings/sharing.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
|
||||
@@ -22,8 +24,7 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
#include "opencl/test/unit_test/test_macros/test_checks_ocl.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
@@ -513,3 +514,56 @@ TEST(Context, givenContextAndDevicesWhenIsTileOnlyThenProperValueReturned) {
|
||||
EXPECT_FALSE(subDevicesContext.isSingleDeviceContext());
|
||||
EXPECT_FALSE(multipleDevicesContext.isSingleDeviceContext());
|
||||
}
|
||||
|
||||
TEST(InvalidExtraPropertiesTests, givenInvalidExtraPropertiesWhenCreatingContextThenContextIsNotCreated) {
|
||||
constexpr cl_context_properties INVALID_PROPERTY_TYPE = (1 << 31);
|
||||
constexpr cl_context_properties INVALID_CONTEXT_FLAG = (1 << 31);
|
||||
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
cl_device_id deviceID = device.get();
|
||||
cl_int retVal = 0;
|
||||
std::unique_ptr<Context> context;
|
||||
|
||||
{
|
||||
cl_context_properties properties[] = {INVALID_PROPERTY_TYPE, INVALID_CONTEXT_FLAG, 0};
|
||||
context.reset(Context::create<Context>(properties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal));
|
||||
EXPECT_EQ(CL_INVALID_PROPERTY, retVal);
|
||||
EXPECT_EQ(nullptr, context.get());
|
||||
}
|
||||
}
|
||||
|
||||
using ContextCreateTests = ::testing::Test;
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ContextCreateTests, givenLocalMemoryAllocationWhenBlitMemoryToAllocationIsCalledThenSuccessIsReturned) {
|
||||
if (is32bit) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.EnableLocalMemory.set(true);
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::Default));
|
||||
UltClDeviceFactory deviceFactory{1, 2};
|
||||
|
||||
ClDevice *devicesToTest[] = {deviceFactory.rootDevices[0], deviceFactory.subDevices[0], deviceFactory.subDevices[1]};
|
||||
|
||||
for (const auto &testedDevice : devicesToTest) {
|
||||
|
||||
MockContext context(testedDevice);
|
||||
cl_int retVal;
|
||||
auto buffer = std::unique_ptr<Buffer>(Buffer::create(&context, {}, 1, nullptr, retVal));
|
||||
auto memory = buffer->getGraphicsAllocation(testedDevice->getRootDeviceIndex());
|
||||
uint8_t hostMemory[1];
|
||||
auto executionEnv = testedDevice->getExecutionEnvironment();
|
||||
executionEnv->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = false;
|
||||
|
||||
const auto &hwInfo = testedDevice->getHardwareInfo();
|
||||
auto isBlitterRequired = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isBlitCopyRequiredForLocalMemory(hwInfo, *memory);
|
||||
|
||||
auto expectedStatus = isBlitterRequired ? BlitOperationResult::Success : BlitOperationResult::Unsupported;
|
||||
|
||||
EXPECT_EQ(expectedStatus, BlitHelper::blitMemoryToAllocation(buffer->getContext()->getDevice(0)->getDevice(), memory, buffer->getOffset(), hostMemory, {1, 1, 1}));
|
||||
|
||||
executionEnv->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
|
||||
EXPECT_EQ(BlitOperationResult::Success, BlitHelper::blitMemoryToAllocation(buffer->getContext()->getDevice(0)->getDevice(), memory, buffer->getOffset(), hostMemory, {1, 1, 1}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user