Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit 016c86b

Browse files
Use linearise in layout
1 parent f3325fd commit 016c86b

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/device/matmul_kernels/layout.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ struct AlignedColMajor{T} <: LayoutBase{T} end
4747
@unroll for i = 1 : vec_len : size[1]
4848
t = translate(tile, (i - 1, j - 1))
4949

50-
base = Tuple(t.base) .+ 1
51-
@inbounds linear_base = LinearIndices(Base.size(workspace))[base...]
52-
53-
offset = Tuple(t.offset) .+ 1
54-
@inbounds linear_offset = LinearIndices(Base.size(workspace))[offset...]
50+
linear_base = linearise(t.base, Base.size(workspace))
51+
linear_offset = linearise(t.offset, Base.size(workspace))
5552

5653
@inbounds res[i, j] = vloada(Vec{vec_len, T}, pointer(workspace, linear_base), linear_offset)
5754
end
@@ -67,11 +64,8 @@ end
6764
@unroll for i = 1 : vec_len : size[1]
6865
t = translate(tile, (i - 1, j - 1))
6966

70-
base = Tuple(t.base) .+ 1
71-
@inbounds linear_base = LinearIndices(Base.size(workspace))[base...]
72-
73-
offset = Tuple(t.offset) .+ 1
74-
@inbounds linear_offset = LinearIndices(Base.size(workspace))[offset...]
67+
linear_base = linearise(t.base, Base.size(workspace))
68+
linear_offset = linearise(t.offset, Base.size(workspace))
7569

7670
vstorea!(Vec{vec_len, T}, pointer(workspace, linear_base), value[i, j], linear_offset)
7771
end

src/device/tiling.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ tensor with dimensions `dims`.
112112
@inbounds return LinearIndices(Tuple(dims))[ind...]
113113
end
114114

115+
@inline linearise(coord::NamedTuple{names, T}, dims::Tuple) where {names, T} = linearise(coord, NamedTuple{names}(dims))
116+
115117
export translate
116118

117119
"""

0 commit comments

Comments
 (0)