-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CONV] fix naive conv kernel for large tensors #3434
base: develop
Are you sure you want to change the base?
Changes from all commits
888894f
64a278f
1665726
36fd522
3554b20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,11 +361,27 @@ GetConv2DFWDSolution(const ExecutionContext& ctx, const ::miopen::conv::ProblemD | |
size_t grid_size = 1; | ||
if(problem.IsLayoutDefault()) | ||
{ | ||
grid_size = static_cast<size_t>(n) * k; | ||
size_t all_workload = static_cast<size_t>(n) * k; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else if(problem.IsLayoutNHWC()) | ||
{ | ||
grid_size = static_cast<size_t>(group) * n * ho; | ||
size_t all_workload = static_cast<size_t>(group) * n * ho; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
Comment on lines
+376
to
+384
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel like the problem is solved here, actually I see a few more problems. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will implemented the kernel itself to handle the capped number of groups. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that a new kernel should be implemented, or the old one can be changed, or even the old one has already got this support and we should change anything - firstly it should be checked. Underloaded GPU problem should be fixed too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we don't need to modify the kernel. We could loop over the same kernel, adjusting the chunk size and buffer offsets as needed. This would handle the limitation of uint32_t in hipExtModuleLaunchKernel which currently overflows when we pass a global work size as gridX((589824 *256) *256 ). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was looking to see how we handle this issue in other locations (since it seems like it would be a global constraint). Looks like the batched_transpose solver also has a version of this issue (and seems somewhat likely we have this issue throughout MIOpen). For HIP this is a general constraint across any kernel launch I think:
I think we might need to come up with a general solution for this, and make sure it's implemented broadly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We don't, kind of. There are some places where the kernel is aware about number of workgroups limit and sometimes the number of workgroups is capped by some value like 4096. That's mostly it.
I'm not sure if thatcan be easily implemented. The main reason is that: the number of workgroups heavily depends on the algorithm and, the most important, on the kernel itself, and sometimes it even comes from heuristics. |
||
} | ||
else | ||
MIOPEN_THROW("Unsupported layout"); | ||
|
@@ -507,13 +523,30 @@ GetConv3DFWDSolution(const ExecutionContext& ctx, const ::miopen::conv::ProblemD | |
|
||
size_t block_size = 256; | ||
size_t grid_size = 1; | ||
|
||
if(problem.IsLayoutDefault()) | ||
{ | ||
grid_size = static_cast<size_t>(n) * k; | ||
size_t all_workload = static_cast<size_t>(n) * k; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else if(problem.IsLayoutNHWC()) | ||
{ | ||
grid_size = static_cast<size_t>(group) * n * do_; | ||
size_t all_workload = static_cast<size_t>(group) * n * do_; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else | ||
MIOPEN_THROW("Unsupported layout"); | ||
|
@@ -867,11 +900,27 @@ GetConv2DBWDSolution(const ExecutionContext& ctx, const ::miopen::conv::ProblemD | |
size_t grid_size = 1; | ||
if(problem.IsLayoutDefault()) | ||
{ | ||
grid_size = static_cast<size_t>(n) * c; | ||
size_t all_workload = static_cast<size_t>(n) * c; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else if(problem.IsLayoutNHWC()) | ||
{ | ||
grid_size = static_cast<size_t>(group) * n * hi; | ||
size_t all_workload = static_cast<size_t>(group) * n * hi; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else | ||
{ | ||
|
@@ -1017,11 +1066,27 @@ GetConv3DBWDSolution(const ExecutionContext& ctx, const ::miopen::conv::ProblemD | |
size_t grid_size = 1; | ||
if(problem.IsLayoutDefault()) | ||
{ | ||
grid_size = static_cast<size_t>(n) * c; | ||
size_t all_workload = static_cast<size_t>(n) * c; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else if(problem.IsLayoutNHWC()) | ||
{ | ||
grid_size = static_cast<size_t>(group) * n * di; | ||
size_t all_workload = static_cast<size_t>(group) * n * di; | ||
if(all_workload <= block_size) | ||
{ | ||
grid_size = all_workload; | ||
} | ||
else | ||
{ | ||
grid_size = (all_workload + block_size - 1) / block_size; | ||
} | ||
} | ||
else | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #2748
It is an integer
Ceil()
function.It's just a reminder that the problem still exists.