From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 0C635BBAF for ; Thu, 24 Jul 2008 21:47:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsAGAIx5iEhIDvyeYWdsb2JhbACSETkXAgUGBxAEmRaGEg X-IronPort-AV: E=Sophos;i="4.31,248,1215381600"; d="scan'208";a="27648836" Received: from po-out-1718.google.com ([72.14.252.158]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Jul 2008 21:47:00 +0200 Received: by po-out-1718.google.com with SMTP id c31so6631896poi.3 for ; Thu, 24 Jul 2008 12:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=grPtEt8+88zgHr+vcXqpqHMTVf6hqnxVNbDf6Wamuf4=; b=HD4QF4FSP5Kr4PKPbU2SwXAQh+jdJdOa+4kLKpeusLTDO/1RsZUuphCGuxypl/PsEP 166qriNwAlkeCjHSURl++jFXF97SPXKi9PHH1gCJDVDw7HKE/N+WG/FV2/Hj/rv1Xtl2 EFSrLIcDrF/17jFy3Voro/7yDj0ldOveun+L4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=dbsd2crbjjv8mlDR92Y0vsT+jW6yP0iXu7vrgvmkE5uUFJd7P2eSpfB3tHATwY8CxY mhCj9MUyCX0x/xmqaFtVkqSp1yWcyARq4mChGSqkO2zoORtKlXONJSmnQb/Vb1/GkRwp rHSRib9yKBdD8a5uZtaeDdHp3Uj0+pYDYWrkw= Received: by 10.140.126.14 with SMTP id y14mr415573rvc.160.1216928818563; Thu, 24 Jul 2008 12:46:58 -0700 (PDT) Received: by 10.140.188.1 with HTTP; Thu, 24 Jul 2008 12:46:58 -0700 (PDT) Message-ID: <666572260807241246m4ef1c4aclc6078db154d68c7a@mail.gmail.com> Date: Thu, 24 Jul 2008 21:46:58 +0200 From: Adrien To: "Raj Bandyopadhyay" Subject: Re: [Caml-list] Array copying in OCaml Cc: caml-list@yquem.inria.fr In-Reply-To: <4888AE76.2030204@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4888AE76.2030204@rice.edu> X-Spam: no; 0.00; ocaml:01 -unsafe:01 arrays:01 speedup:01 ocaml:01 -unsafe:01 arrays:01 blit:01 semantics:01 beginner's:01 bug:01 risen:98 beginners:01 compile:01 exception:01 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 : > 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 >