[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hello from a new user interested in shipping applications



Paul Fernhout writes:
> On Numerical performance. This does appear to be an issue for further
> consideration. It looks like I would then need to improve this area
> myself
> (similar to the library for Gambit or NumPy for Python) if I was to use
> MzScheme for numerical work. Or alternatively, I could generate C code
> to do number crunching from Scheme with type hints. Either of these
> might be doable with a reasonable effort (perhaps leveraging off the
> approach done for say Python's NumPy) -- assuming the other parts of
> the system work well enough for my purposes.

I've just looked at NumPy, and it appears that they've written some C
code to do the basic matrix operations in reasonable time, and then
interfaced to the Netlib (http://www.netlib.org/) libraries for all
the hard algorithms. You could certainly follow this approach in
MzScheme, and get respectable performance.

More interesting is the second approach you mention - generating C
code with(out) type hints. I think almost all the basic research has
been done to get great numerical performance in Scheme. The following
pointers may help:

- Andrew Wright's soft scheme system for infering types (no need for
type hints. See
http://www.intertrust.com/star/wright/personal-index.html) This would
be doubly useful if a distinction is made between fixnums and bignums

- Unboxing of floats (e.g: http://www-fp.dcs.st-and.ac.uk/~kh/papers/pseudoknot/subsubsection3_5_6_4.html)

- It should be possible to avoid most index out-of-bounds checks by
inducing the range of index variables. I don't know if anyone has done 
this. I suppose it would require adding invariant properties to the
type system, so that the compiler could deduce any variable in the
range [0 (vector-length)) doesn't require an out-of-bounds check.

Finally, I read somewhere that researchers in Aspect-Orientated
Programming (http://www.parc.xerox.com/csl/projects/aop/
http://www.acl.lanl.gov/iscope97/papers/lamping.html
http://www.diku.dk/research-groups/topps/activities/PartialEvaluation.html)
developed a system that collapsed operations on arrays into a single
loops. Eg, if one is doing something like Ax + b, the multiplication
and addition are collapsed into one loop without the programmer having
to write special purpose code. The good thing is, this work was
originally done in Scheme. "All are academic projects, with promising
results so far. The Scheme systems are the most mature."

cya,
Noel
-- 
Noel Welsh
http://www.dai.ed.ac.uk/~noelw/   noelw@dai.ed.ac.uk