caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Adrien <camaradetux@gmail.com>
To: "Raj Bandyopadhyay" <rajb@rice.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Array copying in OCaml
Date: Thu, 24 Jul 2008 21:46:58 +0200	[thread overview]
Message-ID: <666572260807241246m4ef1c4aclc6078db154d68c7a@mail.gmail.com> (raw)
In-Reply-To: <4888AE76.2030204@rice.edu>

You can compile with the -unsafe flag. If you're using arrays a lot,
it can easily speed your program by 50%. If your program is array
based, the speedup can be even more important.

Don't assume it could magically make your program behave in a weird
way. When you're trying to access an element which is outside the
bounds of the array, ocaml rises an exception. With the -unsafe flag,
no exception will be risen and you will have no chance to catch it.
Consequently if you're out of bounds, your programm will die. That's
why it is called "unsafe". If you're sure you won't be out of bounds
(or are not trying to catch any exception), you can safely use
-unsafe.

If you don't want to affect globally your program, you can also use
Array.unsafe_get or Arra.unsafe_set. I don't know the full list
though.


 ---

Adrien Nader

2008/7/24 Raj Bandyopadhyay <rajb@rice.edu>:
> Hi
>
> I have an application which copies a lot of (small) OCaml arrays using the
> Array library (Array.sub and Array.blit) functions. This is turning out to
> be extremely expensive.
>
> Is there any general way/trick to reduce the cost of this kind of operation?
> I haven't found a way not to copy as much, because the program semantics
> seems to demand it.
>
> Thanks
> Raj
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  parent reply	other threads:[~2008-07-24 19:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-24 16:31 Raj Bandyopadhyay
2008-07-24 16:37 ` [Caml-list] " Dr. Thomas Fischbacher
2008-07-24 17:25 ` Christophe TROESTLER
2008-07-24 19:46 ` Adrien [this message]
2008-07-28  2:03   ` Raj Bandyopadhyay
2008-07-28  7:52     ` Richard Jones
2008-07-28 17:34   ` Raj Bandyopadhyay
2008-07-28 21:11     ` Richard Jones
2008-07-29  9:37     ` Michel Mauny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=666572260807241246m4ef1c4aclc6078db154d68c7a@mail.gmail.com \
    --to=camaradetux@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=rajb@rice.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).