* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ------------------------------------------------------------------------- */
#ifndef __AIC_LOG_API_H__
#define __AIC_LOG_API_H__
#include <cstdint>
#ifndef MODEL_API
#define MODEL_API __attribute__((visibility("default")))
#endif
typedef struct DvcInstrLogEntry {
uint32_t core_id;
uint32_t sub_core_id;
uint64_t pc;
const char* decode_descr;
const char* exec_descr;
} DvcInstrLogEntry_t;
typedef struct DvcMteLogEntry {
uint32_t core_id;
uint32_t sub_core_id;
const char* op;
union DataT {
struct BifOpInfoT {
const char* intf;
uint32_t port;
uint64_t addr;
uint64_t size;
uint64_t gid;
uint32_t retire_set;
uint64_t instr_id;
uint32_t req_id;
} bif_op_info;
struct IntfOpInfoT {
const char* intf;
uint32_t port;
uint64_t addr;
uint64_t size;
uint32_t tag_id;
uint64_t instr_id;
uint32_t req_id;
} intf_op_info;
struct BiuUopSplitInfoT {
uint32_t thread_id;
uint64_t read_size;
uint32_t retire_set;
uint32_t instr_id;
} biu_uop_split_info;
struct SendDataInfoT {
uint32_t port;
uint32_t thread_id;
uint64_t addr;
uint64_t size;
uint64_t gid;
uint32_t stbidx;
uint32_t retire_set;
uint32_t instr_id;
} send_data_info;
struct EarlyRetireInfoT {
uint32_t sub_id;
uint32_t thread_id;
uint32_t pipe;
uint64_t instr_id;
} early_retire_info;
struct RetireInfoT {
uint64_t instr_id;
} retire_info;
} data;
} DvcMteLogEntry_t;
typedef struct DvcIcacheLogEntry {
uint32_t core_id;
uint32_t sub_core_id;
const char* op;
union DataT {
struct PreloadInfoT {
uint64_t gid;
uint64_t addr;
uint32_t size;
uint8_t last;
} preload_info;
struct MissReadInfoT {
uint64_t addr;
uint32_t size;
uint32_t type;
uint8_t last;
} miss_read_info;
struct PrefetchInfoT {
uint64_t gid;
uint64_t addr;
uint32_t size;
uint8_t last;
} prefetch_info;
struct HitReadInfoT {
uint64_t addr;
uint32_t size;
} hit_read_info;
struct SendInfoT {
uint64_t addr;
uint64_t gid;
} send_info;
struct FetchReqInfoT {
uint64_t addr;
} fetch_req_info;
struct PrefetchReqInfoT {
uint64_t addr;
} prefetch_req_info;
struct PreloadReqInfoT {
uint64_t addr;
} preload_req_info;
struct SendReqInfoT {
uint64_t addr;
uint32_t size;
} send_req_info;
struct RefillReqInfoT {
uint64_t gid;
uint64_t addr;
uint32_t idx_addr;
uint32_t victim;
} refill_req_info;
struct SendRefillInfoT {
uint64_t addr;
uint64_t gid;
} send_refill_info;
} data;
} DvcIcacheLogEntry_t;
typedef struct DvcCcuLogEntry {
uint32_t core_id;
uint32_t sub_core_id;
const char* op;
union DataT {
struct DecodeInfoT {
uint32_t isa_type;
uint32_t isa_latency;
uint64_t pc;
uint64_t instr_id;
} decode_info;
struct D1StageInfoT {
const char* instr_name;
uint64_t pc;
uint64_t instr_id;
} d1_stage_info;
struct IssueInfoT {
const char* instr_name;
uint64_t pc;
uint64_t instr_id;
uint8_t hazard;
uint8_t hazard_type;
uint32_t hazard_spr;
} issue_info;
struct ExecuteInfoT {
const char* instr_name;
uint64_t pc;
uint64_t instr_id;
} execute_info;
struct BranchInfoT {
uint64_t target_pc;
uint64_t instr_pc;
uint64_t instr_id;
uint8_t is_mispredict;
} branch_info;
struct BarrierInfoT {
const char* instr_name;
uint64_t pc;
uint64_t instr_id;
} barrier_info;
struct PushQueueInfoT {
const char* instr_name;
const char* pipe;
uint64_t pc;
uint64_t instr_id;
} push_queue_info;
struct VfInstrInfoT {
uint64_t pc;
uint64_t instr_id;
uint64_t vpc;
uint32_t slot_id;
} vf_instr_info;
struct PushPbInfoT {
uint64_t pc;
uint64_t instr_id;
uint32_t slot_id;
} push_pb_info;
struct BufInfoT {
uint32_t buf_id;
uint64_t pc;
const char* pipe;
} buf_info;
struct FlagInfoT {
uint64_t pc;
uint64_t instr_id;
uint32_t flag_id;
} flag_info;
struct EndInfoT {
uint64_t pc;
uint32_t sub_core_id;
} end_info;
struct EndLabelInfoT {
uint32_t dummy;
} endlabel_info;
struct IntraBlockInfoT {
uint64_t pc;
uint64_t instr_id;
uint32_t block_id;
uint32_t connect_id;
} intra_block_info;
struct DsbInfoT {
uint32_t dsb_pb_map_size;
uint32_t dsb_ub_map_size;
} dsb_info;
struct LoopInfoT {
uint64_t pc;
uint64_t start_pc;
uint32_t iter;
} loop_info;
struct DcciInfoT {
uint64_t pc;
uint64_t instr_id;
} dcci_info;
struct IssueSuccessInfoT {
uint64_t pc;
const char* instr_name;
const char* pipe;
} issue_success_info;
} data;
} DvcCcuLogEntry_t;
typedef struct DvcIfuLogEntry {
uint32_t core_id;
uint32_t sub_core_id;
const char* op;
union DataT {
struct FetchInfoT {
uint64_t pc;
uint32_t fetch_size;
} fetch_info;
struct DispatchInfoT {
const char* instr_name;
uint64_t pc;
uint64_t instr_id;
} dispatch_info;
struct UpdatePredInfoT {
uint64_t start_pc;
uint32_t instr_num;
uint32_t start_pos;
uint32_t pred_loc;
uint32_t end_pos;
} update_pred_info;
struct DecodeInfoT {
uint64_t pc;
uint32_t raw;
const char* instr_name;
uint64_t instr_id;
} decode_info;
struct GetPredictPCInfoT {
uint64_t start_pc;
uint64_t pred_pc;
uint32_t predict_loc;
} get_predict_pc_info;
struct CheckBranchInstrTypeInfoT {
uint64_t pc;
uint64_t instr_id;
uint8_t is_branch_xn;
} check_branch_instr_type_info;
struct HandleBranchInstrInfoT {
uint64_t pc;
uint64_t instr_id;
uint32_t pht_index;
uint64_t pred_pc;
uint64_t next_pc;
} handle_branch_instr_info;
struct SetBranchTargetInfoT {
uint64_t target;
uint64_t pc;
} set_branch_target_info;
} data;
} DvcIfuLogEntry_t;
typedef void (*DvcInstrLogCb_t)(uint64_t, const DvcInstrLogEntry_t*);
typedef void (*DvcMteLogCb_t)(uint64_t, const DvcMteLogEntry_t*);
typedef void (*DvcIcacheLogCb_t)(uint64_t, const DvcIcacheLogEntry_t*);
typedef void (*DvcIfuLogCb_t)(uint64_t, const DvcIfuLogEntry_t*);
typedef void (*DvcCcuLogCb_t)(uint64_t, const DvcCcuLogEntry_t*);
typedef enum DvcLogType {
DVC_INSTR_POPPED_LOG = 0,
DVC_INSTR_LOG = 1,
DVC_MTE_LOG = 2,
DVC_ICACHE_LOG = 3,
DVC_IFU_LOG = 4,
DVC_CCU_LOG = 5,
DVC_UNDEF = 0xff
} DvcLogType_t;
typedef union DvcLogCbFnUnion {
DvcInstrLogCb_t instrLogCb;
DvcMteLogCb_t mteLogCb;
DvcIcacheLogCb_t icacheLogCb;
DvcIfuLogCb_t ifuLogCb;
DvcCcuLogCb_t ccuLogCb;
} DvcLogCbFnUnion_t;
extern "C" {
MODEL_API void DvcSetLogLevel(
const uint32_t file_print_level, const uint32_t screen_print_level, const uint32_t flush_level
);
MODEL_API void DvcSetLogRotation(const uint64_t rotating_file_size, const uint32_t rotating_file_number);
MODEL_API void DvcAttachLogCallback(DvcLogType_t log_type, DvcLogCbFnUnion_t fn_union);
}
#endif