#6391: libGAP! -- create a Cython library interface to gap
------------------------------------------------------------------------+---
Reporter: was |
Owner: was
Type: enhancement |
Status: needs_review
Priority: major |
Milestone: sage-4.7
Component: interfaces |
Keywords:
Work_issues: |
Upstream: N/A
Reviewer: Dima Pasechnik, Ivan Andrus, Volker Braun, William Stein |
Author: Dima Pasechnik, Ivan Andrus, Volker Braun, William Stein
Merged: |
Dependencies:
------------------------------------------------------------------------+---
Comment(by was):
A relevant status update and overview from Volker:
Hi Stephen,
I wanted to contact you for a while about whether and how to integrate
the C GAP library interface that we wrote. I think it would be great
to have a well-defined shared library interface, and it sounds like
you are interested in that as well. We have a working prototype at
http://trac.sagemath.org/sage_trac/ticket/6391 that just needs review
as far as I am concerned. It doesn't have a nicely abstracted
interface, but it works for Sage purposes. Let me comment on the
points in your pdf:
1) IO: we want to inject input and catch output, so we can evaluate
input strings and parse output strings. For this, we just patched
SyFgets() / PutChrTo().
2) For errors, just send a signal from the shared library. We patched
ReadEvalError() to call abort(). The user of the shared library can
then install their own signal handler if they want to catch that. I
don't think entering the break/eval loop is particularly useful in a
shared library, we just set BreakOnError = 0.
3) similarly, if the user of the library wants to interrupt a GAP
computation she can just signal SIGINT etc.
4) To keep objects alive, the Sage library interface just creates a
global GAP record (which aren't garbage collected)
libgap_owned_objects = GVarName( "libgap_owned_objects" );
AssGVar(libgap_owned_objects, NEW_PREC(0))
and then references any objects that are wrapped by libGAP:
libgap_owned_objects_counter += 1
self.libgap_owned_objects_rnam = RNamIntg(libgap_owned_objects_counter)
AssPRec(VAL_GVAR(libgap_owned_objects),
self.libgap_owned_objects_rnam, self.value)
For simplicity we implemented this in Cython, but that should probably
be moved in the C library interface.
5) Memory management: I replaced the sbrk with a malloc'ed workspace.
Added advantage: you can then use valgrind. I think valgrind disallows
large sbrk() calls to force the libc malloc implementation to avoid
it. For now, the libGAP workspace size has to be fixed at
initialization. This isn't ideal but Dima thought that you have some
long-term plans for switching to a different garbage collector. Maybe
you can tell us more about that.
6) We didn't hit any name collisions in Sage, so its not an urgent
issue. I agree that eventually only the relevant symbols should be
exported by the shared library but GAP generally uses less common
names. Most C code doesn't use CamelCase, for starters.
7) I haven't tried loading modules from within libGAP.
8) I didn't encounter any problems with GMP. Sage uses MPIR.
In any case, I'm very interested in getting a library implementation
upstream and can help with that. I'm currently travelling around for
conferences and will be back in DIAS in Dublin for more than a couple
of days starting in August.
Best wishes,
Volker
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6391#comment:66>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.