Ticket #258 (assigned enhancement)

Opened 2 years ago

Last modified 4 months ago

[with spkg, positive review] gp2c -- integrate into SAGE

Reported by: was Assigned to: pdenapo (accepted)
Priority: major Milestone: sage-3.4
Component: interfaces Keywords: editor_mabshoff
Cc:

Description (Last modified by mabshoff)

Create a command in SAGE based on the gp2c program of Bill Alombert.

I envision something like this:

sage: gp = Gp()   # new instead of gp interacitve interpreter
sage: gp.ceval("""
a block of code
""")
...
   at this point the gp2c translator is called and the resulting
   shared object library is loaded into this instance of gp.
...
sage: gp('code that uses new functions defined in the above block of code')
          resulting code runs faster since it is compiled. 

This will give yet another way of writing fast compiled code from interactive/interpreter SAGE. The ways would then be:

  • SageX
  • weave
  • gp2c

The web page for gp2c:

http://pari.math.u-bordeaux.fr/download.html#gp2c

The spkgs by pdenapo can be found at

Attachments

spkg-install.patch (431 bytes) - added by pdenapo on 01/07/2008 08:06:13 PM.
A patch showing the required modifications to spkg-install in pari package
spkg-install (304 bytes) - added by pdenapo on 01/07/2008 08:30:17 PM.
spkg-install file for gp2c
spkg-install-unified-package.patch (0.7 kB) - added by pdenapo on 01/15/2008 07:21:14 AM.
spkg-install file for the unified pari/gp2c package
README.Sage (319 bytes) - added by pdenapo on 01/15/2008 07:22:44 AM.
Readme file for the unified pari/gp2c package
gp2c_integration.patch (4.7 kB) - added by pdenapo on 01/15/2008 07:35:42 AM.
patch: gp2c integration into sage

Change History

09/06/2007 06:59:04 AM changed by mabshoff

  • milestone set to sage-3.

01/07/2008 08:03:22 PM changed by pdenapo

  • owner changed from was to pdenapo.
  • status changed from new to assigned.

I've succeded in creating a gp2c package (for gp2c-0.0.5pl6), that I'm uploading. In order for the script gp2c-run to work, it is needed a miror modification to the pari package so that the file pari.cfg gets installed.

I will try to do the integration with Sage, next (probably more difficult)

I've upload it to

http://pdenapo.googlepages.com/gp2c-0.0.5pl6.spkg

I'm submitting also the correspondig spkg-install file.

Here is my modified pari package:

http://pdenapo.googlepages.com/pari-2.3.3.p1.spkg

I'm submitting also: the patch needed for modifying spkg-install

Note: gp2c uses perl for compilation, if found. It would be possible to pass --with-perl=no parameter to configure, if we don't want that (and use the precompiled descriptions for pari-2.3)

01/07/2008 08:06:13 PM changed by pdenapo

  • attachment spkg-install.patch added.

A patch showing the required modifications to spkg-install in pari package

01/07/2008 08:30:17 PM changed by pdenapo

  • attachment spkg-install added.

spkg-install file for gp2c

01/07/2008 08:31:36 PM changed by pdenapo

My second version of the attachment corrects a minor bash syntax-error (the packages worked either way, but fails to report an error message if pari.cfg was not there)

01/15/2008 07:19:14 AM changed by pdenapo

By suggestion from MichaelAbshoff? (on irc), I've created a unified package for pari ang gp2c, you can downloaded at

http://pdenapo.googlepages.com/pari-2.3.3.p2.spkg

I agree with him in that his is a better solution since gp2c needs some changes in Pari (installing configuration file), and includes precompiled descriptions for an specific version of pari).

This new version uses --with-perl=no when compiling gp2c (used precompiled descriptions for pari-2.3)

I also have included a README.Sage file explaning this.

01/15/2008 07:21:14 AM changed by pdenapo

  • attachment spkg-install-unified-package.patch added.

spkg-install file for the unified pari/gp2c package

01/15/2008 07:22:44 AM changed by pdenapo

  • attachment README.Sage added.

Readme file for the unified pari/gp2c package

01/15/2008 07:34:54 AM changed by pdenapo

I submit a patch for the integration of gp2c into sage

This patch implements two functions for the Gp object: gp2c_compile_file and gp2c

The first one compiles a file using gp2c-run and load its into the instance of the Gp intepreter asociated to the Gp object. (is like the ceval function proposed in the description at the begining, but I think that gp2c would be a better name). Also note that you cannot use it to evaluate arbitrary gp expressions, just to define functions (in a syntax valid for gp2c, for example: avoid C identifiers)

You can use it to do something like:

G=Gp() G.gp2c('f(x)=2*x') G.eval('f(2)') '4'

The second one takes a string, save it to a temporary file and compiles it using gp2c_compile_file

The temporary files are deleted when the Gp object is destroyed.

(This patch also generalizes the function delete_tmpfiles() from misc/misc.py since I need it to delete the temporary files that gp2c patch creates)

01/15/2008 07:35:42 AM changed by pdenapo

  • attachment gp2c_integration.patch added.

patch: gp2c integration into sage

01/15/2008 07:36:38 AM changed by pdenapo

  • milestone changed from sage-feature to sage-2.10.2.

01/15/2008 01:55:52 PM changed by was

This is a comment *on this ticket* from Bill Allombert, who is the author of gp2c:

On Tue, Jan 15, 2008 at 08:34:43AM -0800, William Stein wrote:
> You might have comments about this:
>
> http://trac.sagemath.org/sage_trac/ticket/258

One issue I see is that you can load modules in GP but not unload them.

I do not think it is necessary to merge pari and gp2c. If you install
PARI properly (with make install), you get all the files needed for
compiling GP2C:
$prefix/lib/pari/pari.cfg
$prefix/share/pari/pari.desc
There is no need to change PARI itself, you just need to add a
dependency to GP2C.
Since PARI and GP2C have very different release schedule, merging
them will cause you unnecessary trouble.

Cheers,
Bill.

01/15/2008 02:44:17 PM changed by pdenapo

About merging pari and gp2c: is like you prefer, my first idea was to have two separate packages (my integration patch works with whatever aproach you choose)

Michael told me that integrating them could be better, to have less packages. (and since if we put gp2c as unstable package, there is no way in which it can trigger a pari package update _which would be needed since it expects the pari.cfg to be installed)

However, keeping two separeted packages could make easier to update them when a new version of one of them is released, since as Bill says they have a very different release schedule. Perhaps it is better to follow his advice.

About unloading modules, I don't know if that would be possible. Loading is implemented using the "install" function in gp, is there a function like uninstall in Gp?

02/14/2008 02:46:07 PM changed by mabshoff

  • summary changed from gp2c -- integrate into SAGE to [with spkg] gp2c -- integrate into SAGE.

Okay, after some fundamental discussion at SD7 I would now suggest to have individual packages.

Cheers,

Michael

05/27/2008 08:00:19 AM changed by pdenapo

To use this feature, you need to:

- apply the gp2c-instegration patch to sage. - install my pari spkg (which installs pari.cfg, needed for gp2c to compile) and then the gp2c spkg

07/07/2008 05:46:44 AM changed by mabshoff

  • keywords set to editor_mabshoff.
  • summary changed from [with spkg] gp2c -- integrate into SAGE to [with spkg, needs review] gp2c -- integrate into SAGE.

This has been sitting around for way too long, so let's sort it out soon. I am making myself editor of this ticket.

Cheers,

Michael

07/21/2008 12:37:18 PM changed by cremona

I installed this with no problem, tried the examples and some of my own and it seems to work fine. I only tried one-liners.

I have a lot of gp experience and also some with gp2c.

I think it would be excellent to have this in Sage. +1

08/27/2008 01:19:32 AM changed by mabshoff

  • description changed.
  • summary changed from [with spkg, needs review] gp2c -- integrate into SAGE to [with spkg, positive review] gp2c -- integrate into SAGE.

Hi,

I have deleted the spkgs as attachment and instead linked them in the ticket description. I consider John's review a positive one, so I am changing the subject here. But we need a formal vote on sage-devel to get gp2c into the core of Sage.

Cheers,

Michael