From 8598168355a27f48ac4f0c169f243ea6542b7a52 Mon Sep 17 00:00:00 2001 From: "Stefanowski, Adam" Date: Thu, 9 Aug 2018 10:08:49 +0200 Subject: [PATCH] Remove programCount from device Change-Id: I4edfabadd73166a27db73a120fc1380de52a33a5 --- runtime/device/device.h | 3 -- .../os_interface/linux/drm_memory_manager.cpp | 6 --- runtime/program/program.cpp | 1 - .../linux/drm_memory_manager_tests.cpp | 52 ------------------- unit_tests/program/program_tests.cpp | 7 --- 5 files changed, 69 deletions(-) diff --git a/runtime/device/device.h b/runtime/device/device.h index 928be71f31..4e3afb3226 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -112,8 +112,6 @@ class Device : public BaseObject<_cl_device_id> { unique_ptr_if_unused release() override; OSTime *getOSTime() const { return osTime.get(); }; double getProfilingTimerResolution(); - void increaseProgramCount() { programCount++; } - uint64_t getProgramCount() { return programCount; } unsigned int getEnabledClVersion() const { return enabledClVersion; }; unsigned int getSupportedClVersion() const; double getPlatformHostTimerResolution() const; @@ -162,7 +160,6 @@ class Device : public BaseObject<_cl_device_id> { std::unique_ptr osTime; std::unique_ptr driverInfo; std::unique_ptr performanceCounters; - uint64_t programCount = 0u; void *slmWindowStartAddress; diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index f676bfb0f0..824c06191b 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -282,12 +282,6 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, const auto res = allocatorToUse->allocate(allocationSize); if (!res) { - if (allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION && device && device->getProgramCount() == 0) { - this->force32bitAllocations = false; - device->setForce32BitAddressing(false); - return (DrmAllocation *)allocateGraphicsMemoryInPreferredPool(ptr == nullptr, ptr, static_cast(size), GraphicsAllocation::AllocationType::BUFFER); - } - return nullptr; } diff --git a/runtime/program/program.cpp b/runtime/program/program.cpp index 2d2049f62c..3f95f0cb29 100644 --- a/runtime/program/program.cpp +++ b/runtime/program/program.cpp @@ -82,7 +82,6 @@ Program::Program(Context *context, bool isBuiltIn) : context(context), isBuiltIn if (force32BitAddressess) { internalOptions += "-m32 "; } - pDevice->increaseProgramCount(); if (DebugManager.flags.DisableStatelessToStatefulOptimization.get()) { internalOptions += "-cl-intel-greater-than-4GB-buffer-required "; diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index 55271e7462..e61734069c 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -1050,58 +1050,6 @@ TEST_F(DrmMemoryManagerTest, GivenSizeAbove2GBWhenAllocHostPtrAndUseHostPtrAreCr delete buffer; } -TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExhaustedThenOptimizationIsTurningOfIfNoProgramsAreCreated) { - mock->ioctl_expected.gemUserptr = 1; - mock->ioctl_expected.gemWait = 1; - mock->ioctl_expected.gemClose = 1; - - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.Force32bitAddressing.set(true); - std::unique_ptr pDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); - memoryManager->device = pDevice.get(); - memoryManager->setForce32BitAllocations(true); - - mockAllocator32Bit::resetState(); - fail32BitMmap = true; - failLowerRanger = true; - failUpperRange = true; - failMmap = true; - mockAllocator32Bit::OsInternalsPublic *osInternals = mockAllocator32Bit::createOsInternals(); - osInternals->mmapFunction = MockMmap; - osInternals->munmapFunction = MockMunmap; - std::unique_ptr mock32BitAllocator(new mockAllocator32Bit(osInternals)); - - memoryManager->allocator32Bit.reset(mock32BitAllocator.release()); - - //ask for 4GB - auto allocationSize = 4096u; - bool force32Bit = memoryManager->peekForce32BitAllocations(); - EXPECT_TRUE(force32Bit); - - auto graphicsAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(true, nullptr, static_cast(allocationSize), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); - EXPECT_NE(nullptr, graphicsAllocation); - EXPECT_FALSE(pDevice->getDeviceInfo().force32BitAddressess); - - memoryManager->freeGraphicsMemory(graphicsAllocation); -} - -TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExhaustedAndThereAreProgramsThenOptimizationIsStillOnAndFailureIsReturned) { - mock->ioctl_expected.reset(); - - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.Force32bitAddressing.set(true); - std::unique_ptr pDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); - pDevice->increaseProgramCount(); - memoryManager->device = pDevice.get(); - memoryManager->setForce32BitAllocations(true); - - //ask for 4GB - 1 - size_t allocationSize = (4 * 1023 * 1024 * (size_t)1024u - 1) + 4 * 1024 * (size_t)1024u; - - auto graphicsAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(true, nullptr, static_cast(allocationSize), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); - EXPECT_EQ(nullptr, graphicsAllocation); - EXPECT_TRUE(pDevice->getDeviceInfo().force32BitAddressess); -} TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIsExhaustedAndNewAllocationsIsMadeThenNullIsReturned) { DebugManagerStateRestore dbgStateRestore; diff --git a/unit_tests/program/program_tests.cpp b/unit_tests/program/program_tests.cpp index 34b0d0a522..3fba1418fc 100644 --- a/unit_tests/program/program_tests.cpp +++ b/unit_tests/program/program_tests.cpp @@ -2569,13 +2569,6 @@ TEST_F(Program32BitTests, givenDeviceWithForce32BitAddressingOnWhenProgramIsCrea } } -TEST_F(Program32BitTests, givenDeviceWhenProgramIsCreatedThenProgramCountInDeviceIncreases) { - auto device = pContext->getDevice(0); - EXPECT_EQ(0u, device->getProgramCount()); - MockProgram pProgram(pContext, false); - EXPECT_EQ(1u, device->getProgramCount()); -} - TEST_F(ProgramTests, givenNewProgramTheStatelessToStatefulBufferOffsetOtimizationIsMatchingThePlatformEnablingStatus) { MockProgram prog(pContext, false); auto &internalOpts = prog.getInternalOptions();