LinuxPerf.jl
LinuxPerf.jl copied to clipboard
[WIP] Raw events
BTW, I think you can find all the special encoding here http://sbexr.rabexc.org/latest/sources/ea/031fea6da3334a.html
Yeah we should parse these automatically.
As yinhbo pointed out we probably want to parse the events instead of manually encoding them.
No promises, but I might be able to give the parsing a try later this week. I have a question though:
In, say, (:mem_inst_retired_all_stores, 0x82d0)
how to I get the second UInt16
from the source https://github.com/gregkh/linux/blob/master/tools/perf/pmu-events/arch/x86/skylake/cache.json#L425? I seems to be just
julia> eventcode
0xd0
julia> umask
0x82
julia> (UInt16(umask) << 8) + UInt16(eventcode)
0x82d0
Correct? Is there a better way do to it?
First attempt:
combine_code_umask(eventcode::UInt8, umask::UInt8) = (UInt16(umask) << 8) + eventcode
function get_skylake_raw_events()
base_url = "https://raw.githubusercontent.com/gregkh/linux/master/tools/perf/pmu-events/arch/x86/skylake/"
json_files = ("cache.json",
"floating-point.json",
"frontend.json",
"memory.json",
"other.json",
"pipeline.json",
#"skl-metrics.json",
"uncore.json",
"virtual-memory.json")
events = Tuple{Symbol, UInt16}[]
for jf in json_files
url = joinpath(base_url, jf)
json = JSON.parsefile(download(url))
for entry in json
try
# TODO: some entries in pipeline.json don't have EventCodes
haskey(entry, "EventCode") || continue
if !contains(entry["EventCode"], ",")
eventcode = parse(UInt8, entry["EventCode"])
else
# TODO: What to do if we have multiple EventCodes, i.e. "0xB7, 0xBB" in cache.json
eventcode = parse(UInt8, first(split(entry["EventCode"], ",")))
end
# TODO: some entries in pipeline.json don't have UMasks
haskey(entry, "UMask") || continue
umask = parse(UInt8, entry["UMask"])
eventname = Symbol(lowercase(replace(entry["EventName"], "."=>"_")))
eventtuple = (eventname, combine_code_umask(eventcode, umask))
push!(events, eventtuple)
catch e
@warn "$(entry["EventName"]) in $jf couldn't be parsed: $e"
end
end
end
return events
end
Gives:
julia> LinuxPerf.get_skylake_raw_events()
558-element Vector{Tuple{Symbol, UInt16}}:
(:offcore_response_demand_rfo_l4_hit_local_l4_snoop_hit_no_fwd, 0x01b7)
(:offcore_response_other_l3_hit_s_snoop_hit_no_fwd, 0x01b7)
(:offcore_response_demand_rfo_l3_hit_m_snoop_not_needed, 0x01b7)
(:offcore_response_demand_data_rd_l3_hit_e_any_snoop, 0x01b7)
(:offcore_requests_demand_rfo, 0x04b0)
(:offcore_response_demand_code_rd_any_response, 0x01b7)
(:offcore_response_demand_rfo_supplier_none_snoop_not_needed, 0x01b7)
(:l2_rqsts_pf_miss, 0x3824)
(:offcore_response_demand_code_rd_l3_hit_any_snoop, 0x01b7)
(:offcore_response_demand_data_rd_l3_hit_m_snoop_not_needed, 0x01b7)
(:offcore_response_demand_data_rd_l3_hit_s_spl_hit, 0x01b7)
(:l2_rqsts_all_demand_miss, 0x2724)
⋮
(:dtlb_load_misses_walk_completed_4k, 0x0208)
(:itlb_misses_stlb_hit, 0x2085)
(:dtlb_load_misses_walk_completed_2m_4m, 0x0408)
(:dtlb_load_misses_miss_causes_a_walk, 0x0108)
(:ept_walk_pending, 0x104f)
(:tlb_flush_stlb_any, 0x20bd)
(:dtlb_load_misses_walk_completed_1g, 0x0808)
(:dtlb_load_misses_walk_active, 0x1008)
(:itlb_misses_walk_completed_2m_4m, 0x0485)
(:dtlb_store_misses_walk_completed, 0x0e49)
(:dtlb_store_misses_walk_completed_1g, 0x0849)
Any suggestions how to handle the TODO's?
Note that I can't find some of the events you hardcoded @vchuravy:
julia> for v in x
if isnothing(findfirst(e->e[2] == v[2], events))
@show v
end
end
v = (:fp_arith_inst_retired_scalar, 0x03c7)
v = (:fp_arith_inst_retired_double, 0x15c7)
v = (:fp_arith_inst_retired_single, 0x2ac7)
v = (:fp_arith_inst_retired_packed, 0x3cc7)
v = (:fp_arith_inst_retired_512B_packed_double, 0x40c7)
v = (:L2_trans_L1D_wb, 0x10f0)
v = (:L2_lines_in_all, 0x70f1)
v = (:cas_count_rd, 0x0304)
v = (:cas_count_wr, 0x0c04)
They should be in here: https://github.com/gregkh/linux/blob/a5e13c6df0e41702d2b2c77c8ad41677ebb065b3/tools/perf/pmu-events/arch/x86/skylake/floating-point.json#L11-L19
maybe you have them under a different name?
Also the "official" Intel files live here: https://download.01.org/perfmon/SKL/