Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Compile file with specific optimization
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Waldek Hebisch  
View profile  
 More options Feb 6, 9:29 am
Newsgroups: comp.lang.lisp
From: Waldek Hebisch <hebi...@math.uni.wroc.pl>
Date: Mon, 6 Feb 2012 14:29:10 +0000 (UTC)
Local: Mon, Feb 6 2012 9:29 am
Subject: Compile file with specific optimization
I would like to compile file with specific optimization settings.
More precisely, I would like to write a function
'compile-file-with-optimization'.  My first attempt is

(defun compile-file-with-optimization(file opts)
    (proclaim opts)
    (compile-file file))

However, I would like that after compiling the file optimization
setting should remain  unchanged.  I was thinking about restoring
original settings via second 'proclaim', but it seems that there
is no way to query the compiler about optimization settings.

Is there a simple solution to this problem (besides having my
own bookeeping which remembers all changes to settings done
via proclaim).  I was thinkig about forking separate process
for compilations, but on non-Unix systems I would have to
start entirely new Lisp process and that would be too expensive.
--
                              Waldek Hebisch
hebi...@math.uni.wroc.pl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
S.Mandl  
View profile  
 More options Feb 7, 5:46 pm
Newsgroups: comp.lang.lisp
From: "S.Mandl" <StefanMa...@web.de>
Date: Tue, 7 Feb 2012 14:46:36 -0800 (PST)
Local: Tues, Feb 7 2012 5:46 pm
Subject: Re: Compile file with specific optimization
Dear Waldek,

sorry, I found no solution to your problem in general.
If you are able to modify the files that you want to compile
you can of course place appropriate DECLAIM statements at
the beginning of the file. On the other hand, if the files
already contain such statements you are can do much about
it anyway.
I guess doing your own bookkeeping is not so bad at all.

Just being curious: what is your application scenario for compile-file-
with-optimization?

Regards,

Stefan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Waldek Hebisch  
View profile  
 More options Feb 8, 4:08 pm
Newsgroups: comp.lang.lisp
From: Waldek Hebisch <hebi...@math.uni.wroc.pl>
Date: Wed, 8 Feb 2012 21:08:36 +0000 (UTC)
Local: Wed, Feb 8 2012 4:08 pm
Subject: Re: Compile file with specific optimization

S.Mandl <StefanMa...@web.de> wrote:
> Dear Waldek,

> sorry, I found no solution to your problem in general.
> If you are able to modify the files that you want to compile
> you can of course place appropriate DECLAIM statements at
> the beginning of the file. On the other hand, if the files
> already contain such statements you are can do much about
> it anyway.
> I guess doing your own bookkeeping is not so bad at all.

> Just being curious: what is your application scenario for compile-file-
> with-optimization?

OK, full details.  I am main developer of computer algebra
system FriCAS (which is a fork of Axiom).  Largest part of
FriCAS is written in Spad, which is strongly typed language
translated to Lisp.  Slightly smaller part is written
in Boot which is a syntactic sugar over Lisp or in Lisp
directly.  In principle Lisp code generated from Spad
should be free of type errors and some other factors
make other types of runtime errors less likely.

FriCAS may be used to perform rather heavy computations,
so optimization for speed is desirable. Real code
always have bugs so by FriCAS is normally compiled
using default Lisp compiler setting, which in most
cases gives reasonable speed and enough safety to
debug when problems show up.  However, users requested
way to control speed/safety compiler settings.
In particular they wanted to be able to compile
Spad files at lower safety settings than rest of
sources.  Given that users may know nothing about
Lisp whole business of declaring/proclaiming things,
calling compile etc, must be done by FriCAS.
The first implementation of the feature stored
desired setting in variable and then used 'proclaim'
inside a 'locally' form to apply the settings.  But
of course it did not work as intended, 'locally'
had no effect and setting were changed globally,
at least potentially affecting more files then wanted.

