Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Testing Instruction Set

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
16 posts • Page 1 of 1
Author
Message
taviso
Retired Dev
Retired Dev
User avatar
Posts: 261
Joined: Tue Apr 15, 2003 3:18 pm
Location: United Kingdom
Contact:
Contact taviso
Website

Testing Instruction Set

  • Quote

Post by taviso » Tue Jul 29, 2003 8:36 pm

Earlier today we needed a way to identify which instruction set was used to compile a binary, we were getting reports of "Illegal Instruction" errors on some processors...which was weird, i wrote a script to identify and report which instruction sets were used. It worked great! (the rogue application turned out to be openssl, which has a non-standard build process)

Another alpha dev improved it so that it would update the screen as it searched, and printed which processors it worked on.

I figured it was so cool, i ported it to x86 so you guys can play with it :)

example output:

Code: Select all

taviso@insomniac:~$ ./analyse-x86 /bin/ls   
mmx:     0  sse:     8  sse2:     0
/bin/ls will run on Pentium III and newer.
taviso@insomniac:~$ ./analyse-x6 /usr/bin/mplayer 
mmx:  79809  sse:  2887  sse2:   681
/usr/bin/mplayer will run on Pentium IV and newer.
  • The mmx/sse/sse2 numbers are the number of instructions found from that instruction set.
  • I dont have an AMD machine, so 3dnow wont be identified.
  • The processor revision are correct according to intel documentation.
  • If anyone spots any mistakes, feel free to flame me :)
You can download the script here: http://dev.gentoo.org/~taviso/files/analyse-x86
Last edited by taviso on Fri Nov 28, 2003 11:32 pm, edited 2 times in total.
--------------------------------------
Gentoo on Alpha, is your penguin 64bit?
--------------------------------------------------------
Top
pYrania
Retired Dev
Retired Dev
User avatar
Posts: 650
Joined: Sun Oct 27, 2002 8:19 pm
Location: Cologne - Germany
Contact:
Contact pYrania
Website

  • Quote

Post by pYrania » Tue Jul 29, 2003 9:14 pm

You should add that it determines the Pentium version (Pentium MMX (P55C), Pentium III, Pentium IV, Any) the binary can be used with, to the description.
This might not be obvious to some people ;)

Nice hack anyway.
Markus Nigbur
Top
taviso
Retired Dev
Retired Dev
User avatar
Posts: 261
Joined: Tue Apr 15, 2003 3:18 pm
Location: United Kingdom
Contact:
Contact taviso
Website

  • Quote

Post by taviso » Sat Aug 09, 2003 12:35 am

Well, i was surprised to find a lot of people were interested in this script, i had some emails asking about it and some feature requests. So here is a new version, with the following new features (as requested):
  • AMD support, identify 3dnow and ext3dnow instruction sets.
  • Identify cpuid instruction, and prints out informational message.
  • Identify i486/pentium/pentiumpro instruction sets.
  • Knows about the features of more processors.
http://dev.gentoo.org/~taviso/files/analyse-x86

Some example runs:

Code: Select all

$ ./analyse-x86 /usr/bin/mplayer
Checking vendor_id string...GenuineIntel
Disassembling /usr/bin/mplayer, please wait...
i486:   91 i586:    9 ppro:  391 mmx: 8869 sse: 1084 sse2:  406

This binary was found to contain the cpuid instruction.
It may be able to conditionally execute instructions if
they are supported on the host (i586+).

/usr/bin/mplayer will run on Pentium IV (pentium4) or higher processor.

$ ./analyse-x86 /bin/ls
Checking vendor_id string...GenuineIntel
Disassembling /bin/ls, please wait...
i486:    0 i586:    0 ppro:   15 mmx:    0 sse:    8 sse2:    0
/bin/ls will run on Pentium III (pentium3) or higher processor.

$ ./analyse-x86 /bin/true 
Checking vendor_id string...GenuineIntel
Disassembling /bin/true, please wait...
i486:    0 i586:    0 ppro:    0 mmx:    0 sse:    0 sse2:    0
/bin/true will run on 80386 (i386) or higher processor.
If your an AMD user, please test this script works correctly. If your an expert on processor features, please double check my logic and check i'm reporting correct minimum processors and let me know :)

