View the Project on GitHub mathiasbourgoin/SPOC

Build Status

SPOC is a set of tools for GPGPU programming with OCaml.

The SPOC library enables the detection and use of GPGPU devices with OCaml using Cuda and OpenCL. There is also a camlp4 syntax extension to handle external Cuda or OpenCL kernels, as well as a DSL (called Sarek) to express GPGPU kernels from the OCaml code.

This work was part of my PhD thesis (done in UPMC-LIP6, Paris, France) and was partially funded by the OPENGPU project. I’m currently in the Verimag laboratory (Grenoble, France).

It has currently been tested on multiple architectures and systems, mostly 64-bit Linux and 64-bit OSX systems. It should work with Windows too.

To be able to use SPOC, you’ll need a computer capable of running OCaml (obviously) but also compatible with either OpenCL or Cuda. For Cuda you only need a current proprietary NVidia driver while for OpenCL you need to install the correct OpenCL implementation for your system. SPOC should compile anyway as everything is dynamically linked, but you’ll need Cuda/OpenCL eventually to run your programs.

SPOC comes with some examples and I strongly advise anyone interested to look into the slides and papers. For basic tutorials, you should look into our live demos.

Current work

Spoc and Sarek are still in development, here is a list of features we plan to add (bold ones are currently in development) :

Demos in your browser (experimental)

Using WebCL and js_of_ocaml :

This has been tested with Firefox 26-34 and this plugin under Windows 8.1 (32bit or 64bit), multiple Linux distributions (32bit and 64 bit) and Mac OS/X Mavericks and Yosemite.

Of course, you’ll also need to have OpenCL on your system.

How to test?

You should install/have :

I - How to Build SPOC

1 - Dependencies

Requires :

* ocaml >= 4.01.0 (mainly tested with ocaml 4.02.1)
* camlp4
* ocamlfind 
* camlp4-extra (for ubuntu)
* m4

For cuda compilation :

* nvcc    

2 - Compilation & Installation

From Opam

SPOC and Sarek should be in the opam repository.

For development releases (more up to date but maybe instable), simply add our repository :

opam repository add spoc_repo


opam update spoc_repo
opam install spoc

From sources

To compile SPOC:

cd Spoc
make install

3 - Build Documentation

From the sources :

make doc

Will build the ocamldoc html pages in the Spoc/docs directory

II - Testing SPOC

The “Samples” directory contains few programs using SPOC.

To compile those programs:

cd Samples

Binaries will be located in the Samples/build folder


The “SpocLibs” directory contains few libraries based on Spoc.

The Sample directory contains few samples using those libraries



Book Chapter

Peer Reviewed Papers

General Presentations

On Composition and Skeletons

On Web Programming with SPOC and Sarek

On Applications


LIFO - Bâtiment IIIA
Rue Léonard de Vinci
B.P. 6759
F-45067 ORLEANS Cedex 2
Mathias.Bourgoin (at)