Skip to content

Commit 3caeece

Browse files
committed
modifying docs with new changes
1 parent dd6804b commit 3caeece

File tree

2 files changed

+20
-40
lines changed

2 files changed

+20
-40
lines changed

docs/src/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ will get a lot of functionality for free. This will allow to have multiple GPUAr
99
implementation for different purposes, while maximizing the ability to share code.
1010

1111
**This package is not intended for end users!** Instead, you should use one of the packages
12-
that builds on GPUArrays.jl. There is currently only a single package that actively builds
13-
on these interfaces, namely [CuArrays.jl](https://github.com/JuliaGPU/CuArrays.jl).
12+
that builds on GPUArrays.jl such as [CUDA](https://github.com/JuliaGPU/CUDA.jl), [AMDGPU](https://github.com/JuliaGPU/AMDGPU.jl), [OneAPI](https://github.com/JuliaGPU/oneAPI.jl), or [Metal](https://github.com/JuliaGPU/Metal.jl).
1413

15-
In this documentation, you will find more information on the interface that you are expected
14+
This documentation is meant for users who might wish to implement a version of GPUArrays for another GPU backend and will cover the features you will need
1615
to implement, the functionality you gain by doing so, and the test suite that is available
1716
to verify your implementation. GPUArrays.jl also provides a reference implementation of
1817
these interfaces on the CPU: The `JLArray` array type uses Julia's parallel programming

docs/src/interface.md

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,32 @@
11
# Interface
22

33
To extend the above functionality to a new array type, you should use the types and
4-
implement the interfaces listed on this page. GPUArrays is design around having two
5-
different array types to represent a GPU array: one that only ever lives on the host, and
4+
implement the interfaces listed on this page. GPUArrays is designed around having two
5+
different array types to represent a GPU array: one that exists only on the host, and
66
one that actually can be instantiated on the device (i.e. in kernels).
7+
Device functionality is then handled by [KernelAbstractions.jl](https://github.com/JuliaGPU/KernelAbstractions.jl).
78

9+
## Host abstractions
810

9-
## Device functionality
10-
11-
Several types and interfaces are related to the device and execution of code on it. First of
12-
all, you need to provide a type that represents your execution back-end and a way to call
13-
kernels:
11+
You should provide an array type that builds on the `AbstractGPUArray` supertype, such as:
1412

15-
```@docs
16-
GPUArrays.gpu_call
17-
GPUArrays.thread_block_heuristic
1813
```
14+
mutable struct CustomArray{T, N} <: AbstractGPUArray{T, N}
15+
data::DataRef{Vector{UInt8}}
16+
offset::Int
17+
dims::Dims{N}
18+
...
19+
end
1920
20-
You then need to provide implementations of certain methods that will be executed on the
21-
device itself:
22-
23-
```@docs
24-
GPUArrays.AbstractDeviceArray
25-
GPUArrays.LocalMemory
26-
GPUArrays.synchronize_threads
27-
GPUArrays.blockidx
28-
GPUArrays.blockdim
29-
GPUArrays.threadidx
30-
GPUArrays.griddim
3121
```
3222

23+
This will allow your defined type (in this case `JLArray`) to use the GPUArrays interface where available.
24+
To be able to actually use the functionality that is defined for `AbstractGPUArray`s, you need to define the backend, like so:
3325

34-
## Host abstractions
35-
36-
You should provide an array type that builds on the `AbstractGPUArray` supertype:
37-
38-
```@docs
39-
AbstractGPUArray
4026
```
41-
42-
First of all, you should implement operations that are expected to be defined for any
43-
`AbstractArray` type. Refer to the Julia manual for more details, or look at the `JLArray`
44-
reference implementation.
45-
46-
To be able to actually use the functionality that is defined for `AbstractGPUArray`s, you
47-
should provide implementations of the following interfaces:
48-
49-
```@docs
50-
GPUArrays.backend
27+
import KernelAbstractions: Backend
28+
struct CustomBackend <: KernelAbstractions.GPU
29+
KernelAbstractions.get_backend(a::CA) where CA <: CustomArray = CustomBackend()
5130
```
31+
32+
There are numerous examples of potential interfaces for GPUArrays, such as with [JLArrays](https://github.com/JuliaGPU/GPUArrays.jl/blob/master/lib/JLArrays/src/JLArrays.jl), [CuArrays](https://github.com/JuliaGPU/CUDA.jl/blob/master/src/gpuarrays.jl), and [ROCArrays](https://github.com/JuliaGPU/AMDGPU.jl/blob/master/src/gpuarrays.jl).

0 commit comments

Comments
 (0)