On Saturday, 14 September 2013 00:36:05 UTC+8, James Reeves wrote: > On 13 September 2013 08:54, Mikera <mike.r.an...@gmail.com > <javascript:>>wrote: > >> Either way, if Clojure's semantics prove to be a fundamental issue for >> performance, then I think it is better to start work to improve Clojure's >> semantics (perhaps targeting 2.0 if we think it's a really big breaking >> change). This would be better, IMHO, than forever accepting semantics that >> prevent idiomatic code from ever being truly fast. I'd rather see a bit of >> breakage and fix my code when upgrading to Clojure 2.0 than be stuck with >> poor performance forever. >> > > Out of curiosity, what is the performance hit in these cases? >
Here's a quick highly artificial benchmark I did with Caliper in Java (Obviously can't benchmark in Clojure since we don't have proper float support....) 0% Scenario{vm=java, trial=0, benchmark=Float} 267222.79 ns; σ=1629.43 ns @ 3 trials 50% Scenario{vm=java, trial=0, benchmark=Double} 416110.28 ns; σ=2087.75 ns @ 3 trials benchmark us linear runtime Float 267 =================== Double 416 ============================== vm: java trial: 0 Obviously this is just a microbenchmark, but it fits my general experience that floats are a reasonable bit faster than doubles, typically 20-100% (doubles are closer when it is pure number crunching since 64-bit CPUs are actually pretty good at doubles, floats have a bigger advantage when you are manipulating a lot of data points and hence memory bandwidth matters more) Code here for those interested: src/test/java/mikera/vectorz/performance/FloatVsDoubleBenchmark.java > > Floats obviously save memory, and I believe they're also between 15% to > 40% more efficient for division, at least on Intel CPUs. Is there also a > cost to be paid passing doubles to OpenGL? Do you know what that cost is? > > I'm not exactly an expert in OpenGL, but I would make the following points: - Many GPU applications are actually memory-bandwidth bound (the compute power is insane....). So using floats means you can pump through 2x as much data to keep your GPUs busy - Hardware and driver support is usually not on a par with floats, even if it is technically supported by the OpenGL API This is an interesting article to back up the latter point: For example on NVidia GeForce hardware doubles are 1/8 the speed of floats http://blog.hvidtfeldts.net/index.php/2012/07/double-precision-in-opengl-and-webgl/ -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.