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

Fix Clang compilation error with Lib ATen for ppc64le #106446

Closed
wants to merge 6 commits into from

Conversation

pratiklp00
Copy link
Contributor

@pratiklp00 pratiklp00 commented Aug 2, 2023

This patch fixes error while compiling with Clang for ppc64le
I have used clang version 15.0.7
Errors are as follow:

No matching function for call to 'vec_sel’
No matching function for call to 'vec_splats'
Excess elements in scalar initializer
Use of undeclared identifier 'vec_vsubudm'
Fix for multiple error within int64_t  DEFINE_MEMBER_OP_AND_ONE

References:

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 2, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/106446

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 5e03048 with merge base acd595e (image):

UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 2, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Aug 2, 2023
@ezyang ezyang requested a review from malfet August 2, 2023 13:37
@ezyang ezyang added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 2, 2023
@pratiklp00
Copy link
Contributor Author

@malfet @XiaobingSuper Hi, please let me know if there is any suggestion or change/comment

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Few remakrs:

  • Please specify clang version in PR description and reference some doc explaining why __attribute((altivec(vector__)) does not work for clang, but works for gcc , and vice versa (i.e. if say gcc-9+ supports __attribute__((vector_size(16)) as alternative to altivec attribute, perhaps entire code can be changed to it
  • Please explain why vint64 needs to be defined as signed long long rather than signed long or even int64_t? (This would also avoid force casting vec_splats, wouldn't it?)

Comment on lines 103 to 104
#if defined(__clang__)
#if !defined(vec_splats)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason not to combine the two?

Suggested change
#if defined(__clang__)
#if !defined(vec_splats)
#if defined(__clang__) && !defined(vec_splats)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I will combine it.

#if defined(__clang__)
#if !defined(vec_splats)
C10_ALWAYS_INLINE vint64 vec_splats(const int64_t& a) {
return vec_splats(static_cast<signed long long>(a));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check that int64_t and signed long long are different types, otherwise it feels like a tail recursion.

Suggested change
return vec_splats(static_cast<signed long long>(a));
static_assert(!std::is_same_v<int64_t, signed long long>, "Cast is meaningless here");
return vec_splats(static_cast<signed long long>(a));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it is not different. I will remove the casting.

@@ -37,7 +38,7 @@ class Vectorized<int64_t> {
C10_ALWAYS_INLINE Vectorized(vint64 v1, vint64 v2) : _vec0{v1}, _vec1{v2} {}
C10_ALWAYS_INLINE Vectorized(vbool64 v1, vbool64 v2) : _vecb0{v1}, _vecb1{v2} {}
C10_ALWAYS_INLINE Vectorized(int64_t scalar)
: _vec0{vec_splats(scalar)}, _vec1{vec_splats(scalar)} {}
: _vec0{vec_splats((ElementType)scalar)}, _vec1{(vint64)vec_splats((ElementType)scalar)} {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Those casts feel unnecessary after you've defined an overload in vsx_helpers.h aren't they?
In that case, please remove 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.

I have removed them.

@vinithakv
Copy link
Contributor

@pratiklp00
Some extra spaces reported by linter. Otherwise looks good to me.

@pratiklp00
Copy link
Contributor Author

@malfet Hi, I have made the required changes Please review it.

@pratiklp00
Copy link
Contributor Author

@malfet @ezyang @ezyang Hi Please let me know if any changes are required.

@malfet
Copy link
Contributor

malfet commented Nov 9, 2023

@pratiklp00 at the very list current form of the change break CI all over the place, can you please fix it?

@malfet
Copy link
Contributor

malfet commented Nov 9, 2023

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased libATenFix onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout libATenFix && git pull --rebase)

@malfet
Copy link
Contributor

malfet commented Nov 9, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 9, 2023
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@malfet malfet added release notes: build release notes category topic: bug fixes topic category labels Nov 9, 2023
@malfet
Copy link
Contributor

malfet commented Nov 9, 2023

@pytorchbot merge -f "Lint is green"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
This patch fixes error while compiling with Clang for ppc64le
I have used clang version 15.0.7
Errors are as follow:
```
No matching function for call to 'vec_sel’
No matching function for call to 'vec_splats'
Excess elements in scalar initializer
Use of undeclared identifier 'vec_vsubudm'
Fix for multiple error within int64_t  DEFINE_MEMBER_OP_AND_ONE
```
References:
- https://releases.llvm.org/9.0.0/tools/clang/docs/AttributeReference.html
- https://reviews.llvm.org/D81083

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>

Pull Request resolved: pytorch#106446
Approved by: https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source release notes: build release notes category topic: bug fixes topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants