Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
composable_kernel
Commits
753b98b5
Commit
753b98b5
authored
Apr 03, 2019
by
Jing Zhang
Browse files
refactor inline asm
parent
114fdb58
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
519 deletions
+41
-519
src/include/blockwise_gemm.hip.hpp
src/include/blockwise_gemm.hip.hpp
+25
-500
src/include/threadwise_gemm.hip.hpp
src/include/threadwise_gemm.hip.hpp
+16
-19
No files found.
src/include/blockwise_gemm.hip.hpp
View file @
753b98b5
This diff is collapsed.
Click to expand it.
src/include/threadwise_gemm.hip.hpp
View file @
753b98b5
#pragma once
#include "inline_asm.hpp"
template
<
class
Float
,
class
SrcMatrix
,
class
DstMatrix
,
index_t
NRow
,
index_t
NCol
>
__device__
void
threadwise_matrix_copy
(
SrcMatrix
,
const
Float
*
__restrict__
p_src
,
...
...
@@ -21,18 +23,18 @@ __device__ void threadwise_matrix_copy(SrcMatrix,
p_dst[dst_index] = p_src[src_index];
}
}
#el
if
1
#el
se
static_assert
(
NCol
==
4
,
"only for NCol == 4"
);
using
vector_t
=
typename
vector_type
<
Float
,
4
>::
MemoryType
;
for
(
index_t
i
=
0
;
i
<
NRow
;
++
i
)
{
const
index_t
src_index
=
src_mtx
.
Get1dIndex
(
i
,
0
);
const
index_t
dst_index
=
dst_mtx
.
Get1dIndex
(
i
,
0
);
*
(
reinterpret_cast
<
vector_t
*>
(
&
p_dst
[
dst_index
]))
=
*
(
reinterpret_cast
<
const
vector_t
*>
(
&
p_src
[
src_index
]));
Float4
*
reg_p
=
(
Float4
*
)
&
p_dst
[
dst_index
];
Float4
*
loc_p
=
(
Float4
*
)
&
p_src
[
src_index
];
ds_read_b128
(
reg_p
[
0
],
(
void
*
)
&
loc_p
[
0
]);
}
#endif
}
...
...
@@ -70,25 +72,20 @@ __device__ void threadwise_gemm(MatrixA,
for
(
index_t
k
=
0
;
k
<
K
;
++
k
)
{
for
(
index_t
i
=
0
;
i
<
M
;
++
i
)
{
for
(
index_t
j
=
0
;
j
<
N
;
++
j
)
for
(
index_t
i
=
0
;
i
<
M
;
i
+=
4
)
{
const
index_t
aindex
=
a_mtx
.
Get1dIndex
(
k
,
i
);
// A is transposed
const
Float4
*
a_vec
=
(
const
Float4
*
)
&
p_a_thread
[
aindex
];
for
(
index_t
j
=
0
;
j
<
N
;
j
+=
4
)
{
const
index_t
bindex
=
b_mtx
.
Get1dIndex
(
k
,
j
);
const
index_t
cindex
=
c_mtx
.
Get1dIndex
(
i
,
j
);
#if 0
f_accum(p_c_thread[cindex], p_a_thread[aindex] * p_b_thread[bindex]);
#elif
1
asm
volatile
(
"
\n
\
v_mac_f32 %0, %1, %2
\n
\
"
:
"=v"
(
p_c_thread
[
cindex
])
:
"v"
(
p_a_thread
[
aindex
]),
"v"
(
p_b_thread
[
bindex
]),
"0"
(
p_c_thread
[
cindex
]));
#endif
const
Float4
*
b_vec
=
(
const
Float4
*
)
&
p_b_thread
[
bindex
];
Float4
*
c_vec
=
(
Float4
*
)
&
p_c_thread
[
cindex
];
outerProduct4x4
(
a_vec
[
0
],
b_vec
[
0
],
c_vec
[
0
],
c_vec
[
2
],
c_vec
[
4
],
c_vec
[
6
]);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment