mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix destruction sequence in execution environment.
- Gmm needs to be closed after memory manager. Change-Id: I608fc328034012ce52b7e791afd9ad2ff2f0cd1a
This commit is contained in:

committed by
sys_ocldev

parent
a8ce3ca00a
commit
e34c47271b
@ -32,14 +32,14 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
private:
|
||||
DeviceFactoryCleaner cleaner;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<GmmHelper> gmmHelper;
|
||||
|
||||
public:
|
||||
ExecutionEnvironment();
|
||||
~ExecutionEnvironment() override;
|
||||
void initGmm(const HardwareInfo *hwInfo);
|
||||
std::unique_ptr<CommandStreamReceiver> commandStreamReceiver;
|
||||
std::unique_ptr<MemoryManager> memoryManager;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<GmmHelper> gmmHelper;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -41,7 +41,7 @@ class GmmHelper {
|
||||
public:
|
||||
GmmHelper() = delete;
|
||||
GmmHelper(const HardwareInfo *hwInfo);
|
||||
~GmmHelper();
|
||||
MOCKABLE_VIRTUAL ~GmmHelper();
|
||||
static constexpr uint32_t cacheDisabledIndex = 0;
|
||||
static constexpr uint32_t cacheEnabledIndex = 4;
|
||||
static constexpr uint32_t maxPossiblePitch = 2147483648;
|
||||
|
@ -22,7 +22,10 @@
|
||||
|
||||
#include "test.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
@ -92,3 +95,33 @@ TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillA
|
||||
device.reset(nullptr);
|
||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||
}
|
||||
|
||||
auto destructorId = 0u;
|
||||
static_assert(sizeof(ExecutionEnvironment) == (is64bit ? 48 : 28), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
|
||||
|
||||
TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) {
|
||||
destructorId = 0u;
|
||||
struct GmmHelperMock : public GmmHelper {
|
||||
using GmmHelper::GmmHelper;
|
||||
~GmmHelperMock() override {
|
||||
EXPECT_EQ(destructorId, 1u);
|
||||
destructorId++;
|
||||
}
|
||||
};
|
||||
struct MemoryMangerMock : public OsAgnosticMemoryManager {
|
||||
~MemoryMangerMock() override {
|
||||
EXPECT_EQ(destructorId, 0u);
|
||||
destructorId++;
|
||||
}
|
||||
};
|
||||
struct MockExecutionEnvironment : ExecutionEnvironment {
|
||||
using ExecutionEnvironment::gmmHelper;
|
||||
};
|
||||
|
||||
std::unique_ptr<MockExecutionEnvironment> executionEnvironment(new MockExecutionEnvironment);
|
||||
executionEnvironment->gmmHelper.reset(new GmmHelperMock(platformDevices[0]));
|
||||
executionEnvironment->memoryManager.reset(new MemoryMangerMock);
|
||||
|
||||
executionEnvironment.reset(nullptr);
|
||||
EXPECT_EQ(2u, destructorId);
|
||||
}
|
Reference in New Issue
Block a user