Module: PAPI
- Extended by:
- FFI::Library
- Defined in:
- lib/PAPI/Error.rb,
lib/PAPI/Event.rb,
lib/PAPI/Version.rb,
lib/PAPI/EventSet.rb,
lib/PAPI/Component.rb
Defined Under Namespace
Classes: Component, Error, Event, EventSet, Version
Constant Summary collapse
- MIN_STR_LEN =
64- MAX_STR_LEN =
128- MAX_STR_LEN2 =
256- HUGE_STR_LEN =
1024- MAX_INFO_TERMS =
12- PMU_MAX =
40- OK =
0- PAPI_NULL =
-1- EventModifier =
enum( :enum_events, :enum_first, :preset_enum_avail, :preset_enum_msc, :preset_enum_ins, :preset_enum_idl, :preset_enum_br, :preset_enum_cnd, :preset_enum_mem, :preset_enum_cach, :preset_enum_l1, :preset_enum_l2, :preset_enum_l3, :preset_enum_tlb, :preset_enum_fp, :ntv_enum_umasks, :ntv_enum_umasks_combos, :ntv_enum_iarr, :ntv_enum_darr, :ntv_enum_opcm, :ntv_enum_iear, :ntv_enum_dear, :ntv_enum_groups )
- PRESET_EVENTS =
[]
- PRESET_EVENTS_HASH =
{}
- VERSION =
self.init()
- COMPONENTS =
[]
- COMPONENTS_HASH =
{}
Class Method Summary collapse
- .error_check(errcode) ⇒ Object
- .get_components_info ⇒ Object
- .get_events_info ⇒ Object
- .get_mask_info(code, component) ⇒ Object
- .get_native_events(component) ⇒ Object
- .init ⇒ Object
Class Method Details
.error_check(errcode) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/PAPI/Error.rb', line 105 def self.error_check(errcode) return nil if errcode >= OK klass = Error::error_class(errcode) if klass then raise klass::new else raise Error::new("#{errcode}") end end |
.get_components_info ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/PAPI/Component.rb', line 128 def self.get_components_info if VERSION < Version::new(4,0,0,0) then info_p = PAPI_get_substrate_info() COMPONENTS.push( Component::new(Component::Info::new(info_p))) COMPONENTS_HASH[0] = COMPONENTS[0] else (0...PAPI_num_components()).each { |cid| info_p = PAPI_get_component_info(cid) info = Component::Info::new(info_p) if VERSION >= Version::new(5,0,0,0) and info[:disabled] != 0 then #puts "#{info[:name].to_ptr.read_string}: #{info[:disabled_reason].to_ptr.read_string}" else COMPONENTS.push( Component::new(info, cid) ) COMPONENTS_HASH[cid] = COMPONENTS.last end } end if COMPONENTS.length > 0 then COMPONENTS[0].preset = PRESET_EVENTS end COMPONENTS.each { |c| get_native_events( c ) } end |
.get_events_info ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/PAPI/Event.rb', line 120 def self.get_events_info e_p = FFI::MemoryPointer::new(:uint) e_p.write_uint(0 | Event::PRESET_MASK) PAPI_enum_event(e_p, :enum_first) info = Event::Info::new e = PAPI_get_event_info( e_p.read_int, info ) ev = Event::new(info) PRESET_EVENTS.push(ev) PRESET_EVENTS_HASH[ev.to_i] = ev while PAPI_enum_event(e_p, :preset_enum_avail) == OK do info = Event::Info::new e = PAPI_get_event_info( e_p.read_int, info ) ev = Event::new(info) PRESET_EVENTS.push(ev) PRESET_EVENTS_HASH[ev.to_i] = ev end end |
.get_mask_info(code, component) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/PAPI/Component.rb', line 71 def self.get_mask_info( code, component ) m_p = FFI::MemoryPointer::new(:uint) m_p.write_uint( code.read_uint ) if VERSION < Version::new(4,0,0,0) then e = PAPI_enum_event( m_p, :ntv_enum_umasks ) else e = PAPI_enum_cmp_event( m_p, :ntv_enum_umasks, component.to_i ) end return nil if e != OK info = Event::Info::new e = PAPI_get_event_info( m_p.read_int, info ) if e == OK then ev = Event::new(info) masks = [] masks.push(ev) end while ( VERSION < Version::new(4,0,0,0) ? PAPI_enum_event(e_p, :ntv_enum_umasks) : PAPI_enum_cmp_event( m_p, :ntv_enum_umasks, component.to_i ) ) == OK do info = Event::Info::new e = PAPI_get_event_info( m_p.read_int, info ) next if e != OK ev = Event::new(info) masks = [] if not masks masks.push(ev) end return masks end |
.get_native_events(component) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/PAPI/Component.rb', line 98 def self.get_native_events( component ) e_p = FFI::MemoryPointer::new(:uint) e_p.write_uint(0 | Event::NATIVE_MASK) if VERSION < Version::new(4,0,0,0) then e = PAPI_enum_event(e_p, :enum_first) else e = PAPI_enum_cmp_event(e_p, :enum_first, component.to_i) end return if e != OK info = Event::Info::new e = PAPI_get_event_info( e_p.read_int, info ) if e == OK then ev = Event::new(info, get_mask_info( e_p, component )) component.native = [] component.native.push(ev) end while ( VERSION < Version::new(4,0,0,0) ? PAPI_enum_event(e_p, :enum_events) : PAPI_enum_cmp_event(e_p, :enum_events, component.to_i) ) == OK do info = Event::Info::new e = PAPI_get_event_info( e_p.read_int, info ) next if e != OK ev = Event::new(info, get_mask_info( e_p, component ) ) component.native = [] if not component.native component.native.push(ev) end #puts "#{component}: #{component.to_i}" #puts component.native.length #component.native.each { |evt| puts evt.to_s(true, true) } end |
.init ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/PAPI/Version.rb', line 57 def self.init 5.downto(3) { |major| 9.downto(0) { |minor| 9.downto(0) { |revision| 9.downto(0) { |increment| v = Version::new(major, minor, revision, increment) res = PAPI_library_init(v) if res == v.to_int then return Version::new(res) end } } } } return nil end |