Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] interesting array efficiency observations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-09 (08:24)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] interesting array efficiency observations
> I was investigating the use of 1-D bigarray's vs Array and noticed
>  that the 1-D bigarray using c_layout seems to be slower than Array.
> Is this an expected result ?

Yes.  When compiling to bytecode (or at the top-level), all bigarray
accesses go through a generic access function that is polymorphic over
the number of dimensions, the array type and the array layout, and is
therefore somewhat expensive.  

When compiling to native code, efficient inline code is generated
instead for accesses to 1, 2 and 3-dimensional arrays, provided the
full type of the bigarray (including layout and element type) is known.
In this case, the inline access code is almost as efficient as that
for accessing a regular array: just one extra indirection.

- Xavier Leroy

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: