/eazy-opencl

OpenCL binding for Common Lisp

Primary LanguageCommon Lisp

eazy-opencl - Opencl Binding for Common Lisp

Development status:

  • basic CFFI binding, grovelling
  • proper error handling
  • integration to lisp GC
  • Minimally Viable API
  • extensive testing (https://travis-ci.org/guicho271828/eazy-opencl.svg, https://circleci.com/gh/guicho271828/eazy-opencl.svg)

TODOs:

  • lisp-to-C preprocessor -> work in progress at https://github.com/gos-k/oclcl
  • Loading external OpenCL library easily (like in quicklisp)
  • Really good way to handle complicated memory operation (e.g., generating operations automatically)

Perhaps, I should stop here, and leave these features to external libraries?

Installation

You have to install OpenCL ICD Loader and some OpenCL platform icd. On Debian/Ubuntu,

ICD loader: sudo apt-get install ocl-icd-opencl-dev

A Platform ICD provides an OpenCL implementation. Some are available from apt-get:

  • AMD (proprietary) : sudo apt-get install amd-opencl-icd
  • Nvidia (proprietary) : sudo apt-get install nvidia-opencl-icd
  • Intel (proprietary) : sudo apt-get install beignet-opencl-icd
  • Mesa (free) : sudo apt-get install mesa-opencl-icd
  • POCL (portable opencl) : sudo apt-get install pocl-opencl-icd — Tested on latest source (>=0.12) from Git. Older versions have several unimplemented features/arguments and does not pass all the test, but mostly working as long as you don’t use them.

However, note that these packages (both ICD loader and OpenCL implementation) are not up-to-date. My recommendation is to download the latest driver&icd from vendors’ websites.

As of 2015/11/04, it also requires the latest cffi installed from the git repositry.

cd $quicklisp_local_project ; git clone https://github.com/cffi/cffi.git

Once they are up, just load this library in the quicklisp local-project directory. Run the tests by:

(asdf:test-system :eazy-opencl)

Devices

OpenCL supports wide variety of hardware including CPU. The official, comprehensive device list is available here.

  • CPU with SSE2.X instruction (AMD APPSDK), SSE4.2 instruction (Intel driver)
  • Intel Xeon Phi (Intel driver)
  • ARM mobile CPUs (qualcomm snapdragon etc.)
  • CPU with embedded GPU (latest Intel, or AMD A-series)
  • FPGA, ASIC, DSP
  • GPGPU (Radeon, GeForce)

Note that AMD APPSDK can be installed on any CPUs supporting SSE2 (even on Intel).

Supported OpenCL Versions

This library supports opencl-1.0, 1.1, 1.2 and 2.0. They are automatically switched by grovelling the OpenCL header in the path.

This library is developped on machine with AMD APPSDK v3.0 (OpenCL 2.0), Radeon HD 5770 and PhenomII X6. Tests on CI runs with POCL 0.12 (OpenCL 1.2).

OpenCL has a specification independent from implementations, much like in ANSI Common Lisp. It maintains the backward-compatibility (any programs written with earlier versions of OpenCL should work.)

Bug/Trouble Reports should go to github issues page.

In this library, I do not support ANY OpenGL / Direct3D- related apis since I mostly target scientific use. I welcome any pullrequests as long as it comes with a minimal test.

Author

Masataro Asai (guicho2.71828@gmail.com)

C source generator will be forked from Takagi@CL-CUDA if ever implemented.

CFFI-binding is forked from cl-opencl-3b, but largely extended to support OpenCL 2.0.

Motivation

Both cl-opencl and cl-opencl-3b look abandoned, so I’m trying to supersede it. In fact, no one seems using it, nor it is on Quicklisp.

Implementing Deep NN in lisp is one ambitious goal. However it is not really necessary, since external DL-NN OpenCL libraries are available. See https://github.com/hughperkins/DeepCL.

License

I’ll plan to license it under the LLGPL, but since this is a fork from cl-opencl-3b which lacks the license, I’m asking 3b to specify one.