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 : #include "prof_common.h"
12 : #include "adapter_prof.h"
13 : #include "coll_comm_profiling.h"
14 : #include "profiling_manager_pub.h"
15 : #include "hccl_comm_pub.h"
16 : // 通信域内首次才能上报
17 0 : HcclResult HcclStreamProfilingReport(HcclComm comm, u32 threadNum, const u32* threadId)
18 : {
19 0 : HCCL_INFO("[%s] threadNum = [%u]", __func__, threadNum);
20 0 : CHK_PTR_NULL(comm);
21 0 : CHK_PTR_NULL(threadId);
22 0 : auto* hcclComm = static_cast<hccl::hcclComm*>(comm);
23 0 : std::string commId = hcclComm->GetIdentifier();
24 : ProfilingDeviceCommResInfo hcclMc2Info;
25 0 : std::string GroupName(hcclComm->GetIdentifier());
26 0 : hcclMc2Info.groupName = hrtMsprofGetHashId(GroupName.c_str(), GroupName.length());
27 0 : hcclComm->GetRankSize(hcclMc2Info.rankSize);
28 0 : hcclComm->GetGroupRank(hcclMc2Info.rankId);
29 0 : hcclMc2Info.usrRankId = hcclComm->GetRealUserRank();
30 0 : hcclMc2Info.aicpuKfcStreamId = 0; // 暂无 先报stream 0
31 0 : hcclMc2Info.reserve = 0;
32 0 : uint32_t reportId = 0;
33 : // 上报所有得threadid
34 0 : const uint32_t ONCE_REPORT_STREAM_NUM_MAX = 8;
35 0 : for (uint32_t streamIndex = 0; streamIndex < threadNum; streamIndex++) {
36 0 : u32 id = threadId[streamIndex];
37 0 : HCCL_DEBUG("[%s] streamIndex:[%u], reportId:[%u], streamId[%u]", __func__, streamIndex, reportId, id);
38 0 : hcclMc2Info.commStreamIds[reportId++] = id;
39 0 : if (reportId == ONCE_REPORT_STREAM_NUM_MAX) {
40 0 : hcclMc2Info.commStreamSize = reportId;
41 0 : CHK_RET(hccl::ProfilingManagerPub::CallMsprofReportMc2CommInfo(
42 : hrtMsprofSysCycleTime(), &hcclMc2Info, sizeof(hcclMc2Info)));
43 0 : reportId = 0;
44 : }
45 : }
46 : // 上报剩余的stream
47 0 : if (reportId > 0) {
48 0 : HCCL_DEBUG("[%s] last reportId[%u]", __func__, reportId);
49 0 : hcclMc2Info.commStreamSize = reportId;
50 0 : CHK_RET(hccl::ProfilingManagerPub::CallMsprofReportMc2CommInfo(
51 : hrtMsprofSysCycleTime(), &hcclMc2Info, sizeof(hcclMc2Info)));
52 0 : reportId = 0;
53 : }
54 0 : HCCL_INFO("[%s] success", __func__);
55 0 : return HCCL_SUCCESS;
56 0 : }
|