1 /*
2  * Copyright (C) 2020-2021 Intel Corporation
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  */
7 
8 #include "level_zero/tools/source/sysman/memory/linux/os_memory_imp.h"
9 
10 #include "sysman/linux/os_sysman_imp.h"
11 
12 namespace L0 {
13 
LinuxMemoryImp(OsSysman * pOsSysman,ze_bool_t onSubdevice,uint32_t subdeviceId)14 LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
15     LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
16     pDevice = pLinuxSysmanImp->getDeviceHandle();
17 }
isMemoryModuleSupported()18 bool LinuxMemoryImp::isMemoryModuleSupported() {
19     return pDevice->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(pDevice->getRootDeviceIndex());
20 }
21 
getProperties(zes_mem_properties_t * pProperties)22 ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
23     pProperties->type = ZES_MEM_TYPE_DDR;
24     pProperties->location = ZES_MEM_LOC_DEVICE;
25     pProperties->onSubdevice = isSubdevice;
26     pProperties->subdeviceId = subdeviceId;
27     pProperties->busWidth = -1;
28     pProperties->numChannels = -1;
29     pProperties->physicalSize = 0;
30 
31     return ZE_RESULT_SUCCESS;
32 }
getBandwidth(zes_mem_bandwidth_t * pBandwidth)33 ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
34     return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
35 }
36 
getState(zes_mem_state_t * pState)37 ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
38     return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
39 }
40 
create(OsSysman * pOsSysman,ze_bool_t onSubdevice,uint32_t subdeviceId)41 OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
42     LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId);
43     return static_cast<OsMemory *>(pLinuxMemoryImp);
44 }
45 
46 } // namespace L0
47