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=3.0 required=5.0 tests=AWL,DNS_FROM_SECURITYSAGE, 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 32B20BBAF for ; Sun, 2 Nov 2008 15:50:21 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmoBAGFNDUlC+VyqkGdsb2JhbACCRZESPgEBAQEJCQwHEQOqYIlMAQQ X-IronPort-AV: E=Sophos;i="4.33,529,1220220000"; d="scan'208";a="18767806" Received: from ug-out-1314.google.com ([66.249.92.170]) by mail3-smtp-sop.national.inria.fr with ESMTP; 02 Nov 2008 15:50:20 +0100 Received: by ug-out-1314.google.com with SMTP id k3so1632159ugf.4 for ; Sun, 02 Nov 2008 06:50:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:organization:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id:from; bh=NL8Y92PE0etarPqpyVvdXH8K2O8heqUY2sZFIkki/jA=; b=ATAkYpp4V6KWw1QZSkUiZlBNpLP+qkUDgrEI6W1KX2p+0Zb4NCycHdB68yD8NWI1Bb YKJxXs87xKiXDiFRe6NjEOSJM1ZKbpt8i1ahL6d9BOsImmTR5oAPTHUlykLDjnahmhYg 8JV79WHWXBjapAQWfDAiZQ3LjZ74O2Zabp0zo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=organization:to:subject:date:user-agent:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id:from; b=iJhOlslNepdsJG7CPZBdaZSU4CvJWpITruN5uYcPopTl8lJJCnAX+K2QLLivQPyy90 HE6L+s1UJwW2Le8ErkhzIp5zjNcYOx2iMU3Arv7+OfcKDcmy7xnpI4hcq4iUflpQPReR K5XdCm7bAjUiNkzFj4SlETXKPyuXa0OC22XCM= Received: by 10.210.79.14 with SMTP id c14mr16281200ebb.194.1225637420129; Sun, 02 Nov 2008 06:50:20 -0800 (PST) Received: from leper.local ([87.115.78.230]) by mx.google.com with ESMTPS id p10sm11589349gvf.7.2008.11.02.06.50.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 02 Nov 2008 06:50:18 -0800 (PST) Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Question about optimization Date: Sun, 2 Nov 2008 15:52:12 +0000 User-Agent: KMail/1.9.9 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200811021552.12185.jon@ffconsultancy.com> From: Jon Harrop X-Spam: no; 0.00; ovh:98 frog:98 wrote:01 inline:01 caml-list:01 arithmetic:01 match:02 optimization:03 optimization:03 optimizing:03 prim:03 prim:03 pattern:04 problem:05 vector:05 On Sunday 02 November 2008 02:52:49 Micha=C5=82 C wrote: > Hi! > > I'm working on a physical based ray(path) tracer and the performance > is one of my top priorities (just after the image quality). > So I have a question about optimization: can You share some tips or > maybe optimizing strategies to improve the speed of programs? > > here is my code: http://neos1.ovh.org/ray3.ml, Now that I can profile it, the single biggest problem is obviously that sev= en=20 of my cores are idle! You have manually un-nested pattern matches which is not necessary. For=20 example, this: | Leaf (prim, mat) -> match prim with | Triangle (tri) -> ray_triangle ro rd tri | Sphere (sph) -> ray_sphere ro rd sph May be written: | Leaf (Triangle tri, mat) -> ray_triangle ro rd tri | Leaf (Sphere sph, mat) -> ray_sphere ro rd sph The only obvious optimizations I can see are to use a faster random number= =20 generator and to inline the vector arithmetic by hand. =2D-=20 Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e