News for hackers. Stuff that matters.
Re:There Are Only Four Billion Floats – So Test Them All by jwmerrill on Tuesday January 28, 2014 @04:05AM (#7136129)
Sorry for making you feel sad. Good points all around, here, and in the other comments about GPUs. Regarding CPU, though, my understanding is that on a 64 bit machine, 32 bit arithmetic is no faster than 64 bit arithmetic. Is that incorrect?
Re:There Are Only Four Billion Floats – So Test Them All by sharpneli on Tuesday January 28, 2014 @04:21AM (#7136184)
It is incorrect.

Take SSE2 instructions as an example (Every X64 processor supports these, the old x87 FPU has been obsolete for over 10 years). You can either calculate 4 floats per instruction or 2 doubles per instruction. Similar considerations also apply to ARM.

Also even if you might want to use doubles as intermediate representation you still might wish to use floats as storage. E.g read from float, convert into double, calculate stuff, write back a float.

Re:There Are Only Four Billion Floats – So Test Them All by hayfield on Tuesday January 28, 2014 @04:14AM (#7136150)
Some work I was doing over the summer indicates that the optimal datatype depends on the algorithm you're using.

qsort() can get 15% better performance with uint64_ts than uint32_ts (sorting identical arrays of 8 bit numbers represented differently). On the other hand, a naive bubble sort implementation was managing 5% better performance with 16 bit datatypes over any of the others.

If you start measuring energy usage as well, it becomes even stranger - using a different datatype can make it run 5% faster, while using 10%+ less energy (or in the qsort() case, take less time, but use more energy).

Re:There Are Only Four Billion Floats – So Test Them All by nly on Tuesday January 28, 2014 @08:12AM (#7136818)
qsort strikes me as a bit of a crappy benchmark because of the type erasure. Your compiler likely isn't inlining or applying vectorisation. Vectorisation would likely benefit 32bit floats on a 64bit platform more than doubles.
Re:There Are Only Four Billion Floats – So Test Them All by hayfield on Tuesday January 28, 2014 @01:51PM (#7138926)
Indeed - it probably isn't ideal.

I'd tested a number of sort algorithms (bubble, insertion, quick, merge, counting), so also testing the sort function from stdlib seemed like a logical continuation. It was done rather quickly, so there wasn't time to properly investigate, merely look at the numbers and go "that's strange".

Re:There Are Only Four Billion Floats – So Test Them All by sampo on Tuesday January 28, 2014 @11:19AM (#7137936)
What about 32 bit ints stored 64 bits away from each other?
Re:There Are Only Four Billion Floats – So Test Them All by hayfield on Tuesday January 28, 2014 @01:52PM (#7138931)
I'm not sure. This was a fairly quick experiment on an Ivy Bridge processor where the actual results were of secondary concern at the time (it was proof-of-concepting a separate tool).

If you look on arXiv.org, there are publications looking more at alignment on Cortex and XCore architectures. There's probably work relating to x86, though the longer instruction pipeline makes it more complicated to reason about than the simpler architectures.

Re:There Are Only Four Billion Floats – So Test Them All by chriswarbo on Tuesday January 28, 2014 @04:30AM (#7136207)
I hope you enjoy cache misses ;)
Re:There Are Only Four Billion Floats – So Test Them All by MaulingMonkey on Tuesday January 28, 2014 @08:31AM (#7136899)
Network bandwidth and disk I/O may also bottleneck more significantly, depending on the application.