Any other suggestions/feedback/flames/patches welcome :)
--------------------------------------
Gentoo on Alpha, is your penguin 64bit?
--------------------------------------------------------
Top
taviso
Retired Dev
Retired Dev
User avatar
Posts: 261
Joined: Tue Apr 15, 2003 3:18 pm
Location: United Kingdom
Contact:
Contact taviso
Website

  • Quote

Post by taviso » Fri Nov 28, 2003 11:38 pm

Experimenting with icc earlier today, its interesting how many more processor specific instructions icc crams in there.


CC="gcc"
CFLAGS="-O2 -march=pentium4 -mcpu=pentium4 -fomit-frame-pointer -pipe"

Code: Select all

$ analyse-x86 ./fvwm
Checking vendor_id string...GenuineIntel
Disassembling ./fvwm, please wait...
i486:    0 i586:    0 ppro:   54 mmx:    0 sse:  149 sse2:   93
./fvwm will run on Pentium IV (pentium4) or higher processor.
CC="icc"
CFLAGS="-O2 -tpp7 -xW"

Code: Select all

$ analyse-x86 ./fvwm
Checking vendor_id string...GenuineIntel
Disassembling /usr/bin/fvwm, please wait...
i486:    1 i586:    0 ppro:    1 mmx:  996 sse:  546 sse2: 3849
./fvwm will run on Pentium IV (pentium4) or higher processor.
cool eh? :)

the icc compiled binary does seem faster.
--------------------------------------
Gentoo on Alpha, is your penguin 64bit?
--------------------------------------------------------
Top
rhill
Retired Dev
Retired Dev
User avatar
Posts: 1629
Joined: Fri Oct 22, 2004 9:58 am
Location: sk.ca

  • Quote

Post by rhill » Wed Mar 16, 2005 9:32 am

this is hella cool and deserving of a bump. still works perfectly after almost two years.
by design, by neglect
for a fact or just for effect
Top
Cintra
Advocate
Advocate
User avatar
Posts: 2111
Joined: Sat Apr 03, 2004 3:49 pm
Location: Norway

  • Quote

Post by Cintra » Wed Mar 16, 2005 3:27 pm

dirtyepic wrote:this is hella cool and deserving of a bump. still works perfectly after almost two years.
Right, and its quite some cpu test! ;-)
Mvh
"I am not bound to please thee with my answers" W.S.
Top
johngalt
Guru
Guru
User avatar
Posts: 320
Joined: Thu Sep 09, 2004 4:34 pm
Location: 3rd Rock
Contact:
Contact johngalt
Website

  • Quote

Post by johngalt » Sat May 21, 2005 5:48 am

As there have been a few comparisons between gcc and icc, the most recent that i saw being Scott's comparison, I wonder if icc really does compile binaries with more processor-specific instructions across the board, and also if it is known to break things now like it has been purported to in the past....
desultory wrote:If you want to retain credibility as a functional adult; when you are told that you are acting boorishly, the correct response is to consider that possibility and act accordingly to correct that behavior.
Amen.
Top
rufnut
Apprentice
Apprentice
Posts: 252
Joined: Mon May 16, 2005 7:26 am

  • Quote

Post by rufnut » Thu Jan 15, 2009 8:35 am

I thought this great old thread could do with an update, so I added some of the newer CPU features found in modern CPU's

The new provided script seems to work well for Intel Chips and is interesting, but it needs some enhancement on the AMD instruction set regarding CPU ID.

Hope you find it fun to use 8)

Updated analyse-x86;

Code: Select all

#!/bin/sh
#
# Tavis Ormandy <taviso@gentoo.org> 2003
# Improvments by Will Woods <wwoods@gentoo.org>
# More Improvements by Brett Coady <bc1968au@yahoo.com.au>
# Identify instruction set used in binary.
#
##################

