Page 1 of 2

Dynamic cpu code?

Posted: Sat Dec 04, 2004 8:52 pm
by Dreglor
does the compiler create clone code for each processer so when run on amd it will do the 3dnow! instructions and on intel will use sse2 instuctions?
or is it just uses instructions that aren't cpu spcific?

Posted: Sat Dec 04, 2004 9:05 pm
by Pupil
Check the section "Using the command line compiler" in the manual
PB manual wrote: /DYNAMICCPU: Creates a executable containing all the available processor specific routines. When the program is started, it looks for the processor type and then select the more appropriates routines to use. This makes a bigger executable, but result in the fastest possible program.
To my knowledge there are very few(if any) library commands that come in mmx, 3dnow! optimized versions.

The ASM that the compiler produces itself is to my knowledge only generic ASM.

Posted: Sat Dec 04, 2004 11:24 pm
by Max.²
Pupil wrote:To my knowledge there are very few(if any) library commands that come in mmx, 3dnow! optimized versions.
I made a very few, dealing with encryption. No clue if they work with 3.92 though.
The ASM that the compiler produces itself is to my knowledge only generic ASM.
That is what I know, too.

Posted: Mon Aug 29, 2005 5:42 pm
by Dare2
Does anyone know what DYNAMICCPU actually does? Does it, for example, create 386,486 etc codeblocks and do some internal patching at runtime? :)


Just curious, is all.

Posted: Mon Aug 29, 2005 6:26 pm
by Pupil
My guess is that a jumptable for the functions in question (for the ones that have CPU specific optimizations) is set up in the init code. This is however only a guess from my side, Fred would know for sure, i hope ;)

Posted: Mon Aug 29, 2005 7:28 pm
by Fred
That's exaclty as Pupil said (you can see that when using the /COMMENTED code with a function which actually support it (actually there is no internal PB functions which use it, but some user libs could)).

Posted: Mon Aug 29, 2005 7:50 pm
by thefool
Wondering, if its turned on how will the exe work on lets say non-3dnow cpu's? Will the code that works on all cpu's be included too?

Posted: Mon Aug 29, 2005 8:08 pm
by Jellybean
thefool wrote:Wondering, if its turned on how will the exe work on lets say non-3dnow cpu's? Will the code that works on all cpu's be included too?
If you set it to for example MMX and you happen to use some functions that support this, the executable of course won't work on non-MMX processors.

It seems to me like the point of "dynamic" is to include all function sets and then pick the best at runtime. (So then it will of course run on any processor.)

Posted: Mon Aug 29, 2005 8:22 pm
by thefool
i asked if it just meant that the mmx was included. So the size grew bigger but exe worked on all cpu's as well. Its not all "Of course".... i doubt it will include functions for mmx or 3dnow when using dynamic.

Posted: Mon Aug 29, 2005 9:36 pm
by Fred
When using dynamic CPU all specialized routines will be included which means a probably bigger exe, but also the fastest possible (as each routine will be used depending of the CPU where the exe is running on).

Posted: Mon Aug 29, 2005 9:39 pm
by thefool
ok thanks for the clearifytation [a word i just made i think :?]

Posted: Tue Aug 30, 2005 12:35 am
by Dreglor
Dynamic CPU should be used more often...

it be a good idea if we could have compiler Constants for these so you could write 3dnow!,SSE,MMX version of certain procedures or parts of code that would be nice

Posted: Tue Aug 30, 2005 2:06 am
by Dare2
Very interesting.

Agree with Dreglor, perhaps /DYNAMICCPU should be used more often. And incode compiler switches would be useful.

Posted: Tue Aug 30, 2005 5:00 am
by Dummy
The constants would be a great thing!

You could create Exes for 3DNow!, SSE2 and normal(not optimized) and the create an exe that chooses the fastest one.

I'd just speed up a little more in Loops containing Optimized functions :wink:

That'd be great

Posted: Tue Aug 30, 2005 4:16 pm
by Fred
Dummy: you can already do that, what do you mean exactly ?