English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Multiplication of matrix in C and OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-02-08 (12:08)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Multiplication of matrix in C and OCaml
From: Frédéric Gava <gava@univ-paris12.fr>
>  > gcc -O3 monomorphic: 4.7s
>  > Now, I also found a strange result:
>  > gcc -O3 monomorphic: 1.4s
> Why two different times for the same program ? What is monomorphic ?

The second one is a misprint fron "gcc -O3 polymorphic".
By monomorphic I mean that add and mult are used directly (actually
inlined with -O3), rather than being passed as parameter to
generic_multiply, which should be faster.
The funny thing is that this results in correct code
even with -O3, because the inlined version does not discard its
result, as does the add and mult optimized functions.
So the polymorphic code, completely broken, ends up being 3 times
faster :-)

By the way there was another evident bug in your code: you do pointer
arithmetic on void*, which is clearly wrong. Yet, this can be easily
corrected by passing sizeof(complexe) as an extra argument to
generic_multiply, and adjusting offsets with it.

Jacques Garrigue