Re: native code compiler and exceptions

Jocelyn Serot (Jocelyn.Serot@lasmea.univ-bpclermont.fr)
Fri, 27 Sep 1996 18:01:33 METDST

Message-Id: <199609271559.RAA18699@nez-perce.inria.fr>
From: Jocelyn Serot <Jocelyn.Serot@lasmea.univ-bpclermont.fr>
Subject: Re: native code compiler and exceptions
To: Pierre.Weis@inria.fr (Pierre Weis)
Date: Fri, 27 Sep 1996 18:01:33 METDST
In-Reply-To: <199609271524.RAA27638@pauillac.inria.fr>; from "Pierre Weis" at Sep 27, 96 5:24 pm

Thanks for your enlightments about efficiency concerns in Caml.
Seems like i have re-discovered an evidence: efficiency AND abstraction
do not live well together in the world of programs :-)
For example, i do agree with your optimisation of the conv fn:

> let conv im =
> let nr = nb_rows im and nc = nb_cols im in
> let im' = create nr nc in
> for y = 0 to pred nr do for x = 0 to pred nc do
> let p1 = if x = 0 then 0 else im.(x - 1).(y) in
> let p2 = if y = 0 then 0 else im.(x).(y - 1) in
> let p3 = if x = nc - 1 then 0 else im.(x + 1).(y) in
> let p4 = if y = nr - 1 then 0 else im.(x).(y + 1) in
> im'.(y).(x) <- ((p1 + p2 + p3 + p4) / 4) done done;
> m'
>

But in my code, conv is in fact a generalized "map" fn implemented as a higher
order fn, sth with a signature like:

# val conv : (coord -> coord array) ->
# (pixel array -> pixel) -> (coord -> pixel) -> t -> t
# (* [conv g f clp im] is [im']
# where im'@@(y,x) = f [|p1;..;pk|]
# where pi = im@@(yi,xi) ,if in_bounds m (yi,xi),
# clp (yi,xi) ,otherwise
# where [|(y1,x1);...;(yk,xk)|] = g (y,x) *)
# (*
# * [g] is the "neighboorhing fn"
# * [f] is the "combining fn"
# * [clp] is the "clipping fn" *)

This level of abstraction - that may be useful if you dont want to spend to
time writing "for" loops on image representations - clearly precludes the sort
of optimisation you suggest ...

So i am on my own now, speed or abstraction: this is the question ;-)

Thanks for your help,

Jocelyn

--
E-mail: Jocelyn.Serot@lasmea.univ-bpclermont.fr .............................
S-mail: LASMEA - URA 1793 CNRS, Universite Blaise Pascal, 63177 Aubiere cedex
Tel: (33) 73.40.73.30 - Fax: (33) 73.40.72.62 ...............................
.... http://wwwlasmea.univ-bpclermont.fr/Personnel/Jocelyn.Serot/Welcome.html