You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/quickstart.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -46,33 +46,32 @@ The [`synchronize`](@ref) blocks the *host* until the kernel has completed on th
46
46
## Launching kernel on the backend
47
47
48
48
To launch the kernel on a backend-supported backend `isa(backend, KA.GPU)` (e.g., `CUDABackend()`, `ROCBackend()`, `oneBackend()`), we generate the kernel
49
-
for this backend provided by `CUDAKernels`, `ROCKernels`, or `oneAPIKernels`.
49
+
for this backend.
50
50
51
51
First, we initialize the array using the Array constructor of the chosen backend with
52
52
53
53
```julia
54
-
usingCUDAKernels # Required to access CUDABackend
54
+
usingCUDA: CuArray
55
55
A =CuArray(ones(1024, 1024))
56
56
```
57
57
58
58
```julia
59
-
usingROCKernels # Required to access ROCBackend
59
+
usingROCArrays: ROCArray
60
60
A =ROCArray(ones(1024, 1024))
61
61
```
62
62
63
63
```julia
64
-
usingoneAPIKernels # Required to access oneBackend
64
+
usingoneAPI: oneArray
65
65
A =oneArray(ones(1024, 1024))
66
66
```
67
67
The kernel generation and execution are then
68
68
```julia
69
+
backend =get_backend(A)
69
70
mul2_kernel(backend, 64)(A, ndrange=size(A))
70
71
synchronize(backend)
71
72
all(A .==2.0)
72
73
```
73
74
74
-
For simplicity, we stick with the case of `backend=CUDABackend()`.
75
-
76
75
## Synchronization
77
76
!!! danger
78
77
All kernel launches are asynchronous, use [`synchronize(backend)`](@ref)
@@ -82,23 +81,24 @@ The code around KA may heavily rely on
82
81
[`GPUArrays`](https://github.com/JuliaGPU/GPUArrays.jl), for example, to
83
82
intialize variables.
84
83
```julia
85
-
using CUDAKernels # Required to access CUDABackend
86
-
functionmymul(A::CuArray)
84
+
functionmymul(A)
87
85
A .=1.0
88
-
ev =mul2_kernel(CUDABackend(), 64)(A, ndrange=size(A))
86
+
backend =get_backend(A)
87
+
ev =mul2_kernel(backend, 64)(A, ndrange=size(A))
89
88
synchronize(backend)
90
89
all(A .==2.0)
91
90
end
92
91
```
93
92
94
93
```julia
95
-
using CUDAKernels # Required to access CUDABackend
0 commit comments