# ksh massively out performs bash.
if test -x /bin/ksh -a "$BASH_VERSION"; then
	exec /bin/ksh "$0" "$@"
fi

# initialize everything to zero.
eval {i486,i586,ppro,mmx,sse,sse2,sse3,ssse3,sse41,sse42,sse4a,amd,amd2,cpuid}=0

# unfortunately there are mnemonic collissions between vendor sets
# so check vendor_id string, and enable relevant sets.
printf "Checking vendor_id string..."
if ! test "${1%=*}" == "--vendor"; then
	case "`grep -Em1 '^vendor_id.*: ' /proc/cpuinfo | cut -d\" \" -f2`" in
		*GenuineIntel*) vendor=intel; printf "GenuineIntel\n";;
		*AuthenticAMD*) vendor=amd; printf "AuthenticAMD\n";;
		*CyrixInstead*) vendor=cyrix; printf "CyrixInstead\n";;
		*GenuineTMx86*) vendor=transmeta; printf "GenuineTMx86\n";;
		*) vendor=other; printf "other\n";;
	esac
else
	# allow vendor to be overridden
	vendor=${1#*=}; shift
	printf "%s\n" $vendor
fi

# quick sanity tests.
if ! test "$1"; then
	printf "usage: %s [--vendor=intel|amd|cyrix|transmeta] /path/to/binary\n" $0 1>&2
	exit 1
elif ! test -e "$1"; then 
	printf "error: %s does not exist.\n" "$1" 1>&2
	exit 1
elif ! test -r "$1"; then
	printf "error: cant read %s.\n" "$1" 1>&2
	exit 1
fi

printf "Disassembling %s, please wait...\n" $1

# initialize screen output
case "$vendor" in
	*intel*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u sse3: %4u ssse3: %4u sse4.1: %4u sse4.2: %4u\r" \
		$i486 $i586 $ppro $mmx $sse $sse2 $sse3 $ssse3 $sse41 $sse42;;
	*amd*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u 3dnow: %4u sse2: %4u sse3: %4u sse4a: %4u\r" \
		$i486 $i586 $ppro $mmx $sse $(($amd+$amd2))  $sse2 $sse3 $sse4a;;
	*cyrix*) printf "i486: %4u i586: %4u mmx: %4u\r" \
		$i486 $i586 $mmx;;
	*transmeta*) printf "i486: %4u i586: %4u mmx: %4u\r" \
		$i486 $i586 $mmx;;
	*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
		$i486 $i586 $ppro $mmx $sse $sse2;;
esac

# do the disassembling.

# %cr{0,2,3,4} version
# objdump -d $1 | cut -f3 |
objdump -d $1 | cut -f3 | cut -d" " -f1 | (
# %cr{0,2,3,4} version
# 	while read instruction operands; do
	while read instruction; do
 		case "$instruction" in
			"cmpxchg"|"xadd"|"bswap"|"invd"|"wbinvd"|"invlpg") let ++i486; print=1;;
			"rdmsr"|"wrmsr"|"rdtsc"|"cmpxch8B"|"rsm") let ++i586; print=1;;
			"cmovcc"|"fcmovcc"|"fcomi"|"fcomip"|"fucomi"|"fucomip"|"rdpmc"|"ud2") let ++ppro; print=1;;
			"emms"|"movd"|"movq"|"packsswb"|"packssdw"|"packuswb"|"paddb"|"paddw"|"paddd"|"paddsb"|"paddsw"|"paddusb"| \
"paddusw"|"pand"|"pandn"|"pcmpeqb"|"pcmpeqw"|"pcmpeqd"|"pcmpgtb"|"pcmpgtw"|"pcmpgtd"|"pmaddwd"|"pmulhw"|"pmullw"|"por"| \
"psllw"|"pslld"|"psllq"|"psraw"|"psrad"|"psrlw"|"psrld"|"psrlq"|"psubb"|"psubw"|"psubd"|"psubsb"|"psubsw"|"psubusb"|"psubusw"| \
"punpckhbw"|"punpckhwd"|"punpckhdq"|"punpcklbw"|"punpcklwd"|"punpckldq"|"pxor") let ++mmx; print=1;;
			"addps"|"addss"|"andnps"|"andps"|"cmpps"|"cmpss"|"comiss"|"cvtpi2ps"|"cvtps2pi"|"cvtsi2ss"|"cvtss2si"|"cvttps2pi"|"cvttss2si"| \
