patchGNU Octave - Patches: patch #8395, Work-in-progress port of Octave...

 
 

patch #8395: Work-in-progress port of Octave JIT to libgccjit

Submitted by:  David Malcolm <dmalcolm>
Submitted on:  Fri 14 Mar 2014 10:52:30 PM UTC  
 
Category: NonePriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 18 Nov 2014 05:07:59 PM UTC, comment #8:

Ups, I forgot to post the link.

pull (or clone) from http://hg.octave.org/octave-nkf/ with bookmark gccjit

Here the direct link:
http://hg.octave.org/octave-nkf/rev/da90756b00e8
(The link becomes invalid once I push a new version)

Stefan Mahr <dac922>
Tue 18 Nov 2014 04:56:45 PM UTC, comment #7:

Thanks Stefan. Can you post your current patch please?

David Malcolm <dmalcolm>
Tue 18 Nov 2014 04:53:01 PM UTC, comment #6:

I rebased your patch and added some autoconf magic. Compiling is successful, but running octave leads to SIGABRT.

I built gccjit and octave with this script:

Stefan Mahr <dac922>
Wed 12 Nov 2014 05:03:01 PM UTC, comment #5:

FWIW I merged the libgccjit branch into gcc svn yesterday, so the relevant code this depends on should be in GCC 5 onwards:
https://gcc.gnu.org/ml/gcc/2014-11/msg00163.html

David Malcolm <dmalcolm>
Tue 29 Jul 2014 03:23:09 PM UTC, comment #4:

> * there's a name-mangling issue with gripe_divide_by_zero,
> which for me gets name-mangled by the C++ compiler (to
> "_Z20gripe_divide_by_zerov").
> For now I have a horrible hack I'm applying on the libgccjit
> side which
> special-cases this, and applies the mangling when referencing
> this symbol (am attaching it)


I had a look at fixing this properly from the libgccjit end, by having a flag to enable name-mangling on a function's name, but it's not going to be easy (the name-mangling support in gcc is all inside the C++ frontend, so it's non-trivial to refactor that out).

I think the simplest solution for this is to wrap the decl of
gripe_divide_by_zero
in gripes.h within an extern "C" thusly:
extern "C" {
extern OCTINTERP_API void
gripe_divide_by_zero (void);
}
though I'm not sure if that's going to require changes to the LLVM JIT code.

David Malcolm <dmalcolm>
Mon 17 Mar 2014 08:29:30 PM UTC, comment #3:

Thanks; yes, the type-inference issue appears to be:
https://savannah.gnu.org/bugs/?41312

David Malcolm <dmalcolm>
Sun 16 Mar 2014 11:23:38 PM UTC, comment #2:

> ASSERT errors for: assert (jit_failure_count,0)
> in type-inference on the id (1, 2) I believe, before my code;
> do other people see this?


Yes, it's the same for LLVM JIT

Stefan Mahr <dac922>
Sun 16 Mar 2014 12:40:46 AM UTC, comment #1:

Max, could you comment a little on this?

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Fri 14 Mar 2014 10:52:30 PM UTC, original submission:

I've been experimentally porting Octave's existing JIT to libgccjit:
http://gcc.gnu.org/wiki/JIT

I thought it was time I posted what I have. It compiles and runs, though
there are plenty of issues.

Notes:
* I split out HAVE_LLVM to HAVE_JIT, HAVE_LLVM, and HAVE_GCCJIT

* both the LLVM and gccjit implementations are built within the same
build. This is clearly overkill, but is handy for debugging in that
one can compare what each of the two implementation produces.

The resulting preprocessor gunk is deeply ugly. Perhaps it could be
simplified by making choice of JIT backend be a configure-time thing,
rather than trying to support both within one process.

* jit.tst runs, but I had to hack out some of the tests for now. It
tries to run both the LLVM and gccjit compiler on the IR. It then
tries to run the gccjit-built code, if that succeeded; failing that
the LLVM-built code.

It fails near the end here:
jit fail: Too many parameter to function
***** testif HAVE_JIT
jit_failure_count (0)
assert (id (1), 1);
assert (id (1+1i), 1+1i);
assert (id (1, 2), 1);
assert (jit_failure_count, 0);
!!!!! test failed
ASSERT errors for: assert (jit_failure_count,0)
in type-inference on the id (1, 2) I believe, before my code; do other
people see this?

* I've only implemented JIT-compilation of loops for now, not functions.
I hope the latter is fairly easy to add, but I wanted to post
something.

* lots of FIXMEs, TODOs and other cruft; sorry (e.g. the configure.ac
"test", which for now just hardcodes a location of a libgccjit
checkout)

* libgccjit currently requires function names to be valid C
identifiers, so I changed some functions to obey this restriction

* there's a name-mangling issue with gripe_divide_by_zero, which for me
gets name-mangled by the C++ compiler (to "_Z20gripe_divide_by_zerov").
For now I have a horrible hack I'm applying on the libgccjit side which
special-cases this, and applies the mangling when referencing this
symbol (am attaching it)

Clearly this isn't ready yet, but I wanted some feedback from the Octave
maintainers on the direction of this.

David Malcolm <dmalcolm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #30907:  horrible-name-mangling-hack-to-libgccjit.patch added by dmalcolm (781B - text/x-patch - Horrible name-manging hack to patch libgccjit to mangle gripe_divide_by_zero at the receiving end)
file #30906:  port-of-octave-jit-to-libgccjit.patch added by dmalcolm (121kB - text/x-patch - Work-in-progress port of Octave JIT to libgccjit (patch against "default"))

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dac922 (Posted a comment)
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by jordigh
  • -unavailable- added by jordigh
  • -unavailable- added by dmalcolm (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 16 Mar 2014 12:40:46 AM UTCjordighCarbon-Copy-=>Added -unavailable-
      Carbon-Copy-=>Added -unavailable-
    Fri 14 Mar 2014 10:54:37 PM UTCdmalcolmAttached File-=>Added horrible-name-mangling-hack-to-libgccjit.patch, #30907
    Fri 14 Mar 2014 10:52:30 PM UTCdmalcolmAttached File-=>Added port-of-octave-jit-to-libgccjit.patch, #30906

    Back to the top


    Powered by Savane 3.1-cleanup