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-07-28 10:54:05 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              : };
      85              : 
      86              : struct __attribute__((visibility("default"))) AICPUSubEventStreamInfo {
      87              :     uint32_t streamId;
      88              : };
      89              : 
      90              : struct __attribute__((visibility("default"))) AICPUProfilingModeInfo {
      91              :     uint32_t deviceId;
      92              :     pid_t hostpId;
      93              :     uint32_t flag;
      94              : };
      95              : 
      96              : struct __attribute__((visibility("default"))) AICPULoadSoInfo {
      97              :     uint32_t kernelSoIndex;
      98              : };
      99              : 
     100              : struct __attribute__((visibility("default"))) AICPUEndGraphInfo {
     101              :     uint32_t result;
     102              : };
     103              : 
     104              : struct __attribute__((visibility("default"))) AICPUSharderTaskInfo {
     105              :     uint32_t parallelId;
     106              :     int64_t shardNum;
     107              : 
     108          185 :     bool operator==(const AICPUSharderTaskInfo& sharderInfo) const noexcept
     109              :     {
     110          185 :         return (parallelId == sharderInfo.parallelId);
     111              :     }
     112              : };
     113              : 
     114              : struct __attribute__((visibility("default"))) AICPUUnLockTableInfo {
     115              :     uint32_t tableId;
     116              : };
     117              : 
     118              : struct __attribute__((visibility("default"))) AICPUDumpCustInfo {
     119              :     uint32_t threadIndex; // dump任务的线程号
     120              :     int32_t retCode;      // dump result
     121              :     uint32_t streamId;    // dump key streamId
     122              :     uint32_t taskId;      // dump key taskId
     123              : };
     124              : 
     125              : struct __attribute__((visibility("default"))) AICPUDumpUdfInfo {
     126              :     uint64_t length;
     127              :     uint64_t udfInfo;
     128              :     uint32_t udfPid;
     129              :     char_t rsv[20];
     130              : };
     131              : 
     132              : struct __attribute__((visibility("default"))) AICPULoadPlatformCustInfo {
     133              :     uint64_t length;
     134              :     uint64_t platformInfo;
     135              :     uint32_t aicpuPid;
     136              :     char_t rsv[20];
     137              : };
     138              : 
     139              : struct __attribute__((visibility("default"))) AICPUSubEventInfo {
     140              :     uint32_t modelId;
     141              :     union {
     142              :         AICPUSubEventStreamInfo streamInfo;
     143              :         AICPUProfilingModeInfo modeInfo;
     144              :         AICPULoadSoInfo loadSoInfo;
     145              :         AICPUEndGraphInfo endGraphInfo;
     146              :         AICPUSharderTaskInfo sharderTaskInfo;
     147              :         AICPUUnLockTableInfo unlockTableInfo;
     148              :     } para;
     149              : };
     150              : 
     151              : struct __attribute__((visibility("default"))) AICPUBindSdPidEventMsg {
     152              :     int32_t pid;
     153              : } __attribute__((packed));
     154              : 
     155              : struct __attribute__((visibility("default"))) AICPUOpenCustomSoEventMsg {
     156              :     char_t kernelSoName[MAX_CUST_SO_NAME_LEN];
     157              : } __attribute__((packed));
     158              : 
     159              : struct __attribute__((visibility("default"))) CpuSchedInitParam {
     160              :     uint32_t deviceId;
     161              :     pid_t hostPid;
     162              :     ProfilingMode profilingMode;
     163              :     char_t rsv[128];
     164              : } __attribute__((packed));
     165              : 
     166              : struct __attribute__((visibility("default"))) ModelQueueInfo {
     167              :     uint32_t queueId;
     168              :     uint32_t flag;
     169              : } __attribute__((packed));
     170              : 
     171              : struct __attribute__((visibility("default"))) ModelTaskInfo {
     172              :     uint32_t taskId;
     173              :     uint64_t kernelName;
     174              :     uint64_t paraBase; // param地址
     175              : } __attribute__((packed));
     176              : 
     177              : struct __attribute__((visibility("default"))) ModelStreamInfo {
     178              :     uint32_t streamId;
     179              :     uint32_t streamFlag;
     180              :     uint16_t taskNum;
     181              :     ModelTaskInfo* tasks;
     182              : } __attribute__((packed));
     183              : 
     184              : struct __attribute__((visibility("default"))) AicpuPriInfo {
     185              :     uint16_t checkHead;
     186              :     int32_t pidPriority;
     187              :     int32_t eventPriority;
     188              : } __attribute__((packed));
     189              : 
     190              : struct __attribute__((visibility("default"))) ModelCommOpList {
     191              :     uint64_t commOpDescsListAddr;
     192              :     uint32_t opNum;
     193              : } __attribute__((packed));
     194              : 
     195              : // 配置类型,用于给AICPU控制不同的加载流程
     196              : enum __attribute__((visibility("default"))) ModelType {
     197              :     kModelWithEmbedding = 0,
     198              :     kModelWithSyncEvent = 1,
     199              :     kModelTypeNum
     200              : };
     201              : 
     202              : struct __attribute__((visibility("default"))) CommGroup {
     203              :     const char* groupName;
     204              :     uint32_t rankNum;
     205              :     uint32_t* rankIds;
     206              : } __attribute__((packed));
     207              : 
     208              : struct __attribute__((visibility("default"))) CommGroups {
     209              :     uint32_t groupNum;
     210              :     CommGroup* groups;
     211              : } __attribute__((packed));
     212              : 
     213              : struct __attribute__((visibility("default"))) ModelCfgInfo {
     214              :     uint64_t inBuffPoolSizeAddr;  // input buffer block num array's address, the array is uint16_t[]
     215              :     uint64_t outBuffPoolSizeAddr; // output buffer block num array's address, the array is uint16_t[]
     216              :     uint64_t inBuffSizeAddr;      // input block size array's address, the array is uint64_t[]
     217              :     uint64_t outBuffSizeAddr;     // output block size array's address, the array is uint64_t[]
     218              :     uint32_t inputNum;
     219              :     uint32_t outputNum;
     220              :     int32_t tagId;                // tag id for hccl
     221              :     int32_t rankId;               // rank id for hccl
     222              :     uint64_t rankTableLen;        // rank table length
     223              :     uint64_t rankTableAddr;       // rank table ptr
     224              :     uint64_t roleTableLen;        // cluster spec length
     225              :     uint64_t roleTableAddr;       // role table ptr
     226              :     uint64_t modelCommOpListAddr; // ModelCommOpList ptr
     227              :     uint32_t modelType;
     228              :     uint64_t commGroupsAddr;      // communication groups ptr
     229              :     int32_t psId;                 // ps id
     230              :     bool supportCounterFilter;    // counter filter flag
     231              :     bool memoryRegister;
     232              :     uint64_t clientRankNum;       // clientRank array's length
     233              :     uint64_t clientRankAddr;      // clientRank array's address, the array is uint32_t[]
     234              :     uint64_t hcclCommNameAddr;    // hcclComm name's addr, the name is char*
     235              :     int32_t hcclTimeOut;          // 0 means default, -1 means never timeout
     236              :     bool associateWorker;         // true means we need to associate worker when load model, default false
     237              :     char rsv[53UL];
     238              : } __attribute__((packed));
     239              : 
     240              : struct __attribute__((visibility("default"))) ModelInfo {
     241              :     uint32_t modelId;
     242              :     uint16_t aicpuStreamNum;
     243              :     ModelStreamInfo* streams;
     244              :     uint16_t queueNum;
     245              :     ModelQueueInfo* queues;
     246              :     int32_t abnormalBreak;
     247              :     int32_t abnormalEnqueue;
     248              :     AicpuPriInfo aicpuPriInfo;
     249              :     uint64_t cfgInfoPtr = 0;
     250              :     int32_t abnormalEnable = 1;
     251              :     char rsv[98];
     252              : } __attribute__((packed));
     253              : 
     254              : struct __attribute__((visibility("default"))) ReDeployConfig {
     255              :     uint64_t modelIdsAddr; // ptr which point to modelIds(uint32_t)
     256              :     uint32_t modelIdNum;   // modelIdNum
     257              :     char rsv[4];
     258              : } __attribute__((packed));
     259              : 
     260              : struct __attribute__((visibility("default"))) CheckKernelSupportedConfig {
     261              :     uint64_t kernelNameAddr;  // ptr which point to kernelName
     262              :     uint32_t kernelNameLen;
     263              :     uint64_t checkResultAddr; // int32: 0 is supported, others are not supported
     264              :     uint32_t checkResultLen;
     265              : } __attribute__((packed));
     266              : 
     267              : struct __attribute__((visibility("default"))) DataFlowExceptionNotify {
     268              :     uint64_t transId;
     269              :     uint32_t type;         // 0:Exception occured, 1:Exception expired
     270              :     uint32_t modelIdNum;
     271              :     uint64_t modelIdsAddr; // ptr which point to modelIds(uint32_t)
     272              :     char rsv[40];
     273              : } __attribute__((packed));
     274              : 
     275              : struct __attribute__((visibility("default"))) SomaMemMng {
     276              :     uint64_t size;
     277              :     uint64_t va;            // Virtual address
     278              :     uint64_t mempoolId;     // Id of memory pool
     279              :     uint32_t deviceId;
     280              :     int32_t memAsyncOpType; // Malloc(0) Free(1)
     281              :     int32_t memAsyncSubCMD; // Distinguish between Malloc reuse strategies and Free explicit/implicit reuse methods
     282              :     char rsv[4];
     283              : } __attribute__((packed));
     284              : }
     285              : #endif // AICPUSD_AICPUSD_INFO_H
        

Generated by: LCOV version 2.0-1