LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-12-2005, 11:27 AM   #1
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
march and MMX instruction set


slackware arch is i486. So the binaries don't have any code for mmx instruction set, correct?

when it says i686 optimized it's it means it's optimizing the i486 instruction set schedulilng for a i686, but still is not using the i686 instruction set, correct?
 
Old 03-12-2005, 11:38 AM   #2
MMYoung
Member
 
Registered: Apr 2004
Location: Arkansas
Distribution: Ubuntu 8.10
Posts: 365

Rep: Reputation: 30
All of the i486 package build scripts use the following CFLAGS:

-march=i486 -mcpu-i686 -O2

What that does, basically, is generate code tuned for the specified CPU, but it does not alter the the set of available instructions generated by -march, so you can still run the resulting binary on other CPUs. In this case the package is tuned for the i686 cpu but can still execute/install on an i486. Also setting the -mcpu=i686 does actually turn on things like mmx. If I understand it correctly.

Here's a decent little article about it, GCC Myths and Facts. You can also google around as there are, quite possibly, hundreds of sites with even more information.

HTH,
MMYoung
 
Old 03-12-2005, 11:48 AM   #3
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
Also setting the -mcpu=i686 does actually turn on things like mmx.

confused if the march is set to the i486 instruction set, which excludes the mmx instuction set then how then can mcpu just turn it on?

I thought mcpu just optimizes the scheduling for a specific arch but still does not use any new instruction outside of march. If it did then the code that included the MMX instruction set would fail to run on anything less than a i686.
 
Old 03-12-2005, 12:07 PM   #4
MMYoung
Member
 
Registered: Apr 2004
Location: Arkansas
Distribution: Ubuntu 8.10
Posts: 365

Rep: Reputation: 30
From the article linked above:
Quote:
-march implies -mcpu, so when you use -march, there's no need to use -mcpu.

-mcpu generates code tuned for the specified CPU, but it does not alter the ABI and the set of available instructions, so you can still run the resulting binary on other CPUs (it turns on flags like mmx/3dnow, etc.).

When you use -march, you generate code for the specified machine type, and the available instructions will be used, which means that you probably cannot run the binary on other machine types.
I could be confused, I get that way sometimes when articles seem to go round in circles. .

Later,
MMYoung
 
Old 03-12-2005, 12:17 PM   #5
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
-mcpu generates code tuned for the specified CPU, but it does not alter the ABI and the set of available instructions, so you can still run the resulting binary on other CPUs (it turns on flags like mmx/3dnow, etc.).

that sentence is contradicting itself?

1)does not alter the ABI and the set of available instructions
2)it turns on flags like mmx/3dnow, etc

if 1 is true then 2 is false. if 2 is true then 1 is false. true and false = false. therefore the statement is false. SIMPLE LOGIC.
 
Old 03-12-2005, 12:25 PM   #6
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
lol. you can't do both. not enable anything outside the i486 instruction set and then go ahead and enable the MMX instruction set, which is outside the i486 instruction set?
 
Old 03-12-2005, 12:40 PM   #7
MMYoung
Member
 
Registered: Apr 2004
Location: Arkansas
Distribution: Ubuntu 8.10
Posts: 365

Rep: Reputation: 30
Found something else that might help (or hurt ) with this. This from the GCC site 3.17.11 Intel 386 and AMD x86-64 Options:
Quote:
-mtune=cpu-type Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions. (now if I just knew what ABI stood for )

-march=cpu-type Generate instructions for the machine type cpu-type. The choices for cpu-type are the same as for -mtune. Moreover, specifying -march=cpu-type implies -mtune=cpu-type.
So, if I understand this right you can use -march to compile for the "general" architecture, so setting march=i686 would compile for anything from a Pentium (MMX/PRO?) to a Pentium 4 and even the Athlon/Athlon-XP. Then adding mtune=athlon-xp would ADD any optimizations for that specific CPU.

Or am I lost again?

Later,
MMYoung
 
Old 03-12-2005, 01:00 PM   #8
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
Sorry, I hope you didn't take my logic post as making fun of you. After I looked at it you might take it that way.

If you assume that march=i486 doesn't include the MMX instruction set then then everything makes sense. However, if you assume MMX does get included then everything falls apart again because MMX first started to appear on the pentium 2, it is not on a i486 chip.

