Generally speaking using -O2 gave the best improvements (10% better
or so than plain old Release mode), after that nothing really helped
(but sometimes the numeric evolution was different, leading to
different execution paths, which led to faster 'runs' but with the
wrong results...many an unhappy hour was spent here trying to figure
out if I'd done something clever or stupid!). I'm curious about Mark's
result though, a 5* speed-up is really significant. It is odd that I
couldn't replicate it here.
At the risk of being boring you might want to look at these few paragraphs:
http://research.microsoft.com/en-us/um/people/toddpro/papers/law.htm
I do know that the Intel compiler is generally better than GCC (and
MSVC beats GCC too), that was true at least a year back when I worked
on a cell-based flood modeling system (OpenMP, 8 cores, big PCs,
running on Linux and Windows).
Personally I'm interested in finding a good openmp example and trying
to wire that together to use >1 core :-)
i.
> --
> You received this message because you are subscribed to the Google Groups "shedskin-discuss" group.
> To post to this group, send email to shedskin...@googlegroups.com.
> To unsubscribe from this group, send email to shedskin-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/shedskin-discuss?hl=en.
>
>
--
Ian Ozsvald (A.I. researcher, screencaster)
i...@IanOzsvald.com
http://IanOzsvald.com
http://SocialTiesApp.com/
http://MorConsulting.com/
http://blog.AICookbook.com/
http://TheScreencastingHandbook.com
http://FivePoundApp.com/
http://twitter.com/IanOzsvald
On 6/2/2011 2:01 AM, srepmub wrote:
> hi guys,
>
> there are several interesting tools, acovea and milepost gcc (?), that
> can automatically optimize gcc compiler flags (it literally has
> hundreds of flags..)
>
> so the obvious thought is, wouldn't it be nice if we could combine
> these with shedskin, or implement a simple (genetic?) algorithm that
> does the same thing..? shedskin is dog slow anyway, especially for
> larger programs (my estimate is that if the C64 emulator example grows
> to 5,000 lines, it will currently take 2 hours to compile on a fast
> CPU), so that would certainly fit in with the philosophy.. :-)
>
> thoughts or experencies, anyone..?
I don't have experience, but having seen the difference made by
-march=native (when gcc supports it), using one of those tools might be
even better.
If they depend on running the output, it'll require more specific
documentation on the 'if __name__=="__main__":' section of the code.
Currently it only needs to call the functions with the right types, so
my extension modules are filled with "foo()" and "bar([0])". If the
resulting binary is run for timing, it'll need real inputs like
bar(range(1000))
> btw, I was reminded by private mail of the -Ofast option in GCC 4.6.
> apparently it turns on -ffast-math, and possibly some other goodies.
This, along with -march=native, needs a GCC version check. I have three
versions of GCC installed from the past few years, and the latest I have
is 4.4.5. Distributions update at different speeds, usually skipping a
version or two of tools, so a quick "gcc --version" parsing would be
very useful.
import subprocess
data =
subprocess.Popen(['gcc','--version'],stdout=subprocess.PIPE).communicate()[0]
version = tuple(map(int,data.splitlines()[0].rsplit(' ',1)[-1].split('.')))
version results in (4,4,5) for me
--fahhem
Over the last year I've done a lot of work with pyCUDA and C-based
CUDA (mostly working directly on the .cu C file). Most of the gains
there come from figuring out how to vectorise code, reduce memory
accesses and then tweak things (e.g. obtaining the magical 'coalesced
memory access speedups'). Your code examples remind me of a bunch of
this work :-)
I guess there's an interesting question (Mark?) asking whether
ShedSkin can do some of these conversions automatically?
i.
> Hi Enzo. You're totally right, I was just thinking of compiler flag
> optimisation rather than code layout. The downside is that changing
> the code layout can be quite a lot of work though (I confess to having
> tried it only on occasion though).
>
> Over the last year I've done a lot of work with pyCUDA and C-based
> CUDA (mostly working directly on the .cu C file). Most of the gains
> there come from figuring out how to vectorise code, reduce memory
> accesses and then tweak things (e.g. obtaining the magical 'coalesced
> memory access speedups'). Your code examples remind me of a bunch of
> this work :-)
>
> I guess there's an interesting question (Mark?) asking whether
> ShedSkin can do some of these conversions automatically?
That could work, but thinks like loop unrolling and similar stuff is
automatically done with recent gcc's. There are plenty of optimizing
flags available and many of them are enabled with -O3.
Most of the time I use -ftree-vectorize and
-ftree-vectorizer-verbose=8, so I know where I can change code
efficently, so gcc can parallelize the loop on it's own.
But that doesn't work well with shedskin atm, because it uses to fancy
objects (all the garbage collected stuff). It's on my TODO list to kill
all usage of "units" everywhere, so we could switch the internal
representation, so gcc can further optimize things...
Thomas
|
Optimization |
|
|
Function Inlining
|
x1.27 |
|
Loop Fusion
|
x1.33 |
|
Loop Interchange |
x1.37 |
|
Induction Variable Elimination
|
x1.39 |
|
Common Subexpression Elimination
|
x1.41 |
|
Loop Unrolling
|
x1.43 |
|
Loop Splitting |
x1.46 |
|
Loop Nest Optimization |
x1.47 |
|
Hoisting
|
x1.49 |
|
Loop Skewing |
x1.50 |
|
Loop Unswitching
|
x1.51 |
|
Bitfield Optimization
|
x1.52 |
|
Instruction Combining
|
x1.60 |
|
Loop Reversal |
x1.62 |
|
If Optimization
|
x1.63 |
|
Loop-Invariant Code Motion |
x1.70 |
|
Loop Collapsing
|
x1.71 |
|
Block Merging
|
x1.73 |
|
Loop Inversion |
x1.78 |
|
Expression Simplification
|
x1.82 |
|
Integer Modulus Optimization
|
x1.84 |
|
Forward Store
|
x1.84 |
|
Integer Multiply Optimization
|
x1.95 |
|
Integer Divide Optimization
|
x1.96 |
|
Branch Elimination
|
x1.99 |