Skip to content

Commit

Permalink
likwid-perfctr: Read performance groups from user folder $HOME/.likwi…
Browse files Browse the repository at this point in the history
…d/groups/<arch>
  • Loading branch information
TomTheBear committed Sep 23, 2015
1 parent 69b1092 commit 4849571
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/applications/likwid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -738,19 +738,23 @@ local function get_groups()
local cpuinfo = likwid.getCpuInfo()
if cpuinfo == nil then return 0, {} end
local f = io.popen("ls " .. likwid.groupfolder .. "/" .. cpuinfo["short_name"] .."/*.txt 2>/dev/null")
t = stringsplit(f:read("*a"),"\n")
f:close()
for i, a in pairs(t) do
if a ~= "" then
table.insert(groups,a:sub((a:match'^.*()/')+1,a:len()-4))
if f ~= nil then
t = stringsplit(f:read("*a"),"\n")
f:close()
for i, a in pairs(t) do
if a ~= "" then
table.insert(groups,a:sub((a:match'^.*()/')+1,a:len()-4))
end
end
end
local f = io.popen("ls " ..os.getenv("HOME") .. "/.likwid/groups/" .. cpuinfo["short_name"] .."/*.txt 2>/dev/null")
t = stringsplit(f:read("*a"),"\n")
f:close()
for i, a in pairs(t) do
if a ~= "" then
table.insert(groups,a:sub((a:match'^.*()/')+1,a:len()-4))
f = io.popen("ls " ..os.getenv("HOME") .. "/.likwid/groups/" .. cpuinfo["short_name"] .."/*.txt 2>/dev/null")
if f ~= nil then
t = stringsplit(f:read("*a"),"\n")
f:close()
for i, a in pairs(t) do
if a ~= "" then
table.insert(groups,a:sub((a:match'^.*()/')+1,a:len()-4))
end
end
end
return #groups,groups
Expand Down Expand Up @@ -812,7 +816,17 @@ local function get_groupdata(group)
end
if (group_exist == 0) then return new_groupdata(group, cpuinfo["perf_num_fixed_ctr"]) end

local f = assert(io.open(likwid.groupfolder .. "/" .. cpuinfo["short_name"] .. "/" .. group .. ".txt", "r"))
local f = io.open(likwid.groupfolder .. "/" .. cpuinfo["short_name"] .. "/" .. group .. ".txt", "r")
if f == nil then
f = io.open(os.getenv("HOME") .. "/.likwid/groups/" .. cpuinfo["short_name"] .."/" .. group .. ".txt", "r")
if f == nil then
print("Cannot read data for group "..group)
print("Tried folders:")
print(likwid.groupfolder .. "/" .. cpuinfo["short_name"] .. "/" .. group .. ".txt")
print(os.getenv("HOME") .. "/.likwid/groups/" .. cpuinfo["short_name"] .."/*.txt")
return groupdata
end
end
local t = f:read("*all")
f:close()
local parse_eventset = false
Expand Down

0 comments on commit 4849571

Please sign in to comment.