@@ -2,34 +2,34 @@ using KernelAbstractions, Test, Random
2
2
include (joinpath (dirname (pathof (KernelAbstractions)), " ../examples/utils.jl" )) # Load backend
3
3
4
4
# Simple kernel for matrix multiplication
5
- @kernel function matmul_kernel! (a, b, c )
5
+ @kernel function matmul_kernel! (output, a, b )
6
6
i, j = @index (Global, NTuple)
7
7
8
8
# creating a temporary sum variable for matrix multiplication
9
- tmp_sum = zero (eltype (c ))
9
+ tmp_sum = zero (eltype (output ))
10
10
for k = 1 : size (a)[2 ]
11
11
tmp_sum += a[i,k] * b[k, j]
12
12
end
13
13
14
- c [i,j] = tmp_sum
14
+ output [i,j] = tmp_sum
15
15
end
16
16
17
17
# Creating a wrapper kernel for launching with error checks
18
- function matmul! (a, b, c )
18
+ function matmul! (output, a, b )
19
19
if size (a)[2 ] != size (b)[1 ]
20
20
println (" Matrix size mismatch!" )
21
21
return nothing
22
22
end
23
23
backend = KernelAbstractions. get_backend (a)
24
24
kernel! = matmul_kernel! (backend)
25
- kernel! (a, b, c, ndrange= size (c ))
25
+ kernel! (output, a, b, ndrange= size (output ))
26
26
end
27
27
28
28
a = rand! (allocate (backend, Float32, 256 , 123 ))
29
29
b = rand! (allocate (backend, Float32, 123 , 45 ))
30
- c = KernelAbstractions. zeros (backend, Float32, 256 , 45 )
30
+ output = KernelAbstractions. zeros (backend, Float32, 256 , 45 )
31
31
32
- matmul! (a,b,c )
32
+ matmul! (output, a,b)
33
33
KernelAbstractions. synchronize (backend)
34
34
35
- @test isapprox (c , a* b)
35
+ @test isapprox (output , a* b)
0 commit comments