2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-08 22:15:01 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-11-29 22:41:47 +08:00
|
|
|
#include "core/helpers/hw_info.h"
|
2019-12-09 22:29:30 +08:00
|
|
|
#include "core/helpers/options.h"
|
2019-07-15 19:51:08 +08:00
|
|
|
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/device/device.h"
|
2018-01-16 01:16:50 +08:00
|
|
|
#include "runtime/platform/extensions.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/sharings/sharing_factory.h"
|
2019-03-19 18:57:45 +08:00
|
|
|
#include "unit_tests/fixtures/mock_aub_center_fixture.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "unit_tests/fixtures/platform_fixture.h"
|
2019-01-08 20:11:09 +08:00
|
|
|
#include "unit_tests/helpers/variable_backup.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "unit_tests/libult/create_command_stream.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_async_event_handler.h"
|
2018-11-19 23:18:06 +08:00
|
|
|
#include "unit_tests/mocks/mock_builtins.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_csr.h"
|
2020-01-08 22:15:01 +08:00
|
|
|
#include "unit_tests/mocks/mock_device.h"
|
2018-11-11 05:25:48 +08:00
|
|
|
#include "unit_tests/mocks/mock_execution_environment.h"
|
2018-11-19 23:18:06 +08:00
|
|
|
#include "unit_tests/mocks/mock_source_level_debugger.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "gmock/gmock.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "gtest/gtest.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-03 22:57:45 +08:00
|
|
|
namespace NEO {
|
|
|
|
namespace MockSipData {
|
|
|
|
extern SipKernelType calledType;
|
|
|
|
extern bool called;
|
|
|
|
} // namespace MockSipData
|
|
|
|
} // namespace NEO
|
|
|
|
|
2018-03-30 03:26:25 +08:00
|
|
|
struct PlatformTest : public ::testing::Test {
|
2019-12-03 22:57:45 +08:00
|
|
|
void SetUp() override {
|
|
|
|
MockSipData::calledType = SipKernelType::COUNT;
|
|
|
|
MockSipData::called = false;
|
|
|
|
pPlatform.reset(new Platform());
|
|
|
|
}
|
|
|
|
void TearDown() override {
|
|
|
|
MockSipData::calledType = SipKernelType::COUNT;
|
|
|
|
MockSipData::called = false;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
cl_int retVal = CL_SUCCESS;
|
2018-06-26 18:49:00 +08:00
|
|
|
std::unique_ptr<Platform> pPlatform;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2018-11-11 05:25:48 +08:00
|
|
|
struct MockPlatformWithMockExecutionEnvironment : public Platform {
|
|
|
|
MockExecutionEnvironment *mockExecutionEnvironment = nullptr;
|
|
|
|
|
|
|
|
MockPlatformWithMockExecutionEnvironment() {
|
|
|
|
this->executionEnvironment->decRefInternal();
|
2019-11-15 16:59:48 +08:00
|
|
|
mockExecutionEnvironment = new MockExecutionEnvironment(nullptr, false, 1);
|
2018-11-11 05:25:48 +08:00
|
|
|
executionEnvironment = mockExecutionEnvironment;
|
2019-11-15 16:59:48 +08:00
|
|
|
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
|
2018-11-11 05:25:48 +08:00
|
|
|
executionEnvironment->incRefInternal();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
TEST_F(PlatformTest, GivenUninitializedPlatformWhenInitializeIsCalledThenPlatformIsInitialized) {
|
|
|
|
EXPECT_FALSE(pPlatform->isInitialized());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
EXPECT_TRUE(pPlatform->initialize());
|
|
|
|
EXPECT_TRUE(pPlatform->isInitialized());
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
TEST_F(PlatformTest, WhenGetNumDevicesIsCalledThenExpectedValuesAreReturned) {
|
|
|
|
EXPECT_EQ(0u, pPlatform->getNumDevices());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
pPlatform->initialize();
|
|
|
|
|
|
|
|
EXPECT_GT(pPlatform->getNumDevices(), 0u);
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
TEST_F(PlatformTest, WhenGetDeviceIsCalledThenExpectedValuesAreReturned) {
|
|
|
|
EXPECT_EQ(nullptr, pPlatform->getDevice(0));
|
|
|
|
EXPECT_EQ(nullptr, pPlatform->getClDevice(0));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
pPlatform->initialize();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
EXPECT_NE(nullptr, pPlatform->getDevice(0));
|
|
|
|
EXPECT_NE(nullptr, pPlatform->getClDevice(0));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
auto numDevices = pPlatform->getNumDevices();
|
|
|
|
EXPECT_EQ(nullptr, pPlatform->getDevice(numDevices));
|
|
|
|
EXPECT_EQ(nullptr, pPlatform->getClDevice(numDevices));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PlatformTest, WhenGetClDevicesIsCalledThenExpectedValuesAreReturned) {
|
|
|
|
EXPECT_EQ(nullptr, pPlatform->getClDevices());
|
|
|
|
|
|
|
|
pPlatform->initialize();
|
|
|
|
|
|
|
|
EXPECT_NE(nullptr, pPlatform->getClDevices());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-12-17 20:34:05 +08:00
|
|
|
TEST_F(PlatformTest, givenDebugFlagSetWhenInitializingPlatformThenOverrideGpuAddressSpace) {
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
DebugManager.flags.OverrideGpuAddressSpace.set(12);
|
|
|
|
|
|
|
|
bool status = pPlatform->initialize();
|
|
|
|
EXPECT_TRUE(status);
|
|
|
|
|
|
|
|
EXPECT_EQ(maxNBitValue(12), pPlatform->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.gpuAddressSpace);
|
|
|
|
}
|
|
|
|
|
2018-01-16 01:16:50 +08:00
|
|
|
TEST_F(PlatformTest, PlatformgetAsCompilerEnabledExtensionsString) {
|
|
|
|
std::string compilerExtensions = pPlatform->peekCompilerExtensions();
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(std::string(""), compilerExtensions);
|
|
|
|
|
2018-06-21 00:25:40 +08:00
|
|
|
pPlatform->initialize();
|
2018-01-16 01:16:50 +08:00
|
|
|
compilerExtensions = pPlatform->peekCompilerExtensions();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-02 20:27:55 +08:00
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string(" -cl-ext=-all,+cl")));
|
2019-10-16 16:23:46 +08:00
|
|
|
if (std::string(pPlatform->getDevice(0)->getDeviceInfo().clVersion).find("OpenCL 2.1") != std::string::npos) {
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_subgroups")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PlatformTest, hasAsyncEventsHandler) {
|
|
|
|
EXPECT_NE(nullptr, pPlatform->getAsyncEventsHandler());
|
|
|
|
}
|
|
|
|
|
2018-11-19 23:18:06 +08:00
|
|
|
TEST_F(PlatformTest, givenMidThreadPreemptionWhenInitializingPlatformThenCallGetSipKernel) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
|
|
|
|
|
|
|
auto builtIns = new MockBuiltins();
|
|
|
|
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
|
|
|
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
pPlatform->initialize();
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::Csr, MockSipData::calledType);
|
|
|
|
EXPECT_TRUE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PlatformTest, givenDisabledPreemptionAndNoSourceLevelDebuggerWhenInitializingPlatformThenDoNotCallGetSipKernel) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
|
|
|
|
|
|
|
auto builtIns = new MockBuiltins();
|
|
|
|
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
|
|
|
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
pPlatform->initialize();
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PlatformTest, givenDisabledPreemptionInactiveSourceLevelDebuggerWhenInitializingPlatformThenDoNotCallGetSipKernel) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
|
|
|
|
|
|
|
auto builtIns = new MockBuiltins();
|
|
|
|
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
|
|
|
auto sourceLevelDebugger = new MockSourceLevelDebugger();
|
|
|
|
sourceLevelDebugger->setActive(false);
|
|
|
|
pPlatform->peekExecutionEnvironment()->sourceLevelDebugger.reset(sourceLevelDebugger);
|
|
|
|
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
pPlatform->initialize();
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PlatformTest, givenDisabledPreemptionActiveSourceLevelDebuggerWhenInitializingPlatformThenCallGetSipKernel) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
|
|
|
|
|
|
|
auto builtIns = new MockBuiltins();
|
|
|
|
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
|
|
|
pPlatform->peekExecutionEnvironment()->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger());
|
|
|
|
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
2018-11-19 23:18:06 +08:00
|
|
|
pPlatform->initialize();
|
2019-12-03 22:57:45 +08:00
|
|
|
EXPECT_TRUE(MockSipData::called);
|
|
|
|
EXPECT_LE(SipKernelType::DbgCsr, MockSipData::calledType);
|
|
|
|
EXPECT_GE(SipKernelType::DbgCsrLocal, MockSipData::calledType);
|
2018-11-19 23:18:06 +08:00
|
|
|
}
|
|
|
|
|
2018-11-11 05:25:48 +08:00
|
|
|
TEST(PlatformTestSimple, givenCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsNotCalled) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(0);
|
|
|
|
MockPlatformWithMockExecutionEnvironment platform;
|
|
|
|
bool ret = platform.initialize();
|
|
|
|
EXPECT_TRUE(ret);
|
2019-11-15 16:59:48 +08:00
|
|
|
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(platform.mockExecutionEnvironment->rootDeviceEnvironments[0].get());
|
|
|
|
EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled);
|
2018-11-11 05:25:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(PlatformTestSimple, givenNotCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsCalled) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
2019-01-08 20:11:09 +08:00
|
|
|
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
|
2018-11-11 05:25:48 +08:00
|
|
|
MockPlatformWithMockExecutionEnvironment platform;
|
|
|
|
bool ret = platform.initialize();
|
|
|
|
EXPECT_TRUE(ret);
|
2019-11-15 16:59:48 +08:00
|
|
|
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(platform.mockExecutionEnvironment->rootDeviceEnvironments[0].get());
|
|
|
|
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
2018-11-11 05:25:48 +08:00
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST(PlatformTestSimple, shutdownClosesAsyncEventHandlerThread) {
|
|
|
|
Platform *platform = new Platform;
|
|
|
|
|
|
|
|
MockHandler *mockAsyncHandler = new MockHandler;
|
|
|
|
|
2018-02-21 23:31:53 +08:00
|
|
|
auto oldHandler = platform->setAsyncEventsHandler(std::unique_ptr<AsyncEventsHandler>(mockAsyncHandler));
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(mockAsyncHandler, platform->getAsyncEventsHandler());
|
|
|
|
|
|
|
|
mockAsyncHandler->openThread();
|
|
|
|
delete platform;
|
2018-06-28 14:51:44 +08:00
|
|
|
EXPECT_TRUE(MockAsyncEventHandlerGlobals::destructorCalled);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-08-07 00:01:26 +08:00
|
|
|
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE];
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-10-29 15:01:53 +08:00
|
|
|
CommandStreamReceiver *createMockCommandStreamReceiver(bool withAubDump, ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) {
|
2017-12-21 07:45:38 +08:00
|
|
|
return nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PlatformFailingTest : public PlatformTest {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
|
|
|
PlatformTest::SetUp();
|
|
|
|
hwInfo = platformDevices[0];
|
2019-05-08 22:00:24 +08:00
|
|
|
commandStreamReceiverCreateFunc = commandStreamReceiverFactory[hwInfo->platform.eRenderCoreFamily];
|
|
|
|
commandStreamReceiverFactory[hwInfo->platform.eRenderCoreFamily] = createMockCommandStreamReceiver;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2019-05-08 22:00:24 +08:00
|
|
|
commandStreamReceiverFactory[hwInfo->platform.eRenderCoreFamily] = commandStreamReceiverCreateFunc;
|
2017-12-21 07:45:38 +08:00
|
|
|
PlatformTest::TearDown();
|
|
|
|
}
|
|
|
|
|
2019-01-08 20:11:09 +08:00
|
|
|
VariableBackup<bool> backup{&overrideCommandStreamReceiverCreation, true};
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandStreamReceiverCreateFunc commandStreamReceiverCreateFunc;
|
|
|
|
const HardwareInfo *hwInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(PlatformFailingTest, givenPlatformInitializationWhenIncorrectHwInfoThenInitializationFails) {
|
|
|
|
Platform *platform = new Platform;
|
2018-06-21 00:25:40 +08:00
|
|
|
bool ret = platform->initialize();
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_FALSE(ret);
|
|
|
|
EXPECT_FALSE(platform->isInitialized());
|
|
|
|
delete platform;
|
|
|
|
}
|
2018-01-16 01:16:50 +08:00
|
|
|
|
2018-06-26 21:56:50 +08:00
|
|
|
TEST_F(PlatformTest, givenSupportingCl21WhenPlatformSupportsFp64ThenFillMatchingSubstringsAndMandatoryTrailingSpace) {
|
2018-01-16 01:16:50 +08:00
|
|
|
const HardwareInfo *hwInfo;
|
|
|
|
hwInfo = platformDevices[0];
|
|
|
|
std::string extensionsList = getExtensionsList(*hwInfo);
|
|
|
|
EXPECT_THAT(extensionsList, ::testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
|
|
|
|
|
|
|
|
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
|
2018-05-02 20:27:55 +08:00
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string(" -cl-ext=-all,+cl")));
|
2018-01-16 01:16:50 +08:00
|
|
|
|
|
|
|
if (hwInfo->capabilityTable.clVersionSupport > 20) {
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_subgroups")));
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_il_program")));
|
2019-12-12 23:48:58 +08:00
|
|
|
if (hwInfo->capabilityTable.supportsVme) {
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_intel_spirv_device_side_avc_motion_estimation")));
|
|
|
|
} else {
|
|
|
|
EXPECT_THAT(compilerExtensions, testing::Not(::testing::HasSubstr(std::string("cl_intel_spirv_device_side_avc_motion_estimation"))));
|
|
|
|
}
|
2020-01-08 22:15:01 +08:00
|
|
|
if (hwInfo->capabilityTable.supportsImages) {
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_intel_spirv_media_block_io")));
|
|
|
|
} else {
|
|
|
|
EXPECT_THAT(compilerExtensions, testing::Not(::testing::HasSubstr(std::string("cl_intel_spirv_media_block_io"))));
|
|
|
|
}
|
|
|
|
|
2018-12-17 17:03:08 +08:00
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_intel_spirv_subgroups")));
|
2019-03-18 21:12:57 +08:00
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_spirv_no_integer_wrap_decoration")));
|
2018-01-16 01:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hwInfo->capabilityTable.ftrSupportsFP64) {
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_fp64")));
|
|
|
|
}
|
2018-06-26 21:56:50 +08:00
|
|
|
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::EndsWith(std::string(" ")));
|
2018-01-16 01:16:50 +08:00
|
|
|
}
|
|
|
|
|
2018-06-26 21:56:50 +08:00
|
|
|
TEST_F(PlatformTest, givenNotSupportingCl21WhenPlatformNotSupportFp64ThenNotFillMatchingSubstringAndFillMandatoryTrailingSpace) {
|
2018-01-16 01:16:50 +08:00
|
|
|
HardwareInfo TesthwInfo = *platformDevices[0];
|
|
|
|
TesthwInfo.capabilityTable.ftrSupportsFP64 = false;
|
|
|
|
TesthwInfo.capabilityTable.clVersionSupport = 10;
|
|
|
|
|
|
|
|
std::string extensionsList = getExtensionsList(TesthwInfo);
|
|
|
|
EXPECT_THAT(extensionsList, ::testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
|
|
|
|
|
|
|
|
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("-cl-ext=-all,+cl")));
|
|
|
|
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::Not(::testing::HasSubstr(std::string("cl_khr_fp64"))));
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::Not(::testing::HasSubstr(std::string("cl_khr_subgroups"))));
|
2018-06-26 21:56:50 +08:00
|
|
|
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::EndsWith(std::string(" ")));
|
2018-01-16 01:16:50 +08:00
|
|
|
}
|
|
|
|
|
2019-08-20 21:17:10 +08:00
|
|
|
TEST_F(PlatformTest, givenFtrSupportAtomicsWhenCreateExtentionsListThenGetMatchingSubstrings) {
|
|
|
|
const HardwareInfo *hwInfo;
|
|
|
|
hwInfo = platformDevices[0];
|
|
|
|
std::string extensionsList = getExtensionsList(*hwInfo);
|
|
|
|
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
|
|
|
|
|
|
|
|
if (hwInfo->capabilityTable.ftrSupportsInteger64BitAtomics) {
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_int64_base_atomics")));
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_int64_extended_atomics")));
|
|
|
|
} else {
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::Not(::testing::HasSubstr(std::string("cl_khr_int64_base_atomics"))));
|
|
|
|
EXPECT_THAT(compilerExtensions, ::testing::Not(::testing::HasSubstr(std::string("cl_khr_int64_extended_atomics"))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:15:01 +08:00
|
|
|
TEST_F(PlatformTest, givenSupporteImagesAndClVersion21WhenCreateExtentionsListThenDeviceReportsSpritvMediaBlockIoExtension) {
|
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
hwInfo.capabilityTable.supportsImages = true;
|
|
|
|
hwInfo.capabilityTable.clVersionSupport = 21;
|
|
|
|
std::string extensionsList = getExtensionsList(hwInfo);
|
|
|
|
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
|
|
|
|
|
|
|
|
EXPECT_THAT(compilerExtensions, testing::HasSubstr(std::string("cl_intel_spirv_media_block_io")));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PlatformTest, givenNotSupporteImagesAndClVersion21WhenCreateExtentionsListThenDeviceNotReportsSpritvMediaBlockIoExtension) {
|
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
hwInfo.capabilityTable.supportsImages = false;
|
|
|
|
hwInfo.capabilityTable.clVersionSupport = 21;
|
|
|
|
std::string extensionsList = getExtensionsList(hwInfo);
|
|
|
|
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
|
|
|
|
|
|
|
|
EXPECT_THAT(compilerExtensions, testing::Not(testing::HasSubstr(std::string("cl_intel_spirv_media_block_io"))));
|
|
|
|
}
|
|
|
|
|
2018-01-16 01:16:50 +08:00
|
|
|
TEST_F(PlatformTest, testRemoveLastSpace) {
|
|
|
|
std::string emptyString = "";
|
|
|
|
removeLastSpace(emptyString);
|
|
|
|
EXPECT_EQ(std::string(""), emptyString);
|
|
|
|
|
|
|
|
std::string xString = "x";
|
|
|
|
removeLastSpace(xString);
|
|
|
|
EXPECT_EQ(std::string("x"), xString);
|
|
|
|
|
|
|
|
std::string xSpaceString = "x ";
|
|
|
|
removeLastSpace(xSpaceString);
|
|
|
|
EXPECT_EQ(std::string("x"), xSpaceString);
|
2018-03-30 03:26:25 +08:00
|
|
|
}
|
2018-06-26 22:15:48 +08:00
|
|
|
TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledTwiceThenTheSamePlatformIsReturned) {
|
2018-07-23 18:23:48 +08:00
|
|
|
platformImpl.reset();
|
2018-06-26 22:15:48 +08:00
|
|
|
ASSERT_EQ(nullptr, platformImpl);
|
|
|
|
auto platform = constructPlatform();
|
|
|
|
EXPECT_EQ(platform, platformImpl.get());
|
|
|
|
auto platform2 = constructPlatform();
|
|
|
|
EXPECT_EQ(platform2, platform);
|
|
|
|
EXPECT_NE(platform, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledAfterResetThenNewPlatformIsConstructed) {
|
2018-07-23 18:23:48 +08:00
|
|
|
platformImpl.reset();
|
2018-06-26 22:15:48 +08:00
|
|
|
ASSERT_EQ(nullptr, platformImpl);
|
|
|
|
auto platform = constructPlatform();
|
|
|
|
std::unique_ptr<Platform> temporaryOwnership(std::move(platformImpl));
|
|
|
|
EXPECT_EQ(nullptr, platformImpl.get());
|
|
|
|
auto platform2 = constructPlatform();
|
|
|
|
EXPECT_NE(platform2, platform);
|
|
|
|
EXPECT_NE(platform, nullptr);
|
|
|
|
EXPECT_NE(platform2, nullptr);
|
|
|
|
platformImpl.reset(nullptr);
|
|
|
|
}
|
2018-06-28 14:51:44 +08:00
|
|
|
|
2018-08-14 19:54:33 +08:00
|
|
|
TEST(PlatformInitLoopTests, givenPlatformWhenInitLoopHelperIsCalledThenItDoesNothing) {
|
|
|
|
struct mockPlatform : public Platform {
|
|
|
|
using Platform::initializationLoopHelper;
|
|
|
|
};
|
|
|
|
mockPlatform platform;
|
|
|
|
platform.initializationLoopHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(PlatformInitLoopTests, givenPlatformWithDebugSettingWhenInitIsCalledThenItEntersEndlessLoop) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
DebugManager.flags.LoopAtPlatformInitialize.set(true);
|
|
|
|
bool called = false;
|
|
|
|
struct mockPlatform : public Platform {
|
|
|
|
mockPlatform(bool &called) : called(called){};
|
|
|
|
void initializationLoopHelper() override {
|
|
|
|
DebugManager.flags.LoopAtPlatformInitialize.set(false);
|
|
|
|
called = true;
|
|
|
|
}
|
|
|
|
bool &called;
|
|
|
|
};
|
|
|
|
mockPlatform platform(called);
|
|
|
|
platform.initialize();
|
|
|
|
EXPECT_TRUE(called);
|
|
|
|
}
|