Re: [MP3 ENCODER] MMX question
> Oh, oh no! > Do you want to start a contest of writing the dirties possible program? > > main(_){float x,sin();for(_=0;_<_*_>>8;_+=_) ... you forget the reverse access to arrays :-) int a[5];3[a]=2; -- Gabriel Bouvigne - France [EMAIL PROTECTED] mobile phone: [EMAIL PROTECTED] icq: 12138873 MP3' Tech: www.mp3-tech.org -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
:: > Mark, I got that already, but I have no idea how to check :: > for the presence of a MMX CPU. If someone knows how to do :: > that, fine! Maybe there is some special x86 command that :: > allows to decide whether it is a MMX CPU or not. :: > As a quick fix we could implement that command line switch :: > for LAME. :: :: Can't you just execute an MMX instruction and catch an exception if it :: crashes? i don't know much about C so i don't know how error handling is :: done. :: Oh, oh no! Do you want to start a contest of writing the dirties possible program? main(_){float x,sin();for(_=0;_<_*_>>8;_+=_) ... -- Mit freundlichen Grüßen Frank Klemm eMail | [EMAIL PROTECTED] home: [EMAIL PROTECTED] phone | +49 (3641) 64-2721home: +49 (3641) 390545 sMail | R.-Breitscheid-Str. 43, 07747 Jena, Germany -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
Mark Powell schrieb am Don, 28 Sep 2000: > Intel provide some code to do this at: > > ftp://download.intel.nl/support/processors/procid/cpuinfo.zip > > There's then the additional detection of Cyrix, AMD etc. which may cause > complications. AMD have a similar 32 bit features value which also uses > bit 23 to indicate MMX support. > The AMD specific stuff and all the Intel supported stuff is better > explained at: > > http://www.amd.com/products/cpg/athlon/techdocs/pdf/20734.pdf > Gabriel Bouvigne schrieb am Don, 28 Sep 2000: > This is usually done via the cpuid instruction. I just checked the nasm > manual, and this instruction is supported by nasm. Thanks Mark and Gaby, I will take a look at it. Ciao Robert -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
> "G" == Gabriel Bouvigne <[EMAIL PROTECTED]> writes: G> This is usually done via the cpuid instruction. I just checked G> the nasm manual, and this instruction is supported by nasm. and GOGO uses this to find out the CPU type. --- Takehiro TOMINAGA // may the source be with you! -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
> Mark, I got that already, but I have no idea how to check > for the presence of a MMX CPU. If someone knows how to do > that, fine! Maybe there is some special x86 command that > allows to decide whether it is a MMX CPU or not. > As a quick fix we could implement that command line switch > for LAME. Can't you just execute an MMX instruction and catch an exception if it crashes? i don't know much about C so i don't know how error handling is done. dave _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
On Thu, 28 Sep 2000, Robert Hegemann wrote: > Mark Powell schrieb am Don, 28 Sep 2000: > > > Hmm, you may dig in the Gogo sources. If I remember right > > > they allowed to turn on optimizations with something like > > > --use-mmx. This could be a way to do it in LAME too. > > > > Surely Gabriel was referring to the MMX code always being present in the > > binary. On an non-MMX CPU it would fall back to using the old non-MMX > > code. Thus never executing an illegal instruction. Isn't this how > > commercial applications handle it? Of course if this is a lot of work, for > > little gain, then forgive me :) > > Cheers. > > Mark, I got that already, but I have no idea how to check > for the presence of a MMX CPU. If someone knows how to do > that, fine! Maybe there is some special x86 command that > allows to decide whether it is a MMX CPU or not. Looking at the startup code of FreeBSD it seems quite complex to identify CPU accurately. Of course we just require MMX. Linux will of course have similar sort of code. Unfortunately FreeBSD doesn't make this info available anywhere for configure to find. Using configure doesn't address this issue properly though. As you point out some sort of x86 asm is the global solution. Intel provide some code to do this at: ftp://download.intel.nl/support/processors/procid/cpuinfo.zip This determines whether the CPU supports the CPUID instruction: -SOURCE/CPUINF32/CPUID.C- WORD wincpuidsupport() { int cpuid_support = 1; _asm { pushfd // Get original EFLAGS pop eax mov ecx, eax xor eax, 20h// Flip ID bit in EFLAGS pusheax // Save new EFLAGS value on // stack popfd // Replace current EFLAGS value pushfd // Get new EFLAGS pop eax // Store new EFLAGS in EAX xor eax, ecx// Can not toggle ID bit, jnz support // Processor=80486 mov cpuid_support,0 // Clear support flag support: } return cpuid_support; } // wincpuidsupport() - i.e. if bit 21 of EFLAGS is writable then the CPU supports CPUID. Once you've determined support you can use the undocumented(?) CPUID instruction: #define CPU_ID _asm _emit 0x0f _asm _emit 0xa2 Another function in that file wincpufeatures() will also find the CPU's features using CPUID(0) and CPUID(1). It returns the 32bit features value from the CPUID(1) instruction. According to the FreeBSD /usr/src/sys/i386/i386/identcpu.c, bit 23 determines whether MMX is supported. There's then the additional detection of Cyrix, AMD etc. which may cause complications. AMD have a similar 32 bit features value which also uses bit 23 to indicate MMX support. The AMD specific stuff and all the Intel supported stuff is better explained at: http://www.amd.com/products/cpg/athlon/techdocs/pdf/20734.pdf Like you I used to a lot of 68000 programming. Writing games and such on the Atari ST. Since moving to the UNIX world I've had little use for it. System admin is almost exclusively in perl with a bit of C for good measure. Never touched x86 code before :( Whether executing the CPUID will generally cause a privilege violation on a UNIX box, I'm not yet sure. > As a quick fix we could implement that command line switch > for LAME. Probably the simplest way of doing it :) Cheers. Mark Powell - UNIX System Administrator - The University of Salford Academic Information Services, Clifford Whitworth Building, Salford University, Manchester, M5 4WT, UK. Tel: +44 161 295 5936 Fax: +44 161 295 5888 www.pgp.com for PGP key -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
> Mark, I got that already, but I have no idea how to check > for the presence of a MMX CPU. If someone knows how to do > that, fine! Maybe there is some special x86 command that > allows to decide whether it is a MMX CPU or not. > As a quick fix we could implement that command line switch > for LAME. This is usually done via the cpuid instruction. I just checked the nasm manual, and this instruction is supported by nasm. Regards, -- Gabriel Bouvigne - France [EMAIL PROTECTED] mobile phone: [EMAIL PROTECTED] icq: 12138873 MP3' Tech: www.mp3-tech.org -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
Mark Powell schrieb am Don, 28 Sep 2000: > > Hmm, you may dig in the Gogo sources. If I remember right > > they allowed to turn on optimizations with something like > > --use-mmx. This could be a way to do it in LAME too. > > Surely Gabriel was referring to the MMX code always being present in the > binary. On an non-MMX CPU it would fall back to using the old non-MMX > code. Thus never executing an illegal instruction. Isn't this how > commercial applications handle it? Of course if this is a lot of work, for > little gain, then forgive me :) > Cheers. Mark, I got that already, but I have no idea how to check for the presence of a MMX CPU. If someone knows how to do that, fine! Maybe there is some special x86 command that allows to decide whether it is a MMX CPU or not. As a quick fix we could implement that command line switch for LAME. Ciao Robert -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
On Thu, 28 Sep 2000, Robert Hegemann wrote: > Gabriel Bouvigne schrieb am Don, 28 Sep 2000: > > > > If the mmx version of choose table is used for the compilation, what > > will > > > > happen on a non-mmx cpu? > > > > > > it will crash, and it does so on my old P100. > > > > > > That's bad. Would it be possible to compile both routines in the same > > binaries, with an auto detection? > > Hmm, you may dig in the Gogo sources. If I remember right > they allowed to turn on optimizations with something like > --use-mmx. This could be a way to do it in LAME too. Surely Gabriel was referring to the MMX code always being present in the binary. On an non-MMX CPU it would fall back to using the old non-MMX code. Thus never executing an illegal instruction. Isn't this how commercial applications handle it? Of course if this is a lot of work, for little gain, then forgive me :) Cheers. Mark Powell - UNIX System Administrator - The University of Salford Academic Information Services, Clifford Whitworth Building, Salford University, Manchester, M5 4WT, UK. Tel: +44 161 295 5936 Fax: +44 161 295 5888 www.pgp.com for PGP key -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
Gabriel Bouvigne schrieb am Don, 28 Sep 2000: > > > If the mmx version of choose table is used for the compilation, what > will > > > happen on a non-mmx cpu? > > > > it will crash, and it does so on my old P100. > > > That's bad. Would it be possible to compile both routines in the same > binaries, with an auto detection? Hmm, you may dig in the Gogo sources. If I remember right they allowed to turn on optimizations with something like --use-mmx. This could be a way to do it in LAME too. Ciao Robert -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
> > If the mmx version of choose table is used for the compilation, what will > > happen on a non-mmx cpu? > > it will crash, and it does so on my old P100. That's bad. Would it be possible to compile both routines in the same binaries, with an auto detection? Regards, -- Gabriel Bouvigne - France [EMAIL PROTECTED] mobile phone: [EMAIL PROTECTED] icq: 12138873 MP3' Tech: www.mp3-tech.org -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )
Re: [MP3 ENCODER] MMX question
Gabriel Bouvigne schrieb am Don, 28 Sep 2000: > If the mmx version of choose table is used for the compilation, what will > happen on a non-mmx cpu? it will crash, and it does so on my old P100. Ciao Robert -- MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )