module BOAST::EmlProbe

Public Instance Methods

compute() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 235
def compute
end
configure() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 224
def configure
  get_output.puts "emlInit();"
  get_output.puts "emlDeviceGetCount(&_boast_energy_count);"
  get_output.puts "_boast_energy = malloc(_boast_energy_count*sizeof(*_boast_energy));"
end
decl() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 220
def decl
  get_output.puts "emlData_t **_boast_energy=0;";
  get_output.puts "size_t _boast_energy_count=0;";
end
header() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 215
def header
  get_output.puts "#include <eml.h>"
end
is_available?() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 249
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+'/libeml.so')}
  end
  begin
    path += `ldconfig -p`.gsub("\t","").split("\n").find_all { |e| e.match(/libeml\.so/) }.collect { |e| e.split(" => ")[1] } if path == []
  rescue
    path += `/sbin/ldconfig -p`.gsub("\t","").split("\n").find_all { |e| e.match(/libeml\.so/) }.collect { |e| e.split(" => ")[1] } if path == []
  end
  return path != []
end
preamble() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 218
def preamble
end
start() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 229
def start
  get_output.puts "emlStart();";
end
stop() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 232
def stop
  get_output.puts "emlStop(_boast_energy);";
end
store() click to toggle source
# File lib/BOAST/Runtime/EnergyProbe.rb, line 237
    def store
      get_output.print <<EOF
{
  VALUE results;
  double consumed;
  results = rb_hash_new();
  emlDataGetConsumed(_boast_energy[0], &consumed);
  rb_hash_aset(results, ID2SYM(rb_intern("total" )), rb_float_new(consumed));
  rb_hash_aset(_boast_stats, ID2SYM(rb_intern("energy")), results);
}
EOF
    end