caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Francois BERENGER <berenger@bioreg.kyushu-u.ac.jp>
To: caml-list@inria.fr
Subject: [Caml-list] Can this code be accelerated by porting it to SPOC, SAREK or MetaOCaml ?
Date: Thu, 15 Jun 2017 15:28:57 +0900	[thread overview]
Message-ID: <412f58b7-8a8b-2356-2626-e1bd010be683@bioreg.kyushu-u.ac.jp> (raw)

Dear OCaml hackers,

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'd like to get some feeling before I invest into some new technology.

I'd like to stay in OCaml, not drop down to C.
So I mention SPOC, SAREK and MetaOCaml which look like the right 
technologies.

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
---

So, in terms of size: each point is 3 floats (a 3D coordinate) plus 1 
float (some value).
I usually have several thousands of points, but less than 10_000.

The f function will be called thousands of times for one run of the 
program (let's say 300k calls is a big but reasonable use case).

I don't care about the order of points in the input list.

I also don't care about the order of the results in acc.

I very probably don't care about using single point precision (32 bit 
floats) for everything, instead of double precision.

Thanks a lot for any feedback.

Best regards,
Francois.

PS: vector3 is available in opam, if that helps


             reply	other threads:[~2017-06-15  6:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15  6:28 Francois BERENGER [this message]
2017-06-15  7:09 ` Ronan Le Hy
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=412f58b7-8a8b-2356-2626-e1bd010be683@bioreg.kyushu-u.ac.jp \
    --to=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;
as well as URLs for NNTP newsgroup(s).