Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
platin: import cache-hit statistics from aiT
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhepp committed Sep 19, 2014
1 parent b9fb4d2 commit 78bb690
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions tools/platin/lib/ext/ait.rb
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,17 @@ def rexml_str(name, v)
end
end


class CacheStats
attr_reader :hits, :misses
def initialize(hits, misses)
@hits, @misses = hits, misses
end
def empty?
@hits == 0 && @misses == 0
end
end

class AitImport
attr_reader :pml, :options
def initialize(pml, options)
Expand Down Expand Up @@ -629,7 +640,7 @@ def read_routines(analysis_elem)
die("routine #{routine.instruction} is not a basic block") unless routine.instruction.block.instructions.first == routine.instruction
if elem.attributes['loop']
routine.loop = routine.instruction.block
die("loop routine is not a loop header") unless routine.loop.loopheader?
die("loop #{routine.loop} with id #{elem.attributes['id']} in loop routine #{routine.instruction} is not a loop header") unless routine.loop.loopheader?
else
routine.function = routine.instruction.function
die("routine is not entry block") unless routine.function.entry_block == routine.instruction.block
Expand Down Expand Up @@ -1020,15 +1031,17 @@ def read_wcet_analysis_results(wcet_elem, analysis_entry)
profile_list
end

# XXX add hits and investigate scope of hit/miss stats
def read_cache_misses(wcet_elem, analysis_entry)
misses = {}
# Returns a map with [hits,misses] per cache-type
# XXX investigate scope of hit/miss stats
def read_cache_stats(wcet_elem, analysis_entry)
stats = {}
wcet_elem.each_element("wcet_results/wcet_cache_infos/wcet_cache_info") { |e|
routine = @routines[e.attributes['routine']]
# TODO check: can there be cache results for anything else than the analysis entry?
#routine = @routines[e.attributes['routine']]
type = e.attributes['type']
misses[type] = e.attributes['misses'].to_i
stats[type] = CacheStats.new(e.attributes['hits'].to_i, e.attributes['misses'].to_i)
}
misses
stats
end

def run
Expand All @@ -1037,12 +1050,16 @@ def run

ait_report_file = options.ait_report_prefix + ".#{options.analysis_entry}" + ".xml"
analysis_task_elem = REXML::Document.new(File.read(ait_report_file)).get_elements("a3/wcet_analysis_task").first
read_routines(analysis_task_elem)
debug(options,:ait) { |&msgs|
@routines.each do |id, r|
msgs.call("Routine #{id}: #{r}")
end
}

# read routines (but only if they are actually used later on)
if options.import_block_timings || options.ait_import_addresses
read_routines(analysis_task_elem)
debug(options,:ait) { |&msgs|
@routines.each do |id, r|
msgs.call("Routine #{id}: #{r}")
end
}
end

# read value analysis results
read_contexts(analysis_task_elem.get_elements("value_analysis/contexts").first)
Expand All @@ -1063,8 +1080,9 @@ def run
end

# read cache statistics
read_cache_misses(wcet_elem, analysis_entry).each { |t,v|
timing_entry.attributes['cache-misses-' + t] = v if v > 0
read_cache_stats(wcet_elem, analysis_entry).each { |t,v|
timing_entry.attributes['cache-hits-' + t] = v.hits unless v.empty?
timing_entry.attributes['cache-misses-' + t] = v.misses unless v.empty?
}

statistics("AIT","imported WCET results" => 1) if options.stats
Expand Down

0 comments on commit 78bb690

Please sign in to comment.