December 9, 2011
Hooray! Thank you to my fine coworkers/coconspirators: Schwa, Christophe, Ollie, White Tie, Geoff, and all of the lovely people who helped test
and gave valuable feedback. Schwa and White Tie did a fantastic job on the new web site, too, I must say. <3
Soon after posting the new website (thank you, git, for making that easy), and after grabbing a celebratory coffee, I noticed the web
site was a bit slow. The CPU use was low (an Amazon EC2 instance), but on looking at the bandwidth graph I saw it was pushing a ridiculous amount
of traffic (presumably saturating the link, even). After mirroring the downloads to a CDN (CloudFront), all was well. Thank you, Amazon. I'm very
impressed with AWS/EC2/etc. It's good stuff.
8 Comments
// boring code omitted, see WDL/denormal.h for the full code // WDL_DENORMAL_DOUBLE_HW() is a macro which safely gets you the high 32 bits of a double as an unsigned int. static double WDL_DENORMAL_INLINE denormal_filter_double(double a) { return (WDL_DENORMAL_DOUBLE_HW(&a)&0x7ff00000) ? a : 0.0; }The above code pretty simply looks at the exponent field of the double, and if it is nonzero, returns the double, otherwise it returns 0.
static double WDL_DENORMAL_INLINE denormal_filter_double_aggressive(double a) { return ((WDL_DENORMAL_DOUBLE_HW(&a))&0x7ff00000) >= 0x3c900000 ? a : 0.0; }That was pretty much free (ok slightly larger code, I suppose). One nice thing that became apparent was that we could filter NaN and infinity values this way as well (exponent == 0x7FF), with only the cost of a single integer addition:
static double WDL_DENORMAL_INLINE denormal_filter_double_aggressive(double a) { return ((WDL_DENORMAL_DOUBLE_HW(&a)+0x100000)&0x7ff00000) >= 0x3cA00000 ? a : 0.0; }Note that the exponent is increased by 1, so that 0x7FF becomes 0, and we adjusted the cutoff constant for the change.
where I'm flying through space
hoping there are no power lines
2 Comments