2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-18 16:44:52 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2019-11-19 18:49:19 +08:00
|
|
|
#include "core/gmm_helper/gmm_lib.h"
|
2019-09-17 18:53:37 +08:00
|
|
|
#include "core/memory_manager/memory_constants.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-10-21 20:54:08 +08:00
|
|
|
class GmmClientContext;
|
|
|
|
class OsLibrary;
|
2018-01-12 16:08:49 +08:00
|
|
|
struct HardwareInfo;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-06-21 17:36:47 +08:00
|
|
|
class GmmHelper {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2018-06-21 17:36:47 +08:00
|
|
|
GmmHelper() = delete;
|
2018-07-03 16:00:12 +08:00
|
|
|
GmmHelper(const HardwareInfo *hwInfo);
|
2018-07-13 13:42:18 +08:00
|
|
|
MOCKABLE_VIRTUAL ~GmmHelper();
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *getHardwareInfo();
|
2018-07-23 18:23:48 +08:00
|
|
|
uint32_t getMOCS(uint32_t type);
|
|
|
|
|
2019-01-18 16:44:52 +08:00
|
|
|
static constexpr uint64_t maxPossiblePitch = 2147483648;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-17 18:53:37 +08:00
|
|
|
template <uint8_t addressWidth = 48>
|
|
|
|
static uint64_t canonize(uint64_t address) {
|
|
|
|
return ((int64_t)(address << (64 - addressWidth))) >> (64 - addressWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <uint8_t addressWidth = 48>
|
|
|
|
static uint64_t decanonize(uint64_t address) {
|
2019-11-28 01:00:52 +08:00
|
|
|
return (address & maxNBitValue(addressWidth));
|
2019-09-17 18:53:37 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-23 18:23:48 +08:00
|
|
|
static GmmClientContext *getClientContext();
|
|
|
|
static GmmHelper *getInstance();
|
2018-07-27 19:59:39 +08:00
|
|
|
|
2019-10-15 21:05:47 +08:00
|
|
|
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(HardwareInfo *, decltype(&InitializeGmm), decltype(&GmmDestroy));
|
2018-05-17 17:47:35 +08:00
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
protected:
|
|
|
|
void loadLib();
|
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *hwInfo = nullptr;
|
2018-07-23 18:23:48 +08:00
|
|
|
std::unique_ptr<OsLibrary> gmmLib;
|
|
|
|
std::unique_ptr<GmmClientContext> gmmClientContext;
|
2019-10-15 21:05:47 +08:00
|
|
|
decltype(&InitializeGmm) initGmmFunc;
|
|
|
|
decltype(&GmmDestroy) destroyGmmFunc;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|