On Wed, Oct 7, 2009 at 5:18 AM, Vincent Labrecque <
vincent.labrec...@gmail.com> wrote:

>
> On Oct 7, 2009, at 7:54 AM, Vincent Labrecque wrote:
>
>
> And as I'm writing this, with regards to optimization flags, maybe the sage
> build system should provide an abstraction over -On.   As I'm sure you know,
> these have widely differing behaviors across compilers.  Sometimes -O3 will
> do nothing, sometimes it will break your code.  ``high'', ``medium'' and
> ``low'' can be translated by an expert on the particular platform
> (os/compiler/compiler-version).
>
>
> This probably should even be per-package.  In particular with packages
> doing complex operation chains.  It could be made easy for a package to
> change the optimization level.
>
> To put what I tried to explain in the last post in practice, here's over
> egineering in the form of a helper program, where packages can downgrade
> optimization levels if they know better:
>
>   eval `./interpret-optimization -O0 -O2 -O3`
>   #runs  CFLAGS_OPTIMIZATION_LOW=-O0; export CFLAGS_OPTIMIZATION_LOW
>   #          CFLAGS_OPTIMIZATION_MEDIUM=-O2; export
> CFLAGS_OPTIMIZATION_MEDIUM
>   #          CFLAGS_OPTIMIZATION_HIGH=-O3; export
> CFLAGS_OPTIMIZATION_MEDIUM
>
>   # Here's what could happen if another part of the build system decided
> that anything over -O3 was unsafe.
>   CFLAGS_OPTIMIZATION_HIGH=-O2
>   eval `./interpret-optimization -O1 -O2 -O4`
>   # runs CFLAGS_OPTIMIZATION_LOW=-O1; export CFLAGS_OPTIMIZATION_LOW
>   #          CFLAGS_OPTIMIZATION_MEDIUM=-O2; export
> CFLAGS_OPTIMIZATION_MEDIUM
>
> Maybe one would want to also make sure low <= medium <= high at all times,
> which would require a few more lines.
> Keep in mind that this was only barely tested.  Anyway.  Here's how you can
> unintrusively share environment variables.
>

I have to point out one problem with this whole approach -- debugging.
Instead of there being one canonical Sage on a given platform (modulo weird
compiler issues), got by typing "make", there are now at least 3^n different
Sage's, where n is the number of packages.   This combinatorial explosion is
precisely the problem the Sage design is meant to combat.

An important reason people can just drop the Sage tarball on such a wide
range of systems, type "make", build nearly 6 million lines of code written
by around 1000 people, and get something that works and passes all 100,000
tests is because essentially their only option at present is to type
"make".

Any user who is serious enough to want to build a specific component of Sage
with a particular optimization can already do so.  Just set and export
CFLAGS, etc., then do "sage -f packagename" to force recompilation of that
package.  Or, if that isn't enough, edit the spkg-install and force
recompile.   But somebody doing that should know they are asking for
trouble...

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to