From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 6D3A7BC37 for ; Thu, 17 Dec 2009 01:34:31 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoQDAA0LKUvRVdzjkGdsb2JhbACCX49AiHU/AQEBAQkJDAcTA6k4gTGFRYhjAQIDBYQmBA X-IronPort-AV: E=Sophos;i="4.47,409,1257116400"; d="scan'208";a="38773286" Received: from mail-fx0-f227.google.com ([209.85.220.227]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Dec 2009 01:34:31 +0100 Received: by fxm27 with SMTP id 27so1512587fxm.3 for ; Wed, 16 Dec 2009 16:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=qc44k8+H9l5sc4V0fU0HExu91zof5hl4poOZINAsGVE=; b=tKFuFnvKEHaewaD1rBXMVTcW5N5cJc1JGkjYxvZDkA264G9yM+yPkSoMiwO5vgwIC0 rImMnFAvVPzvb6fbiw+AIYEATU4va51cV0psibvoj2qlvID6O7ijX0lLcxHHyXJh0NEJ j0EMaCZCNzR0cvhoptKDgtegq0x/dY9ixescI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Th2lGRZzkEKst0GJaOGS0xWXo5xwN69KOIyYUuJXVC32aVVxq1s3EQZjqVxgPEjyWK 8elYExtN2scKDl1DSYJk/RA+6udanty4iLkFVhPSmnhwUkUgN9JT2DHEFvWvzrmswdOB rlmTEJ3mDo7glOPnxcJdjhhu5f6t5wizL/NZQ= MIME-Version: 1.0 Received: by 10.239.145.15 with SMTP id q15mr174301hba.121.1261010070617; Wed, 16 Dec 2009 16:34:30 -0800 (PST) In-Reply-To: <320e992a0912160547q7969ed30i129e5798456fbf84@mail.gmail.com> References: <320e992a0912150737t483a5946x9cad351fc344691f@mail.gmail.com> <4B27B981.80700@starynkevitch.net> <200912160039.51086.jon@ffconsultancy.com> <20091216134138.411322D08BF@kicki.hq.vtech> <320e992a0912160547q7969ed30i129e5798456fbf84@mail.gmail.com> Date: Thu, 17 Dec 2009 01:34:30 +0100 Message-ID: <4d1b2df20912161634w682bb804meb6c4090fa28284b@mail.gmail.com> Subject: Re: [Caml-list] How to write a CUDA kernel in ocaml? From: Philippe Wang To: Eray Ozkural Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; ocaml:01 eray:01 ozkural:01 trivial:01 ocaml:01 bytecode:01 bytecode:01 parallelism:01 parallelism:01 computations:01 high-level:01 compiler:01 2009:98 300.:98 imho:01 On Wed, Dec 16, 2009 at 2:47 PM, Eray Ozkural wrote: > One trivial and low-performance solution that comes to mind is: make > an ocaml bytecode interpreter into a CUDA kernel and then pass the > bytecode to it, and then voila, at least we have some 512-way > parallelism on the GT300. How does that sound? We'd be losing some > performance but massive parallelism will cover up for some of that. With parallel processors, you move very quickly the performance bottleneck from processor(s) to memory bandwidth, such that - it's hell to program because you have to manage concurrency and it has a real cost - it's useful for very specific programs that have very few memory access compared to processor computations (such as some compression algorithms, a more specific and very easy to write example is matrix multiplications). Imagine you have 3000MHz for memory bandwidth, which is extremely good today (I think). And imagine you have 100 processors that share this memory bandwidth. If they all want to access memory at the same time, even if you forget the concurrency management cost, you have 3000/100MHz/processor=30MHz/processor, which is very very very low. So think about 10 processors instead of 100 to be more realistic, it's still 300MHz/processor, which looks like what we had about a decade ago... (IMHO) A not-too-too-bad-but-still-realistic way to take benefit of GPUs today, with OCaml (or any high-level language), is to write computation functions in C (possibly with some assembly), and to write composition functions in OCaml. Or (less realistic in a short amount of time) maybe to write a compiler that may do the job for you, but it's not quite easy... Good luck, -- Philippe Wang mail@philippewang.info