problem with ruby1.8 and OpenMP in Ruby extension: shared object cannot be dlopen()'ed

Discussion in 'Ruby' started by Rudi Cilibrasi, Oct 4, 2007.

  1. Hi everybody,

    I am the main developer of CompLearn, an open-source machine learning
    library
    for scientific researchers. I have written a Ruby binding for
    CompLearn
    called complearn-ruby. It has worked fine in the past. But it has a
    problem
    ever since I converted the base library (libcomplearn) to use OpenMP
    for
    multicore processor support. If I just try to use the simplest
    approach that
    has worked in the past in my extconf.rb, I get the following problem
    when I
    try to require the C-extension Ruby binding complearn4r.so and use the
    multicore part of the system:

    ruby: symbol lookup error: /usr/lib/libcomplearn.so.1: undefined
    symbol: GOMP_parallel_start

    To try to fix this error,

    I adjusted the extconf.rb to include this line:

    have_library('gomp', 'main')

    And rebuilding works but running a simple test program (just trying to
    require
    complearn) fails in a different way than before:

    /home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/
    complearn4r.so: libgomp.so.1: shared object cannot be dlopen()ed - /
    home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/
    complearn4r.so (LoadError)
    from /home/cilibrar/rlc/projects/complearn/complearn-ruby/lib/
    complearn.rb:2
    from tests/t2.rb:1:in `require'
    from tests/t2.rb:1

    I don't know what else to try and wonder if anybody else can offer a
    clue?

    I have tried for a long time experimenting with CFLAGS, CPPFLAGS,
    LDFLAGS,
    and -fopenmp among other settings but I still cannot seem to figure
    out
    a solution. I have put the source code for this problem up at

    http://cilibrar.com/~cilibrar/projsup/rubbug/libcomplearn-1.0.4.tar.gz
    and
    http://cilibrar.com/~cilibrar/projsup/rubbug/libcomplearn-ruby-1.0.4.tar.gz

    I would appreciate greatly any help anybody can offer in this
    problem. Thank
    you for your attention,

    Rudi
     
    Rudi Cilibrasi, Oct 4, 2007
    #1
    1. Advertising

  2. Rudi Cilibrasi

    gga Guest


    >
    > /home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/
    > complearn4r.so: libgomp.so.1: shared object cannot be dlopen()ed - /


    That probably means you have some undefined symbol most likely due to
    a missing library during link time.

    That being said, even if you manage to load and compile the stuff,
    wrapping an OpenMP library is *probably* asking for trouble as ruby is
    a single threaded application that relies on knowing how and where the
    stack is. OpenMP will generate new threads behind your back, each one
    with its own stack. Any call from those threads back to ruby will
    probably lead to random crashes or memory issues.
     
    gga, Oct 5, 2007
    #2
    1. Advertising

  3. Thanks for this excellent suggestion. You inspired me to write a much
    superior stdin/stdout style connector instead using pipes that is far
    more flexible in many ways:

    http://hg.cilibrar.com/complearn-uncd/

    Best regards,

    -r.

    On 10/4/07, gga <> wrote:
    >
    > >
    > > /home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/
    > > complearn4r.so: libgomp.so.1: shared object cannot be dlopen()ed - /

    >
    > That probably means you have some undefined symbol most likely due to
    > a missing library during link time.
    >
    > That being said, even if you manage to load and compile the stuff,
    > wrapping an OpenMP library is *probably* asking for trouble as ruby is
    > a single threaded application that relies on knowing how and where the
    > stack is. OpenMP will generate new threads behind your back, each one
    > with its own stack. Any call from those threads back to ruby will
    > probably lead to random crashes or memory issues.
    >
    >
    >



    --
    "We can try to do it by breaking free of the mental prison of
    separation and exclusion and see the world in its interconnectedness
    and non-separability, allowing new alternatives to emerge." -- after
    Vandana Shiva
     
    Rudi Cilibrasi, Oct 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rudi Cilibrasi

    problem with OpenMP in Ruby extension

    Rudi Cilibrasi, Oct 3, 2007, in forum: Ruby
    Replies:
    4
    Views:
    280
    Rudi Cilibrasi
    Oct 6, 2007
  2. Chauk-Mean P.

    Ruby 1.9.0 problem with DL.dlopen

    Chauk-Mean P., Jan 10, 2008, in forum: Ruby
    Replies:
    1
    Views:
    115
    Chauk-Mean P.
    Jan 18, 2008
  3. Iñaki Baz Castillo
    Replies:
    14
    Views:
    257
    Iñaki Baz Castillo
    Apr 5, 2009
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    667
    Rick DeNatale
    Dec 3, 2009
  5. Vm Vm

    Ruby API and OpenMP

    Vm Vm, Jan 27, 2010, in forum: Ruby
    Replies:
    0
    Views:
    201
    Vm Vm
    Jan 27, 2010
Loading...

Share This Page