"divps"|"divss"|"fxrstor"|"fxsave"|"ldmxcsr"|"maxps"|"maxss"|"minps"|"minss"|"movaps"|"movhlps"|"movhps"|"movlhps"|"movlps"| \
"movmskps"|"movss"|"movups"|"mulps"|"mulss"|"orps"|"pavgb"|"pavgw"|"psadbw"|"rcpps"|"rcpss"|"rsqrtps"|"rsqrtss"|"shufps"| \
"sqrtps"|"sqrtss"|"stmxcsr"|"subps"|"subss"|"ucomiss"|"unpckhps"|"unpcklps"|"xorps"|"pextrw"|"pinsrw"|"pmaxsw"|"pmaxub"| \
"pminsw"|"pminub"|"pmovmskb"|"pmulhuw"|"pshufw"|"maskmovq"|"movntps"|"movntq"|"prefetch"|"sfence") let ++sse; print=1;;
			"addpd"|"addsd"|"andnpd"|"andpd"|"clflush"|"cmppd"|"cmpsd"|"comisd"|"cvtdq2pd"|"cvtdq2ps"|"cvtpd2pi"|"cvtpd2pq"|"cvtpd2ps"| \
"cvtpi2pd"|"cvtps2dq"|"cvtps2pd"|"cvtsd2si"|"cvtsd2ss"|"cvtsi2sd"|"cvtss2sd"|"cvttpd2pi"|"cvttpd2dq"|"cvttps2dq"|"cvttsd2si"| \
"divpd"|"divsd"|"lfence"|"maskmovdqu"|"maxpd"|"maxsd"|"mfence"|"minpd"|"minsd"|"movapd"|"movd"|"movdq2q"|"movdqa"|"movdqu"| \
"movhpd"|"movlpd"|"movmskpd"|"movntdq"|"movnti"|"movntpd"|"movq"|"movq2dq"|"movsd"|"movupd"|"mulpd"|"mulsd"|"orpd"| \
"packsswb"|"packssdw"|"packuswb"|"paddb"|"paddw"|"paddd"|"paddq"|"paddq"|"paddsb"|"paddsw"|"paddusb"|"paddusw"|"pand"| \
"pandn"|"pause"|"pavgb"|"pavgw"|"pcmpeqb"|"pcmpeqw"|"pcmpeqd"|"pcmpgtb"|"pcmpgtw"|"pcmpgtd"|"pextrw"|"pinsrw"|"pmaddwd"| \
"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhw"|"pmulhuw"|"pmullw"|"pmuludq"|"pmuludq"|"por"|"psadbw"|"pshufd"|" \
pshufhw"|"pshuflw"|"pslldq"|"psllw"|"pslld"|"psllq"|"psraw"|"psrad"|"psrldq"|"psrlw"|"psrld"|"psrlq"|"psubb"|"psubw"|"psubd"|"psubq"| \
"psubq"|"psubsb"|"psubsw"|"psubusb"|"psubusw"|"psubsb"|"punpckhbw"|"punpckhwd"|"punpckhdq"|"punpckhqdq"|"punpcklbw"| \
"punpcklwd"|"punpckldq"|"punpcklqdq"|"pxor"|"shufpd"|"sqrtpd"|"sqrtsd"|"subpd"|"subsd"|"ucomisd"|"unpckhpd"|"unpcklpd"|"xorpd") let ++sse2; print=1;;
			"addsubpd"|"addsubps"|"haddpd"|"haddps"|"hsubpd"|"hsubps"|"lddqu"|"movddup"|"movshdup"|"movsldup"|"fisttp"|"monitor"|"mwait") let ++sse3; print=1;;
			"psignb"|"psignw"|"psignd"|"pabsb"|"pabsw"|"pabsd"|"palignr"|"pshufb"|"pmulhrsw"|"pmaddubsw"|"phsubw"|"phsubd"|"phsubsw"| \
