module BOAST::RedfstProbe
Public Instance Methods
compute()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 164 def compute end
configure()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 155 def configure get_output.puts "redfst_init();" end
decl()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 152 def decl get_output.puts "redfst_dev_t *_boast_energy=0;" end
header()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 147 def header get_output.puts "#include <redfst.h>" end
is_available?()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 197 def is_available? return false if OS.mac? path = [] if ENV['LIBRARY_PATH'] then path += ENV['LIBRARY_PATH'].split(':').inject([]){|mem, x| []!=mem ? mem : Dir.glob(x+'/libredfst.so')} end begin path += `ldconfig -p`.gsub("\t","").split("\n").find_all { |e| e.match(/libredfst\.so/) }.collect { |e| e.split(" => ")[1] } if path == [] rescue path += `/sbin/ldconfig -p`.gsub("\t","").split("\n").find_all { |e| e.match(/libredfst\.so/) }.collect { |e| e.split(" => ")[1] } if path == [] end return path != [] end
preamble()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 150 def preamble end
start()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 158 def start get_output.puts "redfst_reset();" end
stop()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 161 def stop get_output.puts "_boast_energy = redfst_get(_boast_energy);" end
store()
click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 166 def store get_output.print <<EOF { VALUE results; double pkg, pp0, dram; char *s; int i; pkg = pp0 = dram = 0; results = rb_hash_new(); for(i=0; i < _boast_energy->count; ++i){ rb_hash_aset(results, ID2SYM(rb_intern(_boast_energy->name[i])), rb_float_new(_boast_energy->energy[i])); s = _boast_energy->name[i]; while('.'!=*s++) ; while('.'!=*s++) ; if(!strcmp("pkg",s)) pkg += _boast_energy->energy[i]; else if(!strcmp("pp0",s)) pp0 += _boast_energy->energy[i]; else if(!strcmp("dram",s)) dram += _boast_energy->energy[i]; } rb_hash_aset(results, ID2SYM(rb_intern("total.pkg" )), rb_float_new(pkg)); rb_hash_aset(results, ID2SYM(rb_intern("total.pp0" )), rb_float_new(pp0)); rb_hash_aset(results, ID2SYM(rb_intern("total.dram")), rb_float_new(dram)); rb_hash_aset(results, ID2SYM(rb_intern("total" )), rb_float_new(pkg+dram)); rb_hash_aset(_boast_stats, ID2SYM(rb_intern("energy")), results); } EOF end