Skip to content

API and Data Structures

FindHao edited this page Aug 31, 2025 · 4 revisions

Device→Host Message Types (from include/common.h) 📨

  • reg_info_t (type = MSG_TYPE_REG_INFO)
    • Fields: cta_id_{x,y,z}, warp_id, opcode_id, num_regs, reg_vals[32][8], kernel_launch_id, pc, num_uregs, ureg_vals[8].
  • mem_access_t (type = MSG_TYPE_MEM_ACCESS)
    • Fields: kernel_launch_id, cta_id_{x,y,z}, pc, warp_id, opcode_id, addrs[32].
  • opcode_only_t (type = MSG_TYPE_OPCODE_ONLY)
    • Fields: kernel_launch_id, cta_id_{x,y,z}, pc, warp_id, opcode_id.

Runtime State (from include/analysis.h) 🧠

  • WarpState
    • Tracks region collection (is_collecting), region_counter, and per-region histogram.
  • RegionHistogram
    • Finalized histogram with warp_id, region_id, histogram.
  • CTXstate
    • Channel: channel_dev, channel_host.
    • SASS maps: id_to_sass_map, clock_opcode_ids, exit_opcode_ids.
    • Deadlock detection state: loop_states, active_warps, pending_mem_by_warp, timestamps, and termination counters.

Logging Helpers (from include/log.h) 📝

  • lprintf, oprintf, loprintf, trace_lprintf
  • log_open_kernel_file(ctx, func, iteration), log_close_kernel_file()
  • compute_kernel_name_hash_hex(ctx, func), generate_kernel_log_basename(ctx, func, iteration)

Key Host Functions 🧵

  • recv_thread_fun(void* args)
    • Receives typed messages, dispatches analyses, writes outputs, and performs hang checks.
  • dump_histograms_to_csv(ctx, func, iteration, histograms)
    • Writes kernel_*_hist.csv with warp_id,region_id,instruction,count.

Key Instrumentation Helpers (from src/instrument.cu) 🧰

  • instrument_opcode_only(instr, opcode_id, ctx_state)
  • instrument_register_trace(instr, opcode_id, ctx_state, reg_num_list, ureg_num_list)
  • instrument_memory_trace(instr, opcode_id, ctx_state, mref_idx)

Clone this wiki locally