2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2018-09-18 09:11:08 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2021-06-28 17:36:16 +00:00
|
|
|
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2020-11-27 14:26:12 +01:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
|
|
|
#include "shared/source/os_interface/os_library.h"
|
|
|
|
|
#include "shared/source/sku_info/operations/sku_info_transfer.h"
|
2019-02-27 11:39:32 +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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-04 12:13:57 +01:00
|
|
|
uint32_t GmmHelper::getMOCS(uint32_t type) const {
|
2021-12-07 15:32:00 +00:00
|
|
|
if (l3CacheForDebugDisabled) {
|
|
|
|
|
type = GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED;
|
|
|
|
|
}
|
|
|
|
|
|
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-11-27 14:26:12 +01:00
|
|
|
|
2020-01-14 13:47:40 +01:00
|
|
|
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(osInterface, const_cast<HardwareInfo *>(pHwInfo));
|
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;
|
|
|
|
|
|
2021-06-28 17:36:16 +00:00
|
|
|
decltype(GmmHelper::createGmmContextWrapperFunc) GmmHelper::createGmmContextWrapperFunc = GmmClientContext::create<GmmClientContext>;
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|