From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,fe4802dca487d4d1,start X-Google-Attributes: gid111c93,public X-Google-Thread: fd2d7,fe4802dca487d4d1,start X-Google-Attributes: gidfd2d7,public X-Google-Thread: fd581,fe4802dca487d4d1,start X-Google-Attributes: gidfd581,public From: Martin Wilck Subject: /proc/cpuinfo shell script Date: 2000/11/14 Message-ID: <8us13d$2rbnh$1@fu-berlin.de> X-Deja-AN: 693578835 X-Trace: fu-berlin.de 974227373 2993905 192.124.254.179 (16 1493 1494) Followup-To: comp.os.linux.m68k User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.16nfs3 (i686)) Newsgroups: comp.os.linux.m68k,comp.os.linux.powerpc,comp.os.linux.alpha First of all, many thanks to all people who have answered my request! I wrote a small sh/sed script that parses the cpuinfo information on different architectures. The script handles iX86, alpha, m68k, ppc, mips, and ia64 architectures currently. (--> cpuinfo contents for sparc are still wanted!) I am including the script below. I'd like to ask another favour: Could you run the script on their machines and find out whether it prints something that you think describes your hardware architecture well, in terms of CPU, floating-point unit, and cache (cache information is only available on iX86 and ppc)? Can you suggest improvements for your architecture? The default for the script is to output the information in a way that is suitable as (part of) a file name (it'll be part of the name of the binary rpm for atlas when I'm done), therefore I tried to keep the output as short as possible without losing relevant information. See the usage info at the beginning of the script. Thanks a lot, Martin -- Martin Wilck Institute for Tropospheric Research, Permoserstr. 15, D-04318 Leipzig, Germany Tel. +49-341-2352151 / Fax +49-341-2352361 #! /bin/sh #----------------------------------------------------------------------- # architecture.sh: determine hardware properties from /proc/cpuinfo #----------------------------------------------------------------------- usage="\ $0 Determine detailed architecture model and generate a string suitable for a file name from it. Options: -r - output in file name format (default), -h - output in human-readable format, -? - print this usage information. With -r, the output has the form [architecture]-[cache size in kB]. (c) Martin Wilck 2000 Redistribution and modification granted under the terms of the GNU GPL. NO WARRANTY OF ANY KIND. " #----------------------------------------------------------------------- # Some sed "procedures" for better readability. #----------------------------------------------------------------------- # Remove characters that may irritate the shell. del_special="s/[^a-zA-Z0-9_.-]\{1,\}/-/g" # Get rid of stuff in parentheses (except pure numbers). del_parens='s/(\([0-9]*\))/-\1-/g;s/([^)]*)//g' # Get rid of words that are useless. del_useless='s/[pP]rocessor//;s/[cC][pP][uU]//' # Get rid of spurious "-". purge_minus='s/-\{2,\}/-/g;s/^-*//;s/-*$//' # Get the value of an cpuinfo entry get_value='s/^[^:]*:[ ]*//' # Get a number from a field. get_number='s/^[^0-9]*\([0-9]*\)[^0-9]*$/\1/' # Print hold space contents on a line. print_hold='x;s/\n/ /g;s/^ *//;s/ *$//;s/^$/unknown/;p;q' # If all else fails, print "unknown" at end of file. insert_unknown='$s/^.*$/unknown/p' #----------------------------------------------------------------------- # Check Options. #----------------------------------------------------------------------- mode=name if test $# -gt 0; then case $1 in -h) mode=human;; -r) mode=name;; -\?) echo "$usage" >&2; exit 0 ;; *) echo "$usage" >&2; exit 1 ;; esac fi #----------------------------------------------------------------------- # Do the work. #----------------------------------------------------------------------- mach=`uname -m` cpuinfo=/proc/cpuinfo cache=unknown test -f $cpuinfo || \ { echo "$0: cannot read $cpuinfo !" >&2; exit 1 } case "$mach" in i?86) human=`sed -n "$insert_unknown;/^model name/{$get_value;p;q;}" \ <$cpuinfo` cache=`sed -n "$insert_unknown;/^cache size/{$get_number;p;q;}" \ <$cpuinfo` ;; alpha) human=`sed -n '$'"{$print_hold;};\ /^cpu[^a-z:]*:/{$get_value;H;d;}; /^cpu model/{$get_value;H;d;}; /^cpu variation[^:]*: [0-9]/{$get_number;s/^\(.*\)$/(\1)/;H;$print_hold;}" \ < $cpuinfo` ;; m68k) human=`sed -n '$'"{$print_hold;};\ /^CPU/{$get_value;H;d;}; /^FPU/{$get_value;s/^\(.*\)$/- FPU \1 -/;H;$print_hold;}" \ < $cpuinfo` ;; ppc) human="PPC "`sed -n "$insert_unknown;/^cpu/{$get_value;p;q;}" \ <$cpuinfo` cache=`sed -n "$insert_unknown;\ /^L2 cache/{$get_value;$get_number;p;q;}" \ <$cpuinfo` ;; mips) human=`sed -n '$'"{$print_hold;};\ /^cpu[^a-z:]*:/{$get_value;H;d;}; /^cpu model/{$get_value;H;$print_hold;}" \ < $cpuinfo` ;; ia64) human=`sed -n '$'"{$print_hold;};\ /^family/{$get_value;H;d;}; /^model/{$get_value;H;d;}; /^revision/{$get_value;H;$print_hold;}" \ < $cpuinfo` ;; *) echo "$0: unknown machine type: \"$mach\" !" >&2 human=$mach ;; esac #----------------------------------------------------------------------- # Print result. #----------------------------------------------------------------------- if test $mode = human; then if test $cache = unknown; then echo "$human with unknown L2 cache size" else echo "$human with $cache kB L2 cache" fi else cpu=`echo $human | \ sed "$del_parens;$del_useless;$del_special;$purge_minus;"` echo "$cpu-$cache" fi exit 0