Calling SBCL from C with array arguments 
Author Message
 Calling SBCL from C with array arguments

    Clemens> Having written some functions in SBCL, I want to call them from a C++
    Clemens> (or fortran90, for that matter) program.  The arguments are arrays of

That, I think, is a bit problematical.  It will be very hard for a C++
*program* to call functions in SBCL.  But if you have C++ *routines*
that want to call functions in SBCL, you might be able to do that.

    Clemens> to the CL code and get back three arrays.  How can I do this in SBCL
    Clemens> (or CMUCL)?  The documentation is a bit sparse on this matter.  Any
    Clemens> help is appreciated.

The CVS versions of CMUCL (see the snapshots directory in the download
area from www.cons.org/cmucl), there is support for callbacks so
foreign functions can call Lisp functions.  It's documented in the
CMUCL User's manual with examples.

Perhaps this will do what you want.

Ray



Sun, 29 Jan 2006 22:05:02 GMT  
 Calling SBCL from C with array arguments

Quote:

> Having written some functions in SBCL, I want to call them from a C++
> (or Fortran90, for that matter) program.  The arguments are arrays of
> doubles with some 50,000 elements.  I want to pass two or three arrays
> to the CL code and get back three arrays.  How can I do this in SBCL
> (or CMUCL)?  The documentation is a bit sparse on this matter.  Any
> help is appreciated.

Take a look at this

http://www.cons.org/cmucl/doc/tcl-callback.html

which is similar in the sense that a call from C to cmucl has to be
made, and once you can do that you can do pretty much everything
else. One of the many proyects I have in queue is writing (and
documenting) a smaller example, and I have some code which I can post
later today (I'm currently at my office, said snippet is at home).

But you shoud be aware that you may have to run the C++/F90/F70
program from cmucl/sbcl, which may or may not be a problem.

An alternative would be to use shmget(2) & co. to share some memory
among the programs and a socket to comunicate.

I am assuming here that speed is a mayor concern for you. If not, then
there are a few solutions which are simpler and probably quite fast
too. For example, data can be passed around by writing it to text
files, or can be passed in binary format through a socket, etc.

I hope it helps...



Sun, 29 Jan 2006 22:24:46 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. array section as actual argument where dummy argument is INTENT(OUT)

2. Detecting uninitialized subroutine argument used as array bound of another argument

3. Subroutine arguments: arrays vs array slices

4. Array intrinsics with zero-size array argument

5. to CS: or not to CS: in F-PC assembler

6. Call for programs (CS investigation)

7. Array arguments to verbs containing loops : A confused Newbies Question

8. Array arguments to verbs containing loops : A confused Newbies

9. Passing array as argument to function

10. Arrays as method argument ?

11. Arrays as arguments

12. how to use an array as subroutine arguments?

 

 
Powered by phpBB® Forum Software