12-Jan-2012

FASTPATH.COM

A quick DCL hack to display which CPU is managing each fastpath capable device.


$! See EOF for comments.
$       old_verify = f$verify (0)
$       say := write sys$output
$       status = 1
$       cpu_cnt = f$getsyi ("activecpu_cnt")
$       if cpu_cnt .eq. 1
$       then
$           say "Erm, hardly any use running this on a uniprocessor, is there?"
$           goto exit
$       endif
$       primary_cpu = f$getsyi ("primary_cpuid")
$       active_cpus = f$getsyi ("active_cpu_mask")
$
$       cothd == 0
$       if f$getsyi ("arch_name") .eqs. "IA64"
$       then
$           save_msg = f$environment ("message")
$           set message/nof/noi/nos/not
$           pipe show cpu/full | search/out=nl: sys$pipe "Cothd:" ; -
                                 cothd == f$integer ($status) .eq. %x10000001
$           set message 'save_msg
$       endif
$! Initialize variables so that each CPU number has a variable in the form
$! cpu_<number> and a variable in the form cpu_<number>_devs.
$       temp = 1
$       count = 0
$       cpu_list = ""
$cpu_init_loop:
$       if (temp .and. active_cpus) .ne. 0
$       then
$           cpu_'count' = 0
$           cpu_'count'_devs = ""
$           if cpu_list .eqs. ""
$           then
$               cpu_list = f$string (count)
$           else
$               cpu_list = cpu_list + "," + f$string (count)
$           endif
$       endif
$       if count .lt. 16
$       then
$           temp = temp * 2
$           count = count + 1
$           goto cpu_init_loop
$       endif
$
$loop:
$       device = f$device ("_*0:")
$       if device .eqs. ""
$       then
$           goto end_loop
$       endif
$       if f$getdvi (device, "devclass") .eq. 1
$       then
$           goto loop
$       endif
$       cpu_mask = f$getdvi (device, "preferred_cpu")
$       if cpu_mask .ne. 0
$       then
$           gosub decode_mask
$           if cpu .eq. -1
$           then
$               say "ERROR! CPU mask could not be decoded!
$               say "-ERROR Are you running on a 16+ CPU machine?"
$               status = 44
$               goto exit
$           endif
$           if cpu_'cpu'_devs .eqs. ""
$           then
$               cpu_'cpu'_devs = device
$           else
$               cpu_'cpu'_devs = cpu_'cpu'_devs + "," + device
$           endif
$       endif
$       goto loop
$end_loop:
$       count = 0
$display_loop:
$       cpu = f$element (count, ",", cpu_list)
$       if cpu .eqs. ","
$       then
$           goto end_display_loop
$       endif
$       type = "PHYCPU"
$       if cothd
$       then
$           type = "CO-THD"
$       endif
$       str = "cpu ''cpu' (''type'): " + cpu_'cpu'_devs
$       if cpu .eqs. f$string (primary_cpu)
$       then
$           str = str + " (primary cpu)"
$       endif
$       say str
$       count = count + 1
$       goto display_loop
$
$end_display_loop:
$       goto exit
$exit:
$       exit 'status' + 0*'f$verify (old_verify)'
$!
$decode_mask:
$       bit = 0
$dmloop:
$       if bit .eq. 0
$       then
$           mask = 1
$       else
$           mask = mask * 2
$       endif
$       if mask .eq. cpu_mask
$       then
$           cpu = bit
$           return
$       endif
$       bit = bit + 1
$       if bit .lt. 32
$       then
$           goto dmloop
$       endif
$       cpu = -1
$       return
$!++
$!
$! DESCRIPTION
$!
$!      Simple utility to show you which CPUs are doing fastpath processing
$!      for each fastpath capable device.
$!
$! AUTHOR
$!
$!      James F. Duff
$!
$! DATE WRITTEN
$!
$!      21-Mar-2008
$!
$! MODIFICATION HISTORY
$!
$!      21-Mar-2008     Jim Duff
$!      Original version of module
$!
$!      18-Dec-2011     Jim Duff
$!      If we are running on an IA64 with hyperthreading enabled, indicate
$!      that the CPUs are really cothreads.
$!
$!--

Posted at January 12, 2012 3:48 PM
Tag Set:

Comments are closed