<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/10/e586cb51b535fb11719cb9caa0bf3398"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T23:25:23"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?"
  prev="2009/10/c3d6a2b5703ff6f6470263a84a2e2610"
  next="2009/10/220b341f580c2f05dcd1fe43af8195cf"
  prev-in-thread="2009/10/454ba49ae093f226d01d7090512007cf"
  prev-thread="2009/10/a542f981ec63f1fb137050f0370eebab"
  next-thread="2009/10/63300d21e98ae03b875913a3e95f0dea"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="How to read different ints from a Bigarray?">
<msg 
  url="2009/10/bbb95d9e0194e1762c52367d01c48687"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-28T13:57:42"
  subject="How to read different ints from a Bigarray?">
<msg 
  url="2009/10/46931001437bcbb2e09f17cfe7df9981"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-28T14:17:44"
  subject="Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/8a90d2240c3144428951fc8b8cb530a1"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-28T15:00:48"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/57a3c666e4c3eb4f607f6630601c5bff"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-28T15:17:38"
  subject="Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/38da3897544cafcf0076ecf8ed64195c"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-28T18:01:12"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/49d3727f2409ccf2dd98f311cce6ae25"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-28T18:20:07"
  subject="Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/38a70da8110050e7ef926b81a62c7e61"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-28T21:05:28"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/1fb2fd518c360a1be5184a64a0f2ee6c"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-28T21:26:47"
  subject="Re: How to read different ints from a Bigarray?">
</msg>
</msg>
</msg>
<msg 
  url="2009/10/bf5823ce7568616f364570cd8ba70476"
  from="blue storm &lt;bluestorm.dylc@g...&gt;"
  author="blue storm"
  date="2009-10-28T22:48:07"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/4101b452ec63b2748ed42ae54995fa07"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T09:50:35"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/953f05dc40842238508a9582754f2718"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T10:34:50"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
</msg>
<msg 
  url="2009/10/6511dd596e8b3822f292f446db039088"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2009-10-29T12:20:49"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/4310df5ec194cc33ea355f8239da4261"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T17:11:08"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/5efd3ac5be44f2f55ec5ca61f3280bb5"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2009-10-30T20:30:13"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/11/b49aebddd45e1b64ce359e1fd20405c8"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-11-01T15:11:55"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/11/635da940c72d170c8317dad01c90ef0b"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2009-11-01T19:57:50"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/11/4d025a878558f48af14c5f309995a242"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-11-02T16:11:29"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/11/27802294c3fc891d0c2fb6388296d1f5"
  from="Mauricio Fernandez &lt;mfp@a...&gt;"
  author="Mauricio Fernandez"
  date="2009-11-02T16:33:27"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/11/6800529d761a4da0d1d1c7aff4767544"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2009-11-02T20:27:02"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/11/c237af6592d90c0f97fc6093bb34c20e"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-11-03T13:18:52"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
</msg>
</msg>
<msg 
  url="2009/11/713525c1fcc41fa56a8d7371779cb6eb"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-11-02T20:48:11"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2009/10/161893143f67c350977b99d7f97e55a9"
  from="Florian Weimer &lt;fw@d...&gt;"
  author="Florian Weimer"
  date="2009-10-29T20:40:13"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/30586559793975360d90892ea66b67c9"
  from="Gerd Stolpmann &lt;gerd@g...&gt;"
  author="Gerd Stolpmann"
  date="2009-10-29T20:59:07"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/507822c6b31e007dc642e512f676fb95"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T23:43:14"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/1fa25b75a89559ed7c63df5845298c27"
  from="Gerd Stolpmann &lt;gerd@g...&gt;"
  author="Gerd Stolpmann"
  date="2009-10-30T00:43:59"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
</msg>
</msg>
</msg>
<msg 
  url="2009/10/12b1267c3a1909e9477ed39ab6be37a7"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T23:38:57"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2009/10/b699fc83fc25d4dfb6ba4705183804af"
  from="Olivier Andrieu &lt;oandrieu@n...&gt;"
  author="Olivier Andrieu"
  date="2009-10-28T15:37:39"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
<msg 
  url="2009/10/02a74313db370b81dd3c6315f7190d57"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-28T16:05:56"
  subject="Re: How to read different ints from a Bigarray?">
</msg>
</msg>
<msg 
  url="2009/10/99f45aa9c8324508067c19216451bca4"
  from="Gerd Stolpmann &lt;gerd@g...&gt;"
  author="Gerd Stolpmann"
  date="2009-10-28T15:38:04"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
<msg 
  url="2009/10/14d54df8c72e192b79db94d2c1fac31d"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-28T16:10:10"
  subject="Re: How to read different ints from a Bigarray?">
</msg>
<msg 
  url="2009/10/ebf17417fbc6f4e6317a1582dc10cd69"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-28T18:37:06"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
</msg>
</msg>
<msg 
  url="2009/10/cffc1ff39a3e25f217348767d8336769"
  from="Xavier Leroy &lt;Xavier.Leroy@i...&gt;"
  author="Xavier Leroy"
  date="2009-10-28T17:10:04"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
<msg 
  url="2009/10/39a4e2380bdf79a6b8604c9f1ed8dc03"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-28T19:05:59"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
</msg>
<msg 
  url="2009/10/a8d579c804005ce1954c686973f455af"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T17:05:55"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
<msg 
  url="2009/10/242a11844cb0d850e2c76b2f006e61b1"
  from="Christophe TROESTLER &lt;Christophe.Troestler+ocaml@u...&gt;"
  author="Christophe TROESTLER"
  date="2009-10-29T18:42:39"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
<msg 
  url="2009/10/033810682bfd9b0436bf52c3c97715e7"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T19:03:19"
  subject="Re: [Caml-list] How to read different ints from a Bigarray?">
</msg>
</msg>
<msg 
  url="2009/10/454ba49ae093f226d01d7090512007cf"
  from="Sylvain Le Gall &lt;sylvain@l...&gt;"
  author="Sylvain Le Gall"
  date="2009-10-29T18:49:00"
  subject="Re: How to read different ints from a Bigarray?">
<msg 
  url="2009/10/e586cb51b535fb11719cb9caa0bf3398"
  from="Goswin von Brederlow &lt;goswin-v-b@w...&gt;"
  author="Goswin von Brederlow"
  date="2009-10-29T23:25:23"
  subject="Re: [Caml-list] Re: How to read different ints from a Bigarray?">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Sylvain Le Gall &lt;sylvain@le-gall.net&gt; writes:

&gt; On 29-10-2009, Goswin von Brederlow &lt;goswin-v-b@web.de&gt; wrote:
&gt;&gt; Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt; writes:
&gt;&gt;&gt; Goswin von Brederlow wrote:
&gt;&gt;
&gt;&gt; Here are some benchmark results:
&gt;&gt;
&gt;&gt; get an int out of a string:
&gt;&gt;                 C               Ocaml
&gt;&gt;   uint8  le     19.496          17.433
&gt;&gt;    int8  le     19.298          17.850
&gt;&gt;   uint16 le     19.427          25.046
&gt;&gt;    int16 le     19.383          27.664
&gt;&gt;   uint16 be     20.502          23.200
&gt;&gt;    int16 be     20.350          27.535
&gt;&gt;
&gt;&gt; get an int out of a Bigarray.Array1.t:
&gt;&gt; 		safe		unsafe
&gt;&gt;   uint8  le	55.194s		54.508s
&gt;&gt;   uint64 le     80.51s		81.46s
&gt;&gt;
&gt;
&gt; Can you provide us with the corresponding code and benchmark? 
&gt;
&gt; Maybe you can just commit this in libaio/test/bench.ml.
&gt;
&gt; Regards,
&gt; Sylvain Le Gall

As Christophe guessed the problem was polymorphic functions. If I
specify a fixed Array1 type then the compiler uses the optimized
access functions. Makes unsafe Bigarray slightly faster than unsafe
string actually (must not optimize int_of_char/Char.unsafe_chr away)
and that independent of argument size (on set, on get allocating
int32/int64 costs time so they are slower).

So Bigarray is the fastest but getting different types out of a
Bigarray will be tricky. Unaligned even more so if not impossible.

I have to sleep on this. Maybe in my use case I can have all
structures int64 aligned and then split the int64 up in ocaml where
structures have smaller members. Would have been too much to have a
Bigarray with access functions for any type. Maybe some little wrapper
with Obj.Magic will do *hide*.

As for libaio it should be easy to make it create and use any Bigarray
type.

MfG
        Goswin

</contents>

</message>

