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 (UPMC-LIP6 laboratory, Paris, France) and was partially funded by the OpenGPU project. I continued this project in 2014-2015 in the Verimag laboratory (Grenoble, France) and then from 2015 to 2018 in the LIFO laboratory in Orléans, France. I currently work at Nomadic Labs

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

Docker image (Probably deprecated)

Demos in your browser (experimental)

Using WebCL and js_of_ocaml :

Sadly WebCL development seems stopped, [WebGPU] might be an alternative…
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 (Deprecated for now, new packages may be developed in the future)

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)