"phaddw"|"phaddd"|"phaddsw") let ++ssse3; print=1;;
			"mpsadbw"|"phminposuw"|"pmuldq"|"pmulld"|"dpps"|"dppd"|"blendps"|"blendpd"|"blendvps"|"blendvpd"|"pblendvb"|"pblendw"|"pminsb"| \
"pmaxsb"|"pminuw"|"pmaxuw"|"pminud"|"pmaxud"|"pminsd"|"pmaxsd"|"roundps"|"roundss"|"roundpd"|"roundsd"|"insertps"|"pinsrb"| \
"pinsrd"|"pinsrq"|"extractps"|"pextrb"|"pextrw"|"pextrd"|"pextrq"|"pmovsxbw"|"pmovzxbw"|"pmovsxbd"|"pmovzxbd"|"pmovsxbq"| \
"pmovzxbq"|"pmovsxwd"|"pmovzxwd"|"pmovsxwq"|"pmovzxwq"|"pmovsxdq"|"pmovzxdq"|"ptest"|"pcmpeqq"|"packusdw"|"movntdqa") let ++sse4.1; print=1;;
			"crc32"|"pcmpestri"|"pcmpestrm"|"pcmpistri"|"pcmpistrm"|"pcmpgtq"|"popcnt")
let ++sse4.2; print=1;;
			"lzcnt"|"popcnt"|"extrq"|"insertq"|"movntsd"|"movntss")
let ++sse4a; print=1;;
			"pavgusb"|"pfadd"|"pfsub"|"pfsubr"|"pfacc"|"pfcmpge"|"pfcmpgt"|"pfcmpeq"|"pfmin"|"pfmax"|"pi2fw"|"pi2fd"| \
"pf2iw"|"pf2id"|"pfrcp"|"pfrsqrt"|"pfmul"|"pfrcpit1"|"pfrsqit1"|"pfrcpit2"|"pmulhrw"|"pswapw"|"femms"|"prefetch") let ++amd; print=1;;
			"pf2iw"|"pfnacc"|"pfpnacc"|"pi2fw"|"pswapd"|"maskmovq"|"movntq"|"pavgb"|"pavgw"|"pextrw"|"pinsrw"|"pmaxsw"|"pmaxub"| \
"pminsw"|"pminub"|"pmovmskb"|"pmulhuw"|"prefetchnta"|"prefetcht0"|"prefetcht1"|"prefetcht2"|"psadbw"|"pshufw"|"sfence") let ++amd2; print=1;;
			"cpuid") let ++cpuid ++i586; print=1;;
# %cr{0,2,3,4} version
#			"mov") [[ "$operands" == *%cr[0234]* ]] && let ++i586; print=1;;
		esac
	# check if screen needs updating.
	if test "$print"; then
		case "$vendor" in
			*intel*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u sse3: %4u ssse3: %4u sse4.1: %4u sse4.2: %4u\r" \
				$i486 $i586 $ppro $mmx $sse $sse2 $sse3 $ssse3 $sse41 $sse42;;
			*amd*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u 3dnow: %4u sse2: %4u sse3: %4u sse4a: %4u\r" \
				$i486 $i586 $ppro $mmx $sse $(($amd+$amd2)) $sse2 $sse3 $sse4a;;
			*cyrix*) printf "i486: %4u i586: %4u mmx: %4u\r" \
				$i486 $i586 $mmx;;
			*transmeta*) printf "i486: %4u i586: %4u mmx: %4u\r" \
				$i486 $i586 $mmx;;
			*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
				$i486 $i586 $ppro $mmx $sse $sse2;;
		esac	
		unset print
	fi
	done 

# print a newline
echo

# cpuid instruction could mean the application checks to see
# if an instruction is supported before executing it. This might 
# mean it will work on anything over a pentium.
if test $cpuid -gt 0; then
	printf "\nThis binary was found to contain the cpuid instruction.\n"
	printf "It may be able to conditionally execute instructions if\n"
	printf "they are supported on the host (i586+).\n\n"
fi

# print minimum required processor, if there are collissions
# use the vendor to decide what to print.
if test $sse42 -gt 0; then 
	subarch="Pentium Nehalem (nehalem)"
elif test $sse41 -gt 0; then 
	subarch="Pentium x8000+ (penryn)"
elif test $ssse3 -gt 0; then 
	subarch="Pentium Core (core)"
elif test $sse3 -gt 0; then 
	subarch="Pentium IV (prescott)"
elif test $sse2 -gt 0; then 
	subarch="Pentium IV (pentium4)"
elif test $sse -gt 0; then 
	if test "$vendor" == "intel"; then
		subarch="Pentium III (pentium3)"
	elif test "$vendor" == "amd"; then
		subarch="AMD Athlon 4 (athlon-4)"
	else
		subarch="Pentium III (pentium3)"
	fi
elif test "$vendor" == "amd" -a $amd2 -gt 0; then
	subarch="AMD Athlon (athlon)"
elif test "$vendor" == "amd" -a $amd -gt 0; then
	subarch="AMD K6 III (k6-3)"
elif test $mmx -gt 0; then 
	if test "$vendor" == "intel"; then
		if test $ppro -gt 0; then
			subarch="Pentium II (pentium2)"
		else
			subarch="Intel Pentium MMX [P55C] (pentium-mmx)"
		fi
	elif test "$vendor" == "amd"; then
		subarch="AMD K6 (k6)"
	elif test "$vendor" == "cyrix"; then
		subarch="Cyrix 6x86MX / MII (pentium-mmx)"
	else
		subarch="Intel Pentium MMX [P55C] (pentium-mmx)"
	fi
elif test $ppro -gt 0; then
	subarch="Pentium Pro (i686 or pentiumpro)"
elif test $i586 -gt 0; then
	subarch="Pentium or compatible (i586) (i586 or pentium)"
elif test $i486 -gt 0; then
	subarch="80486 or comaptible (i486)"
else
	subarch="80386 or compatible (i386)"
fi

# print message and exit.
printf "%s will run on %s or higher processor.\n" "$1" "$subarch"; )
Dont forget to chmod 755 the above script


Now, lets teach an old Dog some new tricks

Code: Select all

localhost / # ./analyse-x86 /usr/bin/mplayer
Checking vendor_id string...GenuineIntel
Disassembling /usr/bin/mplayer, please wait...
i486:  135 i586:   13 ppro:    3 mmx: 163948 sse: 25106 sse2: 14512 sse3:   24 ssse3:  231 sse4.1:    0 sse4.2:    0

This binary was found to contain the cpuid instruction.
It may be able to conditionally execute instructions if
they are supported on the host (i586+).

/usr/bin/mplayer will run on Pentium Core (core) or higher processor.
As you can see it does check to see if your new CPU is actually using the codes it should be.

:wink:

line breaks added by NeddySeagoon
Top
rufnut
Apprentice
Apprentice
Posts: 252
Joined: Mon May 16, 2005 7:26 am

  • Quote

Post by rufnut » Sat Jan 24, 2009 12:45 pm

Nerdbert has kindly hosted the file for us :-)

http://www.nerdbert.com/gentoo/analyse-x86
Top
geki
Advocate
Advocate
User avatar
Posts: 2387
Joined: Thu May 13, 2004 8:59 pm
Location: Germania
Contact:
Contact geki
Website

  • Quote

Post by geki » Thu Sep 22, 2011 6:21 pm

hi there!
out of boredom I converted the script to plain C. this was a great exercise, not the script itself
but rather the switch block generator to parse strings listed in a data file. it has still some edges
like how to handle what to print properly, i.e. sse/2 vs 3dnow instructions. ;)

I hope someone has a use for these and may help to improve.