So therefore I'm forced to conclude that march=i486 doesn't include the MMX instuction set in the final binary.

Unless some PH D carrying expert dude could explain it to me. Because when I go to the gcc and read the documentation it seems to me only a PH D carrying expert dude could understand what the hell they are documenting about.
 
Old 03-12-2005, 01:17 PM   #9
MMYoung
Member
 
Registered: Apr 2004
Location: Arkansas
Distribution: Ubuntu 8.10
Posts: 365

Rep: Reputation: 30
Quote:
Originally posted by chbin
Sorry, I hope you didn't take my logic post as making fun of you. After I looked at it you might take it that way.
Nope, never thought no such a thing.
Quote:
Originally posted by chbin
Unless some PH D carrying expert dude could explain it to me. Because when I go to the gcc and read the documentation it seems to me only a PH D carrying expert dude could understand what the hell they are documenting about.
Yeah, I was reading some of that stuff and it cleared everything right up!

Later,
MMYoung
 
Old 03-12-2005, 01:21 PM   #10
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
There is a complete info manual for gcc installed with slackware
To lookup for march, try

info gcc
--then press ' s ' key
--type ' march ', <enter>, <enter> (again)
-- scroll down with the bottom arrow key, position the cursor to:
* i386 and x86-64 Options::
then press <enter>
 
Old 03-12-2005, 01:25 PM   #11
MMYoung
Member
 
Registered: Apr 2004
Location: Arkansas
Distribution: Ubuntu 8.10
Posts: 365

Rep: Reputation: 30
BTAIM, here is my build script, with what I hope are the correct settings (and I think they are) for my Athlon-XP.
Code:
# /bin/bash
#
# Script for building Slackware packages from .tar.gz archives
#
# Set script variables
SRC="/work/src/path"
FILE="filename"
VER="x.xx.x"
ARCH="i686"
REV="xmmy"
STORE="/work/packages/"
BUILD="/work/builds/"
DESC="/work/builds/install/"
DOCS="WHAT EVER DOCS ARE IN ARCHIVE ROOT"
DOCD="/work/builds/usr/doc/"
HOST=""i486-slackware-linux""
FLAGS=""-march=i686 -mtune=athlon-xp -O2 -pipe -fomit-frame-pointer""
XFLAGS=""-march=i686 -mtune=athlon-xp -O2 -pipe -fomit-frame-pointer""
CFG="--prefix=/usr --sysconfdir=/etc --localstatedir=/var"

# Now let's head on over to the source directory and untarr the archive
cd ${SRC}
tar -xvzf ${FILE}-${VER}.tar.gz
cd ${FILE}-${VER}

# OK, that's done now let's start the compile
CHOST=${HOST} \
CFLAGS=${FLAGS} \
CXXFLAGS=${XFLAGS} \
./configure ${CFG}

# Now run make
make

# I need to make sure that the perms and ownership of the files are correct
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;

# Now let's actually build the program and install it to /work/builds
make install DESTDIR=${BUILD}

# Now I need to copy over the "doc" files
mkdir -p ${DOCD}/${FILE}-${VER}
cp ${DOCS} ${DOCD}/${FILE}-${VER}

# Now that's done so we need to head on over to the /work/builds directory
cd ${BUILD}

# Now I need to get the slack-desc file for this package
cp ${SRC}/slack-desc ${DESC}

# Now we're ready to make the package
makepkg ${FILE}-${VER}-${ARCH}-${REV}.tgz

# Now that the package is ready I wan to move it to my package repository
mv *.tgz ${STORE}

# And finally the clean up
rm -rf *
mkdir install
cd ${SRC}
rm -rf ${FILE}-${VER}

# end
I've compiled a few programs using it and the seem to work just fine!

Later,
MMYoung
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc march agdepus Programming 8 05-26-2004 09:11 AM
mcpu vs march Spaz17 Linux - Newbie 6 12-31-2003 12:28 AM
Why doesn't -O3 -march=pentium-mmx -ffast-math speedup my programs ? NOT_a_n00b Linux - Software 1 12-14-2003 08:50 AM
march 8th 2003 SeT General 11 03-10-2003 10:27 PM
Does -march=athlon help? wapcaplet Linux - Software 1 02-26-2003 02:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration