Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4617 > unrolled thread

RubyInline trouble

Started byMartin Hansen <mail@maasha.dk>
First post2011-05-16 09:53 -0500
Last post2011-05-17 04:16 -0500
Articles 4 — 3 participants

Back to article view | Back to comp.lang.ruby


Contents

  RubyInline trouble Martin Hansen <mail@maasha.dk> - 2011-05-16 09:53 -0500
    Re: RubyInline trouble Jeff Dallien <jeff@dallien.net> - 2011-05-16 15:08 -0500
    Re: RubyInline trouble Ryan Davis <ryand-ruby@zenspider.com> - 2011-05-16 17:28 -0500
    Re: RubyInline trouble Martin Hansen <mail@maasha.dk> - 2011-05-17 04:16 -0500

#4617 — RubyInline trouble

FromMartin Hansen <mail@maasha.dk>
Date2011-05-16 09:53 -0500
SubjectRubyInline trouble
Message-ID<c905efc4d373fe6f8d5502a268752dfb@ruby-forum.com>
Hi all,


I am battling with RubyInline to try the following benchmark:

http://pastie.org/1910786

However, it it appears that I am not allowed to define stuff or
initialize an array at the top level in C.

How do I get this to work?

Cheers,


Martin

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [next] | [standalone]


#4628

FromJeff Dallien <jeff@dallien.net>
Date2011-05-16 15:08 -0500
Message-ID<BANLkTikg7JKNHQizU9CMVEvK4rH7wze80Q@mail.gmail.com>
In reply to#4617
On Mon, May 16, 2011 at 10:53 AM, Martin Hansen <mail@maasha.dk> wrote:
> Hi all,
>
>
> I am battling with RubyInline to try the following benchmark:
>
> http://pastie.org/1910786
>
> However, it it appears that I am not allowed to define stuff or
> initialize an array at the top level in C.
>

The #defines do cause the "Can't find signature" warning. It's a check
that fails, but RubyInline continues. The real error ('equal'
undeclared) is because RubyInline is putting your two functions in
separate C files and compiling them independently. You should put them
in the same file by not creating a second 'builder' object. Like this:
http://pastie.org/1912520 (see line 84).

Jeff

> How do I get this to work?
>
> Cheers,
>
>
> Martin
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

[toc] | [prev] | [next] | [standalone]


#4642

FromRyan Davis <ryand-ruby@zenspider.com>
Date2011-05-16 17:28 -0500
Message-ID<D3A82838-6BF5-4586-8341-D833445DDCEF@zenspider.com>
In reply to#4617
On May 16, 2011, at 07:53 , Martin Hansen wrote:

> Hi all,
> 
> 
> I am battling with RubyInline to try the following benchmark:
> 
> http://pastie.org/1910786
> 
> However, it it appears that I am not allowed to define stuff or
> initialize an array at the top level in C.
> 
> How do I get this to work?

builder.c is ONLY for a C function.

Define static declarations and the like with builder.prefix or builder.add_static.

ri Inline::C for more info.

[toc] | [prev] | [next] | [standalone]


#4663

FromMartin Hansen <mail@maasha.dk>
Date2011-05-17 04:16 -0500
Message-ID<937cc4915ef2f73508e7f4638447a02e@ruby-forum.com>
In reply to#4617
This seem to work:

http://pastie.org/1915197

I hope, I build the code the correct way?

Also, the speed increase is roughly 1-fold. I am a bit puzzled that Ruby
on its own is a tad slow on array accession and bit wise operations. But
when is a speed increase big enough to justify moving to Inline C?

Btw, is there a method to pretty print the resulting C code? That would
be nice for inspection.

Morever, I think RubyInline is a bit under documented. The Perl Inline
module comes with a very nice cookbook:

http://search.cpan.org/~sisyphus/Inline-0.48/C/C.pod
http://search.cpan.org/~sisyphus/Inline-0.48/C/C-Cookbook.pod


This RubyInline tool is really cool I must say!


Cheers,


Martin

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web