From: Ronan Le Hy <ronan.lehy@gmail.com>
To: Francois BERENGER <berenger@bioreg.kyushu-u.ac.jp>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Can this code be accelerated by porting it to SPOC, SAREK or MetaOCaml ?
Date: Thu, 15 Jun 2017 09:09:26 +0200 [thread overview]
Message-ID: <CAEc-HQm8ZxOeiMFtAaqo_0ZgPBqrmcfpyX2UxwUX+u0mLnFf4A@mail.gmail.com> (raw)
In-Reply-To: <412f58b7-8a8b-2356-2626-e1bd010be683@bioreg.kyushu-u.ac.jp>
Hi François,
2017-06-15 8:28 GMT+02:00 Francois BERENGER <berenger@bioreg.kyushu-u.ac.jp>:
> I am wondering if some high performance OCaml experts out there
> can know in advance if some code can go faster by executing it
> on a GPU.
> I have some clear bottleneck in my program.
> Here is how the code looks like:
> ---
> let f (points: (Vector3.t * float) list) =
> let acc = ref [] in
> let ac p1 x (p2, y) =
> acc := (Vector3.dist p1 p2, x *. y) :: !acc
> in
> let rec loop = function
> | [] -> ()
> | (p1, x) :: xs ->
> L.iter (ac p1 x) xs;
> loop xs
> in
> loop points;
> !acc
As a baseline before attempting anything on the GPU, I'd vectorize
this. Put all your vectors in a big matrix. Put all your numbers in a
vector. Compute the distances and the products all at once using
Lacaml (make sure you use OpenBLAS as a backend). I'd expect it to be
much faster than the above loop already.
--
Ronan
next prev parent reply other threads:[~2017-06-15 7:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 6:28 Francois BERENGER
2017-06-15 7:09 ` Ronan Le Hy [this message]
2017-06-15 10:38 ` Ivan Gotovchits
2017-06-16 9:49 ` Francois BERENGER
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=CAEc-HQm8ZxOeiMFtAaqo_0ZgPBqrmcfpyX2UxwUX+u0mLnFf4A@mail.gmail.com \
--to=ronan.lehy@gmail.com \
--cc=berenger@bioreg.kyushu-u.ac.jp \
--cc=caml-list@inria.fr \
/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