Skip to content

Commit e58bc1c

Browse files
Defer Sysman Temperature Module Initialization
With this change, init for sysman Temperature API would not be done during zeInit. Rather init and thereby Temperature API handle creation would be done only when user explicitly requests to enumerate handles using zesDeviceEnumTemperatureSensors. Modification to temperature ULTs Related-To: LOCI-3127 Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
1 parent dbdae54 commit e58bc1c

File tree

7 files changed

+445
-12
lines changed

7 files changed

+445
-12
lines changed

level_zero/tools/source/sysman/sysman_imp.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ ze_result_t SysmanDeviceImp::init() {
103103
if (pFabricPortHandleContext) {
104104
pFabricPortHandleContext->init();
105105
}
106-
if (pTempHandleContext) {
107-
pTempHandleContext->init(deviceHandles);
108-
}
109106
if (pPci) {
110107
pPci->init();
111108
}

level_zero/tools/source/sysman/temperature/temperature.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/helpers/basic_math.h"
99

10+
#include "level_zero/tools/source/sysman/os_sysman.h"
1011
#include "level_zero/tools/source/sysman/temperature/temperature_imp.h"
1112

1213
namespace L0 {
@@ -35,6 +36,9 @@ void TemperatureHandleContext::init(std::vector<ze_device_handle_t> &deviceHandl
3536
}
3637

3738
ze_result_t TemperatureHandleContext::temperatureGet(uint32_t *pCount, zes_temp_handle_t *phTemperature) {
39+
std::call_once(initTemperatureOnce, [this]() {
40+
this->init(pOsSysman->getDeviceHandles());
41+
});
3842
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
3943
uint32_t numToCopy = std::min(*pCount, handleListSize);
4044
if (0 == *pCount || *pCount > handleListSize) {

level_zero/tools/source/sysman/temperature/temperature.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -8,6 +8,7 @@
88
#pragma once
99
#include <level_zero/zes_api.h>
1010

11+
#include <mutex>
1112
#include <vector>
1213

1314
struct _zes_temp_handle_t {
@@ -45,6 +46,7 @@ struct TemperatureHandleContext {
4546

4647
private:
4748
void createHandle(const ze_device_handle_t &deviceHandle, zes_temp_sensors_t type);
49+
std::once_flag initTemperatureOnce;
4850
};
4951

50-
} // namespace L0
52+
} // namespace L0

level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66

77
set(L0_TESTS_TOOLS_SYSMAN_TEMPERATURE_LINUX
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9-
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}test_zes_temperature.cpp
109
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_temperature.h
1110
)
1211

13-
if((NEO_ENABLE_i915_PRELIM_DETECTION) AND ("${BRANCH_TYPE}" STREQUAL ""))
14-
list(REMOVE_ITEM L0_TESTS_TOOLS_SYSMAN_TEMPERATURE_LINUX
12+
if(NEO_ENABLE_i915_PRELIM_DETECTION)
13+
list(APPEND L0_TESTS_TOOLS_SYSMAN_TEMPERATURE_LINUX
14+
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_temperature_prelim.cpp
15+
)
16+
else()
17+
list(APPEND L0_TESTS_TOOLS_SYSMAN_TEMPERATURE_LINUX
1518
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_temperature.cpp
1619
)
1720
endif()

level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture {
114114
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt);
115115
}
116116

117-
pSysmanDeviceImp->pTempHandleContext->init(deviceHandles);
117+
getTempHandles(0);
118118
}
119119
void TearDown() override {
120120
if (!sysmanUltsEnable) {
@@ -230,7 +230,7 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture {
230230
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt);
231231
}
232232

233-
pSysmanDeviceImp->pTempHandleContext->init(deviceHandles);
233+
getTempHandles(0);
234234
}
235235
void TearDown() override {
236236
if (!sysmanUltsEnable) {

0 commit comments

Comments
 (0)