Re: Performance assistance / advice
"Tim Bradshaw (as tfb at tfeb dot org)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
Well, it turns out I am a moron (or: my C is even rustier than I thought). I'd made my C function be callable from LW so I could numerically check it was sane (or they were both insane in the same way). There were small differences, which I had assumed were because -O3 was licensing the C compiler to compile code which was sufficiently different. But then they persisted even if I compiled with -g and no optimisation at all. And it turns out they were small because gravity is weak and the system evolves rather little in some thousands of seconds of simulated time. ... Because 'next' is 'continue' not 'break' in C, so my inner loop was getting abandoned half way through. So, after fixing that the systems have zero distance between them, because the C one is now actually doing the work it needs to do. And: C version with -O3: 9.4GFLOPS single-threaded Best Lisp version: 8.1GFLOPS single-threaded C beats Lisp by under 20%. I would not be surprised if some more can be extracted from the Lisp. So if you're writing general-purpose floating-point code (ie you're not explicitly calling GPUs or using vectorisation intrinsics or whatever) then you do not need to write it in C: Lisp compilers produce code which is within epsilon as fast, and you do not die of terrible C-related brain diseases while writing the code. --tim _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html