2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-12-31 15:28:34 +01:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2018-09-18 09:11:08 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-12-04 12:36:16 +01:00
|
|
|
#include "core/gmm_helper/gmm_helper.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2019-09-05 09:35:56 +02:00
|
|
|
#include "core/helpers/debug_helpers.h"
|
2019-11-29 15:41:47 +01:00
|
|
|
#include "core/helpers/hw_info.h"
|
2019-09-17 21:26:09 +02:00
|
|
|
#include "core/memory_manager/graphics_allocation.h"
|
2019-11-19 11:49:19 +01:00
|
|
|
#include "core/os_interface/os_library.h"
|
|
|
|
|
#include "core/sku_info/operations/sku_info_transfer.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
|
|
|
|
#include "gmm_client_context.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-12-24 13:51:39 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-07-23 12:23:48 +02:00
|
|
|
|
2019-12-24 13:51:39 +01:00
|
|
|
uint32_t GmmHelper::addressWidth = 48;
|
|
|
|
|
|
2019-12-04 12:36:16 +01:00
|
|
|
GmmClientContext *GmmHelper::getClientContext() const {
|
|
|
|
|
return gmmClientContext.get();
|
2018-07-23 12:23:48 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-27 13:59:39 +02:00
|
|
|
const HardwareInfo *GmmHelper::getHardwareInfo() {
|
|
|
|
|
return hwInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-21 11:36:47 +02:00
|
|
|
uint32_t GmmHelper::getMOCS(uint32_t type) {
|
2018-07-23 12:23:48 +02:00
|
|
|
MEMORY_OBJECT_CONTROL_STATE mocs = gmmClientContext->cachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
return static_cast<uint32_t>(mocs.DwordValue);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-19 16:24:26 +01:00
|
|
|
GmmHelper::GmmHelper(OSInterface *osInterface, const HardwareInfo *pHwInfo) : hwInfo(pHwInfo) {
|
2019-12-24 13:51:39 +01:00
|
|
|
auto hwInfoAddressWidth = Math::log2(hwInfo->capabilityTable.gpuAddressSpace + 1);
|
2019-12-31 15:28:34 +01:00
|
|
|
GmmHelper::addressWidth = std::max(hwInfoAddressWidth, static_cast<uint32_t>(48));
|
2020-01-09 16:14:59 +01:00
|
|
|
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(osInterface, const_cast<HardwareInfo *>(pHwInfo), InitializeGmm, GmmAdapterDestroy);
|
2019-10-15 15:05:47 +02:00
|
|
|
UNRECOVERABLE_IF(!gmmClientContext);
|
2018-07-03 10:00:12 +02:00
|
|
|
}
|
2019-10-15 15:05:47 +02:00
|
|
|
|
|
|
|
|
GmmHelper::~GmmHelper() = default;
|
|
|
|
|
|
2018-07-27 14:08:40 +02:00
|
|
|
decltype(GmmHelper::createGmmContextWrapperFunc) GmmHelper::createGmmContextWrapperFunc = GmmClientContextBase::create<GmmClientContext>;
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|