News for hackers. Stuff that matters.
Re:Don't use assembly unless you're an expert by charlieflowers on Friday April 04, 2014 @10:06AM (#7531465)
A random thought just crossed my mind -- how about a genetic algorithm that experiments with all these options and evolves towards the best performance?

Run speed is objective and measurable, which is desirable for a fitness criterion.

Somehow, you'd have to specify which instructions can be moved around and which can't -- or maybe not, if you could also assess whether the program executed "successfully."

I don't really see it as practical, but it might be fun. Might uncover optimizations that no one has seen before.

Re:Don't use assembly unless you're an expert by bradleyjg on Friday April 04, 2014 @10:56AM (#7531758)
Take a look at this paper from last year:

Stochastic Superoptimization (http://cs.stanford.edu/people/eschkufz/research/asplos291-sc...)

Re:Don't use assembly unless you're an expert by dankoss on Friday April 04, 2014 @10:25AM (#7531569)
> Run speed is objective and measurable

Unfortunately in most modern OSes run speed on x86 is variable and profiling itself is intrusive. You might be able to get a general trendline toward a faster algorithm but it'll still be lost in statistical noise.

The second problem is that the underlying processor is a moving target. The x86 programming model doesn't directly map to hardware anymore, with out of order execution, branch predictors and register renaming. One variant of the processor with a particular caching algorithm might have totally different results than the next.

Re:Don't use assembly unless you're an expert by jamesjporter on Friday April 04, 2014 @06:14PM (#7534788)
It's not a genetic algorithm, but FFTW's planning system actually does perform experiments to optimize for a particular machine's hardware.
Re:Don't use assembly unless you're an expert by stcredzero on Saturday April 05, 2014 @02:31PM (#7537957)
Genetic algorithms are just a particular kind of stochastic hill-climbing graph-search. (EDIT: It's actually a general graph, not a tree.)
Re:Don't use assembly unless you're an expert by caf on Friday April 04, 2014 @09:01PM (#7535514)