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

Using kernel specific max work group size instead of device max work … #542

Merged
merged 3 commits into from
Jul 11, 2024
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
8 changes: 4 additions & 4 deletions src/ATen/native/xpu/sycl/ActivationGluKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ void launch_glu_backward_kernel(
OffsetCalc offset_calculator,
int64_t gI_byte_offset,
int64_t I_byte_offset) {
const int64_t local_size = syclMaxWorkGroupSize();
const int64_t num_wg = (numel + local_size - 1) / local_size;
const int64_t global_size = num_wg * local_size;

GluBackwardKernelFunctor<scalar_t, OffsetCalc> kfn(
numel, gI, I, gO, offset_calculator, gI_byte_offset, I_byte_offset);

const int64_t local_size = syclMaxWorkGroupSize(kfn);
const int64_t num_wg = (numel + local_size - 1) / local_size;
const int64_t global_size = num_wg * local_size;

sycl_kernel_submit(global_size, local_size, getCurrentSYCLQueue(), kfn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct AdaptiveAvgPool2dBwdSLMKernelFunctor
numel_ = ib_ * ic_ * ih_ * iw_;
int total_item = std::min(numel_, syclMaxWorkItemsPerTile());

local_range_ = syclMaxWorkGroupSize();
local_range_ = syclMaxWorkGroupSize(*this);
global_range_ = total_item < local_range_
? local_range_
: (total_item / local_range_) * local_range_;
Expand Down
15 changes: 10 additions & 5 deletions src/ATen/native/xpu/sycl/BatchKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BatchKernelConfig {
problem_batch_(problem_batch),
problem_along_x_(problem_along_x),
policy_(policy_combine(policies)),
prefer_wg_size_(prefer_wg_size),
problem_wg_range_(0),
problem_glb_range_(0),
problem_range_(0),
Expand All @@ -47,12 +48,15 @@ class BatchKernelConfig {
glb_range_x_(0),
glb_range_y_(0),
wg_range_x_(0),
wg_range_y_(0) {
size_t wg_size = syclMaxWorkGroupSize();
wg_range_y_(0) {}

template <class KernelClass>
void build() {
size_t wg_size = syclMaxWorkGroupSize<KernelClass>();
size_t sg_size = syclMaxSubGroupSize();
if (prefer_wg_size != 0 && prefer_wg_size % sg_size == 0 &&
prefer_wg_size < wg_size) {
wg_size = prefer_wg_size;
if (prefer_wg_size_ != 0 && prefer_wg_size_ % sg_size == 0 &&
prefer_wg_size_ < wg_size) {
wg_size = prefer_wg_size_;
}
wg_range_x_ = sg_size;
wg_range_y_ = wg_size / wg_range_x_;
Expand Down Expand Up @@ -263,6 +267,7 @@ class BatchKernelConfig {
/* logical active batch */ int64_t problem_batch_;
bool problem_along_x_;
Policy policy_;
size_t prefer_wg_size_;
int64_t problem_wg_range_;
int64_t problem_glb_range_;
size_t problem_range_;
Expand Down
Loading