Coder Social home page Coder Social logo

opencl.jl's Introduction

OpenCL.jl

OpenCL bindings for Julia

Build status:

Code coverage:

Julia interface for the OpenCL parallel computation API

This package aims to be a complete solution for OpenCL programming in Julia, similar in scope to PyOpenCL for Python. It provides a high level api for OpenCL to make programing GPU's and multicore CPU's much less onerous.

OpenCL.jl provides access to OpenCL API versions 1.0, 1.1, 1.2 and 2.0.

This package is based off the work of others:

OpenCL.jl has had contributions from many developers.

Currently supported Julia versions

  • Julia v"0.4.x" is supported on the release-0.4 branch and the OpenCL.jl versions v"0.4.x". Only bug-fixes will be applied.
  • Julia v"0.5.x" is supported on the master branch and the OpenCL.jl versions v"0.5.x".
  • Julia v"0.6.x" is experimentally supported on the master branch and the OpenCL.jl versions v"0.5.x".

Discontinued support

  • Julia v"0.3.x" was supported on OpenCL.jl versions v"0.3.x". It should still be installable and work.

Setup

  1. Install an OpenCL driver. If you use OSX, OpenCL is already available
  2. Checkout the packages from the Julia repl
  Pkg.add("OpenCL")
  1. OpenCL will be installed in your .julia directory
  2. cd into your .julia directory to run the tests and try out the examples
  3. To update to the latest development version, from the Julia repl:
  Pkg.update()

IJulia Notebooks

Quick Example

using OpenCL

const sum_kernel = "
   __kernel void sum(__global const float *a,
                     __global const float *b,
                     __global float *c)
    {
      int gid = get_global_id(0);
      c[gid] = a[gid] + b[gid];
    }
"
a = rand(Float32, 50_000)
b = rand(Float32, 50_000)

device, ctx, queue = cl.create_compute_context()

a_buff = cl.Buffer(Float32, ctx, (:r, :copy), hostbuf=a)
b_buff = cl.Buffer(Float32, ctx, (:r, :copy), hostbuf=b)
c_buff = cl.Buffer(Float32, ctx, :w, length(a))

p = cl.Program(ctx, source=sum_kernel) |> cl.build!
k = cl.Kernel(p, "sum")

queue(k, size(a), nothing, a_buff, b_buff, c_buff)

r = cl.read(queue, c_buff)

if isapprox(norm(r - (a+b)), zero(Float32))
    info("Success!")
else
    error("Norm should be 0.0f")
end

opencl.jl's People

Contributors

daveh19 avatar davidbp avatar dfdx avatar jakebolewski avatar juliohm avatar lcw avatar lwabeke avatar maleadt avatar nstiurca avatar ranocha avatar sambitdash avatar simondanisch avatar tkelman avatar vchuravy avatar yuyichao avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.