@@ -82,6 +82,9 @@ def add_list_options(subparsers):
8282 "list" , help = "List options for hw counters, agents and pc-sampling support"
8383 )
8484 add_parser_bool_argument (list_command , "--pmc" , help = "List counters" )
85+ add_parser_bool_argument (
86+ list_command , "--spm" , help = "List counters supporting SPM"
87+ )
8588 add_parser_bool_argument (
8689 list_command , "--agent" , help = "List basic info of agents"
8790 )
@@ -97,6 +100,7 @@ def add_info_options(subparsers):
97100 )
98101
99102 info_command .add_argument ("--pmc" , nargs = "*" , help = "PMC info" )
103+ info_command .add_argument ("--spm" , nargs = "*" , help = "SPM info" )
100104 info_command .add_argument (
101105 "--pc-sampling" , nargs = "*" , help = "Detailed PC Sampling info"
102106 )
@@ -198,6 +202,10 @@ def list_basic_agent(args, list_counters):
198202 from rocprofv3 import avail
199203
200204 def print_agent_counter (counters ):
205+ if len (counters ) == 0 :
206+ msg = "No PMC counters supported"
207+ print ("{:30}\n " .format (msg ))
208+ return
201209 names_len = [len (counter .name ) for counter in counters ]
202210 names = [
203211 "{name:{width}}" .format (name = counter .name , width = max (names_len ))
@@ -271,10 +279,57 @@ def info_pc_sampling(args):
271279 print ("\n " )
272280
273281
274- def listing (args ):
282+ def listing_spm (args ):
283+ from rocprofv3 import avail
284+
285+ def print_agent_counter (counters ):
286+ if len (counters ) == 0 :
287+ print ("{:30}\n " .format ("No SPM counters supported" ))
288+ return
289+ names_len = [len (counter .name ) for counter in counters ]
290+ names = [
291+ "{name:{width}}" .format (name = counter .name , width = max (names_len ))
292+ for counter in counters
293+ ]
294+ columns = get_number_columns (max (names_len ))
295+ print ("{:30}:\n " .format ("SPM" ))
296+ for idx in range (0 , len (names ), columns ):
297+ print ("{:30}" .format (" " .join (names [idx : (idx + columns )])))
298+
299+ agent_spm_counters = avail .get_spm_counters ()
300+ agent_info_map = avail .get_agent_info_map ()
301+
302+ for agent , info in dict (sorted (agent_info_map .items ())).items ():
303+ if (
304+ info ["type" ] == 2
305+ and args .device is not None
306+ and info ["logical_node_type_id" ] == args .device
307+ ):
308+ print (
309+ "{:30}:\t {}\n {:30}:\t {}" .format (
310+ "GPU" , info ["logical_node_type_id" ], "Name" , info ["name" ]
311+ )
312+ )
313+ print_agent_counter (agent_spm_counters [agent ])
314+ print ("\n " )
315+ break
316+ elif info ["type" ] == 2 and args .device is None :
317+ print (
318+ "{:30}:\t {}\n {:30}:\t {}" .format (
319+ "GPU" , info ["logical_node_type_id" ], "Name" , info ["name" ]
320+ )
321+ )
322+ print_agent_counter (agent_spm_counters [agent ])
323+ print ("\n " )
324+
325+
326+ def listing_pmc (args ):
275327 from rocprofv3 import avail
276328
277329 def print_agent_counter (counters ):
330+ if len (counters ) == 0 :
331+ print ("{:30}\n " .format ("No PMC counters supported" ))
332+ return
278333 names_len = [len (counter .name ) for counter in counters ]
279334 names = [
280335 "{name:{width}}" .format (name = counter .name , width = max (names_len ))
@@ -312,24 +367,65 @@ def print_agent_counter(counters):
312367 print ("\n " )
313368
314369
370+ def info_spm (args ):
371+ from rocprofv3 import avail
372+
373+ agent_info_map = avail .get_agent_info_map ()
374+
375+ def print_spm_info (_args , agent ):
376+
377+ if not _args .spm :
378+ spm_counters = avail .get_spm_counters ()[agent ]
379+ for counter in spm_counters :
380+ print (counter )
381+ print ("\n " )
382+ else :
383+ spm_counters = avail .get_spm_counters ()[agent ]
384+ for spm in _args .spm :
385+ for counter in spm_counters :
386+ if spm == counter .get_as_dict ()["Counter_Name" ]:
387+ print (counter )
388+
389+ for agent , info in dict (sorted (agent_info_map .items ())).items ():
390+ if (
391+ info ["type" ] == 2
392+ and args .device is not None
393+ and info ["logical_node_type_id" ] == args .device
394+ ):
395+ print (
396+ "{}:{}\n {}:{}" .format (
397+ "GPU" , info ["logical_node_type_id" ], "Name" , info ["name" ]
398+ )
399+ )
400+ print_spm_info (args , agent )
401+ break
402+ elif info ["type" ] == 2 and args .device is None :
403+ print (
404+ "{}:{}\n {}:{}" .format (
405+ "GPU" , info ["logical_node_type_id" ], "Name" , info ["name" ]
406+ )
407+ )
408+ print_spm_info (args , agent )
409+
410+
315411def info_pmc (args ):
316412 from rocprofv3 import avail
317413
318- agent_counters = avail .get_counters ()
319414 agent_info_map = avail .get_agent_info_map ()
320415
321- def print_pmc_info (args , pmc_counters ):
416+ def print_pmc_info (_args , agent ):
322417
323- if not args .pmc :
418+ if not _args .pmc :
419+ pmc_counters = avail .get_counters ()[agent ]
324420 for counter in pmc_counters :
325421 print (counter )
326422 print ("\n " )
327423 else :
328- for pmc in args .pmc :
424+ pmc_counters = avail .get_counters ()[agent ]
425+ for pmc in _args .pmc :
329426 for counter in pmc_counters :
330427 if pmc == counter .get_as_dict ()["Counter_Name" ]:
331428 print (counter )
332- print ("\n " )
333429
334430 for agent , info in dict (sorted (agent_info_map .items ())).items ():
335431 if (
@@ -342,34 +438,44 @@ def print_pmc_info(args, pmc_counters):
342438 "GPU" , info ["logical_node_type_id" ], "Name" , info ["name" ]
343439 )
344440 )
345- print_pmc_info (args , agent_counters [ agent ] )
441+ print_pmc_info (args , agent )
346442 break
347443 elif info ["type" ] == 2 and args .device is None :
348444 print (
349445 "{}:{}\n {}:{}" .format (
350446 "GPU" , info ["logical_node_type_id" ], "Name" , info ["name" ]
351447 )
352448 )
353- print_pmc_info (args , agent_counters [ agent ] )
449+ print_pmc_info (args , agent )
354450
355451
356452def process_info (args ):
357- if args .pmc is None and args .pc_sampling is None :
453+
454+ if args .pmc is None and args .pc_sampling is None and args .spm is None :
358455 list_basic_agent (args , True )
359456 if args .pmc is not None :
360457 info_pmc (args )
458+ if args .spm is not None :
459+ info_spm (args )
361460 if args .pc_sampling is not None :
362461 os .environ ["ROCPROFILER_PC_SAMPLING_BETA_ENABLED" ] = "on"
363462 info_pc_sampling (args )
364463
365464
366465def process_list (args ):
367- if args .agent is None and args .pc_sampling is None and args .pmc is None :
368- listing (args )
466+ if (
467+ args .agent is None
468+ and args .pc_sampling is None
469+ and args .pmc is None
470+ and args .spm is None
471+ ):
472+ listing_pmc (args )
369473 if args .agent :
370474 list_basic_agent (args , False )
371475 if args .pmc :
372- listing (args )
476+ listing_pmc (args )
477+ if args .spm :
478+ listing_spm (args )
373479 if args .pc_sampling :
374480 os .environ ["ROCPROFILER_PC_SAMPLING_BETA_ENABLED" ] = "on"
375481 list_pc_sampling (args )
0 commit comments