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

[ROCm] torch.sum optimization by increasing min_values_per_thread #1591

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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: 6 additions & 4 deletions aten/src/ATen/native/cuda/Reduce.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -1091,14 +1091,16 @@ ReduceConfig setReduceConfig(const TensorIterator& iter){
config.output_mult[0] = config.split_output(block_width);
}

#ifdef USE_ROCM
// AMD gpus perform better with fewer thread blocks
constexpr int min_values_per_thread = 128;
constexpr int max_values_per_thread = 1024;
#else
constexpr int min_values_per_thread = 16;
#ifndef USE_ROCM
constexpr int max_values_per_thread = 256;
#else
constexpr int max_values_per_thread = 1024;
#endif

if (config.values_per_thread() >= block_height * 16 || config.values_per_thread() >= max_values_per_thread) {
if (config.values_per_thread() >= block_height * min_values_per_thread || config.values_per_thread() >= max_values_per_thread) {
// Divide the input across warps in a thread-block, if that leaves at least
// 16 elements to be summed by each thread. This will require inter-warp
// reduction using shared memory.
Expand Down