Pass platform to ClDevice

Related-To: NEO-4207
Change-Id: I1c70d209df2b378573a41fa991ab594746691adb
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2020-01-27 10:36:39 +01:00 committed by sys_ocldev
parent e0fe796115
commit 0a0b1ce1d8
13 changed files with 19 additions and 18 deletions

View File

@ -13,15 +13,15 @@
namespace NEO { namespace NEO {
ClDevice::ClDevice(Device &device) : device(device), platformId(platform()) { ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platformId(platform) {
device.incRefInternal(); device.incRefInternal();
initializeCaps(); initializeCaps();
auto numAvailableDevices = device.getNumAvailableDevices(); auto numAvailableDevices = device.getNumAvailableDevices();
if (numAvailableDevices > 1) { if (numAvailableDevices > 1) {
for (uint32_t i = 0; i < numAvailableDevices; i++) { for (uint32_t i = 0; i < numAvailableDevices; i++) {
subDevices.push_back(std::make_unique<ClDevice>(*device.getDeviceById(i))); subDevices.push_back(std::make_unique<ClDevice>(*device.getDeviceById(i), platform));
platform()->clDeviceMap.emplace(device.getDeviceById(i), subDevices[i].get()); platform->clDeviceMap.emplace(device.getDeviceById(i), subDevices[i].get());
} }
} }
} }

View File

@ -29,6 +29,7 @@ struct EngineControl;
struct HardwareCapabilities; struct HardwareCapabilities;
struct HardwareInfo; struct HardwareInfo;
struct RootDeviceEnvironment; struct RootDeviceEnvironment;
class Platform;
template <> template <>
struct OpenCLObjectMapper<_cl_device_id> { struct OpenCLObjectMapper<_cl_device_id> {
@ -42,7 +43,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
ClDevice &operator=(const ClDevice &) = delete; ClDevice &operator=(const ClDevice &) = delete;
ClDevice(const ClDevice &) = delete; ClDevice(const ClDevice &) = delete;
explicit ClDevice(Device &device); explicit ClDevice(Device &device, Platform *platformId);
~ClDevice() override; ~ClDevice() override;
unsigned int getEnabledClVersion() const; //CL unsigned int getEnabledClVersion() const; //CL

View File

@ -160,7 +160,7 @@ bool Platform::initialize() {
DEBUG_BREAK_IF(!pDevice); DEBUG_BREAK_IF(!pDevice);
ClDevice *pClDevice = nullptr; ClDevice *pClDevice = nullptr;
if (pDevice) { if (pDevice) {
pClDevice = new ClDevice{*pDevice}; pClDevice = new ClDevice{*pDevice, this};
} }
DEBUG_BREAK_IF(!pClDevice); DEBUG_BREAK_IF(!pClDevice);
if (pClDevice) { if (pClDevice) {

View File

@ -167,7 +167,7 @@ TEST(clCreatePipeTest, givenPlatformWithoutDevicesWhenClCreatePipeIsCalledThenDe
auto executionEnvironment = platform()->peekExecutionEnvironment(); auto executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->initializeMemoryManager(); executionEnvironment->initializeMemoryManager();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto device = std::make_unique<ClDevice>(*Device::create<RootDevice>(executionEnvironment, 0u)); auto device = std::make_unique<ClDevice>(*Device::create<RootDevice>(executionEnvironment, 0u), platform());
const DeviceInfo &devInfo = device->getDeviceInfo(); const DeviceInfo &devInfo = device->getDeviceInfo();
if (devInfo.svmCapabilities == 0) { if (devInfo.svmCapabilities == 0) {
GTEST_SKIP(); GTEST_SKIP();

View File

@ -74,7 +74,7 @@ TEST(clGetSupportedImageFormatsTest, givenPlatformWithoutDevicesWhenClGetSupport
auto executionEnvironment = platform()->peekExecutionEnvironment(); auto executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->initializeMemoryManager(); executionEnvironment->initializeMemoryManager();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto device = std::make_unique<ClDevice>(*Device::create<RootDevice>(executionEnvironment, 0u)); auto device = std::make_unique<ClDevice>(*Device::create<RootDevice>(executionEnvironment, 0u), platform());
const DeviceInfo &devInfo = device->getDeviceInfo(); const DeviceInfo &devInfo = device->getDeviceInfo();
if (!devInfo.imageSupport) { if (!devInfo.imageSupport) {
GTEST_SKIP(); GTEST_SKIP();

View File

@ -41,7 +41,7 @@ TEST(clSVMAllocTest, givenPlatformWithoutDevicesWhenClSVMAllocIsCalledThenDevice
executionEnvironment->initializeMemoryManager(); executionEnvironment->initializeMemoryManager();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto device = Device::create<RootDevice>(executionEnvironment, 0u); auto device = Device::create<RootDevice>(executionEnvironment, 0u);
auto clDevice = std::make_unique<ClDevice>(*device); auto clDevice = std::make_unique<ClDevice>(*device, platform());
const DeviceInfo &devInfo = device->getDeviceInfo(); const DeviceInfo &devInfo = device->getDeviceInfo();
if (devInfo.svmCapabilities == 0) { if (devInfo.svmCapabilities == 0) {
GTEST_SKIP(); GTEST_SKIP();

View File

@ -171,7 +171,7 @@ TEST(SyncBufferHandlerDeviceTest, GivenRootDeviceWhenAllocateSyncBufferIsCalledT
TEST(SyncBufferHandlerDeviceTest, GivenSubDeviceWhenAllocateSyncBufferIsCalledTwiceThenTheObjectIsCreatedOnlyOnce) { TEST(SyncBufferHandlerDeviceTest, GivenSubDeviceWhenAllocateSyncBufferIsCalledTwiceThenTheObjectIsCreatedOnlyOnce) {
const size_t testUsedBufferSize = 100; const size_t testUsedBufferSize = 100;
MockClDevice rootDevice{new MockDevice}; MockClDevice rootDevice{new MockDevice};
ClDevice subDevice{*rootDevice.createSubDevice(0)}; ClDevice subDevice{*rootDevice.createSubDevice(0), platform()};
subDevice.allocateSyncBufferHandler(); subDevice.allocateSyncBufferHandler();
auto syncBufferHandler = reinterpret_cast<MockSyncBufferHandler *>(subDevice.syncBufferHandler.get()); auto syncBufferHandler = reinterpret_cast<MockSyncBufferHandler *>(subDevice.syncBufferHandler.get());

View File

@ -129,7 +129,7 @@ INSTANTIATE_TEST_CASE_P(
struct GetDeviceInfoForImage : public GetDeviceInfoSize {}; struct GetDeviceInfoForImage : public GetDeviceInfoSize {};
TEST_P(GetDeviceInfoForImage, imageInfoSizeIsValid) { TEST_P(GetDeviceInfoForImage, imageInfoSizeIsValid) {
auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr), platform());
if (!device->getDeviceInfo().imageSupport) { if (!device->getDeviceInfo().imageSupport) {
GTEST_SKIP(); GTEST_SKIP();
} }
@ -147,7 +147,7 @@ TEST_P(GetDeviceInfoForImage, imageInfoSizeIsValid) {
} }
TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturned) { TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturned) {
auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr), platform());
if (device->getDeviceInfo().imageSupport) { if (device->getDeviceInfo().imageSupport) {
GTEST_SKIP(); GTEST_SKIP();
} }
@ -161,7 +161,7 @@ TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturn
} }
TEST_P(GetDeviceInfoForImage, givenInfoImageParamsWhenCallGetDeviceInfoForImageThenSizeIsValidAndTrueReturned) { TEST_P(GetDeviceInfoForImage, givenInfoImageParamsWhenCallGetDeviceInfoForImageThenSizeIsValidAndTrueReturned) {
auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr), platform());
size_t srcSize = 0; size_t srcSize = 0;
size_t retSize = 0; size_t retSize = 0;
const void *src = nullptr; const void *src = nullptr;
@ -177,7 +177,7 @@ TEST_P(GetDeviceInfoForImage, givenInfoImageParamsWhenCallGetDeviceInfoForImageT
} }
TEST(GetDeviceInfoForImage, givenNotImageParamWhenCallGetDeviceInfoForImageThenSizeIsNotValidAndFalseReturned) { TEST(GetDeviceInfoForImage, givenNotImageParamWhenCallGetDeviceInfoForImageThenSizeIsNotValidAndFalseReturned) {
auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr), platform());
size_t srcSize = 0; size_t srcSize = 0;
size_t retSize = 0; size_t retSize = 0;
const void *src = nullptr; const void *src = nullptr;

View File

@ -395,7 +395,7 @@ struct UpdateEventTest : public ::testing::Test {
memoryManager = new MockMemoryManager(*executionEnvironment); memoryManager = new MockMemoryManager(*executionEnvironment);
hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager()); hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager());
executionEnvironment->memoryManager.reset(memoryManager); executionEnvironment->memoryManager.reset(memoryManager);
device.reset(new ClDevice{*Device::create<RootDevice>(executionEnvironment, 0u)}); device.reset(new ClDevice{*Device::create<RootDevice>(executionEnvironment, 0u), platform()});
context = std::make_unique<MockContext>(device.get()); context = std::make_unique<MockContext>(device.get());
cl_int retVal = CL_OUT_OF_RESOURCES; cl_int retVal = CL_OUT_OF_RESOURCES;
commandQueue.reset(CommandQueue::create(context.get(), device.get(), nullptr, retVal)); commandQueue.reset(CommandQueue::create(context.get(), device.get(), nullptr, retVal));

View File

@ -14,7 +14,7 @@ namespace NEO {
void DeviceInstrumentationFixture::SetUp(bool instrumentation) { void DeviceInstrumentationFixture::SetUp(bool instrumentation) {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
hwInfo->capabilityTable.instrumentationEnabled = instrumentation; hwInfo->capabilityTable.instrumentationEnabled = instrumentation;
device = std::make_unique<ClDevice>(*Device::create<RootDevice>(executionEnvironment, 0)); device = std::make_unique<ClDevice>(*Device::create<RootDevice>(executionEnvironment, 0), platform());
} }
} // namespace NEO } // namespace NEO

View File

@ -24,7 +24,7 @@ decltype(&createCommandStream) MockDevice::createCommandStreamReceiverFunc = cre
decltype(&createCommandStream) &MockClDevice::createCommandStreamReceiverFunc = MockDevice::createCommandStreamReceiverFunc; decltype(&createCommandStream) &MockClDevice::createCommandStreamReceiverFunc = MockDevice::createCommandStreamReceiverFunc;
MockClDevice::MockClDevice(MockDevice *pMockDevice) MockClDevice::MockClDevice(MockDevice *pMockDevice)
: ClDevice(*pMockDevice), device(*pMockDevice), deviceInfo(pMockDevice->deviceInfo), : ClDevice(*pMockDevice, platform()), device(*pMockDevice), deviceInfo(pMockDevice->deviceInfo),
executionEnvironment(pMockDevice->executionEnvironment), executionEnvironment(pMockDevice->executionEnvironment),
subdevices(pMockDevice->subdevices), mockMemoryManager(pMockDevice->mockMemoryManager), engines(pMockDevice->engines) { subdevices(pMockDevice->subdevices), mockMemoryManager(pMockDevice->mockMemoryManager), engines(pMockDevice->engines) {

View File

@ -41,7 +41,7 @@ TEST(DeviceOsTest, GivenDefaultDeviceWhenCheckingForOsSpecificExtensionsThenCorr
TEST(DeviceOsTest, GivenDefaultClDeviceWhenCheckingForOsSpecificExtensionsThenCorrectExtensionsAreSet) { TEST(DeviceOsTest, GivenDefaultClDeviceWhenCheckingForOsSpecificExtensionsThenCorrectExtensionsAreSet) {
auto hwInfo = *platformDevices; auto hwInfo = *platformDevices;
auto pDevice = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfo); auto pDevice = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfo);
auto pClDevice = new ClDevice{*pDevice}; auto pClDevice = new ClDevice{*pDevice, platform()};
std::string extensionString(pClDevice->getDeviceInfo().deviceExtensions); std::string extensionString(pClDevice->getDeviceInfo().deviceExtensions);

View File

@ -37,7 +37,7 @@ TEST(DeviceOsTest, GivenDefaultDeviceWhenCheckingForOsSpecificExtensionsThenCorr
TEST(DeviceOsTest, GivenDefaultClDeviceWhenCheckingForOsSpecificExtensionsThenCorrectExtensionsAreSet) { TEST(DeviceOsTest, GivenDefaultClDeviceWhenCheckingForOsSpecificExtensionsThenCorrectExtensionsAreSet) {
auto hwInfo = *platformDevices; auto hwInfo = *platformDevices;
auto pDevice = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfo); auto pDevice = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfo);
auto pClDevice = new ClDevice{*pDevice}; auto pClDevice = new ClDevice{*pDevice, platform()};
std::string extensionString(pClDevice->getDeviceInfo().deviceExtensions); std::string extensionString(pClDevice->getDeviceInfo().deviceExtensions);