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
[Caml-list] doing MMX through ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-17 (21:13)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: [Caml-list] doing MMX through ocaml

I've received a lot of feedback on an mpeg2 decoder in ocaml, and
about performance woes ;-) So... the next step: building an MMX
library =) I presume it is possible, though, would lose a lot of
benefits having to use C wrappers everywhere....

The FFI just requires that the external symbol exists, right? Soooo, I
could theoretically define pure ASM routines that O'Caml could call.

The question begs: does OCaml expect the FFI function to have a
particular layout? Obviously, args have to be retrieved from the
stack, right? And there's no way around this?

And since MMX deals solely with integers, the Val_long/Long_val macros
could be implemented by a simple extra MMX instruction or two, right?

Maybe I could mod the compiler: create a 'naked' version of external,
and define registers to put values in, retrieve from? I've had a look
at the interp.c sources, and they don't look that complicated... just
a matter of defining a new instruction type for a C_CALL, and altering
the code generator and parser... though, that part in itself might be
quite tricky.

Basically, the idea is to create either a generic Math, or a special
MMX module built into the kernel, that apps can utilise if so wanted.
Of course, for the packed data types in MMX, might need some custom
types, but that shouldn't be too much of a problem.