|
1 | 1 | # GPUArrays
|
2 | 2 |
|
3 |
| -*Abstract GPU Array package for Julia's various GPU backends.* |
| 3 | +*Reusable GPU array functionality for Julia's various GPU backends.* |
4 | 4 |
|
5 |
| -[![][docs-stable-img]][docs-stable-url] [![][docs-dev-img]][docs-dev-url] [](https://codecov.io/gh/JuliaGPU/GPUArrays.jl) |
| 5 | +| **Documentation** | **Build Status** | |
| 6 | +|:-------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------:| |
| 7 | +| [![][docs-stable-img]][docs-stable-url] [![][docs-dev-img]][docs-dev-url] | [![][gitlab-img]][gitlab-url] [![][travis-img]][travis-url] [![][codecov-img]][codecov-url] | |
6 | 8 |
|
7 |
| -[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg |
8 |
| -[docs-stable-url]: http://JuliaGPU.github.io/GPUArrays.jl/stable/ |
9 |
| -[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg |
10 |
| -[docs-dev-url]: http://JuliaGPU.github.io/GPUArrays.jl/dev/ |
11 |
| - |
12 |
| - |
13 |
| -[Benchmarks](https://github.com/JuliaGPU/GPUBenchmarks.jl/blob/master/results/results.md) |
14 |
| - |
15 |
| -This package is the counterpart of Julia's `Base.AbstractArray` interface, but |
16 |
| -for GPU array types. Currently, you either need to install |
17 |
| -[CLArrays](https://github.com/JuliaGPU/CLArrays.jl) or |
18 |
| -[CuArrays](https://github.com/JuliaGPU/CuArrays.jl) for a concrete |
19 |
| -implementation. |
20 |
| - |
21 |
| - |
22 |
| -# Why another GPU array package in yet another language? |
23 |
| - |
24 |
| -Julia offers great advantages for programming the GPU. |
25 |
| -This [blog post](http://mikeinnes.github.io/2017/08/24/cudanative.html) outlines a few of those. |
26 |
| - |
27 |
| -E.g., we can use Julia's JIT to generate optimized kernels for map/broadcast operations. |
28 |
| - |
29 |
| -This works even for things like complex arithmetic, since we can compile what's already in Julia Base. |
30 |
| -This isn't restricted to Julia Base, GPUArrays works with all kind of user defined types and functions! |
31 |
| - |
32 |
| -GPUArrays relies heavily on Julia's dot broadcasting. |
33 |
| -The great thing about dot broadcasting in Julia is, that it |
34 |
| -[actually fuses operations syntactically](http://julialang.org/blog/2017/01/moredots), which is vital for performance on the GPU. |
35 |
| -E.g.: |
36 |
| - |
37 |
| -```Julia |
38 |
| -out .= a .+ b ./ c .+ 1 |
39 |
| -#turns into this one broadcast (map): |
40 |
| -broadcast!(out, a, b, c) do a, b, c |
41 |
| - a + b / c + 1 |
42 |
| -end |
43 |
| -``` |
44 |
| - |
45 |
| -Will result in one GPU kernel call to a function that combines the operations without any extra allocations. |
46 |
| -This allows GPUArrays to offer a lot of functionality with minimal code. |
47 |
| - |
48 |
| -Also, when compiling Julia for the GPU, we can use all the cool features from Julia, e.g. |
49 |
| -higher order functions, multiple dispatch, meta programming and generated functions. |
50 |
| -Checkout the examples, to see how this can be used to emit specialized code while not losing flexibility: |
51 |
| - |
52 |
| -[<img src="https://raw.githubusercontent.com/JuliaGPU/GPUBenchmarks.jl/master/results/plots/juliaset_result.png" height="150">](https://github.com/JuliaGPU/GPUBenchmarks.jl/blob/master/results/results.md) |
53 |
| -[<img src="https://user-images.githubusercontent.com/1010467/40832645-12ca1f50-658c-11e8-9fb4-170871db2499.png" height="150">](https://juliagpu.github.io/GPUShowcases.jl/latest/) |
54 |
| - |
55 |
| -In theory, we could go as far as inspecting user defined callbacks (we can get the complete AST), count operations and estimate register usage and use those numbers to optimize our kernels! |
| 9 | +[gitlab-img]: https://gitlab.com/JuliaGPU/CuArrays.jl/badges/master/pipeline.svg |
| 10 | +[gitlab-url]: https://gitlab.com/JuliaGPU/CuArrays.jl/commits/master |
56 | 11 |
|
| 12 | +[travis-img]: https://api.travis-ci.org/JuliaGPU/GPUArrays.jl.svg?branch=master |
| 13 | +[travis-url]: https://travis-ci.org/JuliaGPU/GPUArrays.jl |
57 | 14 |
|
58 |
| -# Scope |
59 |
| - |
60 |
| -Interface offered for all backends: |
61 |
| - |
62 |
| -```Julia |
63 |
| -map(f, ::GPUArray...) |
64 |
| -map!(f, dest::GPUArray, ::GPUArray...) |
65 |
| - |
66 |
| -broadcast(f, ::GPUArray...) |
67 |
| -broadcast!(f, dest::GPUArray, ::GPUArray...) |
68 |
| - |
69 |
| -mapreduce(f, op, ::GPUArray...) # so support for sum/mean/minimum etc comes for free |
70 |
| - |
71 |
| -getindex, setindex!, push!, append!, splice!, append!, copy!, reinterpret, convert |
72 |
| - |
73 |
| -From (CL/CU)FFT |
74 |
| -fft!/fft/ifft/ifft! and the matching plan_fft functions. |
75 |
| -From (CL/CU)BLAS |
76 |
| -gemm!, scal!, gemv! and the high level functions that are implemented with these, like A * B, A_mul_B!, etc. |
77 |
| -``` |
78 |
| - |
79 |
| -# Currently supported subset of Julia Code |
80 |
| - |
81 |
| -Working with immutable isbits (not containing pointers) type should be completely supported |
82 |
| -with non-allocating code (so no constructs like `x = [1, 2, 3]`). Note that tuples are isbits, so this works x = (1, 2, 3). |
83 |
| -Transpiler/OpenCL has problems with putting GPU arrays on the gpu into a struct - so no views and actually no multidimensional indexing. For that `size` is needed which would need to be part of the array struct. A fix for that is in sight, though. |
84 |
| - |
85 |
| -# JLArray |
86 |
| - |
87 |
| -The `JLArray` is a `GPUArray` which doesn't run on the GPU and rather uses Julia's async constructs as its backend. It serves as a fallback for testing compatibility with `GPUArray`s in cases where a GPU does not exist and as a reference implementation. It is constructed as follows: |
88 |
| - |
89 |
| -```julia |
90 |
| -gA = JLArray(A) |
91 |
| -``` |
92 |
| - |
93 |
| -# TODO / up for grabs |
94 |
| - |
95 |
| -* stencil operations, convolutions |
96 |
| -* more tests and benchmarks |
97 |
| -* tests, that only switch the backend but use the same code |
98 |
| -* performance improvements!! |
99 |
| -* interop between OpenCL, CUDA and OpenGL is there as a protype, but needs proper hooking up via `Base.copy!` / `convert` |
| 15 | +[codecov-img]: https://codecov.io/gh/JuliaGPU/CuArrays.jl/branch/master/graph/badge.svg |
| 16 | +[codecov-url]: https://codecov.io/gh/JuliaGPU/CuArrays.jl |
100 | 17 |
|
| 18 | +[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg |
| 19 | +[docs-stable-url]: http://JuliaGPU.github.io/GPUArrays.jl/stable/ |
101 | 20 |
|
102 |
| -# Installation |
| 21 | +[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg |
| 22 | +[docs-dev-url]: http://JuliaGPU.github.io/GPUArrays.jl/dev/ |
103 | 23 |
|
104 |
| -See CuArrays or CLArrays for installation instructions. |
| 24 | +This package is the counterpart of Julia's `AbstractArray` interface, but for GPU array |
| 25 | +types: It provides functionality and tooling to speed-up development of new GPU array types. |
| 26 | +**This package is not intended for end users!** Instead, you should use one of the packages |
| 27 | +that builds on GPUArrays.jl, such as [CuArrays](https://github.com/JuliaGPU/CuArrays.jl). |
0 commit comments