Skip to content

[webgpu] Use different global index for flat and non-flat dispatch #5706

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

axinging
Copy link
Contributor

@axinging axinging commented Oct 9, 2021

This change is Reviewable

@google-cla google-cla bot added the cla: yes label Oct 9, 2021
@axinging
Copy link
Contributor Author

axinging commented Oct 9, 2021

@qjia7 @haoyunfeix @xhcao @gyagp PTAL

@@ -65,7 +65,7 @@ export class SliceProgram implements WebGPUProgram {

const userCode = `
${getMainHeaderString()} {
${getGlobalIndexString()}
${getGlobalIndexString(true)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SliceProgram uses the flat dispatch layout. Why pass true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, fixed.

Copy link
Contributor

@qjia7 qjia7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In high level, I think for non-flat dispatch, we shouldn't call ${getGlobalIndexString} at all. Our fixing should remove the dependency on getGlobalIndexString on non-flat dispatch.

let outputCoords : ${
outputCoordsType} = getOutputCoords(globalId, globalIndex);
outputCoordsType} = getOutputCoords(globalId, i32(globalId.x));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second parameter seems like meaningless for non-flat dispatch. You already passed globalId. But you still have to pass globalId.x. I prefer that you refactor getXXX method to remove the dependency of globalIndex. Similar for other places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants