Skip to content
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

[OpenCL] Fix cl_context gen_lwss bugs #6734

Merged
merged 3 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lite/backends/opencl/cl_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ cl::NDRange CLContext::DefaultGlobalWorkSize(const CLImage &image) {
std::set<cl::NDRange, CLContext::CompareByRange>
CLContext::GenerateLocalWorkSizes(cl::NDRange gws, size_t max_ws) {
size_t tune_type = CLRuntime::Global()->auto_tune();
auto first_lws = DefaultLocalWorkSize(gws, max_ws, 3, false);
auto first_lws = DefaultLocalWorkSize(gws, max_ws, tune_type, 3, false);
std::set<cl::NDRange, CompareByRange> lwss;
for (auto one_lws : first_lws) {
lwss.insert(one_lws);
Expand All @@ -139,7 +139,7 @@ CLContext::GenerateLocalWorkSizes(cl::NDRange gws, size_t max_ws) {
for (bool tune_reverse : tune_reverses) {
for (size_t divisor : divisors) {
std::set<cl::NDRange, CompareByRange> tmp_lws =
DefaultLocalWorkSize(gws, max_ws, divisor, tune_reverse);
DefaultLocalWorkSize(gws, max_ws, tune_type, divisor, tune_reverse);
for (cl::NDRange one_lws : tmp_lws) {
lwss.insert(one_lws);
}
Expand Down Expand Up @@ -230,6 +230,7 @@ CLContext::GenerateLocalWorkSizes(cl::NDRange gws, size_t max_ws) {
std::set<cl::NDRange, CLContext::CompareByRange>
CLContext::DefaultLocalWorkSize(const cl::NDRange &gws,
register size_t max_ws,
size_t tune_type /*=0*/,
const int &divisor /*=2*/,
const bool &reverse /*=false*/,
const size_t &user_def_max_ws /*=0*/) {
Expand Down Expand Up @@ -266,7 +267,10 @@ CLContext::DefaultLocalWorkSize(const cl::NDRange &gws,
}
ly_src = (ly_src & 0x01) ? 1 : ly_src >> 1;
} while (ly_src > 1);

if (tune_type == lite_api::CL_TUNE_NONE && lws_set.empty()) {
lws_set.insert(
(reverse ? cl::NDRange{lz, ly, lx} : cl::NDRange{lx, ly, lz}));
}
return lws_set;
}

Expand Down
1 change: 1 addition & 0 deletions lite/backends/opencl/cl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class CLContext {
std::set<cl::NDRange, CompareByRange> DefaultLocalWorkSize(
const cl::NDRange &global_work_size,
register size_t max_work_size,
size_t tune_type = 0,
const int &divitor = 2,
const bool &tune_reverse = false,
const size_t &user_defined_max_work_size = 0);
Expand Down