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
e3e84e91
Commit
e3e84e91
authored
Sep 08, 2022
by
Po-Yen, Chen
Browse files
Let 'Block2TileMap' map block to 2d coordinate
parent
0399af7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
include/ck/tensor_operation/gpu/grid/gridwise_copy.hpp
include/ck/tensor_operation/gpu/grid/gridwise_copy.hpp
+13
-11
No files found.
include/ck/tensor_operation/gpu/grid/gridwise_copy.hpp
View file @
e3e84e91
...
@@ -21,7 +21,8 @@ struct Block2TileMap
...
@@ -21,7 +21,8 @@ struct Block2TileMap
static
constexpr
auto
I0
=
Number
<
0
>
{};
static
constexpr
auto
I0
=
Number
<
0
>
{};
static
constexpr
index_t
NumDim
=
TileDims
::
Size
();
static
constexpr
index_t
NumDim
=
TileDims
::
Size
();
static_assert
(
NumDim
==
GridDescriptor
::
GetNumOfDimension
());
static_assert
(
NumDim
==
2
);
static_assert
(
NumDim
<=
GridDescriptor
::
GetNumOfDimension
());
Block2TileMap
()
=
delete
;
Block2TileMap
()
=
delete
;
Block2TileMap
(
const
Block2TileMap
&
)
=
default
;
Block2TileMap
(
const
Block2TileMap
&
)
=
default
;
...
@@ -37,10 +38,10 @@ struct Block2TileMap
...
@@ -37,10 +38,10 @@ struct Block2TileMap
__host__
constexpr
index_t
CalculateGridSize
(
const
GridDescriptor
&
desc
)
const
__host__
constexpr
index_t
CalculateGridSize
(
const
GridDescriptor
&
desc
)
const
{
{
return
[
&
]()
{
return
[
&
]()
{
std
::
array
<
index_t
,
NumDim
>
num_tiles_per_axis
;
std
::
array
<
index_t
,
2
>
num_tiles_per_axis
;
static_for
<
0
,
NumDim
,
1
>
{}([
&
](
auto
I
)
{
static_for
<
NumDim
-
2
,
NumDim
,
1
>
{}([
&
](
auto
I
)
{
num_tiles_per_axis
[
I
]
=
num_tiles_per_axis
[
I
-
(
NumDim
-
2
)
]
=
math
::
integer_divide_ceil
(
desc
.
GetLength
(
I
),
TileDims
::
At
(
I
));
math
::
integer_divide_ceil
(
desc
.
GetLength
(
I
),
TileDims
::
At
(
I
-
(
NumDim
-
2
)
));
});
});
return
std
::
accumulate
(
begin
(
num_tiles_per_axis
),
return
std
::
accumulate
(
begin
(
num_tiles_per_axis
),
...
@@ -57,12 +58,13 @@ struct Block2TileMap
...
@@ -57,12 +58,13 @@ struct Block2TileMap
auto
block_1d_id
=
idx_top
[
I0
];
auto
block_1d_id
=
idx_top
[
I0
];
std
::
array
<
index_t
,
NumDim
>
num_tiles_per_axis
;
std
::
array
<
index_t
,
2
>
num_tiles_per_axis
;
static_for
<
0
,
NumDim
,
1
>
{}([
&
](
auto
I
)
{
static_for
<
NumDim
-
2
,
NumDim
,
1
>
{}([
&
](
auto
I
)
{
num_tiles_per_axis
[
I
]
=
math
::
integer_divide_ceil
(
desc_
.
GetLength
(
I
),
TileDims
::
At
(
I
));
num_tiles_per_axis
[
I
-
(
NumDim
-
2
)]
=
math
::
integer_divide_ceil
(
desc_
.
GetLength
(
I
),
TileDims
::
At
(
I
-
(
NumDim
-
2
)));
});
});
std
::
array
<
index_t
,
NumDim
>
divisors
;
std
::
array
<
index_t
,
2
>
divisors
;
index_t
product
=
1
;
index_t
product
=
1
;
auto
divisor
=
rbegin
(
divisors
);
auto
divisor
=
rbegin
(
divisors
);
for
(
auto
num_tiles
=
rbegin
(
num_tiles_per_axis
);
num_tiles
!=
rend
(
num_tiles_per_axis
);
for
(
auto
num_tiles
=
rbegin
(
num_tiles_per_axis
);
num_tiles
!=
rend
(
num_tiles_per_axis
);
...
@@ -79,7 +81,7 @@ struct Block2TileMap
...
@@ -79,7 +81,7 @@ struct Block2TileMap
[
&
](
auto
I
)
{
[
&
](
auto
I
)
{
return
(
block_1d_id
%
divisors
[
I
])
/
(
divisors
[
I
]
/
num_tiles_per_axis
[
I
]);
return
(
block_1d_id
%
divisors
[
I
])
/
(
divisors
[
I
]
/
num_tiles_per_axis
[
I
]);
},
},
Number
<
NumDim
>
{});
Number
<
2
>
{});
}
}
private:
private:
...
@@ -140,7 +142,7 @@ struct GridwiseCopy
...
@@ -140,7 +142,7 @@ struct GridwiseCopy
using
ThisThreadBlock
=
ThisThreadBlock
<
BlockSize
>
;
using
ThisThreadBlock
=
ThisThreadBlock
<
BlockSize
>
;
using
DefaultBlock2TileMap
=
using
DefaultBlock2TileMap
=
detail
::
Block2TileMap
<
Sequence
<
NPerBlock
,
HPerBlock
,
WPerBlock
>
,
InGrid1dDesc
>
;
detail
::
Block2TileMap
<
Sequence
<
HPerBlock
,
WPerBlock
>
,
InGrid1dDesc
>
;
__host__
__device__
static
constexpr
auto
GetInBlockDescriptor
()
__host__
__device__
static
constexpr
auto
GetInBlockDescriptor
()
{
{
...
...
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