Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Q: float arrays
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Q: float arrays

> I know that I'm asking too much, but wouldn't it be nice it the
> compiler did it for me?   In the example at hand,
> 
>   let f2 = map (function (p,p') -> (p*.p'))
> 
> the compiler could inline the multiplication automagically, iff it
> still had access to the definition of the map function.

That's right, and I still plan to put some automatic inlining in
Objective Caml at some point. However, known inlining strategies
are very conservative and err on the safe side in order to avoid code
size blowup. This means that if your "map" functional is sufficiently
big, it will not be inlined, even though this could resut in important
speedups.

I'm not trying to discourage anyone from writing polymorphic or
higher-order functions: if that makes the program clearer, do it and
the performances will be all right most of the time.

What I'm saying is that if the performances of your application depend
critically on a few functions (say, matrix operations, or a Fourier
transform), then one of the first things you should consider to
hand-optimize these functions is removing function parameters and
avoid polymorphic array accesses. This is much more important
performance-wise than, say, removing array bound checks or turning
recursive functions into loops.

- Xavier Leroy