Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef HCCL_INC_SAL_PUB_H
12 : #define HCCL_INC_SAL_PUB_H
13 :
14 : #include <string>
15 : #include "types.h"
16 :
17 : namespace Hccl {
18 :
19 : constexpr int HCCL_BASE_DECIMAL = 10; // 10进制字符串转换
20 :
21 : void SaluSleep(u32 usec);
22 :
23 : void SalSleep(u32 sec);
24 :
25 : std::string SalGetEnv(const char* name);
26 :
27 : HcclResult SalStrToULong(const std::string str, int base, u32& val);
28 :
29 : s32 SalGetTid();
30 :
31 : u64 SalGetCurrentTimestamp();
32 :
33 : u64 GetCurAicpuTimestamp();
34 :
35 : void SetThreadName(const std::string& threadStr);
36 :
37 : #ifndef CCL_LLT
38 50 : inline void AsmCntvc(uint64_t& cntvct)
39 : {
40 : #if defined __aarch64__
41 : asm volatile("mrs %0, cntvct_el0" : "=r"(cntvct));
42 : #else
43 50 : cntvct = 0;
44 : #endif
45 50 : }
46 : #endif
47 :
48 50 : inline u64 ProfGetCurCpuTimestamp()
49 : {
50 : #ifndef CCL_LLT
51 : uint64_t cntvct;
52 50 : AsmCntvc(cntvct);
53 50 : return cntvct;
54 : #endif
55 : return 0;
56 : }
57 :
58 : } // namespace Hccl
59 : #endif // !HCCL_INC_SAL_PUB_H
|