/haskell-opencl-examples

Haskell OpenCL Examples

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

haskell-opencl-examples

Build Status

Examples using the OpenCL package in Haskell.

Requirements

These examples are built using the Haskell Stack Tool. Please see their instructions for installing stack.

For MacOS, stack should be able to fetch all dependencies itself, build everything, and produce runnable examples. On other platforms (eg. Linux and Windows) it may also be necessary to install an OpenCL base and an OpenCL ICD (Installable Client Driver) before the examples can compile and run. I will add more instructions for other platforms here once I've figured out the necessary steps.

Additional Documentation

I have described some of this project in a blog post, which may be helpful in following the first example.

Compiling and Running

Try the following:

$ stack setup
$ stack build
$ stack exec 01-hello-world

If everything is working correctly, you should see output similar to the following (possibly with different devices, depending on your system):

* OpenCL Platform Environment *
Platform: Apple
  Device: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
  Device: Intel(R) HD Graphics 530
  Device: AMD Radeon Pro 460 Compute Engine

* Results *
Input:  [-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0]
Output: [-8.0,-6.0,-4.0,-2.0,0.0,2.0,4.0,6.0,8.0]