2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-02-21 21:33:41 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2021-06-29 01:36:16 +08:00
|
|
|
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2020-11-27 21:26:12 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-02-24 05:44:01 +08: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 18:39:32 +08:00
|
|
|
|
2019-12-24 20:51:39 +08:00
|
|
|
#include <algorithm>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2019-12-24 20:51:39 +08:00
|
|
|
uint32_t GmmHelper::addressWidth = 48;
|
|
|
|
|
2019-12-04 19:36:16 +08:00
|
|
|
GmmClientContext *GmmHelper::getClientContext() const {
|
|
|
|
return gmmClientContext.get();
|
2018-07-23 18:23:48 +08:00
|
|
|
}
|
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *GmmHelper::getHardwareInfo() {
|
|
|
|
return hwInfo;
|
|
|
|
}
|
|
|
|
|
2020-02-04 19:13:57 +08:00
|
|
|
uint32_t GmmHelper::getMOCS(uint32_t type) const {
|
2022-02-21 21:33:41 +08:00
|
|
|
if (allResourcesUncached || (DebugManager.flags.ForceAllResourcesUncached.get() == true)) {
|
2021-12-07 23:32:00 +08:00
|
|
|
type = GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED;
|
|
|
|
}
|
|
|
|
|
2018-07-23 18:23:48 +08:00
|
|
|
MEMORY_OBJECT_CONTROL_STATE mocs = gmmClientContext->cachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
return static_cast<uint32_t>(mocs.DwordValue);
|
|
|
|
}
|
|
|
|
|
2019-12-19 23:24:26 +08:00
|
|
|
GmmHelper::GmmHelper(OSInterface *osInterface, const HardwareInfo *pHwInfo) : hwInfo(pHwInfo) {
|
2019-12-24 20:51:39 +08:00
|
|
|
auto hwInfoAddressWidth = Math::log2(hwInfo->capabilityTable.gpuAddressSpace + 1);
|
2019-12-31 22:28:34 +08:00
|
|
|
GmmHelper::addressWidth = std::max(hwInfoAddressWidth, static_cast<uint32_t>(48));
|
2020-11-27 21:26:12 +08:00
|
|
|
|
2020-01-14 20:47:40 +08:00
|
|
|
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(osInterface, const_cast<HardwareInfo *>(pHwInfo));
|
2019-10-15 21:05:47 +08:00
|
|
|
UNRECOVERABLE_IF(!gmmClientContext);
|
2018-07-03 16:00:12 +08:00
|
|
|
}
|
2019-10-15 21:05:47 +08:00
|
|
|
|
2021-12-23 23:32:23 +08:00
|
|
|
bool GmmHelper::isValidCanonicalGpuAddress(uint64_t address) {
|
2022-04-26 03:34:32 +08:00
|
|
|
auto decanonizedAddress = this->decanonize(address);
|
2022-04-29 21:28:15 +08:00
|
|
|
auto canonizedAddress = this->canonize(decanonizedAddress);
|
2021-12-23 23:32:23 +08:00
|
|
|
|
|
|
|
if (address == canonizedAddress) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:05:47 +08:00
|
|
|
GmmHelper::~GmmHelper() = default;
|
|
|
|
|
2021-06-29 01:36:16 +08:00
|
|
|
decltype(GmmHelper::createGmmContextWrapperFunc) GmmHelper::createGmmContextWrapperFunc = GmmClientContext::create<GmmClientContext>;
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|