On Tue, Apr 7, 2015 at 9:48 AM, Peter Bex <pe...@more-magic.net> wrote: >> Even when editing the C code, I wrap it in chicken and dynamically >> load it over and over again as I refine the inner loop. > > Hey, that sounds interesting! How do you do that?
This is a whole different topic from the performance debate. I do the following and "It Works For Me": I work from a chicken REPL. I run the chicken interpreter with the linenoise egg: http://wiki.call-cc.org/eggref/4/linenoise An alternative is to use rlwrap, but the result is that I end up with a csi prompt with readline support: #;1> In theory, it would be even better to run csi in an emacs buffer, but I never adapted to that habit. >From the prompt, I load a set of data into memory, and I put it in srfi-4 vectors in the interpreter: (define big-vector-a ... ) (define big-vector-b ... ) That is my starting state: a scheme prompt which represents a window into a context holding some utility functions and lots of packed binary data. There are three more pieces to the puzzle: Makefile - compiles and links things innerloop.c - the file with the inner loop function with a "for" loop inside example.scm - the wrapper for example.c *** Makefile looks something like: libexample.so: example.o ld -shared -o example.so example.o $(LIBDIR) -lchicken %.o: %.c gcc -c -fPIC $^ $(INCDIR) example.c: innerloop.c chicken example.scm *** innerloop.c looks like: int innerfunc(unsigned char *dat){ for( ... ){ ... } } *** and example.scm: (declare (unit example)) (foreign-declare "#include \"innerloop.c\" ") (define innerwrap (lambda (mybigvector) ((foreign-lambda int innerfunc u8vector) mybigvector))) ************************* and then from my prompt, I run: #;1> (load-library 'example "libexample.so") #;2> (innerwrap big-vector-a) Then, edit innerloop.c and type "make" again and then hit the up arrow and the enter key: #;3> (load-library 'example "libexample.so") #;4> (innerwrap big-vector-a) I do this over and over again until the C code is fast. -Rafael _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users