Message from @DanielKO

Discord ID: 429490836133117962


2018-03-31 03:42:25 UTC  
2018-03-31 03:42:58 UTC  

Most of the other commands are somewhat familiar

2018-03-31 03:46:49 UTC  

it's using single-precision floating point, so if you typed in different numbers it may have automatically chosen a format with more precision?

2018-03-31 03:47:30 UTC  

That's governed by how basic types arithmetic works in C++.

2018-03-31 03:48:18 UTC  

Replace the `float` by `double`, and call `::sqrt()` to see it use different instructions.

2018-03-31 03:49:12 UTC  

https://cdn.discordapp.com/attachments/423219052849397773/429487300972380160/sqrt-test-2.png

2018-03-31 03:51:50 UTC  

The `pxor`, `ucomis` and `ja` serve to check if the argument is positive; if so, it can just use the `sqrt` instruction; otherwise, it needs to call the `sqrt()` function from the standard library, which handles all the nasty NaN, Infinity, negative arguments.

2018-03-31 03:54:52 UTC  

okay. so the chip has its own primitive math

2018-03-31 03:56:29 UTC  

Yeah, it's a CISC architecture.

2018-03-31 03:56:58 UTC  

Switch to the MIPS gcc, and you'll get a very different result.

2018-03-31 03:57:13 UTC  

RISC dont have its own maths intructions?

2018-03-31 03:57:22 UTC  

https://cdn.discordapp.com/attachments/423219052849397773/429489359289319424/sqrt-test-3.png

2018-03-31 03:57:58 UTC  

ive only read a couple pages about MIPS so far

2018-03-31 03:59:18 UTC  

Reduced Instruction Set Computer, the whole point is to have so few instructions in the architecture that the circuitry is very small.

2018-03-31 03:59:59 UTC  

Being small means there's less need for synchronization, thus it can run faster, and there are more transistors that can be used for caches.

2018-03-31 04:00:36 UTC  

PowerISA stands for Performance Optimized With Enhanced Reduced Instruction Set Computer Instruction Set Architecture

2018-03-31 04:01:02 UTC  

So a typical RISC arch won't have any advanced instructions. No specialized math, no instructions that mix register operands with memory, etc.

2018-03-31 04:01:28 UTC  

they dont use the same design pillars when picking acronyms

2018-03-31 04:01:28 UTC  

If course, at some point, you end up with extra room in the silicon, so some complex instructions sneak back in, just because they can.

2018-03-31 04:02:26 UTC  

so all risc programmers need to have all their maths in standard libraries?

2018-03-31 04:03:14 UTC  

It's not like there's a circuit that does math functions in Intel chips. It also runs some software to calculate it.

2018-03-31 04:03:27 UTC  

It's just that it's built into the chip.

2018-03-31 04:04:01 UTC  

Downside is, if the manufacturer didn't pay much attention to details, you can get bad results. Fast, but wrong.

2018-03-31 04:04:02 UTC  

what do you call that? firmware? embedded process??

2018-03-31 04:04:12 UTC  

That would be the CPU's microcode.

2018-03-31 04:04:15 UTC  

ok

2018-03-31 04:04:58 UTC  

Intel CPUs were notorious for having bad trig instructions, when outside the normalized range.

2018-03-31 04:05:38 UTC  

"Bad" meaning they didn't calculate all the bits they promised.

2018-03-31 04:06:00 UTC  

I remember seeing a paper a while back, about how those math functions in CPUs had some unexpected precision problems that didn't even match what the manual promised.

2018-03-31 04:07:29 UTC  

IIRC, for sine/cosine, Intel uses a lookup table, then interpolates the values.

2018-03-31 04:07:39 UTC  

wild guess, did this come to light during the early 3D era?

2018-03-31 04:08:23 UTC  

Not really, it was a paper on scientific computing / simulations field.

2018-03-31 04:09:20 UTC  

Obviously you can't get infinite precision on a computer, but you can keep track of how big the error is. There are a few different approaches for that.

2018-03-31 04:09:51 UTC  

But it's all for nothing if the operations are not delivering the precision they promise.

2018-03-31 04:10:45 UTC  

One of the reasons people that do scientific computing hate Intel's compiler. It tends to gratuitously rewrite floating point expressions to make them faster.

2018-03-31 04:11:20 UTC  

Which, if you spent a significant amount of time making sure every evaluation is careful so you keep track of the error, is a kick in the balls.

2018-03-31 04:12:06 UTC  

Yeah, I think that's the article.

2018-03-31 04:12:40 UTC  

Ive actually been interested in Intel's c++ compiler because I've read it's one of the reasons PRBoom+ runs so much faster than GZdoom

2018-03-31 04:15:25 UTC  

I mean, it's just a game, so sure, worst that can happen is what? Render a pixel wrong?

2018-03-31 04:16:52 UTC  

projectiles will have inaccurate trajectories at long range i guess