🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

bits as float - "MOVD xmm0, eax" and MSVC nonsense

Started by
17 comments, last by NikiTo 4 years, 2 months ago

“For years, PC programmers used x86 assembly to write performance-critical code.”

“Assembly is often used for performance-critical parts of a program, although it is difficult to outperform a good C++ compiler for most programmers.” -Intel

https://software.intel.com/en-us/articles/introduction-to-x64-assembly

Advertisement

tanzanite7 said:
“(*(float*)&val)”

If “val” is anything but a float you're invoking undefined behaviour. You can go ahead and report it as a bug to Microsoft if you want. I can tell you as a compiler developer we get no end of “pleasure” when customers tell us their code containing UB doesn't behave the way they expect it to. “My code is broken you need to fix your compiler!!”

As for why MSVC would write to cache and read it back instead of doing a processor-to-processor transfer directly, it might come down to the way superscalar pipelines work. It can sometime be much much faster to round-trip through the L3 cache than to do onboard conversions between data formats. I make no guarantee that's the case without consulting x86_64 timing tables (and I'm not going to do that if I'm not on the clock) but there are many, many subtleties in today's processors that many people who are not experienced experts consisting partially of silicon themselves might miss. It could also be an artifact of C code containing undefined behaviour. The compiler is allowed to assume your code contains no undefined behaviour and when it does, weird and unexpected things can happen.

Stephen M. Webb
Professional Free Software Developer

I would not report it. First, compiles can not read the thoughts of the coder. They can not get 3 notes music sheet and add the rest of hundreds of notes in order to create the best melody the coder wanted to compose inside his head.

Should we blame a horse for not being able to fly?

Compilers give us productivity. That's why i use a compiler myself.

Second, reporting a bug is to do the job of the compiler programmer. I am not paid to improve the compiler of Intel. They pay to people to do that. Except in the case when i really need for my own interests the bug to be fixed. In which case comes the Third - most probably your bug report will be filed for years or even be ignored by the compiler developers. If the developer has to fix stability-bugs first, he will not even peek into your speed-bug.

This is perfectly normal. Perfectly understandable. I am sure compilers do their best with only 3 musical notes. I have not used ASM myself in years and i wish i dont have to use it. But facts are facts - with ASM i get access to all the musical notes….. then the OS will destroy most of my optimizations by flushing my registers all of the time because of other processes. But this doesn't make ASM slower than a compiler. It is the OS that makes it slower. But again, it is perfectly normal and understandable.

(I can imagine the reaction of some religiously radical compiler developer reading your bug report - “I looked at the ASM output and the produced code is slower than hand written ASM”… LOL just imagine how much and for how long a radical “compiler is faster than any ASM”-type of a dev would swear in your address. How many days the radical compiler developer will be cursing you. Can you imagine it? You do an extra work to file a bug for those people, you show them part of your code and they will send so much so bad vibrations in your address, you could get sick for no apparent reason. I really hope the compiler developers are not radical religious fanatics. But again, i don't mind it how good they do their jobs. Even a bad compiler is good for the purposes of my current project. I need to develop a good algorithm. Tuning my app at the level of produced machine code is the job of other people. They will be paid by their companies to do it, when i am done with my algorithm and sell it. It is not about money, it is about productivity. If i did everything, i would never finish.
I see this is the problem of many people here - they ask how to optimize a 2D game to run at 1200FPS, which is a complete loss of time. They should be spending their time creating the entertainment part of the game, rather than making it get from 800 FPS to 1200FPS(if they want to publish a game someday soon, someday this century))

NikiTo said:
I see this is the problem of many people here - they ask how to optimize a 2D game to run at 1200FPS

Can you post a link to one of the many examples you have seen? Thanks.

Also, you seem to have a great contempt for compiler programmers. You do know that they are among the best assembly programmers around, right?

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

fleabay said:

NikiTo said:
I see this is the problem of many people here - they ask how to optimize a 2D game to run at 1200FPS

Can you post a link to one of the many examples you have seen? Thanks.

Also, you seem to have a great contempt for compiler programmers. You do know that they are among the best assembly programmers around, right?

There are lot of examples in the forum.

Any good compiler dev is needed to have a great knowledge in ASM. I think a good compiler developer would completely agree with the things i said so far. They offer a product to boost productivity of people. And it is easier to start learning programming in JS, so programming gets more popular the easier and more superficial the language is. Which leads to the situation of many programmers having no idea of programming at all.

In the beginning i made a whole interactive responsible site in Flash without knowing nothing at all about programming. The menus were playable around. I pretended to be a programmer while not knowing what a variable is. I recall the case of a man who was operating Linux serves in his daily job. He was behaving as far superior to everybody else in the class, because he was typing in a terminal. But he did not know you can put more than one LAN adapter to the same computer and use it as a networking machine. He was so shocked to learn it, that he exclaimed out loud: “so you can do that! Wow! Amazing! This opens so many new horizons for me”… the class was facepalming… A lot of people believe they are master programmers for using lambdas, although they can not tell when a lambda is really needed, and when a lambda is just a syntax candy.

The main selling point of node.js was “you can have a server in five lines of code” promoting mediocrity.

I would be not surprised if a programmer after working for 20 years in the industry, does not know what is he doing. It can happen with HLLs.

Claiming "Linux is safer than Windows" or “A good compiled code is faster than any assembly code” are symptoms of having not enough understanding of the matter.

You completely ignore the fact i promote compilers. Never ever in this forum i told nobody to drop a compiler and use assembler. I even strongly discouraged people from using ASM. The thing is, me saying that a good assembler can write faster code than a good C++ coder, triggers some people here for some foxy reasons.

What if a compiler developer decides to write a program in ASM for fun? Will the same person write slower assembler than his own compiler? If you can not understand the complete nonsense of the claim “a good compiler can produce faster code than any assembler”, then you need to keep studying.

NikiTo said:
I see this is the problem of many people here - they ask how to optimize a 2D game to run at 1200FPS

NikiTo said:
There are lot of examples in the forum.

Why can't you post a link to one of them? I can cut and paste a URL if you don't know how to make a hyperlink.

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

fleabay said:
I can cut and paste a URL if you don't know how to make a hyperlink.

NikiTo said:

fleabay said:
I can cut and paste a URL if you don't know how to make a hyperlink.

Why did you post a blank quote? Why can't you post a URL as proof of your claim?

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

fleabay said:

NikiTo said:

fleabay said:
I can cut and paste a URL if you don't know how to make a hyperlink.

Why did you post a blank quote? Why can't you post a URL as proof of your claim?

I'm trying! I'm trying!

This topic is closed to new replies.

Advertisement