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

[CINN] Add the ReplaceCrossBlockReduction backend pass #68364

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

lshpku
Copy link
Contributor

@lshpku lshpku commented Sep 22, 2024

PR Category

CINN

PR Types

New features

Description

This PR adds the ReplaceCrossBlockReduction pass in optim::Optimize, and provides the CUDA implementations for grid_reduce and update_semaphore.

The ReplaceCrossBlockReduction pass performs the following tasks:

  • Replaces the cross-block reduction with an external call to grid_reduce.
  • Adds a condition check is_last_block_done to the reduction operation and all subsequent schedule blocks.
  • Adds global buffers (rf and semaphore) to the function’s argument list.

Example:

function reduce_sum (..., var_1)
{
  thread_bind[blockIdx.x] for (i, 0, 16):
    thread_bind[blockIdx.y] for (j, 0, 8): // reduce axis
      var_1[i] += var_1_rf[j, i]
}

After pass:

function reduce_sum (..., var_1, var_1_rf, semaphore)
{
  thread_bind[blockIdx.x] for (i, 0, 16):
    thread_bind[blockIdx.y] for (j, 0, 8): // reduce axis
      is_last_block_done = update_semaphore(semaphore)
      if (is_last_block_done):
        var_1[i] = grid_reduce_sum(var_1_rf)
}


Pcard-85711

@lshpku lshpku force-pushed the replace_grid_reduce branch 2 times, most recently from 0697610 to 6b78d4b Compare September 24, 2024 16:50
Copy link

paddle-ci-bot bot commented Oct 2, 2024

Sorry to inform you that 6b78d4b's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@lshpku lshpku force-pushed the replace_grid_reduce branch from 6b78d4b to d61ca74 Compare October 8, 2024 03:22
@lshpku lshpku force-pushed the replace_grid_reduce branch from d61ca74 to f66c33e Compare October 9, 2024 16:17
@zyfncg zyfncg merged commit 418fcf1 into PaddlePaddle:develop Oct 11, 2024
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants