Advertisement Jump to content
Sign in to follow this  
fir

intrinsics/no intrinsics (in mingw)

This topic is 1812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

doeas mingw always generate intrinsics for such functions

like min sin memcopy - or there is some way to off/spoil that

(I of course would prefer to get intrinsics here but would like to get

sure they are not off

 

if i will wrote min(x,y) is there 100% that mingw will put intrinsic here?

if so need I include header or declaration for this even if this is

then unusable in spite this do not needs a binary to call?

 

Share this post


Link to post
Share on other sites
Advertisement

I think you are misunderstanding what an intrinsic is, it is a specially instruction to the compiler that it should use a particular instruction or group of instructions to transform the code in to asm. For example __m128 as an intrinsic telling the Compiler that if the target you are compiling for supports SSE2 instructions that this should be stored in a SSE2 register instead of normal registers. And yes for intrinsics you need to include headers as well, and they can be compiler specific so look in the help files of your compiler or the online help page.

 

Sin is a function defined in the C runtime and is used to calculate a value that approaches a sin value, how that is implemented and optimised by the compiler depends on the used version of the C runtime and the compile settings you are compiling with.

Edited by NightCreature83

Share this post


Link to post
Share on other sites

I think you are misunderstanding what an intrinsic is, it is a specially instruction to the compiler that it should use a particular instruction or group of instructions to transform the code in to asm. For example __m128 as an intrinsic telling the Compiler that if the target you are compiling for supports SSE2 instructions that this should be stored in a SSE2 register instead of normal registers. And yes for intrinsics you need to include headers as well, and they can be compiler specific so look in the help files of your compiler or the online help page.

 

Sin is a function defined in the C runtime and is used to calculate a value that approaches a sin value, how that is implemented and optimised by the compiler depends on the used version of the C runtime and the compile settings you are compiling with.

dont think so check up in wiki like

 

"In compiler theory, an intrinsic function is a function available for use in a given programming language whose implementation is handled specially by the compiler. Typically, it substitutes a sequence of automatically generated instructions for the original function call, similar to an inline function. Unlike an inline function though, the compiler has an intimate knowledge of the intrinsic function and can therefore better integrate it and optimize it for the situation. This is also called builtin function in many languages."

 

also i seen some page when there was a list of intrinsics in mingw (or intel? forget this page sadly) it was like memset sin min etc etc (thay are untrinsics, not normal functions, even inline) do not confuse this with sse intrinsics

 

i am asking here if all the functions like min sin memcopy are allways intrinsics or they could be of and turn in normal linked functions

Edited by fir

Share this post


Link to post
Share on other sites

We're getting derailed here.

 

The OP asked if he wrote "min( x, y )" or "cos( pi )" it would always generate an instruction.

The answer is no, you don't have a guarantee.

 

(...)

 

As for standard built in functions like min or cos; the compiler may recognize it, or it may not. It depends on compiler optimization flags, runtime debug check flags, precision flags, and complexity of the code. Normally cos & sin tend to be translated to their x87 fpu equivalent with /O2.

 

The best way to check is to look at the generated assembly periodically (which I consider a good practice, IMHO), to ensure the compiler keeps translating to the best code.

 

Cheers

Matias

(you right, i just asked about this )

 

damn, that is bad, Thats what im worried about if not get normal 

external min() call instead of builtin for some unknown reason :-(

Share this post


Link to post
Share on other sites


damn, that is bad, Thats what im worried about if not get normal external min() call instead of builtin for some unknown reason

 

It's not really something that's worth worrying about.  You're talking about a difference of one or two instructions per second. Worry about making the code more efficient instead as that is far more likely to make a noticeable difference.

Share this post


Link to post
Share on other sites

 


damn, that is bad, Thats what im worried about if not get normal external min() call instead of builtin for some unknown reason

 

It's not really something that's worth worrying about.  You're talking about a difference of one or two instructions per second. Worry about making the code more efficient instead as that is far more likely to make a noticeable difference.

 

It depends on context.

If min() is called on some AI code that has multiple branches, then the overhead (in case it's poorly optimized by the compiler) is not going to matter much (it's not going to be a bottleneck, Wikipedia explains the Pareto principle better than I can), and therefore I wouldn't worry.

 

However if that min() is called inside per particle per frame in a particle FX system where having a million particles on scene is the goal, then I WOULD worry about it.

Likewise, if that min() is called inside a mesh' vertex traversal function, then I would worry too (since one mesh could have millions of vertices, even worse if it gets called per frame or for multiple meshes)

 

Furthermore, if you're interesting in optimization, you should make yourself comfortable with profiling. Profiling will tell you where to look to optimize.

Share this post


Link to post
Share on other sites

 

 


damn, that is bad, Thats what im worried about if not get normal external min() call instead of builtin for some unknown reason

 

It's not really something that's worth worrying about.  You're talking about a difference of one or two instructions per second. Worry about making the code more efficient instead as that is far more likely to make a noticeable difference.

 

It depends on context.

If min() is called on some AI code that has multiple branches, then the overhead (in case it's poorly optimized by the compiler) is not going to matter much (it's not going to be a bottleneck, Wikipedia explains the Pareto principle better than I can), and therefore I wouldn't worry.

 

However if that min() is called inside per particle per frame in a particle FX system where having a million particles on scene is the goal, then I WOULD worry about it.

Likewise, if that min() is called inside a mesh' vertex traversal function, then I would worry too (since one mesh could have millions of vertices, even worse if it gets called per frame or for multiple meshes)

 

Furthermore, if you're interesting in optimization, you should make yourself comfortable with profiling. Profiling will tell you where to look to optimize.

 

Asw you said I did not need to profile to know where it is important -

i just see it from teh geometry of code, though measuring the times 

shows the inpact of changes (i use query performance counter

works quite good for me)

 

ps. i am optymizing ultraspinning cpu loops quite often so for me

it is important 

Edited by fir

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!