see:
http://code.google.com/p/gekis-playgrou ... tion_set.c
http://code.google.com/p/gekis-playgrou ... .generated
http://code.google.com/p/gekis-playgrou ... n_set.data
http://code.google.com/p/gekis-playgrou ... on_set.cxx
die@ana:~ $ time ./analyze-x86 /usr/bin/mplayer2
your vendor: GenuineIntel
opened file to analyze: /usr/bin/mplayer2
i486: 13 i586: 8 mmx:3537 3dnow1: 1 3dnow2: 150 sse: 132 sse2:3621 ssse3: 2 cpuid: 8 unused:277151
This binary was found to contain the cpuid instruction.
It may be able to conditionally execute instructions if
they are supported on Pentium or compatible.

Interesting, there are unknown instruction sets used!

The binary will run on Pentium Core (core) or higher processor.

real 0m2.729s
user 0m1.200s
sys 0m1.060s
die@ana:~ $ time . /tmp/analyse-x86 /usr/bin/mplayer2
Checking vendor_id string...GenuineIntel
Disassembling /usr/bin/mplayer2, please wait...
i486: 13 i586: 8 ppro: 0 mmx: 3537 sse: 132 sse2: 20 sse3: 0 ssse3: 2 sse4.1: 0 sse4.2: 0

This binary was found to contain the cpuid instruction.
It may be able to conditionally execute instructions if
they are supported on the host (i586+).

/usr/bin/mplayer2 will run on Pentium Core (core) or higher processor.

real 2m1.120s
user 2m1.316s
sys 0m0.296s
edit #1
with the latest changes parsing mplayer2 took .6 seconds.
hear hear
Top
_______0
Guru
Guru
Posts: 521
Joined: Mon Oct 15, 2012 6:05 pm

  • Quote

Post by _______0 » Tue Jan 01, 2013 4:19 pm

shouldn't this be bulit-in in gcc and be part of some switch to log this stuff??

By the way I just realized how I am missing some instructions despite my cpu supporting them:

i486, ssse3, sse4.1, sse4.2

How to turn these on in make.conf??
Top
_______0
Guru
Guru
Posts: 521
Joined: Mon Oct 15, 2012 6:05 pm

  • Quote

Post by _______0 » Tue Jan 01, 2013 4:44 pm

is this normal for firefox ??

Code: Select all

i486:    1 i586:    0 ppro:    0 mmx:  257 sse:   65 3dnow:    0 sse2:  107 sse3:    0 sse4a:   
Top
geki
Advocate
Advocate
User avatar
Posts: 2387
Joined: Thu May 13, 2004 8:59 pm
Location: Germania
Contact:
Contact geki
Website

  • Quote

Post by geki » Tue Jan 01, 2013 5:03 pm

_______0 wrote:By the way I just realized how I am missing some instructions despite my cpu supporting them:

i486, ssse3, sse4.1, sse4.2

How to turn these on in make.conf??
simply by CFLAGS="-march=native"

Code: Select all

$ gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/cc1 -E -quiet -v - -march=corei7-avx -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mavx -msse4.2 -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=corei7-avx
this is for a core i5
hear hear
Top
_______0
Guru
Guru
Posts: 521
Joined: Mon Oct 15, 2012 6:05 pm

  • Quote

Post by _______0 » Tue Jan 01, 2013 10:55 pm

so why rufnut's mplayer gets more instructions than me and taviso?

I:

Code: Select all

i486:  155 i586:    8 ppro:    3 mmx: 4197 sse:  136 3dnow:   48 sse2:   20 sse3:    0 sse4a:    0
taviso:

Code: Select all

./analyse-x86 /usr/bin/mplayer

i486:   91 i586:    9 ppro:  391 mmx: 8869 sse: 1084 sse2:  406 
geki:

Code: Select all

die@ana:~ $ time . /tmp/analyse-x86 /usr/bin/mplayer2

i486: 13 i586: 8 ppro: 0 mmx: 3537 sse: 132 sse2: 20 sse3: 0 ssse3: 2 sse4.1: 0 sse4.2: 0 
rufnut:

Code: Select all

 ./analyse-x86 /usr/bin/mplayer 

i486:  135 i586:   13 ppro:    3 mmx: 163948 sse: 25106 sse2: 14512 sse3:   24 ssse3:  231 sse4.1:    0 sse4.2:    0 

By the way I am getting this error with the updated script:

Code: Select all

analis-x86: line 80: let: ++sse4.1: syntax error: invalid arithmetic operator (error token is ".1")
Lastly, why not make the script multi-threaded?? That way could get the job done much much faster.
Top
geki
Advocate
Advocate
User avatar
Posts: 2387
Joined: Thu May 13, 2004 8:59 pm
Location: Germania
Contact:
Contact geki
Website

  • Quote

Post by geki » Wed Jan 02, 2013 8:52 am

you may use my c program.

Code: Select all

$ /usr/local/bin/analyze-instruction-set /usr/bin/mplayer2
your vendor: GenuineIntel
opened file to analyze: /usr/bin/mplayer2

i486:   1 i586:   8 mmx:1299 3dnow1:   1 sse2:1295 cpuid:   8 unused:98691
i486:  46 i586:   8 mmx:3896 3dnow1:   1 3dnow2: 109 sse: 107 sse2:3984 ssse3:   2 cpuid:   8 unused:195918
i486:  59 i586:   8 mmx:4374 3dnow1:   1 3dnow2: 151 sse: 133 sse2:4457 ssse3:   2 cpuid:   8 unused:268170


This binary was found to contain the cpuid instruction.
It may be able to conditionally execute instructions if
they are supported on Pentium or compatible.

Interesting, there are unknown instruction sets used!

The binary will run on Pentium Core (core) or higher processor.
hear hear
Top
rufnut
Apprentice
Apprentice
Posts: 252
Joined: Mon May 16, 2005 7:26 am

  • Quote

Post by rufnut » Fri Jan 18, 2013 2:07 pm

_______0 wrote:so why rufnut's mplayer gets more instructions than me and taviso?
I think you will find I optimized that compile and then used ICC. (cheating :oops: )

Code: Select all

/usr/local/bin/analyze-instruction-set /usr/bin/mplayer
your vendor: AuthenticAMD
opened file to analyze: /usr/bin/mplayer

i586:  10 mmx: 757 3dnow2: 222 sse2: 757 cpuid:  10 unused:99011 
i486:  34 i586:  10 mmx:1861 3dnow2: 595 sse: 101 sse2:1917 cpuid:  10 unused:197464 
i486:  37 i586:  10 ppro:   3 mmx:10082 3dnow2:2020 sse:1397 sse2:11385 ssse3:   2 sse41:  24 cpuid:  10 unused:287766 
i486: 110 i586:  10 ppro:   3 mmx:12036 3dnow2:2438 sse:1397 sse2:13335 ssse3:   2 sse41:  26 cpuid:  10 unused:385319 
i486: 208 i586:  10 ppro:   3 mmx:12872 3dnow2:2761 sse:1783 sse2:14170 ssse3:   2 sse41:  30 cpuid:  10 unused:483802 
i486: 223 i586:  10 ppro:   3 mmx:13345 3dnow2:2836 sse:1784 sse2:14643 ssse3:   2 sse41:  30 cpuid:  10 unused:522911 


This binary was found to contain the cpuid instruction.
It may be able to conditionally execute instructions if
they are supported on Pentium or compatible.

Interesting, there are unknown instruction sets used!

The binary will run on Pentium x8000+ (penryn) or higher processor.

above is my Bulldozer CPU now .........maybe all the unused instructions are looking at really low level old stuff like x86,286and 386 instructions? (we should be able to add every instruction and arrive with nothing unused.)
If we don't maybe the script/app is looking at arrays as if they were instructions?


Thanks for making this quicker and better Geki :)
Top
Post Reply

16 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. and of Förderverein Gentoo e.V.
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license.
The Gentoo Name and Logo Usage Guidelines apply.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy