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

[XLA:GPU] Add SPIRV-LLVM-Translator and translation pass #11424

Closed
wants to merge 1 commit into from

Conversation

ShengYang1
Copy link
Contributor

It is a sub PR of #9042 to add spirv-llvm-translator and translation pass

@kamaljeeti
Copy link
Contributor

Hi @penpornk , could you please review this PR? Thanks.

Copy link
Member

@penpornk penpornk left a comment

Choose a reason for hiding this comment

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

Thank you for the PR and sorry for the delay!

Comment on lines +9 to +22
- SPIRAS_Private,
+ SPIRAS_Generic,
SPIRAS_Global,
- SPIRAS_Constant,
+ SPIRAS_Internal,
SPIRAS_Local,
- SPIRAS_Generic,
+ SPIRAS_Constant,
+ SPIRAS_Private,
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, why do we need to reorder them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spir backend uses different addrspace representations link with nvptx backend link. We reorder the enum value here so that we can make xla llvm codegen simple(avoiding changing addrspace based on device backend everywhere)

Copy link
Member

Choose a reason for hiding this comment

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

This is useful context for people who are unfamiliar with the backend.

Could you please add this explanation in this patch file (between line 2 and 3)? I believe the patch tool will ignore anything above the --- a/lib/SPIRV/SPIRVInternal.h line. E.g.,

diff --git a/lib/SPIRV/SPIRVInternal.h b/lib/SPIRV/SPIRVInternal.h
index a828add8..924e13b4 100644

<Explanation here>

--- a/lib/SPIRV/SPIRVInternal.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 1121 to 1183
FeedLLVMWithFlags({"-slp-vectorize-hor=false"});

FeedLLVMWithFlags({
"-slp-min-reg-size=64",
"-slp-max-reg-size=64",
});
Copy link
Member

Choose a reason for hiding this comment

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

Can these be merged into one call?

Suggested change
FeedLLVMWithFlags({"-slp-vectorize-hor=false"});
FeedLLVMWithFlags({
"-slp-min-reg-size=64",
"-slp-max-reg-size=64",
});
FeedLLVMWithFlags({
"-slp-vectorize-hor=false"
"-slp-min-reg-size=64",
"-slp-max-reg-size=64",
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -1075,5 +1082,92 @@ absl::StatusOr<std::vector<uint8_t>> CompileToHsaco(

} // namespace amdgpu

namespace {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please add a blank line after this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

llvm::PassRegistry* registry = llvm::PassRegistry::getPassRegistry();
InitializePasses(registry);
}
} // namespace
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please add a blank line before this.
Please do the same for namespace spir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@github-actions github-actions bot added the kokoro:force-run Forces CI to rerun label May 8, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label May 8, 2024
Comment on lines +9 to +22
- SPIRAS_Private,
+ SPIRAS_Generic,
SPIRAS_Global,
- SPIRAS_Constant,
+ SPIRAS_Internal,
SPIRAS_Local,
- SPIRAS_Generic,
+ SPIRAS_Constant,
+ SPIRAS_Private,
Copy link
Member

Choose a reason for hiding this comment

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

This is useful context for people who are unfamiliar with the backend.

Could you please add this explanation in this patch file (between line 2 and 3)? I believe the patch tool will ignore anything above the --- a/lib/SPIRV/SPIRVInternal.h line. E.g.,

diff --git a/lib/SPIRV/SPIRVInternal.h b/lib/SPIRV/SPIRVInternal.h
index a828add8..924e13b4 100644

<Explanation here>

--- a/lib/SPIRV/SPIRVInternal.h

@github-actions github-actions bot added the kokoro:force-run Forces CI to rerun label May 8, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label May 8, 2024
Copy link
Member

@penpornk penpornk left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@NaiyerRizz
Copy link

Hi @penpornk
This PR has been approved but not yet merged, Can you please look into this.

@dimitar-asenov
Copy link
Member

@ShengYang1 Could you please rebase the PR on top of the latest state of the repo? Thanks!

@github-actions github-actions bot added the kokoro:force-run Forces CI to rerun label May 17, 2024
@ShengYang1
Copy link
Contributor Author

@ShengYang1 Could you please rebase the PR on top of the latest state of the repo? Thanks!

Done.

@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label May 17, 2024
Copy link
Member

@penpornk penpornk left a comment

Choose a reason for hiding this comment

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

Thank you!

@dimitar-asenov dimitar-asenov requested a review from ddunl May 17, 2024 11:26
@dimitar-asenov
Copy link
Member

@ddunl This fails to import internally because copybara isn't sure where to put the new spirv files. It seems like it requires some extra configuration. Could you please advise what's needed to merge this? Thanks.

@akuegel
Copy link
Member

akuegel commented May 24, 2024

@ddunl This fails to import internally because copybara isn't sure where to put the new spirv files. It seems like it requires some extra configuration. Could you please advise what's needed to merge this? Thanks.

TSL repository cannot be changed via PRs, you need to copy the changes manually as all changes to TSL repo are not imported.

@ShengYang1
Copy link
Contributor Author

@ddunl This fails to import internally because copybara isn't sure where to put the new spirv files. It seems like it requires some extra configuration. Could you please advise what's needed to merge this? Thanks.

TSL repository cannot be changed via PRs, you need to copy the changes manually as all changes to TSL repo are not imported.

@akuegel Should I submit another PR for tsl changes?

@akuegel
Copy link
Member

akuegel commented May 28, 2024

@ddunl This fails to import internally because copybara isn't sure where to put the new spirv files. It seems like it requires some extra configuration. Could you please advise what's needed to merge this? Thanks.

TSL repository cannot be changed via PRs, you need to copy the changes manually as all changes to TSL repo are not imported.

@akuegel Should I submit another PR for tsl changes?

No, unfortunately it can only be changed internally.

@xla-rotation importing this PR requires manual work, see comments above.

@akuegel akuegel requested a review from cheshire May 28, 2024 08:14
@dimitar-asenov
Copy link
Member

This PR needs #11425 to be submitted first together with some internal changes. I'm working on those. Once that other PR is in, I will look into this one.

copybara-service bot pushed a commit that referenced this pull request Aug 9, 2024
Imported from GitHub PR #11424

It is a sub PR of #9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76 by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76
PiperOrigin-RevId: 661176906
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661065795
@copybara-service copybara-service bot closed this in c4edf34 Aug 9, 2024
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 660362390
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661192298
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
Imported from GitHub PR openxla/xla#11424

It is a sub PR of openxla/xla#9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76e2b71120106ffae91945df9b974e74dec by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

PiperOrigin-RevId: 661186664
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
`protoc` has been warning of this unused import for a while now, so let's finally remove it
to clean up build logs.

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661195599
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 660608962
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661065783
@golechwierowicz
Copy link
Member

golechwierowicz commented Aug 9, 2024

This has not fully landed yet due to changes in tsl.

I'll let you know once this lands.

copybara-service bot pushed a commit to google/tsl that referenced this pull request Aug 9, 2024
Imported from GitHub PR openxla/xla#11424

It is a sub PR of openxla/xla#9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76e2b71120106ffae91945df9b974e74dec by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661222386
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
Imported from GitHub PR openxla/xla#11424

It is a sub PR of openxla/xla#9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76e2b71120106ffae91945df9b974e74dec by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661222386
@golechwierowicz
Copy link
Member

This change should be in.

copybara-service bot pushed a commit to google/tsl that referenced this pull request Aug 9, 2024
Imported from GitHub PR openxla/xla#11424

It is a sub PR of openxla/xla#9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76e2b71120106ffae91945df9b974e74dec by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

PiperOrigin-RevId: 661272459
copybara-service bot pushed a commit that referenced this pull request Aug 9, 2024
Imported from GitHub PR #11424

It is a sub PR of #9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76 by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

COPYBARA_INTEGRATE_REVIEW=#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76
PiperOrigin-RevId: 661272459
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
Imported from GitHub PR openxla/xla#11424

It is a sub PR of openxla/xla#9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76e2b71120106ffae91945df9b974e74dec by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

PiperOrigin-RevId: 661272459
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Aug 9, 2024
Some parts of it will likely be re-used in a different Dockerfile.

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76e2b71120106ffae91945df9b974e74dec
PiperOrigin-RevId: 661274311
sergachev pushed a commit that referenced this pull request Aug 12, 2024
Imported from GitHub PR #11424

It is a sub PR of #9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76 by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

COPYBARA_INTEGRATE_REVIEW=#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76
PiperOrigin-RevId: 661186664
sergachev pushed a commit that referenced this pull request Aug 12, 2024
Imported from GitHub PR #11424

It is a sub PR of #9042 to add spirv-llvm-translator and translation pass
Copybara import of the project:

--
6d8ce76 by Sheng, Yang <[email protected]>:

Add SPIRV-LLVM-Translator and translation pass

update comments and SPIRV-LLVM-Translator commit

Merging this change closes #11424

COPYBARA_INTEGRATE_REVIEW=#11424 from Intel-tensorflow:yang/llvm-spirv 6d8ce76
PiperOrigin-RevId: 661272459
@Zantares
Copy link

This change should be in.

We've been notified that the changes are merged and I have updated the internal PR track list, thank you very much!

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.

10 participants