I considered wrapping whole content of generated file
into a 'locally' with proper declarations, but that
is unattractive because currently once generated
Lisp files can be reused, but putting declarations
inside files would made reuse harder.

--
                              Waldek Hebisch
hebi...@math.uni.wroc.pl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elias Mårtenson  
View profile  
 More options Feb 8, 10:52 pm
Newsgroups: comp.lang.lisp
From: Elias Mårtenson <loke...@gmail.com>
Date: Wed, 8 Feb 2012 19:52:47 -0800 (PST)
Local: Wed, Feb 8 2012 10:52 pm
Subject: Re: Compile file with specific optimization
Couldn't you set the optimisation settings in a variable which is then evaluated by the reader using something like (declaim #.*optimisation-settings)?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Feb 8, 11:21 pm
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Thu, 09 Feb 2012 05:21:28 +0100
Local: Wed, Feb 8 2012 11:21 pm
Subject: Re: Compile file with specific optimization

Elias Mårtenson <loke...@gmail.com> writes:
> Couldn't you set the optimisation settings in a variable which is then evaluated by the reader using something like (declaim #.*optimisation-settings)?

(proclaim *optimization-settings*) does it.

DECLAIM is just an eval-when wrapper over PROCLAIM.

(macroexpand '(declaim (safety 3)))
-->
(PROGN (EVAL-WHEN (:COMPILE-TOPLEVEL)
          (CCL::COMPILE-TIME-PROCLAMATION '((SAFETY 3)) NIL))
       (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE)
          (PROCLAIM '(SAFETY 3))))

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
S.Mandl  
View profile  
 More options Feb 9, 6:08 pm
Newsgroups: comp.lang.lisp
From: "S.Mandl" <StefanMa...@web.de>
Date: Thu, 9 Feb 2012 15:08:19 -0800 (PST)
Local: Thurs, Feb 9 2012 6:08 pm
Subject: Re: Compile file with specific optimization
As it seems that you are in control of the translation from Spad to
Lisp, I guess you just could generate any optimization settings users
are expecting.

I don't know if it is standardized behavior but I just made a small
experiment in SBCL and it appears that DECLAIMed optimization settings
in files that are given to COMPILE-FILE do not affect the global
optimization settings but are only used for the file being compiled.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Feb 11, 2:04 pm
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Sat, 11 Feb 2012 19:04:58 +0000 (UTC)
Local: Sat, Feb 11 2012 2:04 pm
Subject: Re: Compile file with specific optimization

"S.Mandl" <StefanMa...@web.de> wrote:
> I don't know if it is standardized behavior but I just made a small
> experiment in SBCL and it appears that DECLAIMed optimization settings
> in files that are given to COMPILE-FILE do not affect the global
> optimization settings but are only used for the file being compiled.

I would be happy to be shown to be wrong, but I think this is not portable
behaviour (though it is allowed I think). In fact if I read the description
of DECLAIM right, the previous sentence is correct.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Feb 13, 1:41 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@gmail.com>
Date: Sun, 12 Feb 2012 22:41:39 -0800 (PST)
Local: Mon, Feb 13 2012 1:41 am
Subject: Re: Compile file with specific optimization

On Saturday, February 11, 2012 8:04:58 PM UTC+1, Tim Bradshaw wrote:
> "S.Mandl" <StefanMa...@web.de> wrote:

> > I don't know if it is standardized behavior but I just made a small
> > experiment in SBCL and it appears that DECLAIMed optimization settings
> > in files that are given to COMPILE-FILE do not affect the global
> > optimization settings but are only used for the file being compiled.

> I would be happy to be shown to be wrong, but I think this is not portable
> behaviour (though it is allowed I think). In fact if I read the description
> of DECLAIM right, the previous sentence is correct.

I believe this is what ANSI mandates - I may be wrong, but I recall reading something like this.  Proclamations do not affect compilations across files.  Which kind of beats the purpose.

Cheers
--
MA


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Feb 13, 6:56 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Mon, 13 Feb 2012 11:56:43 +0000
Local: Mon, Feb 13 2012 6:56 am
Subject: Re: Compile file with specific optimization
On 2012-02-13 06:41:39 +0000, Marco Antoniotti said:

> Proclamations do not affect compilations across files.

I think chapter & verse is:

"If a use of this macro appears as a top level form in a file being
processed by the file compiler, the proclamations are also made at
compile-time. As with other defining macros, it is unspecified whether
or not the compile-time side-effects of a declaim persist after the
file has been compiled."

from DECLAIM.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
S.Mandl  
View profile  
 More options Feb 13, 3:30 pm
Newsgroups: comp.lang.lisp
From: "S.Mandl" <StefanMa...@web.de>
Date: Mon, 13 Feb 2012 12:30:10 -0800 (PST)
Local: Mon, Feb 13 2012 3:30 pm
Subject: Re: Compile file with specific optimization
On 13 Feb., 12:56, Tim Bradshaw <t...@tfeb.org> wrote:

> On 2012-02-13 06:41:39 +0000, Marco Antoniotti said:

> > Proclamations do not affect compilations across files.

> I think chapter & verse is:

> "If a use of this macro appears as a top level form in a file being
> processed by the file compiler, the proclamations are also made at
> compile-time. As with other defining macros, it is unspecified whether
> or not the compile-time side-effects of a declaim persist after the
> file has been compiled."

> from DECLAIM.

I agree of course and what I previously described was just a simple
experiment that I thought to be of interest in the context of this
thread.

As Waldek is generating the Lisp code that later is fed into compile-
file, I think he simply could generate the appropriate DECLAIM
statements according to what users specify. So I think there is no
real problem in his particular scenario; or I didn't understand the
description.

As for the problem in general, I think there are good arguments for
all kinds of behaviors and therefore I think it is a reasonable choice
that the effects are unspecified.

Regards,

Stefan Mandl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Duane Rettig  
View profile  
 More options Feb 14, 11:34 am
Newsgroups: comp.lang.lisp
From: Duane Rettig <du...@franz.com>
Date: Tue, 14 Feb 2012 08:34:55 -0800 (PST)
Local: Tues, Feb 14 2012 11:34 am
Subject: Re: Compile file with specific optimization
On Feb 13, 3:56 am, Tim Bradshaw <t...@tfeb.org> wrote:

> On 2012-02-13 06:41:39 +0000, Marco Antoniotti said:

> > Proclamations do not affect compilations across files.

> I think chapter & verse is:

> "If a use of this macro appears as a top level form in a file being
> processed by the file compiler, the proclamations are also made at
> compile-time. As with other defining macros, it is unspecified whether
> or not the compile-time side-effects of a declaim persist after the
> file has been compiled."

> from DECLAIM.

Yes, but even more general is 3.2.3.1.1, "Processing of Defining
Macros":

"It is not specified whether definitions made available in the
compilation environment are available in the evaluation environment,
nor is it specified whether they are available in subsequent
compilation units or subsequent invocations of the compiler. As with
eval-when, these compile-time side effects happen only when the
defining macros appear at top level."

So this provides guidance for all of the listed defining macros (and
if interpreted that way, any defining-macros created by the user),
_and_ it provides limitations, i.e. the long-term effect can only
happen when the form is at top-level.

Allegro CL uses the Environments Access module, and integrates it into
its compiler fully.  Whether it is a feature of that module by
necessity or of Allegro CL for convenience and programmability, we
distinguish those top-level forms by whether they are placed within an
eval-when which includes both :compile-toplevel (or compile) and :load-
toplevel (or load).  If both of these times are included within the
eval-when specification, the definition is promised to be carried
beyond the current compilation-unit (usually a compile-file, in most
cases).  Otherwise, if compile and load times of either style are not
both present, the scope of the definition dies with the compilation-
unit.  This guarantee provides some flexibility and control for
programmers who wish to guarantee what definitions last when, at least
when using Allegro CL.

Duane


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »