LCOV - code coverage report
Current view: top level - /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/ut/pkg_inc/aicpu_sched/aicpu_schedule - aicpusd_info.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-07 10:45:47 Functions: 100.0 % 1 1

            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 AICPUSD_AICPUSD_INFO_H
      12              : #define AICPUSD_AICPUSD_INFO_H
      13              : 
      14              : #include <cstdint>
      15              : #include <sched.h>
      16              : #include <sys/types.h>
      17              : #include "../common/type_def.h"
      18              : 
      19              : extern "C" {
      20              : struct __attribute__((visibility("default"))) AICPUActiveStream {
      21              :     uint32_t streamId;
      22              : };
      23              : 
      24              : static const uint32_t MAX_CUST_SO_NAME_LEN = 128U;
      25              : static const uint32_t OP_NAME_MAX_LEN = 50U;
      26              : static const uint32_t FUN_NAME_MAX_LEN = 30U;
      27              : static const uint32_t ERROR_KEY_INFO_MAX_LEN = 30U;
      28              : static const uint32_t MODULE_NAME_MAX_LEN = 10U;
      29              : static const uint32_t FILE_NAME_MAX_LEN = 30U;
      30              : static const uint16_t PRIORITY_MSG_CHECKCODE = 0xABCD;
      31              : static const int32_t INVALID_ESCAPE_PRI_VALUE = -1;
      32              : // loadOpFromBuf task args
      33              : struct __attribute__((visibility("default"))) LoadOpFromBufArgs {
      34              :     uint64_t kernelSoBuf;     // the starting address of custom operator so buf
      35              :     uint32_t kernelSoBufLen;  // the length of custom operator so buf
      36              :     uint64_t kernelSoName;    // the starting address of custom operator so name
      37              :     uint32_t kernelSoNameLen; // the length of custom operator so name
      38              : } __attribute__((packed));
      39              : 
      40              : // batchLoadOpFromBuf task args
      41              : struct __attribute__((visibility("default"))) BatchLoadOpFromBufArgs {
      42              :     uint32_t soNum; // the number of so
      43              :     uint64_t opInfoArgs;
      44              : } __attribute__((packed));
      45              : 
      46              : /**
      47              :  * The mode of profiling
      48              :  */
      49              : enum __attribute__((visibility("default"))) ProfilingMode {
      50              :     PROFILING_CLOSE = 0,
      51              :     PROFILING_OPEN,
      52              : };
      53              : 
      54              : enum __attribute__((visibility("default"))) AicpuSchedMode {
      55              :     SCHED_MODE_INTERRUPT = 0,
      56              :     SCHED_MODE_MSGQ,
      57              :     SCHED_MODE_INVALID
      58              : };
      59              : 
      60              : enum __attribute__((visibility("default"))) AICPUSubEvent {
      61              :     AICPU_SUB_EVENT_ACTIVE_STREAM = 0,
      62              :     AICPU_SUB_EVENT_EXECUTE_MODEL,
      63              :     AICPU_SUB_EVENT_REPEAT_MODEL,
      64              :     AICPU_SUB_EVENT_RECOVERY_STREAM,
      65              :     AICPU_SUB_EVENT_UPDATE_PROFILING_MODE,
      66              :     AICPU_SUB_EVENT_LOAD_SO,
      67              :     AICPU_SUB_EVENT_END_GRAPH,
      68              :     AICPU_SUB_EVENT_ACTIVE_MODEL,
      69              :     AICPU_SUB_EVENT_PREPARE_MEM,
      70              :     AICPU_SUB_EVENT_TABLE_UNLOCK,
      71              :     AICPU_SUB_EVENT_SUPPLY_ENQUEUE,
      72              :     AICPU_SUB_EVENT_MAX_NUM,
      73              : };
      74              : 
      75              : enum __attribute__((visibility("default"))) AICPUCustSubEvent {
      76              :     // sub type begin with 10 for interface event
      77              :     AICPU_SUB_EVENT_BIND_SD_PID = 10,           // cust-sd bind sd pid, Implemented by cust-sd
      78              :     AICPU_SUB_EVENT_OPEN_CUSTOM_SO,             // open costom so file, Implemented by cust-sd
      79              :     AICPU_SUB_EVENT_CUST_UPDATE_PROFILING_MODE, // update profiling mode, Implemented by cust-sd
      80              :     AICPU_SUB_EVENT_ABNORMAL_LOG,               // print aicpu cust schedule's error log
      81              :     AICPU_SUB_EVENT_REPORT_CUST_DUMPDATA,       // aicpusd do cust datadump
      82              :     AICPU_SUB_EVENT_REPORT_UDF_DUMPDATA,        // aicpusd do udf datadump
      83              :     AICPU_SUB_EVENT_CUST_LOAD_PLATFORM,         // custom scheduler process load platform info event
      84              :     AICPU_SUB_EVENT_CUST_CLOSE_MONITOR,         // notify cust-sd to close aicpu kernel timeout monitor
      85              : };
      86              : 
      87              : struct __attribute__((visibility("default"))) AICPUSubEventStreamInfo {
      88              :     uint32_t streamId;
      89              : };
      90              : 
      91              : struct __attribute__((visibility("default"))) AICPUProfilingModeInfo {
      92              :     uint32_t deviceId;
      93              :     pid_t hostpId;
      94              :     uint32_t flag;
      95              : };
      96              : 
      97              : struct __attribute__((visibility("default"))) AICPULoadSoInfo {
      98              :     uint32_t kernelSoIndex;
      99              : };
     100              : 
     101              : struct __attribute__((visibility("default"))) AICPUEndGraphInfo {
     102              :     uint32_t result;
     103              : };
     104              : 
     105              : struct __attribute__((visibility("default"))) AICPUSharderTaskInfo {
     106              :     uint32_t parallelId;
     107              :     int64_t shardNum;
     108              : 
     109          185 :     bool operator==(const AICPUSharderTaskInfo& sharderInfo) const noexcept
     110              :     {
     111          185 :         return (parallelId == sharderInfo.parallelId);
     112              :     }
     113              : };
     114              : 
     115              : struct __attribute__((visibility("default"))) AICPUUnLockTableInfo {
     116              :     uint32_t tableId;
     117              : };
     118              : 
     119              : struct __attribute__((visibility("default"))) AICPUDumpCustInfo {
     120              :     uint32_t threadIndex; // dump任务的线程号
     121              :     int32_t retCode;      // dump result
     122              :     uint32_t streamId;    // dump key streamId
     123              :     uint32_t taskId;      // dump key taskId
     124              : };
     125              : 
     126              : struct __attribute__((visibility("default"))) AICPUDumpUdfInfo {
     127              :     uint64_t length;
     128              :     uint64_t udfInfo;
     129              :     uint32_t udfPid;
     130              :     char_t rsv[20];
     131              : };
     132              : 
     133              : struct __attribute__((visibility("default"))) AICPULoadPlatformCustInfo {
     134              :     uint64_t length;
     135              :     uint64_t platformInfo;
     136              :     uint32_t aicpuPid;
     137              :     char_t rsv[20];
     138              : };
     139              : 
     140              : struct __attribute__((visibility("default"))) AICPUSubEventInfo {
     141              :     uint32_t modelId;
     142              :     union {
     143              :         AICPUSubEventStreamInfo streamInfo;
     144              :         AICPUProfilingModeInfo modeInfo;
     145              :         AICPULoadSoInfo loadSoInfo;
     146              :         AICPUEndGraphInfo endGraphInfo;
     147              :         AICPUSharderTaskInfo sharderTaskInfo;
     148              :         AICPUUnLockTableInfo unlockTableInfo;
     149              :     } para;
     150              : };
     151              : 
     152              : struct __attribute__((visibility("default"))) AICPUBindSdPidEventMsg {
     153              :     int32_t pid;
     154              : } __attribute__((packed));
     155              : 
     156              : struct __attribute__((visibility("default"))) AICPUOpenCustomSoEventMsg {
     157              :     char_t kernelSoName[MAX_CUST_SO_NAME_LEN];
     158              : } __attribute__((packed));
     159              : 
     160              : struct __attribute__((visibility("default"))) AICPUCloseMonitorEventMsg {
     161              :     uint8_t closeFlag;
     162              : } __attribute__((packed));
     163              : 
     164              : struct __attribute__((visibility("default"))) CpuSchedInitParam {
     165              :     uint32_t deviceId;
     166              :     pid_t hostPid;
     167              :     ProfilingMode profilingMode;
     168              :     char_t rsv[128];
     169              : } __attribute__((packed));
     170              : 
     171              : struct __attribute__((visibility("default"))) ModelQueueInfo {
     172              :     uint32_t queueId;
     173              :     uint32_t flag;
     174              : } __attribute__((packed));
     175              : 
     176              : struct __attribute__((visibility("default"))) ModelTaskInfo {
     177              :     uint32_t taskId;
     178              :     uint64_t kernelName;
     179              :     uint64_t paraBase; // param地址
     180              : } __attribute__((packed));
     181              : 
     182              : struct __attribute__((visibility("default"))) ModelStreamInfo {
     183              :     uint32_t streamId;
     184              :     uint32_t streamFlag;
     185              :     uint16_t taskNum;
     186              :     ModelTaskInfo* tasks;
     187              : } __attribute__((packed));
     188              : 
     189              : struct __attribute__((visibility("default"))) AicpuPriInfo {
     190              :     uint16_t checkHead;
     191              :     int32_t pidPriority;
     192              :     int32_t eventPriority;
     193              : } __attribute__((packed));
     194              : 
     195              : struct __attribute__((visibility("default"))) ModelCommOpList {
     196              :     uint64_t commOpDescsListAddr;
     197              :     uint32_t opNum;
     198              : } __attribute__((packed));
     199              : 
     200              : // 配置类型,用于给AICPU控制不同的加载流程
     201              : enum __attribute__((visibility("default"))) ModelType {
     202              :     kModelWithEmbedding = 0,
     203              :     kModelWithSyncEvent = 1,
     204              :     kModelTypeNum
     205              : };
     206              : 
     207              : struct __attribute__((visibility("default"))) CommGroup {
     208              :     const char* groupName;
     209              :     uint32_t rankNum;
     210              :     uint32_t* rankIds;
     211              : } __attribute__((packed));
     212              : 
     213              : struct __attribute__((visibility("default"))) CommGroups {
     214              :     uint32_t groupNum;
     215              :     CommGroup* groups;
     216              : } __attribute__((packed));
     217              : 
     218              : struct __attribute__((visibility("default"))) ModelCfgInfo {
     219              :     uint64_t inBuffPoolSizeAddr;  // input buffer block num array's address, the array is uint16_t[]
     220              :     uint64_t outBuffPoolSizeAddr; // output buffer block num array's address, the array is uint16_t[]
     221              :     uint64_t inBuffSizeAddr;      // input block size array's address, the array is uint64_t[]
     222              :     uint64_t outBuffSizeAddr;     // output block size array's address, the array is uint64_t[]
     223              :     uint32_t inputNum;
     224              :     uint32_t outputNum;
     225              :     int32_t tagId;                // tag id for hccl
     226              :     int32_t rankId;               // rank id for hccl
     227              :     uint64_t rankTableLen;        // rank table length
     228              :     uint64_t rankTableAddr;       // rank table ptr
     229              :     uint64_t roleTableLen;        // cluster spec length
     230              :     uint64_t roleTableAddr;       // role table ptr
     231              :     uint64_t modelCommOpListAddr; // ModelCommOpList ptr
     232              :     uint32_t modelType;
     233              :     uint64_t commGroupsAddr;      // communication groups ptr
     234              :     int32_t psId;                 // ps id
     235              :     bool supportCounterFilter;    // counter filter flag
     236              :     bool memoryRegister;
     237              :     uint64_t clientRankNum;       // clientRank array's length
     238              :     uint64_t clientRankAddr;      // clientRank array's address, the array is uint32_t[]
     239              :     uint64_t hcclCommNameAddr;    // hcclComm name's addr, the name is char*
     240              :     int32_t hcclTimeOut;          // 0 means default, -1 means never timeout
     241              :     bool associateWorker;         // true means we need to associate worker when load model, default false
     242              :     char rsv[53UL];
     243              : } __attribute__((packed));
     244              : 
     245              : struct __attribute__((visibility("default"))) ModelInfo {
     246              :     uint32_t modelId;
     247              :     uint16_t aicpuStreamNum;
     248              :     ModelStreamInfo* streams;
     249              :     uint16_t queueNum;
     250              :     ModelQueueInfo* queues;
     251              :     int32_t abnormalBreak;
     252              :     int32_t abnormalEnqueue;
     253              :     AicpuPriInfo aicpuPriInfo;
     254              :     uint64_t cfgInfoPtr = 0;
     255              :     int32_t abnormalEnable = 1;
     256              :     char rsv[98];
     257              : } __attribute__((packed));
     258              : 
     259              : struct __attribute__((visibility("default"))) ReDeployConfig {
     260              :     uint64_t modelIdsAddr; // ptr which point to modelIds(uint32_t)
     261              :     uint32_t modelIdNum;   // modelIdNum
     262              :     char rsv[4];
     263              : } __attribute__((packed));
     264              : 
     265              : struct __attribute__((visibility("default"))) CheckKernelSupportedConfig {
     266              :     uint64_t kernelNameAddr;  // ptr which point to kernelName
     267              :     uint32_t kernelNameLen;
     268              :     uint64_t checkResultAddr; // int32: 0 is supported, others are not supported
     269              :     uint32_t checkResultLen;
     270              : } __attribute__((packed));
     271              : 
     272              : struct __attribute__((visibility("default"))) DataFlowExceptionNotify {
     273              :     uint64_t transId;
     274              :     uint32_t type;         // 0:Exception occured, 1:Exception expired
     275              :     uint32_t modelIdNum;
     276              :     uint64_t modelIdsAddr; // ptr which point to modelIds(uint32_t)
     277              :     char rsv[40];
     278              : } __attribute__((packed));
     279              : 
     280              : struct __attribute__((visibility("default"))) SomaMemMng {
     281              :     uint64_t size;
     282              :     uint64_t va;            // Virtual address
     283              :     uint64_t mempoolId;     // Id of memory pool
     284              :     uint32_t deviceId;
     285              :     int32_t memAsyncOpType; // Malloc(0) Free(1)
     286              :     int32_t memAsyncSubCMD; // Distinguish between Malloc reuse strategies and Free explicit/implicit reuse methods
     287              :     char rsv[4];
     288              : } __attribute__((packed));
     289              : }
     290              : #endif // AICPUSD_AICPUSD_INFO_H
        

Generated by: LCOV version 2.0-1