From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA10262; Fri, 16 Aug 2002 00:50:06 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA10271 for ; Fri, 16 Aug 2002 00:50:05 +0200 (MET DST) Received: from gromit.it.su.se (gromit.it.su.se [130.237.95.77]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7FMo4v13634 for ; Fri, 16 Aug 2002 00:50:05 +0200 (MET DST) Received: from gromit.it.su.se (localhost [127.0.0.1]) by gromit.it.su.se (8.12.5/8.12.5) with ESMTP id g7FMo4Bi006080 for ; Fri, 16 Aug 2002 00:50:04 +0200 (CEST) (envelope-from rnyberg@gromit.it.su.se) Received: (from rnyberg@localhost) by gromit.it.su.se (8.12.5/8.12.5/Submit) id g7FMo451006079 for caml-list@inria.fr; Fri, 16 Aug 2002 00:50:04 +0200 (CEST) Date: Fri, 16 Aug 2002 00:50:04 +0200 From: Richard Nyberg To: caml-list@inria.fr Subject: [Caml-list] Bigarray access speed Message-ID: <20020815225004.GA5959@gromit.it.su.se> Mail-Followup-To: Richard Nyberg , caml-list@inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk In the following small programs 3) is faster than 1) and 2), which run equally fast. However, 4 is significantly slower than the rest. If you change the line "a.{i} <- a.{i} + i" to "a.{i} <- i" the execution time is halfed but it's still much slower. Are access to Bigarrays slower when passed to functions? If so, is it fixable? or is there some workaround? I stumbled upon this while coding on a school assignment ((not too ;) fast multiplication of large integers). 1) let a = Array.make 1000000 0 in for i = 0 to 999999 do a.(i) <- a.(i) + i; done;; 2) let a = Array.make 1000000 0 in let rec loop a i = if i <= 999999 then begin a.(i) <- a.(i) + i; loop a (i + 1) end in loop a 0;; 3) open Bigarray;; let a = Array1.create int c_layout 1000000 in Array1.fill a 0; for i = 0 to 999999 do a.{i} <- a.{i} + i done;; 4) open Bigarray;; let a = Array1.create int c_layout 1000000 in Array1.fill a 0; let rec loop a i = if i <= 999999 then begin a.{i} <- a.{i} + i; loop a (i + 1) end in loop a 0;; -Richard ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners