Skip to content

Commit

Permalink
Add -p/--print option to likwid-sysfeatures
Browse files Browse the repository at this point in the history
This option lists all available device types.
  • Loading branch information
ipatix committed Nov 15, 2024
1 parent fb1bce8 commit f192fae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/likwid-sysfeatures.1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ list all provided features for the current system and OS
.B \-\^l,\-\-\^list
list all features with their current value for given devices
.TP
.B \-\^p,\-\-\^print
list available devices for all available device types
.TP
.B \-\^d, \-\-\^devices <device_list>
use devices for listing, getting and setting features
.TP
Expand Down
36 changes: 33 additions & 3 deletions src/applications/likwid-sysfeatures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ local function usage()
print_stdout("-v, --version\t\t Version information")
print_stdout("-a, --all\t\t List all available features")
print_stdout("-l, --list\t\t List features and state for given devices")
print_stdout("-p, --print\t\t List available devices")
print_stdout("-d, --devices <list>\t Perform operations on given devices")
print_stdout("-g, --get <feature(s)>\t Get the value of the given feature(s)")
print_stdout(" \t feature format: <category>.<name> or just <name> if unique")
Expand Down Expand Up @@ -109,6 +110,7 @@ end
-- main variables with defaults
local listFeatures = false
local allFeatures = false
local printDevices = false
local devList = {}
local getList = {}
local setList = {}
Expand All @@ -119,7 +121,7 @@ local verbose = 0
local output_csv = false

-- parse the command line
for opt,arg in likwid.getopt(arg, {"h","v","l","d:","g:","s:","a", "O","help","version","list", "set:", "get:","all", "cpus:", "V:", "verbose:"}) do
for opt,arg in likwid.getopt(arg, {"h","v","l","p","d:","g:","s:","a", "O","help","version","list", "print", "set:", "get:","all", "cpus:", "V:", "verbose:"}) do
if (type(arg) == "string") then
local s,e = arg:find("-");
if s == 1 then
Expand All @@ -138,6 +140,8 @@ for opt,arg in likwid.getopt(arg, {"h","v","l","d:","g:","s:","a", "O","help","v
devList = likwid.createDevicesFromString(arg)
elseif opt == "l" or opt == "list" then
listFeatures = true
elseif opt == "p" or opt == "print" then
printDevices = true
elseif opt == "O" then
output_csv = true
elseif opt == "V" or opt == "verbose" then
Expand All @@ -159,11 +163,11 @@ end


-- validate command line input
if (not listFeatures) and (not allFeatures) and (#getList == 0) and (#setList == 0) then
if (not printDevices) and (not listFeatures) and (not allFeatures) and (#getList == 0) and (#setList == 0) then
print_stderr("No operations specified, exiting...")
os.exit(1)
end
if (listFeatures or allFeatures) and (#getList > 0 or #setList > 0) then
if (printDevices or listFeatures or allFeatures) and (#getList > 0 or #setList > 0) then
print_stderr("Cannot list features and get/set at the same time")
os.exit(1)
end
Expand Down Expand Up @@ -201,6 +205,32 @@ end
-- get a list of all features for the system
local ft_list = likwid.sysFeatures_list()

-- print available devices
if printDevices then
device_types = {}
device_types[likwid.hwthread] = "HWThread"
device_types[likwid.core] = "Core"
device_types[likwid.numa] = "NUMA"
device_types[likwid.die] = "Die"
device_types[likwid.socket] = "Socket"
device_types[likwid.node] = "Node"
if likwid.nvSupported() then
device_types[likwid.nvidia_gpu] = "Nvidia GPU"
end
if likwid.rocmSupported() then
device_types[likwid.amd_gpu] = "AMD GPU"
end
for devtype, name in pairs(device_types) do
print(string.format("%s:", name))
devices = likwid.getAvailableDevices(devtype)
if #devices == 0 then
print("\t<none>")
else
print("\t" .. table.concat(devices, ","))
end
end
end

-- print the list
if allFeatures then
local all = {}
Expand Down

0 comments on commit f192fae

Please sign in to comment.