[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Fw: [ruby-core:23371] Re: Ruby/DL Documentation

Aston

5/7/2009 4:25:00 PM

i guess this thread is more appropriate in ruby-talk rather than polluting =
ruby-core=0A=0A=0A=0A----- Forwarded Message ----=0AFrom: Aston <blackapach=
e512-ticket@yahoo.com>=0ATo: ruby-core@ruby-lang.org=0ASent: Wednesday, 6 M=
ay, 2009 11:34:36 PM=0ASubject: [ruby-core:23371] Re: Ruby/DL Documentation=
=0A=0A=0Athanks a lot tad.bochan@bnpparibas.com and sh@sheepman.sakura.ne.j=
p=0A=0Atad seems to be using 1.8.x, i am using ruby19 on FreeBSD7.2=0A=0A[d=
iesalunix@raptor ~]$ uname -a=0AFreeBSD raptor 7.2-PRERELEASE FreeBSD 7.2-P=
RERELEASE #1: Sun Mar 29=0A19:18:27 UTC 2009 root@raptor:/usr/obj/usr/s=
rc/sys/ARGON18 amd64=0A[diesalunix@raptor ~]$ ruby19 -v=0Aruby 1.9.2dev (2=
009-05-02 trunk 23326) [x86_64-freebsd7.2]=0A=0Aas suggested by sh@ test/dl=
/test_*.rb are good (not gr8!) source for learning, but given the fact ther=
e exists no other code using dl elsewhere I am very happy I found them. tha=
nks sh@=0A=0AWhile googling around I discovered ruby-ffi (http://k...
projects/ruby-ffi/pages/Home), and it seems to be much more clean and compl=
ete solution. It is supported by other VMs as well. I would have prefered t=
o be with dl since it is part of standard ruby C implementation but it is v=
ery difficult to use(u got to have lot of time and little black magic), cod=
e using it is almost non-existent and /dev/null documentation=0A=0Awhen rea=
ding about ruby-ffi elsewhere it appears very promising, what is its future=
in regard to ruby's C implementation ? will it ever be part of stdlib ? it=
appears it is still taking shape but by and large stable=0A=0AAston=0A=0A=
=0A=0A=0A________________________________=0AFrom: "sh@sheepman.sakura.ne.jp=
" <sh@sheepman.sakura.ne.jp>=0ATo: ruby-core@ruby-lang.org=0ASent: Tuesday,=
5 May, 2009 2:06:09 PM=0ASubject: [ruby-core:23359] Re: Ruby/DL Documentat=
ion=0A=0AHi,=0A=0AIt is helpful to read test/dl/test_*.rb in ruby-1.9.tar.g=
z.=0AYou have to master pack and unpack anyway.=0AThe following is an examp=
le.=0A=0A$ cat sum.c=0Adouble sum(double *arry, int len)=0A{=0A double ret=
=3D 0;=0A int i;=0A for(i =3D 0; i < len; i++){=0A ret =3D ret + arry=
[i];=0A }=0A return ret;=0A}=0A=0A$ gcc -shared sum.c -o libsum.so=0A=0A$=
cat d.rb=0Arequire 'dl/import'=0Amodule M=0A extend DL::Importer=0A dllo=
ad './libsum.so'=0A extern 'double sum(double*, int)'=0Aend=0Ap M.sum([2.0=
, 3.0, 4.0].pack("d*"), 3)=0A=0A$ ruby-1.9 -v d.rb=0Aruby 1.9.2dev (2009-05=
-02 trunk 23326) [i686-linux]=0A9.0=0A=0A=0A2009/5/4 Aston <blackapache512-=
ticket@yahoo.com>:=0A> Hello,=0A>=0A> recently i have been trying to learn =
and use dl library. while searching i=0A> found this excellent link=0A> htt=
p://www.jbrowse.com/text/rdl_en.html=0A>=0A> unfortunately it is specific t=
o 1.8.x=0A>=0A> i wonder how people here use DL, since it is very scarcely =
documented. i=0A> have been trying to=0A> hack around ./ext/dl/*.c files bu=
t i have gained very little usable=0A> information.=0A>=0A> ok, my question=
is about passing an array from ruby to some native libraries=0A> (IPP(http=
://software.intel.com/en-us/intel-ipp/) to be specific)=0A> on windows. yes=
i about other alternatives, i could embed ruby in my app and=0A> do whatev=
er, there is gr8 support there=0A> but this is about quickly loading and us=
ing native libraries via dynamic=0A> loader.=0A>=0A> consider code below=0A=
> some_fast_math_function( float* array, int len);=0A>=0A> then how to pass=
'array' argument from ruby ?=0A> i tried this=0A>=0A> require 'dl'=0A>=0A>=
module NativeLibs=0A> # do the job for accessing some_fast_math_function=
=0A> end=0A>=0A> array =3D DL.malloc(size)=0A> NativeLibs.some_fast_math_fu=
nction( array, size) # crashes :(=0A>=0A> some how sucess is elusive for me=
, this crashes(core dumps) for me, i am=0A> sure this is due to my inexperi=
enced stunts with DL=0A>=0A> Aston=0A>=0A>=0A> ____________________________=
____=0A> Now surf faster and smarter ! Check out the new Firefox 3 - Yahoo!=
Edition *=0A> Click here!=0A=0A=0A________________________________=0A Expl=
ore your hobbies and interests. Click here to begin.=0A=0A=0A Cricket =
on your mind? Visit the ultimate cricket website. Enter http://bet...
yahoo.com